浏览代码

- added a ColorRGBA to tempVars
- Used tempvars in Materila.renderMultipassLighting

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

rem..om 14 年之前
父节点
当前提交
310193018d
共有 2 个文件被更改,包括 13 次插入4 次删除
  1. 7 4
      engine/src/core/com/jme3/material/Material.java
  2. 6 0
      engine/src/core/com/jme3/util/TempVars.java

+ 7 - 4
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<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);
         }

+ 6 - 0
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.
      */