diff --git a/engine/src/core/com/jme3/material/Material.java b/engine/src/core/com/jme3/material/Material.java index 1e424d2c0..76b9552eb 100644 --- a/engine/src/core/com/jme3/material/Material.java +++ b/engine/src/core/com/jme3/material/Material.java @@ -61,6 +61,7 @@ import com.jme3.shader.Uniform; import com.jme3.shader.VarType; import com.jme3.texture.Texture; import com.jme3.util.ListMap; +import com.jme3.util.TempVars; import java.io.IOException; import java.util.Collection; import java.util.EnumSet; @@ -698,9 +699,6 @@ public class Material implements Cloneable, Savable, Comparable { lightIndex++; } } - Quaternion tmpLightDirection = new Quaternion(); - Quaternion tmpLightPosition = new Quaternion(); - ColorRGBA tmpLightColor = new ColorRGBA(); protected void renderMultipassLighting(Shader shader, Geometry g, Renderer r) { LightList lightList = g.getWorldLightList(); @@ -729,6 +727,11 @@ public class Material implements Cloneable, Savable, Comparable { isSecondLight = false; } + TempVars vars = TempVars.get(); + Quaternion tmpLightDirection = vars.quat1; + Quaternion tmpLightPosition = vars.quat2; + ColorRGBA tmpLightColor = vars.color; + ColorRGBA color = l.getColor(); tmpLightColor.set(color); tmpLightColor.a = l.getType().getId(); @@ -767,7 +770,7 @@ public class Material implements Cloneable, Savable, Comparable { default: throw new UnsupportedOperationException("Unknown type of light: " + l.getType()); } - + vars.release(); r.setShader(shader); r.renderMesh(g.getMesh(), g.getLodLevel(), 1); } diff --git a/engine/src/core/com/jme3/util/TempVars.java b/engine/src/core/com/jme3/util/TempVars.java index 4f81f02a4..f51ab8313 100644 --- a/engine/src/core/com/jme3/util/TempVars.java +++ b/engine/src/core/com/jme3/util/TempVars.java @@ -32,6 +32,7 @@ package com.jme3.util; import com.jme3.collision.bih.BIHNode.BIHStackData; +import com.jme3.math.ColorRGBA; import com.jme3.math.Eigen3f; import com.jme3.math.Matrix4f; import com.jme3.math.Matrix3f; @@ -160,6 +161,11 @@ public class TempVars { * Fetching triangle from mesh */ public final Triangle triangle = new Triangle(); + + /** + * Color + */ + public final ColorRGBA color = new ColorRGBA(); /** * General vectors. */