fix GImpact scaling in jme3-bullet (native Bullet)

accellbaker
sgold 6 years ago
parent 2cd3dac543
commit 56d37cb866
  1. 14
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_GImpactCollisionShape.cpp
  2. 18
      jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/GImpactCollisionShape.java

@ -55,6 +55,18 @@ extern "C" {
return reinterpret_cast<jlong>(shape); return reinterpret_cast<jlong>(shape);
} }
/*
* Class: com_jme3_bullet_collision_shapes_GImpactCollisionShape
* Method: recalcAabb
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_shapes_GImpactCollisionShape_recalcAabb
(JNIEnv *env, jobject object, jlong shapeId) {
btGImpactMeshShape *pShape
= reinterpret_cast<btGImpactMeshShape *> (shapeId);
pShape->updateBound();
}
/* /*
* Class: com_jme3_bullet_collision_shapes_GImpactCollisionShape * Class: com_jme3_bullet_collision_shapes_GImpactCollisionShape
* Method: finalizeNative * Method: finalizeNative
@ -65,7 +77,7 @@ extern "C" {
btTriangleIndexVertexArray* array = reinterpret_cast<btTriangleIndexVertexArray*> (meshId); btTriangleIndexVertexArray* array = reinterpret_cast<btTriangleIndexVertexArray*> (meshId);
delete(array); delete(array);
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -36,6 +36,7 @@ import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter; import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter; import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule; import com.jme3.export.OutputCapsule;
import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.mesh.IndexBuffer; import com.jme3.scene.mesh.IndexBuffer;
@ -153,6 +154,23 @@ public class GImpactCollisionShape extends CollisionShape {
vertexBase = ByteBuffer.wrap(capsule.readByteArray("vertexBase", new byte[0])); vertexBase = ByteBuffer.wrap(capsule.readByteArray("vertexBase", new byte[0]));
createShape(); createShape();
} }
/**
* Alter the scaling factors of this shape.
* <p>
* Note that if the shape is shared (between collision objects and/or
* compound shapes) changes can have unintended consequences.
*
* @param scale the desired scaling factor for each local axis (not null, no
* negative component, unaffected, default=(1,1,1))
*/
@Override
public void setScale(Vector3f scale) {
super.setScale(scale);
recalcAabb(objectId);
}
native private void recalcAabb(long shapeId);
/** /**
* Instantiate the configured shape in Bullet. * Instantiate the configured shape in Bullet.

Loading…
Cancel
Save