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