- initialize native bullet classes on every object creation

- remove initialization from java physicsspace

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7431 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent dd67011809
commit 3c45cc6e97
  1. 2
      engine/src/bullet/com/jme3/bullet/PhysicsSpace.java
  2. 1
      engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp
  3. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_BoxCollisionShape.cpp
  4. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_CapsuleCollisionShape.cpp
  5. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp
  6. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_ConeCollisionShape.cpp
  7. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_CylinderCollisionShape.cpp
  8. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_GImpactCollisionShape.cpp
  9. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_HeightfieldCollisionShape.cpp
  10. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_HullCollisionShape.cpp
  11. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_MeshCollisionShape.cpp
  12. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_PlaneCollisionShape.cpp
  13. 4
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_SimplexCollisionShape.cpp
  14. 1
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_SphereCollisionShape.cpp
  15. 1
      engine/src/bullet/native/com_jme3_bullet_joints_ConeJoint.cpp
  16. 1
      engine/src/bullet/native/com_jme3_bullet_joints_HingeJoint.cpp
  17. 1
      engine/src/bullet/native/com_jme3_bullet_joints_Point2PointJoint.cpp
  18. 1
      engine/src/bullet/native/com_jme3_bullet_joints_SixDofJoint.cpp
  19. 1
      engine/src/bullet/native/com_jme3_bullet_joints_SliderJoint.cpp
  20. 1
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp
  21. 1
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp
  22. 1
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp
  23. 1
      engine/src/bullet/native/com_jme3_bullet_objects_infos_RigidBodyMotionState.cpp
  24. 1
      engine/src/bullet/native/com_jme3_bullet_util_NativeMeshUtil.cpp

