Box2D Debug Draw

  ... the Physics Box2D Extension for AndEngine.

Box2D Debug Draw

Postby skyuzo » Thu Sep 08, 2011 2:45 am

I was looking for a debug draw the other day, and I found this thread. It didn't work, so I took the code and created my own debug draw.

You can find it here. It only draws the Box2D bodies (polygonal and circle shapes) right now. I hope it is useful for someone.
skyuzo
 
Posts: 76
Joined: Thu Sep 08, 2011 2:29 am

Re: Box2D Debug Draw

Postby asktomsk » Thu Sep 08, 2011 2:59 pm

Very useful, thanks!
My 1st released game Moopa
Image
asktomsk
 
Posts: 56
Joined: Sat Apr 02, 2011 8:42 am
Location: Russia

Re: Box2D Debug Draw

Postby liquidair » Wed Sep 14, 2011 6:44 am

Thank you very much for your effort.
while(dream == true) { Z++; }
http://www.joshideas.com
liquidair
 
Posts: 43
Joined: Fri Dec 31, 2010 4:47 am

Re: Box2D Debug Draw

Postby liquidair » Wed Sep 14, 2011 8:36 pm

Your code didn't work. Not sure if I missed something.

I went back to the original java code you that you rewrote and fixed it. Now, we have two projects.. sorry people..

But, I added a really and painfully ugly looking debugdraw for joints. If anyone is interested in my simple code let me know.. I'll shoot it over to you
Last edited by liquidair on Sun Sep 18, 2011 4:45 pm, edited 1 time in total.
while(dream == true) { Z++; }
http://www.joshideas.com
liquidair
 
Posts: 43
Joined: Fri Dec 31, 2010 4:47 am

Re: Box2D Debug Draw

Postby skyuzo » Sun Sep 18, 2011 11:07 am

liquidair wrote:Your code didn't work. Not sure if I missed something.

I went back to the original java code you rewrote it and updated it and got it working :) Now, we have two.. sorry people..

But, i add a really and painfully ugly looking debugdraw for joints. If anyone is interested in my simple code let me know.. I'll shoot it over to you


Mind fixing what didn't work and adding your joint code to my project? I think this would make things much simpler. PM me your email and I'll add you as a committer.
skyuzo
 
Posts: 76
Joined: Thu Sep 08, 2011 2:29 am

Re: Box2D Debug Draw

Postby Cornstar23 » Sun Sep 25, 2011 5:39 am

It worked for me and was easy to setup. This has saved me lots of time debugging. Much appreciated.
Cornstar23
 
Posts: 9
Joined: Sun Sep 25, 2011 2:03 am

Re: Box2D Debug Draw

Postby RealMayo » Wed Oct 05, 2011 4:54 am

Absolutely awesome! Thank you very much for creating this!
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: Box2D Debug Draw

Postby go4nishu » Wed Oct 12, 2011 1:44 pm

Found a bug in renderer
1. Remove a physics object in the scene
2. Debug renderer child remains on the scene


What is the expected output?
Debug renderer child for the removed object should be removed from scene.

Solution: I found a solution for this issue by removing the renderer child from scene in onManagedUpdate by iterating over bodies map

Here is the code

for(Body body: bodies.keySet()) {
ArrayList<Shape> mShapes = bodies.get(body);
int mShapeCount = mShapes.size();
for(int i = mShapeCount-1; i >= 0; i--) {
Shape debugShape = mShapes.get(i);
if(debugShape != null) {
this.detachChild(debugShape);
}
}
}
bodies.clear();


Added the above code in the start of onManagedUpdate method.
Attachments
Box2dDebugRenderer.png
Udpated Box2dDebugRenderer.java
Box2dDebugRenderer.png (417.6 KiB) Viewed 5295 times
go4nishu
 
Posts: 34
Joined: Tue Sep 13, 2011 9:22 am
Location: Chandigarh, India

Re: Box2D Debug Draw

Postby skyuzo » Mon Oct 17, 2011 9:52 pm

go4nishu wrote:Found a bug in renderer
[...]
Added the above code in the start of onManagedUpdate method.


Thanks! I'll add your fix soon.
skyuzo
 
Posts: 76
Joined: Thu Sep 08, 2011 2:29 am

Re: Box2D Debug Draw

Postby nazgee » Fri Nov 11, 2011 3:13 pm

Hi, in another thread I was complaining about some defects in debugdraw renderer. In the attachment, there is a little explanation of the problem I encountered. I was able to fix it in my code and I will try to contact the author of this extension so it can be fixed in the mainline.
Attachments
bodies.png
bodies.png (36.47 KiB) Viewed 5151 times
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Next

Return to Physics Box2D

Who is online

Users browsing this forum: Google Adsense [Bot] and 7 guests