예제 #1
0
void PhysicsBody::resetForces()
{
    cpBodyResetForces(_info->getBody());
    
    // if _gravityEnable is false, add a reverse of gravity force to body
    if (_world != nullptr && !_gravityEnable)
    {
        applyForce(-_world->getGravity() * _mass);
    }
}
예제 #2
0
void PhysicsBody::resetForces()
{
    cpBodyResetForces(_info->getBody());
    
    // if _gravityEnabled is false, add a reverse of gravity force to body
    if (_world != nullptr && _dynamic && !_gravityEnabled && _mass != PHYSICS_INFINITY)
    {
        applyForce(-_world->getGravity() * _mass);
    }
}
 void CDynamics2DMultiBodyObjectModel::Reset() {
    /* Reset body position */
    MoveTo(GetEmbodiedEntity().GetOriginAnchor().Position,
           GetEmbodiedEntity().GetOriginAnchor().Orientation);
    /* For each body: */
    for(size_t i = 0; i < m_vecBodies.size(); ++i) {
       /* Zero the speeds */
       m_vecBodies[i].Body->v = cpvzero;
       m_vecBodies[i].Body->w = 0.0f;
       /* Zero forces and torques */
       cpBodyResetForces(m_vecBodies[i].Body);
    }
 }
예제 #4
0
void CDynamics2DCylinderEntity::Reset() {
    if(m_ptBody != NULL) {
        /* Reset body position */
        const CVector3& cPosition = GetEmbodiedEntity().GetInitPosition();
        m_ptBody->p = cpv(cPosition.GetX(), cPosition.GetY());
        /* Reset body orientation */
        CRadians cXAngle, cYAngle, cZAngle;
        GetEmbodiedEntity().GetInitOrientation().ToEulerAngles(cZAngle, cYAngle, cXAngle);
        cpBodySetAngle(m_ptBody, cZAngle.GetValue());
        /* Zero speed and applied forces */
        m_ptBody->v = cpvzero;
        m_ptBody->w = 0.0f;
        cpBodyResetForces(m_ptBody);
    }
}
예제 #5
0
static void pullObjectFromPalette(cpShape *shape) {
    domino_t **dom;
    cpBody *body;
    palette_object_t *palObj;

    palObj = (palette_object_t *)shape->data;
    g_Dominoes[dominoIndex] = createDomino(atlMouseClickPos(), palObj);
    dom = &g_Dominoes[dominoIndex++];
    (*dom)->my_index = dominoIndex-1;
    body = (*dom)->body;
    cpBodyResetForces(body);
    cpBodySetMoment(body, INFINITY);
    body->w_limit = 0.0f;
    grabObject(body);
}
 void CDynamics2DSingleBodyObjectModel::Reset() {
    /* Nothing to do for a static body */
    if(cpBodyIsStatic(m_ptBody)) return;
    /* Reset body position */
    const CVector3& cPosition = GetEmbodiedEntity().GetOriginAnchor().Position;
    m_ptBody->p = cpv(cPosition.GetX(), cPosition.GetY());
    /* Reset body orientation */
    CRadians cXAngle, cYAngle, cZAngle;
    GetEmbodiedEntity().GetOriginAnchor().Orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
    cpBodySetAngle(m_ptBody, cZAngle.GetValue());
    /* Zero speed and applied forces */
    m_ptBody->v = cpvzero;
    m_ptBody->w = 0.0f;
    cpBodyResetForces(m_ptBody);
    /* Update bounding box */
    cpSpaceReindexShapesForBody(GetDynamics2DEngine().GetPhysicsSpace(), m_ptBody);
    CalculateBoundingBox();
 }
예제 #7
0
void initializeEditor(void) {
    int i;
    cpArray *bodies;
    cpBody *pb;
    cpPolyShape *ps;

    domino_t *dom;

    editorBody = cpBodyNew(INFINITY, INFINITY);
    editorBody->p = cpvzero;
    cpSpaceAddBody(g_Space, editorBody);

    /* Add collision handler so picking dominoes from the palette doesn't cause
     * weird collisions from the domino overlapping the palette */
    addIgnoredCollisionHandler(g_Space, DOMINO_OBJECT_TYPE, PALETTE_TYPE);

    loadEditorPalette();

    pb = NULL;
    bodies = g_Space->bodies;

    /* lock all bodies */
    for (i = 0; i < bodies->num; ++i) {
        pb = (cpBody *)bodies->arr[i];

        cpBodyResetForces(pb);
        cpBodySetMoment(pb, INFINITY);
        pb->w_limit = 0.0f;
    }

    /* add control points to dominoes */
    for (i = 0; i < MAX_DOMINOES; ++i) {
        dom = g_Dominoes[i];
        if (dom) {
            ps = (cpPolyShape *)dom->shape;
            addControlPointsToDomino(&dom);
        }
    }

    addIgnoredCollisionHandler(g_Space, CONTROL_POINT_TYPE, DOMINO_OBJECT_TYPE);
    addIgnoredCollisionHandler(g_Space, CONTROL_POINT_TYPE, CONTROL_POINT_TYPE);
    addIgnoredCollisionHandler(g_Space, CONTROL_POINT_TYPE, PLATFORM_TYPE);
}
예제 #8
0
파일: cbody.cpp 프로젝트: dogtwelve/eepp
void cBody::ResetForces() {
	cpBodyResetForces( mBody );
}
예제 #9
0
파일: kitty.cpp 프로젝트: teritriano/ftf
void fff::kitty::Reset(){
    rightimpulse = false;
    leftimpulse = false;
    cpBodyResetForces(body);
}
예제 #10
0
void PhysicsBody::resetForces()
{
    cpBodyResetForces(_cpBody);
}
예제 #11
0
//Tällä resetoidaan runkoihin kohdistuvat voimat
void resetBodyForces(cpBody *body, void *data)
{

	//Vaatii pieniä tarkistuksia, koska muuten nukkuminen ei toimisi
	if ((body->f.x != 0) || (body->f.y != 0) || (body->t != 0)) cpBodyResetForces(body);
}
예제 #12
0
파일: rb_cpBody.c 프로젝트: Anaxim/chipmunk
static VALUE
rb_cpBodyResetForces(VALUE self) {
  cpBodyResetForces(BODY(self));
  return self;
}
예제 #13
0
static int cpBody_resetForces (lua_State *L){ 
  cpBody *b = check_cpBody(L, 1);
  cpBodyResetForces(b);
  return 0;
}
예제 #14
0
파일: physics.c 프로젝트: andi2/cgame
void physics_reset_forces(Entity ent)
{
    PhysicsInfo *info = entitypool_get(pool, ent);
    error_assert(info);
    cpBodyResetForces(info->body);
}
예제 #15
0
파일: Body.cpp 프로젝트: Marwes/CppChipmunk
void Body::resetForces()
{
		cpBodyResetForces(body);
}