// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #pragma once #include "Types.h" #include "Collisions.h" #include "Engine/Core/Types/Pair.h" #include "Colliders/Collider.h" #include /// /// Default implementation of the PxSimulationEventCallback to send physics events to the other engine services. /// /// class SimulationEventCallback : public PxSimulationEventCallback { public: typedef Pair CollidersPair; typedef Dictionary CollisionsPool; /// /// The collected collisions. /// CollisionsPool Collisions; /// /// The previous step collisions. /// CollisionsPool PrevCollisions; /// /// The new collisions (for enter event). /// Array NewCollisions; /// /// The old collisions (for exit event). /// Array RemovedCollisions; /// /// The new trigger pairs (for enter event). /// Array NewTriggerPairs; /// /// The removed trigger pairs (for exit event). /// Array LostTriggerPairs; /// /// The broken joints collection. /// Array BrokenJoints; public: /// /// Clears the data. /// void Clear() { PrevCollisions = Collisions; Collisions.Clear(); NewCollisions.Clear(); RemovedCollisions.Clear(); NewTriggerPairs.Clear(); LostTriggerPairs.Clear(); BrokenJoints.Clear(); } /// /// Generates the new/old/removed collisions and a valid trigger pairs. /// void CollectResults(); /// /// Sends the collision events to the managed objects. /// void SendCollisionEvents(); /// /// Sends the trigger events to the managed objects. /// void SendTriggerEvents(); /// /// Sends the joint events to the managed objects. /// void SendJointEvents(); /// /// Called when collider gets removed so all cached events should be removed for this object. /// Prevents sending events and using deleted objects. /// /// The collider. void OnColliderRemoved(PhysicsColliderActor* collider); /// /// Called when joint gets removed so all cached events should be removed for this object. /// Prevents sending events and using deleted objects. /// /// The joint. void OnJointRemoved(Joint* joint); public: // [PxSimulationEventCallback] void onConstraintBreak(PxConstraintInfo* constraints, PxU32 count) override; void onWake(PxActor** actors, PxU32 count) override; void onSleep(PxActor** actors, PxU32 count) override; void onContact(const PxContactPairHeader& pairHeader, const PxContactPair* pairs, PxU32 nbPairs) override; void onTrigger(PxTriggerPair* pairs, PxU32 count) override; void onAdvance(const PxRigidBody* const* bodyBuffer, const PxTransform* poseBuffer, const PxU32 count) override; };