Bullet Native:

- avoid use of pointers for math primitives globally

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7474 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent 6d8b0a2b9d
commit 070ddd23f0
  1. 2
      engine/src/bullet/native/bullet-native-build.txt
  2. 6
      engine/src/bullet/native/com_jme3_bullet_PhysicsSpace.cpp
  3. 6
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_BoxCollisionShape.cpp
  4. 6
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_CollisionShape.cpp
  5. 10
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp
  6. 10
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_CylinderCollisionShape.cpp
  7. 6
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_PlaneCollisionShape.cpp
  8. 48
      engine/src/bullet/native/com_jme3_bullet_collision_shapes_SimplexCollisionShape.cpp
  9. 24
      engine/src/bullet/native/com_jme3_bullet_joints_SixDofJoint.cpp
  10. 12
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsCharacter.cpp
  11. 12
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsGhostObject.cpp
  12. 78
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsRigidBody.cpp
  13. 14
      engine/src/bullet/native/com_jme3_bullet_objects_PhysicsVehicle.cpp

@ -160,7 +160,7 @@ of the old one.
Netbeans Project
-----------------------------------
The project also includes a Netbeans project to edit and build
the source in the Netbeans IDE.
the source in the Netbeans IDE in the /src/bullet/ subfolder.
To have correct syntax highlighting in .cpp/.h files:

