Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / CDTestFramework / Opcode / OPC_PlanesTriOverlap.h
1 /*
2  *      OPCODE - Optimized Collision Detection
3  * http://www.codercorner.com/Opcode.htm
4  * 
5  * Copyright (c) 2001-2008 Pierre Terdiman,  pierre@codercorner.com
6
7 This software is provided 'as-is', without any express or implied warranty.
8 In no event will the authors be held liable for any damages arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose, 
10 including commercial applications, and to alter it and redistribute it freely, 
11 subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
14 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
15 3. This notice may not be removed or altered from any source distribution.
16 */
17
18 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19 /**
20  *      Planes-triangle overlap test.
21  *      \param          in_clip_mask    [in] bitmask for active planes
22  *      \return         TRUE if triangle overlap planes
23  *      \warning        THIS IS A CONSERVATIVE TEST !! Some triangles will be returned as intersecting, while they're not!
24  */
25 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26 inline_ BOOL PlanesCollider::PlanesTriOverlap(udword in_clip_mask)
27 {
28         // Stats
29         mNbVolumePrimTests++;
30
31         const Plane* p = mPlanes;
32         udword Mask = 1;
33
34         while(Mask<=in_clip_mask)
35         {
36                 if(in_clip_mask & Mask)
37                 {
38                         float d0 = p->Distance(*mVP.Vertex[0]);
39                         float d1 = p->Distance(*mVP.Vertex[1]);
40                         float d2 = p->Distance(*mVP.Vertex[2]);
41                         if(d0>0.0f && d1>0.0f && d2>0.0f)       return FALSE;
42 //                      if(!(IR(d0)&SIGN_BITMASK) && !(IR(d1)&SIGN_BITMASK) && !(IR(d2)&SIGN_BITMASK))  return FALSE;
43                 }
44                 Mask+=Mask;
45                 p++;
46         }
47 /*
48         for(udword i=0;i<6;i++)
49         {
50                 float d0 = p[i].Distance(mLeafVerts[0]);
51                 float d1 = p[i].Distance(mLeafVerts[1]);
52                 float d2 = p[i].Distance(mLeafVerts[2]);
53                 if(d0>0.0f && d1>0.0f && d2>0.0f)       return false;
54         }
55 */
56         return TRUE;
57 }