소스 검색

Bind MutableCompoundShape and start using concrete shape types

Lucien Greathouse 5 달 전
부모
커밋
7b7ce96c59
2개의 변경된 파일61개의 추가작업 그리고 5개의 파일을 삭제
  1. 22 3
      JoltC/Functions.h
  2. 39 2
      JoltCImpl/JoltC.cpp

+ 22 - 3
JoltC/Functions.h

@@ -779,7 +779,26 @@ JPC_API void JPC_StaticCompoundShapeSettings_default(JPC_StaticCompoundShapeSett
 JPC_API bool JPC_StaticCompoundShapeSettings_Create(const JPC_StaticCompoundShapeSettings* self, JPC_Shape** outShape, JPC_String** outError);
 
 ////////////////////////////////////////////////////////////////////////////////
-// MutableCompoundShape -> CompoundShapeSettings -> ShapeSettings
+// MutableCompoundShape -> CompoundShape -> Shape
+
+typedef struct JPC_MutableCompoundShape JPC_MutableCompoundShape;
+
+JPC_API uint JPC_MutableCompoundShape_AddShape(
+	JPC_MutableCompoundShape* self,
+	JPC_Vec3 inPosition,
+	JPC_Quat inRotation,
+	const JPC_Shape* inShape,
+	uint32_t inUserData);
+
+JPC_API void JPC_MutableCompoundShape_RemoveShape(JPC_MutableCompoundShape* self, uint inIndex);
+JPC_API void JPC_MutableCompoundShape_ModifyShape(JPC_MutableCompoundShape* self, uint inIndex, JPC_Vec3 inPosition, JPC_Quat inRotation);
+JPC_API void JPC_MutableCompoundShape_ModifyShape2(JPC_MutableCompoundShape* self, uint inIndex, JPC_Vec3 inPosition, JPC_Quat inRotation, const JPC_Shape* inShape);
+
+// TODO:
+// JPC_API void JPC_MutableCompoundShape_ModifyShapes(JPC_MutableCompoundShape* self);
+
+////////////////////////////////////////////////////////////////////////////////
+// MutableCompoundShapeSettings -> CompoundShapeSettings -> ShapeSettings
 
 typedef struct JPC_MutableCompoundShapeSettings {
 	// ShapeSettings
@@ -789,12 +808,12 @@ typedef struct JPC_MutableCompoundShapeSettings {
 	const JPC_SubShapeSettings* SubShapes;
 	size_t SubShapesLen;
 
-	// MutableCompoundShape
+	// MutableCompoundShapeSettings
 	// (no fields)
 } JPC_MutableCompoundShapeSettings;
 
 JPC_API void JPC_MutableCompoundShapeSettings_default(JPC_MutableCompoundShapeSettings* object);
-JPC_API bool JPC_MutableCompoundShapeSettings_Create(const JPC_MutableCompoundShapeSettings* self, JPC_Shape** outShape, JPC_String** outError);
+JPC_API bool JPC_MutableCompoundShapeSettings_Create(const JPC_MutableCompoundShapeSettings* self, JPC_MutableCompoundShape** outShape, JPC_String** outError);
 
 ////////////////////////////////////////////////////////////////////////////////
 // BodyCreationSettings

+ 39 - 2
JoltCImpl/JoltC.cpp

@@ -1210,6 +1210,43 @@ JPC_API bool JPC_StaticCompoundShapeSettings_Create(const JPC_StaticCompoundShap
 	return HandleShapeResult(settings.Create(), outShape, outError);
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// MutableCompoundShape -> CompoundShape -> Shape
+
+JPC_IMPL JPH::MutableCompoundShape* JPC_MutableCompoundShape_to_jph(JPC_MutableCompoundShape* self) {
+	return reinterpret_cast<JPH::MutableCompoundShape*>(self);
+}
+
+JPC_API uint JPC_MutableCompoundShape_AddShape(
+	JPC_MutableCompoundShape* self,
+	JPC_Vec3 inPosition,
+	JPC_Quat inRotation,
+	const JPC_Shape* inShape,
+	uint32_t inUserData)
+{
+	JPH::MutableCompoundShape* self_jph = JPC_MutableCompoundShape_to_jph(self);
+
+	return self_jph->AddShape(to_jph(inPosition), to_jph(inRotation), to_jph(inShape), inUserData);
+}
+
+JPC_API void JPC_MutableCompoundShape_RemoveShape(JPC_MutableCompoundShape* self, uint inIndex) {
+	JPH::MutableCompoundShape* self_jph = JPC_MutableCompoundShape_to_jph(self);
+
+	self_jph->RemoveShape(inIndex);
+}
+
+JPC_API void JPC_MutableCompoundShape_ModifyShape(JPC_MutableCompoundShape* self, uint inIndex, JPC_Vec3 inPosition, JPC_Quat inRotation) {
+	JPH::MutableCompoundShape* self_jph = JPC_MutableCompoundShape_to_jph(self);
+
+	self_jph->ModifyShape(inIndex, to_jph(inPosition), to_jph(inRotation));
+}
+
+JPC_API void JPC_MutableCompoundShape_ModifyShape2(JPC_MutableCompoundShape* self, uint inIndex, JPC_Vec3 inPosition, JPC_Quat inRotation, const JPC_Shape* inShape) {
+	JPH::MutableCompoundShape* self_jph = JPC_MutableCompoundShape_to_jph(self);
+
+	self_jph->ModifyShape(inIndex, to_jph(inPosition), to_jph(inRotation), to_jph(inShape));
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // MutableCompoundShapeSettings -> CompoundShapeSettings -> ShapeSettings
 
@@ -1226,11 +1263,11 @@ JPC_API void JPC_MutableCompoundShapeSettings_default(JPC_MutableCompoundShapeSe
 	object->SubShapesLen = 0;
 }
 
-JPC_API bool JPC_MutableCompoundShapeSettings_Create(const JPC_MutableCompoundShapeSettings* self, JPC_Shape** outShape, JPC_String** outError) {
+JPC_API bool JPC_MutableCompoundShapeSettings_Create(const JPC_MutableCompoundShapeSettings* self, JPC_MutableCompoundShape** outShape, JPC_String** outError) {
 	JPH::MutableCompoundShapeSettings settings;
 	to_jph(self, &settings);
 
-	return HandleShapeResult(settings.Create(), outShape, outError);
+	return HandleShapeResult(settings.Create(), (JPC_Shape**)outShape, outError);
 }
 
 ////////////////////////////////////////////////////////////////////////////////