forces are cleared after first iteration
This commit is contained in:
parent
e02e3f5faf
commit
2737113a84
|
@ -269,9 +269,7 @@ namespace SHADE
|
||||||
|
|
||||||
double accumulatedTime = 0.0f;
|
double accumulatedTime = 0.0f;
|
||||||
|
|
||||||
bool terminate = true;
|
|
||||||
int iterationCounter = simInfo.maxSteps;
|
int iterationCounter = simInfo.maxSteps;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
accumulatedTime += simInfo.timeStep;
|
accumulatedTime += simInfo.timeStep;
|
||||||
|
@ -280,16 +278,13 @@ namespace SHADE
|
||||||
raycastInfo.ray.position = ghostBody.position;
|
raycastInfo.ray.position = ghostBody.position;
|
||||||
raycastInfo.ray.direction = SHVec3::Normalise(ghostBody.linearVelocity);
|
raycastInfo.ray.direction = SHVec3::Normalise(ghostBody.linearVelocity);
|
||||||
|
|
||||||
terminate = !Raycast(raycastInfo).empty() || iterationCounter == 0;
|
if (!Raycast(raycastInfo).empty())
|
||||||
if (terminate)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (accumulatedTime > fixedDT)
|
while (accumulatedTime > fixedDT)
|
||||||
{
|
{
|
||||||
simulateBody(ghostBody, simInfo);
|
simulateBody(ghostBody, simInfo);
|
||||||
accumulatedTime -= fixedDT;
|
accumulatedTime -= fixedDT;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!simInfo.continuousForce)
|
if (!simInfo.continuousForce)
|
||||||
{
|
{
|
||||||
|
@ -297,14 +292,16 @@ namespace SHADE
|
||||||
simInfo.torque = SHVec3::Zero;
|
simInfo.torque = SHVec3::Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (--iterationCounter == 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (output.positions)
|
if (output.positions)
|
||||||
output.positions->emplace_back(ghostBody.position);
|
output.positions->emplace_back(ghostBody.position);
|
||||||
|
|
||||||
if (output.orientations)
|
if (output.orientations)
|
||||||
output.orientations->emplace_back(ghostBody.orientation);
|
output.orientations->emplace_back(ghostBody.orientation);
|
||||||
|
|
||||||
--iterationCounter;
|
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue