Commit 65120d77 authored by lukeph's avatar lukeph

-Fixed bugs in new 'blend operation' code, the 'if' checks on EBO_NONE could...

-Fixed bugs in new 'blend operation' code, the 'if' checks on EBO_NONE could never return true, so everything was set to blend

-Fixed performance bug in CTerrainSceneNode, noticed that preRenderLODCalculations() is ran every render, instead of just when LOD data is recalculated.
  This increases the frame-rate on 'Terrain Rendering Example 12' from 410fps to 1300fps on my machine.




git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3728 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 13793ac5
...@@ -1576,7 +1576,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -1576,7 +1576,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
if (queryFeature(EVDF_BLEND_OPERATIONS) && if (queryFeature(EVDF_BLEND_OPERATIONS) &&
(resetAllRenderstates|| lastmaterial.BlendOperation != material.BlendOperation)) (resetAllRenderstates|| lastmaterial.BlendOperation != material.BlendOperation))
{ {
if (EBO_NONE) if (material.BlendOperation==EBO_NONE)
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
else else
{ {
......
...@@ -2259,7 +2259,7 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -2259,7 +2259,7 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
if (queryFeature(EVDF_BLEND_OPERATIONS) && if (queryFeature(EVDF_BLEND_OPERATIONS) &&
(resetAllRenderstates|| lastmaterial.BlendOperation != material.BlendOperation)) (resetAllRenderstates|| lastmaterial.BlendOperation != material.BlendOperation))
{ {
if (EBO_NONE) if (material.BlendOperation==EBO_NONE)
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
else else
{ {
......
...@@ -2924,7 +2924,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2924,7 +2924,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
if (queryFeature(EVDF_BLEND_OPERATIONS) && if (queryFeature(EVDF_BLEND_OPERATIONS) &&
(resetAllRenderStates|| lastmaterial.BlendOperation != material.BlendOperation)) (resetAllRenderStates|| lastmaterial.BlendOperation != material.BlendOperation))
{ {
if (EBO_NONE) if (material.BlendOperation==EBO_NONE)
glDisable(GL_BLEND); glDisable(GL_BLEND);
else else
{ {
......
...@@ -565,23 +565,23 @@ namespace scene ...@@ -565,23 +565,23 @@ namespace scene
{ {
if (!IsVisible || !SceneManager->getActiveCamera()) if (!IsVisible || !SceneManager->getActiveCamera())
return; return;
preRenderLODCalculations(); SceneManager->registerNodeForRendering(this);
preRenderIndicesCalculations();
preRenderCalculationsIfNeeded();
// Do Not call ISceneNode::OnRegisterSceneNode(), this node should have no children (luke: is this comment still true, as ISceneNode::OnRegisterSceneNode() is called?)
ISceneNode::OnRegisterSceneNode(); ISceneNode::OnRegisterSceneNode();
ForceRecalculation = false; ForceRecalculation = false;
} }
void CTerrainSceneNode::preRenderCalculationsIfNeeded()
void CTerrainSceneNode::preRenderLODCalculations() {
{ scene::ICameraSceneNode * camera = SceneManager->getActiveCamera();
scene::ICameraSceneNode * camera = SceneManager->getActiveCamera();
if(!camera) if(!camera)
return; return;
SceneManager->registerNodeForRendering(this);
// Do Not call ISceneNode::OnRegisterSceneNode(), this node should have no children
// Determine the camera rotation, based on the camera direction. // Determine the camera rotation, based on the camera direction.
const core::vector3df cameraPosition = camera->getAbsolutePosition(); const core::vector3df cameraPosition = camera->getAbsolutePosition();
const core::vector3df cameraRotation = core::line3d<f32>(cameraPosition, camera->getTarget()).getVector().getHorizontalAngle(); const core::vector3df cameraRotation = core::line3d<f32>(cameraPosition, camera->getTarget()).getVector().getHorizontalAngle();
...@@ -607,13 +607,31 @@ namespace scene ...@@ -607,13 +607,31 @@ namespace scene
} }
} }
} }
//we need to redo calculations...
OldCameraPosition = cameraPosition; OldCameraPosition = cameraPosition;
OldCameraRotation = cameraRotation; OldCameraRotation = cameraRotation;
OldCameraUp = cameraUp; OldCameraUp = cameraUp;
OldCameraFOV = CameraFOV; OldCameraFOV = CameraFOV;
const SViewFrustum* frustum = SceneManager->getActiveCamera()->getViewFrustum();
preRenderLODCalculations();
preRenderIndicesCalculations();
}
void CTerrainSceneNode::preRenderLODCalculations()
{
scene::ICameraSceneNode * camera = SceneManager->getActiveCamera();
if(!camera)
return;
const core::vector3df cameraPosition = camera->getAbsolutePosition();
const SViewFrustum* frustum = camera->getViewFrustum();
// Determine each patches LOD based on distance from camera (and whether or not they are in // Determine each patches LOD based on distance from camera (and whether or not they are in
// the view frustum). // the view frustum).
......
...@@ -258,7 +258,10 @@ namespace scene ...@@ -258,7 +258,10 @@ namespace scene
core::aabbox3df BoundingBox; core::aabbox3df BoundingBox;
core::array<f64> LODDistanceThreshold; core::array<f64> LODDistanceThreshold;
}; };
virtual void preRenderCalculationsIfNeeded();
virtual void preRenderLODCalculations(); virtual void preRenderLODCalculations();
virtual void preRenderIndicesCalculations(); virtual void preRenderIndicesCalculations();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment