Step steps the simulation. maxSubSteps should be 10 by default
(frameDelta float32, timeSinceLastCalled float32, maxSubSteps int)
| 190 | // Step steps the simulation. |
| 191 | // maxSubSteps should be 10 by default |
| 192 | func (s *Simulation) StepPlus(frameDelta float32, timeSinceLastCalled float32, maxSubSteps int) { |
| 193 | |
| 194 | if s.paused { |
| 195 | return |
| 196 | } |
| 197 | |
| 198 | dt := frameDelta//float32(frameDelta.Seconds()) |
| 199 | |
| 200 | //if timeSinceLastCalled == 0 { // Fixed, simple stepping |
| 201 | |
| 202 | s.internalStep(dt) |
| 203 | |
| 204 | // Increment time |
| 205 | //s.time += dt |
| 206 | |
| 207 | //} else { |
| 208 | // |
| 209 | // s.accumulator += timeSinceLastCalled |
| 210 | // var substeps = 0 |
| 211 | // for s.accumulator >= dt && substeps < maxSubSteps { |
| 212 | // // Do fixed steps to catch up |
| 213 | // s.internalStep(dt) |
| 214 | // s.accumulator -= dt |
| 215 | // substeps++ |
| 216 | // } |
| 217 | // |
| 218 | // var t = (s.accumulator % dt) / dt |
| 219 | // for j := 0; j < len(s.bodies); j++ { |
| 220 | // var b = s.bodies[j] |
| 221 | // b.previousPosition.lerp(b.position, t, b.interpolatedPosition) |
| 222 | // b.previousQuaternion.slerp(b.quaternion, t, b.interpolatedQuaternion) |
| 223 | // b.previousQuaternion.normalize() |
| 224 | // } |
| 225 | // s.time += timeSinceLastCalled |
| 226 | //} |
| 227 | |
| 228 | } |
| 229 | |
| 230 | // SetPaused sets the paused state of the simulation. |
| 231 | func (s *Simulation) SetPaused(state bool) { |