Implementing a joint

Hi,

If it's easy, could some guru describe what needs to be done to create a custom joint type:
- what methods have to be implemented ?
- when are they called and what should they affect (and how) ?

Thanks in advance if someone can help !
I suggest two options:
1. Copy an existing joint and modify it.
2. Request a new joint type here: http://code.google.com/p/box2d/issues/list
Erin Catto wrote:
2. Request a new joint type here: http://code.google.com/p/box2d/issues/list


I am still in need of those famous portals physics. From previous posts I gathered that this is not in your immediate plans, so I thought I'd better try to do it.

Erin Catto wrote:
1. Copy an existing joint and modify it.


I have some trouble understanding how existing joints work, with regard to the internals of the engine. I was hoping that I could manage mostly by learning about general physics, but I think some knowledge of the engine is required. I would like to avoid random hacking if possible.
Here are my first assumptions, after looking at some existing joints.
Please feel free to correct them, or give any other kind of relevant information.

- m_sweep indicates where a body is about to move in the current step

- In a step, the engine first simulates as if joints did not exist.
- Then InitVelocityConstraints is called once. You (as joint implementer) can do whatever you wish in this method, there is no "contract".
- Then SolveVelocityConstraints and SolvePositionConstraints are called potentially several times in the step. Their goal is to alter m_sweep, m_linearVelocity, and m_angularVelocity of the bodies.
- Only the joint has to be satisfied by these alterations, the engine itself does not care

Many thanks in advance !
Yeah, that is all correct.

You can learn about some of the math by reading some of the documents here:
http://code.google.com/p/box2d/downloads/list

Original thread: https://box2d.org/forum/viewtopic.php?t=5786