apecs-physics: Constraints implementation
Some things about constraints are iffy:
- MaxForce/MaxBias only apply to certain types of constraints, not all constraints
- Getting the properties of constraints leads to immediately outdated data when the constraints take
WVec. For example, I create a pivot joint withPivotJointat some position, but I want to draw the pivot point on a body which moves around. TheWVecisn't updated, so it isn't possible to do so. Chipmunk converts it to thePivotJoint2representation and provides functions to grab it. These could be implemented likeMaxForce, but really are only accessible in pivot joints.
Perhaps the ConstraintType should be lifted into the type of Constraint somehow?
The design of collisions and constraints is definitely still WIP(#36), and this is one of the issues. Since the time I can spend on gamedev is currently somewhat limited, I haven't really been able to play around and look for a better design myself, but it's something I hope to be able to return to in the near future, and any input/PRs are again very much appreciated.
MaxForce/MaxBias only apply to certain types of constraints, not all constraints
I think with these constraint-specific components, I think it might be a good idea to check during explExists whether they make sense for that ConstraintType. This was impossible when I first wrote apecs-physics, but now I think we could implement something like PinJointDistance (Chipmunk's getPinJointDistance) by just checking whether that constraint is actually a PinJoint.
The WVec isn't updated, so it isn't possible to do so.
Maybe for PinJoint it's a good idea to actually convert our own representation to PinJoint2 as well after construction, would that solve the problem in this situation?