pymunk
pymunk copied to clipboard
Can't add to vector length when length is 0
Would be nice for it to remember the last 'direction' it was in to be able to up it's speed once an object has stopped.
Currently throws: File "pymunk\vec2d.pyo", line 310, in __setlength ZeroDivisionError: float division by zero
Though with the convention set in get_angle that the angle is zero if the length is zero, I would at least expect it to increase the vector in that direction.
Thanks
From the user's point of view this seems like a reasonable request, I can see how it would be useful.
However, Im a bit concerned about two things:
- It requires an extra field on the Vec2d class (50% bigger in size), are there any performance implications maybe?
- The vector doesnt "exist" for the pymunk objects until you ask for it. So, if you get the velocity from a Body in one frame, and then ask for it again the next frame it wont use the same vector, instead it creates a new one from a X value and a Y value kept in the underlying c code . And if the new one is 0,0 it cant remember its previous velocity, since it didnt exist at that time, it was a different vector.
The second one is the most serious one, I dont immediately see what a good solution would be.. Not sure if this feature would be useful if you couldnt use it to keep the information about pymunk objects, only free Vec2d objects.
I see, thanks for the extra info, didn't realize about point # 2. That certainly seems like a challenge. Almost seems like a request for Chipmunk directly then.
In my current project I'm now caching the vector so if it's 0,0 I grab the cached one and use that to perform my calculation.