Added events for adding and removing colliders
This commit is contained in:
parent
12758878c5
commit
19ceab84df
|
@ -11,3 +11,6 @@ constexpr SHEventIdentifier SH_ENTITY_CREATION_EVENT { 2 };
|
|||
constexpr SHEventIdentifier SH_COMPONENT_ADDED_EVENT { 3 };
|
||||
constexpr SHEventIdentifier SH_COMPONENT_REMOVED_EVENT { 4 };
|
||||
constexpr SHEventIdentifier SH_SCENEGRAPH_CHANGE_PARENT_EVENT { 5 };
|
||||
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_ADDED_EVENT { 6 };
|
||||
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_REMOVED_EVENT { 7 };
|
||||
|
||||
|
|
|
@ -210,13 +210,29 @@ namespace SHADE
|
|||
void SHPhysicsSystem::AddCollisionShape(EntityID entityID, SHCollider* collider)
|
||||
{
|
||||
auto* physicsObject = GetPhysicsObject(entityID);
|
||||
physicsObject->AddCollider(collider);
|
||||
|
||||
const SHPhysicsColliderAddedEvent COLLIDER_ADDED_EVENT_DATA
|
||||
{
|
||||
.entityID = entityID
|
||||
, .colliderType = collider->GetType()
|
||||
, .colliderIndex = physicsObject->AddCollider(collider)
|
||||
};
|
||||
|
||||
SHEventManager::BroadcastEvent<SHPhysicsColliderAddedEvent>(COLLIDER_ADDED_EVENT_DATA, SH_PHYSICS_COLLIDER_ADDED_EVENT);
|
||||
}
|
||||
|
||||
void SHPhysicsSystem::RemoveCollisionShape(EntityID entityID, int index)
|
||||
{
|
||||
auto* physicsObject = GetPhysicsObject(entityID);
|
||||
physicsObject->RemoveCollider(index);
|
||||
|
||||
const SHPhysicsColliderRemovedEvent COLLIDER_REMOVED_EVENT_DATA
|
||||
{
|
||||
.entityID = entityID
|
||||
, .colliderIndex = index
|
||||
};
|
||||
|
||||
SHEventManager::BroadcastEvent<SHPhysicsColliderRemovedEvent>(COLLIDER_REMOVED_EVENT_DATA, SH_PHYSICS_COLLIDER_REMOVED_EVENT);
|
||||
}
|
||||
|
||||
void SHPhysicsSystem::PhysicsPreUpdate::Execute(double) noexcept
|
||||
|
|
|
@ -184,5 +184,21 @@ namespace SHADE
|
|||
SHEventHandle RemovePhysicsComponent (SHEventPtr removeComponentEvent);
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Event Data Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct SHPhysicsColliderAddedEvent
|
||||
{
|
||||
EntityID entityID;
|
||||
SHCollider::Type colliderType;
|
||||
int colliderIndex;
|
||||
};
|
||||
|
||||
struct SHPhysicsColliderRemovedEvent
|
||||
{
|
||||
EntityID entityID;
|
||||
int colliderIndex;
|
||||
};
|
||||
|
||||
} // namespace SHADE
|
|
@ -158,9 +158,13 @@ namespace SHADE
|
|||
|
||||
SHSceneNode* AllocateNode (EntityID entityID);
|
||||
void ReleaseNode (SHSceneNode* node) noexcept;
|
||||
static void TraverseAndInvokePredicate (const SHSceneNode* node, const UnaryFunction& predicate);
|
||||
static void TraverseAndInvokeFunction (const SHSceneNode* node, const UnaryFunction& function);
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Event Data Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct SHSceneGraphChangeParentEvent
|
||||
{
|
||||
SHSceneNode* node;
|
||||
|
|
Loading…
Reference in New Issue