(self, time)
| 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 | |
| 153 | def bounce(particleSystem, p, groundLevel=0.0): |
no test coverage detected