| Class | ODE::ContactJoint |
| In: |
ext/body.c
(CVS)
|
| Parent: | ODE::Joint |
ODE::ContactJoint::initialize( contact, world, jointGroup ) — Create and return a new contact joint for the given contact.
/*
* ODE::ContactJoint::initialize( contact, world, jointGroup )
* --
* Create and return a new contact joint for the given contact.
*/
static VALUE
ode_contactJoint_init( argc, argv, self )
int argc;
VALUE *argv, self;
{
debugMsg(( "ODE::Joint init." ));
if ( !check_joint(self) ) {
ode_JOINT *ptr;
VALUE world, contact, jointGroup = Qnil;
dWorldID worldId;
ode_CONTACT *contactPtr;
dJointGroupID jointGroupId = 0;
/* Scan arguments */
debugMsg(( "Creating a new Joint: checking args." ));
rb_scan_args( argc, argv, "21", &world, &contact, &jointGroup );
/* Unwrap the underlying values of the world, the contact object, and
the joint group if it was specified. */
worldId = ode_get_world( world );
contactPtr = ode_get_contact( contact );
if ( jointGroup ) {
ode_JOINTGROUP *jointGroupPtr = ode_get_jointGroup( jointGroup );
jointGroupId = jointGroupPtr->id;
debugMsg(( "Got a JointGroup for new Joint: <%p>", jointGroupId ));
}
else {
debugMsg(( "No JointGroup for new Joint" ));
}
/* Allocate a joint struct and set its members */
debugMsg(( "Creating a new Joint: ALLOCing and setting struct members." ));
DATA_PTR( self ) = ptr = ode_joint_alloc();
ptr->object = self;
ptr->world = world;
ptr->contact = contact;
ptr->jointGroup = jointGroup;
ptr->obsolete = Qfalse;
ptr->id = dJointCreateContact( worldId, jointGroupId, contactPtr->contact );
/* Set the Ruby struct as the data pointer of the ODE object */
dJointSetData( ptr->id, ptr );
/* Register the new joint with the joint group specified, if there was
one. */
if ( jointGroup )
ode_jointGroup_register_joint( jointGroup, self );
}
return self;
}
ODE::ContactJoint#contact — Returns the ODE::Contact object associated with the joint.
/*
* ODE::ContactJoint#contact
* --
* Returns the ODE::Contact object associated with the joint.
*/
static VALUE
ode_contactJoint_contact( self )
VALUE self;
{
ode_JOINT *ptr = get_joint( self );
return ptr->contact;
}