Rubygame 3: Day 16
Published: | Comments: 4 | Filed under: Development
|Did some more Chipmunk R&D work today.
Small news is that I found out that it actually is possible to reassign a Shape to a different body. In fact, there was already a Shape#body= accessor that I somehow missed.
Bigger news is that I added a new method, Poly#set_verts, which allows the vertices of a Poly to be changed after creation. I tested it out in one of the demos, by making a shape that changes size at random. Sudden, dramatic changes in shape can cause undesired effects (like falling through the wall), but there's no real problem with gradual (or even moderate) changes in shape.
Thanks to Poly#set_verts, I'll be able to allow sprites to be resized and otherwise transformed, which is nice!
Speaking of transforming Polys, I've been working on a Matrix class for Chipmunk, to store transformation information. It's complete except for a bug in the matrix multiplication math that's causing some incorrect values. Once I fix that, I think it's ready to go.
Unfortunately, Chipmunk does not distinguish between points and vectors. While their data structures are equivalent (both have an X and Y component), there are behavioral differences when it comes to transformations. In particular, vectors should not be affected by translation (movement) operations, while points should be.
I'm not sure how I'll handle this. The obsessive compulsive streak in me thinks that there should be a new Point class, but that would require, I think, more changes to Chipmunk's guts than I want to make. Perhaps I could add an integer field to the Vect struct, which would indicate whether it was representing a vector or a point. Not the cleanest solution in the world, but serviceable.
Might make another report later about my fuzzy, shifting thoughts on sprites and sprite bodies, but now it's back to the code mines to figure out this matrix math.
Comments