MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / update

Method update

src/main/java/trace/physics/PhysicsSystem.kt:102–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101 })
102 }
103
104 fun update(delta: Float) {
105 var timeStep = delta / 1000f
106 if (timeStep > 0.2) {
107 System.err.println(" warning: large timestep :" + timeStep)
108 timeStep = 0.2f
109 } else if (timeStep < 1e-8) {
110 timeStep = 1 / 30f;
111 }
112
113 val velocityIterations = 6
114 val positionIterations = 3
115
116 world.step(timeStep, velocityIterations, positionIterations)
117
118 allPhysicsLines.forEach {
119 it.physicsToFLine()
120 }
121
122 contacts.retainAll {
123 if (it.tick == TICK) {
124 fire<List<field.linalg.Vec2>>(it.A, onContactStart, it.points)
125 fire<List<field.linalg.Vec2>>(it.B, onContactStart, it.points)
126 }
127 if (it.terminated != -1L) {
128 fire(it.A, onContactEnd)
129 fire(it.B, onContactEnd)
130 false
131 }
132 true
133 }
134 TICK++
135 }
136

Callers

nothing calls this directly

Calls 6

physicsToFLineMethod · 0.80
retainAllMethod · 0.80
updateFunction · 0.50
printlnMethod · 0.45
stepMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected