Instant Teleportation

mayobutter wrote:
I'm pretty sure that sensor contacts are handled in exactly the same manner as normal body contacts (just without a collision response). So... CCD should work with sensors. Correct me if I'm wrong.
Yeah, CCD doesn't work with sensors, though the manual doesn't say so explicitly. Problem is that if sensors counted for CCD then an overlapping shape would cause the engine to hang by advancing the time by 0 repeatedly. There is probably some work around to ensure that sensors only count for CCD once per frame, but it ain't in Box2D yet. There is already a TODO_ERIN in the code which looks like it will fix this.
spitzanator wrote:
Unfortunately, I try to store the contact velocity, but when the contact callback registers, it has the new velocity (the one that it receives AFTER bouncing).
It really should be working? The docs for b2ContactPoint.velocity definitely states it has the pre-solver velocity (relative velocity, not that it affects you). You sure you are getting a contact point and not a contact result?
It's all over the place in classes and such, but the jist is:

while (true) {
flushbuffer();
updateworld();

}

...where my listener dumps events into the buffer, which gets flushed to propagate all collisions.

I'm assuming that after the world is updated, all of the listeners will have received all callbacks.

I guess the other question is what sort of edits I can do inside the callback. I know I can't delete pointers, but can I move bodies around mid-callback? I thought that wasn't allowed.

Thanks,
Matt
BorisTheBrave wrote:
Yeah, CCD doesn't work with sensors, though the manual doesn't say so explicitly. Problem is that if sensors counted for CCD then an overlapping shape would cause the engine to hang by advancing the time by 0 repeatedly.

Yikes. Ok, thanks for the correction! Good to know.
Don't mind this post. See the new one below. I'm still an idiot.
Now I'm further confused.

I'm sorry, earlier, I was pulling the velocity from the contactPoint->ball->getBody()->velocity

That'd make sense that that's the POST collision. I'm an idiot. Now, to do the right thing...

@Boris:

How do you get the b2ContactPoint.velocity? The only class members I see in b2Contact.h are:

/// This structure is used to report contact points.
struct b2ContactPoint
{
b2Shape* shape1; ///< the first shape
b2Shape* shape2; ///< the second shape
b2Vec2 position; ///< position in world coordinates
b2Vec2 normal; ///< points from shape1 to shape2
float32 separation; ///< the separation is negative when shapes are touching
float32 normalForce; ///< the signed magnitude of the normal force
float32 tangentForce; ///< the signed magnitude of the tangent force
b2ContactID id; ///< the contact id identifies the features in contact
};
Seems like you've got an older version where the velocity hadn't been added yet.
Yeah, you need to upgrade, to get that velocity field.
Similarly, I think even if you had correctly tried to GetLinearVelocity when the listener was called (instead of when it was retrieved from the buffer), you would still have got the post solver value. IIRC this was changed when Erin Catto added the Result callback.
Ah HAH!

Thanks! I'll upgrade. I assume it's all backward-compatible...?
Bah, RTFM, Matt.

Thank you everyone for your help. I really appreciate it. I guess I started working on this thing in mid-March and didn't expect updates to come so frequently.

Hooray for updates!

Thanks again.

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