ZDoom / gzdoom

GZDoom is a feature centric port for all Doom engine games, based on ZDoom, adding an OpenGL renderer and powerful scripting capabilities
http://zdoom.org
GNU General Public License v3.0
2.52k stars 546 forks source link

[BUG] Quaternion Inverse/Conjugate results in JIT error #1903

Open OrdinaryMagician opened 1 year ago

OrdinaryMagician commented 1 year ago

GZDoom version

4.10.0

Which game are you running with GZDoom?

Doom 2

What Operating System are you using?

Linux x86_64

Please describe your specific OS version

No response

Relevant hardware info

No response

Have you checked that no other similar issue already exists?

A clear and concise description of what the bug is.

Calling Inverse() or Conjugate() on any quaternion will result in a JIT error mentioning an "unexpected register type for self pointer".

A simple example is provided here: zscript.txt

Steps to reproduce the behaviour.

  1. Load example, go into any map
  2. Summon "TestMii"
  3. An error message will appear in the console

Your configuration

No response

Provide a Log

No response

CandiceJoy commented 1 year ago

I can't reproduce this, was this fixed?

MajorCooke commented 1 year ago

Something to ask @Gutawer.

OrdinaryMagician commented 1 year ago

I'm still seeing the error, so it wasn't.

CandiceJoy commented 1 year ago

I'm still seeing the error, so it wasn't.

Dunno, I even added a print statement in it so I knew it was getting called and it is, just...no error.

OrdinaryMagician commented 1 year ago

Could be OS-specific, then.

CandiceJoy commented 1 year ago

Yeah. Surely by now you know I'm on Mac :P

OrdinaryMagician commented 1 year ago

And I'm on Linux. This might be a GCC quirk (again...)

Gutawer commented 1 year ago

I'm on Linux and use Clang. It's probable that this just coincidentally worked on my machine but I'm not really in a state where I'm going to look into a fix anytime soon. In the meantime it's worth noting that Conjugate is just the same as q.xyz = -q.xyz;, and you probably don't need Inverse.

OrdinaryMagician commented 1 year ago

I do have an use case for Inverse, though. I need to "undo" a rotation on a vector so I can make BobWeapon3D move the weapon in world space instead of view space.

Gutawer commented 1 year ago

Conjugate does that and is computationally faster. This maybe needs to be cleared up a bit but it's the normal naming convention - Inverse is the true inverse function which works on every quaternion, no matter its norm. Conjugate is extremely similar to Inverse and it is equal to Inverse on unit quaternions (i.e. every quaternion you'll ever use for rotation), but fails to provide an inverse on non-unit quaterions. So 99% of use-cases would better served by Conjugate.

OrdinaryMagician commented 1 year ago

I see.

CandiceJoy commented 1 year ago

PR is #1978