Collisions WTF?!

BlitzMax Forums/MiniB3D Module/Collisions WTF?!

Sledge(Posted 2009) [#1]
I've probably missed something obvious here but it's got me scratching my head at the moment. Here's some code to illustrate the issue I'm having:



Now if you keep your eye on the output, you'll notice that the fist set of results is 'off': It reports CollisionX wrongly as 0.0 when it is 0.5 and, similarly, the difference between EntityZ and CollisionZ is also different to all subsequent results. I'm prototyping a project where getting these values wrong even once is fatal, so this is a bit of a spanner in the works. Anyone want to point out what idiot thing I'm doing wrong?

Results
=======
Difference: 0.899999440
Collision X: 0.000000000

Difference: 1.89999938
Collision X: 0.500000000

Difference: 1.89999938
Collision X: 0.500000000

Difference: 1.89999938
Collision X: 0.500000000

Difference: 1.89999938
Collision X: 0.500000000...



D4NM4N(Posted 2009) [#2]
Im not sure how the collision works in mb3d, but if you are inside a flipped mesh, is that what is causing a collision? the fact you are in the middlle of it.

try flipping it the right way and colliding against the outside :/


Sledge(Posted 2009) [#3]
The flipped cube is there as a stand-in for a .b3d mesh which, in my actual project, exhibits the same sort of anomalies.


simonh(Posted 2009) [#4]
Yes, it's a bug, well spotted.

To fix, in TCollision.bmx, change line 197:

If C_CollisionResponse(c_col_info,c_coll,response)=False Then Exit

To this:

If x=False Then Exit

Now add the following line directly after line 164:

Local x=C_CollisionResponse(c_col_info,c_coll,response)

The bug was due to the C_CollisionResponse function being called too late, so that the CollisionX/Y/Z etc functions were always one call behind.


Sledge(Posted 2009) [#5]
Sweet! Thanks for the quick fix -- I guess iMiniB3D is identical and can be fixed in the same way, syntax aside?


simonh(Posted 2009) [#6]
Yes, that's correct.


D4NM4N(Posted 2009) [#7]
lol open source is awesome :D


jtfrench(Posted 2011) [#8]
I don't completely understand what transpired in this past conversation, but it makes me happy to see how awesome the community out here can put together –— and support —— some awesome stuff.

Props to open source , simonh & sledge