[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / BulletCollision / Gimpact / btGImpactQuantizedBvhStructs.h
1 #ifndef GIM_QUANTIZED_SET_STRUCTS_H_INCLUDED
2 #define GIM_QUANTIZED_SET_STRUCTS_H_INCLUDED
3
4 /*! \file btGImpactQuantizedBvh.h
5 \author Francisco Leon Najera
6 */
7 /*
8 This source file is part of GIMPACT Library.
9
10 For the latest info, see http://gimpact.sourceforge.net/
11
12 Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
13 email: projectileman@yahoo.com
14
15
16 This software is provided 'as-is', without any express or implied warranty.
17 In no event will the authors be held liable for any damages arising from the use of this software.
18 Permission is granted to anyone to use this software for any purpose,
19 including commercial applications, and to alter it and redistribute it freely,
20 subject to the following restrictions:
21
22 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.
23 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
24 3. This notice may not be removed or altered from any source distribution.
25 */
26
27 #include "btGImpactBvh.h"
28 #include "btQuantization.h"
29
30 ///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
31 ///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
32 ATTRIBUTE_ALIGNED16(struct)
33 BT_QUANTIZED_BVH_NODE
34 {
35         //12 bytes
36         unsigned short int m_quantizedAabbMin[3];
37         unsigned short int m_quantizedAabbMax[3];
38         //4 bytes
39         int m_escapeIndexOrDataIndex;
40
41         BT_QUANTIZED_BVH_NODE()
42         {
43                 m_escapeIndexOrDataIndex = 0;
44         }
45
46         SIMD_FORCE_INLINE bool isLeafNode() const
47         {
48                 //skipindex is negative (internal node), triangleindex >=0 (leafnode)
49                 return (m_escapeIndexOrDataIndex >= 0);
50         }
51
52         SIMD_FORCE_INLINE int getEscapeIndex() const
53         {
54                 //btAssert(m_escapeIndexOrDataIndex < 0);
55                 return -m_escapeIndexOrDataIndex;
56         }
57
58         SIMD_FORCE_INLINE void setEscapeIndex(int index)
59         {
60                 m_escapeIndexOrDataIndex = -index;
61         }
62
63         SIMD_FORCE_INLINE int getDataIndex() const
64         {
65                 //btAssert(m_escapeIndexOrDataIndex >= 0);
66
67                 return m_escapeIndexOrDataIndex;
68         }
69
70         SIMD_FORCE_INLINE void setDataIndex(int index)
71         {
72                 m_escapeIndexOrDataIndex = index;
73         }
74
75         SIMD_FORCE_INLINE bool testQuantizedBoxOverlapp(
76                 unsigned short* quantizedMin, unsigned short* quantizedMax) const
77         {
78                 if (m_quantizedAabbMin[0] > quantizedMax[0] ||
79                         m_quantizedAabbMax[0] < quantizedMin[0] ||
80                         m_quantizedAabbMin[1] > quantizedMax[1] ||
81                         m_quantizedAabbMax[1] < quantizedMin[1] ||
82                         m_quantizedAabbMin[2] > quantizedMax[2] ||
83                         m_quantizedAabbMax[2] < quantizedMin[2])
84                 {
85                         return false;
86                 }
87                 return true;
88         }
89 };
90
91 #endif  // GIM_QUANTIZED_SET_STRUCTS_H_INCLUDED