mirror of
https://github.com/ENSL/NS.git
synced 2024-12-02 01:02:09 +00:00
36c78acbce
* handle particles project VC++ compilation errors with MVCS and project property changes - retarget to v142 platformtoolset - remove explicit windows SDK version; use latest by default - remove settings that are otherwise default values in project or are best determined by solution * attempt to handle clang++ issues regarding unsupported c++11 features * reset file changes to particledefs.h * removing PARTICLEDLL_API definition and replacing usage with extern "C" block statements * add g++ compiler option to specify c++11 standard * attempt to resolve forward enum errors by adding std to base cflags * replacing deprecated libstdc++ and removing -lstdc++ flag, updating MacOSX10 sdk version * small refactor to Makefiles, and add libstdc++ back to linux build * remove added type to enum * reset makefile changes that may be causing unexpected linux build failures * refactoring std=c++11 declarations in Makefile to mitgate linux build failing * ensure std is set for hl_cdll make * attempt to define a standard library to resolve vector initialization_list constructor issue * attempt to update MacOS sdk, set minimum os to be 10.7, and include export in travis ci to define deployment target
143 lines
2.2 KiB
C++
143 lines
2.2 KiB
C++
// p_vector.h - yet another vector class.
|
|
//
|
|
// Copyright 1997 by Jonathan P. Leech
|
|
// Modifications Copyright 1997-1999 by David K. McAllister
|
|
//
|
|
// A simple 3D float vector class for internal use by the particle systems.
|
|
|
|
#ifndef particle_vector_h
|
|
#define particle_vector_h
|
|
|
|
#if _MSC_VER >= 1900 // C++11 Compatible for Visual Studio 2015 and later.
|
|
#include <cmath>
|
|
#else
|
|
#include "math.h"
|
|
#endif
|
|
|
|
#ifndef M_PI
|
|
#define M_PI 3.1415926535897932384626433f
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
#define drand48() (((float) rand())/((float) RAND_MAX))
|
|
#define srand48(x) srand(x)
|
|
|
|
#endif
|
|
|
|
class pVector
|
|
{
|
|
public:
|
|
float x, y, z;
|
|
|
|
inline pVector(float ax, float ay, float az) : x(ax), y(ay), z(az)
|
|
{
|
|
//x = ax; y = ay; z = az;
|
|
}
|
|
|
|
inline pVector() {}
|
|
|
|
inline float length() const
|
|
{
|
|
return sqrtf(x*x+y*y+z*z);
|
|
}
|
|
|
|
inline float length2() const
|
|
{
|
|
return (x*x+y*y+z*z);
|
|
}
|
|
|
|
inline float normalize()
|
|
{
|
|
float onel = 1.0f / sqrtf(x*x+y*y+z*z);
|
|
x *= onel;
|
|
y *= onel;
|
|
z *= onel;
|
|
|
|
return onel;
|
|
}
|
|
|
|
inline float operator*(const pVector &a) const
|
|
{
|
|
return x*a.x + y*a.y + z*a.z;
|
|
}
|
|
|
|
inline pVector operator*(const float s) const
|
|
{
|
|
return pVector(x*s, y*s, z*s);
|
|
}
|
|
|
|
inline pVector operator/(const float s) const
|
|
{
|
|
float invs = 1.0f / s;
|
|
return pVector(x*invs, y*invs, z*invs);
|
|
}
|
|
|
|
inline pVector operator+(const pVector& a) const
|
|
{
|
|
return pVector(x+a.x, y+a.y, z+a.z);
|
|
}
|
|
|
|
inline pVector operator-(const pVector& a) const
|
|
{
|
|
return pVector(x-a.x, y-a.y, z-a.z);
|
|
}
|
|
|
|
inline pVector operator-()
|
|
{
|
|
x = -x;
|
|
y = -y;
|
|
z = -z;
|
|
return *this;
|
|
}
|
|
|
|
inline pVector& operator+=(const pVector& a)
|
|
{
|
|
x += a.x;
|
|
y += a.y;
|
|
z += a.z;
|
|
return *this;
|
|
}
|
|
|
|
inline pVector& operator-=(const pVector& a)
|
|
{
|
|
x -= a.x;
|
|
y -= a.y;
|
|
z -= a.z;
|
|
return *this;
|
|
}
|
|
|
|
inline pVector& operator*=(const float a)
|
|
{
|
|
x *= a;
|
|
y *= a;
|
|
z *= a;
|
|
return *this;
|
|
}
|
|
|
|
inline pVector& operator/=(const float a)
|
|
{
|
|
float b = 1.0f / a;
|
|
x *= b;
|
|
y *= b;
|
|
z *= b;
|
|
return *this;
|
|
}
|
|
|
|
inline pVector& operator=(const pVector& a)
|
|
{
|
|
x = a.x;
|
|
y = a.y;
|
|
z = a.z;
|
|
return *this;
|
|
}
|
|
|
|
inline pVector operator^(const pVector& b) const
|
|
{
|
|
return pVector(
|
|
y*b.z-z*b.y,
|
|
z*b.x-x*b.z,
|
|
x*b.y-y*b.x);
|
|
}
|
|
};
|
|
|
|
#endif
|