Skip to content

Commit 9ab6b83

Browse files
committed
- Remove usingnamespace usage
- Introduce a new system for interfaces: - They are defined as structs that are composed as the first member of the implementation - `initInterface` is used to build VTable default values at comptime automatically - Enhance the DebugRenderer test to verify that the render functions are called - Change the signature of DestroyTriangleBatch to pass non-const user pointer
1 parent 3b1f716 commit 9ab6b83

File tree

5 files changed

+676
-1038
lines changed

5 files changed

+676
-1038
lines changed

build.zig

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,18 @@ pub fn build(b: *std.Build) void {
5858
});
5959
zjolt.addIncludePath(b.path("libs/JoltC"));
6060

61-
const joltc = if (options.shared) blk: {
62-
const lib = b.addSharedLibrary(.{
63-
.name = "joltc",
61+
const joltc = b.addLibrary(.{
62+
.name = "joltc",
63+
.linkage = if (options.shared) .dynamic else .static,
64+
.root_module = b.createModule(.{
6465
.target = target,
6566
.optimize = optimize,
66-
});
67-
if (target.result.os.tag == .windows) {
68-
lib.root_module.addCMacro("JPC_API", "extern __declspec(dllexport)");
69-
}
70-
break :blk lib;
71-
} else b.addStaticLibrary(.{
72-
.name = "joltc",
73-
.target = target,
74-
.optimize = optimize,
67+
}),
7568
});
69+
70+
if (options.shared and target.result.os.tag == .windows)
71+
joltc.root_module.addCMacro("JPC_API", "extern __declspec(dllexport)");
72+
7673
b.installArtifact(joltc);
7774

7875
joltc.addIncludePath(b.path("libs"));
@@ -248,9 +245,11 @@ pub fn build(b: *std.Build) void {
248245

249246
const tests = b.addTest(.{
250247
.name = "zphysics-tests",
251-
.root_source_file = b.path("src/zphysics.zig"),
252-
.target = target,
253-
.optimize = optimize,
248+
.root_module = b.createModule(.{
249+
.root_source_file = b.path("src/zphysics.zig"),
250+
.target = target,
251+
.optimize = optimize,
252+
}),
254253
});
255254
b.installArtifact(tests);
256255

build.zig.zon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.name = .zphysics,
33
.fingerprint = 0x1def6aac00c4909d,
44
.version = "0.2.0-dev",
5+
.minimum_zig_version = "0.14.1",
56
.paths = .{
67
"build.zig",
78
"build.zig.zon",

libs/JoltC/JoltPhysicsC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ class DebugRendererImpl final : public JPH::DebugRenderer
741741
{
742742
if (sInstance && sInstance->c_renderer->vtbl->DestroyTriangleBatch)
743743
{
744-
sInstance->c_renderer->vtbl->DestroyTriangleBatch(sInstance->c_renderer, c_primitive);
744+
sInstance->c_renderer->vtbl->DestroyTriangleBatch(sInstance->c_renderer, (void*)c_primitive);
745745
}
746746
}
747747

libs/JoltC/JoltPhysicsC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ typedef struct JPC_DebugRendererVTable
10601060

10611061
// Optional
10621062
void
1063-
(*DestroyTriangleBatch)(void *in_self, const void *in_primitive);
1063+
(*DestroyTriangleBatch)(void *in_self, void *in_primitive);
10641064

10651065
// Required, *cannot* be NULL.
10661066
void

0 commit comments

Comments
 (0)