icculus / Serious-Engine

An open source version of a game engine developed by Croteam for the classic Serious Sam games.
GNU General Public License v2.0
164 stars 21 forks source link

Collision glitch #65

Open Elinvention opened 8 years ago

Elinvention commented 8 years ago

I had fun enjoying Serious Sam The Second Encounter until I reached the level where there is a rotating floor. When the floor begins its rotation, Sam sinks into floor and dies.

This assertion fails and seems to be related:

Assertion failure at CheckTriangleAgainstEdges (/home/elia/Progetti/Serious-Engine/Sources/Engine/Brushes/BrushTriangularize.cpp:530), triggered 1 time:
  'itbed->bed_pbvxVertex0 != tr_pbedBottom->bed_pbvxVertex0 ||itbed->bed_pbvxVertex1 != tr_pbedBottom->bed_pbvxVertex1'
lukassup commented 8 years ago

I have experienced a quite similar issue while walking up the ramps in the first level of TSE (in the room where you get the invulnerability powerup and shoot skeletons). The camera rolls around and it is impossible to continue playing. It does not throw any exceptions however.

DanielGibson commented 8 years ago

@lukassup this: https://github.com/rcgordon/Serious-Engine/issues/48 ? Not sure if this issue is related, but could be.

lukassup commented 8 years ago

@DanielGibson looks really similar to what I experience, probably the same issue. EDIT: I wasn't using the flag mentioned in the title. I have built the engine for 64bit linux with: $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug .. $ ninja

ptitSeb commented 7 years ago

Does anyone knows if this glitch (in "The Pit") also happens with upstream build on Windows? I does happens for me on x86/Linux and on arm/Linux.

ptitSeb commented 7 years ago

I tested on Windows, with a freshly built OpenSource version from upstream (built with VS 2015), and the bug is also there. So it's not a Linux only issue.

ptitSeb commented 7 years ago

But the same save state on the Steam version works flawlessly.

ptitSeb commented 7 years ago

In case someone is still interested in this: I have fixed the issue. tl;dr it was Sin/Cos function not always behaving properly. The fix is on my github repo (https://github.com/ptitSeb/Serious-Engine/commit/dce391583cf3a0379fca1b317abb06cd49eae71b) and on a Pull Request here.

Long story: I debugged, using many printf (well, the Windows/VS equivalent of it) to try pinpoint the wrong value when Sam goes through the tilting floor. Eventually, I found out that a rotation matrix was wrong. Issue was inside void CSimpleProjection3D_DOUBLE::ProjectMapping(const CMappingDefinition &mdObject, const DOUBLEplane3D &plObject, CMappingDefinition &mdView) const Using some more printf, I was getting (from the Prepare method): for a rotation matrix using Angle3D {90,-3.18055e-15,8.125} if I transform FLOAT3D(0,1,0) I get (0, 0.989962, 0.141333) which seems correct. But for the next step (of the rotation floor), I had Angle3D {90,-3.81667e-14,9.37499} so very similar angles, the same FLOAT3D(0,1,0) got transformed to (0.986643, 0, 0.162895) wich is all wrong (and make Sam fall!). The rotation matrix calculation seems good. But the Sin and Cos functions themselves.. They have a complicated prologue to get the quadran and so, and then call regular sin function (probably, at first, it was a single SIN table that was called, or something similar). Commenting all this and simply call regular sin/cos function fixes the issue...

The fix works on Linux and on Windows builds.

DanielGibson commented 7 years ago

Awesome, thanks so much for debugging this (and also your other improvements)!