From d486cde330e5797ed484ac66e8b27ab413ee7f6a Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 20 Mar 2015 21:32:26 +0100 Subject: [PATCH] Fix broken VisControllers --- apps/nifosgtest/test.cpp | 3 ++- components/nifosg/controller.cpp | 3 ++- components/nifosg/nifloader.cpp | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/nifosgtest/test.cpp b/apps/nifosgtest/test.cpp index fee919787..3e70c8cd2 100644 --- a/apps/nifosgtest/test.cpp +++ b/apps/nifosgtest/test.cpp @@ -133,7 +133,8 @@ int main(int argc, char** argv) viewer.setCameraManipulator(new osgGA::TrackballManipulator()); viewer.addEventHandler(new WireframeKeyHandler(root)); - //viewer.getCamera()->setCullMask() + // Mask to separate cull visitors from update visitors + viewer.getCamera()->setCullMask(~(0x1)); // We're going to change this from the event callback, set the variance to DYNAMIC so that // we don't interfere with the draw thread. diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index 509d20bbf..01671dbd8 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -316,7 +316,8 @@ void VisController::operator() (osg::Node* node, osg::NodeVisitor* nv) if (hasInput()) { bool vis = calculate(getInputValue(nv)); - node->setNodeMask(vis ? ~0 : 0); + // Leave 0x1 enabled for UpdateVisitor, so we can make ourselves visible again in the future from this update callback + node->setNodeMask(vis ? ~0 : 0x1); } traverse(node, nv); } diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 26f0927b5..2fb60280b 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -322,14 +322,14 @@ namespace NifOsg if (nifNode->recType == Nif::RC_RootCollisionNode) { collisionNode = true; - transformNode->setNodeMask(0); + // Leave mask for UpdateVisitor enabled + transformNode->setNodeMask(0x1); } // We could probably skip hidden nodes entirely if they don't have a VisController that // might make them visible later - // FIXME: this disables update callbacks, so VisController no longer works if (nifNode->flags & Nif::NiNode::Flag_Hidden) - transformNode->setNodeMask(0); + transformNode->setNodeMask(0x1); // Leave mask for UpdateVisitor enabled // Insert bones at position 0 to prevent update order problems (see comment in osg Skeleton.cpp) parentNode->insertChild(0, transformNode);