- CcdPhysicsDemo also uses Generic6DofConstraint (testing with mouse picking).
- HingeConstraint back to old method by default (comparison) - FCollada by default in ColladaDemo
This commit is contained in:
@@ -94,7 +94,7 @@ void HingeConstraint::BuildJacobian()
|
|||||||
|
|
||||||
void HingeConstraint::SolveConstraint(SimdScalar timeStep)
|
void HingeConstraint::SolveConstraint(SimdScalar timeStep)
|
||||||
{
|
{
|
||||||
#define NEW_IMPLEMENTATION
|
//#define NEW_IMPLEMENTATION
|
||||||
|
|
||||||
#ifdef NEW_IMPLEMENTATION
|
#ifdef NEW_IMPLEMENTATION
|
||||||
SimdScalar tau = 0.3f;
|
SimdScalar tau = 0.3f;
|
||||||
@@ -164,8 +164,9 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep)
|
|||||||
SimdScalar jacDiagABInv0 = 1.f / m_jacAng[0].getDiagonal();
|
SimdScalar jacDiagABInv0 = 1.f / m_jacAng[0].getDiagonal();
|
||||||
SimdScalar rel_vel0 = m_jacAng[0].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA,
|
SimdScalar rel_vel0 = m_jacAng[0].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA,
|
||||||
m_rbB.getLinearVelocity(),angvelB);
|
m_rbB.getLinearVelocity(),angvelB);
|
||||||
|
float tau1 = tau;//0.f;
|
||||||
|
|
||||||
SimdScalar impulse0 = (tau * axisB.dot(jointAxis1) / timeStep - damping * rel_vel0) * jacDiagABInv0;
|
SimdScalar impulse0 = (tau1 * axisB.dot(jointAxis1) / timeStep - damping * rel_vel0) * jacDiagABInv0;
|
||||||
SimdVector3 angular_impulse0 = jointAxis0 * impulse0;
|
SimdVector3 angular_impulse0 = jointAxis0 * impulse0;
|
||||||
|
|
||||||
m_rbA.applyTorqueImpulse( angular_impulse0);
|
m_rbA.applyTorqueImpulse( angular_impulse0);
|
||||||
@@ -181,7 +182,7 @@ void HingeConstraint::SolveConstraint(SimdScalar timeStep)
|
|||||||
SimdScalar rel_vel1 = m_jacAng[1].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA,
|
SimdScalar rel_vel1 = m_jacAng[1].getRelativeVelocity(m_rbA.getLinearVelocity(),angvelA,
|
||||||
m_rbB.getLinearVelocity(),angvelB);;
|
m_rbB.getLinearVelocity(),angvelB);;
|
||||||
|
|
||||||
SimdScalar impulse1 = -(tau * axisB.dot(jointAxis0) / timeStep + damping * rel_vel1) * jacDiagABInv1;
|
SimdScalar impulse1 = -(tau1 * axisB.dot(jointAxis0) / timeStep + damping * rel_vel1) * jacDiagABInv1;
|
||||||
SimdVector3 angular_impulse1 = jointAxis1 * impulse1;
|
SimdVector3 angular_impulse1 = jointAxis1 * impulse1;
|
||||||
|
|
||||||
m_rbA.applyTorqueImpulse( angular_impulse1);
|
m_rbA.applyTorqueImpulse( angular_impulse1);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ extern int glutScreenHeight;
|
|||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
const int numObjects = 120;//22;
|
const int numObjects = 22;
|
||||||
#else
|
#else
|
||||||
const int numObjects = 120;
|
const int numObjects = 120;
|
||||||
#endif
|
#endif
|
||||||
@@ -285,45 +285,34 @@ int main(int argc,char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//create a constraint
|
clientResetScene();
|
||||||
if (createConstraint)
|
|
||||||
{
|
{
|
||||||
//physObjects[i]->SetAngularVelocity(0,0,-2,true);
|
//physObjects[i]->SetAngularVelocity(0,0,-2,true);
|
||||||
int constraintId;
|
int constraintId;
|
||||||
|
|
||||||
float pivotX=CUBE_HALF_EXTENTS,
|
float pivotX=CUBE_HALF_EXTENTS,
|
||||||
pivotY=-CUBE_HALF_EXTENTS,
|
pivotY=CUBE_HALF_EXTENTS,
|
||||||
pivotZ=CUBE_HALF_EXTENTS;
|
pivotZ=CUBE_HALF_EXTENTS;
|
||||||
|
float axisX=0,axisY=1,axisZ=0;
|
||||||
float axisX=1,axisY=0,axisZ=0;
|
|
||||||
|
|
||||||
|
|
||||||
|
constraintId =physicsEnvironmentPtr->createConstraint(
|
||||||
HingeConstraint* hinge = 0;
|
physObjects[1],
|
||||||
|
//0,
|
||||||
SimdVector3 pivotInA(CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS);
|
physObjects[2],
|
||||||
SimdVector3 pivotInB(-CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS);
|
////PHY_POINT2POINT_CONSTRAINT,
|
||||||
SimdVector3 axisInA(0,1,0);
|
PHY_GENERIC_6DOF_CONSTRAINT,//can leave any of the 6 degree of freedom 'free' or 'locked'
|
||||||
SimdVector3 axisInB(0,-1,0);
|
//PHY_LINEHINGE_CONSTRAINT,
|
||||||
|
pivotX,pivotY,pivotZ,
|
||||||
RigidBody* rb0 = physObjects[1]->GetRigidBody();
|
axisX,axisY,axisZ
|
||||||
RigidBody* rb1 = physObjects[2]->GetRigidBody();
|
);
|
||||||
|
|
||||||
hinge = new HingeConstraint(
|
|
||||||
*rb0,
|
|
||||||
*rb1,pivotInA,pivotInB,axisInA,axisInB);
|
|
||||||
|
|
||||||
physicsEnvironmentPtr->m_constraints.push_back(hinge);
|
|
||||||
|
|
||||||
hinge->SetUserConstraintId(100);
|
|
||||||
hinge->SetUserConstraintType(PHY_LINEHINGE_CONSTRAINT);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clientResetScene();
|
|
||||||
|
|
||||||
setCameraDistance(26.f);
|
setCameraDistance(26.f);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ extern int gForwardAxis;
|
|||||||
#include "GLDebugDrawer.h"
|
#include "GLDebugDrawer.h"
|
||||||
|
|
||||||
//either FCollada or COLLADA_DOM
|
//either FCollada or COLLADA_DOM
|
||||||
//#define USE_FCOLLADA 1
|
#define USE_FCOLLADA 1
|
||||||
#ifdef USE_FCOLLADA
|
#ifdef USE_FCOLLADA
|
||||||
|
|
||||||
//Collada Physics test
|
//Collada Physics test
|
||||||
@@ -1088,6 +1088,23 @@ int main(int argc,char** argv)
|
|||||||
if (geom->getConvex_mesh())
|
if (geom->getConvex_mesh())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
{
|
||||||
|
const domConvex_meshRef convexRef = geom->getConvex_mesh();
|
||||||
|
daeElementRef otherElemRef = convexRef->getConvex_hull_of().getElement();
|
||||||
|
if ( otherElemRef != NULL )
|
||||||
|
{
|
||||||
|
domGeometryRef linkedGeom = *(domGeometryRef*)&otherElemRef;
|
||||||
|
printf( "otherLinked\n");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
printf("convexMesh polyCount = %i\n",convexRef->getPolygons_array().getCount());
|
||||||
|
printf("convexMesh triCount = %i\n",convexRef->getTriangles_array().getCount());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConvexHullShape* convexHullShape = new ConvexHullShape(0,0);
|
ConvexHullShape* convexHullShape = new ConvexHullShape(0,0);
|
||||||
|
|
||||||
//it is quite a trick to get to the vertices, using Collada.
|
//it is quite a trick to get to the vertices, using Collada.
|
||||||
|
|||||||
Reference in New Issue
Block a user