Box2d debug draw - working and simple to use

  ... the case you feel the need for a new feature or want to submit one.

Re: Box2d debug draw - working and simple to use

Postby RealMayo » Wed Jan 02, 2013 5:02 am

I'm excited to see the joints supported now!
I'm not using Anchor Center, I'm using Nicolas' AndEngine GLES2 and hrabia's box2D.
I'm experiencing some errors with your DebugDraw GLES2-latest-B2D branch. (Note: your previous version worked fine)

In DebugRenderer.java errors begin occurring at this line...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. while (iterator.hasNext()) {
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


In RenderOfJointPolyline errors begin occurring at this line...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import org.andengine.util.adt.color.Color;
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: Box2d debug draw - working and simple to use

Postby nazgee » Wed Jan 02, 2013 9:10 am

Should be fixed now- these errors were result of a failed merge... However, I checked only for compilation errors- no functional tests were done on branches other than GLES2-AnchorCenter-latest-B2D
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: Box2d debug draw - working and simple to use

Postby RealMayo » Wed Jan 02, 2013 7:03 pm

Thanks, it works now. :)
I just wish that it worked a bit differently. For joints, you currently display an icon that looks like an hourglass (having a triangle on top and triangle on bottom). I was hoping that each of those triangles represented the anchor points of the joint. For example with a RevoluteJoint you can set localAnchorA and localAnchorB. Your debugDraw would be very useful when trying to establish the location of the anchors if I could see the location of each anchor on the screen. :|
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: Box2d debug draw - working and simple to use

Postby RealMayo » Wed Jan 02, 2013 7:10 pm

Another thing I just noticed.... it is rendering the behavior of revoluteJoints wrong. Your previous version worked fine. When I rotate a body attached to a revoluteJoint the debugDraw is showing a weird rotation that is not what is actually happening. :|
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: Box2d debug draw - working and simple to use

Postby nazgee » Wed Jan 02, 2013 7:29 pm

I must have broken GLES2 branch again apparently... (works fine for Anchor center). I am currently having 38.5'C fever so I am unable to seat in front of PC, but I will gladly accept pull requests to fix the issue ;) I bet that it is setRotationCenter() call that is broken again...

As you can see in "spider example" from the first post, hourglass should be drawn for joints that have anchor points in the same place (closer than 0.1m), and line connecting anchor points should be drawn in case where they are far away from each other.
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: Box2d debug draw - working and simple to use

Postby RealMayo » Wed Jan 02, 2013 8:03 pm

I hope you feel better soon.

I don't see a line drawn.
Perhaps the problem with this as well as the weird rotation is that you have your Y-axis flipped because of AnchorCenter, and you forgot to flip the Y-axis back for GLES2.
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: Box2d debug draw - working and simple to use

Postby nazgee » Fri Jan 04, 2013 1:18 am

I've fixed the wrong rotation issue for GLES2 and GLES2-latest-B2D, so bodies should be rendered fine again.

Regarding nicer represantation of joints anchor points, there is still some kind of issue. Problem is that this piece of code returns true no matter what (for epsilon=0.1):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private boolean epsilonEquals (Vector2 objA, Vector2 objB, float epsilon) {
  2.                 if (Math.abs(objB.x - objA.x) > epsilon) return false;
  3.                 if (Math.abs(objB.y - objA.y) > epsilon) return false;
  4.                 return true;
  5.         }
  6.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


As a result debug draw "thinks" that joints' anchors are very close to each other and draws an hourglass, instead of line connecting them... strange.

I am not really sure if it happens exclusively for revolution joints, or 'old' (aka Nicolas') version of AndEnginePhysicsBox2DExtension. All I can tell is that it works for rope joint in 'latest' (RealFictionFactory's) version of AndEnginePhysicsBox2DExtension.

If you wish to have a look at the troublesome code, have a look at update() method here: https://github.com/nazgee/AndEngineDebu ... yline.java
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: Box2d debug draw - working and simple to use

Postby nazgee » Fri Jan 04, 2013 1:36 am

I am currently pretty sure, that revolution joints are using anchor points in a different way than rope/mouse joints do, hence problems with properly drawing them...

I assumed, that this will be fine for all types of joints:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Vector2 aA = getJoint().getAnchorA();
  2. Vector2 aB = getJoint().getAnchorB();
  3.  
  4. if (epsilonEquals(aA, aB, EQUALITY_EPSILON)) {
  5.         drawHourGlassInAnchorA();
  6. } else {
  7.         drawLineFrom_AnchorA_to_AnchorB();
  8. }
  9.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


Apparently this is not a good approach for RevolutionJoints... Crap. I can't afford to waste any more time on it right now. I think that RopeJoint and MouseJoint will be fine, and RevolutionJoint will stay broken for now... Right now I just do not know how to fix it.
Last edited by nazgee on Fri Jan 04, 2013 12:20 pm, edited 1 time in total.
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: Box2d debug draw - working and simple to use

Postby RealMayo » Fri Jan 04, 2013 4:38 am

No worries, we appreciate all of your effort :)
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: Box2d debug draw - working and simple to use

Postby Mathew » Wed May 15, 2013 6:50 pm

There is little bug with chain shapes, it draws line between first and last point of chain shape.

While using chain shape generated by ChainShape class createChain(Vector2 vertices[])

Create a chain with isolated end vertices.
User avatar
Mathew
 
Posts: 1073
Joined: Sun Jul 31, 2011 2:49 pm
Location: Tarnów, Poland

PreviousNext

Return to Features

Who is online

Users browsing this forum: No registered users and 4 guests