瀏覽代碼

JPC_PhysicsSystem

Lucien Greathouse 1 年之前
父節點
當前提交
9dcd0422f7
共有 3 個文件被更改,包括 21 次插入6 次删除
  1. 3 0
      HelloWorld/main.cpp
  2. 5 0
      JoltC/Functions.h
  3. 13 6
      JoltC/JoltC.cpp

+ 3 - 0
HelloWorld/main.cpp

@@ -11,6 +11,9 @@ int main() {
 
 	JPC_JobSystemThreadPool* job_system = JPC_JobSystemThreadPool_new2(JPC_MAX_PHYSICS_JOBS, JPC_MAX_PHYSICS_BARRIERS);
 
+	JPC_PhysicsSystem* physics_system = JPC_PhysicsSystem_new();
+
+	JPC_PhysicsSystem_delete(physics_system);
 	JPC_JobSystemThreadPool_delete(job_system);
 	JPC_TempAllocatorImpl_delete(temp_allocator);
 

+ 5 - 0
JoltC/Functions.h

@@ -30,6 +30,11 @@ JPC_API JPC_JobSystemThreadPool* JPC_JobSystemThreadPool_new3(
 
 JPC_API void JPC_JobSystemThreadPool_delete(JPC_JobSystemThreadPool* object);
 
+typedef struct JPC_PhysicsSystem JPC_PhysicsSystem;
+
+JPC_API JPC_PhysicsSystem* JPC_PhysicsSystem_new();
+JPC_API void JPC_PhysicsSystem_delete(JPC_PhysicsSystem* object);
+
 #ifdef __cplusplus
 }
 #endif

+ 13 - 6
JoltC/JoltC.cpp

@@ -5,6 +5,7 @@
 #include "Jolt/Core/JobSystemThreadPool.h"
 #include "Jolt/Core/Memory.h"
 #include "Jolt/Core/TempAllocator.h"
+#include "Jolt/Physics/PhysicsSystem.h"
 #include "Jolt/RegisterTypes.h"
 
 #include "JoltC/JoltC.h"
@@ -13,7 +14,13 @@
 	static auto to_jpc(cpp_type *in) { return reinterpret_cast<c_type*>(in); } \
 	static auto to_jph(c_type *in) { return reinterpret_cast<cpp_type*>(in); }
 
+#define DESTRUCTOR(c_type) \
+	JPC_API void c_type##_delete(c_type* object) { \
+		delete to_jph(object); \
+	}
+
 OPAQUE_WRAPPER(JPC_TempAllocatorImpl, JPH::TempAllocatorImpl)
+DESTRUCTOR(JPC_TempAllocatorImpl)
 
 JPC_API void JPC_RegisterDefaultAllocator() {
 	JPH::RegisterDefaultAllocator();
@@ -31,11 +38,8 @@ JPC_API JPC_TempAllocatorImpl* JPC_TempAllocatorImpl_new(uint size) {
 	return to_jpc(new JPH::TempAllocatorImpl(size));
 }
 
-JPC_API void JPC_TempAllocatorImpl_delete(JPC_TempAllocatorImpl* object) {
-	delete to_jph(object);
-}
-
 OPAQUE_WRAPPER(JPC_JobSystemThreadPool, JPH::JobSystemThreadPool)
+DESTRUCTOR(JPC_JobSystemThreadPool)
 
 JPC_API JPC_JobSystemThreadPool* JPC_JobSystemThreadPool_new2(
 	uint inMaxJobs,
@@ -52,6 +56,9 @@ JPC_API JPC_JobSystemThreadPool* JPC_JobSystemThreadPool_new3(
 	return to_jpc(new JPH::JobSystemThreadPool(inMaxJobs, inMaxBarriers, inNumThreads));
 }
 
-JPC_API void JPC_JobSystemThreadPool_delete(JPC_JobSystemThreadPool* object) {
-	delete to_jph(object);
+OPAQUE_WRAPPER(JPC_PhysicsSystem, JPH::PhysicsSystem)
+DESTRUCTOR(JPC_PhysicsSystem)
+
+JPC_API JPC_PhysicsSystem* JPC_PhysicsSystem_new() {
+	return to_jpc(new JPH::PhysicsSystem());
 }