Initial import of Red Planet v4.10 Win32 source
Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+167
@@ -0,0 +1,167 @@
|
||||
#include "munga.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "angle.h"
|
||||
|
||||
#if defined(USE_SIGNATURE)
|
||||
int Is_Signature_Bad(const volatile Radian *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
Scalar Radian::Normalize(Scalar Value)
|
||||
{
|
||||
Scalar temp;
|
||||
|
||||
temp = fmod(Value,TWO_PI);
|
||||
if (temp > PI) {
|
||||
temp -= TWO_PI;
|
||||
}
|
||||
else if (temp < -PI) {
|
||||
temp += TWO_PI;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Radian&
|
||||
Radian::Normalize()
|
||||
{
|
||||
Check(this);
|
||||
angle = fmod(angle,TWO_PI);
|
||||
if (angle > PI) {
|
||||
angle -= TWO_PI;
|
||||
}
|
||||
else if (angle < -PI) {
|
||||
angle += TWO_PI;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Radian&
|
||||
Radian::Lerp(const Radian &a,const Radian &b,Scalar t)
|
||||
{
|
||||
Scalar a1,a2;
|
||||
|
||||
Check_Pointer(this);
|
||||
Check(&a);
|
||||
Check(&b);
|
||||
a1 = Radian::Normalize(a.angle);
|
||||
a2 = Radian::Normalize(b.angle);
|
||||
if (a2-a1 > PI) {
|
||||
a2 -= TWO_PI;
|
||||
}
|
||||
else if (a2-a1 < -PI) {
|
||||
a2 += TWO_PI;
|
||||
}
|
||||
angle = ::Lerp(a1, a2, t);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
std::ostream& operator<<(std::ostream& stream, const Radian& radian)
|
||||
{
|
||||
return stream << radian.angle << " rad";
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Logical Radian::TestInstance() const
|
||||
{
|
||||
return angle >= -100.0f && angle <= 100.0f;
|
||||
}
|
||||
|
||||
#if defined(USE_SIGNATURE)
|
||||
int Is_Signature_Bad(const volatile Degree *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
std::ostream& operator<<(std::ostream& stream, const Degree& degree)
|
||||
{
|
||||
return stream << degree.angle << " deg";
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Logical
|
||||
Degree::TestInstance() const
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
#if defined(USE_SIGNATURE)
|
||||
int
|
||||
Is_Signature_Bad(const volatile SinCosPair *)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
SinCosPair&
|
||||
SinCosPair::operator=(const Radian &radian)
|
||||
{
|
||||
Check_Pointer(this);
|
||||
Check(&radian);
|
||||
|
||||
cosine = cos(radian);
|
||||
sine = sin(radian);
|
||||
#if defined(__BCPLUSPLUS__)
|
||||
cosine = cos(radian); // STUPID FUCKING BORLAND LIBRARY HACK!!!!!
|
||||
#endif
|
||||
Check(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
std::ostream& operator<<(std::ostream& stream, const SinCosPair& pair)
|
||||
{
|
||||
return stream << '{' << pair.cosine << ',' << pair.sine << '}';
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Logical SinCosPair::TestInstance() const
|
||||
{
|
||||
Scalar t = sine*sine + cosine*cosine;
|
||||
if (!Close_Enough(t,1.0f,0.001f))
|
||||
{
|
||||
Dump(*this);
|
||||
Dump(t);
|
||||
return False;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
#if defined(TEST_CLASS)
|
||||
# include "angle.tcp"
|
||||
#endif
|
||||
Reference in New Issue
Block a user