summaryrefslogtreecommitdiff
path: root/src/ecs.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-10-20 16:26:16 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-11-15 13:06:16 -0500
commit4cd5b991a6c4cd3bd8f052a052df03485f1d8526 (patch)
tree37ab672c69854b4fae85e4de82844cd0c858e2f2 /src/ecs.cpp
parent1513216876a0409f45d88cbad14ae8b48fca37e2 (diff)
add bullet dependency first pass
Diffstat (limited to 'src/ecs.cpp')
-rw-r--r--src/ecs.cpp23
1 files changed, 23 insertions, 0 deletions
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 <btBulletDynamicsCommon.h>
+
TypeSafeInt_B(EntityHandle);
const uint64_t maxBucketItemCount = 256;
@@ -28,6 +31,13 @@ BucketContainer<EntityBucket, EntityHandle_T> Entities_BucketContainer{};
BucketContainer<GrBindsBucket, GrBindsHandle_T> Comp_GrBinds_BucketContainer{};
BucketContainer<InstanceBucket, InstanceHandle_T> 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<EntityHandle_T>(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<btDefaultCollisionConfiguration>(bulletBucket);
+ btDispatcher = Pke_New<btCollisionDispatcher>(bulletBucket);
+ new (btDispatcher) btCollisionDispatcher(btConfiguration);
+ btBroadphase = Pke_New<btDbvtBroadphase>(bulletBucket);
+ btSolver = Pke_New<btSequentialImpulseConstraintSolver>(bulletBucket);
+ btDynamicsWorld = Pke_New<btDiscreteDynamicsWorld>(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();