mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 18:09:39 +00:00
Inherit the view point from main camera for water RTT cameras
This commit is contained in:
parent
489e5c6cce
commit
e908790584
2 changed files with 19 additions and 1 deletions
|
@ -161,6 +161,23 @@ private:
|
||||||
osg::Plane mPlane;
|
osg::Plane mPlane;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// This callback on the Camera has the effect of a RELATIVE_RF_INHERIT_VIEWPOINT transform mode (which does not exist in OSG).
|
||||||
|
/// We want to keep the View Point of the parent camera so we will not have to recreate LODs.
|
||||||
|
class InheritViewPointCallback : public osg::NodeCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InheritViewPointCallback() {}
|
||||||
|
|
||||||
|
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||||
|
{
|
||||||
|
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
||||||
|
osg::ref_ptr<osg::RefMatrix> modelViewMatrix = new osg::RefMatrix(*cv->getModelViewMatrix());
|
||||||
|
cv->popModelViewMatrix();
|
||||||
|
cv->pushModelViewMatrix(modelViewMatrix, osg::Transform::ABSOLUTE_RF_INHERIT_VIEWPOINT);
|
||||||
|
traverse(node, nv);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// Moves water mesh away from the camera slightly if the camera gets too close on the Z axis.
|
/// Moves water mesh away from the camera slightly if the camera gets too close on the Z axis.
|
||||||
/// The offset works around graphics artifacts that occurred with the GL_DEPTH_CLAMP when the camera gets extremely close to the mesh (seen on NVIDIA at least).
|
/// The offset works around graphics artifacts that occurred with the GL_DEPTH_CLAMP when the camera gets extremely close to the mesh (seen on NVIDIA at least).
|
||||||
/// Must be added as a Cull callback.
|
/// Must be added as a Cull callback.
|
||||||
|
@ -224,6 +241,7 @@ public:
|
||||||
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
||||||
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
||||||
setName("RefractionCamera");
|
setName("RefractionCamera");
|
||||||
|
setCullCallback(new InheritViewPointCallback);
|
||||||
|
|
||||||
setCullMask(Mask_Effect|Mask_Scene|Mask_Object|Mask_Static|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting);
|
setCullMask(Mask_Effect|Mask_Scene|Mask_Object|Mask_Static|Mask_Terrain|Mask_Actor|Mask_ParticleSystem|Mask_Sky|Mask_Sun|Mask_Player|Mask_Lighting);
|
||||||
setNodeMask(Mask_RenderToTexture);
|
setNodeMask(Mask_RenderToTexture);
|
||||||
|
@ -315,6 +333,7 @@ public:
|
||||||
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
setReferenceFrame(osg::Camera::RELATIVE_RF);
|
||||||
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
setSmallFeatureCullingPixelSize(Settings::Manager::getInt("small feature culling pixel size", "Water"));
|
||||||
setName("ReflectionCamera");
|
setName("ReflectionCamera");
|
||||||
|
setCullCallback(new InheritViewPointCallback);
|
||||||
|
|
||||||
int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water");
|
int reflectionDetail = Settings::Manager::getInt("reflection detail", "Water");
|
||||||
reflectionDetail = std::min(4, std::max(isInterior ? 2 : 0, reflectionDetail));
|
reflectionDetail = std::min(4, std::max(isInterior ? 2 : 0, reflectionDetail));
|
||||||
|
|
|
@ -132,7 +132,6 @@ ViewData *ViewDataMap::getViewData(osg::Object *viewer, const osg::Vec3f& viewPo
|
||||||
if (found == mViews.end())
|
if (found == mViews.end())
|
||||||
{
|
{
|
||||||
vd = createOrReuseView();
|
vd = createOrReuseView();
|
||||||
vd->setViewer(viewer);
|
|
||||||
mViews[viewer] = vd;
|
mViews[viewer] = vd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue