define_list_fix
saloisio 9 years ago
commit e187cb7e9b
  1. 2
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_objects_PhysicsRigidBody.cpp
  2. 2
      jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CylinderCollisionShape.java
  3. 12
      jme3-core/src/main/java/com/jme3/material/Material.java
  4. 13
      jme3-core/src/main/java/com/jme3/material/Technique.java
  5. 4
      jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
  6. 42
      jme3-core/src/main/java/com/jme3/scene/Spatial.java
  7. 2
      jme3-core/src/main/java/com/jme3/util/SafeArrayList.java
  8. 2
      jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CylinderCollisionShape.java

@ -52,7 +52,9 @@ extern "C" {
btMotionState* motionState = reinterpret_cast<btMotionState*>(motionstatId); btMotionState* motionState = reinterpret_cast<btMotionState*>(motionstatId);
btCollisionShape* shape = reinterpret_cast<btCollisionShape*>(shapeId); btCollisionShape* shape = reinterpret_cast<btCollisionShape*>(shapeId);
btVector3 localInertia = btVector3(); btVector3 localInertia = btVector3();
if(mass > 0){
shape->calculateLocalInertia(mass, localInertia); shape->calculateLocalInertia(mass, localInertia);
}
btRigidBody* body = new btRigidBody(mass, motionState, shape, localInertia); btRigidBody* body = new btRigidBody(mass, motionState, shape, localInertia);
body->setUserPointer(NULL); body->setUserPointer(NULL);
return reinterpret_cast<jlong>(body); return reinterpret_cast<jlong>(body);

@ -86,8 +86,10 @@ public class CylinderCollisionShape extends CollisionShape {
*/ */
@Override @Override
public void setScale(Vector3f scale) { public void setScale(Vector3f scale) {
if (!scale.equals(Vector3f.UNIT_XYZ)) {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CylinderCollisionShape cannot be scaled"); Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CylinderCollisionShape cannot be scaled");
} }
}
public void write(JmeExporter ex) throws IOException { public void write(JmeExporter ex) throws IOException {
super.write(ex); super.write(ex);

@ -35,7 +35,7 @@ import com.jme3.asset.AssetKey;
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.asset.CloneableSmartAsset; import com.jme3.asset.CloneableSmartAsset;
import com.jme3.export.*; import com.jme3.export.*;
import com.jme3.light.*; import com.jme3.light.LightList;
import com.jme3.material.RenderState.BlendMode; import com.jme3.material.RenderState.BlendMode;
import com.jme3.material.RenderState.FaceCullMode; import com.jme3.material.RenderState.FaceCullMode;
import com.jme3.material.TechniqueDef.LightMode; import com.jme3.material.TechniqueDef.LightMode;
@ -54,6 +54,8 @@ import com.jme3.texture.Image;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import com.jme3.texture.image.ColorSpace; import com.jme3.texture.image.ColorSpace;
import com.jme3.util.ListMap; import com.jme3.util.ListMap;
import com.jme3.util.SafeArrayList;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
@ -749,8 +751,8 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
sortingId = -1; sortingId = -1;
} }
private int applyOverrides(Renderer renderer, Shader shader, List<MatParamOverride> overrides, int unit) { private int applyOverrides(Renderer renderer, Shader shader, SafeArrayList<MatParamOverride> overrides, int unit) {
for (MatParamOverride override : overrides) { for (MatParamOverride override : overrides.getArray()) {
VarType type = override.getVarType(); VarType type = override.getVarType();
MatParam paramDef = def.getMaterialParam(override.getName()); MatParam paramDef = def.getMaterialParam(override.getName());
@ -777,7 +779,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
} }
private void updateShaderMaterialParameters(Renderer renderer, Shader shader, private void updateShaderMaterialParameters(Renderer renderer, Shader shader,
List<MatParamOverride> worldOverrides, List<MatParamOverride> forcedOverrides) { SafeArrayList<MatParamOverride> worldOverrides, SafeArrayList<MatParamOverride> forcedOverrides) {
int unit = 0; int unit = 0;
if (worldOverrides != null) { if (worldOverrides != null) {
@ -945,7 +947,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
updateRenderState(renderManager, renderer, techniqueDef); updateRenderState(renderManager, renderer, techniqueDef);
// Get world overrides // Get world overrides
List<MatParamOverride> overrides = geometry.getWorldMatParamOverrides(); SafeArrayList<MatParamOverride> overrides = geometry.getWorldMatParamOverrides();
// Select shader to use // Select shader to use
Shader shader = technique.makeCurrent(renderManager, overrides, renderManager.getForcedMatParams(), lights, rendererCaps); Shader shader = technique.makeCurrent(renderManager, overrides, renderManager.getForcedMatParams(), lights, rendererCaps);

@ -31,10 +31,10 @@
*/ */
package com.jme3.material; package com.jme3.material;
import com.jme3.material.logic.TechniqueDefLogic;
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.light.LightList; import com.jme3.light.LightList;
import com.jme3.material.TechniqueDef.LightMode; import com.jme3.material.TechniqueDef.LightMode;
import com.jme3.material.logic.TechniqueDefLogic;
import com.jme3.renderer.Caps; import com.jme3.renderer.Caps;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
@ -42,9 +42,8 @@ import com.jme3.shader.DefineList;
import com.jme3.shader.Shader; import com.jme3.shader.Shader;
import com.jme3.shader.VarType; import com.jme3.shader.VarType;
import com.jme3.util.ListMap; import com.jme3.util.ListMap;
import java.util.ArrayList; import com.jme3.util.SafeArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List;
/** /**
* Represents a technique instance. * Represents a technique instance.
@ -110,8 +109,8 @@ public final class Technique {
} }
} }
private void applyOverrides(DefineList defineList, List<MatParamOverride> overrides) { private void applyOverrides(DefineList defineList, SafeArrayList<MatParamOverride> overrides) {
for (MatParamOverride override : overrides) { for (MatParamOverride override : overrides.getArray()) {
if (!override.isEnabled()) { if (!override.isEnabled()) {
continue; continue;
} }
@ -134,8 +133,8 @@ public final class Technique {
* @param rendererCaps The renderer capabilities which the shader should support. * @param rendererCaps The renderer capabilities which the shader should support.
* @return A compatible shader. * @return A compatible shader.
*/ */
Shader makeCurrent(RenderManager renderManager, List<MatParamOverride> worldOverrides, Shader makeCurrent(RenderManager renderManager, SafeArrayList<MatParamOverride> worldOverrides,
List<MatParamOverride> forcedOverrides, SafeArrayList<MatParamOverride> forcedOverrides,
LightList lights, EnumSet<Caps> rendererCaps) { LightList lights, EnumSet<Caps> rendererCaps) {
TechniqueDefLogic logic = def.getLogic(); TechniqueDefLogic logic = def.getLogic();
AssetManager assetManager = owner.getMaterialDef().getAssetManager(); AssetManager assetManager = owner.getMaterialDef().getAssetManager();

@ -83,7 +83,7 @@ public class RenderManager {
private Material forcedMaterial = null; private Material forcedMaterial = null;
private String forcedTechnique = null; private String forcedTechnique = null;
private RenderState forcedRenderState = null; private RenderState forcedRenderState = null;
private final List<MatParamOverride> forcedOverrides = new ArrayList<>(); private final SafeArrayList<MatParamOverride> forcedOverrides = new SafeArrayList<>(MatParamOverride.class);
private int viewX, viewY, viewWidth, viewHeight; private int viewX, viewY, viewWidth, viewHeight;
private final Matrix4f orthoMatrix = new Matrix4f(); private final Matrix4f orthoMatrix = new Matrix4f();
private final LightList filteredLightList = new LightList(null); private final LightList filteredLightList = new LightList(null);
@ -462,7 +462,7 @@ public class RenderManager {
* *
* @return The forced material parameters. * @return The forced material parameters.
*/ */
public List<MatParamOverride> getForcedMatParams() { public SafeArrayList<MatParamOverride> getForcedMatParams() {
return forcedOverrides; return forcedOverrides;
} }

@ -138,8 +138,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
protected LightList localLights; protected LightList localLights;
protected transient LightList worldLights; protected transient LightList worldLights;
protected ArrayList<MatParamOverride> localOverrides; protected SafeArrayList<MatParamOverride> localOverrides;
protected ArrayList<MatParamOverride> worldOverrides; protected SafeArrayList<MatParamOverride> worldOverrides;
/** /**
* This spatial's name. * This spatial's name.
@ -207,8 +207,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
localLights = new LightList(this); localLights = new LightList(this);
worldLights = new LightList(this); worldLights = new LightList(this);
localOverrides = new ArrayList<>(); localOverrides = new SafeArrayList<>(MatParamOverride.class);
worldOverrides = new ArrayList<>(); worldOverrides = new SafeArrayList<>(MatParamOverride.class);
refreshFlags |= RF_BOUND; refreshFlags |= RF_BOUND;
} }
@ -432,7 +432,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
* *
* @return The list of local material parameter overrides. * @return The list of local material parameter overrides.
*/ */
public List<MatParamOverride> getLocalMatParamOverrides() { public SafeArrayList<MatParamOverride> getLocalMatParamOverrides() {
return localOverrides; return localOverrides;
} }
@ -446,7 +446,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
* *
* @return The list of world material parameter overrides. * @return The list of world material parameter overrides.
*/ */
public List<MatParamOverride> getWorldMatParamOverrides() { public SafeArrayList<MatParamOverride> getWorldMatParamOverrides() {
return worldOverrides; return worldOverrides;
} }
@ -1384,8 +1384,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
clone.localLights.setOwner(clone); clone.localLights.setOwner(clone);
clone.worldLights.setOwner(clone); clone.worldLights.setOwner(clone);
clone.worldOverrides = new ArrayList<MatParamOverride>(); clone.worldOverrides = new SafeArrayList<>(MatParamOverride.class);
clone.localOverrides = new ArrayList<MatParamOverride>(); clone.localOverrides = new SafeArrayList<>(MatParamOverride.class);
for (MatParamOverride override : localOverrides) { for (MatParamOverride override : localOverrides) {
clone.localOverrides.add((MatParamOverride) override.clone()); clone.localOverrides.add((MatParamOverride) override.clone());
@ -1524,18 +1524,24 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
} }
public void setUserData(String key, Object data) { public void setUserData(String key, Object data) {
if (data == null) {
if (userData != null) {
userData.remove(key);
if(userData.isEmpty()) {
userData = null;
}
}
} else {
if (userData == null) { if (userData == null) {
userData = new HashMap<String, Savable>(); userData = new HashMap<String, Savable>();
} }
if (data instanceof Savable) {
if(data == null){
userData.remove(key);
}else if (data instanceof Savable) {
userData.put(key, (Savable) data); userData.put(key, (Savable) data);
} else { } else {
userData.put(key, new UserData(UserData.getObjectType(data), data)); userData.put(key, new UserData(UserData.getObjectType(data), data));
} }
} }
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T getUserData(String key) { public <T> T getUserData(String key) {
@ -1598,7 +1604,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
capsule.write(shadowMode, "shadow_mode", ShadowMode.Inherit); capsule.write(shadowMode, "shadow_mode", ShadowMode.Inherit);
capsule.write(localTransform, "transform", Transform.IDENTITY); capsule.write(localTransform, "transform", Transform.IDENTITY);
capsule.write(localLights, "lights", null); capsule.write(localLights, "lights", null);
capsule.writeSavableArrayList(localOverrides, "overrides", null); capsule.writeSavableArrayList(new ArrayList(localOverrides), "overrides", null);
// Shallow clone the controls array to convert its type. // Shallow clone the controls array to convert its type.
capsule.writeSavableArrayList(new ArrayList(controls), "controlsList", null); capsule.writeSavableArrayList(new ArrayList(controls), "controlsList", null);
@ -1622,11 +1628,13 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
localLights = (LightList) ic.readSavable("lights", null); localLights = (LightList) ic.readSavable("lights", null);
localLights.setOwner(this); localLights.setOwner(this);
localOverrides = ic.readSavableArrayList("overrides", null); ArrayList<MatParamOverride> localOverridesList = ic.readSavableArrayList("overrides", null);
if (localOverrides == null) { if (localOverridesList == null) {
localOverrides = new ArrayList<>(); localOverrides = new SafeArrayList<>(MatParamOverride.class);
} else {
localOverrides = new SafeArrayList(MatParamOverride.class, localOverridesList);
} }
worldOverrides = new ArrayList<>(); worldOverrides = new SafeArrayList<>(MatParamOverride.class);
//changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split //changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split
//the AnimControl creates the SkeletonControl for old files and add it to the spatial. //the AnimControl creates the SkeletonControl for old files and add it to the spatial.

@ -258,7 +258,7 @@ public class SafeArrayList<E> implements List<E>, Cloneable {
if( o1 == null || !o1.equals(o2) ) if( o1 == null || !o1.equals(o2) )
return false; return false;
} }
return !(i1.hasNext() || !i2.hasNext()); return !(i1.hasNext() || i2.hasNext());
} }
public int hashCode() { public int hashCode() {

@ -90,8 +90,10 @@ public class CylinderCollisionShape extends CollisionShape {
*/ */
@Override @Override
public void setScale(Vector3f scale) { public void setScale(Vector3f scale) {
if (!scale.equals(Vector3f.UNIT_XYZ)) {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CylinderCollisionShape cannot be scaled"); Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "CylinderCollisionShape cannot be scaled");
} }
}
public void write(JmeExporter ex) throws IOException { public void write(JmeExporter ex) throws IOException {
super.write(ex); super.write(ex);

Loading…
Cancel
Save