From 281d38d60926dd4f277af76b9f538381c93a005a Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Mon, 1 Oct 2012 22:29:40 +0000 Subject: [PATCH] RenderManager : Changed renderScene to reset the camera plane state to 0 (the first node to render is not always a root, it can be a sub part of the scene graph) and call renderSubScene. Created a private method renderSubScene that recursively renders the scene graph. This fixes culling issues with the reflection/redraction processors for the water effects se this post http://jmonkeyengine.org/groups/graphics/forum/topic/possibly-bug-simplewater-postprocessor-renders-entire-scene-no-frustrum-of-objects/?#post-192561 git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9790 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../core/com/jme3/renderer/RenderManager.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/engine/src/core/com/jme3/renderer/RenderManager.java b/engine/src/core/com/jme3/renderer/RenderManager.java index b65c193f6..b3ae3591a 100644 --- a/engine/src/core/com/jme3/renderer/RenderManager.java +++ b/engine/src/core/com/jme3/renderer/RenderManager.java @@ -636,9 +636,15 @@ public class RenderManager { * contain the flattened scene graph. */ public void renderScene(Spatial scene, ViewPort vp) { - if (scene.getParent() == null) { - vp.getCamera().setPlaneState(0); - } + //reset of the camera plane state for proper culling (must be 0 for the first note of the scene to be rendered) + vp.getCamera().setPlaneState(0); + //rendering the scene + renderSubScene(scene, vp); + } + + // recursively renders the scene + private void renderSubScene(Spatial scene, ViewPort vp) { + // check culling first. if (!scene.checkCulling(vp.getCamera())) { // move on to shadow-only render @@ -658,7 +664,7 @@ public class RenderManager { for (int i = 0; i < children.size(); i++) { // Restoring cam state before proceeding children recusively vp.getCamera().setPlaneState(camState); - renderScene(children.get(i), vp); + renderSubScene(children.get(i), vp); } } else if (scene instanceof Geometry) { // add to the render queue @@ -889,7 +895,7 @@ public class RenderManager { public void renderViewPortRaw(ViewPort vp) { setCamera(vp.getCamera(), false); List scenes = vp.getScenes(); - for (int i = scenes.size() - 1; i >= 0; i--) { + for (int i = scenes.size() - 1; i >= 0; i--) { renderScene(scenes.get(i), vp); } flushQueue(vp); @@ -966,7 +972,7 @@ public class RenderManager { } List scenes = vp.getScenes(); - for (int i = scenes.size() - 1; i >= 0; i--) { + for (int i = scenes.size() - 1; i >= 0; i--) { renderScene(scenes.get(i), vp); }