* Proper equals/hashCode methods in OgreMaterialKey/OgreMeshKey

* Formatting in MaterialExtensionSet

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9305 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent f844ca429f
commit 90f32dc703
  1. 30
      engine/src/ogre/com/jme3/scene/plugins/ogre/OgreMeshKey.java
  2. 11
      engine/src/ogre/com/jme3/scene/plugins/ogre/matext/MaterialExtensionSet.java
  3. 41
      engine/src/ogre/com/jme3/scene/plugins/ogre/matext/OgreMaterialKey.java

@ -66,6 +66,36 @@ public class OgreMeshKey extends ModelKey {
this.materialName = materialName; this.materialName = materialName;
} }
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OgreMeshKey other = (OgreMeshKey) obj;
if (!super.equals(other)) {
return false;
}
if (this.materialList != other.materialList && (this.materialList == null || !this.materialList.equals(other.materialList))) {
return false;
}
if ((this.materialName == null) ? (other.materialName != null) : !this.materialName.equals(other.materialName)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 31 * hash + (super.hashCode());
hash = 31 * hash + (this.materialList != null ? this.materialList.hashCode() : 0);
hash = 31 * hash + (this.materialName != null ? this.materialName.hashCode() : 0);
return hash;
}
public MaterialList getMaterialList() { public MaterialList getMaterialList() {
return materialList; return materialList;
} }

@ -29,7 +29,6 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package com.jme3.scene.plugins.ogre.matext; package com.jme3.scene.plugins.ogre.matext;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,12 +41,13 @@ import java.util.List;
* {@link OgreMaterialKey}s used. * {@link OgreMaterialKey}s used.
*/ */
public class MaterialExtensionSet { public class MaterialExtensionSet {
private HashMap<String, MaterialExtension> extensions
= new HashMap<String, MaterialExtension>(); private HashMap<String, MaterialExtension> extensions = new HashMap<String, MaterialExtension>();
private HashMap<String, List<String>> nameMappings = new HashMap<String, List<String>>(); private HashMap<String, List<String>> nameMappings = new HashMap<String, List<String>>();
/** /**
* Adds a new material extension to the set of extensions. * Adds a new material extension to the set of extensions.
*
* @param extension The {@link MaterialExtension} to add. * @param extension The {@link MaterialExtension} to add.
*/ */
public void addMaterialExtension(MaterialExtension extension) { public void addMaterialExtension(MaterialExtension extension) {
@ -55,8 +55,8 @@ public class MaterialExtensionSet {
} }
/** /**
* Returns the {@link MaterialExtension} for a given Ogre3D base * Returns the {@link MaterialExtension} for a given Ogre3D base material
* material name. * name.
* *
* @param baseMatName The ogre3D base material name. * @param baseMatName The ogre3D base material name.
* @return {@link MaterialExtension} that is set, or null if not set. * @return {@link MaterialExtension} that is set, or null if not set.
@ -67,6 +67,7 @@ public class MaterialExtensionSet {
/** /**
* Adds an alternative name for a material * Adds an alternative name for a material
*
* @param name The material name to be found in a .mesh.xml file * @param name The material name to be found in a .mesh.xml file
* @param alias The material name to be found in a .material file * @param alias The material name to be found in a .material file
*/ */

@ -29,15 +29,14 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package com.jme3.scene.plugins.ogre.matext; package com.jme3.scene.plugins.ogre.matext;
import com.jme3.asset.AssetKey; import com.jme3.asset.AssetKey;
import com.jme3.material.MaterialList; import com.jme3.material.MaterialList;
/** /**
* <code>OgreMaterialKey</code> allows specifying material extensions, * <code>OgreMaterialKey</code> allows specifying material extensions, which map
* which map from Ogre3D base materials to jME3 materials * from Ogre3D base materials to jME3 materials
*/ */
public class OgreMaterialKey extends AssetKey<MaterialList> { public class OgreMaterialKey extends AssetKey<MaterialList> {
@ -51,10 +50,36 @@ public class OgreMaterialKey extends AssetKey<MaterialList> {
super(); super();
} }
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OgreMaterialKey other = (OgreMaterialKey) obj;
if (!super.equals(other)) {
return false;
}
if (this.matExts != other.matExts && (this.matExts == null || !this.matExts.equals(other.matExts))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 71 * hash + (super.hashCode());
hash = 71 * hash + (this.matExts != null ? this.matExts.hashCode() : 0);
return hash;
}
/** /**
* Set the {@link MaterialExtensionSet} to use for mapping * Set the {@link MaterialExtensionSet} to use for mapping base materials to
* base materials to jME3 matdefs when loading. * jME3 matdefs when loading. Set to
* Set to <code>null</code> to disable this functionality. * <code>null</code> to disable this functionality.
* *
* @param matExts The {@link MaterialExtensionSet} to use * @param matExts The {@link MaterialExtensionSet} to use
*/ */
@ -64,7 +89,9 @@ public class OgreMaterialKey extends AssetKey<MaterialList> {
/** /**
* Returns the {@link MaterialExtensionSet} previously set using * Returns the {@link MaterialExtensionSet} previously set using
* {@link OgreMaterialKey#setMaterialExtensionSet(com.jme3.scene.plugins.ogre.matext.MaterialExtensionSet) } method. * {@link OgreMaterialKey#setMaterialExtensionSet(com.jme3.scene.plugins.ogre.matext.MaterialExtensionSet)
* } method.
*
* @return the {@link MaterialExtensionSet} * @return the {@link MaterialExtensionSet}
*/ */
public MaterialExtensionSet getMaterialExtensionSet() { public MaterialExtensionSet getMaterialExtensionSet() {

Loading…
Cancel
Save