From 783ec50326025deeacf0b75e49ff1b646ba2cec7 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Wed, 9 May 2012 12:50:01 +0000 Subject: [PATCH] - 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 --- engine/src/core/com/jme3/material/Material.java | 8 ++++---- engine/src/core/com/jme3/material/RenderState.java | 2 +- engine/src/core/com/jme3/scene/BatchNode.java | 4 ++-- .../tools/jme3tools/optimize/GeometryBatchFactory.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engine/src/core/com/jme3/material/Material.java b/engine/src/core/com/jme3/material/Material.java index 81ed991a7..527bb5675 100644 --- a/engine/src/core/com/jme3/material/Material.java +++ b/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; } diff --git a/engine/src/core/com/jme3/material/RenderState.java b/engine/src/core/com/jme3/material/RenderState.java index 0f4b19ca7..cbb8ff0a9 100644 --- a/engine/src/core/com/jme3/material/RenderState.java +++ b/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); diff --git a/engine/src/core/com/jme3/scene/BatchNode.java b/engine/src/core/com/jme3/scene/BatchNode.java index c71213d97..cd8248536 100644 --- a/engine/src/core/com/jme3/scene/BatchNode.java +++ b/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> 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; } } diff --git a/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java b/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java index a6c3ed4c6..65d60fb85 100644 --- a/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java +++ b/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); } }