Actually, the part that I haven't figured out yet is what to do in the Distance functions for continuous physics. 😕
Edge Shapes for C++ (Merged!)
General DiscussionSmall bug:
When trying to delete static edge shapes that aren't a loop, the final one's m_nextEdge is garbage, so it'll crash.
Fix:
Either initialize m_nextEdge/m_prevEdge to NULL in b2EdgeShape's constructor
and/or modify b2Body::CreateShape:
Edit:
Somehow not completely fixed. Creating a new edge after deleting an old one causes this assertion to go off in b2World::SolveTOI:
b2Assert(0.0f <= toi && toi <= 1.0f);
Once an object hits the newly created edge. Hmm...
When trying to delete static edge shapes that aren't a loop, the final one's m_nextEdge is garbage, so it'll crash.
Fix:
Either initialize m_nextEdge/m_prevEdge to NULL in b2EdgeShape's constructor
and/or modify b2Body::CreateShape:
Code:
if (edgeDef->isALoop)
connectEdges(s1, s0, angle);
else
s1->m_nextEdge=NULL;
connectEdges(s1, s0, angle);
else
s1->m_nextEdge=NULL;
Edit:
Somehow not completely fixed. Creating a new edge after deleting an old one causes this assertion to go off in b2World::SolveTOI:
b2Assert(0.0f <= toi && toi <= 1.0f);
Once an object hits the newly created edge. Hmm...
Oh, my bad. Thank you again for the help, and I'm glad you're finding my contribution useful. 🙂
Could you produce a testbed example demonstrating the second problem after properly initializing m_nextEdge?
Also, have you been able to reproduce the "crash bug" mentioned at the top of this thread? I haven't been able to cause it after releasing my code, so I'm thinking of mentally checking off that bug as "CANNOT REPRODUCE" even though I never figured out what might have fixed it.
Could you produce a testbed example demonstrating the second problem after properly initializing m_nextEdge?
Also, have you been able to reproduce the "crash bug" mentioned at the top of this thread? I haven't been able to cause it after releasing my code, so I'm thinking of mentally checking off that bug as "CANNOT REPRODUCE" even though I never figured out what might have fixed it.
Okay, after adding the fixes for m_nextEdge, add the attached test. Create a curve (c) then delete it (d) and then create another one. It'll fail on the SolveTOI with a -infinity TOI.
As far as your original bug, I've played around with the testbed quite a bit, but I haven't seen that specific problem.
As far as your original bug, I've played around with the testbed quite a bit, but I haven't seen that specific problem.
I'm sorry, I don't seem to be able to reproduce the bug on my machine. I think Macs will initialize everything to zero anyway. :/ On the plus side, this probably confirms that the bug is a bad variable initialization.
If I can get the testbed to compile on my old windows computer (it doesn't have visual studio...) I'll check it out there.
Also, that bezier curves thing is SICK (after setting ShiftMouseDown to virtual 🙂 ). Thanks for the link to the fast bezier curve implementation.
If I can get the testbed to compile on my old windows computer (it doesn't have visual studio...) I'll check it out there.
Also, that bezier curves thing is SICK (after setting ShiftMouseDown to virtual 🙂 ). Thanks for the link to the fast bezier curve implementation.
Ah, I had no idea Macs initialize to zero. I'll keep looking on the Windows side and see if I find the problem.
No problem. though. 🙂 I was really happy with it, too.
Edit:
Oops, it was easy enough that I should've caught it while looking at the prevedge stuff. Looks like a small typo in the constructor is what did it:
Second should obviously be m_coreV2. Works flawlessly after that!
No problem. though. 🙂 I was really happy with it, too.
Edit:
Oops, it was easy enough that I should've caught it while looking at the prevedge stuff. Looks like a small typo in the constructor is what did it:
Code:
m_coreV1 = -b2_toiSlop * (m_normal - m_direction) + m_v1;
m_coreV1 = -b2_toiSlop * (m_normal + m_direction) + m_v2;
m_coreV1 = -b2_toiSlop * (m_normal + m_direction) + m_v2;
Second should obviously be m_coreV2. Works flawlessly after that!
Excellent. I've updated the download at the top of this thread with your bug fixes.
Wha......Bezier lines!!! when does flash get this?!?!?
kne just used this formula, copied almost exactly from the C implementation provided near the bottom:
http://www.niksula.cs.hut.fi/~hkankaan/ ... rfast.html
It feeds the results into a b2EdgeChainDef to make lots of little edges to approximate the curve. It's arguably a performance hit to represent a curve as many line segments, but the C++ version runs fast enough that it's still very useful. It might also be useful for the Flash version, but either way it's not a part of Box2D, it's just a method for generating points.
http://www.niksula.cs.hut.fi/~hkankaan/ ... rfast.html
It feeds the results into a b2EdgeChainDef to make lots of little edges to approximate the curve. It's arguably a performance hit to represent a curve as many line segments, but the C++ version runs fast enough that it's still very useful. It might also be useful for the Flash version, but either way it's not a part of Box2D, it's just a method for generating points.
Ah right i see...
Original thread: https://box2d.org/forum/viewtopic.php?t=1577