disable help text by default in AllBulletDemos (text slows down many graphics cards)
improve CollisionDemo.cpp, show multi-contact generation using perturbation improve ColladaConverter: add hinge/point 2 point constraint conversion support, add btScaledTriangleMeshShape support Fix Dynamica MayaPlygin: remove 'active' flag, it has to be replaced by mass=0 for active, mass<>0 for passive Added missing projectfiles Fixed single-shot contact generation. it is disabled by default to improve performance Bugfixes for character controller, thanks to John McCutchan for reporting Constraint solver: better default settings btDefaultAllocator: aligned allocator uses non-aligned allocator (instead of directly malloc/free) disable memalign by default, use Bullet's aligned allocator
This commit is contained in:
@@ -26,7 +26,7 @@ subject to the following restrictions:
|
||||
#include <string>
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCylinderShape.h"
|
||||
@@ -274,6 +274,40 @@ void ColladaConverter::reset ()
|
||||
m_dom = NULL;
|
||||
}
|
||||
|
||||
void ColladaConverter::setCameraInfo(const btVector3& upAxis,int forwardAxis)
|
||||
{
|
||||
if (!instantiateDom ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
domAsset::domUp_axis * up = m_dom->getAsset()->getUp_axis();
|
||||
int upAxisIndex = upAxis.maxAxis();
|
||||
|
||||
switch (upAxisIndex)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
up->setValue(UPAXISTYPE_X_UP);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
up->setValue(UPAXISTYPE_Y_UP);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
up->setValue(UPAXISTYPE_Z_UP);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool ColladaConverter::convert()
|
||||
{
|
||||
@@ -1515,6 +1549,16 @@ void ColladaConverter::addConvexMesh (btCollisionShape* shape, const char* nodeN
|
||||
printf("ERROR: Unsupported.\n");
|
||||
}
|
||||
|
||||
void ColladaConverter::addScaledConcaveMesh(btCollisionShape* shape, const char* nodeName)
|
||||
{
|
||||
btScaledBvhTriangleMeshShape* scaledShape = (btScaledBvhTriangleMeshShape*)shape;
|
||||
btBvhTriangleMeshShape* meshShape = scaledShape->getChildShape();
|
||||
btStridingMeshInterface* meshInterface = meshShape->getMeshInterface ();
|
||||
addConcaveMeshInternal(meshInterface,nodeName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ColladaConverter::addConcaveMesh(btCollisionShape* shape, const char* nodeName)
|
||||
{
|
||||
btTriangleMeshShape* meshShape = (btTriangleMeshShape*)shape;
|
||||
@@ -1560,8 +1604,11 @@ void ColladaConverter::addConcaveMeshInternal(btStridingMeshInterface* meshInter
|
||||
geo->setId( nodeName );
|
||||
geo->setName ( nodeName);
|
||||
|
||||
printf("numSubParts = \n",meshInterface->getNumSubParts ());
|
||||
|
||||
for (int i = 0; i < meshInterface->getNumSubParts (); i++)
|
||||
{
|
||||
|
||||
|
||||
domMesh *mesh = daeSafeCast<domMesh>( geo->createAndPlace( COLLADA_ELEMENT_MESH ) );
|
||||
if ( mesh == NULL )
|
||||
@@ -1581,6 +1628,12 @@ void ColladaConverter::addConcaveMeshInternal(btStridingMeshInterface* meshInter
|
||||
|
||||
meshInterface->getLockedReadOnlyVertexIndexBase (&vertexBase, numVerts, vertexType, vertexStride, &indexBase, indexStride, numFaces, indexType, i);
|
||||
|
||||
printf("meshInterface subpart[%d].numVerts = %d\n",i,numVerts);
|
||||
printf("meshInterface subpart[%d].numFaces = %d\n",i,numFaces);
|
||||
printf("meshInterface subpart[%d].indexType= %d\n",i,indexType);
|
||||
|
||||
|
||||
|
||||
btAssert (vertexBase);
|
||||
btAssert (indexBase);
|
||||
btAssert (vertexType == PHY_FLOAT);
|
||||
@@ -1820,6 +1873,15 @@ void ColladaConverter::buildShapeNew (btCollisionShape* shape, void* domTechniqu
|
||||
|
||||
}
|
||||
break;
|
||||
case SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
||||
{
|
||||
addScaledConcaveMesh (shape, shapeName);
|
||||
char shapeURL[512];
|
||||
snprintf(&shapeURL[0], 512, "#%s", shapeName);
|
||||
domInstance_geometry* gi = (domInstance_geometry*)colladaShape->createAndPlace (COLLADA_ELEMENT_INSTANCE_GEOMETRY);
|
||||
gi->setUrl (shapeURL);
|
||||
break;
|
||||
}
|
||||
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
||||
{
|
||||
addConcaveMesh (shape, shapeName);
|
||||
@@ -1934,9 +1996,58 @@ domNode* ColladaConverter::addNode (btRigidBody* rb, const char* nodeName, const
|
||||
}
|
||||
|
||||
|
||||
domRigid_constraint* ColladaConverter::addConstraint (btTypedConstraint* constraint, const char* constraintName)
|
||||
domRigid_constraint* ColladaConverter::addConstraint (btTypedConstraint* originalConstraint, const char* constraintName)
|
||||
{
|
||||
if (constraint->getConstraintType() != D6_CONSTRAINT_TYPE)
|
||||
btGeneric6DofConstraint* constraint = 0;
|
||||
btGeneric6DofConstraint* tmpConstraint = 0;
|
||||
|
||||
switch (originalConstraint->getConstraintType())
|
||||
{
|
||||
|
||||
case D6_CONSTRAINT_TYPE:
|
||||
{
|
||||
constraint = (btGeneric6DofConstraint*)originalConstraint;
|
||||
break;
|
||||
}
|
||||
|
||||
case POINT2POINT_CONSTRAINT_TYPE:
|
||||
{
|
||||
btPoint2PointConstraint* p2p = (btPoint2PointConstraint*) originalConstraint;
|
||||
bool useLinearReferenceFrameA = true;
|
||||
btTransform frameA,frameB;
|
||||
frameA.setIdentity();
|
||||
frameB.setIdentity();
|
||||
frameA.setOrigin(p2p->getPivotInA());
|
||||
frameB.setOrigin(p2p->getPivotInB());
|
||||
tmpConstraint = new btGeneric6DofConstraint(p2p->getRigidBodyA(),p2p->getRigidBodyB(),frameA,frameB,useLinearReferenceFrameA);
|
||||
tmpConstraint->setLinearLowerLimit(btVector3(0,0,0));
|
||||
tmpConstraint->setLinearUpperLimit(btVector3(0,0,0));
|
||||
constraint = tmpConstraint;
|
||||
break;
|
||||
}
|
||||
case HINGE_CONSTRAINT_TYPE:
|
||||
{
|
||||
btHingeConstraint* hinge = (btHingeConstraint*)originalConstraint;
|
||||
bool useLinearReferenceFrameA = true;
|
||||
btTransform frameB = hinge->getBFrame();//todo: remove this flipping
|
||||
frameB.getBasis()[0][2] *= btScalar(-1.);
|
||||
frameB.getBasis()[1][2] *= btScalar(-1.);
|
||||
frameB.getBasis()[2][2] *= btScalar(-1.);
|
||||
|
||||
tmpConstraint = new btGeneric6DofConstraint(hinge->getRigidBodyA(),hinge->getRigidBodyB(),hinge->getAFrame(),frameB,useLinearReferenceFrameA);
|
||||
tmpConstraint->setLinearLowerLimit(btVector3(0,0,0));
|
||||
tmpConstraint->setLinearUpperLimit(btVector3(0,0,0));
|
||||
tmpConstraint->setAngularLowerLimit(btVector3(0,0,1));
|
||||
tmpConstraint->setAngularUpperLimit(btVector3(0,0,-1));//max<min means free (not limited)
|
||||
constraint = tmpConstraint;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
};
|
||||
//convert non-6DOF constraints into a 6DOF
|
||||
if (!constraint || (constraint->getConstraintType() != D6_CONSTRAINT_TYPE))
|
||||
return NULL;
|
||||
|
||||
btGeneric6DofConstraint* g6c = (btGeneric6DofConstraint*)constraint;
|
||||
@@ -2085,6 +2196,8 @@ domRigid_constraint* ColladaConverter::addConstraint (btTypedConstraint* constra
|
||||
max->getValue().set (1, limit->m_upperLimit[1]);
|
||||
max->getValue().set (2, limit->m_upperLimit[2]);
|
||||
}
|
||||
if (tmpConstraint)
|
||||
delete tmpConstraint;
|
||||
return domRigidConstraint;
|
||||
}
|
||||
|
||||
@@ -2388,15 +2501,15 @@ void ColladaConverter::syncOrAddGeometry (btCollisionShape* shape, const char* n
|
||||
|
||||
void ColladaConverter::syncOrAddRigidBody (btRigidBody* body)
|
||||
{
|
||||
domNodeRef node = findNode (body);
|
||||
domNodeRef nodeRef = findNode (body);
|
||||
domLibrary_geometriesRef geomLib = getDefaultGeomLib ();
|
||||
|
||||
static int random_node_name_key = 0;
|
||||
if (node != NULL)
|
||||
if (nodeRef != NULL)
|
||||
{
|
||||
updateRigidBodyPosition (body, node);
|
||||
updateRigidBodyPosition (body, nodeRef);
|
||||
updateRigidBodyVelocity (body);
|
||||
printf("Updating %s in the COLLADA DOM.\n", node->getId() ? node->getId() : "");
|
||||
printf("Updating %s in the COLLADA DOM.\n", nodeRef->getId() ? nodeRef->getId() : "");
|
||||
} else {
|
||||
/* This is a new body. */
|
||||
const char* shapeName = NULL;
|
||||
@@ -2428,19 +2541,9 @@ void ColladaConverter::syncOrAddRigidBody (btRigidBody* body)
|
||||
shapeName = &shapeNameGen[0];
|
||||
}
|
||||
|
||||
if (shape->getShapeType () == TRIANGLE_MESH_SHAPE_PROXYTYPE) {
|
||||
addConcaveMesh (shape, shapeName);
|
||||
} else if (shape->getShapeType () == GIMPACT_SHAPE_PROXYTYPE)
|
||||
{
|
||||
addGimpactMesh (shape, shapeName);
|
||||
} else if (!shape->isConvex () && !shape->isCompound() && (shape->getShapeType()!=STATIC_PLANE_PROXYTYPE)) {
|
||||
printf("Unknown shape type. %d Skipping rigidbody.\n", shape->getShapeType());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
printf("Adding %s to COLLADA DOM.\n", nodeName);
|
||||
|
||||
|
||||
switch (shape->getShapeType())
|
||||
{
|
||||
case STATIC_PLANE_PROXYTYPE:
|
||||
@@ -2455,12 +2558,49 @@ void ColladaConverter::syncOrAddRigidBody (btRigidBody* body)
|
||||
dNode = addNode (body, nodeName, concaveShapeName);
|
||||
break;
|
||||
}
|
||||
case SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
||||
{
|
||||
addScaledConcaveMesh (shape, shapeName);
|
||||
btScaledBvhTriangleMeshShape* scaledShape = (btScaledBvhTriangleMeshShape*)shape;
|
||||
dNode = addNode (body, nodeName, shapeName);
|
||||
//add scaling
|
||||
domScale* scale= (domScale*)dNode->createAndPlace (COLLADA_ELEMENT_SCALE);
|
||||
{
|
||||
btVector3 localScaling = scaledShape->getLocalScaling();
|
||||
scale->getValue().append(localScaling[0]);
|
||||
scale->getValue().append(localScaling[1]);
|
||||
scale->getValue().append(localScaling[2]);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
||||
{
|
||||
addConcaveMesh (shape, shapeName);
|
||||
dNode = addNode (body, nodeName, shapeName);
|
||||
break;
|
||||
}
|
||||
case GIMPACT_SHAPE_PROXYTYPE:
|
||||
{
|
||||
addGimpactMesh (shape, shapeName);
|
||||
dNode = addNode (body, nodeName, shapeName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (!shape->isConvex () && !shape->isCompound() && (shape->getShapeType()!=STATIC_PLANE_PROXYTYPE))
|
||||
{
|
||||
printf("Unknown shape type. %d Skipping rigidbody.\n", shape->getShapeType());
|
||||
return;
|
||||
}
|
||||
dNode = addNode (body, nodeName, shapeName);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
addMaterial (body, nodeName);
|
||||
|
||||
dRigidBody = addRigidBody (body, nodeName, shapeName);
|
||||
|
||||
@@ -141,6 +141,7 @@ protected:
|
||||
void addConvexHull (btCollisionShape* shape, const char* nodeName);
|
||||
void addConvexMesh (btCollisionShape* shape, const char* nodeName);
|
||||
void addConcaveMesh(btCollisionShape* shape, const char* nodeName);
|
||||
void addScaledConcaveMesh(btCollisionShape* shape, const char* nodeName);
|
||||
void addGimpactMesh(btCollisionShape* shape, const char* nodeName);
|
||||
|
||||
void addConcaveMeshInternal(class btStridingMeshInterface* meshInterface , const char* nodeName);
|
||||
@@ -220,9 +221,7 @@ public:
|
||||
virtual btTypedConstraint* getConstraint (int i);
|
||||
virtual void setGravity(const btVector3& gravity);
|
||||
virtual btVector3 getGravity ();
|
||||
virtual void setCameraInfo(const btVector3& up, int forwardAxis)
|
||||
{
|
||||
};
|
||||
virtual void setCameraInfo(const btVector3& up, int forwardAxis);
|
||||
|
||||
virtual btCollisionShape* createPlaneShape(const btVector3& planeNormal,btScalar planeConstant);
|
||||
virtual btCollisionShape* createBoxShape(const btVector3& halfExtents);
|
||||
|
||||
@@ -694,6 +694,26 @@
|
||||
Name="Source Files"
|
||||
>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\scripts\AEdCollisionShapeTemplate.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\scripts\AEdNailConstraintTemplate.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\scripts\AEdRigidBodyArrayTemplate.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\scripts\AEdRigidBodyTemplate.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\scripts\AEdSolverTemplate.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\box_shape.h"
|
||||
>
|
||||
@@ -834,6 +854,14 @@
|
||||
RelativePath=".\dSolverNode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\scripts\dynamica.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\scripts\dynamicaUI.mel"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\mathUtils.h"
|
||||
>
|
||||
|
||||
@@ -195,10 +195,10 @@ void initRigidBody(MObject &node)
|
||||
|
||||
MFnTransform fnTransform(fnDagNode.parent(0));
|
||||
|
||||
MPlug plgActive(node, rigidBodyNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
if(active) {
|
||||
MPlug plgMass(node, rigidBodyNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
if(mass>0.f) {
|
||||
//active rigid body, set the world transform from the initial* attributes
|
||||
MObject obj;
|
||||
|
||||
@@ -259,9 +259,11 @@ void initRigidBodyArray(MObject &node)
|
||||
|
||||
MFnTransform fnTransform(fnDagNode.parent(0));
|
||||
|
||||
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyArrayNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
|
||||
if(active) {
|
||||
//active rigid body, set the world transform from the initial* attributes
|
||||
MObject obj;
|
||||
@@ -382,9 +384,10 @@ void dSolverNode::gatherPassiveTransforms(MPlugArray &rbConnections, std::vector
|
||||
|
||||
MFnTransform fnTransform(fnDagNode.parent(0));
|
||||
|
||||
MPlug plgActive(node, rigidBodyNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(!active) {
|
||||
MQuaternion mquat;
|
||||
fnTransform.getRotation(mquat);
|
||||
@@ -404,9 +407,10 @@ void dSolverNode::gatherPassiveTransforms(MPlugArray &rbConnections, std::vector
|
||||
return;
|
||||
}
|
||||
|
||||
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyArrayNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(!active) {
|
||||
MPlug plgPosition(node, rigidBodyArrayNode::io_position);
|
||||
MPlug plgRotation(node, rigidBodyArrayNode::io_rotation);
|
||||
@@ -453,9 +457,10 @@ void dSolverNode::updatePassiveRigidBodies(MPlugArray &rbConnections, std::vecto
|
||||
continue;
|
||||
}
|
||||
|
||||
MPlug plgActive(node, rigidBodyNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(!active) {
|
||||
//do linear interpolation for now
|
||||
rb->set_transform(xforms[pb].m_x0 + t * (xforms[pb].m_x1 - xforms[pb].m_x0),
|
||||
@@ -471,9 +476,10 @@ void dSolverNode::updatePassiveRigidBodies(MPlugArray &rbConnections, std::vecto
|
||||
return;
|
||||
}
|
||||
|
||||
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyArrayNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(!active) {
|
||||
for(size_t j = 0; j < rbs.size(); ++j) {
|
||||
rbs[j]->set_transform(xforms[pb].m_x0 + t * (xforms[pb].m_x1 - xforms[pb].m_x0),
|
||||
@@ -503,9 +509,10 @@ void dSolverNode::updateActiveRigidBodies(MPlugArray &rbConnections)
|
||||
|
||||
MFnTransform fnTransform(fnDagNode.parent(0));
|
||||
|
||||
MPlug plgActive(node, rigidBodyNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(active) {
|
||||
quatf rot;
|
||||
vec3f pos;
|
||||
@@ -517,10 +524,10 @@ void dSolverNode::updateActiveRigidBodies(MPlugArray &rbConnections)
|
||||
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
|
||||
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
|
||||
|
||||
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
|
||||
MPlug plgMass(node, rigidBodyArrayNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
//write the position and rotations
|
||||
if(active) {
|
||||
MPlug plgPosition(node, rigidBodyArrayNode::io_position);
|
||||
@@ -574,9 +581,10 @@ void dSolverNode::applyFields(MPlugArray &rbConnections, float dt)
|
||||
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
|
||||
rigid_body_t::pointer rb = rbNode->rigid_body();
|
||||
|
||||
MPlug plgActive(node, rigidBodyNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(active) {
|
||||
rigid_bodies.push_back(rb.get());
|
||||
}
|
||||
@@ -584,9 +592,10 @@ void dSolverNode::applyFields(MPlugArray &rbConnections, float dt)
|
||||
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
|
||||
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
|
||||
|
||||
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
|
||||
bool active = false;
|
||||
plgActive.getValue(active);
|
||||
MPlug plgMass(node, rigidBodyArrayNode::ia_mass);
|
||||
float mass = 0.f;
|
||||
plgMass.getValue(mass);
|
||||
bool active = (mass>0.f);
|
||||
if(active) {
|
||||
for(size_t j = 0; j < rbs.size(); ++j) {
|
||||
rigid_bodies.push_back(rbs[j].get());
|
||||
|
||||
@@ -49,7 +49,7 @@ MString rigidBodyArrayNode::typeName("dRigidBodyArray");
|
||||
MObject rigidBodyArrayNode::ia_collisionShape;
|
||||
MObject rigidBodyArrayNode::ia_solver;
|
||||
MObject rigidBodyArrayNode::ia_numBodies;
|
||||
MObject rigidBodyArrayNode::ia_active;
|
||||
|
||||
MObject rigidBodyArrayNode::ia_mass;
|
||||
MObject rigidBodyArrayNode::ia_restitution;
|
||||
MObject rigidBodyArrayNode::ia_friction;
|
||||
@@ -92,12 +92,7 @@ MStatus rigidBodyArrayNode::initialize()
|
||||
status = addAttribute(ia_numBodies);
|
||||
MCHECKSTATUS(status, "adding numBodies attribute")
|
||||
|
||||
ia_active = fnNumericAttr.create("active", "ac", MFnNumericData::kBoolean, 1, &status);
|
||||
MCHECKSTATUS(status, "creating active attribute")
|
||||
fnNumericAttr.setKeyable(true);
|
||||
status = addAttribute(ia_active);
|
||||
MCHECKSTATUS(status, "adding active attribute")
|
||||
|
||||
|
||||
ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, 1.0, &status);
|
||||
MCHECKSTATUS(status, "creating mass attribute")
|
||||
fnNumericAttr.setKeyable(true);
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
static MObject ia_collisionShape;
|
||||
static MObject ia_solver;
|
||||
static MObject ia_numBodies;
|
||||
static MObject ia_active;
|
||||
//ia_active is obsolete and redundant -> use ia_mass == 0 for (ia_active==false), and ia_mass > 0 for (ia_active == true)
|
||||
static MObject ia_mass;
|
||||
static MObject ia_restitution;
|
||||
static MObject ia_friction;
|
||||
|
||||
@@ -45,7 +45,6 @@ MString rigidBodyNode::typeName("dRigidBody");
|
||||
|
||||
MObject rigidBodyNode::ia_collisionShape;
|
||||
MObject rigidBodyNode::ia_solver;
|
||||
MObject rigidBodyNode::ia_active;
|
||||
MObject rigidBodyNode::ia_mass;
|
||||
MObject rigidBodyNode::ia_restitution;
|
||||
MObject rigidBodyNode::ia_friction;
|
||||
@@ -77,12 +76,6 @@ MStatus rigidBodyNode::initialize()
|
||||
status = addAttribute(ia_solver);
|
||||
MCHECKSTATUS(status, "adding solver attribute")
|
||||
|
||||
ia_active = fnNumericAttr.create("active", "ac", MFnNumericData::kBoolean, 1, &status);
|
||||
MCHECKSTATUS(status, "creating active attribute")
|
||||
fnNumericAttr.setKeyable(true);
|
||||
status = addAttribute(ia_active);
|
||||
MCHECKSTATUS(status, "adding active attribute")
|
||||
|
||||
ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, 1.0, &status);
|
||||
MCHECKSTATUS(status, "creating mass attribute")
|
||||
fnNumericAttr.setKeyable(true);
|
||||
@@ -184,8 +177,6 @@ MStatus rigidBodyNode::initialize()
|
||||
status = attributeAffects(ia_solver, ca_solver);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_solver, ca_solver)")
|
||||
|
||||
// status = attributeAffects(ia_active, ca_rigidBodyParam);
|
||||
// MCHECKSTATUS(status, "adding attributeAffects(ia_active, ca_rigidBodyParam)")
|
||||
|
||||
return MS::kSuccess;
|
||||
}
|
||||
@@ -521,7 +512,6 @@ void rigidBodyNode::computeRigidBodyParam(const MPlug& plug, MDataBlock& data)
|
||||
m_rigid_body->set_friction(data.inputValue(ia_friction).asDouble());
|
||||
m_rigid_body->set_linear_damping(data.inputValue(ia_linearDamping).asDouble());
|
||||
m_rigid_body->set_angular_damping(data.inputValue(ia_angularDamping).asDouble());
|
||||
// m_rigid_body->set_kinematic(!data.inputValue(ia_active).asBool());
|
||||
|
||||
data.outputValue(ca_rigidBodyParam).set(true);
|
||||
data.setClean(plug);
|
||||
|
||||
@@ -68,7 +68,6 @@ public:
|
||||
//Attributes
|
||||
static MObject ia_collisionShape;
|
||||
static MObject ia_solver;
|
||||
static MObject ia_active;
|
||||
static MObject ia_mass;
|
||||
static MObject ia_restitution;
|
||||
static MObject ia_friction;
|
||||
|
||||
@@ -395,8 +395,15 @@ global proc dynamicaUI_STsubstepsChanged()
|
||||
|
||||
}
|
||||
|
||||
proc dynamicaUI_createRigidBody(int $active, int $collisionShapeType)
|
||||
proc dynamicaUI_createRigidBody(int $activebody, int $collisionShapeType)
|
||||
{
|
||||
float $mass = 1;
|
||||
|
||||
if($activebody == false)
|
||||
{
|
||||
$mass = 0;
|
||||
}
|
||||
|
||||
string $selection[] = `ls -selection -dag -leaf -showType -type "geometry"`;
|
||||
|
||||
//create dSolver node if necessary
|
||||
@@ -419,7 +426,7 @@ proc dynamicaUI_createRigidBody(int $active, int $collisionShapeType)
|
||||
connectAttr ($selection[$i * 2] + ".message") ($collisionShapeNode + ".inShape");
|
||||
hide $shapeTransforms[0];
|
||||
}
|
||||
setAttr ($rigidBodyNode + ".active" ) $active;
|
||||
setAttr ($rigidBodyNode + ".mass" ) $mass;
|
||||
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
|
||||
|
||||
float $pos[]= `getAttr ($shapeTransforms[0] + ".translate")`;
|
||||
@@ -439,7 +446,7 @@ proc dynamicaUI_createRigidBody(int $active, int $collisionShapeType)
|
||||
connectAttr ($collisionShapeNode + ".outCollisionShape") ($rigidBodyNode + ".inCollisionShape");
|
||||
string $rigidBodyTransforms[] = `listRelatives -parent $rigidBodyNode`;
|
||||
|
||||
setAttr ($rigidBodyNode + ".active" ) $active;
|
||||
setAttr ($rigidBodyNode + ".mass" ) $mass;
|
||||
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
|
||||
$newBodies[0] = $rigidBodyTransforms[0];
|
||||
}
|
||||
@@ -562,8 +569,15 @@ global proc dynamicaUI_createPassiveMeshRB()
|
||||
dynamicaUI_createRigidBody(false, 1);
|
||||
}
|
||||
|
||||
proc dynamicaUI_createRigidBodyArray(int $active, int $collisionShapeType)
|
||||
proc dynamicaUI_createRigidBodyArray(int $activebody, int $collisionShapeType)
|
||||
{
|
||||
float $mass = 1;
|
||||
|
||||
if ($activebody == false)
|
||||
{
|
||||
$mass = 0;
|
||||
}
|
||||
|
||||
global int $dynamicaUI_createArrayUI_size[];
|
||||
global float $dynamicaUI_createArrayUI_offset[];
|
||||
|
||||
@@ -586,7 +600,7 @@ proc dynamicaUI_createRigidBodyArray(int $active, int $collisionShapeType)
|
||||
}
|
||||
}
|
||||
|
||||
setAttr ($rigidBodyArrayNode + ".active" ) $active;
|
||||
setAttr ($rigidBodyArrayNode + ".mass" ) $mass;
|
||||
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
|
||||
|
||||
select -r $rigidBodyTransforms[0];
|
||||
|
||||
Reference in New Issue
Block a user