mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 05:39:41 +00:00
LightManager: fix incorrect view matrix for RELATIVE_RF cameras
This commit is contained in:
parent
6dff11f847
commit
49df6b7450
2 changed files with 7 additions and 4 deletions
|
@ -198,7 +198,7 @@ namespace SceneUtil
|
|||
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);
|
||||
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)
|
||||
{
|
||||
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());
|
||||
transformBoundingSphere(worldViewMat, viewBound);
|
||||
|
||||
|
@ -280,7 +280,10 @@ namespace SceneUtil
|
|||
// - cull list of lights by the camera frustum
|
||||
// - 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())
|
||||
{
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace SceneUtil
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue