Darthfett / A-Priori-Physics-System

A side-scroller game based upon Mega Man X, with a priori collision detection, and objects being represented as a sequence of connected points.
3 stars 0 forks source link

Remove duplicate calls to physics.ParabolaLineCollision #30

Closed Darthfett closed 12 years ago

Darthfett commented 12 years ago

This currently happens with shapes with more than just a single line, which share points.

This would effectively change the running time of the algorithm from depending on an entity's 'number of lines' to 'number of points', by forcing entities' shape structures to be a sequential list of points, rather than an unordered list of lines.

I haven't seen any use case for having entities be represented by lines which are not always connected together.

Darthfett commented 12 years ago

WIP d657727 is a first pass on converting the algorithms. The game is compiling, but collision is acting strangely.

Darthfett commented 12 years ago

Collision is VERY strange indeed. Collision sub-issues:

  1. With the new WIP version of the collision detector, some collisions look exactly right, others are never ever seen.
  2. There is also an issue with time somehow being off when doing collisions with the 'box' Level, being way too late. This is NOT broken if you disable 'enclosed' for the 'box' Level, which gets rid of the left line. This makes absolutely no sense.
  3. Additionally, there seems to be some issue with BOTH algorithms when I try to avoid duplicate collision calculation. For example, if I calculate between object A and B, then between B and A, everything seems to work okay. If I remove this second call, collisions after the first collision never seem to happen. Very strange.
Darthfett commented 12 years ago

In cd429a3, there is some debugging output for the new algorithm.

After removing all duplicate calls to ParabolaLineCollision, here are the results of what is happening for a player defined as a 3-sided circle, and randomly generated lines for the ground at 64px intervals:

New algorithm: http://pastebin.com/q9LEsHnw Old algorithm: http://pastebin.com/WraDgAX3

What's interesting to note is that the values are identical for detecting collisions of the ground relative to the player. However, even more interesting is the collisions of the player relative to the ground. It is clearly wrong, but I can see what is happening: Each iteration is somehow adding '30' to the x and '350' to the y of the player's position. This is exactly the values for the player's position. The ground position is at (0, 0), and this is why the issue is not seen in both sides.