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 osg::StateSet* stateset = mStateSets[nv->getTraversalNumber()%2];
std::swap(mStateSets[0], mStateSets[1]); node->setStateSet(stateset);
node->setStateSet(mStateSets[0]);
apply(mStateSets[0], nv); apply(stateset, nv);
traverse(node, 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 /// 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. /// 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, /// @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. /// one StateSet we can write to, the second one is currently in use by the draw traversal of the last frame.
/// After a frame is completed the places are swapped.
/// @par Must be set as UpdateCallback on a Node. /// @par Must be set as UpdateCallback on a Node.
/// @note Do not add the same StateSetUpdater to multiple nodes. /// @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. /// @note Do not add multiple StateSetControllers on the same Node as they will conflict - instead use the CompositeStateSetUpdater.

Loading…
Cancel
Save