mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-05 11:15:32 +00:00
Merge branch 'magic_numbers' into 'master'
compromise on magic numbers making things easier to follow See merge request OpenMW/openmw!181
This commit is contained in:
commit
65a669344b
7 changed files with 30 additions and 15 deletions
|
@ -10,9 +10,6 @@ namespace CSVRender
|
||||||
/// @copydoc MWRender::VisMask
|
/// @copydoc MWRender::VisMask
|
||||||
enum Mask
|
enum Mask
|
||||||
{
|
{
|
||||||
// internal use within NifLoader, do not change
|
|
||||||
Mask_UpdateVisitor = 0x1,
|
|
||||||
|
|
||||||
// elements that are part of the actual scene
|
// elements that are part of the actual scene
|
||||||
Mask_Reference = 0x2,
|
Mask_Reference = 0x2,
|
||||||
Mask_Pathgrid = 0x4,
|
Mask_Pathgrid = 0x4,
|
||||||
|
|
|
@ -88,8 +88,6 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
// Add ability to signal osg to show its statistics for debugging purposes
|
// Add ability to signal osg to show its statistics for debugging purposes
|
||||||
mView->addEventHandler(new osgViewer::StatsHandler);
|
mView->addEventHandler(new osgViewer::StatsHandler);
|
||||||
|
|
||||||
mView->getCamera()->setCullMask(~(Mask_UpdateVisitor));
|
|
||||||
|
|
||||||
viewer.addView(mView);
|
viewer.addView(mView);
|
||||||
viewer.setDone(false);
|
viewer.setDone(false);
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
|
#include <components/nifosg/nifloader.hpp>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
@ -373,6 +375,7 @@ namespace MWRender
|
||||||
mViewer->getCamera()->setCullingMode(cullingMode);
|
mViewer->getCamera()->setCullingMode(cullingMode);
|
||||||
|
|
||||||
mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater));
|
mViewer->getCamera()->setCullMask(~(Mask_UpdateVisitor|Mask_SimpleWater));
|
||||||
|
NifOsg::Loader::setHiddenNodeMask(Mask_UpdateVisitor);
|
||||||
|
|
||||||
mNearClip = Settings::Manager::getFloat("near clip", "Camera");
|
mNearClip = Settings::Manager::getFloat("near clip", "Camera");
|
||||||
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
|
mViewDistance = Settings::Manager::getFloat("viewing distance", "Camera");
|
||||||
|
|
|
@ -269,12 +269,14 @@ void UVController::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VisController::VisController(const Nif::NiVisData *data)
|
VisController::VisController(const Nif::NiVisData *data, unsigned int mask)
|
||||||
: mData(data->mVis)
|
: mData(data->mVis)
|
||||||
|
, mMask(mask)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VisController::VisController()
|
VisController::VisController()
|
||||||
|
: mMask(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,6 +284,7 @@ VisController::VisController(const VisController ©, const osg::CopyOp ©o
|
||||||
: osg::NodeCallback(copy, copyop)
|
: osg::NodeCallback(copy, copyop)
|
||||||
, Controller(copy)
|
, Controller(copy)
|
||||||
, mData(copy.mData)
|
, mData(copy.mData)
|
||||||
|
, mMask(copy.mMask)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +306,7 @@ void VisController::operator() (osg::Node* node, osg::NodeVisitor* nv)
|
||||||
if (hasInput())
|
if (hasInput())
|
||||||
{
|
{
|
||||||
bool vis = calculate(getInputValue(nv));
|
bool vis = calculate(getInputValue(nv));
|
||||||
// Leave 0x1 enabled for UpdateVisitor, so we can make ourselves visible again in the future from this update callback
|
node->setNodeMask(vis ? ~0 : mMask);
|
||||||
node->setNodeMask(vis ? ~0 : 0x1);
|
|
||||||
}
|
}
|
||||||
traverse(node, nv);
|
traverse(node, nv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,11 +234,12 @@ namespace NifOsg
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<Nif::NiVisData::VisData> mData;
|
std::vector<Nif::NiVisData::VisData> mData;
|
||||||
|
unsigned int mMask;
|
||||||
|
|
||||||
bool calculate(float time) const;
|
bool calculate(float time) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VisController(const Nif::NiVisData *data);
|
VisController(const Nif::NiVisData *data, unsigned int mask);
|
||||||
VisController();
|
VisController();
|
||||||
VisController(const VisController& copy, const osg::CopyOp& copyop);
|
VisController(const VisController& copy, const osg::CopyOp& copyop);
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,17 @@ namespace NifOsg
|
||||||
return sShowMarkers;
|
return sShowMarkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Loader::sHiddenNodeMask = 0;
|
||||||
|
|
||||||
|
void Loader::setHiddenNodeMask(unsigned int mask)
|
||||||
|
{
|
||||||
|
sHiddenNodeMask = mask;
|
||||||
|
}
|
||||||
|
unsigned int Loader::getHiddenNodeMask()
|
||||||
|
{
|
||||||
|
return sHiddenNodeMask;
|
||||||
|
}
|
||||||
|
|
||||||
class LoaderImpl
|
class LoaderImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -571,8 +582,7 @@ namespace NifOsg
|
||||||
if (nifNode->recType == Nif::RC_RootCollisionNode)
|
if (nifNode->recType == Nif::RC_RootCollisionNode)
|
||||||
{
|
{
|
||||||
skipMeshes = true;
|
skipMeshes = true;
|
||||||
// Leave mask for UpdateVisitor enabled
|
node->setNodeMask(Loader::getHiddenNodeMask());
|
||||||
node->setNodeMask(0x1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can skip creating meshes for hidden nodes if they don't have a VisController that
|
// We can skip creating meshes for hidden nodes if they don't have a VisController that
|
||||||
|
@ -586,8 +596,7 @@ namespace NifOsg
|
||||||
if (!hasVisController)
|
if (!hasVisController)
|
||||||
skipMeshes = true; // skip child meshes, but still create the child node hierarchy for animating collision shapes
|
skipMeshes = true; // skip child meshes, but still create the child node hierarchy for animating collision shapes
|
||||||
|
|
||||||
// now hide this node, but leave the mask for UpdateVisitor enabled so that KeyframeController works
|
node->setNodeMask(Loader::getHiddenNodeMask());
|
||||||
node->setNodeMask(0x1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((skipMeshes || hasMarkers) && isAnimated) // make sure the empty node is not optimized away so the physicssystem can find it.
|
if ((skipMeshes || hasMarkers) && isAnimated) // make sure the empty node is not optimized away so the physicssystem can find it.
|
||||||
|
@ -753,7 +762,7 @@ namespace NifOsg
|
||||||
{
|
{
|
||||||
if (visctrl->data.empty())
|
if (visctrl->data.empty())
|
||||||
return;
|
return;
|
||||||
osg::ref_ptr<VisController> callback(new VisController(visctrl->data.getPtr()));
|
osg::ref_ptr<VisController> callback(new VisController(visctrl->data.getPtr(), Loader::getHiddenNodeMask()));
|
||||||
setupController(visctrl, callback, animflags);
|
setupController(visctrl, callback, animflags);
|
||||||
node->addUpdateCallback(callback);
|
node->addUpdateCallback(callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,13 @@ namespace NifOsg
|
||||||
|
|
||||||
static bool getShowMarkers();
|
static bool getShowMarkers();
|
||||||
|
|
||||||
private:
|
/// Set the mask to use for hidden nodes. The default is 0, i.e. updates to those nodes can no longer happen.
|
||||||
|
/// If you need to run animations or physics for hidden nodes, you may want to set this to a non-zero mask and remove exactly that mask from the camera's cull mask.
|
||||||
|
static void setHiddenNodeMask(unsigned int mask);
|
||||||
|
static unsigned int getHiddenNodeMask();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static unsigned int sHiddenNodeMask;
|
||||||
static bool sShowMarkers;
|
static bool sShowMarkers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue