mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Merge pull request #3042 from akortunov/helpers
Refactoring pre-requisites for groundcover
This commit is contained in:
commit
e68651e9a6
@ -249,15 +249,6 @@ namespace MWRender
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TemplateRef : public osg::Object
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TemplateRef() {}
|
|
||||||
TemplateRef(const TemplateRef& copy, const osg::CopyOp&) : mObjects(copy.mObjects) {}
|
|
||||||
META_Object(MWRender, TemplateRef)
|
|
||||||
std::vector<osg::ref_ptr<const Object>> mObjects;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RefnumSet : public osg::Object
|
class RefnumSet : public osg::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -530,7 +521,7 @@ namespace MWRender
|
|||||||
|
|
||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
osg::ref_ptr<osg::Group> mergeGroup = new osg::Group;
|
osg::ref_ptr<osg::Group> mergeGroup = new osg::Group;
|
||||||
osg::ref_ptr<TemplateRef> templateRefs = new TemplateRef;
|
osg::ref_ptr<Resource::TemplateMultiRef> templateRefs = new Resource::TemplateMultiRef;
|
||||||
osgUtil::StateToCompile stateToCompile(0, nullptr);
|
osgUtil::StateToCompile stateToCompile(0, nullptr);
|
||||||
CopyOp copyop;
|
CopyOp copyop;
|
||||||
for (const auto& pair : nodes)
|
for (const auto& pair : nodes)
|
||||||
@ -596,7 +587,7 @@ namespace MWRender
|
|||||||
if (numinstances > 0)
|
if (numinstances > 0)
|
||||||
{
|
{
|
||||||
// add a ref to the original template, to hint to the cache that it's still being used and should be kept in cache
|
// add a ref to the original template, to hint to the cache that it's still being used and should be kept in cache
|
||||||
templateRefs->mObjects.emplace_back(cnode);
|
templateRefs->addRef(cnode);
|
||||||
|
|
||||||
if (pair.second.mNeedCompile)
|
if (pair.second.mNeedCompile)
|
||||||
{
|
{
|
||||||
|
@ -1134,6 +1134,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
|
|||||||
, mRainEntranceSpeed(1)
|
, mRainEntranceSpeed(1)
|
||||||
, mRainMaxRaindrops(0)
|
, mRainMaxRaindrops(0)
|
||||||
, mWindSpeed(0.f)
|
, mWindSpeed(0.f)
|
||||||
|
, mBaseWindSpeed(0.f)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
, mSunEnabled(true)
|
, mSunEnabled(true)
|
||||||
, mWeatherAlpha(0.f)
|
, mWeatherAlpha(0.f)
|
||||||
@ -1685,6 +1686,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||||||
mRainMaxHeight = weather.mRainMaxHeight;
|
mRainMaxHeight = weather.mRainMaxHeight;
|
||||||
mRainSpeed = weather.mRainSpeed;
|
mRainSpeed = weather.mRainSpeed;
|
||||||
mWindSpeed = weather.mWindSpeed;
|
mWindSpeed = weather.mWindSpeed;
|
||||||
|
mBaseWindSpeed = weather.mBaseWindSpeed;
|
||||||
|
|
||||||
if (mRainEffect != weather.mRainEffect)
|
if (mRainEffect != weather.mRainEffect)
|
||||||
{
|
{
|
||||||
@ -1853,6 +1855,13 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||||||
fader->setAlpha(weather.mEffectFade);
|
fader->setAlpha(weather.mEffectFade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SkyManager::getBaseWindSpeed() const
|
||||||
|
{
|
||||||
|
if (!mCreated) return 0.f;
|
||||||
|
|
||||||
|
return mBaseWindSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
void SkyManager::sunEnable()
|
void SkyManager::sunEnable()
|
||||||
{
|
{
|
||||||
if (!mCreated) return;
|
if (!mCreated) return;
|
||||||
|
@ -70,6 +70,7 @@ namespace MWRender
|
|||||||
float mDLFogOffset;
|
float mDLFogOffset;
|
||||||
|
|
||||||
float mWindSpeed;
|
float mWindSpeed;
|
||||||
|
float mBaseWindSpeed;
|
||||||
float mCurrentWindSpeed;
|
float mCurrentWindSpeed;
|
||||||
float mNextWindSpeed;
|
float mNextWindSpeed;
|
||||||
|
|
||||||
@ -181,6 +182,8 @@ namespace MWRender
|
|||||||
|
|
||||||
void setRainIntensityUniform(osg::Uniform *uniform);
|
void setRainIntensityUniform(osg::Uniform *uniform);
|
||||||
|
|
||||||
|
float getBaseWindSpeed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create();
|
void create();
|
||||||
///< no need to call this, automatically done on first enable()
|
///< no need to call this, automatically done on first enable()
|
||||||
@ -265,6 +268,7 @@ namespace MWRender
|
|||||||
float mRainEntranceSpeed;
|
float mRainEntranceSpeed;
|
||||||
int mRainMaxRaindrops;
|
int mRainMaxRaindrops;
|
||||||
float mWindSpeed;
|
float mWindSpeed;
|
||||||
|
float mBaseWindSpeed;
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
bool mSunEnabled;
|
bool mSunEnabled;
|
||||||
|
@ -1123,6 +1123,7 @@ inline void WeatherManager::calculateResult(const int weatherID, const float gam
|
|||||||
mResult.mCloudBlendFactor = 0;
|
mResult.mCloudBlendFactor = 0;
|
||||||
mResult.mNextWindSpeed = 0;
|
mResult.mNextWindSpeed = 0;
|
||||||
mResult.mWindSpeed = mResult.mCurrentWindSpeed = calculateWindSpeed(weatherID, mWindSpeed);
|
mResult.mWindSpeed = mResult.mCurrentWindSpeed = calculateWindSpeed(weatherID, mWindSpeed);
|
||||||
|
mResult.mBaseWindSpeed = mWeatherSettings[weatherID].mWindSpeed;
|
||||||
|
|
||||||
mResult.mCloudSpeed = current.mCloudSpeed;
|
mResult.mCloudSpeed = current.mCloudSpeed;
|
||||||
mResult.mGlareView = current.mGlareView;
|
mResult.mGlareView = current.mGlareView;
|
||||||
@ -1214,6 +1215,7 @@ inline void WeatherManager::calculateTransitionResult(const float factor, const
|
|||||||
|
|
||||||
mResult.mCurrentWindSpeed = calculateWindSpeed(mCurrentWeather, mCurrentWindSpeed);
|
mResult.mCurrentWindSpeed = calculateWindSpeed(mCurrentWeather, mCurrentWindSpeed);
|
||||||
mResult.mNextWindSpeed = calculateWindSpeed(mNextWeather, mNextWindSpeed);
|
mResult.mNextWindSpeed = calculateWindSpeed(mNextWeather, mNextWindSpeed);
|
||||||
|
mResult.mBaseWindSpeed = lerp(current.mBaseWindSpeed, other.mBaseWindSpeed, factor);
|
||||||
|
|
||||||
mResult.mWindSpeed = lerp(mResult.mCurrentWindSpeed, mResult.mNextWindSpeed, factor);
|
mResult.mWindSpeed = lerp(mResult.mCurrentWindSpeed, mResult.mNextWindSpeed, factor);
|
||||||
mResult.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed, factor);
|
mResult.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed, factor);
|
||||||
|
@ -54,6 +54,11 @@ struct Position
|
|||||||
{
|
{
|
||||||
return osg::Vec3f(pos[0], pos[1], pos[2]);
|
return osg::Vec3f(pos[0], pos[1], pos[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::Vec3f asRotationVec3() const
|
||||||
|
{
|
||||||
|
return osg::Vec3f(rot[0], rot[1], rot[2]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
@ -110,6 +110,10 @@ namespace
|
|||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
void TemplateMultiRef::addRef(const osg::Node* node)
|
||||||
|
{
|
||||||
|
mObjects.emplace_back(node);
|
||||||
|
}
|
||||||
|
|
||||||
class SharedStateManager : public osgDB::SharedStateManager
|
class SharedStateManager : public osgDB::SharedStateManager
|
||||||
{
|
{
|
||||||
@ -554,20 +558,6 @@ namespace Resource
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TemplateRef : public osg::Object
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TemplateRef(const Object* object)
|
|
||||||
: mObject(object) {}
|
|
||||||
TemplateRef() {}
|
|
||||||
TemplateRef(const TemplateRef& copy, const osg::CopyOp&) : mObject(copy.mObject) {}
|
|
||||||
|
|
||||||
META_Object(Resource, TemplateRef)
|
|
||||||
|
|
||||||
private:
|
|
||||||
osg::ref_ptr<const Object> mObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> SceneManager::createInstance(const std::string& name)
|
osg::ref_ptr<osg::Node> SceneManager::createInstance(const std::string& name)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<const osg::Node> scene = getTemplate(name);
|
osg::ref_ptr<const osg::Node> scene = getTemplate(name);
|
||||||
|
@ -37,6 +37,31 @@ namespace Shader
|
|||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
class TemplateRef : public osg::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TemplateRef(const Object* object) : mObject(object) {}
|
||||||
|
TemplateRef() {}
|
||||||
|
TemplateRef(const TemplateRef& copy, const osg::CopyOp&) : mObject(copy.mObject) {}
|
||||||
|
|
||||||
|
META_Object(Resource, TemplateRef)
|
||||||
|
|
||||||
|
private:
|
||||||
|
osg::ref_ptr<const Object> mObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TemplateMultiRef : public osg::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TemplateMultiRef() {}
|
||||||
|
TemplateMultiRef(const TemplateMultiRef& copy, const osg::CopyOp&) : mObjects(copy.mObjects) {}
|
||||||
|
void addRef(const osg::Node* node);
|
||||||
|
|
||||||
|
META_Object(Resource, TemplateMultiRef)
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<osg::ref_ptr<const Object>> mObjects;
|
||||||
|
};
|
||||||
|
|
||||||
class MultiObjectCache;
|
class MultiObjectCache;
|
||||||
|
|
||||||
|
@ -121,6 +121,7 @@ void registerSerializers()
|
|||||||
const char* ignore[] = {
|
const char* ignore[] = {
|
||||||
"MWRender::PtrHolder",
|
"MWRender::PtrHolder",
|
||||||
"Resource::TemplateRef",
|
"Resource::TemplateRef",
|
||||||
|
"Resource::TemplateMultiRef",
|
||||||
"SceneUtil::CompositeStateSetUpdater",
|
"SceneUtil::CompositeStateSetUpdater",
|
||||||
"SceneUtil::LightListCallback",
|
"SceneUtil::LightListCallback",
|
||||||
"SceneUtil::LightManagerUpdateCallback",
|
"SceneUtil::LightManagerUpdateCallback",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user