From 198adb0753dceca3d96b302f4f0f419e61dd465b Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Fri, 19 Apr 2013 16:12:51 +0000 Subject: [PATCH] Fixed NPE in water filter when setting the reflection mapsize before the filter has been initialized git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10560 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core-effects/com/jme3/water/WaterFilter.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/src/core-effects/com/jme3/water/WaterFilter.java b/engine/src/core-effects/com/jme3/water/WaterFilter.java index fba95f44b..10749cc99 100644 --- a/engine/src/core-effects/com/jme3/water/WaterFilter.java +++ b/engine/src/core-effects/com/jme3/water/WaterFilter.java @@ -853,10 +853,13 @@ public class WaterFilter extends Filter { */ public void setReflectionMapSize(int reflectionMapSize) { this.reflectionMapSize = reflectionMapSize; - reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth); - reflectionCam.resize(reflectionMapSize, reflectionMapSize, true); - reflectionProcessor.setReflectionBuffer(reflectionPass.getRenderFrameBuffer()); - material.setTexture("ReflectionMap", reflectionPass.getRenderedTexture()); + //if reflection pass is already initialized we must update it + if(reflectionPass != null){ + reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth); + reflectionCam.resize(reflectionMapSize, reflectionMapSize, true); + reflectionProcessor.setReflectionBuffer(reflectionPass.getRenderFrameBuffer()); + material.setTexture("ReflectionMap", reflectionPass.getRenderedTexture()); + } }