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_collidable.h"
\r
20 namespace PhysicsEffects {
\r
22 void PfxCollidable::addShape(const PfxShape &shape)
\r
24 if(m_numShapes<m_maxShapes) {
\r
25 PfxShape &newShape = getNewShape();
\r
30 void PfxCollidable::finish()
\r
32 if(m_numShapes == 0) return;
\r
35 PfxVector3 halfMax(-SCE_PFX_FLT_MAX),halfMin(SCE_PFX_FLT_MAX);
\r
37 for(PfxUInt32 i=0;i<getNumShapes();i++) {
\r
38 const PfxShape &shape = getShape(i);
\r
39 PfxVector3 aabbMin,aabbMax;
\r
40 shape.getAabb(aabbMin,aabbMax);
\r
41 halfMax = maxPerElem(halfMax,aabbMax);
\r
42 halfMin = minPerElem(halfMin,aabbMin);
\r
45 PfxVector3 allCenter = ( halfMin + halfMax ) * 0.5f;
\r
46 PfxVector3 allHalf = ( halfMax - halfMin ) * 0.5f;
\r
47 m_center[0] = allCenter[0];
\r
48 m_center[1] = allCenter[1];
\r
49 m_center[2] = allCenter[2];
\r
50 m_half[0] = allHalf[0];
\r
51 m_half[1] = allHalf[1];
\r
52 m_half[2] = allHalf[2];
\r
55 } //namespace PhysicsEffects
\r