From c01469dddabe404506ef3a64542e8423f9e11f2c Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 30 Jan 2022 17:44:05 +0100 Subject: Converted Opcode and Ice into unix newlines format --- Opcode/OPC_SphereAABBOverlap.h | 256 ++++++++++++++++++++--------------------- 1 file changed, 128 insertions(+), 128 deletions(-) (limited to 'Opcode/OPC_SphereAABBOverlap.h') diff --git a/Opcode/OPC_SphereAABBOverlap.h b/Opcode/OPC_SphereAABBOverlap.h index a5bd35b..b7b4376 100644 --- a/Opcode/OPC_SphereAABBOverlap.h +++ b/Opcode/OPC_SphereAABBOverlap.h @@ -1,128 +1,128 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/** - * Sphere-AABB overlap test, based on Jim Arvo's code. - * \param center [in] box center - * \param extents [in] box extents - * \return TRUE on overlap - */ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL SphereCollider::SphereAABBOverlap(const IcePoint& center, const IcePoint& extents) -{ - // Stats - mNbVolumeBVTests++; - - float d = 0.0f; - - //find the square of the distance - //from the sphere to the box -#ifdef OLDIES - for(udword i=0;i<3;i++) - { - float tmp = mCenter[i] - center[i]; - float s = tmp + extents[i]; - - if(s<0.0f) d += s*s; - else - { - s = tmp - extents[i]; - if(s>0.0f) d += s*s; - } - } -#endif - -//#ifdef NEW_TEST - -// float tmp = mCenter.x - center.x; -// float s = tmp + extents.x; - - float tmp,s; - - tmp = mCenter.x - center.x; - s = tmp + extents.x; - - if(s<0.0f) - { - d += s*s; - if(d>mRadius2) return FALSE; - } - else - { - s = tmp - extents.x; - if(s>0.0f) - { - d += s*s; - if(d>mRadius2) return FALSE; - } - } - - tmp = mCenter.y - center.y; - s = tmp + extents.y; - - if(s<0.0f) - { - d += s*s; - if(d>mRadius2) return FALSE; - } - else - { - s = tmp - extents.y; - if(s>0.0f) - { - d += s*s; - if(d>mRadius2) return FALSE; - } - } - - tmp = mCenter.z - center.z; - s = tmp + extents.z; - - if(s<0.0f) - { - d += s*s; - if(d>mRadius2) return FALSE; - } - else - { - s = tmp - extents.z; - if(s>0.0f) - { - d += s*s; - if(d>mRadius2) return FALSE; - } - } -//#endif - -#ifdef OLDIES -// IcePoint Min = center - extents; -// IcePoint Max = center + extents; - - float d = 0.0f; - - //find the square of the distance - //from the sphere to the box - for(udword i=0;i<3;i++) - { -float Min = center[i] - extents[i]; - -// if(mCenter[i]Max[i]) - if(mCenter[i]>Max) - { - float s = mCenter[i] - Max; - d += s*s; - } - } - } -#endif - return d <= mRadius2; -} +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * Sphere-AABB overlap test, based on Jim Arvo's code. + * \param center [in] box center + * \param extents [in] box extents + * \return TRUE on overlap + */ +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +inline_ BOOL SphereCollider::SphereAABBOverlap(const IcePoint& center, const IcePoint& extents) +{ + // Stats + mNbVolumeBVTests++; + + float d = 0.0f; + + //find the square of the distance + //from the sphere to the box +#ifdef OLDIES + for(udword i=0;i<3;i++) + { + float tmp = mCenter[i] - center[i]; + float s = tmp + extents[i]; + + if(s<0.0f) d += s*s; + else + { + s = tmp - extents[i]; + if(s>0.0f) d += s*s; + } + } +#endif + +//#ifdef NEW_TEST + +// float tmp = mCenter.x - center.x; +// float s = tmp + extents.x; + + float tmp,s; + + tmp = mCenter.x - center.x; + s = tmp + extents.x; + + if(s<0.0f) + { + d += s*s; + if(d>mRadius2) return FALSE; + } + else + { + s = tmp - extents.x; + if(s>0.0f) + { + d += s*s; + if(d>mRadius2) return FALSE; + } + } + + tmp = mCenter.y - center.y; + s = tmp + extents.y; + + if(s<0.0f) + { + d += s*s; + if(d>mRadius2) return FALSE; + } + else + { + s = tmp - extents.y; + if(s>0.0f) + { + d += s*s; + if(d>mRadius2) return FALSE; + } + } + + tmp = mCenter.z - center.z; + s = tmp + extents.z; + + if(s<0.0f) + { + d += s*s; + if(d>mRadius2) return FALSE; + } + else + { + s = tmp - extents.z; + if(s>0.0f) + { + d += s*s; + if(d>mRadius2) return FALSE; + } + } +//#endif + +#ifdef OLDIES +// IcePoint Min = center - extents; +// IcePoint Max = center + extents; + + float d = 0.0f; + + //find the square of the distance + //from the sphere to the box + for(udword i=0;i<3;i++) + { +float Min = center[i] - extents[i]; + +// if(mCenter[i]Max[i]) + if(mCenter[i]>Max) + { + float s = mCenter[i] - Max; + d += s*s; + } + } + } +#endif + return d <= mRadius2; +} -- cgit v1.1