Ejemplo n.º 1
0
ETERM *space_add_body(ETERM *fromp, ETERM *argp) {

    // get the args
    ETERM *space_refp = erl_element(1, argp);
    ETERM *idp = erl_element(2, argp);
    ETERM *massp = erl_element(3, argp);
    // ETERM *inertiap = erl_element(4, argp);

    erlmunk_space *s;
    int space_id = ERL_REF_NUMBER(space_refp);
    HASH_FIND_INT(erlmunk_spaces, &space_id, s);

    int object_id = ERL_INT_VALUE(idp);

    cpBody *body = cpSpaceAddBody(s->space,
                                  cpBodyNew(ERL_FLOAT_VALUE(massp),
                                            INFINITY));
    // the body is created inactive, it is explicitly activated
    // when all it's values have been set.
    cpBodySleep(body);
    erlmunk_body_data *data = malloc(sizeof(erlmunk_body_data));
    data->id = object_id;
    data->term = NULL;
    cpBodySetUserData(body, (cpDataPointer) data);
    space_add_body_hash(s, object_id, body);

    return NULL;
}
Ejemplo n.º 2
0
Archivo: physics.c Proyecto: dns/CLove
/* Forces a body to sleep. Cannot be called from a callback! */
static int l_physics_setBodySleep(lua_State* state)
{
    l_tools_checkUserDataPlusErrMsg(state, 1, "You must provide a body");
    l_physics_Body* body = (l_physics_Body*)lua_touserdata(state, 1);

    cpBodySleep(body->body);

    return 0;
}
Ejemplo n.º 3
0
void PhysicsBody::setResting(bool rest) const
{
    if (rest && !isResting())
    {
        cpBodySleep(_info->getBody());
    }else if(!rest && isResting())
    {
        cpBodyActivate(_info->getBody());
    }
}
Ejemplo n.º 4
0
void cBody::Sleep() {
	cpBodySleep( mBody );
}
Ejemplo n.º 5
0
static VALUE
rb_cpBodySleep(VALUE self) {
  cpBody * body = rb_cpBodySleepValidate(self);
  cpBodySleep(body);
  return self;
}
Ejemplo n.º 6
0
void Body::sleep()
{
		cpBodySleep(body);
}