- create HeightFieldCollisionShapes in CollisionShapeFactory CompoundShape generation as well
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8736 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
bd613fee2b
commit
aa4b8d19e7
@ -89,13 +89,24 @@ public class CollisionShapeFactory {
|
||||
private static CompoundCollisionShape createCompoundShape(Node realRootNode,
|
||||
Node rootNode, CompoundCollisionShape shape, boolean meshAccurate, boolean dynamic) {
|
||||
for (Spatial spatial : rootNode.getChildren()) {
|
||||
if (spatial instanceof Node) {
|
||||
if (spatial instanceof TerrainQuad) {
|
||||
Boolean bool = spatial.getUserData(UserData.JME_PHYSICSIGNORE);
|
||||
if (bool != null && bool.booleanValue()) {
|
||||
continue; // go to the next child in the loop
|
||||
}
|
||||
TerrainQuad terrain = (TerrainQuad) spatial;
|
||||
Transform trans = getTransform(spatial, realRootNode);
|
||||
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()),
|
||||
trans.getTranslation(),
|
||||
trans.getRotation().toRotationMatrix());
|
||||
} else if (spatial instanceof Node) {
|
||||
createCompoundShape(realRootNode, (Node) spatial, shape, meshAccurate, dynamic);
|
||||
} else if (spatial instanceof Geometry) {
|
||||
Boolean bool = spatial.getUserData(UserData.JME_PHYSICSIGNORE);
|
||||
if (bool != null && bool.booleanValue()) {
|
||||
continue; // go to the next child in the loop
|
||||
}
|
||||
|
||||
if (meshAccurate) {
|
||||
CollisionShape childShape = dynamic
|
||||
? createSingleDynamicMeshShape((Geometry) spatial, realRootNode)
|
||||
@ -112,6 +123,16 @@ public class CollisionShapeFactory {
|
||||
trans.getTranslation(),
|
||||
trans.getRotation().toRotationMatrix());
|
||||
}
|
||||
} else if (spatial instanceof TerrainPatch) {
|
||||
Boolean bool = spatial.getUserData(UserData.JME_PHYSICSIGNORE);
|
||||
if (bool != null && bool.booleanValue()) {
|
||||
continue; // go to the next child in the loop
|
||||
}
|
||||
TerrainPatch terrain = (TerrainPatch) spatial;
|
||||
Transform trans = getTransform(spatial, realRootNode);
|
||||
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightmap(), terrain.getLocalScale()),
|
||||
trans.getTranslation(),
|
||||
trans.getRotation().toRotationMatrix());
|
||||
}
|
||||
}
|
||||
return shape;
|
||||
|
@ -89,14 +89,24 @@ public class CollisionShapeFactory {
|
||||
private static CompoundCollisionShape createCompoundShape(Node realRootNode,
|
||||
Node rootNode, CompoundCollisionShape shape, boolean meshAccurate, boolean dynamic) {
|
||||
for (Spatial spatial : rootNode.getChildren()) {
|
||||
if (spatial instanceof Node) {
|
||||
if (spatial instanceof TerrainQuad) {
|
||||
Boolean bool = spatial.getUserData(UserData.JME_PHYSICSIGNORE);
|
||||
if (bool != null && bool.booleanValue()) {
|
||||
continue; // go to the next child in the loop
|
||||
}
|
||||
TerrainQuad terrain = (TerrainQuad) spatial;
|
||||
Transform trans = getTransform(spatial, realRootNode);
|
||||
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()),
|
||||
trans.getTranslation(),
|
||||
trans.getRotation().toRotationMatrix());
|
||||
} else if (spatial instanceof Node) {
|
||||
createCompoundShape(realRootNode, (Node) spatial, shape, meshAccurate, dynamic);
|
||||
} else if (spatial instanceof Geometry) {
|
||||
Boolean bool = spatial.getUserData(UserData.JME_PHYSICSIGNORE);
|
||||
if (bool != null && bool.booleanValue()){
|
||||
if (bool != null && bool.booleanValue()) {
|
||||
continue; // go to the next child in the loop
|
||||
}
|
||||
|
||||
|
||||
if (meshAccurate) {
|
||||
CollisionShape childShape = dynamic
|
||||
? createSingleDynamicMeshShape((Geometry) spatial, realRootNode)
|
||||
@ -113,6 +123,16 @@ public class CollisionShapeFactory {
|
||||
trans.getTranslation(),
|
||||
trans.getRotation().toRotationMatrix());
|
||||
}
|
||||
} else if (spatial instanceof TerrainPatch) {
|
||||
Boolean bool = spatial.getUserData(UserData.JME_PHYSICSIGNORE);
|
||||
if (bool != null && bool.booleanValue()) {
|
||||
continue; // go to the next child in the loop
|
||||
}
|
||||
TerrainPatch terrain = (TerrainPatch) spatial;
|
||||
Transform trans = getTransform(spatial, realRootNode);
|
||||
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightmap(), terrain.getLocalScale()),
|
||||
trans.getTranslation(),
|
||||
trans.getRotation().toRotationMatrix());
|
||||
}
|
||||
}
|
||||
return shape;
|
||||
@ -235,7 +255,7 @@ public class CollisionShapeFactory {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method moves each child shape of a compound shape by the given vector
|
||||
* @param vector
|
||||
|
Loading…
x
Reference in New Issue
Block a user