From 94ccd3f0145ef9a9a9293514074fdda8b56cdc22 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 10 Nov 2007 15:03:28 +0100 Subject: [PATCH] d3dx8: Implement the C++ stuff of the D3DXPLANE structure. --- include/d3dx8math.h | 14 ++++++++++++ include/d3dx8math.inl | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/d3dx8math.h b/include/d3dx8math.h index f35bed85c8..0c60b66f50 100644 --- a/include/d3dx8math.h +++ b/include/d3dx8math.h @@ -201,6 +201,20 @@ typedef struct D3DXQUATERNION typedef struct D3DXPLANE { +#ifdef __cplusplus + D3DXPLANE(); + D3DXPLANE(CONST FLOAT *pf); + D3DXPLANE(FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd); + + operator FLOAT* (); + operator CONST FLOAT* () const; + + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + BOOL operator == (CONST D3DXPLANE&) const; + BOOL operator != (CONST D3DXPLANE&) const; +#endif /* __cplusplus */ FLOAT a, b, c, d; } D3DXPLANE, *LPD3DXPLANE; diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl index bce60702b4..c04c9d1162 100644 --- a/include/d3dx8math.inl +++ b/include/d3dx8math.inl @@ -639,6 +639,57 @@ inline BOOL D3DXQUATERNION::operator != (CONST D3DXQUATERNION& quat) const return x != quat.x || y != quat.y || z != quat.z || w != quat.w; } +inline D3DXPLANE::D3DXPLANE() +{ +} + +inline D3DXPLANE::D3DXPLANE(CONST FLOAT *pf) +{ + if(!pf) return; + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +inline D3DXPLANE::D3DXPLANE(FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + +inline D3DXPLANE::operator FLOAT* () +{ + return (FLOAT*)&a; +} + +inline D3DXPLANE::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&a; +} + +inline D3DXPLANE D3DXPLANE::operator + () const +{ + return *this; +} + +inline D3DXPLANE D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + +inline BOOL D3DXPLANE::operator == (CONST D3DXPLANE& pl) const +{ + return a == pl.a && b == pl.b && c == pl.c && d == pl.d; +} + +inline BOOL D3DXPLANE::operator != (CONST D3DXPLANE& pl) const +{ + return a != pl.a || b != pl.b || c != pl.c || d != pl.d; +} + #endif /* __cplusplus */ /*_______________D3DXCOLOR_____________________*/