TriggerSystem implemented and working.
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
#include "Core/Ray.h"
|
||||
#include "Core/AABB.h"
|
||||
#include "Engine/Rendering/RawModel.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
class World;
|
||||
struct ComponentWrapper;
|
||||
|
||||
namespace Collision
|
||||
{
|
||||
@@ -39,6 +43,10 @@ bool RayVsModel(const Ray& ray,
|
||||
bool AABBVsAABB(const AABB& a, const AABB& b);
|
||||
bool IsSameBoxProbably(const AABB& first, const AABB& second, const float epsilon = 0.0001f);
|
||||
|
||||
//Returns true if the entity has a boundingbox. Outputs the aabb in [outBox].
|
||||
bool GetEntityBox(World* world, EntityID entity, AABB& outBox, bool forceBoxFromModel = false);
|
||||
bool GetEntityBox(World* world, ComponentWrapper& AABBComponent, AABB& outBox);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,23 +10,21 @@
|
||||
|
||||
class AABB;
|
||||
|
||||
class TriggerSystem : public System
|
||||
class TriggerSystem : public PureSystem
|
||||
{
|
||||
public:
|
||||
TriggerSystem(EventBroker* eventBroker)
|
||||
: System(eventBroker, "Trigger")
|
||||
: PureSystem(eventBroker, "Trigger")
|
||||
{}
|
||||
|
||||
virtual void Update(World* world, ComponentWrapper& collision, double dt) override;
|
||||
virtual void UpdateComponent(World* world, ComponentWrapper& collision, double dt) override;
|
||||
|
||||
private:
|
||||
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesTouchingTrigger;
|
||||
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesCompletelyInTrigger;
|
||||
|
||||
bool getEntityBox(World* world, EntityID id, AABB& outBox);
|
||||
//True if leave event was thrown.
|
||||
bool throwLeaveIfWasInTrigger(std::unordered_set<EntityID>& triggerSet, EntityID pId, EntityID tId);
|
||||
void attachAABBComponentFromModel(World* world, EntityID id);
|
||||
template<typename Event>
|
||||
void publish(EntityID pId, EntityID tId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user