Removing code duplication.
This commit is contained in:
parent
85d08d81d2
commit
2b0be77ac9
@ -23,9 +23,6 @@ void Physics::init(std::string geometryPath) //prepares bullet by creating all i
|
||||
|
||||
void Physics::takeUpdateStep(float timeDiff)
|
||||
{
|
||||
if(simulationActive)
|
||||
{
|
||||
|
||||
for(unsigned i = 0; i < allPositionConstraints.size();i++) //this handles the spring constraints
|
||||
{
|
||||
if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition()) //if constraint != position of the body because otherwise dir = 0
|
||||
@ -36,7 +33,8 @@ void Physics::takeUpdateStep(float timeDiff)
|
||||
allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength); //apply a foce upon the object pushing it towards the constraint position
|
||||
}
|
||||
}
|
||||
|
||||
if(simulationActive)
|
||||
{
|
||||
if(endgame)
|
||||
{
|
||||
currentDirection = playerBall->getCenterOfMassPosition();
|
||||
@ -64,23 +62,10 @@ void Physics::takeUpdateStep(float timeDiff)
|
||||
cameraBody->applyCentralForce(currentForce*1.0/force);
|
||||
}
|
||||
|
||||
|
||||
|
||||
world->stepSimulation(timeDiff);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned i = 0; i < allPositionConstraints.size();i++) //this handles the spring constraints
|
||||
{
|
||||
if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition()) //if constraint != position of the body because otherwise dir = 0
|
||||
{
|
||||
btVector3 dir = allPositionConstraints[i].position - allPositionConstraints[i].body->getCenterOfMassPosition();
|
||||
dir = dir*allPositionConstraints[i].strength - allPositionConstraints[i].body->getLinearVelocity()
|
||||
*allPositionConstraints[i].body->getLinearVelocity().length();
|
||||
allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength); //apply a foce upon the object pushing it towards the constraint position
|
||||
}
|
||||
}
|
||||
|
||||
btVector3 camPos = cameraBody->getCenterOfMassPosition();
|
||||
if(sinking)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user