Crash bug when "mesh" applied twice fixed
Constraints reworked - all of them could now work with one or two bodies Modification of constraint frames and initial positions of rigid bodies now allowed at start frame only Plugin version is set to 2.76
This commit is contained in:
@@ -20,8 +20,7 @@ not be misrepresented as being the original software.
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
01/22/2010 : Constraints reworked
|
||||
*/
|
||||
|
||||
//bt_nail_constraint.h
|
||||
@@ -29,6 +28,7 @@ Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
#ifndef DYN_BT_NAIL_CONSTRAINT_H
|
||||
#define DYN_BT_NAIL_CONSTRAINT_H
|
||||
|
||||
#include "bt_rigid_body.h"
|
||||
#include "bt_constraint.h"
|
||||
#include "nail_constraint_impl.h"
|
||||
|
||||
@@ -50,8 +50,7 @@ public:
|
||||
btPoint2PointConstraint* p2pc = static_cast<btPoint2PointConstraint*>(m_constraint.get());
|
||||
btVector3 bt_pivot(p[0], p[1], p[2]);
|
||||
p2pc->setPivotA(bt_pivot);
|
||||
p2pc->setPivotB(m_constraint->getRigidBodyA().getCenterOfMassTransform()(bt_pivot));
|
||||
// p2pc->buildJacobian();
|
||||
setPivotChanged(true);
|
||||
}
|
||||
|
||||
virtual void get_pivotA(vec3f &p) const {
|
||||
@@ -61,17 +60,34 @@ public:
|
||||
p[2] = p2pc->getPivotInA().z();
|
||||
}
|
||||
|
||||
virtual void get_world_pivot(vec3f &p) const {
|
||||
// btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
// p[0] = p2pc->getPivotInB().x();
|
||||
// p[1] = p2pc->getPivotInB().y();
|
||||
// p[2] = p2pc->getPivotInB().z();
|
||||
virtual void set_pivotB(vec3f const &p) {
|
||||
btPoint2PointConstraint* p2pc = static_cast<btPoint2PointConstraint*>(m_constraint.get());
|
||||
btVector3 bt_pivot(p[0], p[1], p[2]);
|
||||
p2pc->setPivotB(bt_pivot);
|
||||
setPivotChanged(true);
|
||||
}
|
||||
|
||||
virtual void get_pivotB(vec3f &p) const {
|
||||
btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
p[0] = p2pc->getPivotInB().x();
|
||||
p[1] = p2pc->getPivotInB().y();
|
||||
p[2] = p2pc->getPivotInB().z();
|
||||
}
|
||||
|
||||
virtual void get_world_pivotA(vec3f &p) const {
|
||||
btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
btVector3 pivotAinW = p2pc->getRigidBodyA().getCenterOfMassTransform()* p2pc->getPivotInA();
|
||||
p[0] = pivotAinW.x();
|
||||
p[1] = pivotAinW.y();
|
||||
p[2] = pivotAinW.z();
|
||||
}
|
||||
virtual void get_world_pivotB(vec3f &p) const {
|
||||
btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
btVector3 pivotBinW = p2pc->getRigidBodyB().getCenterOfMassTransform()* p2pc->getPivotInB();
|
||||
p[0] = pivotBinW.x();
|
||||
p[1] = pivotBinW.y();
|
||||
p[2] = pivotBinW.z();
|
||||
}
|
||||
|
||||
virtual void set_world(vec3f const &p) {
|
||||
btPoint2PointConstraint* p2pc = static_cast<btPoint2PointConstraint*>(m_constraint.get());
|
||||
@@ -80,15 +96,12 @@ public:
|
||||
p2pc->setPivotA(pivotA);
|
||||
btVector3 pivotB = p2pc->getRigidBodyB().getWorldTransform().inverse() (world);
|
||||
p2pc->setPivotB(pivotB);
|
||||
// p2pc->buildJacobian();
|
||||
setPivotChanged(true);
|
||||
}
|
||||
|
||||
virtual void get_world(vec3f &p) const {
|
||||
btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
btVector3 pivotAinW = p2pc->getRigidBodyA().getCenterOfMassTransform()* p2pc->getPivotInA();
|
||||
// p[0] = p2pc->getPivotInB().x();
|
||||
// p[1] = p2pc->getPivotInB().y();
|
||||
// p[2] = p2pc->getPivotInB().z();
|
||||
p[0] = pivotAinW.x();
|
||||
p[1] = pivotAinW.y();
|
||||
p[2] = pivotAinW.z();
|
||||
@@ -115,10 +128,7 @@ public:
|
||||
{
|
||||
world.setValue(0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
// btVector3 world = p2pc->getPivotInB();
|
||||
// btVector3 pivotA = p2pc->getRigidBodyA().getWorldTransform().inverse() (world);
|
||||
// p2pc->setPivotA(pivotA);
|
||||
setPivotChanged(true);
|
||||
}
|
||||
protected:
|
||||
friend class bt_solver_t;
|
||||
@@ -126,30 +136,19 @@ protected:
|
||||
bt_nail_constraint_t(rigid_body_impl_t* rb, vec3f const& pivot):
|
||||
nail_constraint_impl_t()
|
||||
{
|
||||
btVector3 pivotW(pivot[0], pivot[1], pivot[2]);
|
||||
btVector3 bulPivot(pivot[0], pivot[1], pivot[2]);
|
||||
btRigidBody& bt_body = *static_cast<bt_rigid_body_t*>(rb)->body();
|
||||
const btTransform& tr = bt_body.getCenterOfMassTransform();
|
||||
btTransform iTr = tr.inverse();
|
||||
btVector3 nPivot = iTr * pivotW;
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_body, nPivot));
|
||||
// btVector3 pivotA = bt_body.getCenterOfMassPosition();
|
||||
// m_constraint.reset(new btPoint2PointConstraint(bt_body, -pivotA));
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_body, bulPivot));
|
||||
rb->add_constraint(this);
|
||||
}
|
||||
|
||||
bt_nail_constraint_t(rigid_body_impl_t* rbA, rigid_body_impl_t* rbB, vec3f const& pivot):
|
||||
bt_nail_constraint_t(rigid_body_impl_t* rbA, rigid_body_impl_t* rbB, vec3f const& pivotInA, vec3f const& pivotInB):
|
||||
nail_constraint_impl_t()
|
||||
{
|
||||
btVector3 pivotW(pivot[0], pivot[1], pivot[2]);
|
||||
btRigidBody& bt_bodyA = *static_cast<bt_rigid_body_t*>(rbA)->body();
|
||||
const btTransform& trA = bt_bodyA.getCenterOfMassTransform();
|
||||
btTransform iTrA = trA.inverse();
|
||||
btVector3 nPivotA = iTrA * pivotW;
|
||||
btRigidBody& bt_bodyB = *static_cast<bt_rigid_body_t*>(rbB)->body();
|
||||
const btTransform& trB = bt_bodyB.getCenterOfMassTransform();
|
||||
btTransform iTrB = trB.inverse();
|
||||
btVector3 nPivotB = iTrB * pivotW;
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_bodyA, bt_bodyB, nPivotA, nPivotB));
|
||||
btVector3 bulPivotInA(pivotInA[0], pivotInA[1], pivotInA[2]);
|
||||
btVector3 bulPivotInB(pivotInB[0], pivotInB[1], pivotInB[2]);
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_bodyA, bt_bodyB, bulPivotInA, bulPivotInB));
|
||||
rbA->add_constraint(this);
|
||||
rbB->add_constraint(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user