Browse Source

- final version of Material/RenderState comparison and hashValue methods, he who changes them again has to buy a crate of beer for all core members

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9365 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 13 years ago
parent
commit
783ec50326

+ 4 - 4
engine/src/core/com/jme3/material/Material.java

@@ -219,12 +219,12 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
      * Compares two materials and returns true if they are equal. 
      * This methods compare definition, parameters, additional render states.
      * Since materials are mutable objects, implementing equals() properly is not possible, 
-     * hence the name dynamicEquals().
+     * hence the name contentEquals().
      * 
      * @param otherObj the material to compare to this material
      * @return true if the materials are equal.
      */
-    public boolean dynamicEquals(Object otherObj) {
+    public boolean contentEquals(Object otherObj) {
         if (!(otherObj instanceof Material)) {
             return false;
         }
@@ -291,12 +291,12 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
     /**
      * Works like {@link Object#hashCode() } except it may change together with the material as the material is mutable by definition.
      */
-    public int dynamicHashCode() {
+    public int contentHashCode() {
         int hash = 7;
         hash = 29 * hash + (this.def != null ? this.def.hashCode() : 0);
         hash = 29 * hash + (this.paramValues != null ? this.paramValues.hashCode() : 0);
         hash = 29 * hash + (this.technique != null ? this.technique.getDef().getName().hashCode() : 0);
-        hash = 29 * hash + (this.additionalState != null ? this.additionalState.dynamicHashCode() : 0);
+        hash = 29 * hash + (this.additionalState != null ? this.additionalState.contentHashCode() : 0);
         return hash;
     }
     

+ 1 - 1
engine/src/core/com/jme3/material/RenderState.java

@@ -1047,7 +1047,7 @@ public class RenderState implements Cloneable, Savable {
     /**
      *
      */
-    public int dynamicHashCode() {
+    public int contentHashCode() {
         if (cachedHashCode == -1){
             int hash = 7;
             hash = 79 * hash + (this.pointSprite ? 1 : 0);

+ 2 - 2
engine/src/core/com/jme3/scene/BatchNode.java

@@ -259,7 +259,7 @@ public class BatchNode extends Node implements Savable {
                     if (list == null) {
                         //trying to compare materials with the isEqual method 
                         for (Map.Entry<Material, List<Geometry>> mat : map.entrySet()) {
-                            if (g.getMaterial().dynamicEquals(mat)) {
+                            if (g.getMaterial().contentEquals(mat)) {
                                 list = mat.getValue();
                             }
                         }
@@ -286,7 +286,7 @@ public class BatchNode extends Node implements Savable {
 
     private Batch findBatchByMaterial(Material m) {
         for (Batch batch : batches.getArray()) {
-            if (batch.geometry.getMaterial().dynamicEquals(m)) {
+            if (batch.geometry.getMaterial().contentEquals(m)) {
                 return batch;
             }
         }

+ 1 - 1
engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java

@@ -291,7 +291,7 @@ public class GeometryBatchFactory {
             if (outList == null) {
                 //trying to compare materials with the contentEquals method 
                 for (Material mat : matToGeom.keySet()) {
-                    if (geom.getMaterial().dynamicEquals(mat)){
+                    if (geom.getMaterial().contentEquals(mat)){
                         outList = matToGeom.get(mat);
                     }
                 }