Box2D Forums

It is currently Wed May 22, 2013 5:07 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Thu Oct 16, 2008 11:36 am 
Offline

Joined: Sun Jan 20, 2008 7:52 pm
Posts: 434
Actually, the part that I haven't figured out yet is what to do in the Distance functions for continuous physics. :?


Top
 Profile  
 
PostPosted: Fri Oct 31, 2008 12:38 pm 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
Small 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:
Code:
      if (edgeDef->isALoop)
         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...


Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 2:23 am 
Offline

Joined: Sun Jan 20, 2008 7:52 pm
Posts: 434
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.


Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 9:00 am 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
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.


Attachments:
BezierCurves.zip [2.15 KiB]
Downloaded 158 times
Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 3:16 pm 
Offline

Joined: Sun Jan 20, 2008 7:52 pm
Posts: 434
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.


Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 5:52 pm 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
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:
Code:
   m_coreV1 = -b2_toiSlop * (m_normal - m_direction) + m_v1;
   m_coreV1 = -b2_toiSlop * (m_normal + m_direction) + m_v2;

Second should obviously be m_coreV2. Works flawlessly after that!


Top
 Profile  
 
PostPosted: Sat Nov 01, 2008 9:00 pm 
Offline

Joined: Sun Jan 20, 2008 7:52 pm
Posts: 434
Excellent. I've updated the download at the top of this thread with your bug fixes.


Top
 Profile  
 
PostPosted: Sun Nov 02, 2008 12:51 am 
Offline

Joined: Tue Mar 18, 2008 8:53 pm
Posts: 156
Wha......Bezier lines!!! when does flash get this?!?!?


Top
 Profile  
 
PostPosted: Sun Nov 02, 2008 1:13 am 
Offline

Joined: Sun Jan 20, 2008 7:52 pm
Posts: 434
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.


Top
 Profile  
 
PostPosted: Sun Nov 02, 2008 7:48 pm 
Offline

Joined: Tue Mar 18, 2008 8:53 pm
Posts: 156
Ah right i see...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group