Skip to content

Commit 2e54368

Browse files
committed
- Add DestroyTriangleBatch
1 parent cf48eb9 commit 2e54368

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

libs/JoltC/JoltPhysicsC.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,14 @@ class DebugRendererImpl final : public JPH::DebugRenderer
735735
{
736736
public:
737737
JPH_OVERRIDE_NEW_DELETE
738-
BatchImpl(const JPC_DebugRenderer_Primitive *prim) : RenderPrimitive(prim) { }
738+
BatchImpl(const JPC_DebugRenderer_Primitive *c_primitive) : RenderPrimitive(c_primitive) {}
739+
~BatchImpl()
740+
{
741+
if (sInstance && sInstance->c_renderer->vtbl->DestroyTriangleBatch)
742+
{
743+
sInstance->c_renderer->vtbl->DestroyTriangleBatch(sInstance->c_renderer, c_primitive);
744+
}
745+
}
739746

740747
virtual void AddRef() override
741748
{

libs/JoltC/JoltPhysicsC.h

+4
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,10 @@ typedef struct JPC_DebugRendererVTable
10481048
const uint32_t *in_indices,
10491049
uint32_t in_index_count);
10501050

1051+
// Optional
1052+
void
1053+
(*DestroyTriangleBatch)(void *in_self, const void *in_primitive);
1054+
10511055
// Required, *cannot* be NULL.
10521056
void
10531057
(*DrawGeometry)(void *in_self,

src/zphysics.zig

+4-1
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,6 @@ pub const DebugRenderer = if (!debug_renderer_enabled) extern struct {} else ext
12781278

12791279
pub fn destroySingleton() void {
12801280
_ = c.JPC_DestroyDebugRendererSingleton(); // For Zig API, don't care if one actually existed, discard error.
1281-
12821281
}
12831282

12841283
pub fn createTriangleBatch(primitive_in: *const anyopaque) *TriangleBatch {
@@ -1422,6 +1421,10 @@ pub const DebugRenderer = if (!debug_renderer_enabled) extern struct {} else ext
14221421
indices: [*]u32,
14231422
index_count: u32,
14241423
) callconv(.C) *anyopaque = null,
1424+
destroyTriangleBatch: ?*const fn (
1425+
self: *T,
1426+
batch: *const anyopaque,
1427+
) callconv(.C) void = null,
14251428
drawGeometry: ?*const fn (
14261429
self: *T,
14271430
model_matrix: *const RMatrix,

0 commit comments

Comments
 (0)