Palm-Studios / sh3redux

SILENT HILL 3 Engine Remake in OpenGL and C++
GNU General Public License v3.0
162 stars 16 forks source link

Add Angle struct #115

Closed z33ky closed 6 years ago

z33ky commented 7 years ago

This will make it explicit when we expect to deal with angles in degrees or radians. The internal representation is in radians, since maths functions usually expect this and thus we hopefully need less conversions.

I'm not certain if Angle::Zero() and Angle::Turn() are useful. Because equality-comparing floating-point values is tricky, I've opted into only providing an IsExactlyZero method. If we ever need to check the equality of angles in the future we can make up our minds on how to implement that.

As we stumble upon them we can add overloads for certain functions, e.g. std::min or std::sin, so we can just say std::min(angleA, angleB) instead of Angle::FromRadians(angleA.AsRadians(), angleB.AsRadians()).

Quaker762 commented 7 years ago

Looks good.

Did you want me to add this into the camera (in regards to the FOV etc) after we merge this?

z33ky commented 7 years ago

Yes.

Quaker762 commented 6 years ago

@z33ky I can't seem to compile with this. I'm getting a whole lot of

undefined reference toangle::angle(float)'|`

undefined reference toangle::angle(double)'|`

The file has been added to project and is being compiled.

z33ky commented 6 years ago

Added angle.cpp to the Code::Blocks project.

Have you added any code using angle?

Quaker762 commented 6 years ago

It still doesn't seem to be working. Hrrm

Have you added any code using angle?

Nope, this is just a straight recompile with the angle class added. Perhaps there's a bug (again.....) with my version of g++ in regards to using extern with templates??

Here's the build log:

https://pastebin.com/Drz7A81c

EDIT: Just downloaded and installed MinGW with g++ 7.1.0, it's still throwing the same linker error.

z33ky commented 6 years ago

What's the output of nm obj\Debug\i686\source\SH3\angle.o|c++filt?

z33ky commented 6 years ago

This seems to be a known issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728 I'm guessing that the empty body has the same effect as = default; here. Try removing the extern template lines from angle.hpp. If that works I'll check the compiler version to conditionally use this feature or not. It's not necessary, just a compile time improvement.

Quaker762 commented 6 years ago

Try removing the extern template lines from angle.hpp. If that works I'll check the compiler version to conditionally use this feature or not. It's not necessary, just a compile time improvement.

This seems to have fixed it. The version of mingw g++ I have is 7.1.0 (not sure what the latest is on Linux). I should have a Linux box soon though.

z33ky commented 6 years ago

Alright, try this.