CoriEngine
Loading...
Searching...
No Matches
WorldSystem/Systems/Physics.hpp
Go to the documentation of this file.
1#pragma once
2#include "System.hpp"
3#include "Physics/Physics.hpp"
4
5#ifndef CORI_PHYSICS_TASK_POOL_SIZE
6 #define CORI_PHYSICS_TASK_POOL_SIZE 64
7#endif
8
9namespace Cori {
10 namespace World {
11 namespace Systems {
16 class PhysicsSystem final : public System {
17 public:
18
19 void OnTickUpdate(Core::GameTimer& gameTimer) override;
20
21 bool Create(Physics::World::Params params);
22
27 Physics::WorldRef GetWorld() { return m_World; }
28
29 static constexpr SystemPriority Priority = 5;
30
31 static void* EnqueueTask(b2TaskCallback* task, int32_t itemCount, int32_t minRange, void* taskContext, void* userContext);
32 static void FinishTask(void* taskPtr, void* userContext);
33
34 private:
35 struct Box2DTaskGroup {
36 std::vector<std::future<void>> futures;
37 };
38
39 Physics::World m_World;
40
41 uint16_t m_WorkerCount{ 1 };
42 std::array<Box2DTaskGroup, CORI_PHYSICS_TASK_POOL_SIZE> m_TaskPool;
43 std::atomic<uint16_t> m_CurrentTaskIndex;
44
45 void OnRigidBodyCreate(entt::registry& registry, entt::entity entity);
46 };
47 }
48 }
49}
A GameTimer is responsible for managing everything that is connected with time, ticks,...
Definition Time.hpp:8
System(const System &)=delete
static void FinishTask(void *taskPtr, void *userContext)
bool Create(Physics::World::Params params)
void OnTickUpdate(Core::GameTimer &gameTimer) override
Physics::WorldRef GetWorld()
Retries the reference to the Box2D world.
static void * EnqueueTask(b2TaskCallback *task, int32_t itemCount, int32_t minRange, void *taskContext, void *userContext)
uint16_t SystemPriority
Definition Concept.hpp:5
Global engine namespace.