vanderlin / ofxBox2d

Openframework wrapper for box2d
zlib License
320 stars 122 forks source link

enableGravity is commented out #110

Closed ofZach closed 5 years ago

ofZach commented 8 years ago

this has been commented out

https://github.com/vanderlin/ofxBox2d/blob/4ff6400dd19ca5277ba1407bc309f3622040ac10/src/ofxBox2dBaseShape.cpp#L155-L157

potential fix might be:

void ofxBox2dBaseShape::enableGravity(bool b) {
    if (b == false){
        bodyDef.gravityScale = 0.0;
    } else {
        bodyDef.gravityScale = 1.0;
    }
}
vanderlin commented 5 years ago

The bodyDef is only used before the body is created. This should do it, adding to updates I'm working on.

void ofxBox2dBaseShape::enableGravity(bool b) {
    if (body) {
        body->SetGravityScale(b ? 1 : 0);
    }
    else {
        bodyDef.gravityScale = b ? 1 : 0;
    }
}