Browse Source

IndexedTriangleList and related types

Lucien Greathouse 1 year ago
parent
commit
08368befe7
3 changed files with 33 additions and 1 deletions
  1. 21 0
      JoltC/Functions.h
  2. 11 0
      JoltC/JoltC.cpp
  3. 1 1
      JoltC/Test.cpp

+ 21 - 0
JoltC/Functions.h

@@ -91,6 +91,19 @@ ENSURE_SIZE_ALIGN(JPC_BroadPhaseLayer, JPH::BroadPhaseLayer)
 
 ENSURE_SIZE_ALIGN(JPC_ObjectLayer, JPH::ObjectLayer)
 
+typedef struct JPC_IndexedTriangleNoMaterial {
+	uint32_t idx[3];
+} JPC_IndexedTriangleNoMaterial;
+
+ENSURE_SIZE_ALIGN(JPC_IndexedTriangleNoMaterial, JPH::IndexedTriangleNoMaterial)
+
+typedef struct JPC_IndexedTriangle {
+	uint32_t idx[3];
+	uint32_t materialIndex;
+} JPC_IndexedTriangle;
+
+ENSURE_SIZE_ALIGN(JPC_IndexedTriangle, JPH::IndexedTriangle)
+
 ////////////////////////////////////////////////////////////////////////////////
 // VertexList == Array<Float3> == std::vector<Float3>
 
@@ -99,6 +112,14 @@ typedef struct JPC_VertexList JPC_VertexList;
 JPC_API JPC_VertexList* JPC_VertexList_new(const JPC_Float3* storage, size_t len);
 JPC_API void JPC_VertexList_delete(JPC_VertexList* object);
 
+////////////////////////////////////////////////////////////////////////////////
+// IndexedTriangleList == Array<IndexedTriangle> == std::vector<IndexedTriangle>
+
+typedef struct JPC_IndexedTriangleList JPC_IndexedTriangleList;
+
+JPC_API JPC_IndexedTriangleList* JPC_IndexedTriangleList_new(const JPC_IndexedTriangle* storage, size_t len);
+JPC_API void JPC_IndexedTriangleList_delete(JPC_IndexedTriangleList* object);
+
 ////////////////////////////////////////////////////////////////////////////////
 // TempAllocatorImpl
 

+ 11 - 0
JoltC/JoltC.cpp

@@ -57,6 +57,9 @@ OPAQUE_WRAPPER(JPC_Body, JPH::Body)
 OPAQUE_WRAPPER(JPC_VertexList, JPH::VertexList)
 DESTRUCTOR(JPC_VertexList)
 
+OPAQUE_WRAPPER(JPC_IndexedTriangleList, JPH::IndexedTriangleList)
+DESTRUCTOR(JPC_IndexedTriangleList)
+
 OPAQUE_WRAPPER(JPC_String, JPH::String)
 DESTRUCTOR(JPC_String)
 
@@ -126,6 +129,14 @@ JPC_API JPC_VertexList* JPC_VertexList_new(const JPC_Float3* storage, size_t len
 	return to_jpc(new JPH::VertexList(new_storage, new_storage + len));
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// IndexedTriangleList == Array<IndexedTriangle> == std::vector<IndexedTriangle>
+
+JPC_API JPC_IndexedTriangleList* JPC_IndexedTriangleList_new(const JPC_IndexedTriangle* storage, size_t len) {
+	const JPH::IndexedTriangle* new_storage = (const JPH::IndexedTriangle*)storage;
+	return to_jpc(new JPH::IndexedTriangleList(new_storage, new_storage + len));
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // TempAllocatorImpl
 

+ 1 - 1
JoltC/Test.cpp

@@ -36,7 +36,7 @@ constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type
 #define ENSURE_SIZE_ALIGN(c_type, cpp_type) \
     static_assert(sizeof(c_type) == sizeof(cpp_type), "size of " #c_type " did not match size of " #cpp_type); \
     static_assert(alignof(c_type) == alignof(cpp_type), "align of " #c_type " did not match align of " #cpp_type); \
-    static_assert(std::is_standard_layout<cpp_type>::value, #cpp_type " is not standard layout");
+    static_assert(!std::is_polymorphic_v<cpp_type>, #cpp_type " is polymorphic and cannot be mirrored");
 
 #define unsafe_offsetof(st, m) ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))
 #define unsafe_fieldtype(st, m) decltype((st *)(0)->m)