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 #ifndef _SCE_PFX_CONTACT_CACHE_H
\r
18 #define _SCE_PFX_CONTACT_CACHE_H
\r
20 #include "../../../include/physics_effects/base_level/base/pfx_common.h"
\r
21 #include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h"
\r
22 #include "../../../include/physics_effects/base_level/collision/pfx_sub_data.h"
\r
25 namespace PhysicsEffects {
\r
27 #define SCE_PFX_MAX_CACHED_CONTACT_POINTS 4
\r
30 内部の衝突判定に使う軽量なコンタクトキャッシュ
\r
33 ///////////////////////////////////////////////////////////////////////////////
\r
36 struct PfxCachedContactPoint
\r
38 PfxSubData m_subData;
\r
39 PfxUInt8 m_shapeIdA;
\r
40 PfxUInt8 m_shapeIdB;
\r
41 SCE_PFX_PADDING(1,2)
\r
42 PfxFloat m_distance;
\r
43 PfxVector3 m_normal;
\r
44 PfxPoint3 m_localPointA;
\r
45 PfxPoint3 m_localPointB;
\r
49 m_shapeIdA = m_shapeIdB = 0;
\r
50 m_subData = PfxSubData();
\r
51 m_distance = SCE_PFX_FLT_MAX;
\r
55 ///////////////////////////////////////////////////////////////////////////////
\r
58 class PfxContactCache
\r
61 PfxUInt32 m_numContacts;
\r
62 SCE_PFX_PADDING(1,12)
\r
63 PfxCachedContactPoint m_cachedContactPoints[SCE_PFX_MAX_CACHED_CONTACT_POINTS];
\r
65 int findNearestContactPoint(const PfxPoint3 &newPoint,const PfxVector3 &newNormal);
\r
66 int sort4ContactPoints(const PfxPoint3 &newPoint,PfxFloat newDistance);
\r
69 PfxContactCache() : m_numContacts(0) {}
\r
71 void addContactPoint(
\r
72 PfxFloat newDistance,
\r
73 const PfxVector3 &newNormal, // world normal vector
\r
74 const PfxPoint3 &newPointA, // local contact point to the objectA
\r
75 const PfxPoint3 &newPointB, // local contact point to the objectB
\r
76 PfxSubData m_subData);
\r
78 void addContactPoint(const PfxCachedContactPoint &cp);
\r
80 int getNumContacts() const {return (int)m_numContacts;}
\r
82 PfxCachedContactPoint &getContactPoint(int i) {return m_cachedContactPoints[i];}
\r
84 const PfxCachedContactPoint &getContactPoint(int i) const {return m_cachedContactPoints[i];}
\r
86 PfxFloat getDistance(int i) {return m_cachedContactPoints[i].m_distance;}
\r
88 const PfxVector3 &getNormal(int i) const {return m_cachedContactPoints[i].m_normal;}
\r
90 const PfxPoint3 &getLocalPointA(int i) const {return m_cachedContactPoints[i].m_localPointA;}
\r
92 const PfxPoint3 &getLocalPointB(int i) const {return m_cachedContactPoints[i].m_localPointB;}
\r
94 const PfxSubData &getSubData(int i) const {return m_cachedContactPoints[i].m_subData;}
\r
97 } //namespace PhysicsEffects
\r
100 #endif // _SCE_PFX_CONTACT_CACHE_H
\r