MCPcopy Create free account
hub / github.com/csaez/mscreen / simulate

Method simulate

tests/test_stress.py:118–150  ·  view source on GitHub ↗
(self, time)

Source from the content-addressed store, hash-verified

116 self._states[state][2] = value
117
118 def simulate(self, time):
119 if time == 1 and time != self.time:
120 self.clear()
121 self.time = 1
122 return
123 if time <= self.time:
124 return
125
126 for state in self._states:
127 emitters = state[1]
128 for e in emitters:
129 for _ in range(e.rate):
130 p = self.addPoint()
131 p.position = om2.MVector(e.position)
132 p.velocity = om2.MVector(e.initialVelocity)
133
134 for p in self.particles:
135 if p is None:
136 continue
137 # update velocity
138 forces = self._states[p.state][0]
139 for f in forces:
140 p.velocity += f(p)
141 # update position
142 p.position += p.velocity
143 p.age += 1
144 # remove old particle
145 ageLimit = self._states[p.state][2]
146 if ageLimit and p.age > ageLimit:
147 self.particles[p.id] = None
148 p.destroy()
149
150 self.time = time
151
152
153def bounce(particleSystem, p, groundLevel=0.0):

Callers 1

test_stress.pyFile · 0.80

Calls 3

clearMethod · 0.95
addPointMethod · 0.95
destroyMethod · 0.80

Tested by

no test coverage detected