diff --git a/code/PolyTools.h b/code/PolyTools.h index 4f807eb90..9a3a81744 100644 --- a/code/PolyTools.h +++ b/code/PolyTools.h @@ -178,8 +178,8 @@ inline bool IsCCW(T* in, size_t npoints) { * @note The data arrays must have storage for at least num+2 elements. Using * this method is much faster than the 'other' NewellNormal() */ -template -inline void NewellNormal (aiVector3D& out, int num, float* x, float* y, float* z) +template +inline void NewellNormal (aiVector3t& out, int num, TReal* x, TReal* y, TReal* z) { // Duplicate the first two vertices at the end x[(num+0)*ofs_x] = x[0]; @@ -191,11 +191,11 @@ inline void NewellNormal (aiVector3D& out, int num, float* x, float* y, float* z z[(num+0)*ofs_z] = z[0]; z[(num+1)*ofs_z] = z[ofs_z]; - float sum_xy = 0.0, sum_yz = 0.0, sum_zx = 0.0; + TReal sum_xy = 0.0, sum_yz = 0.0, sum_zx = 0.0; - float *xptr = x +ofs_x, *xlow = x, *xhigh = x + ofs_x*2; - float *yptr = y +ofs_y, *ylow = y, *yhigh = y + ofs_y*2; - float *zptr = z +ofs_z, *zlow = z, *zhigh = z + ofs_z*2; + TReal *xptr = x +ofs_x, *xlow = x, *xhigh = x + ofs_x*2; + TReal *yptr = y +ofs_y, *ylow = y, *yhigh = y + ofs_y*2; + TReal *zptr = z +ofs_z, *zlow = z, *zhigh = z + ofs_z*2; for (int tmp=0; tmp < num; tmp++) { sum_xy += (*xptr) * ( (*yhigh) - (*ylow) ); @@ -214,7 +214,7 @@ inline void NewellNormal (aiVector3D& out, int num, float* x, float* y, float* z zlow += ofs_z; zhigh += ofs_z; } - out = aiVector3D(sum_yz,sum_zx,sum_xy); + out = aiVector3t(sum_yz,sum_zx,sum_xy); } } // ! Assimp diff --git a/code/ProcessHelper.h b/code/ProcessHelper.h index b0be855ed..e25dbf782 100644 --- a/code/ProcessHelper.h +++ b/code/ProcessHelper.h @@ -55,45 +55,56 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace std { // std::min for aiVector3D - inline ::aiVector3D min (const ::aiVector3D& a, const ::aiVector3D& b) { - return ::aiVector3D (min(a.x,b.x),min(a.y,b.y),min(a.z,b.z)); + template + inline ::aiVector3t min (const ::aiVector3t& a, const ::aiVector3t& b) { + return ::aiVector3t (min(a.x,b.x),min(a.y,b.y),min(a.z,b.z)); } - // std::max for aiVector3D - inline ::aiVector3D max (const ::aiVector3D& a, const ::aiVector3D& b) { - return ::aiVector3D (max(a.x,b.x),max(a.y,b.y),max(a.z,b.z)); + // std::max for aiVector3t + template + inline ::aiVector3t max (const ::aiVector3t& a, const ::aiVector3t& b) { + return ::aiVector3t (max(a.x,b.x),max(a.y,b.y),max(a.z,b.z)); } - // std::min for aiVector2D - inline ::aiVector2D min (const ::aiVector2D& a, const ::aiVector2D& b) { - return ::aiVector2D (min(a.x,b.x),min(a.y,b.y)); + // std::min for aiVector2t + template + inline ::aiVector2t min (const ::aiVector2t& a, const ::aiVector2t& b) { + return ::aiVector2t (min(a.x,b.x),min(a.y,b.y)); } - // std::max for aiVector2D - inline ::aiVector2D max (const ::aiVector2D& a, const ::aiVector2D& b) { - return ::aiVector2D (max(a.x,b.x),max(a.y,b.y)); + // std::max for aiVector2t + template + inline ::aiVector2t max (const ::aiVector2t& a, const ::aiVector2t& b) { + return ::aiVector2t (max(a.x,b.x),max(a.y,b.y)); } // std::min for aiColor4D - inline ::aiColor4D min (const ::aiColor4D& a, const ::aiColor4D& b) { - return ::aiColor4D (min(a.r,b.r),min(a.g,b.g),min(a.b,b.b),min(a.a,b.a)); + template + inline ::aiColor4t min (const ::aiColor4t& a, const ::aiColor4t& b) { + return ::aiColor4t (min(a.r,b.r),min(a.g,b.g),min(a.b,b.b),min(a.a,b.a)); } // std::max for aiColor4D - inline ::aiColor4D max (const ::aiColor4D& a, const ::aiColor4D& b) { - return ::aiColor4D (max(a.r,b.r),max(a.g,b.g),max(a.b,b.b),max(a.a,b.a)); + template + inline ::aiColor4t max (const ::aiColor4t& a, const ::aiColor4t& b) { + return ::aiColor4t (max(a.r,b.r),max(a.g,b.g),max(a.b,b.b),max(a.a,b.a)); } - // std::min for aiQuaternion - inline ::aiQuaternion min (const ::aiQuaternion& a, const ::aiQuaternion& b) { - return ::aiQuaternion (min(a.w,b.w),min(a.x,b.x),min(a.y,b.y),min(a.z,b.z)); + + // std::min for aiQuaterniont + template + inline ::aiQuaterniont min (const ::aiQuaterniont& a, const ::aiQuaterniont& b) { + return ::aiQuaterniont (min(a.w,b.w),min(a.x,b.x),min(a.y,b.y),min(a.z,b.z)); } - // std::max for aiQuaternion - inline ::aiQuaternion max (const ::aiQuaternion& a, const ::aiQuaternion& b) { - return ::aiQuaternion (max(a.w,b.w),max(a.x,b.x),max(a.y,b.y),max(a.z,b.z)); + // std::max for aiQuaterniont + template + inline ::aiQuaterniont max (const ::aiQuaterniont& a, const ::aiQuaterniont& b) { + return ::aiQuaterniont (max(a.w,b.w),max(a.x,b.x),max(a.y,b.y),max(a.z,b.z)); } + + // std::min for aiVectorKey inline ::aiVectorKey min (const ::aiVectorKey& a, const ::aiVectorKey& b) { return ::aiVectorKey (min(a.mTime,b.mTime),min(a.mValue,b.mValue)); @@ -150,26 +161,26 @@ template <> struct MinMaxChooser { min = (1u<<(sizeof(unsigned int)*8-1)); }}; -template <> struct MinMaxChooser { - void operator ()(aiVector3D& min,aiVector3D& max) { - max = aiVector3D(-1e10f,-1e10f,-1e10f); - min = aiVector3D( 1e10f, 1e10f, 1e10f); +template struct MinMaxChooser< aiVector3t > { + void operator ()(aiVector3t& min,aiVector3t& max) { + max = aiVector3t(-1e10f,-1e10f,-1e10f); + min = aiVector3t( 1e10f, 1e10f, 1e10f); }}; -template <> struct MinMaxChooser { - void operator ()(aiVector2D& min,aiVector2D& max) { - max = aiVector2D(-1e10f,-1e10f); - min = aiVector2D( 1e10f, 1e10f); +template struct MinMaxChooser< aiVector2t > { + void operator ()(aiVector2t& min,aiVector2t& max) { + max = aiVector2t(-1e10f,-1e10f); + min = aiVector2t( 1e10f, 1e10f); }}; -template <> struct MinMaxChooser { - void operator ()(aiColor4D& min,aiColor4D& max) { - max = aiColor4D(-1e10f,-1e10f,-1e10f,-1e10f); - min = aiColor4D( 1e10f, 1e10f, 1e10f, 1e10f); +template struct MinMaxChooser< aiColor4t > { + void operator ()(aiColor4t& min,aiColor4t& max) { + max = aiColor4t(-1e10f,-1e10f,-1e10f,-1e10f); + min = aiColor4t( 1e10f, 1e10f, 1e10f, 1e10f); }}; -template <> struct MinMaxChooser { - void operator ()(aiQuaternion& min,aiQuaternion& max) { - max = aiQuaternion(-1e10f,-1e10f,-1e10f,-1e10f); - min = aiQuaternion( 1e10f, 1e10f, 1e10f, 1e10f); +template struct MinMaxChooser< aiQuaterniont > { + void operator ()(aiQuaterniont& min,aiQuaterniont& max) { + max = aiQuaterniont(-1e10f,-1e10f,-1e10f,-1e10f); + min = aiQuaterniont( 1e10f, 1e10f, 1e10f, 1e10f); }}; template <> struct MinMaxChooser {