Browse Source

- change Material.equals to Material.contentEquals
- update BatchNode, GeometryBatchFactory and Test

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

nor..67 13 years ago
parent
commit
92e2e35aef

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

@@ -222,8 +222,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
      * @param otherObj the material to compare to this material
      * @param otherObj the material to compare to this material
      * @return true if the materials are equal.
      * @return true if the materials are equal.
      */
      */
-    @Override
-    public boolean equals(Object otherObj) {
+    public boolean contentEquals(Object otherObj) {
         if (!(otherObj instanceof Material)) {
         if (!(otherObj instanceof Material)) {
             return false;
             return false;
         }
         }
@@ -287,16 +286,16 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
         return true;
         return true;
     }
     }
 
 
-    @Override
-    public int hashCode() {
-        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.hashCode() : 0);
-        return hash;
-    }
-
+//    @Override
+//    public int hashCode() {
+//        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.hashCode() : 0);
+//        return hash;
+//    }
+    
     /**
     /**
      * Returns the currently active technique.
      * Returns the currently active technique.
      * <p>
      * <p>

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

@@ -241,9 +241,9 @@ public class BatchNode extends Node implements Savable {
                     }
                     }
                     List<Geometry> list = map.get(g.getMaterial());
                     List<Geometry> list = map.get(g.getMaterial());
                     if (list == null) {
                     if (list == null) {
-                        //trying to compare materials with the isEqual method 
+                        //trying to compare materials with the contentEquals method 
                         for ( Map.Entry<Material, List<Geometry>> mat : map.entrySet()) {
                         for ( Map.Entry<Material, List<Geometry>> mat : map.entrySet()) {
-                            if (g.getMaterial().equals(mat.getKey())) {
+                            if (g.getMaterial().contentEquals(mat.getKey())) {
                                 list = mat.getValue();
                                 list = mat.getValue();
                             }
                             }
                         }
                         }

+ 1 - 1
engine/src/test/jme3test/material/TestMaterialCompare.java

@@ -105,7 +105,7 @@ public class TestMaterialCompare {
     }
     }
 
 
     private static void testEquality(Material mat1, Material mat2, boolean expected) {
     private static void testEquality(Material mat1, Material mat2, boolean expected) {
-        if (mat2.equals(mat1)) {
+        if (mat2.contentEquals(mat1)) {
             System.out.print(mat1.getName() + " == " + mat2.getName());
             System.out.print(mat1.getName() + " == " + mat2.getName());
             if (expected) {
             if (expected) {
                 System.out.println(" EQUAL OK");
                 System.out.println(" EQUAL OK");

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

@@ -289,9 +289,9 @@ public class GeometryBatchFactory {
         for (Geometry geom : geometries) {
         for (Geometry geom : geometries) {
             List<Geometry> outList = matToGeom.get(geom.getMaterial());
             List<Geometry> outList = matToGeom.get(geom.getMaterial());
             if (outList == null) {
             if (outList == null) {
-                //trying to compare materials with the isEqual method 
+                //trying to compare materials with the contentEquals method 
                 for (Material mat : matToGeom.keySet()) {
                 for (Material mat : matToGeom.keySet()) {
-                    if (geom.getMaterial().equals(mat)) {
+                    if (geom.getMaterial().contentEquals(mat)) {
                         outList = matToGeom.get(mat);
                         outList = matToGeom.get(mat);
                     }
                     }
                 }
                 }