mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Merge pull request #3042 from akortunov/helpers
Refactoring pre-requisites for groundcover
This commit is contained in:
commit
e68651e9a6
8 changed files with 52 additions and 25 deletions
|
@ -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
|
||||
{
|
||||
public:
|
||||
|
@ -530,7 +521,7 @@ namespace MWRender
|
|||
|
||||
osg::ref_ptr<osg::Group> group = 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);
|
||||
CopyOp copyop;
|
||||
for (const auto& pair : nodes)
|
||||
|
@ -596,7 +587,7 @@ namespace MWRender
|
|||
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
|
||||
templateRefs->mObjects.emplace_back(cnode);
|
||||
templateRefs->addRef(cnode);
|
||||
|
||||
if (pair.second.mNeedCompile)
|
||||
{
|
||||
|
|
|
@ -1134,6 +1134,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
|
|||
, mRainEntranceSpeed(1)
|
||||
, mRainMaxRaindrops(0)
|
||||
, mWindSpeed(0.f)
|
||||
, mBaseWindSpeed(0.f)
|
||||
, mEnabled(true)
|
||||
, mSunEnabled(true)
|
||||
, mWeatherAlpha(0.f)
|
||||
|
@ -1685,6 +1686,7 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||
mRainMaxHeight = weather.mRainMaxHeight;
|
||||
mRainSpeed = weather.mRainSpeed;
|
||||
mWindSpeed = weather.mWindSpeed;
|
||||
mBaseWindSpeed = weather.mBaseWindSpeed;
|
||||
|
||||
if (mRainEffect != weather.mRainEffect)
|
||||
{
|
||||
|
@ -1853,6 +1855,13 @@ void SkyManager::setWeather(const WeatherResult& weather)
|
|||
fader->setAlpha(weather.mEffectFade);
|
||||
}
|
||||
|
||||
float SkyManager::getBaseWindSpeed() const
|
||||
{
|
||||
if (!mCreated) return 0.f;
|
||||
|
||||
return mBaseWindSpeed;
|
||||
}
|
||||
|
||||
void SkyManager::sunEnable()
|
||||
{
|
||||
if (!mCreated) return;
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace MWRender
|
|||
float mDLFogOffset;
|
||||
|
||||
float mWindSpeed;
|
||||
float mBaseWindSpeed;
|
||||
float mCurrentWindSpeed;
|
||||
float mNextWindSpeed;
|
||||
|
||||
|
@ -181,6 +182,8 @@ namespace MWRender
|
|||
|
||||
void setRainIntensityUniform(osg::Uniform *uniform);
|
||||
|
||||
float getBaseWindSpeed() const;
|
||||
|
||||
private:
|
||||
void create();
|
||||
///< no need to call this, automatically done on first enable()
|
||||
|
@ -265,6 +268,7 @@ namespace MWRender
|
|||
float mRainEntranceSpeed;
|
||||
int mRainMaxRaindrops;
|
||||
float mWindSpeed;
|
||||
float mBaseWindSpeed;
|
||||
|
||||
bool mEnabled;
|
||||
bool mSunEnabled;
|
||||
|
|
|
@ -1123,6 +1123,7 @@ inline void WeatherManager::calculateResult(const int weatherID, const float gam
|
|||
mResult.mCloudBlendFactor = 0;
|
||||
mResult.mNextWindSpeed = 0;
|
||||
mResult.mWindSpeed = mResult.mCurrentWindSpeed = calculateWindSpeed(weatherID, mWindSpeed);
|
||||
mResult.mBaseWindSpeed = mWeatherSettings[weatherID].mWindSpeed;
|
||||
|
||||
mResult.mCloudSpeed = current.mCloudSpeed;
|
||||
mResult.mGlareView = current.mGlareView;
|
||||
|
@ -1214,6 +1215,7 @@ inline void WeatherManager::calculateTransitionResult(const float factor, const
|
|||
|
||||
mResult.mCurrentWindSpeed = calculateWindSpeed(mCurrentWeather, mCurrentWindSpeed);
|
||||
mResult.mNextWindSpeed = calculateWindSpeed(mNextWeather, mNextWindSpeed);
|
||||
mResult.mBaseWindSpeed = lerp(current.mBaseWindSpeed, other.mBaseWindSpeed, factor);
|
||||
|
||||
mResult.mWindSpeed = lerp(mResult.mCurrentWindSpeed, mResult.mNextWindSpeed, factor);
|
||||
mResult.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed, factor);
|
||||
|
|
|
@ -54,6 +54,11 @@ struct Position
|
|||
{
|
||||
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)
|
||||
|
||||
|
|
|
@ -110,6 +110,10 @@ namespace
|
|||
|
||||
namespace Resource
|
||||
{
|
||||
void TemplateMultiRef::addRef(const osg::Node* node)
|
||||
{
|
||||
mObjects.emplace_back(node);
|
||||
}
|
||||
|
||||
class SharedStateManager : public osgDB::SharedStateManager
|
||||
{
|
||||
|
@ -554,20 +558,6 @@ namespace Resource
|
|||
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<const osg::Node> scene = getTemplate(name);
|
||||
|
|
|
@ -37,6 +37,31 @@ namespace Shader
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -121,6 +121,7 @@ void registerSerializers()
|
|||
const char* ignore[] = {
|
||||
"MWRender::PtrHolder",
|
||||
"Resource::TemplateRef",
|
||||
"Resource::TemplateMultiRef",
|
||||
"SceneUtil::CompositeStateSetUpdater",
|
||||
"SceneUtil::LightListCallback",
|
||||
"SceneUtil::LightManagerUpdateCallback",
|
||||
|
|
Loading…
Reference in a new issue