mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-14 01:19:59 +00:00
move rendering related code to mwrender
This commit is contained in:
parent
ea1b89741a
commit
935df3a239
@ -8,34 +8,6 @@
|
||||
#include "../mwrender/vismask.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
class LeafParamsAssigner : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
LeafParamsAssigner(const MWWorld::LiveCellRef<ESM4::Tree>* treeRef)
|
||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||
, mTreeRef(treeRef)
|
||||
, mVertexAttrib(new osg::Vec3Array(1))
|
||||
, mTimeOffset(Misc::Rng::roll0to99())
|
||||
{
|
||||
mVertexAttrib->at(0) = osg::Vec3f(
|
||||
mTreeRef->mBase->mParams.mLeafAmplitude, mTreeRef->mBase->mParams.mLeafFrequency, mTimeOffset);
|
||||
}
|
||||
|
||||
void apply(osg::Geometry& geometry) override
|
||||
{
|
||||
geometry.setVertexAttribArray(7, mVertexAttrib, osg::Array::BIND_OVERALL);
|
||||
|
||||
traverse(geometry);
|
||||
}
|
||||
|
||||
const MWWorld::LiveCellRef<ESM4::Tree>* mTreeRef = nullptr;
|
||||
osg::ref_ptr<osg::Vec3Array> mVertexAttrib = nullptr;
|
||||
float mTimeOffset = 0.f;
|
||||
};
|
||||
}
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
ESM4Tree::ESM4Tree()
|
||||
@ -49,10 +21,6 @@ namespace MWClass
|
||||
if (!model.empty())
|
||||
{
|
||||
renderingInterface.getObjects().insertModel(ptr, model);
|
||||
|
||||
LeafParamsAssigner nv{ ptr.get<ESM4::Tree>() };
|
||||
ptr.getRefData().getBaseNode()->accept(nv);
|
||||
|
||||
ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <components/esm3/loadnpc.hpp>
|
||||
#include <components/esm3/loadrace.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadtree.hpp>
|
||||
|
||||
#include <components/misc/constants.hpp>
|
||||
#include <components/misc/pathhelpers.hpp>
|
||||
@ -67,6 +68,31 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
class LeafParamsAssigner : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
LeafParamsAssigner(const MWWorld::LiveCellRef<ESM4::Tree>* treeRef)
|
||||
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||
, mTreeRef(treeRef)
|
||||
, mVertexAttrib(new osg::Vec3Array(1))
|
||||
, mTimeOffset(Misc::Rng::roll0to99())
|
||||
{
|
||||
mVertexAttrib->at(0) = osg::Vec3f(
|
||||
mTreeRef->mBase->mParams.mLeafAmplitude, mTreeRef->mBase->mParams.mLeafFrequency, mTimeOffset);
|
||||
}
|
||||
|
||||
void apply(osg::Geometry& geometry) override
|
||||
{
|
||||
geometry.setVertexAttribArray(7, mVertexAttrib, osg::Array::BIND_OVERALL);
|
||||
|
||||
traverse(geometry);
|
||||
}
|
||||
|
||||
const MWWorld::LiveCellRef<ESM4::Tree>* mTreeRef = nullptr;
|
||||
osg::ref_ptr<osg::Vec3Array> mVertexAttrib = nullptr;
|
||||
float mTimeOffset = 0.f;
|
||||
};
|
||||
|
||||
class MarkDrawablesVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
@ -2079,6 +2105,11 @@ namespace MWRender
|
||||
addExtraLight(getOrCreateObjectRoot(), SceneUtil::LightCommon(*ptr.get<ESM::Light>()->mBase));
|
||||
if (ptr.getType() == ESM4::Light::sRecordId && allowLight)
|
||||
addExtraLight(getOrCreateObjectRoot(), SceneUtil::LightCommon(*ptr.get<ESM4::Light>()->mBase));
|
||||
if (ptr.getType() == ESM4::Tree::sRecordId)
|
||||
{
|
||||
LeafParamsAssigner nv{ ptr.get<ESM4::Tree>() };
|
||||
ptr.getRefData().getBaseNode()->accept(nv);
|
||||
}
|
||||
|
||||
if (!allowLight && mObjectRoot)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user