|
|
|
@ -381,21 +381,23 @@ namespace SceneUtil
|
|
|
|
|
{
|
|
|
|
|
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
|
|
|
|
|
|
|
|
|
bool pushedState = pushLightState(node, cv);
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
if (pushedState)
|
|
|
|
|
cv->popStateSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LightListCallback::pushLightState(osg::Node *node, osgUtil::CullVisitor *cv)
|
|
|
|
|
{
|
|
|
|
|
if (!mLightManager)
|
|
|
|
|
{
|
|
|
|
|
mLightManager = findLightManager(nv->getNodePath());
|
|
|
|
|
mLightManager = findLightManager(cv->getNodePath());
|
|
|
|
|
if (!mLightManager)
|
|
|
|
|
{
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(cv->getCurrentCamera()->getCullMask() & mLightManager->getLightingMask()))
|
|
|
|
|
{
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Possible optimizations:
|
|
|
|
|
// - cull list of lights by the camera frustum
|
|
|
|
@ -404,9 +406,9 @@ namespace SceneUtil
|
|
|
|
|
|
|
|
|
|
// update light list if necessary
|
|
|
|
|
// makes sure we don't update it more than once per frame when rendering with multiple cameras
|
|
|
|
|
if (mLastFrameNumber != nv->getTraversalNumber())
|
|
|
|
|
if (mLastFrameNumber != cv->getTraversalNumber())
|
|
|
|
|
{
|
|
|
|
|
mLastFrameNumber = nv->getTraversalNumber();
|
|
|
|
|
mLastFrameNumber = cv->getTraversalNumber();
|
|
|
|
|
|
|
|
|
|
// Don't use Camera::getViewMatrix, that one might be relative to another camera!
|
|
|
|
|
const osg::RefMatrix* viewMatrix = cv->getCurrentRenderStage()->getInitialViewMatrix();
|
|
|
|
@ -469,20 +471,16 @@ namespace SceneUtil
|
|
|
|
|
while (lightList.size() > maxLights)
|
|
|
|
|
lightList.pop_back();
|
|
|
|
|
}
|
|
|
|
|
stateset = mLightManager->getLightListStateSet(lightList, nv->getTraversalNumber());
|
|
|
|
|
stateset = mLightManager->getLightListStateSet(lightList, cv->getTraversalNumber());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
stateset = mLightManager->getLightListStateSet(mLightList, nv->getTraversalNumber());
|
|
|
|
|
stateset = mLightManager->getLightListStateSet(mLightList, cv->getTraversalNumber());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv->pushStateSet(stateset);
|
|
|
|
|
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
|
|
|
|
|
cv->popStateSet();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
traverse(node, nv);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|