From 4140a2055287583932097b374d55894052b67854 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Sun, 31 Jan 2010 16:46:06 +0000 Subject: [PATCH] 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 --- .../ConvexDecompositionDemo.cpp | 2 +- Extras/MayaPlugin/Makefile.mac | 14 +- .../constraint/hingeConstraintNode.cpp | 125 ++++++++++-------- .../constraint/sixdofConstraintNode.cpp | 125 +++++++++--------- .../constraint/sliderConstraintNode.cpp | 123 +++++++++-------- .../btBulletWorldImporter.cpp | 2 +- config.h.in | 29 +--- src/Makefile.am | 5 +- 8 files changed, 217 insertions(+), 208 deletions(-) diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index b550b17e1..e6b66ea99 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -23,7 +23,7 @@ subject to the following restrictions: #include "LinearMath/btGeometryUtil.h" #include "BulletCollision/CollisionShapes/btShapeHull.h" -#define TEST_SERIALIZATION +//#define TEST_SERIALIZATION //#define NO_OBJ_TO_BULLET #ifdef TEST_SERIALIZATION diff --git a/Extras/MayaPlugin/Makefile.mac b/Extras/MayaPlugin/Makefile.mac index e5d1f0a55..bcbd5b16c 100644 --- a/Extras/MayaPlugin/Makefile.mac +++ b/Extras/MayaPlugin/Makefile.mac @@ -1,6 +1,6 @@ #MayaPlugin Makefile -MAYA_LOCATION?=/Applications/Autodesk/maya2008/devkit +MAYA_LOCATION?=/Applications/Autodesk/maya2009/devkit ## MAYA_LOCATION is the Maya installation directory. It should be already defined in your # environment variables. If not, please change it to the appropriate directory @@ -30,16 +30,22 @@ CPPFLAGS = -DMAC_PLUGIN -DOSMac_MachO_ -DBits32_ -m32 -DUNIX -D_BOOL -DOSMac_ -D LDFLAGS = -ldl -shared BULLET_INCLUDE=-I$(BULLET)/src -I. + BULLET_LIB=-L$(BULLET)/out/macosxx86/optimize/libs -L$(BULLET)/src \ - -lBulletColladaConverter -lcolladadom -llibxml -lGIMPACTUtils -lbulletdynamics \ + -lGIMPACTUtils -lbulletdynamics \ -lbulletcollision -lbulletmath +#BULLET_LIB=-L$(BULLET)/src/.libs \ +# -lbulletdynamics \ +# -lbulletcollision -lbulletmath + + GL_LIB=-framework OpenGL MAYA_INCLUDE=-I$(MAYA)/include -MAYA_LIB=-L/Applications/Autodesk/maya2008/Maya.app/Contents/MacOS -lOpenMaya -lFoundation -Wl,-executable_path,/Applications/Autodesk/maya2008/Maya.app/Contents/MacOS -lOpenMayaUI -lOpenMayaFX -lOpenMaya -lFoundation +MAYA_LIB=-L/Applications/Autodesk/maya2009/Maya.app/Contents/MacOS -lOpenMaya -lFoundation -Wl,-executable_path,/Applications/Autodesk/maya2009/Maya.app/Contents/MacOS -lOpenMayaUI -lOpenMayaFX -lOpenMaya -lFoundation -SOURCES = pluginMain.cpp colladaExport.cpp rigidBodyNode.cpp rigidBodyArrayNode.cpp collisionShapeNode.cpp \ +SOURCES = pluginMain.cpp bulletExport.cpp rigidBodyNode.cpp rigidBodyArrayNode.cpp collisionShapeNode.cpp \ solver.cpp bt_solver.cpp dSolverNode.cpp dSolverCmd.cpp dRigidBodyCmd.cpp dRigidBodyArrayCmd.cpp \ pdbIO.cpp drawUtils.cpp constraint/dHingeConstraintCmd.cpp constraint/dSliderConstraintCmd.cpp \ constraint/hingeConstraintNode.cpp constraint/sixdofConstraintNode.cpp constraint/dNailConstraintCmd.cpp \ diff --git a/Extras/MayaPlugin/constraint/hingeConstraintNode.cpp b/Extras/MayaPlugin/constraint/hingeConstraintNode.cpp index 1fcce934c..43d4b5174 100644 --- a/Extras/MayaPlugin/constraint/hingeConstraintNode.cpp +++ b/Extras/MayaPlugin/constraint/hingeConstraintNode.cpp @@ -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 - -Modified by Roman Ponomarev -01/22/2010 : Constraints reworked + +Modified by Roman Ponomarev +01/22/2010 : Constraints reworked */ //hingeConstraintNode.cpp @@ -42,8 +42,8 @@ Modified by Roman Ponomarev #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(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(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); diff --git a/Extras/MayaPlugin/constraint/sixdofConstraintNode.cpp b/Extras/MayaPlugin/constraint/sixdofConstraintNode.cpp index 0f41e362a..ae8b386a3 100644 --- a/Extras/MayaPlugin/constraint/sixdofConstraintNode.cpp +++ b/Extras/MayaPlugin/constraint/sixdofConstraintNode.cpp @@ -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 - -Modified by Roman Ponomarev -01/22/2010 : Constraints reworked + +Modified by Roman Ponomarev +01/22/2010 : Constraints reworked */ //sixdofConstraintNode.cpp @@ -42,8 +42,8 @@ Modified by Roman Ponomarev #include "mayaUtils.h" #include "solver.h" -#include "dSolverNode.h" -#include "constraint/bt_sixdof_constraint.h" +#include "dSolverNode.h" +#include "constraint/bt_sixdof_constraint.h" MTypeId sixdofConstraintNode::typeId(0x100384); MString sixdofConstraintNode::typeName("dSixdofConstraint"); @@ -274,7 +274,14 @@ void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path, M3dView::DisplayStatus status ) { update(); - + vec3f zeroVec(0.f,0.f,0.f); + 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); + view.beginGL(); glPushAttrib( GL_ALL_ATTRIB_BITS ); @@ -301,7 +308,7 @@ void sixdofConstraintNode::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); + m_constraint->worldFromB(zeroVec, pos); m_constraint->worldToA(pos, pivB); } @@ -330,21 +337,21 @@ void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path, vec3f posT, posP, posM; - 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]); @@ -430,13 +437,13 @@ void sixdofConstraintNode::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_sixdof_constraint(rigid_bodyA, pivInA, rotA, rigid_bodyB, pivInB, rotB); constraint = static_cast(m_constraint); solver_t::add_constraint(constraint); @@ -452,9 +459,9 @@ void sixdofConstraintNode::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_sixdof_constraint(rigid_bodyA, pivInA, rotA); constraint = static_cast(m_constraint); solver_t::add_constraint(constraint); @@ -480,8 +487,8 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat 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; @@ -520,8 +527,8 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat } if(m_constraint) { - MQuaternion mrotation; - fnParentTransform.getRotation(mrotation, MSpace::kTransform); + MQuaternion mrotation; + fnParentTransform.getRotation(mrotation, MSpace::kTransform); bool doUpdatePivot = m_constraint->getPivotChanged(); if(!doUpdatePivot) { @@ -531,46 +538,46 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat 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); } } } @@ -581,8 +588,8 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat 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); diff --git a/Extras/MayaPlugin/constraint/sliderConstraintNode.cpp b/Extras/MayaPlugin/constraint/sliderConstraintNode.cpp index d949158ac..671d5c44d 100644 --- a/Extras/MayaPlugin/constraint/sliderConstraintNode.cpp +++ b/Extras/MayaPlugin/constraint/sliderConstraintNode.cpp @@ -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 - -Modified by Roman Ponomarev -01/22/2010 : Constraints reworked + +Modified by Roman Ponomarev +01/22/2010 : Constraints reworked */ //sliderConstraintNode.cpp @@ -42,8 +42,8 @@ Modified by Roman Ponomarev #include "mayaUtils.h" #include "solver.h" -#include "dSolverNode.h" -#include "constraint/bt_slider_constraint.h" +#include "dSolverNode.h" +#include "constraint/bt_slider_constraint.h" MTypeId sliderConstraintNode::typeId(0x100385); MString sliderConstraintNode::typeName("dSliderConstraint"); @@ -270,6 +270,13 @@ void sliderConstraintNode::draw( M3dView & view, const MDagPath &path, M3dView::DisplayStatus status ) { update(); + vec3f zeroVec(0.f,0.f,0.f); + 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); view.beginGL(); glPushAttrib( GL_ALL_ATTRIB_BITS ); @@ -297,7 +304,7 @@ void sliderConstraintNode::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); + m_constraint->worldFromB(zeroVec, pos); m_constraint->worldToA(pos, pivB); } @@ -326,21 +333,21 @@ void sliderConstraintNode::draw( M3dView & view, const MDagPath &path, vec3f posT, posP, posM; - 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]); @@ -426,13 +433,13 @@ void sliderConstraintNode::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_slider_constraint(rigid_bodyA, pivInA, rotA, rigid_bodyB, pivInB, rotB); constraint = static_cast(m_constraint); solver_t::add_constraint(constraint); @@ -448,9 +455,9 @@ void sliderConstraintNode::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_slider_constraint(rigid_bodyA, pivInA, rotA); constraint = static_cast(m_constraint); solver_t::add_constraint(constraint); @@ -475,8 +482,8 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat 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; @@ -515,8 +522,8 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat } if(m_constraint) { - MQuaternion mrotation; - fnParentTransform.getRotation(mrotation, MSpace::kTransform); + MQuaternion mrotation; + fnParentTransform.getRotation(mrotation, MSpace::kTransform); bool doUpdatePivot = m_constraint->getPivotChanged(); if(!doUpdatePivot) { @@ -526,46 +533,46 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat 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); } } } @@ -576,8 +583,8 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat 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); diff --git a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp index 2decfcc29..fd81fcb30 100644 --- a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp @@ -614,7 +614,7 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil } - return false; + return true; } btTypedConstraint* btBulletWorldImporter::createUniversalD6Constraint(class btRigidBody* body0,class btRigidBody* otherBody, diff --git a/config.h.in b/config.h.in index 3159f1e96..5f6908192 100644 --- a/config.h.in +++ b/config.h.in @@ -9,27 +9,12 @@ /* Architecture is x86-64 */ #undef ARCH_X86_64 -/* Define when compiling for MacOS/X */ -#undef CS_PLATFORM_MACOSX - -/* Define when compiling for Unix and Unix-like (i.e. MacOS/X) */ -#undef CS_PLATFORM_UNIX - -/* Define when compiling for Win32 */ -#undef CS_PLATFORM_WIN32 - /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `mx' library (-lmx). */ -#undef HAVE_LIBMX - -/* Define to 1 if you have the `nsl' library (-lnsl). */ -#undef HAVE_LIBNSL - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -51,14 +36,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H -/* Whether the int32 type is available */ -#undef HAVE_TYPE_INT32 - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to 1 if you have the header file. */ -#undef HAVE_WINDOWS_H +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O @@ -99,9 +82,3 @@ /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN - -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* Avoid problem caused by missing */ -#undef __CARBONSOUND__ diff --git a/src/Makefile.am b/src/Makefile.am index 01b6e41a1..3a01aaf97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,6 +93,7 @@ libbulletmath_la_SOURCES = \ LinearMath/btQuickprof.cpp \ LinearMath/btGeometryUtil.cpp \ LinearMath/btAlignedAllocator.cpp \ + LinearMath/btSerializer.cpp \ LinearMath/btConvexHull.cpp \ LinearMath/btHashMap.h \ LinearMath/btConvexHull.h \ @@ -111,6 +112,7 @@ libbulletmath_la_SOURCES = \ LinearMath/btQuaternion.h \ LinearMath/btAlignedObjectArray.h \ LinearMath/btQuickprof.h \ + LinearMath/btSerializer.h \ LinearMath/btTransformUtil.h \ LinearMath/btTransform.h \ LinearMath/btDefaultMotionState.h \ @@ -545,4 +547,5 @@ nobase_bullet_include_HEADERS += \ LinearMath/btStackAlloc.h \ LinearMath/btAlignedObjectArray.h \ LinearMath/btHashMap.h \ - LinearMath/btQuickprof.h + LinearMath/btQuickprof.h\ + LinearMath/btSerializer.h