Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Nov 28, 2018
1 parent 8e0db85 commit 1071ec3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ extern "C" {
btTransform transB = btTransform(mtx2);
jmeBulletUtil::convert(env, pivotB, &transB.getOrigin());
jmeBulletUtil::convert(env, rotB, &transB.getBasis());
btConeTwistConstraint* joint = new btConeTwistConstraint(*bodyA, *bodyB, transA, transB);

btConeTwistConstraint *joint;

if (bodyA->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT) { // If bodyA is static
joint = new btConeTwistConstraint(*bodyB, transB);
}else if(bodyB->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyB is static
joint = new btConeTwistConstraint(*bodyA, transA);
}else{
joint = new btConeTwistConstraint(*bodyA, *bodyB, transA, transB);
}

return reinterpret_cast<jlong>(joint);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ extern "C" {

btHingeConstraint *joint;

// If bodyA is static, use a static point instead of a rigidbody. Fix issue #877
if(bodyA->getCollisionFlags()&btCollisionObject::CF_STATIC_OBJECT==btCollisionObject::CF_STATIC_OBJECT){
if(bodyA->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyA is static
joint = new btHingeConstraint(*bodyB, pivotBbt, axisBbt);
}else if(bodyB->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyB is static
joint = new btHingeConstraint(*bodyA, pivotAbt, axisAbt);
}else{
joint = new btHingeConstraint(*bodyA, *bodyB, pivotAbt, pivotBbt, axisAbt, axisBbt);
}

return reinterpret_cast<jlong>(joint);
}
#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ extern "C" {
btVector3 pivotBIn;
jmeBulletUtil::convert(env, pivotA, &pivotAIn);
jmeBulletUtil::convert(env, pivotB, &pivotBIn);
btPoint2PointConstraint * joint = new btPoint2PointConstraint(*bodyA, *bodyB, pivotAIn, pivotBIn);

btPoint2PointConstraint *joint;
if (bodyA->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT) { // If bodyA is static
joint = new btPoint2PointConstraint(*bodyB, pivotBIn);
}else if(bodyB->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyB is static
joint = new btPoint2PointConstraint(*bodyA, pivotAIn);
}else{
joint = new btPoint2PointConstraint(*bodyA, *bodyB, pivotAIn, pivotBIn);
}

return reinterpret_cast<jlong>(joint);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,17 @@ extern "C" {
btTransform transB = btTransform(mtx2);
jmeBulletUtil::convert(env, pivotB, &transB.getOrigin());
jmeBulletUtil::convert(env, rotB, &transB.getBasis());
btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);

btGeneric6DofConstraint *joint;
if (bodyA->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT) { // If bodyA is static
joint = new btGeneric6DofConstraint(*bodyB, transB, useLinearReferenceFrameA);
}else if(bodyB->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyB is static
joint = new btGeneric6DofConstraint(*bodyA, transA, useLinearReferenceFrameA);
}else{
joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);
}


return reinterpret_cast<jlong>(joint);
}
#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoin
jmeBulletUtil::convert(env, pivotB, &transB.getOrigin());
jmeBulletUtil::convert(env, rotB, &transB.getBasis());

btGeneric6DofSpringConstraint* joint = new btGeneric6DofSpringConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);
btGeneric6DofSpringConstraint *joint;
if (bodyA->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT) { // If bodyA is static
joint = new btGeneric6DofSpringConstraint(*bodyB, transB, useLinearReferenceFrameA);
}else if(bodyB->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyB is static
joint = new btGeneric6DofSpringConstraint(*bodyA, transA, useLinearReferenceFrameA);
}else{
joint = new btGeneric6DofSpringConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);
}

return reinterpret_cast<jlong>(joint);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,17 @@ extern "C" {
btTransform transB = btTransform(mtx2);
jmeBulletUtil::convert(env, pivotB, &transB.getOrigin());
jmeBulletUtil::convert(env, rotB, &transB.getBasis());
btSliderConstraint* joint = new btSliderConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);

btSliderConstraint *joint;
if (bodyA->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT) { // If bodyA is static
joint = new btSliderConstraint(*bodyB, transB, useLinearReferenceFrameA);
}else if(bodyB->getCollisionFlags() & btCollisionObject::CF_STATIC_OBJECT == btCollisionObject::CF_STATIC_OBJECT){ // If bodyB is static
joint = new btSliderConstraint(*bodyA, transA, useLinearReferenceFrameA);
}else{
joint = new btSliderConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);
}


return reinterpret_cast<jlong>(joint);
}

Expand Down

0 comments on commit 1071ec3

Please sign in to comment.