LightManager: fix incorrect view matrix for RELATIVE_RF cameras

openmw-37
scrawl 9 years ago
parent 6dff11f847
commit 49df6b7450

@ -198,7 +198,7 @@ namespace SceneUtil
return mLights; return mLights;
} }
const std::vector<LightManager::LightSourceViewBound>& LightManager::getLightsInViewSpace(osg::Camera *camera) const std::vector<LightManager::LightSourceViewBound>& LightManager::getLightsInViewSpace(osg::Camera *camera, const osg::RefMatrix* viewMatrix)
{ {
osg::observer_ptr<osg::Camera> camPtr (camera); osg::observer_ptr<osg::Camera> camPtr (camera);
std::map<osg::observer_ptr<osg::Camera>, LightSourceViewBoundCollection>::iterator it = mLightsInViewSpace.find(camPtr); std::map<osg::observer_ptr<osg::Camera>, LightSourceViewBoundCollection>::iterator it = mLightsInViewSpace.find(camPtr);
@ -209,7 +209,7 @@ namespace SceneUtil
for (std::vector<LightSourceTransform>::iterator lightIt = mLights.begin(); lightIt != mLights.end(); ++lightIt) for (std::vector<LightSourceTransform>::iterator lightIt = mLights.begin(); lightIt != mLights.end(); ++lightIt)
{ {
osg::Matrix worldViewMat = lightIt->mWorldMatrix * camera->getViewMatrix(); osg::Matrix worldViewMat = lightIt->mWorldMatrix * (*viewMatrix);
osg::BoundingSphere viewBound = osg::BoundingSphere(osg::Vec3f(0,0,0), lightIt->mLightSource->getRadius()); osg::BoundingSphere viewBound = osg::BoundingSphere(osg::Vec3f(0,0,0), lightIt->mLightSource->getRadius());
transformBoundingSphere(worldViewMat, viewBound); transformBoundingSphere(worldViewMat, viewBound);
@ -280,7 +280,10 @@ namespace SceneUtil
// - cull list of lights by the camera frustum // - cull list of lights by the camera frustum
// - organize lights in a quad tree // - organize lights in a quad tree
const std::vector<LightManager::LightSourceViewBound>& lights = mLightManager->getLightsInViewSpace(cv->getCurrentCamera()); // Don't use Camera::getViewMatrix, that one might be relative to another camera!
const osg::RefMatrix* viewMatrix = cv->getCurrentRenderStage()->getInitialViewMatrix();
const std::vector<LightManager::LightSourceViewBound>& lights = mLightManager->getLightsInViewSpace(cv->getCurrentCamera(), viewMatrix);
if (lights.size()) if (lights.size())
{ {

@ -88,7 +88,7 @@ namespace SceneUtil
osg::BoundingSphere mViewBound; osg::BoundingSphere mViewBound;
}; };
const std::vector<LightSourceViewBound>& getLightsInViewSpace(osg::Camera* camera); const std::vector<LightSourceViewBound>& getLightsInViewSpace(osg::Camera* camera, const osg::RefMatrix* viewMatrix);
typedef std::vector<const LightSourceViewBound*> LightList; typedef std::vector<const LightSourceViewBound*> LightList;

Loading…
Cancel
Save