Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / PhysicsEffects / src / low_level / collision / pfx_intersect_ray_func.cpp
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 #include "../../../include/physics_effects/base_level/collision/pfx_shape.h"\r
18 #include "../../base_level/collision/pfx_intersect_ray_box.h"\r
19 #include "../../base_level/collision/pfx_intersect_ray_sphere.h"\r
20 #include "../../base_level/collision/pfx_intersect_ray_capsule.h"\r
21 #include "../../base_level/collision/pfx_intersect_ray_cylinder.h"\r
22 #include "../../base_level/collision/pfx_intersect_ray_convex.h"\r
23 #include "../../base_level/collision/pfx_intersect_ray_large_tri_mesh.h"\r
24 #include "pfx_intersect_ray_func.h"\r
25 \r
26 \r
27 namespace sce {\r
28 namespace PhysicsEffects {\r
29 \r
30 \r
31 ///////////////////////////////////////////////////////////////////////////////\r
32 // Ray Intersection Function Table\r
33 \r
34 PfxBool intersectRayFuncDummy(\r
35                                 const PfxRayInput &ray,PfxRayOutput &out,\r
36                                 const PfxShape &shape,const PfxTransform3 &transform)\r
37 {\r
38         (void)ray,(void)out,(void)shape,(void)transform;\r
39         return false;\r
40 }\r
41 \r
42 PfxBool intersectRayFuncBox(\r
43                                 const PfxRayInput &ray,PfxRayOutput &out,\r
44                                 const PfxShape &shape,const PfxTransform3 &transform)\r
45 {\r
46         return pfxIntersectRayBox(ray,out,shape.getBox(),transform);\r
47 }\r
48 \r
49 PfxBool intersectRayFuncSphere(\r
50                                 const PfxRayInput &ray,PfxRayOutput &out,\r
51                                 const PfxShape &shape,const PfxTransform3 &transform)\r
52 {\r
53         return pfxIntersectRaySphere(ray,out,shape.getSphere(),transform);\r
54 }\r
55 \r
56 PfxBool intersectRayFuncCapsule(\r
57                                 const PfxRayInput &ray,PfxRayOutput &out,\r
58                                 const PfxShape &shape,const PfxTransform3 &transform)\r
59 {\r
60         return pfxIntersectRayCapsule(ray,out,shape.getCapsule(),transform);\r
61 }\r
62 \r
63 PfxBool intersectRayFuncCylinder(\r
64                                 const PfxRayInput &ray,PfxRayOutput &out,\r
65                                 const PfxShape &shape,const PfxTransform3 &transform)\r
66 {\r
67         return pfxIntersectRayCylinder(ray,out,shape.getCylinder(),transform);\r
68 }\r
69 \r
70 PfxBool intersectRayFuncConvex(\r
71                                 const PfxRayInput &ray,PfxRayOutput &out,\r
72                                 const PfxShape &shape,const PfxTransform3 &transform)\r
73 {\r
74 const PfxConvexMesh *convex = shape.getConvexMesh();\r
75         \r
76         PfxBool ret = pfxIntersectRayConvex(ray,out,(const void*)convex,transform);\r
77         \r
78         \r
79         return ret;\r
80 }\r
81 \r
82 PfxBool intersectRayFuncLargeTriMesh(\r
83                                 const PfxRayInput &ray,PfxRayOutput &out,\r
84                                 const PfxShape &shape,const PfxTransform3 &transform)\r
85 {\r
86 const PfxLargeTriMesh *lmesh = shape.getLargeTriMesh();\r
87         \r
88         PfxBool ret = pfxIntersectRayLargeTriMesh(ray,out,(const void*)lmesh,transform);\r
89         \r
90         \r
91         return ret;\r
92 }\r
93 \r
94 PfxIntersectRayFunc funcTbl_intersectRay[kPfxShapeCount] = {\r
95         intersectRayFuncSphere,\r
96         intersectRayFuncBox,\r
97         intersectRayFuncCapsule,\r
98         intersectRayFuncCylinder,\r
99         intersectRayFuncConvex,\r
100         intersectRayFuncLargeTriMesh,\r
101         intersectRayFuncDummy,\r
102         intersectRayFuncDummy,\r
103         intersectRayFuncDummy,\r
104         intersectRayFuncDummy,\r
105         intersectRayFuncDummy,\r
106         intersectRayFuncDummy,\r
107 };\r
108 \r
109 ///////////////////////////////////////////////////////////////////////////////\r
110 // Ray Intersection Function Table Interface\r
111 \r
112 PfxIntersectRayFunc pfxGetIntersectRayFunc(PfxUInt8 shapeType)\r
113 {\r
114         return funcTbl_intersectRay[shapeType];\r
115 }\r
116 \r
117 PfxInt32 pfxSetIntersectRayFunc(PfxUInt8 shapeType,PfxIntersectRayFunc func)\r
118 {\r
119         if(shapeType >= kPfxShapeCount) {\r
120                 return SCE_PFX_ERR_OUT_OF_RANGE;\r
121         }\r
122         \r
123         funcTbl_intersectRay[shapeType] = func;\r
124         \r
125         return SCE_PFX_OK;\r
126 }\r
127 \r
128 } //namespace PhysicsEffects\r
129 } //namespace sce\r