Created
September 13, 2012 21:59
-
-
Save mosra/3718006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RigidBodyGroup::physicsStep(GLfloat timeDelta) { | |
for(RigidBody* body: bodies) { | |
/* Compute force at current position */ | |
body->force = _gravity; | |
body->physicsStep(); | |
GLfloat accelerationHalfTimeDelta = (body->force/(body->_mass*2))*timeDelta; | |
/* New position */ | |
body->transformation()[3].setXyz(body->transformation()[3].xyz() + (body->velocity + accelerationHalfTimeDelta)*timeDelta); | |
/* Compute force at new position */ | |
body->force = _gravity; | |
body->physicsStep(); | |
/* New velocity */ | |
body->velocity += accelerationHalfTimeDelta + (body->force/(body->_mass*2))*timeDelta; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment