EListenerPhysicsContact更名为EListenerPhysicsCollision
This commit is contained in:
parent
e2c796ee59
commit
36b1d9ef50
|
|
@ -219,7 +219,7 @@
|
|||
<ClCompile Include="Geometry\EGeometry.cpp" />
|
||||
<ClCompile Include="Geometry\EPhysicsMsg.cpp" />
|
||||
<ClCompile Include="Geometry\ERectangle.cpp" />
|
||||
<ClCompile Include="Listener\EListenerPhysicsContact.cpp" />
|
||||
<ClCompile Include="Listener\EListenerPhysicsCollision.cpp" />
|
||||
<ClCompile Include="Listener\EListenerKeyboard.cpp" />
|
||||
<ClCompile Include="Listener\EListenerKeyboardPress.cpp" />
|
||||
<ClCompile Include="Listener\EListener.cpp" />
|
||||
|
|
|
|||
|
|
@ -198,9 +198,6 @@
|
|||
<ClCompile Include="Listener\EListenerPhysics.cpp">
|
||||
<Filter>Listener</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Listener\EListenerPhysicsContact.cpp">
|
||||
<Filter>Listener</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Common\EFont.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -210,6 +207,9 @@
|
|||
<ClCompile Include="Common\ETexture.cpp">
|
||||
<Filter>Common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Listener\EListenerPhysicsCollision.cpp">
|
||||
<Filter>Listener</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Win\winbase.h">
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
e2d::EGeometry::EGeometry()
|
||||
: m_bTransformed(false)
|
||||
, m_nCategoryBitmask(0)
|
||||
,m_nContactBitmask(0)
|
||||
, m_nCollisionBitmask(0)
|
||||
, m_bIsVisiable(true)
|
||||
, m_nColor(EColor::RED)
|
||||
, m_fOpacity(1)
|
||||
|
|
@ -20,11 +20,6 @@ e2d::EGeometry::~EGeometry()
|
|||
SafeReleaseInterface(&m_pTransformedGeometry);
|
||||
}
|
||||
|
||||
bool e2d::EGeometry::isContactWith(EGeometry * geometry)
|
||||
{
|
||||
return ((this->m_nContactBitmask & geometry->m_nCategoryBitmask) != 0);
|
||||
}
|
||||
|
||||
e2d::ENode * e2d::EGeometry::getParentNode() const
|
||||
{
|
||||
return m_pParentNode;
|
||||
|
|
@ -35,9 +30,9 @@ UINT32 e2d::EGeometry::getCategoryBitmask() const
|
|||
return m_nCategoryBitmask;
|
||||
}
|
||||
|
||||
UINT32 e2d::EGeometry::getContactBitmask() const
|
||||
UINT32 e2d::EGeometry::getCollisionBitmask() const
|
||||
{
|
||||
return m_nContactBitmask;
|
||||
return m_nCollisionBitmask;
|
||||
}
|
||||
|
||||
void e2d::EGeometry::setCategoryBitmask(UINT32 mask)
|
||||
|
|
@ -45,9 +40,9 @@ void e2d::EGeometry::setCategoryBitmask(UINT32 mask)
|
|||
m_nCategoryBitmask = mask;
|
||||
}
|
||||
|
||||
void e2d::EGeometry::setContactBitmask(UINT32 mask)
|
||||
void e2d::EGeometry::setCollisionBitmask(UINT32 mask)
|
||||
{
|
||||
m_nContactBitmask = mask;
|
||||
m_nCollisionBitmask = mask;
|
||||
}
|
||||
|
||||
void e2d::EGeometry::setVisiable(bool bVisiable)
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
#include "..\elisteners.h"
|
||||
#include "..\egeometry.h"
|
||||
|
||||
e2d::EListenerPhysicsContact::EListenerPhysicsContact()
|
||||
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision()
|
||||
: EListenerPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EListenerPhysicsContact::EListenerPhysicsContact(const EString & name)
|
||||
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision(const EString & name)
|
||||
: EListenerPhysics(name)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::EListenerPhysicsContact::EListenerPhysicsContact(const COLLISION_LISTENER_CALLBACK & callback)
|
||||
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision(const COLLISION_LISTENER_CALLBACK & callback)
|
||||
: EListenerPhysics()
|
||||
{
|
||||
this->m_Callback = callback;
|
||||
}
|
||||
|
||||
e2d::EListenerPhysicsContact::EListenerPhysicsContact(const EString & name, const COLLISION_LISTENER_CALLBACK & callback)
|
||||
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision(const EString & name, const COLLISION_LISTENER_CALLBACK & callback)
|
||||
: EListenerPhysics(name)
|
||||
{
|
||||
this->m_Callback = callback;
|
||||
}
|
||||
|
||||
void e2d::EListenerPhysicsContact::_callOn()
|
||||
void e2d::EListenerPhysicsCollision::_callOn()
|
||||
{
|
||||
if (EPhysicsMsg::getMsg() == EPhysicsMsg::OVERLAP ||
|
||||
EPhysicsMsg::getMsg() == EPhysicsMsg::CONTAINS ||
|
||||
|
|
@ -26,9 +26,9 @@ void e2d::EPhysicsManager::PhysicsGeometryProc(EGeometry * pActiveGeometry)
|
|||
|
||||
if (pActiveGeometry != pPassiveGeometry)
|
||||
{
|
||||
// 判断两物体是否会产生接触消息
|
||||
if (!pActiveGeometry->isContactWith(pPassiveGeometry))
|
||||
continue;
|
||||
// 判断两物体是否是相互冲突的物体
|
||||
if (pActiveGeometry->m_nCollisionBitmask & pPassiveGeometry->m_nCategoryBitmask)
|
||||
{
|
||||
// pPassiveGeometry 为被动方
|
||||
EPhysicsMsg::s_pPassiveGeometry = pPassiveGeometry;
|
||||
// 获取两方的关系
|
||||
|
|
@ -42,6 +42,7 @@ void e2d::EPhysicsManager::PhysicsGeometryProc(EGeometry * pActiveGeometry)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::EPhysicsManager::PhysicsListenerProc()
|
||||
|
|
|
|||
|
|
@ -49,27 +49,22 @@ public:
|
|||
|
||||
virtual ~EGeometry();
|
||||
|
||||
// 判断是否可以和另一几何图形产生接触消息
|
||||
bool isContactWith(
|
||||
EGeometry * geometry
|
||||
);
|
||||
|
||||
// 获取父节点
|
||||
ENode * getParentNode() const;
|
||||
|
||||
// 获取类别掩码
|
||||
UINT32 getCategoryBitmask() const;
|
||||
|
||||
// 获取接触掩码
|
||||
UINT32 getContactBitmask() const;
|
||||
// »ñÈ¡³åÍ»ÑÚÂë
|
||||
UINT32 getCollisionBitmask() const;
|
||||
|
||||
// 设置类别掩码
|
||||
void setCategoryBitmask(
|
||||
UINT32 mask
|
||||
);
|
||||
|
||||
// 设置接触掩码
|
||||
void setContactBitmask(
|
||||
// ÉèÖóåÍ»ÑÚÂë
|
||||
void setCollisionBitmask(
|
||||
UINT32 mask
|
||||
);
|
||||
|
||||
|
|
@ -106,7 +101,7 @@ protected:
|
|||
bool m_bTransformed;
|
||||
bool m_bIsVisiable;
|
||||
UINT32 m_nCategoryBitmask;
|
||||
UINT32 m_nContactBitmask;
|
||||
UINT32 m_nCollisionBitmask;
|
||||
UINT32 m_nColor;
|
||||
float m_fOpacity;
|
||||
ENode * m_pParentNode;
|
||||
|
|
|
|||
|
|
@ -328,12 +328,6 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
// 物理世界消息监听器回调函数(参数:主动方、被动方、两方关系)
|
||||
typedef std::function<void(ENode *active, ENode *passive, int relation)> PHYSICS_LISTENER_CALLBACK;
|
||||
|
||||
// 碰撞消息监听器回调函数(参数:主动方、被动方)
|
||||
typedef std::function<void(ENode *active, ENode *passive)> COLLISION_LISTENER_CALLBACK;
|
||||
|
||||
// 物理世界消息监听器
|
||||
class EListenerPhysics :
|
||||
public EListener
|
||||
|
|
@ -380,23 +374,22 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EListenerPhysicsContact :
|
||||
// 几何体冲突消息监听器
|
||||
class EListenerPhysicsCollision :
|
||||
public EListenerPhysics
|
||||
{
|
||||
friend EMsgManager;
|
||||
|
||||
public:
|
||||
EListenerPhysicsContact();
|
||||
EListenerPhysicsCollision();
|
||||
|
||||
EListenerPhysicsContact(
|
||||
EListenerPhysicsCollision(
|
||||
const EString &name
|
||||
);
|
||||
|
||||
EListenerPhysicsContact(
|
||||
EListenerPhysicsCollision(
|
||||
const COLLISION_LISTENER_CALLBACK &callback
|
||||
);
|
||||
|
||||
EListenerPhysicsContact(
|
||||
EListenerPhysicsCollision(
|
||||
const EString &name,
|
||||
const COLLISION_LISTENER_CALLBACK &callback
|
||||
);
|
||||
|
|
|
|||
|
|
@ -103,13 +103,19 @@ struct EWindowStyle
|
|||
}
|
||||
};
|
||||
|
||||
// 二维向量
|
||||
typedef EPoint EVec;
|
||||
|
||||
// 字符串
|
||||
typedef std::wstring EString;
|
||||
|
||||
// Vector 容器
|
||||
template<typename T>
|
||||
using EVector = std::vector<T>;
|
||||
|
||||
|
||||
class ENode;
|
||||
|
||||
// 定时器回调函数(参数为该定时器被调用的次数,从 0 开始)
|
||||
typedef std::function<void(int)> TIMER_CALLBACK;
|
||||
|
||||
|
|
@ -134,4 +140,10 @@ typedef MOUSE_CLICK_LISTENER_CALLBACK MOUSE_DBLCLK_LISTENER_CALLBACK;
|
|||
// 鼠标拖动消息监听回调函数(参数为拖动前位置和拖动后位置)
|
||||
typedef std::function<void(EPoint begin, EPoint end)> MOUSE_DRAG_LISTENER_CALLBACK;
|
||||
|
||||
// 物理世界消息监听器回调函数(参数:主动方、被动方、两方关系)
|
||||
typedef std::function<void(ENode *active, ENode *passive, int relation)> PHYSICS_LISTENER_CALLBACK;
|
||||
|
||||
// 碰撞消息监听器回调函数(参数:主动方、被动方)
|
||||
typedef std::function<void(ENode *active, ENode *passive)> COLLISION_LISTENER_CALLBACK;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue