accept constraint with single rigidbody

This commit is contained in:
ejcoumans
2007-01-19 03:48:54 +00:00
parent 959e4498f4
commit 7b5301bb43
2 changed files with 61 additions and 27 deletions

View File

@@ -537,8 +537,8 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
const domRigid_constraint::domRef_attachmentRef attachRefBody = rigidConstraintRef->getRef_attachment();
const domRigid_constraint::domAttachmentRef attachBody1 = rigidConstraintRef->getAttachment();
daeString orgUri0 = attachRefBody->getRigid_body().getOriginalURI();
daeString orgUri1 = attachBody1->getRigid_body().getOriginalURI();
daeString orgUri0 = attachRefBody ? attachRefBody->getRigid_body().getOriginalURI() : "";
daeString orgUri1 = attachBody1 ? attachBody1->getRigid_body().getOriginalURI() : "";
btRigidBody* body0=0,*body1=0;
for (int i=0;i<m_numObjects;i++)
@@ -579,14 +579,22 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
{
btTransform attachFrameRef0;
attachFrameRef0.setIdentity();
if (attachRefBody)
{
attachFrameRef0 =
GetbtTransformFromCOLLADA_DOM
(
emptyMatrixArray,
attachRefBody->getRotate_array(),
attachRefBody->getTranslate_array());
}
btTransform attachFrameOther;
attachFrameOther.setIdentity();
if (attachBody1)
{
attachFrameOther =
GetbtTransformFromCOLLADA_DOM
(
@@ -594,6 +602,7 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
attachBody1->getRotate_array(),
attachBody1->getTranslate_array()
);
}
//convert INF / -INF into lower > upper
@@ -639,7 +648,22 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
}
if (body0&& body1)
if (body0 || body1)
{
//swap so that first body is non-zero
if (!body0)
{
createUniversalD6Constraint(
body1,
body0,
attachFrameOther,
attachFrameRef0,
linearLowerLimits,
linearUpperLimits,
angularLowerLimits,
angularUpperLimits
);
} else
{
createUniversalD6Constraint(
body0,
@@ -651,6 +675,7 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
angularLowerLimits,
angularUpperLimits
);
}
} else
{
printf("Error: Cannot find Rigidbodies(%s,%s) for constraint %s\n",orgUri0,orgUri1,constraintName);

View File

@@ -57,8 +57,17 @@ class MyColladaConverter : public ColladaConverter
const btVector3& angularMaxLimits
)
{
if (bodyRef && bodyOther)
if (bodyRef)
{
if (!bodyOther)
{
bodyOther = new btRigidBody(0,0,0);
bodyOther->setWorldTransform(bodyRef->getWorldTransform());
localAttachmentOther = localAttachmentFrameRef;
}
btGeneric6DofConstraint* genericConstraint = new btGeneric6DofConstraint(
*bodyRef,*bodyOther,
localAttachmentFrameRef,localAttachmentOther);