From 92e2e35aef37a4d80f1a56baf1212337fa97aebd Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Mon, 7 May 2012 22:35:25 +0000 Subject: [PATCH] - 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 --- .../src/core/com/jme3/material/Material.java | 23 +++++++++---------- engine/src/core/com/jme3/scene/BatchNode.java | 4 ++-- .../material/TestMaterialCompare.java | 2 +- .../optimize/GeometryBatchFactory.java | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/engine/src/core/com/jme3/material/Material.java b/engine/src/core/com/jme3/material/Material.java index 0989a0aaf..d2200311a 100644 --- a/engine/src/core/com/jme3/material/Material.java +++ b/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 * @return true if the materials are equal. */ - @Override - public boolean equals(Object otherObj) { + public boolean contentEquals(Object otherObj) { if (!(otherObj instanceof Material)) { return false; } @@ -287,16 +286,16 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable { 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. *

diff --git a/engine/src/core/com/jme3/scene/BatchNode.java b/engine/src/core/com/jme3/scene/BatchNode.java index c4f498ce5..f4ddbd450 100644 --- a/engine/src/core/com/jme3/scene/BatchNode.java +++ b/engine/src/core/com/jme3/scene/BatchNode.java @@ -241,9 +241,9 @@ public class BatchNode extends Node implements Savable { } List list = map.get(g.getMaterial()); if (list == null) { - //trying to compare materials with the isEqual method + //trying to compare materials with the contentEquals method for ( Map.Entry> mat : map.entrySet()) { - if (g.getMaterial().equals(mat.getKey())) { + if (g.getMaterial().contentEquals(mat.getKey())) { list = mat.getValue(); } } diff --git a/engine/src/test/jme3test/material/TestMaterialCompare.java b/engine/src/test/jme3test/material/TestMaterialCompare.java index e1c7a7264..541135823 100644 --- a/engine/src/test/jme3test/material/TestMaterialCompare.java +++ b/engine/src/test/jme3test/material/TestMaterialCompare.java @@ -105,7 +105,7 @@ public class TestMaterialCompare { } 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()); if (expected) { System.out.println(" EQUAL OK"); diff --git a/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java b/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java index dff58df9e..88c63be18 100644 --- a/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java +++ b/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java @@ -289,9 +289,9 @@ public class GeometryBatchFactory { for (Geometry geom : geometries) { List outList = matToGeom.get(geom.getMaterial()); if (outList == null) { - //trying to compare materials with the isEqual method + //trying to compare materials with the contentEquals method for (Material mat : matToGeom.keySet()) { - if (geom.getMaterial().equals(mat)) { + if (geom.getMaterial().contentEquals(mat)) { outList = matToGeom.get(mat); } }