Box2D Java

Yeah the one remaining group of bugs in my program are a series of cases which occur in my dynamic breakage code which generates shapes that either have edges that are too short, or complex shapes which I believe mostly get handled correctly (just their area calculation becomes incorrect and could be a negative value), and there are possibly even more issues with it.

Problem is, I can hardly debug it because running box2d in debug mode causes a 10 to 100-fold decrease in performance and before I can reproduce any of these issues it slows down a LOT to the point where it is very difficult to do anything (sub 1 frame per second). One good thing is that I do use a fixed timestep so the behavior ought to be identical. I just gotta sit down one day and patiently smash things together when running in debug mode.
BTW. wouldn't it be a good idea to move discation to the sourceforge forums that came with the jBox2D project?
I think it's better to stay here. Most questions are generic enough that it is experience with the engine that matters, rather than the specific language.
But JBox2D users, you really don't have to stick in this one thread. That would be a bit limiting.
Unless anybody objects, I suggest that the following classes and methods would be made public:
public class org.jbox2d.util.nonconvex.Triangle

For org.jbox2d.util.nonconvex.Polygon:
public boolean isCCW()
public Polygon add(Triangle t)

I'm using those for slightly customized convex decomposition code. With the edge chains I only use the decomposition results for rendering, so I modified the methods to ease the restrictions that are needed for Box2D usage. And yes, they're easy to change, but I don't see any reason why they couldn't be public, as they're utilities after all. 🙂 Thanks!
mh114 wrote:
Unless anybody objects, I suggest that the following classes and methods would be made public:
public class org.jbox2d.util.nonconvex.Triangle

For org.jbox2d.util.nonconvex.Polygon:
public boolean isCCW()
public Polygon add(Triangle t)

I'm using those for slightly customized convex decomposition code. With the edge chains I only use the decomposition results for rendering, so I modified the methods to ease the restrictions that are needed for Box2D usage. And yes, they're easy to change, but I don't see any reason why they couldn't be public, as they're utilities after all. 🙂 Thanks!

I have no problem with that, I'll put it into the next update.

Be aware, though, that the "add" method only merges the poly and triangle if they have two vertices that touch, and in particular it does not create a union; if I make it public, I may refactor it to change the name (and make sure the Javadoc is crystal clear on that point) so that there's no confusion.
Hi everyone,
I'm just about to implement a laser weapon so I started scanning the forum about ray casting. Apart from the [AS3 contribution] by BorisTheBrave, the way described [here] seems to be the way to go.
Although the World.query(..) method is probably good enough for me already I was wondering if someone has already implemented Shape.TestSegment(...) in Java (of which currently only the out-commented signature can be found in the Java port svn repository).
Boing wrote:
Hi everyone,
I'm just about to implement a laser weapon so I started scanning the forum about ray casting. Apart from the [AS3 contribution] by BorisTheBrave, the way described [here] seems to be the way to go.
Although the World.query(..) method is probably good enough for me already I was wondering if someone has already implemented Shape.TestSegment(...) in Java (of which currently only the out-commented signature can be found in the Java port svn repository).

Er...hehe. My bad.

I put those bits of code aside "for the moment" while updating to 2.0.1 because they're not entirely straightforward to translate (a float pointer is passed as a parameter to hold one of the results, so I have to create a RaycastResult holder class to do something similar in Java), and I completely and utterly forgot about going back to finish them up.

I'll try to do this before I do a full update with the things that have changed since 2.0.1, but it might be a couple weeks before I can get to it (I just took on a new contract this week so I'm pretty busy - gotta pay the bills once in a while!). I'll almost certainly port BorisTheBrave's raycasting contributions as well, since they make things very usable and quick.

That said, if anyone has already brought the code over, I'd happily include a patch, as long as it works.
Sounds great - I'm really looking forward to trying out the stuff.
So long I wish you all the best for your other projects!
Hi, i just started using your port for a little game I'm writing just for fun.
I'd like to help if i can, perhaps i can port that code for raycasting?
freakypie wrote:
Hi, i just started using your port for a little game I'm writing just for fun.
I'd like to help if i can, perhaps i can port that code for raycasting?

If you'd like to give it a go, feel free - you'll need to implement the testSegment methods for the shapes as well, and figure out a decent approach to holding the results (the AS3 port probably does this the "right" way, though I haven't checked). I'm happy to take contributed code in, esp. since at the moment I have very little time to port myself (at least for the next few weeks).

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