From 4cd5b991a6c4cd3bd8f052a052df03485f1d8526 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Fri, 20 Oct 2023 16:26:16 -0400 Subject: add bullet dependency first pass --- src/ecs.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/ecs.cpp') diff --git a/src/ecs.cpp b/src/ecs.cpp index b4207f8..17c5a89 100644 --- a/src/ecs.cpp +++ b/src/ecs.cpp @@ -1,9 +1,12 @@ #include "ecs.hpp" +#include "memory.hpp" #include "vendor/glm_include.hpp" #include "window.hpp" +#include + TypeSafeInt_B(EntityHandle); const uint64_t maxBucketItemCount = 256; @@ -28,6 +31,13 @@ BucketContainer Entities_BucketContainer{}; BucketContainer Comp_GrBinds_BucketContainer{}; BucketContainer Comp_Instance_BucketContainer{}; +MemBucket *bulletBucket = nullptr; +btDefaultCollisionConfiguration *btConfiguration = nullptr; +btCollisionDispatcher *btDispatcher = nullptr; +btBroadphaseInterface *btBroadphase = nullptr; +btConstraintSolver *btSolver = nullptr; +btDiscreteDynamicsWorld *btDynamicsWorld = nullptr; + void ECS_GetEntity_Inner(EntityHandle entHandle, Entity*& ent) { EntityHandle_T entHandle_t{static_cast(entHandle)}; assert(entHandle_t != EntityHandle_T_MAX && "Unknown entity handle"); @@ -40,6 +50,18 @@ void ECS_Init() { Buckets_Init(Entities_BucketContainer); Buckets_Init(Comp_GrBinds_BucketContainer); Buckets_Init(Comp_Instance_BucketContainer); + // bullet + { + bulletBucket = Pke_BeginTransientBucket(); + btConfiguration = Pke_New(bulletBucket); + btDispatcher = Pke_New(bulletBucket); + new (btDispatcher) btCollisionDispatcher(btConfiguration); + btBroadphase = Pke_New(bulletBucket); + btSolver = Pke_New(bulletBucket); + btDynamicsWorld = Pke_New(bulletBucket); + new (btDynamicsWorld) btDiscreteDynamicsWorld(btDispatcher, btBroadphase, btSolver, btConfiguration); + btDynamicsWorld->setGravity(btVector3(0, -1, 0)); + } } uint64_t ECS_GetEntities_BucketCount() { @@ -401,6 +423,7 @@ CompInstance *ECS_GetInstances(uint64_t bucketIndex, uint64_t &itemCount) { } void ECS_Teardown() { + Pke_EndTransientBucket(bulletBucket); EntitiesWithExcessInstances.~DynArray(); entitiesYetToBeRemoved.~DynArray(); EntitiesToBeRemoved.~DynArray(); -- cgit v1.2.3