StateSetUpdater: use the frameNumber

More robust in case a node is updated twice in the same frame (e.g. because it has multiple parents).
openmw-38
scrawl 9 years ago
parent f22982d251
commit 1f8ee9b8d1

@ -20,11 +20,10 @@ namespace SceneUtil
}
}
// Swap to make the StateSet in [0] writable, [1] is now the StateSet that was queued by the last frame
std::swap(mStateSets[0], mStateSets[1]);
node->setStateSet(mStateSets[0]);
osg::StateSet* stateset = mStateSets[nv->getTraversalNumber()%2];
node->setStateSet(stateset);
apply(mStateSets[0], nv);
apply(stateset, nv);
traverse(node, nv);
}

@ -12,8 +12,7 @@ namespace SceneUtil
/// DYNAMIC data variance but that would undo all the benefits of the threading model - having the cull and draw
/// traversals run in parallel can yield up to 200% framerates.
/// @par Race conditions are prevented using a "double buffering" scheme - we have two StateSets that take turns,
/// the first StateSet is the one we can write to, the second is the one currently in use by the draw traversal of the last frame.
/// After a frame is completed the places are swapped.
/// one StateSet we can write to, the second one is currently in use by the draw traversal of the last frame.
/// @par Must be set as UpdateCallback on a Node.
/// @note Do not add the same StateSetUpdater to multiple nodes.
/// @note Do not add multiple StateSetControllers on the same Node as they will conflict - instead use the CompositeStateSetUpdater.

Loading…
Cancel
Save