True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

CollisionShared.h

00001 //---------------------------------------------------------------------------------
00002 // File Name: CollisionShared.h
00003 // Description:
00004 //      Internally shared collision functions, structures and data.
00005 //
00006 // Copyright (C) 2004 - 2006 True Axis Pty Ltd, Australia. 
00007 // All Rights Reserved.
00008 //
00009 // History:
00010 //      Created File.
00011 //---------------------------------------------------------------------------------
00012 
00013 #ifndef TA_COLLISIONSHARED_H
00014 #define TA_COLLISIONSHARED_H
00015 
00016 #ifndef TA_MFRAME_H
00017 #include "../Common/MFrame.h"
00018 #endif // TA_MFRAME_H
00019 
00020 #ifndef TA_COLLISION_H
00021 #include "Collision.h"
00022 #endif // TA_COLLISION_H
00023 
00024 namespace TA
00025 {
00026 
00027 //---------------------------------------------------------------------------------
00028 //---------------------------------------------------------------------------------
00029 bool TAC_CALL CollisionShared_NewCollision(Collision& collision, CollisionCallData* pCollisionCallbackData);
00030 
00031 //---------------------------------------------------------------------------------
00032 //---------------------------------------------------------------------------------
00033 bool TAC_CALL CollisionShared_NewCollisionWithComplex(Collision& collision, CollisionCallData* pCollisionCallbackData);
00034 
00035 //---------------------------------------------------------------------------------
00036 //---------------------------------------------------------------------------------
00037 int TAC_CALL CollisionShared_SolveQuartic(float fB, float fC, float fD, float fE, float pfRootList[4]);
00038 
00039 //---------------------------------------------------------------------------------
00040 //---------------------------------------------------------------------------------
00041 bool TAC_CALL CollisionShared_LineVsQuarterTorus(
00042     const Vec3& v3Line0,
00043     const Vec3& v3Line1,
00044     const Vec3& v3TorusCenter,
00045     const Vec3& v3TorusNormal,
00046     float fRadius1,
00047     float fRadius2,
00048     float& fResultTime,
00049     Vec3& v3ResultPos,
00050     Vec3& v3ResultNormal);
00051 
00052 //---------------------------------------------------------------------------------
00053 //---------------------------------------------------------------------------------
00054 inline int TAC_CALL CollisionShared_Next(int nValue, int nMaxValue) 
00055 { 
00056     int nNext = nValue + 1;
00057     if (nNext >= nMaxValue)
00058         nNext = 0;
00059     return nNext;
00060     // Could try the below code that avoids the if.
00061     // Although, surly branch prediction should work well in this case?
00062     //int nNext = nValue + 1;
00063     //((u32&)(nNext - nMaxValue) >> 31) * nNext
00064     //return nNext;
00065 }
00066 //---------------------------------------------------------------------------------
00067 //---------------------------------------------------------------------------------
00068 inline int TAC_CALL CollisionShared_Prev(int nValue, int nMaxValue) 
00069 { 
00070     int nNext = nValue - 1;
00071     if (nNext < 0)
00072         nNext = nMaxValue - 1;
00073     return nNext;
00074 }
00075 
00076 }
00077 
00078 #endif // TA_COLLISIONSHARED_H


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.