2 Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
\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
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
13 A copy of the BSD License is distributed with
\r
14 Physics Effects under the filename: physics_effects_license.txt
\r
17 #include "../../../include/physics_effects/base_level/collision/pfx_shape.h"
\r
20 namespace PhysicsEffects {
\r
21 void pfxGetShapeAabbDummy(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
23 (void)shape,(void)aabbMin,(void)aabbMax;
\r
26 void pfxGetShapeAabbSphere(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
28 aabbMin = shape.getOffsetPosition() - PfxVector3(shape.getSphere().m_radius);
\r
29 aabbMax = shape.getOffsetPosition() + PfxVector3(shape.getSphere().m_radius);
\r
32 void pfxGetShapeAabbBox(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
34 PfxVector3 boxSize = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * shape.getBox().m_half;
\r
35 aabbMin = shape.getOffsetPosition() - boxSize;
\r
36 aabbMax = shape.getOffsetPosition() + boxSize;
\r
39 void pfxGetShapeAabbCapsule(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
41 PfxVector3 dir = rotate(shape.getOffsetOrientation(),PfxVector3(1.0f,0.0f,0.0f));
\r
42 PfxVector3 capSize = absPerElem(dir) * shape.getCapsule().m_halfLen +
\r
43 PfxVector3(shape.getCapsule().m_radius);
\r
44 aabbMin = shape.getOffsetPosition() - capSize;
\r
45 aabbMax = shape.getOffsetPosition() + capSize;
\r
48 void pfxGetShapeAabbCylinder(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
50 PfxVector3 capSize = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) *
\r
51 PfxVector3(shape.getCylinder().m_halfLen,shape.getCylinder().m_radius,shape.getCylinder().m_radius);
\r
52 aabbMin = shape.getOffsetPosition() - capSize;
\r
53 aabbMax = shape.getOffsetPosition() + capSize;
\r
56 void pfxGetShapeAabbConvexMesh(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
58 const PfxConvexMesh *convex = shape.getConvexMesh();
\r
59 PfxVector3 half = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * convex->m_half;
\r
60 aabbMin = shape.getOffsetPosition() - half;
\r
61 aabbMax = shape.getOffsetPosition() + half;
\r
64 void pfxGetShapeAabbLargeTriMesh(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax)
\r
66 const PfxLargeTriMesh *largemesh = shape.getLargeTriMesh();
\r
67 PfxVector3 half = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * largemesh->m_half;
\r
68 aabbMin = shape.getOffsetPosition() - half;
\r
69 aabbMax = shape.getOffsetPosition() + half;
\r
72 typedef void (*PfxFuncGetShapeAabb)(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax);
\r
74 PfxFuncGetShapeAabb pfxFuncGetShapeAabb[kPfxShapeCount] = {
\r
75 pfxGetShapeAabbSphere,
\r
77 pfxGetShapeAabbCapsule,
\r
78 pfxGetShapeAabbCylinder,
\r
79 pfxGetShapeAabbConvexMesh,
\r
80 pfxGetShapeAabbLargeTriMesh,
\r
81 pfxGetShapeAabbDummy,
\r
82 pfxGetShapeAabbDummy,
\r
83 pfxGetShapeAabbDummy,
\r
84 pfxGetShapeAabbDummy,
\r
85 pfxGetShapeAabbDummy,
\r
86 pfxGetShapeAabbDummy,
\r
89 void PfxShape::getAabb(PfxVector3 &aabbMin,PfxVector3 &aabbMax) const
\r
91 return pfxFuncGetShapeAabb[m_type](*this,aabbMin,aabbMax);
\r
94 } //namespace PhysicsEffects
\r