Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Extras / CDTestFramework / Opcode / Ice / IceTrilist.h
1 /*
2  *      ICE / 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  *      Contains code for a triangle container.
20  *      \file           IceTrilist.h
21  *      \author         Pierre Terdiman
22  *      \date           April, 4, 2000
23  */
24 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25
26 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27 // Include Guard
28 #ifndef __ICETRILIST_H__
29 #define __ICETRILIST_H__
30
31         class ICEMATHS_API TriList : public Container
32         {
33                 public:
34                 // Constructor / Destructor
35                                                                 TriList()                                       {}
36                                                                 ~TriList()                                      {}
37
38                 inline_ udword                  GetNbTriangles()        const   { return GetNbEntries()/9;                      }
39                 inline_ Triangle*               GetTriangles()          const   { return (Triangle*)GetEntries();       }
40
41                                 void                    AddTri(const Triangle& tri)
42                                                                 {
43                                                                         Add(tri.mVerts[0].x).Add(tri.mVerts[0].y).Add(tri.mVerts[0].z);
44                                                                         Add(tri.mVerts[1].x).Add(tri.mVerts[1].y).Add(tri.mVerts[1].z);
45                                                                         Add(tri.mVerts[2].x).Add(tri.mVerts[2].y).Add(tri.mVerts[2].z);
46                                                                 }
47
48                                 void                    AddTri(const Point& p0, const Point& p1, const Point& p2)
49                                                                 {
50                                                                         Add(p0.x).Add(p0.y).Add(p0.z);
51                                                                         Add(p1.x).Add(p1.y).Add(p1.z);
52                                                                         Add(p2.x).Add(p2.y).Add(p2.z);
53                                                                 }
54         };
55
56         class ICEMATHS_API TriangleList : public Container
57         {
58                 public:
59                 // Constructor / Destructor
60                                                                         TriangleList()                          {}
61                                                                         ~TriangleList()                         {}
62
63                 inline_ udword                          GetNbTriangles()        const   { return GetNbEntries()/3;                              }
64                 inline_ IndexedTriangle*        GetTriangles()          const   { return (IndexedTriangle*)GetEntries();}
65
66                                 void                            AddTriangle(const IndexedTriangle& tri)
67                                                                         {
68                                                                                 Add(tri.mVRef[0]).Add(tri.mVRef[1]).Add(tri.mVRef[2]);
69                                                                         }
70
71                                 void                            AddTriangle(udword vref0, udword vref1, udword vref2)
72                                                                         {
73                                                                                 Add(vref0).Add(vref1).Add(vref2);
74                                                                         }
75         };
76
77 #endif //__ICETRILIST_H__