68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/Physics/PhysicsEvents.h>
|
|
#include <XCEngine/Physics/RaycastHit.h>
|
|
#include <XCEngine/Physics/PhysicsTypes.h>
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace Components {
|
|
|
|
class Component;
|
|
|
|
} // namespace Components
|
|
} // namespace XCEngine
|
|
|
|
namespace XCEngine {
|
|
namespace Physics {
|
|
|
|
class PhysXWorldBackend;
|
|
|
|
class PhysicsWorld {
|
|
public:
|
|
PhysicsWorld();
|
|
~PhysicsWorld();
|
|
|
|
static bool IsPhysXAvailable();
|
|
|
|
bool Initialize(const PhysicsWorldCreateInfo& createInfo);
|
|
void Shutdown();
|
|
void Step(float fixedDeltaTime);
|
|
void ConsumeSimulationEvents(std::vector<PhysicsEvent>& outEvents);
|
|
bool Raycast(
|
|
const Math::Vector3& origin,
|
|
const Math::Vector3& direction,
|
|
float maxDistance,
|
|
RaycastHit& outHit);
|
|
|
|
bool IsInitialized() const { return m_initialized; }
|
|
const PhysicsWorldCreateInfo& GetCreateInfo() const { return m_createInfo; }
|
|
size_t GetTrackedRigidbodyCount() const { return m_trackedRigidbodyCount; }
|
|
size_t GetTrackedColliderCount() const { return m_trackedColliderCount; }
|
|
size_t GetNativeActorCount() const;
|
|
size_t GetNativeShapeCount() const;
|
|
|
|
private:
|
|
void AttachSceneEventHandlers(Components::Scene* scene);
|
|
void DetachSceneEventHandlers();
|
|
void RebuildTrackedSceneState();
|
|
void TrackGameObjectComponents(Components::GameObject* gameObject, int delta);
|
|
void TrackComponent(Components::Component* component, int delta);
|
|
|
|
PhysicsWorldCreateInfo m_createInfo;
|
|
bool m_initialized = false;
|
|
uint64_t m_componentAddedSubscriptionId = 0;
|
|
uint64_t m_componentRemovedSubscriptionId = 0;
|
|
uint64_t m_gameObjectDestroyedSubscriptionId = 0;
|
|
size_t m_trackedRigidbodyCount = 0;
|
|
size_t m_trackedColliderCount = 0;
|
|
std::unique_ptr<PhysXWorldBackend> m_backend;
|
|
};
|
|
|
|
} // namespace Physics
|
|
} // namespace XCEngine
|