- 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
3.0
nor..67 13 years ago
parent f6ea856f9e
commit 92e2e35aef
  1. 21
      engine/src/core/com/jme3/material/Material.java
  2. 4
      engine/src/core/com/jme3/scene/BatchNode.java
  3. 2
      engine/src/test/jme3test/material/TestMaterialCompare.java
  4. 4
      engine/src/tools/jme3tools/optimize/GeometryBatchFactory.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,15 +286,15 @@ 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.

@ -241,9 +241,9 @@ public class BatchNode extends Node implements Savable {
}
List<Geometry> 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<Material, List<Geometry>> mat : map.entrySet()) {
if (g.getMaterial().equals(mat.getKey())) {
if (g.getMaterial().contentEquals(mat.getKey())) {
list = mat.getValue();
}
}

@ -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");

@ -289,9 +289,9 @@ public class GeometryBatchFactory {
for (Geometry geom : geometries) {
List<Geometry> 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);
}
}

Loading…
Cancel
Save