Menu

#41 More bad bullet collision detections

1.2.1
closed
7
2012-10-10
2006-10-22
No

This bug is related to 1580467, but not an exact
duplicate. I've been running some tests where my robot
sits still and fires directly at a bunch of
SittingDucks. The bullets are all fire power 1, and
yet sometimes I get a bunch of BulletHitBulletEvents!
Here is an example of the x,y coordinates of two
bullets that ran into each other:

84.41021743200135,747.7225711862856
220.88222650173248,573.8939465571092

These are not close together at all. I tried to figure
out what was going on in the new intersects() method of
BulletPeer, but other than first line where line
intersection is calculated I can't tell what else is
being done. Seems like something is not right, but it
is not very frequent depending on the layout of the
battle.

You should also be able to see this problem if you look
at bullet collisions in a battle with enough rounds
between TrackFire and SittingDuck. However, while I
noticed that TrackFire loses to SittingDuck on occasion
because its bullets mysteriously disappear, it didn't
look like TrackFire ever received
BulletHitBulletEvents.

Discussion

  • Flemming N. Larsen

    Logged In: YES
    user_id=1249353

    This has not been put in any releases, and rolled back as
    most people did not want to real collision detection.

    This entry is marked as invalid, as the code was never put
    in any real release, even though it was a bug. ;-)

     
  • Matt Jacobsen

    Matt Jacobsen - 2006-10-24

    Logged In: YES
    user_id=1626816

    Turns out this bug still in 1.1.5, but that's because it's a bug with java's own Line2D.intersectsLine()
    method. Here is a reference to java's site: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457965

    The problem is that intersectsLine() sometimes returns the wrong answer for colinear line segments. This is
    not just for line segments that are right on top of each other. It also applies to segments that are in
    completely different areas of the map but happen to be on the same line. If you create a test program
    creating Line2Ds from the points in this bug description you will be able to see the problem. This is not
    too common because it is subject to floating point roundoff coincidence. I encountered the bug in about 5
    out of 100 rounds against 6 SittingDucks. I lost those rounds because all my bullets were destroyed and the
    round timed out eventually.

    The java site recommends a couple ways to work around this. I tried testing to make sure that the slope of
    the two lines was different in order to satisfy a collision, but this is still subject to slight floating
    point roundoff (I only saw the bug in 1 out of 1000 rounds against 6 SittingDucks). You could instead check
    to make sure that the x and y coordinates of the two line segments overlap. The number of conditions in the
    latter approach is annoying, but it would only need to be executed if intersectsLine() returns true, similar
    to the endpoint tests that are already there.

     
  • Flemming N. Larsen

    Logged In: YES
    user_id=1249353

    Doh. You are right. I somehow got the impression that the Line2D.intersectsLine() bug was corrected in Java 5.

    I will look into this issue ASAP.

     
  • Flemming N. Larsen

    Logged In: YES
    user_id=1249353

    I have now made a workaround for this Java 5 bug, and put it in the CVS. The fix is ready for the next release.

    The workaround checks if lineIntersect() returns true. If this is the case the slope for each line is compared to
    each other. If the slopes are equal, then a boundary check is made against the x coordinates. I have tested this
    against the reference code at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457965 + my own test stubs, and
    it seems to work now.

     
  • Flemming N. Larsen

    Logged In: YES
    user_id=1249353

    Fixed in 1.2 Beta

     
  • Matt Jacobsen

    Matt Jacobsen - 2006-11-16

    Logged In: YES
    user_id=1626816
    Originator: YES

    I've been using 1.2 for a little while now, and it appears that most if not all bullet collisions are gone. I think the current fix for this bug does a test for bullet line intersections and then checks to see if the slopes are equal. If they are, then a collision is reported. However, this appears to be the only way to get a collision. The code should return true if there is a line intersection and the lines do not have equal slope.

     
  • Flemming N. Larsen

    Logged In: YES
    user_id=1249353
    Originator: NO

    I have now replaced the bullet collision algorithm in the intersect() method so it uses the 2D line intersection algorithm by Paul Bourke. This avoids the Java 5 bug with Line2D.intersect().

    This fix will be available in the comming 1.2.1 release.

     
  • Flemming N. Larsen

    Logged In: YES
    user_id=1249353
    Originator: NO

    I have now replaced the bullet collision algorithm in the intersect() method so it uses the 2D line intersection algorithm by Paul Bourke. This avoids the Java 5 bug with Line2D.intersect().

    This fix will be available in the comming 1.2.1 release.

     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 30 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.