Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / RigidBodyGpuPipeline / dynamics / basic_demo / Stubs / AdlContact4.h
1 /*
2 Copyright (c) 2012 Advanced Micro Devices, Inc.  
3
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose, 
7 including commercial applications, and to alter it and redistribute it freely, 
8 subject to the following restrictions:
9
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 //Originally written by Takahiro Harada
15
16
17 #ifndef ADL_CONTACT4_H
18 #define ADL_CONTACT4_H
19
20 #ifdef CL_PLATFORM_AMD
21 #include "AdlConstraint4.h"
22 #include "Adl/Adl.h"
23
24 typedef adl::Buffer<Constraint4>* SolverData;
25 #else
26 typedef void* SolverData;
27 #endif
28
29 typedef void* ShapeDataType;
30
31
32 struct Contact4
33 {
34         _MEM_ALIGNED_ALLOCATOR16;
35
36         float4 m_worldPos[4];
37         float4 m_worldNormal;
38 //      float m_restituitionCoeff;
39 //      float m_frictionCoeff;
40         u16 m_restituitionCoeffCmp;
41         u16 m_frictionCoeffCmp;
42         int m_batchIdx;
43
44         u32 m_bodyAPtr;
45         u32 m_bodyBPtr;
46
47         //      todo. make it safer
48         int& getBatchIdx() { return m_batchIdx; }
49         float getRestituitionCoeff() const { return ((float)m_restituitionCoeffCmp/(float)0xffff); }
50         void setRestituitionCoeff( float c ) { ADLASSERT( c >= 0.f && c <= 1.f ); m_restituitionCoeffCmp = (u16)(c*0xffff); }
51         float getFrictionCoeff() const { return ((float)m_frictionCoeffCmp/(float)0xffff); }
52         void setFrictionCoeff( float c ) { ADLASSERT( c >= 0.f && c <= 1.f ); m_frictionCoeffCmp = (u16)(c*0xffff); }
53
54         float& getNPoints() { return m_worldNormal.w; }
55         float getNPoints() const { return m_worldNormal.w; }
56
57         float getPenetration(int idx) const { return m_worldPos[idx].w; }
58
59         bool isInvalid() const { return ((u32)m_bodyAPtr+(u32)m_bodyBPtr) == 0; }
60 };
61
62 struct ContactPoint4
63                 {
64                         float4 m_worldPos[4];
65                         union
66                         {
67                                 float4 m_worldNormal;
68
69                                 struct Data
70                                 {
71                                         int m_padding[3];
72                                         float m_nPoints;        //      for cl
73                                 }m_data;
74
75                         };
76                         float m_restituitionCoeff;
77                         float m_frictionCoeff;
78 //                      int m_nPoints;
79 //                      int m_padding0;
80
81                         void* m_bodyAPtr;
82                         void* m_bodyBPtr;
83 //                      int m_padding1;
84 //                      int m_padding2;
85
86                         float& getNPoints() { return m_data.m_nPoints; }
87                         float getNPoints() const { return m_data.m_nPoints; }
88
89                         float getPenetration(int idx) const { return m_worldPos[idx].w; }
90
91 //                      __inline
92 //                      void load(int idx, const ContactPoint& src);
93 //                      __inline
94 //                      void store(int idx, ContactPoint& dst) const;
95
96                         bool isInvalid() const { return ((u32)m_bodyAPtr+(u32)m_bodyBPtr) == 0; }
97
98                 };
99
100
101 #endif //ADL_CONTACT4_H
102