Apply gel hinge joint limits when appropriate.
This commit is contained in:
@@ -425,7 +425,7 @@ float b2RevoluteJoint::GetUpperLimit() const
|
|||||||
void b2RevoluteJoint::SetLimits(float lower, float upper)
|
void b2RevoluteJoint::SetLimits(float lower, float upper)
|
||||||
{
|
{
|
||||||
b2Assert(lower <= upper);
|
b2Assert(lower <= upper);
|
||||||
|
|
||||||
if (lower != m_lowerAngle || upper != m_upperAngle)
|
if (lower != m_lowerAngle || upper != m_upperAngle)
|
||||||
{
|
{
|
||||||
m_bodyA->SetAwake(true);
|
m_bodyA->SetAwake(true);
|
||||||
|
|||||||
@@ -35,17 +35,15 @@ extern "C"
|
|||||||
/// Forge
|
/// Forge
|
||||||
//
|
//
|
||||||
|
|
||||||
|
Joint *
|
||||||
Joint*
|
b2d_new_hinge_Joint_with_local_anchors (Space *in_Space,
|
||||||
b2d_new_hinge_Joint_with_local_anchors
|
Object *Object_A,
|
||||||
(Space* in_Space,
|
Object *Object_B,
|
||||||
Object* Object_A,
|
Vector_3 *Anchor_in_A,
|
||||||
Object* Object_B,
|
Vector_3 *Anchor_in_B,
|
||||||
Vector_3* Anchor_in_A,
|
float low_Limit,
|
||||||
Vector_3* Anchor_in_B,
|
float high_Limit,
|
||||||
float low_Limit,
|
bool collide_Connected)
|
||||||
float high_Limit,
|
|
||||||
bool collide_Connected)
|
|
||||||
{
|
{
|
||||||
b2RevoluteJointDef* Self = new b2RevoluteJointDef();
|
b2RevoluteJointDef* Self = new b2RevoluteJointDef();
|
||||||
|
|
||||||
@@ -54,10 +52,10 @@ b2d_new_hinge_Joint_with_local_anchors
|
|||||||
Self->bodyB = (b2Body*) Object_B; // The actual b2Body will be substituted when the joint is added to the world.
|
Self->bodyB = (b2Body*) Object_B; // The actual b2Body will be substituted when the joint is added to the world.
|
||||||
|
|
||||||
Self->localAnchorA = b2Vec2 (Anchor_in_A->x,
|
Self->localAnchorA = b2Vec2 (Anchor_in_A->x,
|
||||||
Anchor_in_A->y);
|
Anchor_in_A->y);
|
||||||
|
|
||||||
Self->localAnchorB = b2Vec2 (Anchor_in_B->x,
|
Self->localAnchorB = b2Vec2 (Anchor_in_B->x,
|
||||||
Anchor_in_B->y);
|
Anchor_in_B->y);
|
||||||
|
|
||||||
Self->lowerAngle = low_Limit;
|
Self->lowerAngle = low_Limit;
|
||||||
Self->upperAngle = high_Limit;
|
Self->upperAngle = high_Limit;
|
||||||
@@ -70,15 +68,15 @@ b2d_new_hinge_Joint_with_local_anchors
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Joint*
|
Joint *
|
||||||
b2d_new_hinge_Joint (Space* in_Space,
|
b2d_new_hinge_Joint (Space *in_Space,
|
||||||
Object* Object_A,
|
Object *Object_A,
|
||||||
Object* Object_B,
|
Object *Object_B,
|
||||||
Matrix_4x4* Frame_A,
|
Matrix_4x4 *Frame_A,
|
||||||
Matrix_4x4* Frame_B,
|
Matrix_4x4 *Frame_B,
|
||||||
float low_Limit,
|
float low_Limit,
|
||||||
float high_Limit,
|
float high_Limit,
|
||||||
bool collide_Connected)
|
bool collide_Connected)
|
||||||
{
|
{
|
||||||
b2RevoluteJointDef* Self = new b2RevoluteJointDef();
|
b2RevoluteJointDef* Self = new b2RevoluteJointDef();
|
||||||
|
|
||||||
@@ -99,10 +97,26 @@ b2d_new_hinge_Joint (Space* in_Space,
|
|||||||
|
|
||||||
|
|
||||||
Joint*
|
Joint*
|
||||||
b2d_new_space_hinge_Joint (Object* Object_A,
|
b2d_new_space_hinge_Joint (Space* in_Space,
|
||||||
|
Object* Object_A,
|
||||||
Matrix_4x4* Frame_A)
|
Matrix_4x4* Frame_A)
|
||||||
{
|
{
|
||||||
return 0;
|
b2RevoluteJointDef* Self = new b2RevoluteJointDef();
|
||||||
|
b2World* World = (b2World*) in_Space;
|
||||||
|
b2BodyDef groundDef;
|
||||||
|
b2Body* Ground = World->CreateBody (&groundDef);
|
||||||
|
Vector_2 ground_Site = Vector_2 (0.0, 0.0);
|
||||||
|
// Object* Object_B = b2d_new_Object (&ground_Site,
|
||||||
|
// 0.0,
|
||||||
|
// 0.0,
|
||||||
|
// 0.0,
|
||||||
|
// b2d_new_Circle (0.1));
|
||||||
|
|
||||||
|
Self->bodyA = (b2Body*) Object_A;
|
||||||
|
Self->bodyB = Ground; // (b2Body*) Object_B;
|
||||||
|
|
||||||
|
|
||||||
|
return (Joint*) dynamic_cast <b2JointDef*> (Self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,37 +7,37 @@
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Joint;
|
struct Joint;
|
||||||
struct Space;
|
struct Space;
|
||||||
|
|
||||||
|
|
||||||
/////////
|
/////////
|
||||||
/// Forge
|
/// Forge
|
||||||
//
|
//
|
||||||
|
|
||||||
Joint* b2d_new_hinge_Joint_with_local_anchors
|
Joint *b2d_new_hinge_Joint_with_local_anchors (Space *in_Space,
|
||||||
(Space* in_Space,
|
Object *Object_A,
|
||||||
Object* Object_A,
|
Object *Object_B,
|
||||||
Object* Object_B,
|
Vector_3 *Anchor_in_A,
|
||||||
Vector_3* Anchor_in_A,
|
Vector_3 *Anchor_in_B,
|
||||||
Vector_3* Anchor_in_B,
|
float low_Limit,
|
||||||
float low_Limit,
|
float high_Limit,
|
||||||
float high_Limit,
|
bool collide_Connected);
|
||||||
bool collide_Connected);
|
|
||||||
|
|
||||||
Joint* b2d_new_hinge_Joint (Space* in_Space,
|
Joint* b2d_new_hinge_Joint (Space* in_Space,
|
||||||
Object* Object_A,
|
Object* Object_A,
|
||||||
Object* Object_B,
|
Object* Object_B,
|
||||||
Matrix_4x4* Frame_A,
|
Matrix_4x4* Frame_A,
|
||||||
Matrix_4x4* Frame_B,
|
Matrix_4x4* Frame_B,
|
||||||
float low_Limit,
|
float low_Limit,
|
||||||
float high_Limit,
|
float high_Limit,
|
||||||
bool collide_Connected);
|
bool collide_Connected);
|
||||||
|
|
||||||
void b2d_free_hinge_Joint (Joint* Self);
|
void b2d_free_hinge_Joint (Joint* Self);
|
||||||
|
|
||||||
Joint* b2d_new_space_hinge_Joint (Object* Object_A,
|
Joint* b2d_new_space_hinge_Joint (Space* in_Space,
|
||||||
|
Object* Object_A,
|
||||||
Matrix_4x4* Frame_A);
|
Matrix_4x4* Frame_A);
|
||||||
|
|
||||||
|
|
||||||
@@ -61,13 +61,13 @@ extern "C"
|
|||||||
Vector_3* Pivot_in_A,
|
Vector_3* Pivot_in_A,
|
||||||
Vector_3* Pivot_in_B);
|
Vector_3* Pivot_in_B);
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
/// Attributes
|
/// Attributes
|
||||||
//
|
//
|
||||||
|
|
||||||
void* b2d_Joint_user_Data (Joint* Self);
|
void* b2d_Joint_user_Data (Joint* Self);
|
||||||
void b2d_Joint_user_Data_is (Joint* Self, void* Now);
|
// void b2d_Joint_user_Data_is (Joint* Self, void* Now);
|
||||||
|
|
||||||
Object* b2d_Joint_Object_A (Joint* Self);
|
Object* b2d_Joint_Object_A (Joint* Self);
|
||||||
Object* b2d_Joint_Object_B (Joint* Self);
|
Object* b2d_Joint_Object_B (Joint* Self);
|
||||||
@@ -80,8 +80,8 @@ extern "C"
|
|||||||
|
|
||||||
void b2d_Joint_set_local_Anchor (Joint* Self, bool is_Anchor_A,
|
void b2d_Joint_set_local_Anchor (Joint* Self, bool is_Anchor_A,
|
||||||
Vector_3* local_Anchor);
|
Vector_3* local_Anchor);
|
||||||
|
|
||||||
|
|
||||||
bool b2d_Joint_is_Limited (Joint* Self, int DoF);
|
bool b2d_Joint_is_Limited (Joint* Self, int DoF);
|
||||||
bool b2d_Joint_Extent (Joint* Self, int DoF);
|
bool b2d_Joint_Extent (Joint* Self, int DoF);
|
||||||
|
|
||||||
@@ -90,16 +90,16 @@ extern "C"
|
|||||||
|
|
||||||
Vector_3 b2d_Joint_reaction_Force (Joint* Self);
|
Vector_3 b2d_Joint_reaction_Force (Joint* Self);
|
||||||
Real b2d_Joint_reaction_Torque (Joint* Self);
|
Real b2d_Joint_reaction_Torque (Joint* Self);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Hinge
|
/// Hinge
|
||||||
//
|
//
|
||||||
|
|
||||||
void b2d_Joint_hinge_Limits_are (Joint* Self, Real Low,
|
void b2d_Joint_hinge_Limits_are (Joint* Self, Real Low,
|
||||||
Real High);
|
Real High);
|
||||||
|
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -765,7 +765,9 @@ is
|
|||||||
end new_hinge_Joint;
|
end new_hinge_Joint;
|
||||||
|
|
||||||
|
|
||||||
function new_hinge_Joint (Object_A : in physics.Object.view;
|
|
||||||
|
function new_hinge_Joint (in_Space : in box2d_c.Pointers.Space_Pointer;
|
||||||
|
Object_A : in physics.Object.view;
|
||||||
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view
|
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view
|
||||||
is
|
is
|
||||||
use type box2d_physics.Object.view;
|
use type box2d_physics.Object.view;
|
||||||
@@ -775,7 +777,8 @@ is
|
|||||||
c_Object_A : constant box2d_C.Pointers.Object_Pointer := box2d_physics.Object.view (Object_A).C;
|
c_Object_A : constant box2d_C.Pointers.Object_Pointer := box2d_physics.Object.view (Object_A).C;
|
||||||
c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A;
|
c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A;
|
||||||
begin
|
begin
|
||||||
Self.C := b2d_new_space_hinge_Joint (c_Object_A,
|
Self.C := b2d_new_space_hinge_Joint (in_Space,
|
||||||
|
c_Object_A,
|
||||||
c_Frame_A'unchecked_Access);
|
c_Frame_A'unchecked_Access);
|
||||||
return Self;
|
return Self;
|
||||||
end new_hinge_Joint;
|
end new_hinge_Joint;
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ is
|
|||||||
low_Limit, high_Limit : in math.Real;
|
low_Limit, high_Limit : in math.Real;
|
||||||
collide_Conected : in Boolean) return physics.Joint.hinge.view;
|
collide_Conected : in Boolean) return physics.Joint.hinge.view;
|
||||||
|
|
||||||
function new_hinge_Joint (Object_A : in physics.Object.view;
|
function new_hinge_Joint (in_Space : in box2d_c.Pointers.Space_Pointer;
|
||||||
|
Object_A : in physics.Object.view;
|
||||||
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view;
|
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ is
|
|||||||
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view
|
Frame_A : in Matrix_4x4) return physics.Joint.hinge.view
|
||||||
is
|
is
|
||||||
pragma unreferenced (Self);
|
pragma unreferenced (Self);
|
||||||
the_Joint : constant physics.Joint.hinge.view := box2d_physics.Joint.new_hinge_Joint (Object_A, Frame_A);
|
the_Joint : constant physics.Joint.hinge.view := box2d_physics.Joint.new_hinge_Joint (Self.C, Object_A, Frame_A);
|
||||||
begin
|
begin
|
||||||
return the_Joint;
|
return the_Joint;
|
||||||
end new_hinge_Joint;
|
end new_hinge_Joint;
|
||||||
|
|||||||
@@ -973,7 +973,6 @@ is
|
|||||||
pivot_Anchor => pivot_Anchor);
|
pivot_Anchor => pivot_Anchor);
|
||||||
|
|
||||||
the_Joint.Limits_are (low_Limit, high_Limit);
|
the_Joint.Limits_are (low_Limit, high_Limit);
|
||||||
|
|
||||||
Self.attach (the_Child, the_Joint.all'Access);
|
Self.attach (the_Child, the_Joint.all'Access);
|
||||||
|
|
||||||
new_Joint := the_Joint.all'Access;
|
new_Joint := the_Joint.all'Access;
|
||||||
|
|||||||
Reference in New Issue
Block a user