fixed some compile issue for Mac Dynamica plugin, see
http://code.google.com/p/bullet/issues/detail?id=221 added some missing file for autotools/Makefile.am fix: btBulletWorldImporter::loadFileFromMemory always returned false, if it was succesful
This commit is contained in:
@@ -18,9 +18,9 @@ not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Herbert Law <Herbert.Law@gmail.com>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
01/22/2010 : Constraints reworked
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
01/22/2010 : Constraints reworked
|
||||
*/
|
||||
|
||||
//hingeConstraintNode.cpp
|
||||
@@ -42,8 +42,8 @@ Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
#include "mayaUtils.h"
|
||||
|
||||
#include "solver.h"
|
||||
#include "dSolverNode.h"
|
||||
#include "constraint/bt_hinge_constraint.h"
|
||||
#include "dSolverNode.h"
|
||||
#include "constraint/bt_hinge_constraint.h"
|
||||
|
||||
MTypeId hingeConstraintNode::typeId(0x10033B);
|
||||
MString hingeConstraintNode::typeName("dHingeConstraint");
|
||||
@@ -341,7 +341,8 @@ void hingeConstraintNode::draw( M3dView & view, const MDagPath &path,
|
||||
rigid_bodyB->get_transform(pos, rot);
|
||||
m_constraint->worldToA(pos, posB);
|
||||
}
|
||||
m_constraint->worldFromB(vec3f(0.f, 0.f, 0.f), pos);
|
||||
vec3f zeroVec(0.f,0.f,0.f);
|
||||
m_constraint->worldFromB(zeroVec, pos);
|
||||
m_constraint->worldToA(pos, pivB);
|
||||
}
|
||||
|
||||
@@ -369,22 +370,30 @@ void hingeConstraintNode::draw( M3dView & view, const MDagPath &path,
|
||||
glVertex3f(0.0, 0.0, 1.0);
|
||||
|
||||
vec3f posT, posP, posM;
|
||||
|
||||
vec3f minusXVec(-1.f,0.f,0.f);
|
||||
vec3f posXVec(1.f,0.f,0.f);
|
||||
vec3f minusYVec (0.f,-1.f,0.f);
|
||||
vec3f posYVec (0.f,1.f,0.f);
|
||||
vec3f minusZVec (0.f,0.f,-1.f);
|
||||
vec3f posZVec (0.f,0.f,1.f);
|
||||
|
||||
|
||||
m_constraint->worldFromB(vec3f(-1.f, 0.f, 0.f), posT);
|
||||
m_constraint->worldFromB(minusXVec, posT);
|
||||
m_constraint->worldToA(posT, posM);
|
||||
m_constraint->worldFromB(vec3f( 1.f, 0.f, 0.f), posT);
|
||||
m_constraint->worldFromB(posXVec, posT);
|
||||
m_constraint->worldToA(posT, posP);
|
||||
glVertex3f(posM[0], posM[1], posM[2]);
|
||||
glVertex3f(posP[0], posP[1], posP[2]);
|
||||
m_constraint->worldFromB(vec3f( 0.f, -1.f, 0.f), posT);
|
||||
m_constraint->worldFromB(minusYVec, posT);
|
||||
m_constraint->worldToA(posT, posM);
|
||||
m_constraint->worldFromB(vec3f( 0.f, 1.f, 0.f), posT);
|
||||
m_constraint->worldFromB(posYVec, posT);
|
||||
m_constraint->worldToA(posT, posP);
|
||||
glVertex3f(posM[0], posM[1], posM[2]);
|
||||
glVertex3f(posP[0], posP[1], posP[2]);
|
||||
m_constraint->worldFromB(vec3f( 0.f, 0.f, -1.f), posT);
|
||||
m_constraint->worldFromB(minusZVec, posT);
|
||||
m_constraint->worldToA(posT, posM);
|
||||
m_constraint->worldFromB(vec3f( 0.f, 0.f, 1.f), posT);
|
||||
m_constraint->worldFromB(posZVec, posT);
|
||||
m_constraint->worldToA(posT, posP);
|
||||
glVertex3f(posM[0], posM[1], posM[2]);
|
||||
glVertex3f(posP[0], posP[1], posP[2]);
|
||||
@@ -469,13 +478,13 @@ void hingeConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data)
|
||||
pivInB[i] = (float)mPivInB[i];
|
||||
}
|
||||
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
|
||||
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
|
||||
MQuaternion mquatA = meulerA.asQuaternion();
|
||||
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
|
||||
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
|
||||
MQuaternion mquatA = meulerA.asQuaternion();
|
||||
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
|
||||
float3& mRotInB = data.inputValue(ia_rotationInB).asFloat3();
|
||||
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
|
||||
MQuaternion mquatB = meulerB.asQuaternion();
|
||||
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
|
||||
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
|
||||
MQuaternion mquatB = meulerB.asQuaternion();
|
||||
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
|
||||
m_constraint = solver_t::create_hinge_constraint(rigid_bodyA, pivInA, rotA, rigid_bodyB, pivInB, rotB);
|
||||
constraint = static_cast<constraint_t::pointer>(m_constraint);
|
||||
solver_t::add_constraint(constraint);
|
||||
@@ -491,9 +500,9 @@ void hingeConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data)
|
||||
pivInA[i] = (float)mPivInA[i];
|
||||
}
|
||||
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
|
||||
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
|
||||
MQuaternion mquat = meuler.asQuaternion();
|
||||
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
|
||||
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
|
||||
MQuaternion mquat = meuler.asQuaternion();
|
||||
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
|
||||
m_constraint = solver_t::create_hinge_constraint(rigid_bodyA, pivInA, rotA);
|
||||
constraint = static_cast<constraint_t::pointer>(m_constraint);
|
||||
solver_t::add_constraint(constraint);
|
||||
@@ -518,8 +527,8 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
|
||||
fnParentTransform.setScale(fixScale);
|
||||
MVector mtranslation = fnParentTransform.getTranslation(MSpace::kTransform, &status);
|
||||
|
||||
if(dSolverNode::isStartTime)
|
||||
{ // allow to edit pivots
|
||||
if(dSolverNode::isStartTime)
|
||||
{ // allow to edit pivots
|
||||
MPlug plgRigidBodyA(thisObject, ia_rigidBodyA);
|
||||
MPlug plgRigidBodyB(thisObject, ia_rigidBodyB);
|
||||
MObject update;
|
||||
@@ -558,8 +567,8 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
|
||||
}
|
||||
if(m_constraint)
|
||||
{
|
||||
MQuaternion mrotation;
|
||||
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
|
||||
MQuaternion mrotation;
|
||||
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
|
||||
bool doUpdatePivot = m_constraint->getPivotChanged();
|
||||
if(!doUpdatePivot)
|
||||
{
|
||||
@@ -569,46 +578,46 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
|
||||
float deltaPX = worldP[0] - float(mtranslation.x);
|
||||
float deltaPY = worldP[1] - float(mtranslation.y);
|
||||
float deltaPZ = worldP[2] - float(mtranslation.z);
|
||||
float deltaRX = (float)mrotation.x - worldR[1];
|
||||
float deltaRY = (float)mrotation.y - worldR[2];
|
||||
float deltaRZ = (float)mrotation.z - worldR[3];
|
||||
float deltaRW = (float)mrotation.w - worldR[0];
|
||||
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
|
||||
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
|
||||
float deltaRX = (float)mrotation.x - worldR[1];
|
||||
float deltaRY = (float)mrotation.y - worldR[2];
|
||||
float deltaRZ = (float)mrotation.z - worldR[3];
|
||||
float deltaRW = (float)mrotation.w - worldR[0];
|
||||
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
|
||||
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
|
||||
doUpdatePivot = (deltaSq > FLT_EPSILON);
|
||||
}
|
||||
if(doUpdatePivot)
|
||||
{
|
||||
m_constraint->set_world(vec3f((float) mtranslation[0], (float) mtranslation[1], (float) mtranslation[2]),
|
||||
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
|
||||
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
|
||||
vec3f pivInA, pivInB;
|
||||
quatf rotInA, rotInB;
|
||||
m_constraint->get_frameA(pivInA, rotInA);
|
||||
m_constraint->get_frameB(pivInB, rotInB);
|
||||
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
|
||||
float3 &ihPivInA = hPivInA.asFloat3();
|
||||
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
|
||||
float3 &ihPivInB = hPivInB.asFloat3();
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
ihPivInA[i] = pivInA[i];
|
||||
ihPivInB[i] = pivInB[i];
|
||||
}
|
||||
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
|
||||
float3 &hrotInA = hRotInA.asFloat3();
|
||||
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
|
||||
MEulerRotation newrotA(mrotA.asEulerRotation());
|
||||
hrotInA[0] = rad2deg((float)newrotA.x);
|
||||
hrotInA[1] = rad2deg((float)newrotA.y);
|
||||
hrotInA[2] = rad2deg((float)newrotA.z);
|
||||
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
|
||||
float3 &hrotInB = hRotInB.asFloat3();
|
||||
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
|
||||
MEulerRotation newrotB(mrotB.asEulerRotation());
|
||||
hrotInB[0] = rad2deg((float)newrotB.x);
|
||||
hrotInB[1] = rad2deg((float)newrotB.y);
|
||||
hrotInB[2] = rad2deg((float)newrotB.z);
|
||||
m_constraint->setPivotChanged(false);
|
||||
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
|
||||
float3 &ihPivInA = hPivInA.asFloat3();
|
||||
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
|
||||
float3 &ihPivInB = hPivInB.asFloat3();
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
ihPivInA[i] = pivInA[i];
|
||||
ihPivInB[i] = pivInB[i];
|
||||
}
|
||||
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
|
||||
float3 &hrotInA = hRotInA.asFloat3();
|
||||
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
|
||||
MEulerRotation newrotA(mrotA.asEulerRotation());
|
||||
hrotInA[0] = rad2deg((float)newrotA.x);
|
||||
hrotInA[1] = rad2deg((float)newrotA.y);
|
||||
hrotInA[2] = rad2deg((float)newrotA.z);
|
||||
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
|
||||
float3 &hrotInB = hRotInB.asFloat3();
|
||||
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
|
||||
MEulerRotation newrotB(mrotB.asEulerRotation());
|
||||
hrotInB[0] = rad2deg((float)newrotB.x);
|
||||
hrotInB[1] = rad2deg((float)newrotB.y);
|
||||
hrotInB[2] = rad2deg((float)newrotB.z);
|
||||
m_constraint->setPivotChanged(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -619,8 +628,8 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
|
||||
vec3f worldP;
|
||||
quatf worldR;
|
||||
m_constraint->get_world(worldP, worldR);
|
||||
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
|
||||
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
|
||||
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
|
||||
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
|
||||
}
|
||||
}
|
||||
data.setClean(plug);
|
||||
|
||||
Reference in New Issue
Block a user