diff options
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 27 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 33 |
2 files changed, 29 insertions, 31 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 86fc2267c64..bca2213fd73 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2166,22 +2166,25 @@ void BL_ConvertBlenderObjects(struct Main* maggie, (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), (float)axis2.x(),(float)axis2.y(),(float)axis2.z() ); - //if it is a generic 6DOF constraint, set all the limits accordingly - if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) + if (constraintId) { - int dof; - int dofbit=1; - for (dof=0;dof<6;dof++) + //if it is a generic 6DOF constraint, set all the limits accordingly + if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) { - if (dat->flag & dofbit) + int dof; + int dofbit=1; + for (dof=0;dof<6;dof++) { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); - } else - { - //minLimit > maxLimit means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); + if (dat->flag & dofbit) + { + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); + } else + { + //minLimit > maxLimit means free(disabled limit) for this degree of freedom + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); + } + dofbit<<=1; } - dofbit<<=1; } } } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index c4d4ba349b5..34894128690 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1035,9 +1035,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) : rb0->getCenterOfMassTransform() * pivotInA; btVector3 axisInA(axisX,axisY,axisZ); - btVector3 axisInB = rb1 ? - (rb1->getCenterOfMassTransform().getBasis().inverse()*(rb0->getCenterOfMassTransform().getBasis() * axisInA)) : - rb0->getCenterOfMassTransform().getBasis() * axisInA; + bool angularOnly = false; @@ -1087,16 +1085,14 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), axisInA.y(), axis1.y(), axis2.y(), axisInA.z(), axis1.z(), axis2.z() ); - - - btPlaneSpace1( axisInB, axis1, axis2 ); - frameInB.getBasis().setValue( axisInB.x(), axis1.x(), axis2.x(), - axisInB.y(), axis1.y(), axis2.y(), - axisInB.z(), axis1.z(), axis2.z() ); - frameInA.setOrigin( pivotInA ); - frameInB.setOrigin( pivotInB ); + btTransform inv = rb1->getCenterOfMassTransform().inverse(); + + btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; + + frameInB = inv * globalFrameA; + genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, frameInA,frameInB); @@ -1105,7 +1101,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl } else { static btRigidBody s_fixedObject2( 0,0,0); - btTransform frameInA; + btTransform frameInA; btTransform frameInB; btVector3 axis1, axis2; @@ -1115,15 +1111,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl axisInA.y(), axis1.y(), axis2.y(), axisInA.z(), axis1.z(), axis2.z() ); - - btPlaneSpace1( axisInB, axis1, axis2 ); - frameInB.getBasis().setValue( axisInB.x(), axis1.x(), axis2.x(), - axisInB.y(), axis1.y(), axis2.y(), - axisInB.z(), axis1.z(), axis2.z() ); - frameInA.setOrigin( pivotInA ); - frameInB.setOrigin( pivotInB ); + ///frameInB in worldspace + frameInB = rb0->getCenterOfMassTransform() * frameInA; genericConstraint = new btGeneric6DofConstraint( *rb0,s_fixedObject2, @@ -1152,6 +1143,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl if (rb1) { + btVector3 axisInB = rb1 ? + (rb1->getCenterOfMassTransform().getBasis().inverse()*(rb0->getCenterOfMassTransform().getBasis() * axisInA)) : + rb0->getCenterOfMassTransform().getBasis() * axisInA; + hinge = new btHingeConstraint( *rb0, *rb1,pivotInA,pivotInB,axisInA,axisInB); |