accept constraint with single rigidbody
This commit is contained in:
@@ -537,8 +537,8 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
|
|||||||
const domRigid_constraint::domRef_attachmentRef attachRefBody = rigidConstraintRef->getRef_attachment();
|
const domRigid_constraint::domRef_attachmentRef attachRefBody = rigidConstraintRef->getRef_attachment();
|
||||||
const domRigid_constraint::domAttachmentRef attachBody1 = rigidConstraintRef->getAttachment();
|
const domRigid_constraint::domAttachmentRef attachBody1 = rigidConstraintRef->getAttachment();
|
||||||
|
|
||||||
daeString orgUri0 = attachRefBody->getRigid_body().getOriginalURI();
|
daeString orgUri0 = attachRefBody ? attachRefBody->getRigid_body().getOriginalURI() : "";
|
||||||
daeString orgUri1 = attachBody1->getRigid_body().getOriginalURI();
|
daeString orgUri1 = attachBody1 ? attachBody1->getRigid_body().getOriginalURI() : "";
|
||||||
btRigidBody* body0=0,*body1=0;
|
btRigidBody* body0=0,*body1=0;
|
||||||
|
|
||||||
for (int i=0;i<m_numObjects;i++)
|
for (int i=0;i<m_numObjects;i++)
|
||||||
@@ -579,14 +579,22 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
|
|||||||
{
|
{
|
||||||
|
|
||||||
btTransform attachFrameRef0;
|
btTransform attachFrameRef0;
|
||||||
|
attachFrameRef0.setIdentity();
|
||||||
|
|
||||||
|
if (attachRefBody)
|
||||||
|
{
|
||||||
attachFrameRef0 =
|
attachFrameRef0 =
|
||||||
GetbtTransformFromCOLLADA_DOM
|
GetbtTransformFromCOLLADA_DOM
|
||||||
(
|
(
|
||||||
emptyMatrixArray,
|
emptyMatrixArray,
|
||||||
attachRefBody->getRotate_array(),
|
attachRefBody->getRotate_array(),
|
||||||
attachRefBody->getTranslate_array());
|
attachRefBody->getTranslate_array());
|
||||||
|
}
|
||||||
|
|
||||||
btTransform attachFrameOther;
|
btTransform attachFrameOther;
|
||||||
|
attachFrameOther.setIdentity();
|
||||||
|
if (attachBody1)
|
||||||
|
{
|
||||||
attachFrameOther =
|
attachFrameOther =
|
||||||
GetbtTransformFromCOLLADA_DOM
|
GetbtTransformFromCOLLADA_DOM
|
||||||
(
|
(
|
||||||
@@ -594,6 +602,7 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
|
|||||||
attachBody1->getRotate_array(),
|
attachBody1->getRotate_array(),
|
||||||
attachBody1->getTranslate_array()
|
attachBody1->getTranslate_array()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//convert INF / -INF into lower > upper
|
//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(
|
createUniversalD6Constraint(
|
||||||
body0,
|
body0,
|
||||||
@@ -651,6 +675,7 @@ void ColladaConverter::prepareConstraints(ConstraintInput& input)
|
|||||||
angularLowerLimits,
|
angularLowerLimits,
|
||||||
angularUpperLimits
|
angularUpperLimits
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("Error: Cannot find Rigidbodies(%s,%s) for constraint %s\n",orgUri0,orgUri1,constraintName);
|
printf("Error: Cannot find Rigidbodies(%s,%s) for constraint %s\n",orgUri0,orgUri1,constraintName);
|
||||||
|
|||||||
@@ -57,8 +57,17 @@ class MyColladaConverter : public ColladaConverter
|
|||||||
const btVector3& angularMaxLimits
|
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(
|
btGeneric6DofConstraint* genericConstraint = new btGeneric6DofConstraint(
|
||||||
*bodyRef,*bodyOther,
|
*bodyRef,*bodyOther,
|
||||||
localAttachmentFrameRef,localAttachmentOther);
|
localAttachmentFrameRef,localAttachmentOther);
|
||||||
|
|||||||
Reference in New Issue
Block a user