Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2011-02-27 12:21:13 +0300
committerDalai Felinto <dfelinto@gmail.com>2011-02-27 12:21:13 +0300
commitac1b08a9281e7a93064455b89a36715f094da2b0 (patch)
tree03529091ed4094cb13819d15608719ec16f816f8 /source/gameengine/Physics
parent2e5eb4152262adfc382860073dc5e73ced187e35 (diff)
BGE patch: [#26223] Some RigidBody joints fixes (ui angles, conetwist/hinge limits etc) by Juha Mäki-Kanto + ui changes pour moi
From the tracker::: Issues fixed: - ConeTwist-constraint's params weren't making it to the CcdPhysicsEnvironment, also added Hinge's params. - UI wasn't using angles where applicable. - btHingeConstraint's constructor can create frame-matrices which don't align so the hinge doesn's start at 0 degree tilt. This is an issue when setting limits. Changes: - UI: Hinge limits can be set (and disabled). - UI: ConeTwist only has max-limits and only the twistX can be disabled - PyApi via rna_constraint.c: added the functions limit_xyz_min, limit_xyz_max (for 6dof), limit_angle_xyz_min, limit_angle_xyz_max (for 6dof), limit_angle_x_min, limit_angle_x_max (for hinge). - PyApi: dropped python-function limit_cone_min. .:. Extra: UI Changes: - renamed "RigidBody Joint" to "Rigid Boidy Joint" - reorganized UI to conform with other parameters (e.g. Limit Rot) - added dis/active all over the place :)
Diffstat (limited to 'source/gameengine/Physics')
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp85
1 files changed, 77 insertions, 8 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 93f1d0962d7..937c70ede5e 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -1990,6 +1990,41 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float
default:
{
}
+ };
+ break;
+ };
+ case PHY_CONE_TWIST_CONSTRAINT:
+ {
+ switch (param)
+ {
+ case 3: case 4: case 5:
+ {
+ //param = 3,4,5 are constraint limits, high limit values
+ btConeTwistConstraint* coneTwist = (btConeTwistConstraint*)typedConstraint;
+ coneTwist->setLimit(param,value1);
+ break;
+ }
+ default:
+ {
+ }
+ };
+ break;
+ };
+ case PHY_ANGULAR_CONSTRAINT:
+ case PHY_LINEHINGE_CONSTRAINT:
+ {
+ switch (param)
+ {
+ case 3:
+ {
+ //param = 3 is a constraint limit, with low/high limit value
+ btHingeConstraint* hingeCons = (btHingeConstraint*)typedConstraint;
+ hingeCons->setLimit(value0,value1);
+ break;
+ }
+ default:
+ {
+ }
}
break;
};
@@ -2623,20 +2658,54 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
if (rb1)
{
- btVector3 axisInB = rb1 ?
- (rb1->getCenterOfMassTransform().getBasis().inverse()*(rb0->getCenterOfMassTransform().getBasis() * axisInA)) :
- rb0->getCenterOfMassTransform().getBasis() * axisInA;
+ // We know the orientations so we should use them instead of
+ // having btHingeConstraint fill in the blanks any way it wants to.
+ btTransform frameInA;
+ btTransform frameInB;
+
+ btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
+ if (axis1.length() == 0.0)
+ {
+ btPlaneSpace1( axisInA, axis1, axis2 );
+ }
+
+ // Internally btHingeConstraint's hinge-axis is z
+ frameInA.getBasis().setValue( axis1.x(), axis2.x(), axisInA.x(),
+ axis1.y(), axis2.y(), axisInA.y(),
+ axis1.z(), axis2.z(), axisInA.z() );
+
+ frameInA.setOrigin( pivotInA );
+
+ btTransform inv = rb1->getCenterOfMassTransform().inverse();
- hinge = new btHingeConstraint(
- *rb0,
- *rb1,pivotInA,pivotInB,axisInA,axisInB);
+ btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA;
+
+ frameInB = inv * globalFrameA;
+
+ hinge = new btHingeConstraint(*rb0,*rb1,frameInA,frameInB);
} else
{
- hinge = new btHingeConstraint(*rb0,
- pivotInA,axisInA);
+ static btRigidBody s_fixedObject2( 0,0,0);
+
+ btTransform frameInA;
+ btTransform frameInB;
+
+ btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
+ if (axis1.length() == 0.0)
+ {
+ btPlaneSpace1( axisInA, axis1, axis2 );
+ }
+
+ // Internally btHingeConstraint's hinge-axis is z
+ frameInA.getBasis().setValue( axis1.x(), axis2.x(), axisInA.x(),
+ axis1.y(), axis2.y(), axisInA.y(),
+ axis1.z(), axis2.z(), axisInA.z() );
+ frameInA.setOrigin( pivotInA );
+ frameInB = rb0->getCenterOfMassTransform() * frameInA;
+ hinge = new btHingeConstraint(*rb0, s_fixedObject2, frameInA, frameInB);
}
hinge->setAngularOnly(angularOnly);