box2d world :: everything is so light !

一笑奈何 提交于 2019-12-14 02:40:40

问题


i'm using box2d 2.1.2 with cocos2d 0.99.4

in my world, everything is light, there is no sensation about dropping a stone or a box !! everything falling slowly at the same speed

b2Vec2 gravity; 
gravity.Set(0.0f, -10.0f);
bool doSleep = true;
world = new b2World(gravity, doSleep);

and my objects :

b2BodyDef *TBodyDef = new b2BodyDef;
    TBodyDef->position.Set(100, 200);
    b2Body *TBody = world->CreateBody(TBodyDef);
    TBody->SetType(b2_dynamicBody);
    TBody->SetAwake(true);
    b2CircleShape TCircleShape;
    TCircleShape.m_radius = 20;
    b2FixtureDef TFixtureDef;
    TFixtureDef.shape = &TCircleShape;
    TFixtureDef.friction = 0.1;
    TFixtureDef.density = 0.1;
    TFixtureDef.restitution = 1;
    TFixtureDef.filter.categoryBits = COLLISION_BIT_GP;
    TFixtureDef.filter.maskBits = COLLISION_BIT_TERRAIN;
    TBody->CreateFixture(&TFixtureDef);

    b2BodyDef *TBodyDef1 = new b2BodyDef;
    TBodyDef1->position.Set(200, 200);
    b2Body *TBody1 = world->CreateBody(TBodyDef1);
    TBody1->SetType(b2_dynamicBody);
    TBody1->SetAwake(true);
    b2CircleShape TCircleShape1;
    TCircleShape1.m_radius = 20;
    b2FixtureDef TFixtureDef1;
    TFixtureDef1.shape = &TCircleShape;
    TFixtureDef1.friction = 0.1;
    TFixtureDef1.density = 0.5;
    TFixtureDef1.restitution = 1;
    TFixtureDef1.filter.categoryBits = COLLISION_BIT_GP;
    TFixtureDef1.filter.maskBits = COLLISION_BIT_TERRAIN;
    TBody1->CreateFixture(&TFixtureDef1);

and my step :

int32 velocityIterations = 8;
int32 positionIterations = 3;

world->Step(dt, velocityIterations, positionIterations);

density changes nothing about the speed of falling. what is missing to make it as fluid as this : link text

thank you for your help


回答1:


An objects density does not affect the speed it falls at.

Negating air-resistance and other generally negligible effects all objects DO fall at the same speed.

How to test this: Pick up something light (e.g. your friends iPhone 4) and something heavy (your old CRT) and drop them out of a window at exactly the same time.



来源:https://stackoverflow.com/questions/3905315/box2d-world-everything-is-so-light

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!