@ -351,9 +351,9 @@ extern "C" {
env->ThrowNew(newExc, "The physics space does not exist.");
return;
}
btVector3* gravity = &btVector3();
jmeBulletUtil::convert(env, vector, gravity);
space->getDynamicsWorld()->setGravity(*gravity);
btVector3 gravity = btVector3();
jmeBulletUtil::convert(env, vector, &gravity);
space->getDynamicsWorld()->setGravity(gravity);
}
/*

@ -48,9 +48,9 @@ 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);
btVector3 extents = btVector3();
jmeBulletUtil::convert(env, halfExtents, &extents);
btBoxShape* shape = new btBoxShape(extents);
return (long)shape;
}

@ -59,9 +59,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_shapes_CollisionShape_setLocalScaling
(JNIEnv * env, jobject object, jlong shapeId, jobject scale) {
btCollisionShape* shape = (btCollisionShape*) shapeId;
btVector3* scl = &btVector3();
jmeBulletUtil::convert(env, scale, scl);
shape->setLocalScaling(*scl);
btVector3 scl = btVector3();
jmeBulletUtil::convert(env, scale, &scl);
shape->setLocalScaling(scl);
}
/*

@ -61,11 +61,11 @@ extern "C" {
(JNIEnv *env, jobject object, jlong compoundId, jlong childId, jobject childLocation, jobject childRotation) {
btCompoundShape* shape = (btCompoundShape*) compoundId;
btCollisionShape* child = (btCollisionShape*) childId;
btMatrix3x3* mtx = &btMatrix3x3();
btTransform* trans = &btTransform(*mtx);
jmeBulletUtil::convert(env, childLocation, &trans->getOrigin());
jmeBulletUtil::convert(env, childRotation, &trans->getBasis());
shape->addChildShape(*trans, child);
btMatrix3x3 mtx = btMatrix3x3();
btTransform trans = btTransform(mtx);
jmeBulletUtil::convert(env, childLocation, &trans.getOrigin());
jmeBulletUtil::convert(env, childRotation, &trans.getBasis());
shape->addChildShape(trans, child);
return 0;
}

@ -48,18 +48,18 @@ 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);
btVector3 extents = btVector3();
jmeBulletUtil::convert(env, halfExtents, &extents);
btCollisionShape* shape;
switch (axis) {
case 0:
shape = new btCylinderShapeX(*extents);
shape = new btCylinderShapeX(extents);
break;
case 1:
shape = new btCylinderShape(*extents);
shape = new btCylinderShape(extents);
break;
case 2:
shape = new btCylinderShapeZ(*extents);
shape = new btCylinderShapeZ(extents);
break;
}
return (long) shape;

@ -49,9 +49,9 @@ 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);
btVector3 norm = btVector3();
jmeBulletUtil::convert(env, normal, &norm);
btStaticPlaneShape* shape = new btStaticPlaneShape(norm, constant);
return (long)shape;
}

@ -48,9 +48,9 @@ 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);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, vector1, &vec1);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(vec1);
return (long) simplexShape;
}
@ -62,11 +62,11 @@ 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();
jmeBulletUtil::convert(env, vector2, vec2);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(*vec1, *vec2);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, vector1, &vec1);
btVector3 vec2 = btVector3();
jmeBulletUtil::convert(env, vector2, &vec2);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(vec1, vec2);
return (long) simplexShape;
}
/*
@ -77,13 +77,13 @@ 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();
jmeBulletUtil::convert(env, vector2, vec2);
btVector3* vec3 = &btVector3();
jmeBulletUtil::convert(env, vector3, vec3);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(*vec1, *vec2, *vec3);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, vector1, &vec1);
btVector3 vec2 = btVector3();
jmeBulletUtil::convert(env, vector2, &vec2);
btVector3 vec3 = btVector3();
jmeBulletUtil::convert(env, vector3, &vec3);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(vec1, vec2, vec3);
return (long) simplexShape;
}
/*
@ -94,15 +94,15 @@ 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();
jmeBulletUtil::convert(env, vector2, vec2);
btVector3* vec3 = &btVector3();
jmeBulletUtil::convert(env, vector3, vec3);
btVector3* vec4 = &btVector3();
jmeBulletUtil::convert(env, vector4, vec4);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(*vec1, *vec2, *vec3, *vec4);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, vector1, &vec1);
btVector3 vec2 = btVector3();
jmeBulletUtil::convert(env, vector2, &vec2);
btVector3 vec3 = btVector3();
jmeBulletUtil::convert(env, vector3, &vec3);
btVector3 vec4 = btVector3();
jmeBulletUtil::convert(env, vector4, &vec4);
btBU_Simplex1to4* simplexShape = new btBU_Simplex1to4(vec1, vec2, vec3, vec4);
return (long) simplexShape;
}
#ifdef __cplusplus

@ -70,9 +70,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setLinearUpperLimit
(JNIEnv * env, jobject object, jlong jointId, jobject vector) {
btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, vector, vec);
joint->setLinearUpperLimit(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, vector, &vec);
joint->setLinearUpperLimit(vec);
}
/*
@ -83,9 +83,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setLinearLowerLimit
(JNIEnv * env, jobject object, jlong jointId, jobject vector) {
btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, vector, vec);
joint->setLinearLowerLimit(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, vector, &vec);
joint->setLinearLowerLimit(vec);
}
/*
@ -96,9 +96,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setAngularUpperLimit
(JNIEnv * env, jobject object, jlong jointId, jobject vector) {
btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, vector, vec);
joint->setAngularUpperLimit(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, vector, &vec);
joint->setAngularUpperLimit(vec);
}
/*
@ -109,9 +109,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_setAngularLowerLimit
(JNIEnv * env, jobject object, jlong jointId, jobject vector) {
btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, vector, vec);
joint->setAngularLowerLimit(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, vector, &vec);
joint->setAngularLowerLimit(vec);
}
/*

@ -89,9 +89,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_warp
(JNIEnv *env, jobject object, jlong objectId, jobject vector) {
btKinematicCharacterController* character = (btKinematicCharacterController*) objectId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, vector, vec);
character->warp(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, vector, &vec);
character->warp(vec);
}
/*
@ -102,9 +102,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsCharacter_setWalkDirection
(JNIEnv *env, jobject object, jlong objectId, jobject vector) {
btKinematicCharacterController* character = (btKinematicCharacterController*) objectId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, vector, vec);
character->setWalkDirection(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, vector, &vec);
character->setWalkDirection(vec);
}
/*

@ -74,10 +74,6 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setPhysicsLocation
(JNIEnv *env, jobject object, jlong objectId, jobject value){
btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId;
// btVector3* vec = new btVector3();
// jmeBulletUtil::convert(value, vec);
// ghost->getWorldTransform().setOrigin(vec);
// delete(vec);
jmeBulletUtil::convert(env, value, &ghost->getWorldTransform().getOrigin());
}
@ -89,10 +85,6 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setPhysicsRotation__JLcom_jme3_math_Matrix3f_2
(JNIEnv *env, jobject object, jlong objectId, jobject value){
btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId;
// btVector3* vec = new btVector3();
// jmeBulletUtil::convert(value, vec);
// ghost->getWorldTransform().setOrigin(vec);
// delete(vec);
jmeBulletUtil::convert(env, value, &ghost->getWorldTransform().getBasis());
}
@ -104,10 +96,6 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsGhostObject_setPhysicsRotation__JLcom_jme3_math_Quaternion_2
(JNIEnv *env, jobject object, jlong objectId, jobject value){
btPairCachingGhostObject* ghost = (btPairCachingGhostObject*)objectId;
// btVector3* vec = new btVector3();
// jmeBulletUtil::convert(value, vec);
// ghost->getWorldTransform().setOrigin(vec);
// delete(vec);
jmeBulletUtil::convertQuat(env, value, &ghost->getWorldTransform().getBasis());
}

@ -51,9 +51,9 @@ extern "C" {
jmeClasses::initJavaClasses(env);
btMotionState* motionState = (btMotionState*) motionstatId;
btCollisionShape* shape = (btCollisionShape*) shapeId;
btVector3* localInertia = &btVector3();
shape->calculateLocalInertia(mass, *localInertia);
btRigidBody* body = new btRigidBody(mass, motionState, shape, *localInertia);
btVector3 localInertia = btVector3();
shape->calculateLocalInertia(mass, localInertia);
btRigidBody* body = new btRigidBody(mass, motionState, shape, localInertia);
return (long) body;
}
@ -257,9 +257,9 @@ extern "C" {
(JNIEnv *env, jobject object, jlong bodyId, jlong shapeId, jfloat mass) {
btRigidBody* body = (btRigidBody*) bodyId;
btCollisionShape* shape = (btCollisionShape*) shapeId;
btVector3* localInertia = &btVector3();
shape->calculateLocalInertia(mass, *localInertia);
body->setMassProps(mass, *localInertia);
btVector3 localInertia = btVector3();
shape->calculateLocalInertia(mass, localInertia);
body->setMassProps(mass, localInertia);
return (long) body;
}
@ -282,9 +282,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setGravity
(JNIEnv *env, jobject object, jlong bodyId, jobject value) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, value, vec);
body->setGravity(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, value, &vec);
body->setGravity(vec);
}
/*
@ -394,9 +394,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularVelocity
(JNIEnv *env, jobject object, jlong bodyId, jobject value) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, value, vec);
body->setAngularVelocity(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, value,&vec);
body->setAngularVelocity(vec);
}
/*
@ -418,9 +418,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setLinearVelocity
(JNIEnv *env, jobject object, jlong bodyId, jobject value) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec = &btVector3();
jmeBulletUtil::convert(env, value, vec);
body->setLinearVelocity(*vec);
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, value, &vec);
body->setLinearVelocity(vec);
}
/*
@ -431,11 +431,11 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyForce
(JNIEnv *env, jobject object, jlong bodyId, jobject force, jobject location) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec1 = &btVector3();
btVector3* vec2 = &btVector3();
jmeBulletUtil::convert(env, force, vec1);
jmeBulletUtil::convert(env, location, vec2);
body->applyForce(*vec1, *vec2);
btVector3 vec1 = btVector3();
btVector3 vec2 = btVector3();
jmeBulletUtil::convert(env, force, &vec1);
jmeBulletUtil::convert(env, location, &vec2);
body->applyForce(vec1, vec2);
}
/*
@ -446,9 +446,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyCentralForce
(JNIEnv *env, jobject object, jlong bodyId, jobject force) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, force, vec1);
body->applyCentralForce(*vec1);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, force, &vec1);
body->applyCentralForce(vec1);
}
/*
@ -459,9 +459,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyTorque
(JNIEnv *env, jobject object, jlong bodyId, jobject force) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, force, vec1);
body->applyTorque(*vec1);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, force, &vec1);
body->applyTorque(vec1);
}
/*
@ -472,11 +472,11 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyImpulse
(JNIEnv *env, jobject object, jlong bodyId, jobject force, jobject location) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec1 = &btVector3();
btVector3* vec2 = &btVector3();
jmeBulletUtil::convert(env, force, vec1);
jmeBulletUtil::convert(env, location, vec2);
body->applyImpulse(*vec1, *vec2);
btVector3 vec1 = btVector3();
btVector3 vec2 = btVector3();
jmeBulletUtil::convert(env, force, &vec1);
jmeBulletUtil::convert(env, location, &vec2);
body->applyImpulse(vec1, vec2);
}
/*
@ -487,9 +487,9 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyTorqueImpulse
(JNIEnv *env, jobject object, jlong bodyId, jobject force) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec1 = &btVector3();
jmeBulletUtil::convert(env, force, vec1);
body->applyTorqueImpulse(*vec1);
btVector3 vec1 = btVector3();
jmeBulletUtil::convert(env, force, &vec1);
body->applyTorqueImpulse(vec1);
}
/*
@ -611,11 +611,11 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularFactor
(JNIEnv *env, jobject object, jlong bodyId, jfloat value) {
btRigidBody* body = (btRigidBody*) bodyId;
btVector3* vec1 = &btVector3();
vec1->setX(value);
vec1->setY(value);
vec1->setZ(value);
body->setAngularFactor(*vec1);
btVector3 vec1 = btVector3();
vec1.setX(value);
vec1.setY(value);
vec1.setZ(value);
body->setAngularFactor(vec1);
}
#ifdef __cplusplus

@ -101,14 +101,14 @@ extern "C" {
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsVehicle_addWheel
(JNIEnv *env, jobject object, jlong vehicleId, jobject location, jobject direction, jobject axle, jfloat restLength, jfloat radius, jobject tuning, jboolean frontWheel) {
btRaycastVehicle* vehicle = (btRaycastVehicle*) vehicleId;
btVector3* vec1 = &btVector3();
btVector3* vec2 = &btVector3();
btVector3* vec3 = &btVector3();
jmeBulletUtil::convert(env, location, vec1);
jmeBulletUtil::convert(env, direction, vec2);
jmeBulletUtil::convert(env, axle, vec3);
btVector3 vec1 = btVector3();
btVector3 vec2 = btVector3();
btVector3 vec3 = btVector3();
jmeBulletUtil::convert(env, location, &vec1);
jmeBulletUtil::convert(env, direction, &vec2);
jmeBulletUtil::convert(env, axle, &vec3);
btRaycastVehicle::btVehicleTuning tune;
btWheelInfo* info = &vehicle->addWheel(*vec1, *vec2, *vec3, restLength, radius, tune, frontWheel);
btWheelInfo* info = &vehicle->addWheel(vec1, vec2, vec3, restLength, radius, tune, frontWheel);
return (long) info;
}

Loading…
Cancel
Save