Tizen 2.1 base
[platform/upstream/libbullet.git] / Extras / PhysicsEffects / include / physics_effects / base_level / solver / pfx_joint.h
1 /*\r
2 Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.\r
3 All rights reserved.\r
4 \r
5 Physics Effects is open software; you can redistribute it and/or\r
6 modify it under the terms of the BSD License.\r
7 \r
8 Physics Effects is distributed in the hope that it will be useful,\r
9 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
11 See the BSD License for more details.\r
12 \r
13 A copy of the BSD License is distributed with\r
14 Physics Effects under the filename: physics_effects_license.txt\r
15 */\r
16 \r
17 #ifndef _SCE_PFX_JOINT_H\r
18 #define _SCE_PFX_JOINT_H\r
19 \r
20 #include "../rigidbody/pfx_rigid_state.h"\r
21 #include "pfx_joint_constraint.h"\r
22 #include "pfx_constraint_pair.h"\r
23 \r
24 namespace sce {\r
25 namespace PhysicsEffects {\r
26 \r
27 // Joint Type\r
28 enum ePfxJointType {\r
29         kPfxJointBall = 0,\r
30         kPfxJointSwingtwist,\r
31         kPfxJointHinge,\r
32         kPfxJointSlider,\r
33         kPfxJointFix,\r
34         kPfxJointUniversal,\r
35         kPfxJointAnimation,\r
36         kPfxJointReserved0,\r
37         kPfxJointReserved1,\r
38         kPfxJointReserved2,\r
39         kPfxJointUser0,\r
40         kPfxJointUser1,\r
41         kPfxJointUser2,\r
42         kPfxJointUser3,\r
43         kPfxJointUser4,\r
44         kPfxJointCount // = 15\r
45 };\r
46 \r
47 // Joint Structure\r
48 struct SCE_PFX_ALIGNED(128) PfxJoint {\r
49         PfxUInt8 m_active;\r
50         PfxUInt8 m_numConstraints;\r
51         PfxUInt8 m_type;\r
52         SCE_PFX_PADDING(1,1)\r
53         PfxUInt16 m_rigidBodyIdA;\r
54         PfxUInt16 m_rigidBodyIdB;\r
55         SCE_PFX_PADDING(2,8)\r
56         PfxJointConstraint m_constraints[6];\r
57         void *m_userData;\r
58         SCE_PFX_PADDING(3,12)\r
59         PfxVector3 m_param[4]; // Used by some joints for specific features\r
60         PfxVector3 m_anchorA;\r
61         PfxVector3 m_anchorB;\r
62         PfxMatrix3 m_frameA;\r
63         PfxMatrix3 m_frameB;\r
64         SCE_PFX_PADDING(4,32)\r
65 };\r
66 \r
67 SCE_PFX_FORCE_INLINE \r
68 void pfxUpdateJointPairs(\r
69         PfxConstraintPair &pair,\r
70         PfxUInt32 jointId,\r
71         const PfxJoint &joint,\r
72         const PfxRigidState &stateA,\r
73         const PfxRigidState &stateB\r
74         )\r
75 {\r
76         SCE_PFX_ALWAYS_ASSERT(stateA.getRigidBodyId()==joint.m_rigidBodyIdA);\r
77         SCE_PFX_ALWAYS_ASSERT(stateB.getRigidBodyId()==joint.m_rigidBodyIdB);\r
78         pfxSetObjectIdA(pair,stateA.getRigidBodyId());\r
79         pfxSetObjectIdB(pair,stateB.getRigidBodyId());\r
80         pfxSetMotionMaskA(pair,stateA.getMotionMask());\r
81         pfxSetMotionMaskB(pair,stateB.getMotionMask());\r
82         pfxSetConstraintId(pair,jointId);\r
83         pfxSetNumConstraints(pair,joint.m_numConstraints);\r
84         pfxSetActive(pair,joint.m_active>0);\r
85 }\r
86 } //namespace PhysicsEffects\r
87 } //namespace sce\r
88 \r
89 \r
90 #endif // _PFX_JOINT_H\r