OSDN Git Service

- added a ColorRGBA to tempVars
authorremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Fri, 22 Jul 2011 21:41:45 +0000 (21:41 +0000)
committerremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Fri, 22 Jul 2011 21:41:45 +0000 (21:41 +0000)
- Used tempvars in Materila.renderMultipassLighting

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7903 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/core/com/jme3/material/Material.java
engine/src/core/com/jme3/util/TempVars.java

index 1e424d2..76b9552 100644 (file)
@@ -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<Material> {
             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<Material> {
                 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<Material> {
                 default:
                     throw new UnsupportedOperationException("Unknown type of light: " + l.getType());
             }
-
+            vars.release();
             r.setShader(shader);
             r.renderMesh(g.getMesh(), g.getLodLevel(), 1);
         }
index 4f81f02..f51ab83 100644 (file)
@@ -32,6 +32,7 @@
 package com.jme3.util;\r
 \r
 import com.jme3.collision.bih.BIHNode.BIHStackData;\r
+import com.jme3.math.ColorRGBA;\r
 import com.jme3.math.Eigen3f;\r
 import com.jme3.math.Matrix4f;\r
 import com.jme3.math.Matrix3f;\r
@@ -160,6 +161,11 @@ public class TempVars {
      * Fetching triangle from mesh\r
      */\r
     public final Triangle triangle = new Triangle();\r
+    \r
+    /**\r
+     * Color\r
+     */\r
+    public final ColorRGBA color = new ColorRGBA();\r
     /**\r
      * General vectors.\r
      */\r