@ -142,7 +142,6 @@ public class PhysicsSpace {
this.worldMax.set(worldMax);
this.broadphaseType = broadphaseType;
create();
initNativePhysics();
}
/**
@ -150,7 +149,6 @@ public class PhysicsSpace {
*/
public void create() {
//TODO: boroadphase!
initNativePhysics();
physicsSpaceId = createPhysicsSpace(worldMin.x, worldMin.y, worldMin.z, worldMax.x, worldMax.y, worldMax.z, 3, false);
pQueueTL.set(pQueue);
physicsSpaceTL.set(this);

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace
(JNIEnv * env, jobject object, jfloat minX, jfloat minY, jfloat minZ, jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphase, jboolean threading) {
jmeClasses::initJavaClasses(env);
jmePhysicsSpace* space = new jmePhysicsSpace(env, object);
if (space == NULL) {
jclass newExc = env->FindClass("java/lang/IllegalStateException");

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_BoxCollisionShape_createShape
(JNIEnv *env, jobject object, jobject halfExtents) {
jmeClasses::initJavaClasses(env);
btVector3* extents = &btVector3();
jmeBulletUtil::convert(env, halfExtents, extents);
btBoxShape* shape = new btBoxShape(*extents);

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_CapsuleCollisionShape_createShape
(JNIEnv * env, jobject object, jint axis, jfloat radius, jfloat height) {
jmeClasses::initJavaClasses(env);
btCollisionShape* shape;
switch(axis){
case 0:

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_CompoundCollisionShape_createShape
(JNIEnv *env, jobject object) {
jmeClasses::initJavaClasses(env);
btCompoundShape* shape = new btCompoundShape();
return (long) shape;
}

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_ConeCollisionShape_createShape
(JNIEnv * env, jobject object, jint axis, jfloat radius, jfloat height) {
jmeClasses::initJavaClasses(env);
btCollisionShape* shape;
switch (axis) {
case 0:

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_CylinderCollisionShape_createShape
(JNIEnv * env, jobject object, jint axis, jobject halfExtents) {
jmeClasses::initJavaClasses(env);
btVector3* extents = &btVector3();
jmeBulletUtil::convert(env, halfExtents, extents);
btCollisionShape* shape;

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_GImpactCollisionShape_createShape
(JNIEnv * env, jobject object, jlong meshId) {
jmeClasses::initJavaClasses(env);
btTriangleIndexVertexArray* array = (btTriangleIndexVertexArray*) meshId;
btGImpactMeshShape* shape = new btGImpactMeshShape(array);
return (long) shape;

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_HeightfieldCollisionShape_createShape
(JNIEnv * env, jobject object, jint heightStickWidth, jint heightStickLength, jobject heightfieldData, jfloat heightScale, jfloat minHeight, jfloat maxHeight, jint upAxis, jboolean flipQuadEdges) {
jmeClasses::initJavaClasses(env);
void* data = env->GetDirectBufferAddress(heightfieldData);
btHeightfieldTerrainShape* shape=new btHeightfieldTerrainShape(heightStickWidth, heightStickLength, data, heightScale, minHeight, maxHeight, upAxis, PHY_FLOAT, flipQuadEdges);
return (long)shape;

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_HullCollisionShape_createShape
(JNIEnv *env, jobject object, jobject array) {
jmeClasses::initJavaClasses(env);
float* data = (float*) env->GetDirectBufferAddress(array);
//TODO: capacity will not always be length!
int length = env->GetDirectBufferCapacity(array)/4;

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_MeshCollisionShape_createShape
(JNIEnv * env, jobject object, jlong arrayId) {
jmeClasses::initJavaClasses(env);
btTriangleIndexVertexArray* array = (btTriangleIndexVertexArray*) arrayId;
btBvhTriangleMeshShape* shape = new btBvhTriangleMeshShape(array, true, true);
return (long) shape;

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_PlaneCollisionShape_createShape
(JNIEnv * env, jobject object, jobject normal, jfloat constant) {
jmeClasses::initJavaClasses(env);
btVector3* norm = &btVector3();
jmeBulletUtil::convert(env, normal, norm);
btStaticPlaneShape* shape = new btStaticPlaneShape(*norm, constant);

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_SimplexCollisionShape_createShape__Lcom_jme3_math_Vector3f_2
(JNIEnv *env, jobject object, jobject vector1) {
jmeClasses::initJavaClasses(env);
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, vector1, vec1);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(*vec1);
@ -60,6 +61,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_SimplexCollisionShape_createShape__Lcom_jme3_math_Vector3f_2Lcom_jme3_math_Vector3f_2
(JNIEnv *env, jobject object, jobject vector1, jobject vector2) {
jmeClasses::initJavaClasses(env);
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, vector1, vec1);
btVector3* vec2 = &btVector3();
@ -74,6 +76,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_SimplexCollisionShape_createShape__Lcom_jme3_math_Vector3f_2Lcom_jme3_math_Vector3f_2Lcom_jme3_math_Vector3f_2
(JNIEnv * env, jobject object, jobject vector1, jobject vector2, jobject vector3) {
jmeClasses::initJavaClasses(env);
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, vector1, vec1);
btVector3* vec2 = &btVector3();
@ -90,6 +93,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_SimplexCollisionShape_createShape__Lcom_jme3_math_Vector3f_2Lcom_jme3_math_Vector3f_2Lcom_jme3_math_Vector3f_2Lcom_jme3_math_Vector3f_2
(JNIEnv * env, jobject object, jobject vector1, jobject vector2, jobject vector3, jobject vector4) {
jmeClasses::initJavaClasses(env);
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, vector1, vec1);
btVector3* vec2 = &btVector3();

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_collision_shapes_SphereCollisionShape_createShape
(JNIEnv *env, jobject object, jfloat radius) {
jmeClasses::initJavaClasses(env);
btSphereShape* shape=new btSphereShape(radius);
return (long)shape;
}

@ -70,6 +70,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_ConeJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB) {
jmeClasses::initJavaClasses(env);
btRigidBody* bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btMatrix3x3* mtx1 = &btMatrix3x3();

@ -157,6 +157,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_HingeJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject axisA, jobject pivotB, jobject axisB) {
jmeClasses::initJavaClasses(env);
btRigidBody* bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btVector3* vec1 = &btVector3();

@ -113,6 +113,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_Point2PointJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject pivotB) {
jmeClasses::initJavaClasses(env);
btRigidBody* bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
//TODO: matrix not needed?

@ -121,6 +121,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
jmeClasses::initJavaClasses(env);
btRigidBody* bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btMatrix3x3* mtx1 = &btMatrix3x3();

@ -663,6 +663,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SliderJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
jmeClasses::initJavaClasses(env);
btRigidBody* bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btMatrix3x3* mtx1=&btMatrix3x3();

@ -50,6 +50,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_createGhostObject
(JNIEnv * env, jobject object) {
jmeClasses::initJavaClasses(env);
btPairCachingGhostObject* ghost = new btPairCachingGhostObject();
return (long) ghost;
}

@ -50,6 +50,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_createGhostObject
(JNIEnv * env, jobject object) {
jmeClasses::initJavaClasses(env);
btPairCachingGhostObject* ghost = new btPairCachingGhostObject();
return (long) ghost;
}

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_createRigidBody
(JNIEnv *env, jobject object, jfloat mass, jlong motionstatId, jlong shapeId) {
jmeClasses::initJavaClasses(env);
btMotionState* motionState = (btMotionState*) motionstatId;
btCollisionShape* shape = (btCollisionShape*) shapeId;
btVector3* localInertia = &btVector3();

@ -48,6 +48,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_infos_RigidBodyMotionState_createMotionState
(JNIEnv *env, jobject object) {
jmeClasses::initJavaClasses(env);
jmeMotionState* motionState = new jmeMotionState();
return (long) motionState;
}

@ -47,6 +47,7 @@ extern "C" {
*/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_util_NativeMeshUtil_createTriangleIndexVertexArray
(JNIEnv * env, jclass cls, jobject triangleIndexBase, jobject vertexIndexBase, jint numTriangles, jint numVertices, jint vertexStride, jint triangleIndexStride) {
jmeClasses::initJavaClasses(env);
int* triangles = (int*) env->GetDirectBufferAddress(triangleIndexBase);
float* vertices = (float*) env->GetDirectBufferAddress(vertexIndexBase);
btTriangleIndexVertexArray* array = new btTriangleIndexVertexArray(numTriangles, triangles, triangleIndexStride, numVertices, vertices, vertexStride);

Loading…
Cancel
Save