summaryrefslogtreecommitdiff
path: root/src/physics.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2024-11-14 14:46:23 -0500
committerJonathan Bradley <jcb@pikum.xyz>2024-11-14 14:46:23 -0500
commitb2548ba4ce295fcd94a50123fb543fac2ef2bc33 (patch)
tree444a32abb4a094c4fa2f7bc9a95aa86963ad4110 /src/physics.cpp
parentb1d926361b9d613ad712ad161f9a8b7ccab4551d (diff)
add pk.h and major pkmem refactor
Completely replaces the memory module with pkmem pkmem is a newer implementation of the same bucket memory structure. Also includes replacing pkstr.h with pk.h's pkstr
Diffstat (limited to 'src/physics.cpp')
-rw-r--r--src/physics.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/physics.cpp b/src/physics.cpp
index 88c8139..d939e21 100644
--- a/src/physics.cpp
+++ b/src/physics.cpp
@@ -13,7 +13,7 @@
TypeSafeInt_B(PhysicsCollision);
-MemBucket *MemBkt_Bullet = nullptr;
+struct pk_membucket *MemBkt_Bullet = nullptr;
btDiscreteDynamicsWorld *BtDynamicsWorld = nullptr;
struct AllocedData {
@@ -33,7 +33,7 @@ struct EntityCollision {
PkeArray<EntityCollision> collisionsThisTick{};
void *pke_btAlignedAllocFunc(size_t size, int alignment) {
- void *ptr = Pke_New(size, alignment, MemBkt_Bullet);
+ void *ptr = pk_new_bkt(size, alignment, MemBkt_Bullet);
bulletAllocs->Push({ptr, size});
return ptr;
}
@@ -48,11 +48,11 @@ void pke_btAlignedFreeFunc(void *memBlock) {
}
}
assert(index != -1);
- Pke_Delete(const_cast<void *>(memBlock), arr[index].size, MemBkt_Bullet);
+ pk_delete_bkt(memBlock, arr[index].size, MemBkt_Bullet);
bulletAllocs->Remove(index);
}
void *pke_btAllocFunc(size_t size) {
- void *ptr = Pke_New(size, MINIMUM_ALIGNMENT, MemBkt_Bullet);
+ void *ptr = pk_new_bkt(size, PK_MINIMUM_ALIGNMENT, MemBkt_Bullet);
bulletAllocs->Push({ptr, size});
return ptr;
}
@@ -67,7 +67,7 @@ void pke_btFreeFunc(void *memBlock) {
}
}
assert(index != -1);
- Pke_Delete(const_cast<void *>(memBlock), arr[index].size, MemBkt_Bullet);
+ pk_delete_bkt(memBlock, arr[index].size, MemBkt_Bullet);
bulletAllocs->Remove(index);
}
@@ -95,28 +95,28 @@ struct CollisionHandlerStruct : public btOverlapFilterCallback {
} collisionHandlerStruct;
void Physics_Init() {
- MemBkt_Bullet = Pke_BeginTransientBucket();
- bulletAllocs = Pke_New<DynArray<AllocedData>>(MemBkt_Bullet);
+ MemBkt_Bullet = pk_bucket_create("physics", PK_DEFAULT_BUCKET_SIZE, false);
+ bulletAllocs = pk_new<DynArray<AllocedData>>(MemBkt_Bullet);
new (bulletAllocs) DynArray<AllocedData>(MemBkt_Bullet);
bulletAllocs->Reserve(1024);
btAlignedAllocSetCustom(pke_btAllocFunc, pke_btFreeFunc);
btAlignedAllocSetCustomAligned(pke_btAlignedAllocFunc, pke_btAlignedFreeFunc);
- btConfiguration = Pke_New<btDefaultCollisionConfiguration>(MemBkt_Bullet);
- btDispatcher = Pke_New<btCollisionDispatcher>(MemBkt_Bullet);
+ btConfiguration = pk_new<btDefaultCollisionConfiguration>(MemBkt_Bullet);
+ btDispatcher = pk_new<btCollisionDispatcher>(MemBkt_Bullet);
new (btDispatcher) btCollisionDispatcher(btConfiguration);
- btBroadphase = Pke_New<btDbvtBroadphase>(MemBkt_Bullet);
+ btBroadphase = pk_new<btDbvtBroadphase>(MemBkt_Bullet);
#if 1
- btHashedOverlappingPairCache *overlappingPairCache = Pke_New<btHashedOverlappingPairCache>(MemBkt_Bullet);
+ btHashedOverlappingPairCache *overlappingPairCache = pk_new<btHashedOverlappingPairCache>(MemBkt_Bullet);
overlappingPairCache->setOverlapFilterCallback(&collisionHandlerStruct);
new (btBroadphase) btDbvtBroadphase(overlappingPairCache);
#else
new (btBroadphase) btDbvtBroadphase();
#endif
- btSolver = Pke_New<btSequentialImpulseConstraintSolver>(MemBkt_Bullet);
+ btSolver = pk_new<btSequentialImpulseConstraintSolver>(MemBkt_Bullet);
- BtDynamicsWorld = Pke_New<btDiscreteDynamicsWorld>(MemBkt_Bullet);
+ BtDynamicsWorld = pk_new<btDiscreteDynamicsWorld>(MemBkt_Bullet);
new (BtDynamicsWorld) btDiscreteDynamicsWorld(btDispatcher, btBroadphase, btSolver, btConfiguration);
}
@@ -132,5 +132,5 @@ int32_t Physics_Tick(double delta) {
}
void Physics_Teardown() {
- Pke_EndTransientBucket(MemBkt_Bullet);
+ pk_bucket_destroy(MemBkt_Bullet);
}