Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,34 @@ pub fn build(b: *std.Build) void {

const options_module = options_step.createModule();

_ = b.addModule("root", .{
const mod = b.addModule("root", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zmesh_options", .module = options_module },
},
});

const zmesh_lib = if (options.shared) blk: {
const lib = b.addSharedLibrary(.{
const lib = b.addLibrary(.{
.name = "zmesh",
.target = target,
.optimize = optimize,
.root_module = mod,
.linkage = .dynamic,
});

if (target.result.os.tag == .windows) {
lib.root_module.addCMacro("PAR_SHAPES_API", "__declspec(dllexport)");
lib.root_module.addCMacro("CGLTF_API", "__declspec(dllexport)");
lib.root_module.addCMacro("MESHOPTIMIZER_API", "__declspec(dllexport)");
lib.root_module.addCMacro("ZMESH_API", "__declspec(dllexport)");
mod.addCMacro("PAR_SHAPES_API", "__declspec(dllexport)");
mod.addCMacro("CGLTF_API", "__declspec(dllexport)");
mod.addCMacro("MESHOPTIMIZER_API", "__declspec(dllexport)");
mod.addCMacro("ZMESH_API", "__declspec(dllexport)");
}

break :blk lib;
} else b.addStaticLibrary(.{
} else b.addLibrary(.{
.name = "zmesh",
.target = target,
.optimize = optimize,
.root_module = mod,
.linkage = .static,
});
b.installArtifact(zmesh_lib);

Expand Down Expand Up @@ -93,13 +95,10 @@ pub fn build(b: *std.Build) void {

const tests = b.addTest(.{
.name = "zmesh-tests",
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.root_module = mod,
});
b.installArtifact(tests);

tests.linkLibrary(zmesh_lib);
tests.addIncludePath(b.path("libs/cgltf"));

test_step.dependOn(&b.addRunArtifact(tests).step);
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .zmesh,
.fingerprint = 0xb56bea39e6c0eda0,
.version = "0.11.0-dev",
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.1",
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
20 changes: 10 additions & 10 deletions src/Shape.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const builtin = @import("builtin");
const std = @import("std");
const assert = std.debug.assert;
const expect = std.testing.expect;
const builtin = @import("builtin");

const zmeshMalloc = @import("memory.zig").zmeshMalloc;

pub const IndexType: type = blk: {
Expand All @@ -25,10 +27,10 @@ texcoords: ?[][2]f32,
handle: ShapeHandle,

pub fn init(
indices: std.ArrayList(IndexType),
positions: std.ArrayList([3]f32),
maybe_normals: ?std.ArrayList([3]f32),
maybe_texcoords: ?std.ArrayList([2]f32),
indices: std.array_list.Managed(IndexType),
positions: std.array_list.Managed([3]f32),
maybe_normals: ?std.array_list.Managed([3]f32),
maybe_texcoords: ?std.array_list.Managed([2]f32),
) Shape {
const handle = par_shapes_create_empty();
const parmesh = @as(
Expand Down Expand Up @@ -248,7 +250,7 @@ pub const UvToPositionFn = *const fn (
uv: *const [2]f32,
position: *[3]f32,
userdata: ?*anyopaque,
) callconv(.C) void;
) callconv(.c) void;

pub fn initParametric(
fun: UvToPositionFn,
Expand Down Expand Up @@ -327,8 +329,6 @@ extern fn par_shapes_create_parametric(
extern fn par_shapes_create_empty() ShapeHandle;

const test_enable_write_to_disk = false;
const expect = std.testing.expect;

test "zmesh.basic" {
const zmesh = @import("root.zig");

Expand Down Expand Up @@ -461,13 +461,13 @@ test "zmesh.custom" {
zmesh.init(std.testing.allocator);
defer zmesh.deinit();

var positions = std.ArrayList([3]f32).init(std.testing.allocator);
var positions = std.array_list.Managed([3]f32).init(std.testing.allocator);
defer positions.deinit();
try positions.append(.{ 0.0, 0.0, 0.0 });
try positions.append(.{ 1.0, 0.0, 0.0 });
try positions.append(.{ 1.0, 0.0, 1.0 });

var indices = std.ArrayList(IndexType).init(std.testing.allocator);
var indices = std.array_list.Managed(IndexType).init(std.testing.allocator);
defer indices.deinit();
try indices.append(0);
try indices.append(1);
Expand Down
Loading
Loading