diff --git a/.gitmodules b/.gitmodules index fc015f8..443fbff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "raylib"] path = raylib - url = https://github.com/raysan5/raylib + url = git@forge.irithice.cc:irithice/raylib-voxel.git [submodule "znoise"] path = znoise url = https://github.com/zig-gamedev/znoise diff --git a/raylib b/raylib index a5639bb..77e6260 160000 --- a/raylib +++ b/raylib @@ -1 +1 @@ -Subproject commit a5639bb186f5c5644c1eee02f5954320637cfb02 +Subproject commit 77e626060d3c5419c539edfa4fe4f268f9015ade diff --git a/resources/images/ambient_occlusion.png b/resources/images/ambient_occlusion.png new file mode 100644 index 0000000..9b56dcf Binary files /dev/null and b/resources/images/ambient_occlusion.png differ diff --git a/resources/images/tiles.png b/resources/images/tiles.png index 9f807c7..4d91f61 100644 Binary files a/resources/images/tiles.png and b/resources/images/tiles.png differ diff --git a/resources/images/tiles.png~ b/resources/images/tiles.png~ index 8eafed8..9f807c7 100644 Binary files a/resources/images/tiles.png~ and b/resources/images/tiles.png~ differ diff --git a/resources/scripts/ambient_occlusion_texture_generator.py b/resources/scripts/ambient_occlusion_texture_generator.py new file mode 100644 index 0000000..8b9aa2c --- /dev/null +++ b/resources/scripts/ambient_occlusion_texture_generator.py @@ -0,0 +1,100 @@ +from PIL import Image, ImageFilter +import random +import math + +SQUARE_SIZE = 32 +SQUARES = 2**8 +ITERATIONS_PER_PIXEL = 1000 +COORDS = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)] + + +def random_point_on_sphere(): + theta = random.uniform(0, 2 * math.pi) + phi = math.acos(random.uniform(-1, 1)) + x = math.sin(phi) * math.cos(theta) + y = math.sin(phi) * math.sin(theta) + z = math.cos(phi) + return [x, y, z] + + +calculated_squares = dict() +with Image.new("RGBA", (SQUARE_SIZE*SQUARES, SQUARE_SIZE), "black") as im: + px = im.load() + + for square_id in range(SQUARES): + print(f"square {square_id}: ", end="") + square = square_id + + # if 2 side touching tiles are obscuring, then we can assume the corner is obscuring as well + if square & (1 << 6) > 0 and square & (1 << 4) > 0: + square = square | (1 << 5) + if square & (1 << 4) > 0 and square & (1 << 2) > 0: + square = square | (1 << 3) + if square & (1 << 2) > 0 and square & (1 << 0) > 0: + square = square | (1 << 1) + if square & (1 << 0) > 0 and square & (1 << 6) > 0: + square = square | (1 << 7) + + # check if we've already done the task in a rotated variation + instance_found = False + for rotation in range(4): # clockwise rotations by pi/2 + rotated_square = (square >> (rotation * 2)) | ((square & ((1 << rotation*2)-1)) << 2*(4 - rotation)) + if rotated_square in calculated_squares: + square_id_from = calculated_squares[rotated_square] + print(f"already calculated at {square_id_from}") + + box_from = (SQUARE_SIZE*square_id_from, 0, SQUARE_SIZE*(square_id_from+1), SQUARE_SIZE) + box_to = (SQUARE_SIZE*square_id, 0, SQUARE_SIZE*(square_id+1), SQUARE_SIZE) + region = im.crop(box_from) + if rotation == 1: + region = region.transpose(Image.Transpose.ROTATE_270) + if rotation == 2: + region = region.transpose(Image.Transpose.ROTATE_180) + if rotation == 3: + region = region.transpose(Image.Transpose.ROTATE_90) + im.paste(region, box_to) + + instance_found = True + break + if instance_found: + continue + + # actually calculate the occlusion + obscured = [i for c, i in enumerate(COORDS) if (square >> c) & 1 == 1] + for x in range(SQUARE_SIZE): + for y in range(SQUARE_SIZE): + point_coord = ((x+0.5)/SQUARE_SIZE-0.5, (y+0.5)/SQUARE_SIZE-0.5, 0) + count = 0 + for i in range(ITERATIONS_PER_PIXEL): + point = random_point_on_sphere() + point[0] += point_coord[0] + point[1] += point_coord[1] + rounded_point = (round(point[0]), round(point[1])) + if rounded_point in obscured: + count += 1 + result_color = 255-255*count//ITERATIONS_PER_PIXEL + px[x+square_id*SQUARE_SIZE, y] = (result_color, result_color, result_color, 255) + calculated_squares[square] = square_id + + # smooth it + box = (SQUARE_SIZE*square_id, 0, SQUARE_SIZE*(square_id+1), SQUARE_SIZE) + region = im.crop(box) + region = region.filter(filter=ImageFilter.GaussianBlur(2)) + im.paste(region, box) + + print(f"calculated") + + print(f"total squares calculated: {len(calculated_squares)}") + + # result_side_length = int(SQUARES**0.5) + # with Image.new("RGBA", (SQUARE_SIZE*result_side_length, SQUARE_SIZE*result_side_length), "black") as new_im: + # for i in range(result_side_length): + # box_from = (SQUARE_SIZE*result_side_length*i, 0, SQUARE_SIZE*result_side_length*(i+1), SQUARE_SIZE) + # box_to = (0, SQUARE_SIZE*i, SQUARE_SIZE*result_side_length, SQUARE_SIZE*(i+1)) + # new_im.paste(im.crop(box_from), box_to) + # new_im.show() + # new_im.save("../images/ambient_occlusion.png") + + im.show() + im.save("../images/ambient_occlusion.png") + diff --git a/resources/shaders/tiling.fs b/resources/shaders/tiling.fs index cf89965..7430751 100644 --- a/resources/shaders/tiling.fs +++ b/resources/shaders/tiling.fs @@ -1,43 +1,69 @@ #version 330 core uniform sampler2D diffuseMap; +uniform sampler2D occlusionMap; uniform vec2 textureTiling; in vec2 fragTexCoord; in vec3 fragNormal; in vec2 fragTileTexCoord; -flat in int ambientOcclusionSide1; -flat in int ambientOcclusionSide2; -flat in int ambientOcclusionCorner1; -flat in int ambientOcclusionCorner2; -flat in int ambientOcclusionCorner3; + +flat in uvec4 occlusionSides; +flat in int topLeftObscured; +flat in int topRightObscured; +flat in int bottomLeftObscured; +flat in int bottomRightObscured; flat in int quadHeight; flat in int quadWidth; out vec4 outColor; -// this is a shitty approximation of arcsin(x)/pi that gets the tails right and is reasonably close to the actual arcsin(x)/pi curve. -float fakeArcsin(float x) { - x = clamp(x, -1.0, 1.0); - float ax = abs(x); - float sqrtPart = sqrt(1.0 - ax); - float result = 0.5 - sqrtPart * (0.5 - 0.06667 * ax); - return x < 0.0 ? -result : result; +int calculate_ao_square() +{ + ivec2 tileCoord = ivec2(fragTileTexCoord); + int ao_square = 0; + + if(tileCoord.x == quadWidth - 1 && ((occlusionSides.x & uint(1 << tileCoord.y)) > uint(0))) ao_square |= 1 << 0; + + if(tileCoord.x == quadWidth - 1 && tileCoord.y == quadHeight - 1 && bottomRightObscured > 0) ao_square |= 1 << 1; + if(tileCoord.x == quadWidth - 1 && tileCoord.y != quadHeight - 1 && ((occlusionSides.x & uint(1 << (tileCoord.y+1))) > uint(0))) ao_square |= 1 << 1; + if(tileCoord.x != quadWidth - 1 && tileCoord.y == quadHeight - 1 && ((occlusionSides.w & uint(1 << (tileCoord.x+1))) > uint(0))) ao_square |= 1 << 1; + + if(tileCoord.y == quadHeight - 1 && ((occlusionSides.w & uint(1 << tileCoord.x)) > uint(0))) ao_square |= 1 << 2; + + if(tileCoord.x == 0 && tileCoord.y == quadHeight - 1 && bottomLeftObscured > 0) ao_square |= 1 << 3; + if(tileCoord.x == 0 && tileCoord.y != quadHeight - 1 && ((occlusionSides.y & uint(1 << (tileCoord.y+1))) > uint(0))) ao_square |= 1 << 3; + if(tileCoord.x != 0 && tileCoord.y == quadHeight - 1 && ((occlusionSides.w & uint(1 << (tileCoord.x-1))) > uint(0))) ao_square |= 1 << 3; + + if(tileCoord.x == 0 && ((occlusionSides.y & uint(1 << tileCoord.y)) > uint(0))) ao_square |= 1 << 4; + + if(tileCoord.x == 0 && tileCoord.y == 0 && topRightObscured > 0) ao_square |= 1 << 5; + if(tileCoord.x == 0 && tileCoord.y != 0 && ((occlusionSides.y & uint(1 << (tileCoord.y-1))) > uint(0))) ao_square |= 1 << 5; + if(tileCoord.x != 0 && tileCoord.y == 0 && ((occlusionSides.z & uint(1 << (tileCoord.x-1))) > uint(0))) ao_square |= 1 << 5; + + if(tileCoord.y == 0 && ((occlusionSides.z & uint(1 << tileCoord.x)) > uint(0))) ao_square |= 1 << 6; + + if(tileCoord.x == quadWidth - 1 && tileCoord.y == 0 && topLeftObscured > 0) ao_square |= 1 << 7; + if(tileCoord.x == quadWidth - 1 && tileCoord.y != 0 && ((occlusionSides.x & uint(1 << (tileCoord.y-1))) > uint(0))) ao_square |= 1 << 7; + if(tileCoord.x != quadWidth - 1 && tileCoord.y == 0 && ((occlusionSides.z & uint(1 << (tileCoord.x+1))) > uint(0))) ao_square |= 1 << 7; + + return ao_square; } void main() { vec2 texCoord = (floor(fragTexCoord*textureTiling) + fract(fragTileTexCoord)) / textureTiling; + + int ao_square = calculate_ao_square(); + outColor = texture(diffuseMap, texCoord); - - ivec2 floorFragTileTexCoord = ivec2(fragTileTexCoord); - - if(fragTileTexCoord.x < 1 && (((ambientOcclusionSide1 >> floorFragTileTexCoord.y) & 1) == 1)) outColor *= 0.5 + fakeArcsin(fragTileTexCoord.x); - - // if(fragTileTexCoord.x < 0.125 && fragTileTexCoord.x < fract(fragTileTexCoord.y) && fragTileTexCoord.x + fract(fragTileTexCoord.y) < 1.0 && ((ambientOcclusionSide1 >> floorFragTileTexCoord.y) & 1) == 1) outColor *= 0.5; - - //if((fragTileTexCoord.x < 0.25 || fragTileTexCoord.x > quadWidth-0.25) && (((ambientOcclusionSide1 >> floorFragTileTexCoord.y) & 1) == 1)) outColor *= 0.5; - //if((fragTileTexCoord.y < 0.25 || fragTileTexCoord.y > quadHeight-0.25) && (((ambientOcclusionSide2 >> floorFragTileTexCoord.y) & 1) == 1)) outColor *= 0.5; + outColor *= texture(occlusionMap, (vec2(ao_square, 0)+fract(fragTileTexCoord))/vec2(256, 1)); outColor.a = 1; + + //uint bit = uint(fragTileTexCoord * 32); + //outColor.g = (((uint(quadWidth) >> bit) & uint(1)) == uint(1)) ? + // ((bit % uint(2) == uint(0)) ? 1.0 : 0.8): + // ((bit % uint(2) == uint(0)) ? 0.0 : 0.2); } + diff --git a/resources/shaders/tiling.vs b/resources/shaders/tiling.vs index 6148ca7..5fa028f 100644 --- a/resources/shaders/tiling.vs +++ b/resources/shaders/tiling.vs @@ -4,17 +4,18 @@ in vec3 vertexPosition; in vec2 vertexTexCoord; in vec3 vertexNormal; in vec2 vertexTileTexCoord; -in vec4 vertexMetadata1; +in uvec4 vertexMetadata1; +in uvec4 vertexOcclusionSides; out vec2 fragTexCoord; out vec3 fragNormal; out vec2 fragTileTexCoord; -flat out int ambientOcclusionSide1; -flat out int ambientOcclusionSide2; -flat out int ambientOcclusionCorner1; -flat out int ambientOcclusionCorner2; -flat out int ambientOcclusionCorner3; +flat out uvec4 occlusionSides; +flat out int topLeftObscured; +flat out int topRightObscured; +flat out int bottomLeftObscured; +flat out int bottomRightObscured; flat out int quadHeight; flat out int quadWidth; @@ -24,16 +25,15 @@ void main() { fragTexCoord = vertexTexCoord; fragTileTexCoord = vertexTileTexCoord; fragNormal = vertexNormal; + occlusionSides = vertexOcclusionSides; gl_Position = mvp*vec4(vertexPosition, 1.0); // metadata 1 parsing - ambientOcclusionSide1 = floatBitsToInt(vertexMetadata1.x); - ambientOcclusionSide2 = floatBitsToInt(vertexMetadata1.y); - int metadata1Z = floatBitsToInt(vertexMetadata1.z); - int metadata1W = floatBitsToInt(vertexMetadata1.w); - ambientOcclusionCorner1 = (metadata1Z & 0x1) >> 0; // Take 0th bit. - ambientOcclusionCorner2 = (metadata1Z & 0x2) >> 1; // Take 1st bit. - ambientOcclusionCorner3 = (metadata1Z & 0x4) >> 2; // Take 2nd bit. - quadHeight = (metadata1Z & 0x1f8) >> 3; // Take 3rd-8th bits. - quadWidth = (metadata1Z & 0x7e00) >> 9; // Take 9th-14th bits. + int metadata1W = int(vertexMetadata1.x); + topLeftObscured = (metadata1W & 0x1); // Take 0th bit. + topRightObscured = (metadata1W & 0x2) >> 1; // Take 1st bits. + bottomLeftObscured = (metadata1W & 0x4) >> 2; // Take 2nd bits. + bottomRightObscured = (metadata1W & 0x8) >> 3; // Take 3rd bits. + quadHeight = (metadata1W & 0x3f0) >> 4; // Take 4rd-9th bits. + quadWidth = (metadata1W & 0xfc00) >> 10; // Take 10th-16th bits. } diff --git a/rmodels.tmpzig b/rmodels.tmpzig deleted file mode 100644 index c24bfc5..0000000 --- a/rmodels.tmpzig +++ /dev/null @@ -1,40465 +0,0 @@ -pub const __builtin_bswap16 = @import("std").zig.c_builtins.__builtin_bswap16; -pub const __builtin_bswap32 = @import("std").zig.c_builtins.__builtin_bswap32; -pub const __builtin_bswap64 = @import("std").zig.c_builtins.__builtin_bswap64; -pub const __builtin_signbit = @import("std").zig.c_builtins.__builtin_signbit; -pub const __builtin_signbitf = @import("std").zig.c_builtins.__builtin_signbitf; -pub const __builtin_popcount = @import("std").zig.c_builtins.__builtin_popcount; -pub const __builtin_ctz = @import("std").zig.c_builtins.__builtin_ctz; -pub const __builtin_clz = @import("std").zig.c_builtins.__builtin_clz; -pub const __builtin_sqrt = @import("std").zig.c_builtins.__builtin_sqrt; -pub const __builtin_sqrtf = @import("std").zig.c_builtins.__builtin_sqrtf; -pub const __builtin_sin = @import("std").zig.c_builtins.__builtin_sin; -pub const __builtin_sinf = @import("std").zig.c_builtins.__builtin_sinf; -pub const __builtin_cos = @import("std").zig.c_builtins.__builtin_cos; -pub const __builtin_cosf = @import("std").zig.c_builtins.__builtin_cosf; -pub const __builtin_exp = @import("std").zig.c_builtins.__builtin_exp; -pub const __builtin_expf = @import("std").zig.c_builtins.__builtin_expf; -pub const __builtin_exp2 = @import("std").zig.c_builtins.__builtin_exp2; -pub const __builtin_exp2f = @import("std").zig.c_builtins.__builtin_exp2f; -pub const __builtin_log = @import("std").zig.c_builtins.__builtin_log; -pub const __builtin_logf = @import("std").zig.c_builtins.__builtin_logf; -pub const __builtin_log2 = @import("std").zig.c_builtins.__builtin_log2; -pub const __builtin_log2f = @import("std").zig.c_builtins.__builtin_log2f; -pub const __builtin_log10 = @import("std").zig.c_builtins.__builtin_log10; -pub const __builtin_log10f = @import("std").zig.c_builtins.__builtin_log10f; -pub const __builtin_abs = @import("std").zig.c_builtins.__builtin_abs; -pub const __builtin_labs = @import("std").zig.c_builtins.__builtin_labs; -pub const __builtin_llabs = @import("std").zig.c_builtins.__builtin_llabs; -pub const __builtin_fabs = @import("std").zig.c_builtins.__builtin_fabs; -pub const __builtin_fabsf = @import("std").zig.c_builtins.__builtin_fabsf; -pub const __builtin_floor = @import("std").zig.c_builtins.__builtin_floor; -pub const __builtin_floorf = @import("std").zig.c_builtins.__builtin_floorf; -pub const __builtin_ceil = @import("std").zig.c_builtins.__builtin_ceil; -pub const __builtin_ceilf = @import("std").zig.c_builtins.__builtin_ceilf; -pub const __builtin_trunc = @import("std").zig.c_builtins.__builtin_trunc; -pub const __builtin_truncf = @import("std").zig.c_builtins.__builtin_truncf; -pub const __builtin_round = @import("std").zig.c_builtins.__builtin_round; -pub const __builtin_roundf = @import("std").zig.c_builtins.__builtin_roundf; -pub const __builtin_strlen = @import("std").zig.c_builtins.__builtin_strlen; -pub const __builtin_strcmp = @import("std").zig.c_builtins.__builtin_strcmp; -pub const __builtin_object_size = @import("std").zig.c_builtins.__builtin_object_size; -pub const __builtin___memset_chk = @import("std").zig.c_builtins.__builtin___memset_chk; -pub const __builtin_memset = @import("std").zig.c_builtins.__builtin_memset; -pub const __builtin___memcpy_chk = @import("std").zig.c_builtins.__builtin___memcpy_chk; -pub const __builtin_memcpy = @import("std").zig.c_builtins.__builtin_memcpy; -pub const __builtin_expect = @import("std").zig.c_builtins.__builtin_expect; -pub const __builtin_nanf = @import("std").zig.c_builtins.__builtin_nanf; -pub const __builtin_huge_valf = @import("std").zig.c_builtins.__builtin_huge_valf; -pub const __builtin_inff = @import("std").zig.c_builtins.__builtin_inff; -pub const __builtin_isnan = @import("std").zig.c_builtins.__builtin_isnan; -pub const __builtin_isinf = @import("std").zig.c_builtins.__builtin_isinf; -pub const __builtin_isinf_sign = @import("std").zig.c_builtins.__builtin_isinf_sign; -pub const __has_builtin = @import("std").zig.c_builtins.__has_builtin; -pub const __builtin_assume = @import("std").zig.c_builtins.__builtin_assume; -pub const __builtin_unreachable = @import("std").zig.c_builtins.__builtin_unreachable; -pub const __builtin_constant_p = @import("std").zig.c_builtins.__builtin_constant_p; -pub const __builtin_mul_overflow = @import("std").zig.c_builtins.__builtin_mul_overflow; -pub const struct___va_list_tag_1 = extern struct { - gp_offset: c_uint = @import("std").mem.zeroes(c_uint), - fp_offset: c_uint = @import("std").mem.zeroes(c_uint), - overflow_arg_area: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - reg_save_area: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), -}; -pub const __builtin_va_list = [1]struct___va_list_tag_1; -pub const __gnuc_va_list = __builtin_va_list; -pub const va_list = __builtin_va_list; -pub const struct_Vector2 = extern struct { - x: f32 = @import("std").mem.zeroes(f32), - y: f32 = @import("std").mem.zeroes(f32), -}; -pub const Vector2 = struct_Vector2; -pub const struct_Vector3 = extern struct { - x: f32 = @import("std").mem.zeroes(f32), - y: f32 = @import("std").mem.zeroes(f32), - z: f32 = @import("std").mem.zeroes(f32), -}; -pub const Vector3 = struct_Vector3; -pub const struct_Vector4 = extern struct { - x: f32 = @import("std").mem.zeroes(f32), - y: f32 = @import("std").mem.zeroes(f32), - z: f32 = @import("std").mem.zeroes(f32), - w: f32 = @import("std").mem.zeroes(f32), -}; -pub const Vector4 = struct_Vector4; -pub const Quaternion = Vector4; -pub const struct_Matrix = extern struct { - m0: f32 = @import("std").mem.zeroes(f32), - m4: f32 = @import("std").mem.zeroes(f32), - m8: f32 = @import("std").mem.zeroes(f32), - m12: f32 = @import("std").mem.zeroes(f32), - m1: f32 = @import("std").mem.zeroes(f32), - m5: f32 = @import("std").mem.zeroes(f32), - m9: f32 = @import("std").mem.zeroes(f32), - m13: f32 = @import("std").mem.zeroes(f32), - m2: f32 = @import("std").mem.zeroes(f32), - m6: f32 = @import("std").mem.zeroes(f32), - m10: f32 = @import("std").mem.zeroes(f32), - m14: f32 = @import("std").mem.zeroes(f32), - m3: f32 = @import("std").mem.zeroes(f32), - m7: f32 = @import("std").mem.zeroes(f32), - m11: f32 = @import("std").mem.zeroes(f32), - m15: f32 = @import("std").mem.zeroes(f32), -}; -pub const Matrix = struct_Matrix; -pub const struct_Color = extern struct { - r: u8 = @import("std").mem.zeroes(u8), - g: u8 = @import("std").mem.zeroes(u8), - b: u8 = @import("std").mem.zeroes(u8), - a: u8 = @import("std").mem.zeroes(u8), -}; -pub const Color = struct_Color; -pub const struct_Rectangle = extern struct { - x: f32 = @import("std").mem.zeroes(f32), - y: f32 = @import("std").mem.zeroes(f32), - width: f32 = @import("std").mem.zeroes(f32), - height: f32 = @import("std").mem.zeroes(f32), -}; -pub const Rectangle = struct_Rectangle; -pub const struct_Image = extern struct { - data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - width: c_int = @import("std").mem.zeroes(c_int), - height: c_int = @import("std").mem.zeroes(c_int), - mipmaps: c_int = @import("std").mem.zeroes(c_int), - format: c_int = @import("std").mem.zeroes(c_int), -}; -pub const Image = struct_Image; -pub const struct_Texture = extern struct { - id: c_uint = @import("std").mem.zeroes(c_uint), - width: c_int = @import("std").mem.zeroes(c_int), - height: c_int = @import("std").mem.zeroes(c_int), - mipmaps: c_int = @import("std").mem.zeroes(c_int), - format: c_int = @import("std").mem.zeroes(c_int), -}; -pub const Texture = struct_Texture; -pub const Texture2D = Texture; -pub const TextureCubemap = Texture; -pub const struct_RenderTexture = extern struct { - id: c_uint = @import("std").mem.zeroes(c_uint), - texture: Texture = @import("std").mem.zeroes(Texture), - depth: Texture = @import("std").mem.zeroes(Texture), -}; -pub const RenderTexture = struct_RenderTexture; -pub const RenderTexture2D = RenderTexture; -pub const struct_NPatchInfo = extern struct { - source: Rectangle = @import("std").mem.zeroes(Rectangle), - left: c_int = @import("std").mem.zeroes(c_int), - top: c_int = @import("std").mem.zeroes(c_int), - right: c_int = @import("std").mem.zeroes(c_int), - bottom: c_int = @import("std").mem.zeroes(c_int), - layout: c_int = @import("std").mem.zeroes(c_int), -}; -pub const NPatchInfo = struct_NPatchInfo; -pub const struct_GlyphInfo = extern struct { - value: c_int = @import("std").mem.zeroes(c_int), - offsetX: c_int = @import("std").mem.zeroes(c_int), - offsetY: c_int = @import("std").mem.zeroes(c_int), - advanceX: c_int = @import("std").mem.zeroes(c_int), - image: Image = @import("std").mem.zeroes(Image), -}; -pub const GlyphInfo = struct_GlyphInfo; -pub const struct_Font = extern struct { - baseSize: c_int = @import("std").mem.zeroes(c_int), - glyphCount: c_int = @import("std").mem.zeroes(c_int), - glyphPadding: c_int = @import("std").mem.zeroes(c_int), - texture: Texture2D = @import("std").mem.zeroes(Texture2D), - recs: [*c]Rectangle = @import("std").mem.zeroes([*c]Rectangle), - glyphs: [*c]GlyphInfo = @import("std").mem.zeroes([*c]GlyphInfo), -}; -pub const Font = struct_Font; -pub const struct_Camera3D = extern struct { - position: Vector3 = @import("std").mem.zeroes(Vector3), - target: Vector3 = @import("std").mem.zeroes(Vector3), - up: Vector3 = @import("std").mem.zeroes(Vector3), - fovy: f32 = @import("std").mem.zeroes(f32), - projection: c_int = @import("std").mem.zeroes(c_int), -}; -pub const Camera3D = struct_Camera3D; -pub const Camera = Camera3D; -pub const struct_Camera2D = extern struct { - offset: Vector2 = @import("std").mem.zeroes(Vector2), - target: Vector2 = @import("std").mem.zeroes(Vector2), - rotation: f32 = @import("std").mem.zeroes(f32), - zoom: f32 = @import("std").mem.zeroes(f32), -}; -pub const Camera2D = struct_Camera2D; -pub const struct_Mesh = extern struct { - vertexCount: c_int = @import("std").mem.zeroes(c_int), - triangleCount: c_int = @import("std").mem.zeroes(c_int), - vertices: [*c]f32 = @import("std").mem.zeroes([*c]f32), - texcoords: [*c]f32 = @import("std").mem.zeroes([*c]f32), - texcoords2: [*c]f32 = @import("std").mem.zeroes([*c]f32), - normals: [*c]f32 = @import("std").mem.zeroes([*c]f32), - tangents: [*c]f32 = @import("std").mem.zeroes([*c]f32), - colors: [*c]u8 = @import("std").mem.zeroes([*c]u8), - indices: [*c]c_ushort = @import("std").mem.zeroes([*c]c_ushort), - animVertices: [*c]f32 = @import("std").mem.zeroes([*c]f32), - animNormals: [*c]f32 = @import("std").mem.zeroes([*c]f32), - boneIds: [*c]u8 = @import("std").mem.zeroes([*c]u8), - boneWeights: [*c]f32 = @import("std").mem.zeroes([*c]f32), - vaoId: c_uint = @import("std").mem.zeroes(c_uint), - vboId: [*c]c_uint = @import("std").mem.zeroes([*c]c_uint), -}; -pub const Mesh = struct_Mesh; -pub const struct_Shader = extern struct { - id: c_uint = @import("std").mem.zeroes(c_uint), - locs: [*c]c_int = @import("std").mem.zeroes([*c]c_int), -}; -pub const Shader = struct_Shader; -pub const struct_MaterialMap = extern struct { - texture: Texture2D = @import("std").mem.zeroes(Texture2D), - color: Color = @import("std").mem.zeroes(Color), - value: f32 = @import("std").mem.zeroes(f32), -}; -pub const MaterialMap = struct_MaterialMap; -pub const struct_Material = extern struct { - shader: Shader = @import("std").mem.zeroes(Shader), - maps: [*c]MaterialMap = @import("std").mem.zeroes([*c]MaterialMap), - params: [4]f32 = @import("std").mem.zeroes([4]f32), -}; -pub const Material = struct_Material; -pub const struct_Transform = extern struct { - translation: Vector3 = @import("std").mem.zeroes(Vector3), - rotation: Quaternion = @import("std").mem.zeroes(Quaternion), - scale: Vector3 = @import("std").mem.zeroes(Vector3), -}; -pub const Transform = struct_Transform; -pub const struct_BoneInfo = extern struct { - name: [32]u8 = @import("std").mem.zeroes([32]u8), - parent: c_int = @import("std").mem.zeroes(c_int), -}; -pub const BoneInfo = struct_BoneInfo; -pub const struct_Model = extern struct { - transform: Matrix = @import("std").mem.zeroes(Matrix), - meshCount: c_int = @import("std").mem.zeroes(c_int), - materialCount: c_int = @import("std").mem.zeroes(c_int), - meshes: [*c]Mesh = @import("std").mem.zeroes([*c]Mesh), - materials: [*c]Material = @import("std").mem.zeroes([*c]Material), - meshMaterial: [*c]c_int = @import("std").mem.zeroes([*c]c_int), - boneCount: c_int = @import("std").mem.zeroes(c_int), - bones: [*c]BoneInfo = @import("std").mem.zeroes([*c]BoneInfo), - bindPose: [*c]Transform = @import("std").mem.zeroes([*c]Transform), -}; -pub const Model = struct_Model; -pub const struct_ModelAnimation = extern struct { - boneCount: c_int = @import("std").mem.zeroes(c_int), - frameCount: c_int = @import("std").mem.zeroes(c_int), - bones: [*c]BoneInfo = @import("std").mem.zeroes([*c]BoneInfo), - framePoses: [*c][*c]Transform = @import("std").mem.zeroes([*c][*c]Transform), - name: [32]u8 = @import("std").mem.zeroes([32]u8), -}; -pub const ModelAnimation = struct_ModelAnimation; -pub const struct_Ray = extern struct { - position: Vector3 = @import("std").mem.zeroes(Vector3), - direction: Vector3 = @import("std").mem.zeroes(Vector3), -}; -pub const Ray = struct_Ray; -pub const struct_RayCollision = extern struct { - hit: bool = @import("std").mem.zeroes(bool), - distance: f32 = @import("std").mem.zeroes(f32), - point: Vector3 = @import("std").mem.zeroes(Vector3), - normal: Vector3 = @import("std").mem.zeroes(Vector3), -}; -pub const RayCollision = struct_RayCollision; -pub const struct_BoundingBox = extern struct { - min: Vector3 = @import("std").mem.zeroes(Vector3), - max: Vector3 = @import("std").mem.zeroes(Vector3), -}; -pub const BoundingBox = struct_BoundingBox; -pub const struct_Wave = extern struct { - frameCount: c_uint = @import("std").mem.zeroes(c_uint), - sampleRate: c_uint = @import("std").mem.zeroes(c_uint), - sampleSize: c_uint = @import("std").mem.zeroes(c_uint), - channels: c_uint = @import("std").mem.zeroes(c_uint), - data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), -}; -pub const Wave = struct_Wave; -pub const struct_rAudioBuffer = opaque {}; -pub const rAudioBuffer = struct_rAudioBuffer; -pub const struct_rAudioProcessor = opaque {}; -pub const rAudioProcessor = struct_rAudioProcessor; -pub const struct_AudioStream = extern struct { - buffer: ?*rAudioBuffer = @import("std").mem.zeroes(?*rAudioBuffer), - processor: ?*rAudioProcessor = @import("std").mem.zeroes(?*rAudioProcessor), - sampleRate: c_uint = @import("std").mem.zeroes(c_uint), - sampleSize: c_uint = @import("std").mem.zeroes(c_uint), - channels: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub const AudioStream = struct_AudioStream; -pub const struct_Sound = extern struct { - stream: AudioStream = @import("std").mem.zeroes(AudioStream), - frameCount: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub const Sound = struct_Sound; -pub const struct_Music = extern struct { - stream: AudioStream = @import("std").mem.zeroes(AudioStream), - frameCount: c_uint = @import("std").mem.zeroes(c_uint), - looping: bool = @import("std").mem.zeroes(bool), - ctxType: c_int = @import("std").mem.zeroes(c_int), - ctxData: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), -}; -pub const Music = struct_Music; -pub const struct_VrDeviceInfo = extern struct { - hResolution: c_int = @import("std").mem.zeroes(c_int), - vResolution: c_int = @import("std").mem.zeroes(c_int), - hScreenSize: f32 = @import("std").mem.zeroes(f32), - vScreenSize: f32 = @import("std").mem.zeroes(f32), - eyeToScreenDistance: f32 = @import("std").mem.zeroes(f32), - lensSeparationDistance: f32 = @import("std").mem.zeroes(f32), - interpupillaryDistance: f32 = @import("std").mem.zeroes(f32), - lensDistortionValues: [4]f32 = @import("std").mem.zeroes([4]f32), - chromaAbCorrection: [4]f32 = @import("std").mem.zeroes([4]f32), -}; -pub const VrDeviceInfo = struct_VrDeviceInfo; -pub const struct_VrStereoConfig = extern struct { - projection: [2]Matrix = @import("std").mem.zeroes([2]Matrix), - viewOffset: [2]Matrix = @import("std").mem.zeroes([2]Matrix), - leftLensCenter: [2]f32 = @import("std").mem.zeroes([2]f32), - rightLensCenter: [2]f32 = @import("std").mem.zeroes([2]f32), - leftScreenCenter: [2]f32 = @import("std").mem.zeroes([2]f32), - rightScreenCenter: [2]f32 = @import("std").mem.zeroes([2]f32), - scale: [2]f32 = @import("std").mem.zeroes([2]f32), - scaleIn: [2]f32 = @import("std").mem.zeroes([2]f32), -}; -pub const VrStereoConfig = struct_VrStereoConfig; -pub const struct_FilePathList = extern struct { - capacity: c_uint = @import("std").mem.zeroes(c_uint), - count: c_uint = @import("std").mem.zeroes(c_uint), - paths: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), -}; -pub const FilePathList = struct_FilePathList; -pub const struct_AutomationEvent = extern struct { - frame: c_uint = @import("std").mem.zeroes(c_uint), - type: c_uint = @import("std").mem.zeroes(c_uint), - params: [4]c_int = @import("std").mem.zeroes([4]c_int), -}; -pub const AutomationEvent = struct_AutomationEvent; -pub const struct_AutomationEventList = extern struct { - capacity: c_uint = @import("std").mem.zeroes(c_uint), - count: c_uint = @import("std").mem.zeroes(c_uint), - events: [*c]AutomationEvent = @import("std").mem.zeroes([*c]AutomationEvent), -}; -pub const AutomationEventList = struct_AutomationEventList; -pub const FLAG_VSYNC_HINT: c_int = 64; -pub const FLAG_FULLSCREEN_MODE: c_int = 2; -pub const FLAG_WINDOW_RESIZABLE: c_int = 4; -pub const FLAG_WINDOW_UNDECORATED: c_int = 8; -pub const FLAG_WINDOW_HIDDEN: c_int = 128; -pub const FLAG_WINDOW_MINIMIZED: c_int = 512; -pub const FLAG_WINDOW_MAXIMIZED: c_int = 1024; -pub const FLAG_WINDOW_UNFOCUSED: c_int = 2048; -pub const FLAG_WINDOW_TOPMOST: c_int = 4096; -pub const FLAG_WINDOW_ALWAYS_RUN: c_int = 256; -pub const FLAG_WINDOW_TRANSPARENT: c_int = 16; -pub const FLAG_WINDOW_HIGHDPI: c_int = 8192; -pub const FLAG_WINDOW_MOUSE_PASSTHROUGH: c_int = 16384; -pub const FLAG_BORDERLESS_WINDOWED_MODE: c_int = 32768; -pub const FLAG_MSAA_4X_HINT: c_int = 32; -pub const FLAG_INTERLACED_HINT: c_int = 65536; -pub const ConfigFlags = c_uint; -pub const LOG_ALL: c_int = 0; -pub const LOG_TRACE: c_int = 1; -pub const LOG_DEBUG: c_int = 2; -pub const LOG_INFO: c_int = 3; -pub const LOG_WARNING: c_int = 4; -pub const LOG_ERROR: c_int = 5; -pub const LOG_FATAL: c_int = 6; -pub const LOG_NONE: c_int = 7; -pub const TraceLogLevel = c_uint; -pub const KEY_NULL: c_int = 0; -pub const KEY_APOSTROPHE: c_int = 39; -pub const KEY_COMMA: c_int = 44; -pub const KEY_MINUS: c_int = 45; -pub const KEY_PERIOD: c_int = 46; -pub const KEY_SLASH: c_int = 47; -pub const KEY_ZERO: c_int = 48; -pub const KEY_ONE: c_int = 49; -pub const KEY_TWO: c_int = 50; -pub const KEY_THREE: c_int = 51; -pub const KEY_FOUR: c_int = 52; -pub const KEY_FIVE: c_int = 53; -pub const KEY_SIX: c_int = 54; -pub const KEY_SEVEN: c_int = 55; -pub const KEY_EIGHT: c_int = 56; -pub const KEY_NINE: c_int = 57; -pub const KEY_SEMICOLON: c_int = 59; -pub const KEY_EQUAL: c_int = 61; -pub const KEY_A: c_int = 65; -pub const KEY_B: c_int = 66; -pub const KEY_C: c_int = 67; -pub const KEY_D: c_int = 68; -pub const KEY_E: c_int = 69; -pub const KEY_F: c_int = 70; -pub const KEY_G: c_int = 71; -pub const KEY_H: c_int = 72; -pub const KEY_I: c_int = 73; -pub const KEY_J: c_int = 74; -pub const KEY_K: c_int = 75; -pub const KEY_L: c_int = 76; -pub const KEY_M: c_int = 77; -pub const KEY_N: c_int = 78; -pub const KEY_O: c_int = 79; -pub const KEY_P: c_int = 80; -pub const KEY_Q: c_int = 81; -pub const KEY_R: c_int = 82; -pub const KEY_S: c_int = 83; -pub const KEY_T: c_int = 84; -pub const KEY_U: c_int = 85; -pub const KEY_V: c_int = 86; -pub const KEY_W: c_int = 87; -pub const KEY_X: c_int = 88; -pub const KEY_Y: c_int = 89; -pub const KEY_Z: c_int = 90; -pub const KEY_LEFT_BRACKET: c_int = 91; -pub const KEY_BACKSLASH: c_int = 92; -pub const KEY_RIGHT_BRACKET: c_int = 93; -pub const KEY_GRAVE: c_int = 96; -pub const KEY_SPACE: c_int = 32; -pub const KEY_ESCAPE: c_int = 256; -pub const KEY_ENTER: c_int = 257; -pub const KEY_TAB: c_int = 258; -pub const KEY_BACKSPACE: c_int = 259; -pub const KEY_INSERT: c_int = 260; -pub const KEY_DELETE: c_int = 261; -pub const KEY_RIGHT: c_int = 262; -pub const KEY_LEFT: c_int = 263; -pub const KEY_DOWN: c_int = 264; -pub const KEY_UP: c_int = 265; -pub const KEY_PAGE_UP: c_int = 266; -pub const KEY_PAGE_DOWN: c_int = 267; -pub const KEY_HOME: c_int = 268; -pub const KEY_END: c_int = 269; -pub const KEY_CAPS_LOCK: c_int = 280; -pub const KEY_SCROLL_LOCK: c_int = 281; -pub const KEY_NUM_LOCK: c_int = 282; -pub const KEY_PRINT_SCREEN: c_int = 283; -pub const KEY_PAUSE: c_int = 284; -pub const KEY_F1: c_int = 290; -pub const KEY_F2: c_int = 291; -pub const KEY_F3: c_int = 292; -pub const KEY_F4: c_int = 293; -pub const KEY_F5: c_int = 294; -pub const KEY_F6: c_int = 295; -pub const KEY_F7: c_int = 296; -pub const KEY_F8: c_int = 297; -pub const KEY_F9: c_int = 298; -pub const KEY_F10: c_int = 299; -pub const KEY_F11: c_int = 300; -pub const KEY_F12: c_int = 301; -pub const KEY_LEFT_SHIFT: c_int = 340; -pub const KEY_LEFT_CONTROL: c_int = 341; -pub const KEY_LEFT_ALT: c_int = 342; -pub const KEY_LEFT_SUPER: c_int = 343; -pub const KEY_RIGHT_SHIFT: c_int = 344; -pub const KEY_RIGHT_CONTROL: c_int = 345; -pub const KEY_RIGHT_ALT: c_int = 346; -pub const KEY_RIGHT_SUPER: c_int = 347; -pub const KEY_KB_MENU: c_int = 348; -pub const KEY_KP_0: c_int = 320; -pub const KEY_KP_1: c_int = 321; -pub const KEY_KP_2: c_int = 322; -pub const KEY_KP_3: c_int = 323; -pub const KEY_KP_4: c_int = 324; -pub const KEY_KP_5: c_int = 325; -pub const KEY_KP_6: c_int = 326; -pub const KEY_KP_7: c_int = 327; -pub const KEY_KP_8: c_int = 328; -pub const KEY_KP_9: c_int = 329; -pub const KEY_KP_DECIMAL: c_int = 330; -pub const KEY_KP_DIVIDE: c_int = 331; -pub const KEY_KP_MULTIPLY: c_int = 332; -pub const KEY_KP_SUBTRACT: c_int = 333; -pub const KEY_KP_ADD: c_int = 334; -pub const KEY_KP_ENTER: c_int = 335; -pub const KEY_KP_EQUAL: c_int = 336; -pub const KEY_BACK: c_int = 4; -pub const KEY_MENU: c_int = 5; -pub const KEY_VOLUME_UP: c_int = 24; -pub const KEY_VOLUME_DOWN: c_int = 25; -pub const KeyboardKey = c_uint; -pub const MOUSE_BUTTON_LEFT: c_int = 0; -pub const MOUSE_BUTTON_RIGHT: c_int = 1; -pub const MOUSE_BUTTON_MIDDLE: c_int = 2; -pub const MOUSE_BUTTON_SIDE: c_int = 3; -pub const MOUSE_BUTTON_EXTRA: c_int = 4; -pub const MOUSE_BUTTON_FORWARD: c_int = 5; -pub const MOUSE_BUTTON_BACK: c_int = 6; -pub const MouseButton = c_uint; -pub const MOUSE_CURSOR_DEFAULT: c_int = 0; -pub const MOUSE_CURSOR_ARROW: c_int = 1; -pub const MOUSE_CURSOR_IBEAM: c_int = 2; -pub const MOUSE_CURSOR_CROSSHAIR: c_int = 3; -pub const MOUSE_CURSOR_POINTING_HAND: c_int = 4; -pub const MOUSE_CURSOR_RESIZE_EW: c_int = 5; -pub const MOUSE_CURSOR_RESIZE_NS: c_int = 6; -pub const MOUSE_CURSOR_RESIZE_NWSE: c_int = 7; -pub const MOUSE_CURSOR_RESIZE_NESW: c_int = 8; -pub const MOUSE_CURSOR_RESIZE_ALL: c_int = 9; -pub const MOUSE_CURSOR_NOT_ALLOWED: c_int = 10; -pub const MouseCursor = c_uint; -pub const GAMEPAD_BUTTON_UNKNOWN: c_int = 0; -pub const GAMEPAD_BUTTON_LEFT_FACE_UP: c_int = 1; -pub const GAMEPAD_BUTTON_LEFT_FACE_RIGHT: c_int = 2; -pub const GAMEPAD_BUTTON_LEFT_FACE_DOWN: c_int = 3; -pub const GAMEPAD_BUTTON_LEFT_FACE_LEFT: c_int = 4; -pub const GAMEPAD_BUTTON_RIGHT_FACE_UP: c_int = 5; -pub const GAMEPAD_BUTTON_RIGHT_FACE_RIGHT: c_int = 6; -pub const GAMEPAD_BUTTON_RIGHT_FACE_DOWN: c_int = 7; -pub const GAMEPAD_BUTTON_RIGHT_FACE_LEFT: c_int = 8; -pub const GAMEPAD_BUTTON_LEFT_TRIGGER_1: c_int = 9; -pub const GAMEPAD_BUTTON_LEFT_TRIGGER_2: c_int = 10; -pub const GAMEPAD_BUTTON_RIGHT_TRIGGER_1: c_int = 11; -pub const GAMEPAD_BUTTON_RIGHT_TRIGGER_2: c_int = 12; -pub const GAMEPAD_BUTTON_MIDDLE_LEFT: c_int = 13; -pub const GAMEPAD_BUTTON_MIDDLE: c_int = 14; -pub const GAMEPAD_BUTTON_MIDDLE_RIGHT: c_int = 15; -pub const GAMEPAD_BUTTON_LEFT_THUMB: c_int = 16; -pub const GAMEPAD_BUTTON_RIGHT_THUMB: c_int = 17; -pub const GamepadButton = c_uint; -pub const GAMEPAD_AXIS_LEFT_X: c_int = 0; -pub const GAMEPAD_AXIS_LEFT_Y: c_int = 1; -pub const GAMEPAD_AXIS_RIGHT_X: c_int = 2; -pub const GAMEPAD_AXIS_RIGHT_Y: c_int = 3; -pub const GAMEPAD_AXIS_LEFT_TRIGGER: c_int = 4; -pub const GAMEPAD_AXIS_RIGHT_TRIGGER: c_int = 5; -pub const GamepadAxis = c_uint; -pub const MATERIAL_MAP_ALBEDO: c_int = 0; -pub const MATERIAL_MAP_METALNESS: c_int = 1; -pub const MATERIAL_MAP_NORMAL: c_int = 2; -pub const MATERIAL_MAP_ROUGHNESS: c_int = 3; -pub const MATERIAL_MAP_OCCLUSION: c_int = 4; -pub const MATERIAL_MAP_EMISSION: c_int = 5; -pub const MATERIAL_MAP_HEIGHT: c_int = 6; -pub const MATERIAL_MAP_CUBEMAP: c_int = 7; -pub const MATERIAL_MAP_IRRADIANCE: c_int = 8; -pub const MATERIAL_MAP_PREFILTER: c_int = 9; -pub const MATERIAL_MAP_BRDF: c_int = 10; -pub const MaterialMapIndex = c_uint; -pub const SHADER_LOC_VERTEX_POSITION: c_int = 0; -pub const SHADER_LOC_VERTEX_TEXCOORD01: c_int = 1; -pub const SHADER_LOC_VERTEX_TEXCOORD02: c_int = 2; -pub const SHADER_LOC_VERTEX_NORMAL: c_int = 3; -pub const SHADER_LOC_VERTEX_TANGENT: c_int = 4; -pub const SHADER_LOC_VERTEX_COLOR: c_int = 5; -pub const SHADER_LOC_MATRIX_MVP: c_int = 6; -pub const SHADER_LOC_MATRIX_VIEW: c_int = 7; -pub const SHADER_LOC_MATRIX_PROJECTION: c_int = 8; -pub const SHADER_LOC_MATRIX_MODEL: c_int = 9; -pub const SHADER_LOC_MATRIX_NORMAL: c_int = 10; -pub const SHADER_LOC_VECTOR_VIEW: c_int = 11; -pub const SHADER_LOC_COLOR_DIFFUSE: c_int = 12; -pub const SHADER_LOC_COLOR_SPECULAR: c_int = 13; -pub const SHADER_LOC_COLOR_AMBIENT: c_int = 14; -pub const SHADER_LOC_MAP_ALBEDO: c_int = 15; -pub const SHADER_LOC_MAP_METALNESS: c_int = 16; -pub const SHADER_LOC_MAP_NORMAL: c_int = 17; -pub const SHADER_LOC_MAP_ROUGHNESS: c_int = 18; -pub const SHADER_LOC_MAP_OCCLUSION: c_int = 19; -pub const SHADER_LOC_MAP_EMISSION: c_int = 20; -pub const SHADER_LOC_MAP_HEIGHT: c_int = 21; -pub const SHADER_LOC_MAP_CUBEMAP: c_int = 22; -pub const SHADER_LOC_MAP_IRRADIANCE: c_int = 23; -pub const SHADER_LOC_MAP_PREFILTER: c_int = 24; -pub const SHADER_LOC_MAP_BRDF: c_int = 25; -pub const ShaderLocationIndex = c_uint; -pub const SHADER_UNIFORM_FLOAT: c_int = 0; -pub const SHADER_UNIFORM_VEC2: c_int = 1; -pub const SHADER_UNIFORM_VEC3: c_int = 2; -pub const SHADER_UNIFORM_VEC4: c_int = 3; -pub const SHADER_UNIFORM_INT: c_int = 4; -pub const SHADER_UNIFORM_IVEC2: c_int = 5; -pub const SHADER_UNIFORM_IVEC3: c_int = 6; -pub const SHADER_UNIFORM_IVEC4: c_int = 7; -pub const SHADER_UNIFORM_SAMPLER2D: c_int = 8; -pub const ShaderUniformDataType = c_uint; -pub const SHADER_ATTRIB_FLOAT: c_int = 0; -pub const SHADER_ATTRIB_VEC2: c_int = 1; -pub const SHADER_ATTRIB_VEC3: c_int = 2; -pub const SHADER_ATTRIB_VEC4: c_int = 3; -pub const ShaderAttributeDataType = c_uint; -pub const PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: c_int = 1; -pub const PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: c_int = 2; -pub const PIXELFORMAT_UNCOMPRESSED_R5G6B5: c_int = 3; -pub const PIXELFORMAT_UNCOMPRESSED_R8G8B8: c_int = 4; -pub const PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: c_int = 5; -pub const PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: c_int = 6; -pub const PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: c_int = 7; -pub const PIXELFORMAT_UNCOMPRESSED_R32: c_int = 8; -pub const PIXELFORMAT_UNCOMPRESSED_R32G32B32: c_int = 9; -pub const PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: c_int = 10; -pub const PIXELFORMAT_UNCOMPRESSED_R16: c_int = 11; -pub const PIXELFORMAT_UNCOMPRESSED_R16G16B16: c_int = 12; -pub const PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: c_int = 13; -pub const PIXELFORMAT_COMPRESSED_DXT1_RGB: c_int = 14; -pub const PIXELFORMAT_COMPRESSED_DXT1_RGBA: c_int = 15; -pub const PIXELFORMAT_COMPRESSED_DXT3_RGBA: c_int = 16; -pub const PIXELFORMAT_COMPRESSED_DXT5_RGBA: c_int = 17; -pub const PIXELFORMAT_COMPRESSED_ETC1_RGB: c_int = 18; -pub const PIXELFORMAT_COMPRESSED_ETC2_RGB: c_int = 19; -pub const PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA: c_int = 20; -pub const PIXELFORMAT_COMPRESSED_PVRT_RGB: c_int = 21; -pub const PIXELFORMAT_COMPRESSED_PVRT_RGBA: c_int = 22; -pub const PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: c_int = 23; -pub const PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: c_int = 24; -pub const PixelFormat = c_uint; -pub const TEXTURE_FILTER_POINT: c_int = 0; -pub const TEXTURE_FILTER_BILINEAR: c_int = 1; -pub const TEXTURE_FILTER_TRILINEAR: c_int = 2; -pub const TEXTURE_FILTER_ANISOTROPIC_4X: c_int = 3; -pub const TEXTURE_FILTER_ANISOTROPIC_8X: c_int = 4; -pub const TEXTURE_FILTER_ANISOTROPIC_16X: c_int = 5; -pub const TextureFilter = c_uint; -pub const TEXTURE_WRAP_REPEAT: c_int = 0; -pub const TEXTURE_WRAP_CLAMP: c_int = 1; -pub const TEXTURE_WRAP_MIRROR_REPEAT: c_int = 2; -pub const TEXTURE_WRAP_MIRROR_CLAMP: c_int = 3; -pub const TextureWrap = c_uint; -pub const CUBEMAP_LAYOUT_AUTO_DETECT: c_int = 0; -pub const CUBEMAP_LAYOUT_LINE_VERTICAL: c_int = 1; -pub const CUBEMAP_LAYOUT_LINE_HORIZONTAL: c_int = 2; -pub const CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR: c_int = 3; -pub const CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE: c_int = 4; -pub const CUBEMAP_LAYOUT_PANORAMA: c_int = 5; -pub const CubemapLayout = c_uint; -pub const FONT_DEFAULT: c_int = 0; -pub const FONT_BITMAP: c_int = 1; -pub const FONT_SDF: c_int = 2; -pub const FontType = c_uint; -pub const BLEND_ALPHA: c_int = 0; -pub const BLEND_ADDITIVE: c_int = 1; -pub const BLEND_MULTIPLIED: c_int = 2; -pub const BLEND_ADD_COLORS: c_int = 3; -pub const BLEND_SUBTRACT_COLORS: c_int = 4; -pub const BLEND_ALPHA_PREMULTIPLY: c_int = 5; -pub const BLEND_CUSTOM: c_int = 6; -pub const BLEND_CUSTOM_SEPARATE: c_int = 7; -pub const BlendMode = c_uint; -pub const GESTURE_NONE: c_int = 0; -pub const GESTURE_TAP: c_int = 1; -pub const GESTURE_DOUBLETAP: c_int = 2; -pub const GESTURE_HOLD: c_int = 4; -pub const GESTURE_DRAG: c_int = 8; -pub const GESTURE_SWIPE_RIGHT: c_int = 16; -pub const GESTURE_SWIPE_LEFT: c_int = 32; -pub const GESTURE_SWIPE_UP: c_int = 64; -pub const GESTURE_SWIPE_DOWN: c_int = 128; -pub const GESTURE_PINCH_IN: c_int = 256; -pub const GESTURE_PINCH_OUT: c_int = 512; -pub const Gesture = c_uint; -pub const CAMERA_CUSTOM: c_int = 0; -pub const CAMERA_FREE: c_int = 1; -pub const CAMERA_ORBITAL: c_int = 2; -pub const CAMERA_FIRST_PERSON: c_int = 3; -pub const CAMERA_THIRD_PERSON: c_int = 4; -pub const CameraMode = c_uint; -pub const CAMERA_PERSPECTIVE: c_int = 0; -pub const CAMERA_ORTHOGRAPHIC: c_int = 1; -pub const CameraProjection = c_uint; -pub const NPATCH_NINE_PATCH: c_int = 0; -pub const NPATCH_THREE_PATCH_VERTICAL: c_int = 1; -pub const NPATCH_THREE_PATCH_HORIZONTAL: c_int = 2; -pub const NPatchLayout = c_uint; -pub const TraceLogCallback = ?*const fn (c_int, [*c]const u8, [*c]struct___va_list_tag_1) callconv(.C) void; -pub const LoadFileDataCallback = ?*const fn ([*c]const u8, [*c]c_int) callconv(.C) [*c]u8; -pub const SaveFileDataCallback = ?*const fn ([*c]const u8, ?*anyopaque, c_int) callconv(.C) bool; -pub const LoadFileTextCallback = ?*const fn ([*c]const u8) callconv(.C) [*c]u8; -pub const SaveFileTextCallback = ?*const fn ([*c]const u8, [*c]u8) callconv(.C) bool; -pub extern fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void; -pub extern fn CloseWindow() void; -pub extern fn WindowShouldClose() bool; -pub extern fn IsWindowReady() bool; -pub extern fn IsWindowFullscreen() bool; -pub extern fn IsWindowHidden() bool; -pub extern fn IsWindowMinimized() bool; -pub extern fn IsWindowMaximized() bool; -pub extern fn IsWindowFocused() bool; -pub extern fn IsWindowResized() bool; -pub extern fn IsWindowState(flag: c_uint) bool; -pub extern fn SetWindowState(flags: c_uint) void; -pub extern fn ClearWindowState(flags: c_uint) void; -pub extern fn ToggleFullscreen() void; -pub extern fn ToggleBorderlessWindowed() void; -pub extern fn MaximizeWindow() void; -pub extern fn MinimizeWindow() void; -pub extern fn RestoreWindow() void; -pub extern fn SetWindowIcon(image: Image) void; -pub extern fn SetWindowIcons(images: [*c]Image, count: c_int) void; -pub extern fn SetWindowTitle(title: [*c]const u8) void; -pub extern fn SetWindowPosition(x: c_int, y: c_int) void; -pub extern fn SetWindowMonitor(monitor: c_int) void; -pub extern fn SetWindowMinSize(width: c_int, height: c_int) void; -pub extern fn SetWindowMaxSize(width: c_int, height: c_int) void; -pub extern fn SetWindowSize(width: c_int, height: c_int) void; -pub extern fn SetWindowOpacity(opacity: f32) void; -pub extern fn SetWindowFocused() void; -pub extern fn GetWindowHandle() ?*anyopaque; -pub extern fn GetScreenWidth() c_int; -pub extern fn GetScreenHeight() c_int; -pub extern fn GetRenderWidth() c_int; -pub extern fn GetRenderHeight() c_int; -pub extern fn GetMonitorCount() c_int; -pub extern fn GetCurrentMonitor() c_int; -pub extern fn GetMonitorPosition(monitor: c_int) Vector2; -pub extern fn GetMonitorWidth(monitor: c_int) c_int; -pub extern fn GetMonitorHeight(monitor: c_int) c_int; -pub extern fn GetMonitorPhysicalWidth(monitor: c_int) c_int; -pub extern fn GetMonitorPhysicalHeight(monitor: c_int) c_int; -pub extern fn GetMonitorRefreshRate(monitor: c_int) c_int; -pub extern fn GetWindowPosition() Vector2; -pub extern fn GetWindowScaleDPI() Vector2; -pub extern fn GetMonitorName(monitor: c_int) [*c]const u8; -pub extern fn SetClipboardText(text: [*c]const u8) void; -pub extern fn GetClipboardText() [*c]const u8; -pub extern fn EnableEventWaiting() void; -pub extern fn DisableEventWaiting() void; -pub extern fn ShowCursor() void; -pub extern fn HideCursor() void; -pub extern fn IsCursorHidden() bool; -pub extern fn EnableCursor() void; -pub extern fn DisableCursor() void; -pub extern fn IsCursorOnScreen() bool; -pub extern fn ClearBackground(color: Color) void; -pub extern fn BeginDrawing() void; -pub extern fn EndDrawing() void; -pub extern fn BeginMode2D(camera: Camera2D) void; -pub extern fn EndMode2D() void; -pub extern fn BeginMode3D(camera: Camera3D) void; -pub extern fn EndMode3D() void; -pub extern fn BeginTextureMode(target: RenderTexture2D) void; -pub extern fn EndTextureMode() void; -pub extern fn BeginShaderMode(shader: Shader) void; -pub extern fn EndShaderMode() void; -pub extern fn BeginBlendMode(mode: c_int) void; -pub extern fn EndBlendMode() void; -pub extern fn BeginScissorMode(x: c_int, y: c_int, width: c_int, height: c_int) void; -pub extern fn EndScissorMode() void; -pub extern fn BeginVrStereoMode(config: VrStereoConfig) void; -pub extern fn EndVrStereoMode() void; -pub extern fn LoadVrStereoConfig(device: VrDeviceInfo) VrStereoConfig; -pub extern fn UnloadVrStereoConfig(config: VrStereoConfig) void; -pub extern fn LoadShader(vsFileName: [*c]const u8, fsFileName: [*c]const u8) Shader; -pub extern fn LoadShaderFromMemory(vsCode: [*c]const u8, fsCode: [*c]const u8) Shader; -pub extern fn IsShaderReady(shader: Shader) bool; -pub extern fn GetShaderLocation(shader: Shader, uniformName: [*c]const u8) c_int; -pub extern fn GetShaderLocationAttrib(shader: Shader, attribName: [*c]const u8) c_int; -pub extern fn SetShaderValue(shader: Shader, locIndex: c_int, value: ?*const anyopaque, uniformType: c_int) void; -pub extern fn SetShaderValueV(shader: Shader, locIndex: c_int, value: ?*const anyopaque, uniformType: c_int, count: c_int) void; -pub extern fn SetShaderValueMatrix(shader: Shader, locIndex: c_int, mat: Matrix) void; -pub extern fn SetShaderValueTexture(shader: Shader, locIndex: c_int, texture: Texture2D) void; -pub extern fn UnloadShader(shader: Shader) void; -pub extern fn GetScreenToWorldRay(position: Vector2, camera: Camera) Ray; -pub extern fn GetScreenToWorldRayEx(position: Vector2, camera: Camera, width: c_int, height: c_int) Ray; -pub extern fn GetWorldToScreen(position: Vector3, camera: Camera) Vector2; -pub extern fn GetWorldToScreenEx(position: Vector3, camera: Camera, width: c_int, height: c_int) Vector2; -pub extern fn GetWorldToScreen2D(position: Vector2, camera: Camera2D) Vector2; -pub extern fn GetScreenToWorld2D(position: Vector2, camera: Camera2D) Vector2; -pub extern fn GetCameraMatrix(camera: Camera) Matrix; -pub extern fn GetCameraMatrix2D(camera: Camera2D) Matrix; -pub extern fn SetTargetFPS(fps: c_int) void; -pub extern fn GetFrameTime() f32; -pub extern fn GetTime() f64; -pub extern fn GetFPS() c_int; -pub extern fn SwapScreenBuffer() void; -pub extern fn PollInputEvents() void; -pub extern fn WaitTime(seconds: f64) void; -pub extern fn SetRandomSeed(seed: c_uint) void; -pub extern fn GetRandomValue(min: c_int, max: c_int) c_int; -pub extern fn LoadRandomSequence(count: c_uint, min: c_int, max: c_int) [*c]c_int; -pub extern fn UnloadRandomSequence(sequence: [*c]c_int) void; -pub extern fn TakeScreenshot(fileName: [*c]const u8) void; -pub extern fn SetConfigFlags(flags: c_uint) void; -pub extern fn OpenURL(url: [*c]const u8) void; -pub extern fn TraceLog(logLevel: c_int, text: [*c]const u8, ...) void; -pub extern fn SetTraceLogLevel(logLevel: c_int) void; -pub extern fn MemAlloc(size: c_uint) ?*anyopaque; -pub extern fn MemRealloc(ptr: ?*anyopaque, size: c_uint) ?*anyopaque; -pub extern fn MemFree(ptr: ?*anyopaque) void; -pub extern fn SetTraceLogCallback(callback: TraceLogCallback) void; -pub extern fn SetLoadFileDataCallback(callback: LoadFileDataCallback) void; -pub extern fn SetSaveFileDataCallback(callback: SaveFileDataCallback) void; -pub extern fn SetLoadFileTextCallback(callback: LoadFileTextCallback) void; -pub extern fn SetSaveFileTextCallback(callback: SaveFileTextCallback) void; -pub extern fn LoadFileData(fileName: [*c]const u8, dataSize: [*c]c_int) [*c]u8; -pub extern fn UnloadFileData(data: [*c]u8) void; -pub extern fn SaveFileData(fileName: [*c]const u8, data: ?*anyopaque, dataSize: c_int) bool; -pub extern fn ExportDataAsCode(data: [*c]const u8, dataSize: c_int, fileName: [*c]const u8) bool; -pub extern fn LoadFileText(fileName: [*c]const u8) [*c]u8; -pub extern fn UnloadFileText(text: [*c]u8) void; -pub extern fn SaveFileText(fileName: [*c]const u8, text: [*c]u8) bool; -pub extern fn FileExists(fileName: [*c]const u8) bool; -pub extern fn DirectoryExists(dirPath: [*c]const u8) bool; -pub extern fn IsFileExtension(fileName: [*c]const u8, ext: [*c]const u8) bool; -pub extern fn GetFileLength(fileName: [*c]const u8) c_int; -pub extern fn GetFileExtension(fileName: [*c]const u8) [*c]const u8; -pub extern fn GetFileName(filePath: [*c]const u8) [*c]const u8; -pub extern fn GetFileNameWithoutExt(filePath: [*c]const u8) [*c]const u8; -pub extern fn GetDirectoryPath(filePath: [*c]const u8) [*c]const u8; -pub extern fn GetPrevDirectoryPath(dirPath: [*c]const u8) [*c]const u8; -pub extern fn GetWorkingDirectory() [*c]const u8; -pub extern fn GetApplicationDirectory() [*c]const u8; -pub extern fn ChangeDirectory(dir: [*c]const u8) bool; -pub extern fn IsPathFile(path: [*c]const u8) bool; -pub extern fn IsFileNameValid(fileName: [*c]const u8) bool; -pub extern fn LoadDirectoryFiles(dirPath: [*c]const u8) FilePathList; -pub extern fn LoadDirectoryFilesEx(basePath: [*c]const u8, filter: [*c]const u8, scanSubdirs: bool) FilePathList; -pub extern fn UnloadDirectoryFiles(files: FilePathList) void; -pub extern fn IsFileDropped() bool; -pub extern fn LoadDroppedFiles() FilePathList; -pub extern fn UnloadDroppedFiles(files: FilePathList) void; -pub extern fn GetFileModTime(fileName: [*c]const u8) c_long; -pub extern fn CompressData(data: [*c]const u8, dataSize: c_int, compDataSize: [*c]c_int) [*c]u8; -pub extern fn DecompressData(compData: [*c]const u8, compDataSize: c_int, dataSize: [*c]c_int) [*c]u8; -pub extern fn EncodeDataBase64(data: [*c]const u8, dataSize: c_int, outputSize: [*c]c_int) [*c]u8; -pub extern fn DecodeDataBase64(data: [*c]const u8, outputSize: [*c]c_int) [*c]u8; -pub extern fn LoadAutomationEventList(fileName: [*c]const u8) AutomationEventList; -pub extern fn UnloadAutomationEventList(list: AutomationEventList) void; -pub extern fn ExportAutomationEventList(list: AutomationEventList, fileName: [*c]const u8) bool; -pub extern fn SetAutomationEventList(list: [*c]AutomationEventList) void; -pub extern fn SetAutomationEventBaseFrame(frame: c_int) void; -pub extern fn StartAutomationEventRecording() void; -pub extern fn StopAutomationEventRecording() void; -pub extern fn PlayAutomationEvent(event: AutomationEvent) void; -pub extern fn IsKeyPressed(key: c_int) bool; -pub extern fn IsKeyPressedRepeat(key: c_int) bool; -pub extern fn IsKeyDown(key: c_int) bool; -pub extern fn IsKeyReleased(key: c_int) bool; -pub extern fn IsKeyUp(key: c_int) bool; -pub extern fn GetKeyPressed() c_int; -pub extern fn GetCharPressed() c_int; -pub extern fn SetExitKey(key: c_int) void; -pub extern fn IsGamepadAvailable(gamepad: c_int) bool; -pub extern fn GetGamepadName(gamepad: c_int) [*c]const u8; -pub extern fn IsGamepadButtonPressed(gamepad: c_int, button: c_int) bool; -pub extern fn IsGamepadButtonDown(gamepad: c_int, button: c_int) bool; -pub extern fn IsGamepadButtonReleased(gamepad: c_int, button: c_int) bool; -pub extern fn IsGamepadButtonUp(gamepad: c_int, button: c_int) bool; -pub extern fn GetGamepadButtonPressed() c_int; -pub extern fn GetGamepadAxisCount(gamepad: c_int) c_int; -pub extern fn GetGamepadAxisMovement(gamepad: c_int, axis: c_int) f32; -pub extern fn SetGamepadMappings(mappings: [*c]const u8) c_int; -pub extern fn SetGamepadVibration(gamepad: c_int, leftMotor: f32, rightMotor: f32) void; -pub extern fn IsMouseButtonPressed(button: c_int) bool; -pub extern fn IsMouseButtonDown(button: c_int) bool; -pub extern fn IsMouseButtonReleased(button: c_int) bool; -pub extern fn IsMouseButtonUp(button: c_int) bool; -pub extern fn GetMouseX() c_int; -pub extern fn GetMouseY() c_int; -pub extern fn GetMousePosition() Vector2; -pub extern fn GetMouseDelta() Vector2; -pub extern fn SetMousePosition(x: c_int, y: c_int) void; -pub extern fn SetMouseOffset(offsetX: c_int, offsetY: c_int) void; -pub extern fn SetMouseScale(scaleX: f32, scaleY: f32) void; -pub extern fn GetMouseWheelMove() f32; -pub extern fn GetMouseWheelMoveV() Vector2; -pub extern fn SetMouseCursor(cursor: c_int) void; -pub extern fn GetTouchX() c_int; -pub extern fn GetTouchY() c_int; -pub extern fn GetTouchPosition(index: c_int) Vector2; -pub extern fn GetTouchPointId(index: c_int) c_int; -pub extern fn GetTouchPointCount() c_int; -pub extern fn SetGesturesEnabled(flags: c_uint) void; -pub extern fn IsGestureDetected(gesture: c_uint) bool; -pub extern fn GetGestureDetected() c_int; -pub extern fn GetGestureHoldDuration() f32; -pub extern fn GetGestureDragVector() Vector2; -pub extern fn GetGestureDragAngle() f32; -pub extern fn GetGesturePinchVector() Vector2; -pub extern fn GetGesturePinchAngle() f32; -pub extern fn UpdateCamera(camera: [*c]Camera, mode: c_int) void; -pub extern fn UpdateCameraPro(camera: [*c]Camera, movement: Vector3, rotation: Vector3, zoom: f32) void; -pub extern fn SetShapesTexture(texture: Texture2D, source: Rectangle) void; -pub extern fn GetShapesTexture() Texture2D; -pub extern fn GetShapesTextureRectangle() Rectangle; -pub extern fn DrawPixel(posX: c_int, posY: c_int, color: Color) void; -pub extern fn DrawPixelV(position: Vector2, color: Color) void; -pub extern fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void; -pub extern fn DrawLineV(startPos: Vector2, endPos: Vector2, color: Color) void; -pub extern fn DrawLineEx(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void; -pub extern fn DrawLineStrip(points: [*c]const Vector2, pointCount: c_int, color: Color) void; -pub extern fn DrawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void; -pub extern fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: Color) void; -pub extern fn DrawCircleSector(center: Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; -pub extern fn DrawCircleSectorLines(center: Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; -pub extern fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, inner: Color, outer: Color) void; -pub extern fn DrawCircleV(center: Vector2, radius: f32, color: Color) void; -pub extern fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: Color) void; -pub extern fn DrawCircleLinesV(center: Vector2, radius: f32, color: Color) void; -pub extern fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void; -pub extern fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void; -pub extern fn DrawRing(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; -pub extern fn DrawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: c_int, color: Color) void; -pub extern fn DrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; -pub extern fn DrawRectangleV(position: Vector2, size: Vector2, color: Color) void; -pub extern fn DrawRectangleRec(rec: Rectangle, color: Color) void; -pub extern fn DrawRectanglePro(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void; -pub extern fn DrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, top: Color, bottom: Color) void; -pub extern fn DrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, left: Color, right: Color) void; -pub extern fn DrawRectangleGradientEx(rec: Rectangle, topLeft: Color, bottomLeft: Color, topRight: Color, bottomRight: Color) void; -pub extern fn DrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; -pub extern fn DrawRectangleLinesEx(rec: Rectangle, lineThick: f32, color: Color) void; -pub extern fn DrawRectangleRounded(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void; -pub extern fn DrawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void; -pub extern fn DrawRectangleRoundedLinesEx(rec: Rectangle, roundness: f32, segments: c_int, lineThick: f32, color: Color) void; -pub extern fn DrawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; -pub extern fn DrawTriangleLines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; -pub extern fn DrawTriangleFan(points: [*c]const Vector2, pointCount: c_int, color: Color) void; -pub extern fn DrawTriangleStrip(points: [*c]const Vector2, pointCount: c_int, color: Color) void; -pub extern fn DrawPoly(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void; -pub extern fn DrawPolyLines(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void; -pub extern fn DrawPolyLinesEx(center: Vector2, sides: c_int, radius: f32, rotation: f32, lineThick: f32, color: Color) void; -pub extern fn DrawSplineLinear(points: [*c]const Vector2, pointCount: c_int, thick: f32, color: Color) void; -pub extern fn DrawSplineBasis(points: [*c]const Vector2, pointCount: c_int, thick: f32, color: Color) void; -pub extern fn DrawSplineCatmullRom(points: [*c]const Vector2, pointCount: c_int, thick: f32, color: Color) void; -pub extern fn DrawSplineBezierQuadratic(points: [*c]const Vector2, pointCount: c_int, thick: f32, color: Color) void; -pub extern fn DrawSplineBezierCubic(points: [*c]const Vector2, pointCount: c_int, thick: f32, color: Color) void; -pub extern fn DrawSplineSegmentLinear(p1: Vector2, p2: Vector2, thick: f32, color: Color) void; -pub extern fn DrawSplineSegmentBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void; -pub extern fn DrawSplineSegmentCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void; -pub extern fn DrawSplineSegmentBezierQuadratic(p1: Vector2, c2: Vector2, p3: Vector2, thick: f32, color: Color) void; -pub extern fn DrawSplineSegmentBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, thick: f32, color: Color) void; -pub extern fn GetSplinePointLinear(startPos: Vector2, endPos: Vector2, t: f32) Vector2; -pub extern fn GetSplinePointBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2; -pub extern fn GetSplinePointCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2; -pub extern fn GetSplinePointBezierQuad(p1: Vector2, c2: Vector2, p3: Vector2, t: f32) Vector2; -pub extern fn GetSplinePointBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, t: f32) Vector2; -pub extern fn CheckCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool; -pub extern fn CheckCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool; -pub extern fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool; -pub extern fn CheckCollisionPointRec(point: Vector2, rec: Rectangle) bool; -pub extern fn CheckCollisionPointCircle(point: Vector2, center: Vector2, radius: f32) bool; -pub extern fn CheckCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool; -pub extern fn CheckCollisionPointPoly(point: Vector2, points: [*c]const Vector2, pointCount: c_int) bool; -pub extern fn CheckCollisionLines(startPos1: Vector2, endPos1: Vector2, startPos2: Vector2, endPos2: Vector2, collisionPoint: [*c]Vector2) bool; -pub extern fn CheckCollisionPointLine(point: Vector2, p1: Vector2, p2: Vector2, threshold: c_int) bool; -pub extern fn CheckCollisionCircleLine(center: Vector2, radius: f32, p1: Vector2, p2: Vector2) bool; -pub extern fn GetCollisionRec(rec1: Rectangle, rec2: Rectangle) Rectangle; -pub extern fn LoadImage(fileName: [*c]const u8) Image; -pub extern fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: c_int, headerSize: c_int) Image; -pub extern fn LoadImageSvg(fileNameOrString: [*c]const u8, width: c_int, height: c_int) Image; -pub extern fn LoadImageAnim(fileName: [*c]const u8, frames: [*c]c_int) Image; -pub extern fn LoadImageAnimFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int, frames: [*c]c_int) Image; -pub extern fn LoadImageFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) Image; -pub extern fn LoadImageFromTexture(texture: Texture2D) Image; -pub extern fn LoadImageFromScreen() Image; -pub extern fn IsImageReady(image: Image) bool; -pub extern fn UnloadImage(image: Image) void; -pub extern fn ExportImage(image: Image, fileName: [*c]const u8) bool; -pub extern fn ExportImageToMemory(image: Image, fileType: [*c]const u8, fileSize: [*c]c_int) [*c]u8; -pub extern fn ExportImageAsCode(image: Image, fileName: [*c]const u8) bool; -pub extern fn GenImageColor(width: c_int, height: c_int, color: Color) Image; -pub extern fn GenImageGradientLinear(width: c_int, height: c_int, direction: c_int, start: Color, end: Color) Image; -pub extern fn GenImageGradientRadial(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image; -pub extern fn GenImageGradientSquare(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image; -pub extern fn GenImageChecked(width: c_int, height: c_int, checksX: c_int, checksY: c_int, col1: Color, col2: Color) Image; -pub extern fn GenImageWhiteNoise(width: c_int, height: c_int, factor: f32) Image; -pub extern fn GenImagePerlinNoise(width: c_int, height: c_int, offsetX: c_int, offsetY: c_int, scale: f32) Image; -pub extern fn GenImageCellular(width: c_int, height: c_int, tileSize: c_int) Image; -pub extern fn GenImageText(width: c_int, height: c_int, text: [*c]const u8) Image; -pub extern fn ImageCopy(image: Image) Image; -pub extern fn ImageFromImage(image: Image, rec: Rectangle) Image; -pub extern fn ImageFromChannel(image: Image, selectedChannel: c_int) Image; -pub extern fn ImageText(text: [*c]const u8, fontSize: c_int, color: Color) Image; -pub extern fn ImageTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, tint: Color) Image; -pub extern fn ImageFormat(image: [*c]Image, newFormat: c_int) void; -pub extern fn ImageToPOT(image: [*c]Image, fill: Color) void; -pub extern fn ImageCrop(image: [*c]Image, crop: Rectangle) void; -pub extern fn ImageAlphaCrop(image: [*c]Image, threshold: f32) void; -pub extern fn ImageAlphaClear(image: [*c]Image, color: Color, threshold: f32) void; -pub extern fn ImageAlphaMask(image: [*c]Image, alphaMask: Image) void; -pub extern fn ImageAlphaPremultiply(image: [*c]Image) void; -pub extern fn ImageBlurGaussian(image: [*c]Image, blurSize: c_int) void; -pub extern fn ImageKernelConvolution(image: [*c]Image, kernel: [*c]const f32, kernelSize: c_int) void; -pub extern fn ImageResize(image: [*c]Image, newWidth: c_int, newHeight: c_int) void; -pub extern fn ImageResizeNN(image: [*c]Image, newWidth: c_int, newHeight: c_int) void; -pub extern fn ImageResizeCanvas(image: [*c]Image, newWidth: c_int, newHeight: c_int, offsetX: c_int, offsetY: c_int, fill: Color) void; -pub extern fn ImageMipmaps(image: [*c]Image) void; -pub extern fn ImageDither(image: [*c]Image, rBpp: c_int, gBpp: c_int, bBpp: c_int, aBpp: c_int) void; -pub extern fn ImageFlipVertical(image: [*c]Image) void; -pub extern fn ImageFlipHorizontal(image: [*c]Image) void; -pub extern fn ImageRotate(image: [*c]Image, degrees: c_int) void; -pub extern fn ImageRotateCW(image: [*c]Image) void; -pub extern fn ImageRotateCCW(image: [*c]Image) void; -pub extern fn ImageColorTint(image: [*c]Image, color: Color) void; -pub extern fn ImageColorInvert(image: [*c]Image) void; -pub extern fn ImageColorGrayscale(image: [*c]Image) void; -pub extern fn ImageColorContrast(image: [*c]Image, contrast: f32) void; -pub extern fn ImageColorBrightness(image: [*c]Image, brightness: c_int) void; -pub extern fn ImageColorReplace(image: [*c]Image, color: Color, replace: Color) void; -pub extern fn LoadImageColors(image: Image) [*c]Color; -pub extern fn LoadImagePalette(image: Image, maxPaletteSize: c_int, colorCount: [*c]c_int) [*c]Color; -pub extern fn UnloadImageColors(colors: [*c]Color) void; -pub extern fn UnloadImagePalette(colors: [*c]Color) void; -pub extern fn GetImageAlphaBorder(image: Image, threshold: f32) Rectangle; -pub extern fn GetImageColor(image: Image, x: c_int, y: c_int) Color; -pub extern fn ImageClearBackground(dst: [*c]Image, color: Color) void; -pub extern fn ImageDrawPixel(dst: [*c]Image, posX: c_int, posY: c_int, color: Color) void; -pub extern fn ImageDrawPixelV(dst: [*c]Image, position: Vector2, color: Color) void; -pub extern fn ImageDrawLine(dst: [*c]Image, startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void; -pub extern fn ImageDrawLineV(dst: [*c]Image, start: Vector2, end: Vector2, color: Color) void; -pub extern fn ImageDrawLineEx(dst: [*c]Image, start: Vector2, end: Vector2, thick: c_int, color: Color) void; -pub extern fn ImageDrawCircle(dst: [*c]Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void; -pub extern fn ImageDrawCircleV(dst: [*c]Image, center: Vector2, radius: c_int, color: Color) void; -pub extern fn ImageDrawCircleLines(dst: [*c]Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void; -pub extern fn ImageDrawCircleLinesV(dst: [*c]Image, center: Vector2, radius: c_int, color: Color) void; -pub extern fn ImageDrawRectangle(dst: [*c]Image, posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; -pub extern fn ImageDrawRectangleV(dst: [*c]Image, position: Vector2, size: Vector2, color: Color) void; -pub extern fn ImageDrawRectangleRec(dst: [*c]Image, rec: Rectangle, color: Color) void; -pub extern fn ImageDrawRectangleLines(dst: [*c]Image, rec: Rectangle, thick: c_int, color: Color) void; -pub extern fn ImageDrawTriangle(dst: [*c]Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; -pub extern fn ImageDrawTriangleEx(dst: [*c]Image, v1: Vector2, v2: Vector2, v3: Vector2, c1: Color, c2: Color, c3: Color) void; -pub extern fn ImageDrawTriangleLines(dst: [*c]Image, v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; -pub extern fn ImageDrawTriangleFan(dst: [*c]Image, points: [*c]Vector2, pointCount: c_int, color: Color) void; -pub extern fn ImageDrawTriangleStrip(dst: [*c]Image, points: [*c]Vector2, pointCount: c_int, color: Color) void; -pub extern fn ImageDraw(dst: [*c]Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color) void; -pub extern fn ImageDrawText(dst: [*c]Image, text: [*c]const u8, posX: c_int, posY: c_int, fontSize: c_int, color: Color) void; -pub extern fn ImageDrawTextEx(dst: [*c]Image, font: Font, text: [*c]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; -pub extern fn LoadTexture(fileName: [*c]const u8) Texture2D; -pub extern fn LoadTextureFromImage(image: Image) Texture2D; -pub extern fn LoadTextureCubemap(image: Image, layout: c_int) TextureCubemap; -pub extern fn LoadRenderTexture(width: c_int, height: c_int) RenderTexture2D; -pub extern fn IsTextureReady(texture: Texture2D) bool; -pub extern fn UnloadTexture(texture: Texture2D) void; -pub extern fn IsRenderTextureReady(target: RenderTexture2D) bool; -pub extern fn UnloadRenderTexture(target: RenderTexture2D) void; -pub extern fn UpdateTexture(texture: Texture2D, pixels: ?*const anyopaque) void; -pub extern fn UpdateTextureRec(texture: Texture2D, rec: Rectangle, pixels: ?*const anyopaque) void; -pub extern fn GenTextureMipmaps(texture: [*c]Texture2D) void; -pub extern fn SetTextureFilter(texture: Texture2D, filter: c_int) void; -pub extern fn SetTextureWrap(texture: Texture2D, wrap: c_int) void; -pub extern fn DrawTexture(texture: Texture2D, posX: c_int, posY: c_int, tint: Color) void; -pub extern fn DrawTextureV(texture: Texture2D, position: Vector2, tint: Color) void; -pub extern fn DrawTextureEx(texture: Texture2D, position: Vector2, rotation: f32, scale: f32, tint: Color) void; -pub extern fn DrawTextureRec(texture: Texture2D, source: Rectangle, position: Vector2, tint: Color) void; -pub extern fn DrawTexturePro(texture: Texture2D, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void; -pub extern fn DrawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void; -pub extern fn ColorIsEqual(col1: Color, col2: Color) bool; -pub extern fn Fade(color: Color, alpha: f32) Color; -pub extern fn ColorToInt(color: Color) c_int; -pub extern fn ColorNormalize(color: Color) Vector4; -pub extern fn ColorFromNormalized(normalized: Vector4) Color; -pub extern fn ColorToHSV(color: Color) Vector3; -pub extern fn ColorFromHSV(hue: f32, saturation: f32, value: f32) Color; -pub extern fn ColorTint(color: Color, tint: Color) Color; -pub extern fn ColorBrightness(color: Color, factor: f32) Color; -pub extern fn ColorContrast(color: Color, contrast: f32) Color; -pub extern fn ColorAlpha(color: Color, alpha: f32) Color; -pub extern fn ColorAlphaBlend(dst: Color, src: Color, tint: Color) Color; -pub extern fn GetColor(hexValue: c_uint) Color; -pub extern fn GetPixelColor(srcPtr: ?*anyopaque, format: c_int) Color; -pub extern fn SetPixelColor(dstPtr: ?*anyopaque, color: Color, format: c_int) void; -pub extern fn GetPixelDataSize(width: c_int, height: c_int, format: c_int) c_int; -pub extern fn GetFontDefault() Font; -pub extern fn LoadFont(fileName: [*c]const u8) Font; -pub extern fn LoadFontEx(fileName: [*c]const u8, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int) Font; -pub extern fn LoadFontFromImage(image: Image, key: Color, firstChar: c_int) Font; -pub extern fn LoadFontFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int) Font; -pub extern fn IsFontReady(font: Font) bool; -pub extern fn LoadFontData(fileData: [*c]const u8, dataSize: c_int, fontSize: c_int, codepoints: [*c]c_int, codepointCount: c_int, @"type": c_int) [*c]GlyphInfo; -pub extern fn GenImageFontAtlas(glyphs: [*c]const GlyphInfo, glyphRecs: [*c][*c]Rectangle, glyphCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) Image; -pub extern fn UnloadFontData(glyphs: [*c]GlyphInfo, glyphCount: c_int) void; -pub extern fn UnloadFont(font: Font) void; -pub extern fn ExportFontAsCode(font: Font, fileName: [*c]const u8) bool; -pub extern fn DrawFPS(posX: c_int, posY: c_int) void; -pub extern fn DrawText(text: [*c]const u8, posX: c_int, posY: c_int, fontSize: c_int, color: Color) void; -pub extern fn DrawTextEx(font: Font, text: [*c]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; -pub extern fn DrawTextPro(font: Font, text: [*c]const u8, position: Vector2, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) void; -pub extern fn DrawTextCodepoint(font: Font, codepoint: c_int, position: Vector2, fontSize: f32, tint: Color) void; -pub extern fn DrawTextCodepoints(font: Font, codepoints: [*c]const c_int, codepointCount: c_int, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; -pub extern fn SetTextLineSpacing(spacing: c_int) void; -pub extern fn MeasureText(text: [*c]const u8, fontSize: c_int) c_int; -pub extern fn MeasureTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32) Vector2; -pub extern fn GetGlyphIndex(font: Font, codepoint: c_int) c_int; -pub extern fn GetGlyphInfo(font: Font, codepoint: c_int) GlyphInfo; -pub extern fn GetGlyphAtlasRec(font: Font, codepoint: c_int) Rectangle; -pub extern fn LoadUTF8(codepoints: [*c]const c_int, length: c_int) [*c]u8; -pub extern fn UnloadUTF8(text: [*c]u8) void; -pub extern fn LoadCodepoints(text: [*c]const u8, count: [*c]c_int) [*c]c_int; -pub extern fn UnloadCodepoints(codepoints: [*c]c_int) void; -pub extern fn GetCodepointCount(text: [*c]const u8) c_int; -pub extern fn GetCodepoint(text: [*c]const u8, codepointSize: [*c]c_int) c_int; -pub extern fn GetCodepointNext(text: [*c]const u8, codepointSize: [*c]c_int) c_int; -pub extern fn GetCodepointPrevious(text: [*c]const u8, codepointSize: [*c]c_int) c_int; -pub extern fn CodepointToUTF8(codepoint: c_int, utf8Size: [*c]c_int) [*c]const u8; -pub extern fn TextCopy(dst: [*c]u8, src: [*c]const u8) c_int; -pub extern fn TextIsEqual(text1: [*c]const u8, text2: [*c]const u8) bool; -pub extern fn TextLength(text: [*c]const u8) c_uint; -pub extern fn TextFormat(text: [*c]const u8, ...) [*c]const u8; -pub extern fn TextSubtext(text: [*c]const u8, position: c_int, length: c_int) [*c]const u8; -pub extern fn TextReplace(text: [*c]const u8, replace: [*c]const u8, by: [*c]const u8) [*c]u8; -pub extern fn TextInsert(text: [*c]const u8, insert: [*c]const u8, position: c_int) [*c]u8; -pub extern fn TextJoin(textList: [*c][*c]const u8, count: c_int, delimiter: [*c]const u8) [*c]const u8; -pub extern fn TextSplit(text: [*c]const u8, delimiter: u8, count: [*c]c_int) [*c][*c]const u8; -pub extern fn TextAppend(text: [*c]u8, append: [*c]const u8, position: [*c]c_int) void; -pub extern fn TextFindIndex(text: [*c]const u8, find: [*c]const u8) c_int; -pub extern fn TextToUpper(text: [*c]const u8) [*c]const u8; -pub extern fn TextToLower(text: [*c]const u8) [*c]const u8; -pub extern fn TextToPascal(text: [*c]const u8) [*c]const u8; -pub extern fn TextToSnake(text: [*c]const u8) [*c]const u8; -pub extern fn TextToCamel(text: [*c]const u8) [*c]const u8; -pub extern fn TextToInteger(text: [*c]const u8) c_int; -pub extern fn TextToFloat(text: [*c]const u8) f32; -pub export fn DrawLine3D(arg_startPos: Vector3, arg_endPos: Vector3, arg_color: Color) void { - var startPos = arg_startPos; - _ = &startPos; - var endPos = arg_endPos; - _ = &endPos; - var color = arg_color; - _ = &color; - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex3f(startPos.x, startPos.y, startPos.z); - rlVertex3f(endPos.x, endPos.y, endPos.z); - rlEnd(); -} -pub export fn DrawPoint3D(arg_position: Vector3, arg_color: Color) void { - var position = arg_position; - _ = &position; - var color = arg_color; - _ = &color; - rlPushMatrix(); - rlTranslatef(position.x, position.y, position.z); - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex3f(0.0, 0.0, 0.0); - rlVertex3f(0.0, 0.0, 0.10000000149011612); - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawCircle3D(arg_center: Vector3, arg_radius: f32, arg_rotationAxis: Vector3, arg_rotationAngle: f32, arg_color: Color) void { - var center = arg_center; - _ = ¢er; - var radius = arg_radius; - _ = &radius; - var rotationAxis = arg_rotationAxis; - _ = &rotationAxis; - var rotationAngle = arg_rotationAngle; - _ = &rotationAngle; - var color = arg_color; - _ = &color; - rlPushMatrix(); - rlTranslatef(center.x, center.y, center.z); - rlRotatef(rotationAngle, rotationAxis.x, rotationAxis.y, rotationAxis.z); - rlBegin(@as(c_int, 1)); - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 360)) : (i += @as(c_int, 10)) { - rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex3f(sinf((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * radius, cosf((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * radius, 0.0); - rlVertex3f(sinf((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 10)))) * radius, cosf((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 10)))) * radius, 0.0); - } - } - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawTriangle3D(arg_v1: Vector3, arg_v2: Vector3, arg_v3: Vector3, arg_color: Color) void { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var v3 = arg_v3; - _ = &v3; - var color = arg_color; - _ = &color; - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex3f(v1.x, v1.y, v1.z); - rlVertex3f(v2.x, v2.y, v2.z); - rlVertex3f(v3.x, v3.y, v3.z); - rlEnd(); -} -pub export fn DrawTriangleStrip3D(arg_points: [*c]const Vector3, arg_pointCount: c_int, arg_color: Color) void { - var points = arg_points; - _ = &points; - var pointCount = arg_pointCount; - _ = &pointCount; - var color = arg_color; - _ = &color; - if (pointCount < @as(c_int, 3)) return; - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var i: c_int = 2; - _ = &i; - while (i < pointCount) : (i += 1) { - if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 2)) == @as(c_int, 0)) { - rlVertex3f((blk: { - const tmp = i; - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x, (blk: { - const tmp = i; - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y, (blk: { - const tmp = i; - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z); - rlVertex3f((blk: { - const tmp = i - @as(c_int, 2); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x, (blk: { - const tmp = i - @as(c_int, 2); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y, (blk: { - const tmp = i - @as(c_int, 2); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z); - rlVertex3f((blk: { - const tmp = i - @as(c_int, 1); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x, (blk: { - const tmp = i - @as(c_int, 1); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y, (blk: { - const tmp = i - @as(c_int, 1); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z); - } else { - rlVertex3f((blk: { - const tmp = i; - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x, (blk: { - const tmp = i; - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y, (blk: { - const tmp = i; - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z); - rlVertex3f((blk: { - const tmp = i - @as(c_int, 1); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x, (blk: { - const tmp = i - @as(c_int, 1); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y, (blk: { - const tmp = i - @as(c_int, 1); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z); - rlVertex3f((blk: { - const tmp = i - @as(c_int, 2); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x, (blk: { - const tmp = i - @as(c_int, 2); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y, (blk: { - const tmp = i - @as(c_int, 2); - if (tmp >= 0) break :blk points + @as(usize, @intCast(tmp)) else break :blk points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z); - } - } - } - rlEnd(); -} -pub export fn DrawCube(arg_position: Vector3, arg_width: f32, arg_height: f32, arg_length: f32, arg_color: Color) void { - var position = arg_position; - _ = &position; - var width = arg_width; - _ = &width; - var height = arg_height; - _ = &height; - var length = arg_length; - _ = &length; - var color = arg_color; - _ = &color; - var x: f32 = 0.0; - _ = &x; - var y: f32 = 0.0; - _ = &y; - var z: f32 = 0.0; - _ = &z; - rlPushMatrix(); - rlTranslatef(position.x, position.y, position.z); - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlNormal3f(0.0, 0.0, 1.0); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlNormal3f(0.0, 0.0, -1.0); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlNormal3f(0.0, 1.0, 0.0); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlNormal3f(0.0, -1.0, 0.0); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlNormal3f(1.0, 0.0, 0.0); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlNormal3f(-1.0, 0.0, 0.0); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawCubeV(arg_position: Vector3, arg_size: Vector3, arg_color: Color) void { - var position = arg_position; - _ = &position; - var size = arg_size; - _ = &size; - var color = arg_color; - _ = &color; - DrawCube(position, size.x, size.y, size.z, color); -} -pub export fn DrawCubeWires(arg_position: Vector3, arg_width: f32, arg_height: f32, arg_length: f32, arg_color: Color) void { - var position = arg_position; - _ = &position; - var width = arg_width; - _ = &width; - var height = arg_height; - _ = &height; - var length = arg_length; - _ = &length; - var color = arg_color; - _ = &color; - var x: f32 = 0.0; - _ = &x; - var y: f32 = 0.0; - _ = &y; - var z: f32 = 0.0; - _ = &z; - rlPushMatrix(); - rlTranslatef(position.x, position.y, position.z); - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y + (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x - (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z + (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlVertex3f(x + (width / @as(f32, @floatFromInt(@as(c_int, 2)))), y - (height / @as(f32, @floatFromInt(@as(c_int, 2)))), z - (length / @as(f32, @floatFromInt(@as(c_int, 2))))); - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawCubeWiresV(arg_position: Vector3, arg_size: Vector3, arg_color: Color) void { - var position = arg_position; - _ = &position; - var size = arg_size; - _ = &size; - var color = arg_color; - _ = &color; - DrawCubeWires(position, size.x, size.y, size.z, color); -} -pub export fn DrawSphere(arg_centerPos: Vector3, arg_radius: f32, arg_color: Color) void { - var centerPos = arg_centerPos; - _ = ¢erPos; - var radius = arg_radius; - _ = &radius; - var color = arg_color; - _ = &color; - DrawSphereEx(centerPos, radius, @as(c_int, 16), @as(c_int, 16), color); -} -pub export fn DrawSphereEx(arg_centerPos: Vector3, arg_radius: f32, arg_rings: c_int, arg_slices: c_int, arg_color: Color) void { - var centerPos = arg_centerPos; - _ = ¢erPos; - var radius = arg_radius; - _ = &radius; - var rings = arg_rings; - _ = &rings; - var slices = arg_slices; - _ = &slices; - var color = arg_color; - _ = &color; - rlPushMatrix(); - rlTranslatef(centerPos.x, centerPos.y, centerPos.z); - rlScalef(radius, radius, radius); - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - var ringangle: f32 = (3.1415927410125732 / 180.0) * (180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))); - _ = &ringangle; - var sliceangle: f32 = (3.1415927410125732 / 180.0) * (360.0 / @as(f32, @floatFromInt(slices))); - _ = &sliceangle; - var cosring: f32 = cosf(ringangle); - _ = &cosring; - var sinring: f32 = sinf(ringangle); - _ = &sinring; - var cosslice: f32 = cosf(sliceangle); - _ = &cosslice; - var sinslice: f32 = sinf(sliceangle); - _ = &sinslice; - var vertices: [4]Vector3 = [1]Vector3{ - Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }, - } ++ [1]Vector3{@import("std").mem.zeroes(Vector3)} ** 3; - _ = &vertices; - vertices[@as(c_uint, @intCast(@as(c_int, 2)))] = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }; - vertices[@as(c_uint, @intCast(@as(c_int, 3)))] = Vector3{ - .x = sinring, - .y = cosring, - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }; - { - var i: c_int = 0; - _ = &i; - while (i < (rings + @as(c_int, 1))) : (i += 1) { - { - var j: c_int = 0; - _ = &j; - while (j < slices) : (j += 1) { - vertices[@as(c_uint, @intCast(@as(c_int, 0)))] = vertices[@as(c_uint, @intCast(@as(c_int, 2)))]; - vertices[@as(c_uint, @intCast(@as(c_int, 1)))] = vertices[@as(c_uint, @intCast(@as(c_int, 3)))]; - vertices[@as(c_uint, @intCast(@as(c_int, 2)))] = Vector3{ - .x = (cosslice * vertices[@as(c_uint, @intCast(@as(c_int, 2)))].x) - (sinslice * vertices[@as(c_uint, @intCast(@as(c_int, 2)))].z), - .y = vertices[@as(c_uint, @intCast(@as(c_int, 2)))].y, - .z = (sinslice * vertices[@as(c_uint, @intCast(@as(c_int, 2)))].x) + (cosslice * vertices[@as(c_uint, @intCast(@as(c_int, 2)))].z), - }; - vertices[@as(c_uint, @intCast(@as(c_int, 3)))] = Vector3{ - .x = (cosslice * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].x) - (sinslice * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].z), - .y = vertices[@as(c_uint, @intCast(@as(c_int, 3)))].y, - .z = (sinslice * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].x) + (cosslice * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].z), - }; - rlVertex3f(vertices[@as(c_uint, @intCast(@as(c_int, 0)))].x, vertices[@as(c_uint, @intCast(@as(c_int, 0)))].y, vertices[@as(c_uint, @intCast(@as(c_int, 0)))].z); - rlVertex3f(vertices[@as(c_uint, @intCast(@as(c_int, 3)))].x, vertices[@as(c_uint, @intCast(@as(c_int, 3)))].y, vertices[@as(c_uint, @intCast(@as(c_int, 3)))].z); - rlVertex3f(vertices[@as(c_uint, @intCast(@as(c_int, 1)))].x, vertices[@as(c_uint, @intCast(@as(c_int, 1)))].y, vertices[@as(c_uint, @intCast(@as(c_int, 1)))].z); - rlVertex3f(vertices[@as(c_uint, @intCast(@as(c_int, 0)))].x, vertices[@as(c_uint, @intCast(@as(c_int, 0)))].y, vertices[@as(c_uint, @intCast(@as(c_int, 0)))].z); - rlVertex3f(vertices[@as(c_uint, @intCast(@as(c_int, 2)))].x, vertices[@as(c_uint, @intCast(@as(c_int, 2)))].y, vertices[@as(c_uint, @intCast(@as(c_int, 2)))].z); - rlVertex3f(vertices[@as(c_uint, @intCast(@as(c_int, 3)))].x, vertices[@as(c_uint, @intCast(@as(c_int, 3)))].y, vertices[@as(c_uint, @intCast(@as(c_int, 3)))].z); - } - } - vertices[@as(c_uint, @intCast(@as(c_int, 2)))] = vertices[@as(c_uint, @intCast(@as(c_int, 3)))]; - vertices[@as(c_uint, @intCast(@as(c_int, 3)))] = Vector3{ - .x = (cosring * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].x) + (sinring * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].y), - .y = (-sinring * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].x) + (cosring * vertices[@as(c_uint, @intCast(@as(c_int, 3)))].y), - .z = vertices[@as(c_uint, @intCast(@as(c_int, 3)))].z, - }; - } - } - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawSphereWires(arg_centerPos: Vector3, arg_radius: f32, arg_rings: c_int, arg_slices: c_int, arg_color: Color) void { - var centerPos = arg_centerPos; - _ = ¢erPos; - var radius = arg_radius; - _ = &radius; - var rings = arg_rings; - _ = &rings; - var slices = arg_slices; - _ = &slices; - var color = arg_color; - _ = &color; - rlPushMatrix(); - rlTranslatef(centerPos.x, centerPos.y, centerPos.z); - rlScalef(radius, radius, radius); - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var i: c_int = 0; - _ = &i; - while (i < (rings + @as(c_int, 2))) : (i += 1) { - { - var j: c_int = 0; - _ = &j; - while (j < slices) : (j += 1) { - rlVertex3f(cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i))))) * sinf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices)))), sinf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i))))), cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i))))) * cosf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices))))); - rlVertex3f(cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * sinf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j + @as(c_int, 1)))) / @as(f32, @floatFromInt(slices)))), sinf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))), cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * cosf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j + @as(c_int, 1)))) / @as(f32, @floatFromInt(slices))))); - rlVertex3f(cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * sinf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j + @as(c_int, 1)))) / @as(f32, @floatFromInt(slices)))), sinf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))), cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * cosf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j + @as(c_int, 1)))) / @as(f32, @floatFromInt(slices))))); - rlVertex3f(cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * sinf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices)))), sinf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))), cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * cosf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices))))); - rlVertex3f(cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * sinf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices)))), sinf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))), cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i + @as(c_int, 1)))))) * cosf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices))))); - rlVertex3f(cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i))))) * sinf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices)))), sinf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i))))), cosf((3.1415927410125732 / 180.0) * (@as(f32, @floatFromInt(@as(c_int, 270))) + ((180.0 / @as(f32, @floatFromInt(rings + @as(c_int, 1)))) * @as(f32, @floatFromInt(i))))) * cosf((3.1415927410125732 / 180.0) * ((360.0 * @as(f32, @floatFromInt(j))) / @as(f32, @floatFromInt(slices))))); - } - } - } - } - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawCylinder(arg_position: Vector3, arg_radiusTop: f32, arg_radiusBottom: f32, arg_height: f32, arg_sides: c_int, arg_color: Color) void { - var position = arg_position; - _ = &position; - var radiusTop = arg_radiusTop; - _ = &radiusTop; - var radiusBottom = arg_radiusBottom; - _ = &radiusBottom; - var height = arg_height; - _ = &height; - var sides = arg_sides; - _ = &sides; - var color = arg_color; - _ = &color; - if (sides < @as(c_int, 3)) { - sides = 3; - } - const angleStep: f32 = 360.0 / @as(f32, @floatFromInt(sides)); - _ = &angleStep; - rlPushMatrix(); - rlTranslatef(position.x, position.y, position.z); - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - if (radiusTop > @as(f32, @floatFromInt(@as(c_int, 0)))) { - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop); - } - } - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - rlVertex3f(@as(f32, @floatFromInt(@as(c_int, 0))), height, @as(f32, @floatFromInt(@as(c_int, 0)))); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop); - } - } - } else { - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - rlVertex3f(@as(f32, @floatFromInt(@as(c_int, 0))), height, @as(f32, @floatFromInt(@as(c_int, 0)))); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom); - } - } - } - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - rlVertex3f(@as(f32, @floatFromInt(@as(c_int, 0))), @as(f32, @floatFromInt(@as(c_int, 0))), @as(f32, @floatFromInt(@as(c_int, 0)))); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom); - } - } - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawCylinderEx(arg_startPos: Vector3, arg_endPos: Vector3, arg_startRadius: f32, arg_endRadius: f32, arg_sides: c_int, arg_color: Color) void { - var startPos = arg_startPos; - _ = &startPos; - var endPos = arg_endPos; - _ = &endPos; - var startRadius = arg_startRadius; - _ = &startRadius; - var endRadius = arg_endRadius; - _ = &endRadius; - var sides = arg_sides; - _ = &sides; - var color = arg_color; - _ = &color; - if (sides < @as(c_int, 3)) { - sides = 3; - } - var direction: Vector3 = Vector3{ - .x = endPos.x - startPos.x, - .y = endPos.y - startPos.y, - .z = endPos.z - startPos.z, - }; - _ = &direction; - if (((direction.x == @as(f32, @floatFromInt(@as(c_int, 0)))) and (direction.y == @as(f32, @floatFromInt(@as(c_int, 0))))) and (direction.z == @as(f32, @floatFromInt(@as(c_int, 0))))) return; - var b1: Vector3 = Vector3Normalize(Vector3Perpendicular(direction)); - _ = &b1; - var b2: Vector3 = Vector3Normalize(Vector3CrossProduct(b1, direction)); - _ = &b2; - var baseAngle: f32 = (2.0 * 3.1415927410125732) / @as(f32, @floatFromInt(sides)); - _ = &baseAngle; - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - var s1: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * startRadius; - _ = &s1; - var c1: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * startRadius; - _ = &c1; - var w1: Vector3 = Vector3{ - .x = (startPos.x + (s1 * b1.x)) + (c1 * b2.x), - .y = (startPos.y + (s1 * b1.y)) + (c1 * b2.y), - .z = (startPos.z + (s1 * b1.z)) + (c1 * b2.z), - }; - _ = &w1; - var s2: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * startRadius; - _ = &s2; - var c2: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * startRadius; - _ = &c2; - var w2: Vector3 = Vector3{ - .x = (startPos.x + (s2 * b1.x)) + (c2 * b2.x), - .y = (startPos.y + (s2 * b1.y)) + (c2 * b2.y), - .z = (startPos.z + (s2 * b1.z)) + (c2 * b2.z), - }; - _ = &w2; - var s3: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * endRadius; - _ = &s3; - var c3: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * endRadius; - _ = &c3; - var w3: Vector3 = Vector3{ - .x = (endPos.x + (s3 * b1.x)) + (c3 * b2.x), - .y = (endPos.y + (s3 * b1.y)) + (c3 * b2.y), - .z = (endPos.z + (s3 * b1.z)) + (c3 * b2.z), - }; - _ = &w3; - var s4: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * endRadius; - _ = &s4; - var c4: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * endRadius; - _ = &c4; - var w4: Vector3 = Vector3{ - .x = (endPos.x + (s4 * b1.x)) + (c4 * b2.x), - .y = (endPos.y + (s4 * b1.y)) + (c4 * b2.y), - .z = (endPos.z + (s4 * b1.z)) + (c4 * b2.z), - }; - _ = &w4; - if (startRadius > @as(f32, @floatFromInt(@as(c_int, 0)))) { - rlVertex3f(startPos.x, startPos.y, startPos.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w1.x, w1.y, w1.z); - } - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w4.x, w4.y, w4.z); - rlVertex3f(w3.x, w3.y, w3.z); - if (endRadius > @as(f32, @floatFromInt(@as(c_int, 0)))) { - rlVertex3f(endPos.x, endPos.y, endPos.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w4.x, w4.y, w4.z); - } - } - } - rlEnd(); -} -pub export fn DrawCylinderWires(arg_position: Vector3, arg_radiusTop: f32, arg_radiusBottom: f32, arg_height: f32, arg_sides: c_int, arg_color: Color) void { - var position = arg_position; - _ = &position; - var radiusTop = arg_radiusTop; - _ = &radiusTop; - var radiusBottom = arg_radiusBottom; - _ = &radiusBottom; - var height = arg_height; - _ = &height; - var sides = arg_sides; - _ = &sides; - var color = arg_color; - _ = &color; - if (sides < @as(c_int, 3)) { - sides = 3; - } - const angleStep: f32 = 360.0 / @as(f32, @floatFromInt(sides)); - _ = &angleStep; - rlPushMatrix(); - rlTranslatef(position.x, position.y, position.z); - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusBottom); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop, height, cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusTop); - rlVertex3f(sinf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom, @as(f32, @floatFromInt(@as(c_int, 0))), cosf(((3.1415927410125732 / 180.0) * @as(f32, @floatFromInt(i))) * angleStep) * radiusBottom); - } - } - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawCylinderWiresEx(arg_startPos: Vector3, arg_endPos: Vector3, arg_startRadius: f32, arg_endRadius: f32, arg_sides: c_int, arg_color: Color) void { - var startPos = arg_startPos; - _ = &startPos; - var endPos = arg_endPos; - _ = &endPos; - var startRadius = arg_startRadius; - _ = &startRadius; - var endRadius = arg_endRadius; - _ = &endRadius; - var sides = arg_sides; - _ = &sides; - var color = arg_color; - _ = &color; - if (sides < @as(c_int, 3)) { - sides = 3; - } - var direction: Vector3 = Vector3{ - .x = endPos.x - startPos.x, - .y = endPos.y - startPos.y, - .z = endPos.z - startPos.z, - }; - _ = &direction; - if (((direction.x == @as(f32, @floatFromInt(@as(c_int, 0)))) and (direction.y == @as(f32, @floatFromInt(@as(c_int, 0))))) and (direction.z == @as(f32, @floatFromInt(@as(c_int, 0))))) return; - var b1: Vector3 = Vector3Normalize(Vector3Perpendicular(direction)); - _ = &b1; - var b2: Vector3 = Vector3Normalize(Vector3CrossProduct(b1, direction)); - _ = &b2; - var baseAngle: f32 = (2.0 * 3.1415927410125732) / @as(f32, @floatFromInt(sides)); - _ = &baseAngle; - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var i: c_int = 0; - _ = &i; - while (i < sides) : (i += 1) { - var s1: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * startRadius; - _ = &s1; - var c1: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * startRadius; - _ = &c1; - var w1: Vector3 = Vector3{ - .x = (startPos.x + (s1 * b1.x)) + (c1 * b2.x), - .y = (startPos.y + (s1 * b1.y)) + (c1 * b2.y), - .z = (startPos.z + (s1 * b1.z)) + (c1 * b2.z), - }; - _ = &w1; - var s2: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * startRadius; - _ = &s2; - var c2: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * startRadius; - _ = &c2; - var w2: Vector3 = Vector3{ - .x = (startPos.x + (s2 * b1.x)) + (c2 * b2.x), - .y = (startPos.y + (s2 * b1.y)) + (c2 * b2.y), - .z = (startPos.z + (s2 * b1.z)) + (c2 * b2.z), - }; - _ = &w2; - var s3: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * endRadius; - _ = &s3; - var c3: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * endRadius; - _ = &c3; - var w3: Vector3 = Vector3{ - .x = (endPos.x + (s3 * b1.x)) + (c3 * b2.x), - .y = (endPos.y + (s3 * b1.y)) + (c3 * b2.y), - .z = (endPos.z + (s3 * b1.z)) + (c3 * b2.z), - }; - _ = &w3; - var s4: f32 = sinf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * endRadius; - _ = &s4; - var c4: f32 = cosf(baseAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * endRadius; - _ = &c4; - var w4: Vector3 = Vector3{ - .x = (endPos.x + (s4 * b1.x)) + (c4 * b2.x), - .y = (endPos.y + (s4 * b1.y)) + (c4 * b2.y), - .z = (endPos.z + (s4 * b1.z)) + (c4 * b2.z), - }; - _ = &w4; - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w4.x, w4.y, w4.z); - } - } - rlEnd(); -} -pub export fn DrawCapsule(arg_startPos: Vector3, arg_endPos: Vector3, arg_radius: f32, arg_slices: c_int, arg_rings: c_int, arg_color: Color) void { - var startPos = arg_startPos; - _ = &startPos; - var endPos = arg_endPos; - _ = &endPos; - var radius = arg_radius; - _ = &radius; - var slices = arg_slices; - _ = &slices; - var rings = arg_rings; - _ = &rings; - var color = arg_color; - _ = &color; - if (slices < @as(c_int, 3)) { - slices = 3; - } - var direction: Vector3 = Vector3{ - .x = endPos.x - startPos.x, - .y = endPos.y - startPos.y, - .z = endPos.z - startPos.z, - }; - _ = &direction; - var sphereCase: bool = ((direction.x == @as(f32, @floatFromInt(@as(c_int, 0)))) and (direction.y == @as(f32, @floatFromInt(@as(c_int, 0))))) and (direction.z == @as(f32, @floatFromInt(@as(c_int, 0)))); - _ = &sphereCase; - if (sphereCase) { - direction = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - } - var b0: Vector3 = Vector3Normalize(direction); - _ = &b0; - var b1: Vector3 = Vector3Normalize(Vector3Perpendicular(direction)); - _ = &b1; - var b2: Vector3 = Vector3Normalize(Vector3CrossProduct(b1, direction)); - _ = &b2; - var capCenter: Vector3 = endPos; - _ = &capCenter; - var baseSliceAngle: f32 = (2.0 * 3.1415927410125732) / @as(f32, @floatFromInt(slices)); - _ = &baseSliceAngle; - var baseRingAngle: f32 = (3.1415927410125732 * 0.5) / @as(f32, @floatFromInt(rings)); - _ = &baseRingAngle; - rlBegin(@as(c_int, 4)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var c: c_int = 0; - _ = &c; - while (c < @as(c_int, 2)) : (c += 1) { - { - var i: c_int = 0; - _ = &i; - while (i < rings) : (i += 1) { - { - var j: c_int = 0; - _ = &j; - while (j < slices) : (j += 1) { - var ringSin1: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringSin1; - var ringCos1: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringCos1; - var w1: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.x) + (ringSin1 * b1.x)) + (ringCos1 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.y) + (ringSin1 * b1.y)) + (ringCos1 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.z) + (ringSin1 * b1.z)) + (ringCos1 * b2.z)) * radius), - }; - _ = &w1; - var ringSin2: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringSin2; - var ringCos2: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringCos2; - var w2: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.x) + (ringSin2 * b1.x)) + (ringCos2 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.y) + (ringSin2 * b1.y)) + (ringCos2 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.z) + (ringSin2 * b1.z)) + (ringCos2 * b2.z)) * radius), - }; - _ = &w2; - var ringSin3: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringSin3; - var ringCos3: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringCos3; - var w3: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.x) + (ringSin3 * b1.x)) + (ringCos3 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.y) + (ringSin3 * b1.y)) + (ringCos3 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.z) + (ringSin3 * b1.z)) + (ringCos3 * b2.z)) * radius), - }; - _ = &w3; - var ringSin4: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringSin4; - var ringCos4: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringCos4; - var w4: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.x) + (ringSin4 * b1.x)) + (ringCos4 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.y) + (ringSin4 * b1.y)) + (ringCos4 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.z) + (ringSin4 * b1.z)) + (ringCos4 * b2.z)) * radius), - }; - _ = &w4; - if (c == @as(c_int, 0)) { - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w4.x, w4.y, w4.z); - rlVertex3f(w3.x, w3.y, w3.z); - } else { - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w4.x, w4.y, w4.z); - } - } - } - } - } - capCenter = startPos; - b0 = Vector3Scale(b0, -1.0); - } - } - if (!sphereCase) { - { - var j: c_int = 0; - _ = &j; - while (j < slices) : (j += 1) { - var ringSin1: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringSin1; - var ringCos1: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringCos1; - var w1: Vector3 = Vector3{ - .x = (startPos.x + (ringSin1 * b1.x)) + (ringCos1 * b2.x), - .y = (startPos.y + (ringSin1 * b1.y)) + (ringCos1 * b2.y), - .z = (startPos.z + (ringSin1 * b1.z)) + (ringCos1 * b2.z), - }; - _ = &w1; - var ringSin2: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringSin2; - var ringCos2: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringCos2; - var w2: Vector3 = Vector3{ - .x = (startPos.x + (ringSin2 * b1.x)) + (ringCos2 * b2.x), - .y = (startPos.y + (ringSin2 * b1.y)) + (ringCos2 * b2.y), - .z = (startPos.z + (ringSin2 * b1.z)) + (ringCos2 * b2.z), - }; - _ = &w2; - var ringSin3: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringSin3; - var ringCos3: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringCos3; - var w3: Vector3 = Vector3{ - .x = (endPos.x + (ringSin3 * b1.x)) + (ringCos3 * b2.x), - .y = (endPos.y + (ringSin3 * b1.y)) + (ringCos3 * b2.y), - .z = (endPos.z + (ringSin3 * b1.z)) + (ringCos3 * b2.z), - }; - _ = &w3; - var ringSin4: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringSin4; - var ringCos4: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringCos4; - var w4: Vector3 = Vector3{ - .x = (endPos.x + (ringSin4 * b1.x)) + (ringCos4 * b2.x), - .y = (endPos.y + (ringSin4 * b1.y)) + (ringCos4 * b2.y), - .z = (endPos.z + (ringSin4 * b1.z)) + (ringCos4 * b2.z), - }; - _ = &w4; - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w4.x, w4.y, w4.z); - rlVertex3f(w3.x, w3.y, w3.z); - } - } - } - rlEnd(); -} -pub export fn DrawCapsuleWires(arg_startPos: Vector3, arg_endPos: Vector3, arg_radius: f32, arg_slices: c_int, arg_rings: c_int, arg_color: Color) void { - var startPos = arg_startPos; - _ = &startPos; - var endPos = arg_endPos; - _ = &endPos; - var radius = arg_radius; - _ = &radius; - var slices = arg_slices; - _ = &slices; - var rings = arg_rings; - _ = &rings; - var color = arg_color; - _ = &color; - if (slices < @as(c_int, 3)) { - slices = 3; - } - var direction: Vector3 = Vector3{ - .x = endPos.x - startPos.x, - .y = endPos.y - startPos.y, - .z = endPos.z - startPos.z, - }; - _ = &direction; - var sphereCase: bool = ((direction.x == @as(f32, @floatFromInt(@as(c_int, 0)))) and (direction.y == @as(f32, @floatFromInt(@as(c_int, 0))))) and (direction.z == @as(f32, @floatFromInt(@as(c_int, 0)))); - _ = &sphereCase; - if (sphereCase) { - direction = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - } - var b0: Vector3 = Vector3Normalize(direction); - _ = &b0; - var b1: Vector3 = Vector3Normalize(Vector3Perpendicular(direction)); - _ = &b1; - var b2: Vector3 = Vector3Normalize(Vector3CrossProduct(b1, direction)); - _ = &b2; - var capCenter: Vector3 = endPos; - _ = &capCenter; - var baseSliceAngle: f32 = (2.0 * 3.1415927410125732) / @as(f32, @floatFromInt(slices)); - _ = &baseSliceAngle; - var baseRingAngle: f32 = (3.1415927410125732 * 0.5) / @as(f32, @floatFromInt(rings)); - _ = &baseRingAngle; - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - { - var c: c_int = 0; - _ = &c; - while (c < @as(c_int, 2)) : (c += 1) { - { - var i: c_int = 0; - _ = &i; - while (i < rings) : (i += 1) { - { - var j: c_int = 0; - _ = &j; - while (j < slices) : (j += 1) { - var ringSin1: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringSin1; - var ringCos1: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringCos1; - var w1: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.x) + (ringSin1 * b1.x)) + (ringCos1 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.y) + (ringSin1 * b1.y)) + (ringCos1 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.z) + (ringSin1 * b1.z)) + (ringCos1 * b2.z)) * radius), - }; - _ = &w1; - var ringSin2: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringSin2; - var ringCos2: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))); - _ = &ringCos2; - var w2: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.x) + (ringSin2 * b1.x)) + (ringCos2 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.y) + (ringSin2 * b1.y)) + (ringCos2 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 0)))) * b0.z) + (ringSin2 * b1.z)) + (ringCos2 * b2.z)) * radius), - }; - _ = &w2; - var ringSin3: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringSin3; - var ringCos3: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringCos3; - var w3: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.x) + (ringSin3 * b1.x)) + (ringCos3 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.y) + (ringSin3 * b1.y)) + (ringCos3 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.z) + (ringSin3 * b1.z)) + (ringCos3 * b2.z)) * radius), - }; - _ = &w3; - var ringSin4: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringSin4; - var ringCos4: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * cosf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))); - _ = &ringCos4; - var w4: Vector3 = Vector3{ - .x = capCenter.x + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.x) + (ringSin4 * b1.x)) + (ringCos4 * b2.x)) * radius), - .y = capCenter.y + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.y) + (ringSin4 * b1.y)) + (ringCos4 * b2.y)) * radius), - .z = capCenter.z + ((((sinf(baseRingAngle * @as(f32, @floatFromInt(i + @as(c_int, 1)))) * b0.z) + (ringSin4 * b1.z)) + (ringCos4 * b2.z)) * radius), - }; - _ = &w4; - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w4.x, w4.y, w4.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w4.x, w4.y, w4.z); - } - } - } - } - capCenter = startPos; - b0 = Vector3Scale(b0, -1.0); - } - } - if (!sphereCase) { - { - var j: c_int = 0; - _ = &j; - while (j < slices) : (j += 1) { - var ringSin1: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringSin1; - var ringCos1: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringCos1; - var w1: Vector3 = Vector3{ - .x = (startPos.x + (ringSin1 * b1.x)) + (ringCos1 * b2.x), - .y = (startPos.y + (ringSin1 * b1.y)) + (ringCos1 * b2.y), - .z = (startPos.z + (ringSin1 * b1.z)) + (ringCos1 * b2.z), - }; - _ = &w1; - var ringSin2: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringSin2; - var ringCos2: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringCos2; - var w2: Vector3 = Vector3{ - .x = (startPos.x + (ringSin2 * b1.x)) + (ringCos2 * b2.x), - .y = (startPos.y + (ringSin2 * b1.y)) + (ringCos2 * b2.y), - .z = (startPos.z + (ringSin2 * b1.z)) + (ringCos2 * b2.z), - }; - _ = &w2; - var ringSin3: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringSin3; - var ringCos3: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 0)))) * radius; - _ = &ringCos3; - var w3: Vector3 = Vector3{ - .x = (endPos.x + (ringSin3 * b1.x)) + (ringCos3 * b2.x), - .y = (endPos.y + (ringSin3 * b1.y)) + (ringCos3 * b2.y), - .z = (endPos.z + (ringSin3 * b1.z)) + (ringCos3 * b2.z), - }; - _ = &w3; - var ringSin4: f32 = sinf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringSin4; - var ringCos4: f32 = cosf(baseSliceAngle * @as(f32, @floatFromInt(j + @as(c_int, 1)))) * radius; - _ = &ringCos4; - var w4: Vector3 = Vector3{ - .x = (endPos.x + (ringSin4 * b1.x)) + (ringCos4 * b2.x), - .y = (endPos.y + (ringSin4 * b1.y)) + (ringCos4 * b2.y), - .z = (endPos.z + (ringSin4 * b1.z)) + (ringCos4 * b2.z), - }; - _ = &w4; - rlVertex3f(w1.x, w1.y, w1.z); - rlVertex3f(w3.x, w3.y, w3.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w4.x, w4.y, w4.z); - rlVertex3f(w2.x, w2.y, w2.z); - rlVertex3f(w3.x, w3.y, w3.z); - } - } - } - rlEnd(); -} -pub export fn DrawPlane(arg_centerPos: Vector3, arg_size: Vector2, arg_color: Color) void { - var centerPos = arg_centerPos; - _ = ¢erPos; - var size = arg_size; - _ = &size; - var color = arg_color; - _ = &color; - rlPushMatrix(); - rlTranslatef(centerPos.x, centerPos.y, centerPos.z); - rlScalef(size.x, 1.0, size.y); - rlBegin(@as(c_int, 7)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlNormal3f(0.0, 1.0, 0.0); - rlVertex3f(-0.5, 0.0, -0.5); - rlVertex3f(-0.5, 0.0, 0.5); - rlVertex3f(0.5, 0.0, 0.5); - rlVertex3f(0.5, 0.0, -0.5); - rlEnd(); - rlPopMatrix(); -} -pub export fn DrawRay(arg_ray: Ray, arg_color: Color) void { - var ray = arg_ray; - _ = &ray; - var color = arg_color; - _ = &color; - var scale: f32 = 10000; - _ = &scale; - rlBegin(@as(c_int, 1)); - rlColor4ub(color.r, color.g, color.b, color.a); - rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex3f(ray.position.x, ray.position.y, ray.position.z); - rlVertex3f(ray.position.x + (ray.direction.x * scale), ray.position.y + (ray.direction.y * scale), ray.position.z + (ray.direction.z * scale)); - rlEnd(); -} -pub export fn DrawGrid(arg_slices: c_int, arg_spacing: f32) void { - var slices = arg_slices; - _ = &slices; - var spacing = arg_spacing; - _ = &spacing; - var halfSlices: c_int = @divTrunc(slices, @as(c_int, 2)); - _ = &halfSlices; - rlBegin(@as(c_int, 1)); - { - var i: c_int = -halfSlices; - _ = &i; - while (i <= halfSlices) : (i += 1) { - if (i == @as(c_int, 0)) { - rlColor3f(0.5, 0.5, 0.5); - } else { - rlColor3f(0.75, 0.75, 0.75); - } - rlVertex3f(@as(f32, @floatFromInt(i)) * spacing, 0.0, @as(f32, @floatFromInt(-halfSlices)) * spacing); - rlVertex3f(@as(f32, @floatFromInt(i)) * spacing, 0.0, @as(f32, @floatFromInt(halfSlices)) * spacing); - rlVertex3f(@as(f32, @floatFromInt(-halfSlices)) * spacing, 0.0, @as(f32, @floatFromInt(i)) * spacing); - rlVertex3f(@as(f32, @floatFromInt(halfSlices)) * spacing, 0.0, @as(f32, @floatFromInt(i)) * spacing); - } - } - rlEnd(); -} -pub export fn LoadModel(arg_fileName: [*c]const u8) Model { - var fileName = arg_fileName; - _ = &fileName; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - if (IsFileExtension(fileName, ".obj")) { - model = LoadOBJ(fileName); - } - if (IsFileExtension(fileName, ".iqm")) { - model = LoadIQM(fileName); - } - if ((@as(c_int, @intFromBool(IsFileExtension(fileName, ".gltf"))) != 0) or (@as(c_int, @intFromBool(IsFileExtension(fileName, ".glb"))) != 0)) { - model = LoadGLTF(fileName); - } - if (IsFileExtension(fileName, ".vox")) { - model = LoadVOX(fileName); - } - if (IsFileExtension(fileName, ".m3d")) { - model = LoadM3D(fileName); - } - model.transform = MatrixIdentity(); - if ((model.meshCount != @as(c_int, 0)) and (model.meshes != @as([*c]Mesh, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - { - var i: c_int = 0; - _ = &i; - while (i < model.meshCount) : (i += 1) { - UploadMesh(&(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(c_int, 0) != 0); - } - } - } else { - TraceLog(LOG_WARNING, "MESH: [%s] Failed to load model mesh(es) data", fileName); - } - if (model.materialCount == @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MATERIAL: [%s] Failed to load model material data, default to white material", fileName); - model.materialCount = 1; - model.materials = @as([*c]Material, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.materialCount))), @sizeOf(Material))))); - model.materials[@as(c_uint, @intCast(@as(c_int, 0)))] = LoadMaterialDefault(); - if (model.meshMaterial == @as([*c]c_int, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(c_int))))); - } - } - return model; -} -pub export fn LoadModelFromMesh(arg_mesh: Mesh) Model { - var mesh = arg_mesh; - _ = &mesh; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - model.transform = MatrixIdentity(); - model.meshCount = 1; - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(Mesh))))); - model.meshes[@as(c_uint, @intCast(@as(c_int, 0)))] = mesh; - model.materialCount = 1; - model.materials = @as([*c]Material, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.materialCount))), @sizeOf(Material))))); - model.materials[@as(c_uint, @intCast(@as(c_int, 0)))] = LoadMaterialDefault(); - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(c_int))))); - model.meshMaterial[@as(c_uint, @intCast(@as(c_int, 0)))] = 0; - return model; -} -pub export fn IsModelReady(arg_model: Model) bool { - var model = arg_model; - _ = &model; - var result: bool = @as(c_int, 0) != 0; - _ = &result; - if (((((model.meshes != @as([*c]Mesh, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) and (model.materials != @as([*c]Material, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) and (model.meshMaterial != @as([*c]c_int, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) and (model.meshCount > @as(c_int, 0))) and (model.materialCount > @as(c_int, 0))) { - result = @as(c_int, 1) != 0; - } - return result; -} -pub export fn UnloadModel(arg_model: Model) void { - var model = arg_model; - _ = &model; - { - var i: c_int = 0; - _ = &i; - while (i < model.meshCount) : (i += 1) { - UnloadMesh((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*); - } - } - { - var i: c_int = 0; - _ = &i; - while (i < model.materialCount) : (i += 1) { - free(@as(?*anyopaque, @ptrCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.materials + @as(usize, @intCast(tmp)) else break :blk model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.maps))); - } - } - free(@as(?*anyopaque, @ptrCast(model.meshes))); - free(@as(?*anyopaque, @ptrCast(model.materials))); - free(@as(?*anyopaque, @ptrCast(model.meshMaterial))); - free(@as(?*anyopaque, @ptrCast(model.bones))); - free(@as(?*anyopaque, @ptrCast(model.bindPose))); - TraceLog(LOG_INFO, "MODEL: Unloaded model (and meshes) from RAM and VRAM"); -} -pub export fn GetModelBoundingBox(arg_model: Model) BoundingBox { - var model = arg_model; - _ = &model; - var bounds: BoundingBox = BoundingBox{ - .min = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }, - .max = @import("std").mem.zeroes(Vector3), - }; - _ = &bounds; - if (model.meshCount > @as(c_int, 0)) { - var temp: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &temp; - bounds = GetMeshBoundingBox(model.meshes[@as(c_uint, @intCast(@as(c_int, 0)))]); - { - var i: c_int = 1; - _ = &i; - while (i < model.meshCount) : (i += 1) { - var tempBounds: BoundingBox = GetMeshBoundingBox((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*); - _ = &tempBounds; - temp.x = if (bounds.min.x < tempBounds.min.x) bounds.min.x else tempBounds.min.x; - temp.y = if (bounds.min.y < tempBounds.min.y) bounds.min.y else tempBounds.min.y; - temp.z = if (bounds.min.z < tempBounds.min.z) bounds.min.z else tempBounds.min.z; - bounds.min = temp; - temp.x = if (bounds.max.x > tempBounds.max.x) bounds.max.x else tempBounds.max.x; - temp.y = if (bounds.max.y > tempBounds.max.y) bounds.max.y else tempBounds.max.y; - temp.z = if (bounds.max.z > tempBounds.max.z) bounds.max.z else tempBounds.max.z; - bounds.max = temp; - } - } - } - bounds.min = Vector3Transform(bounds.min, model.transform); - bounds.max = Vector3Transform(bounds.max, model.transform); - return bounds; -} -pub export fn DrawModel(arg_model: Model, arg_position: Vector3, arg_scale: f32, arg_tint: Color) void { - var model = arg_model; - _ = &model; - var position = arg_position; - _ = &position; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - var vScale: Vector3 = Vector3{ - .x = scale, - .y = scale, - .z = scale, - }; - _ = &vScale; - var rotationAxis: Vector3 = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - _ = &rotationAxis; - DrawModelEx(model, position, rotationAxis, 0.0, vScale, tint); -} -pub export fn DrawModelEx(arg_model: Model, arg_position: Vector3, arg_rotationAxis: Vector3, arg_rotationAngle: f32, arg_scale: Vector3, arg_tint: Color) void { - var model = arg_model; - _ = &model; - var position = arg_position; - _ = &position; - var rotationAxis = arg_rotationAxis; - _ = &rotationAxis; - var rotationAngle = arg_rotationAngle; - _ = &rotationAngle; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - var matScale: Matrix = MatrixScale(scale.x, scale.y, scale.z); - _ = &matScale; - var matRotation: Matrix = MatrixRotate(rotationAxis, rotationAngle * (3.1415927410125732 / 180.0)); - _ = &matRotation; - var matTranslation: Matrix = MatrixTranslate(position.x, position.y, position.z); - _ = &matTranslation; - var matTransform: Matrix = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); - _ = &matTransform; - model.transform = MatrixMultiply(model.transform, matTransform); - { - var i: c_int = 0; - _ = &i; - while (i < model.meshCount) : (i += 1) { - var color: Color = (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.meshMaterial + @as(usize, @intCast(tmp_3)) else break :blk_2 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.meshMaterial + @as(usize, @intCast(tmp_3)) else break :blk_2 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color; - _ = &color; - var colorTint: Color = Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - _ = &colorTint; - colorTint.r = @as(u8, @bitCast(@as(i8, @truncate(@divTrunc(@as(c_int, @bitCast(@as(c_uint, color.r))) * @as(c_int, @bitCast(@as(c_uint, tint.r))), @as(c_int, 255)))))); - colorTint.g = @as(u8, @bitCast(@as(i8, @truncate(@divTrunc(@as(c_int, @bitCast(@as(c_uint, color.g))) * @as(c_int, @bitCast(@as(c_uint, tint.g))), @as(c_int, 255)))))); - colorTint.b = @as(u8, @bitCast(@as(i8, @truncate(@divTrunc(@as(c_int, @bitCast(@as(c_uint, color.b))) * @as(c_int, @bitCast(@as(c_uint, tint.b))), @as(c_int, 255)))))); - colorTint.a = @as(u8, @bitCast(@as(i8, @truncate(@divTrunc(@as(c_int, @bitCast(@as(c_uint, color.a))) * @as(c_int, @bitCast(@as(c_uint, tint.a))), @as(c_int, 255)))))); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.meshMaterial + @as(usize, @intCast(tmp_3)) else break :blk_2 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.meshMaterial + @as(usize, @intCast(tmp_3)) else break :blk_2 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = colorTint; - DrawMesh((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.meshMaterial + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*; - if (tmp >= 0) break :blk model.materials + @as(usize, @intCast(tmp)) else break :blk model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, model.transform); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.meshMaterial + @as(usize, @intCast(tmp_3)) else break :blk_2 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.meshMaterial + @as(usize, @intCast(tmp_3)) else break :blk_2 model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = color; - } - } -} -pub export fn DrawModelWires(arg_model: Model, arg_position: Vector3, arg_scale: f32, arg_tint: Color) void { - var model = arg_model; - _ = &model; - var position = arg_position; - _ = &position; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - rlEnableWireMode(); - DrawModel(model, position, scale, tint); - rlDisableWireMode(); -} -pub export fn DrawModelWiresEx(arg_model: Model, arg_position: Vector3, arg_rotationAxis: Vector3, arg_rotationAngle: f32, arg_scale: Vector3, arg_tint: Color) void { - var model = arg_model; - _ = &model; - var position = arg_position; - _ = &position; - var rotationAxis = arg_rotationAxis; - _ = &rotationAxis; - var rotationAngle = arg_rotationAngle; - _ = &rotationAngle; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - rlEnableWireMode(); - DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint); - rlDisableWireMode(); -} -pub export fn DrawModelPoints(arg_model: Model, arg_position: Vector3, arg_scale: f32, arg_tint: Color) void { - var model = arg_model; - _ = &model; - var position = arg_position; - _ = &position; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - rlEnablePointMode(); - rlDisableBackfaceCulling(); - DrawModel(model, position, scale, tint); - rlEnableBackfaceCulling(); - rlDisableWireMode(); -} -pub export fn DrawModelPointsEx(arg_model: Model, arg_position: Vector3, arg_rotationAxis: Vector3, arg_rotationAngle: f32, arg_scale: Vector3, arg_tint: Color) void { - var model = arg_model; - _ = &model; - var position = arg_position; - _ = &position; - var rotationAxis = arg_rotationAxis; - _ = &rotationAxis; - var rotationAngle = arg_rotationAngle; - _ = &rotationAngle; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - rlEnablePointMode(); - rlDisableBackfaceCulling(); - DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint); - rlEnableBackfaceCulling(); - rlDisableWireMode(); -} -pub export fn DrawBoundingBox(arg_box: BoundingBox, arg_color: Color) void { - var box = arg_box; - _ = &box; - var color = arg_color; - _ = &color; - var size: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &size; - size.x = fabsf(box.max.x - box.min.x); - size.y = fabsf(box.max.y - box.min.y); - size.z = fabsf(box.max.z - box.min.z); - var center: Vector3 = Vector3{ - .x = box.min.x + (size.x / 2.0), - .y = box.min.y + (size.y / 2.0), - .z = box.min.z + (size.z / 2.0), - }; - _ = ¢er; - DrawCubeWires(center, size.x, size.y, size.z, color); -} -pub export fn DrawBillboard(arg_camera: Camera, arg_texture: Texture2D, arg_position: Vector3, arg_scale: f32, arg_tint: Color) void { - var camera = arg_camera; - _ = &camera; - var texture = arg_texture; - _ = &texture; - var position = arg_position; - _ = &position; - var scale = arg_scale; - _ = &scale; - var tint = arg_tint; - _ = ∭ - var source: Rectangle = Rectangle{ - .x = 0.0, - .y = 0.0, - .width = @as(f32, @floatFromInt(texture.width)), - .height = @as(f32, @floatFromInt(texture.height)), - }; - _ = &source; - DrawBillboardRec(camera, texture, source, position, Vector2{ - .x = scale * fabsf(source.width / source.height), - .y = scale, - }, tint); -} -pub export fn DrawBillboardRec(arg_camera: Camera, arg_texture: Texture2D, arg_source: Rectangle, arg_position: Vector3, arg_size: Vector2, arg_tint: Color) void { - var camera = arg_camera; - _ = &camera; - var texture = arg_texture; - _ = &texture; - var source = arg_source; - _ = &source; - var position = arg_position; - _ = &position; - var size = arg_size; - _ = &size; - var tint = arg_tint; - _ = ∭ - var up: Vector3 = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - _ = &up; - DrawBillboardPro(camera, texture, source, position, up, size, Vector2Scale(size, @as(f32, @floatCast(0.5))), 0.0, tint); -} -pub export fn DrawBillboardPro(arg_camera: Camera, arg_texture: Texture2D, arg_source: Rectangle, arg_position: Vector3, arg_up: Vector3, arg_size: Vector2, arg_origin: Vector2, arg_rotation: f32, arg_tint: Color) void { - var camera = arg_camera; - _ = &camera; - var texture = arg_texture; - _ = &texture; - var source = arg_source; - _ = &source; - var position = arg_position; - _ = &position; - var up = arg_up; - _ = &up; - var size = arg_size; - _ = &size; - var origin = arg_origin; - _ = &origin; - var rotation = arg_rotation; - _ = &rotation; - var tint = arg_tint; - _ = ∭ - var matView: Matrix = MatrixLookAt(camera.position, camera.target, camera.up); - _ = &matView; - var right: Vector3 = Vector3{ - .x = matView.m0, - .y = matView.m4, - .z = matView.m8, - }; - _ = &right; - right = Vector3Scale(right, size.x); - up = Vector3Scale(up, size.y); - if (size.x < 0.0) { - source.x += size.x; - source.width *= @as(f32, @floatCast(-1.0)); - right = Vector3Negate(right); - origin.x *= -1.0; - } - if (size.y < 0.0) { - source.y += size.y; - source.height *= @as(f32, @floatCast(-1.0)); - up = Vector3Negate(up); - origin.y *= -1.0; - } - var forward: Vector3 = undefined; - _ = &forward; - if (@as(f64, @floatCast(rotation)) != 0.0) { - forward = Vector3CrossProduct(right, up); - } - var origin3D: Vector3 = Vector3Add(Vector3Scale(Vector3Normalize(right), origin.x), Vector3Scale(Vector3Normalize(up), origin.y)); - _ = &origin3D; - var points: [4]Vector3 = undefined; - _ = &points; - points[@as(c_uint, @intCast(@as(c_int, 0)))] = Vector3Zero(); - points[@as(c_uint, @intCast(@as(c_int, 1)))] = right; - points[@as(c_uint, @intCast(@as(c_int, 2)))] = Vector3Add(up, right); - points[@as(c_uint, @intCast(@as(c_int, 3)))] = up; - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 4)) : (i += 1) { - points[@as(c_uint, @intCast(i))] = Vector3Subtract(points[@as(c_uint, @intCast(i))], origin3D); - if (@as(f64, @floatCast(rotation)) != 0.0) { - points[@as(c_uint, @intCast(i))] = Vector3RotateByAxisAngle(points[@as(c_uint, @intCast(i))], forward, rotation * (3.1415927410125732 / 180.0)); - } - points[@as(c_uint, @intCast(i))] = Vector3Add(points[@as(c_uint, @intCast(i))], position); - } - } - var texcoords: [4]Vector2 = undefined; - _ = &texcoords; - texcoords[@as(c_uint, @intCast(@as(c_int, 0)))] = Vector2{ - .x = source.x / @as(f32, @floatFromInt(texture.width)), - .y = (source.y + source.height) / @as(f32, @floatFromInt(texture.height)), - }; - texcoords[@as(c_uint, @intCast(@as(c_int, 1)))] = Vector2{ - .x = (source.x + source.width) / @as(f32, @floatFromInt(texture.width)), - .y = (source.y + source.height) / @as(f32, @floatFromInt(texture.height)), - }; - texcoords[@as(c_uint, @intCast(@as(c_int, 2)))] = Vector2{ - .x = (source.x + source.width) / @as(f32, @floatFromInt(texture.width)), - .y = source.y / @as(f32, @floatFromInt(texture.height)), - }; - texcoords[@as(c_uint, @intCast(@as(c_int, 3)))] = Vector2{ - .x = source.x / @as(f32, @floatFromInt(texture.width)), - .y = source.y / @as(f32, @floatFromInt(texture.height)), - }; - rlSetTexture(texture.id); - rlBegin(@as(c_int, 7)); - rlColor4ub(tint.r, tint.g, tint.b, tint.a); - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 4)) : (i += 1) { - rlTexCoord2f(texcoords[@as(c_uint, @intCast(i))].x, texcoords[@as(c_uint, @intCast(i))].y); - rlVertex3f(points[@as(c_uint, @intCast(i))].x, points[@as(c_uint, @intCast(i))].y, points[@as(c_uint, @intCast(i))].z); - } - } - rlEnd(); - rlSetTexture(@as(c_uint, @bitCast(@as(c_int, 0)))); -} -pub export fn UploadMesh(arg_mesh: [*c]Mesh, arg_dynamic: bool) void { - var mesh = arg_mesh; - _ = &mesh; - var dynamic = arg_dynamic; - _ = &dynamic; - if (mesh.*.vaoId > @as(c_uint, @bitCast(@as(c_int, 0)))) { - TraceLog(LOG_WARNING, "VAO: [ID %i] Trying to re-load an already loaded mesh", mesh.*.vaoId); - return; - } - mesh.*.vboId = @as([*c]c_uint, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 7)))), @sizeOf(c_uint))))); - mesh.*.vaoId = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 0)))] = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 1)))] = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 2)))] = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 3)))] = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 4)))] = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 5)))] = 0; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 6)))] = 0; - mesh.*.vaoId = rlLoadVertexArray(); - _ = rlEnableVertexArray(mesh.*.vaoId); - var vertices: ?*anyopaque = @as(?*anyopaque, @ptrCast(if (mesh.*.animVertices != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) mesh.*.animVertices else mesh.*.vertices)); - _ = &vertices; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 0)))] = rlLoadVertexBuffer(vertices, @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))), dynamic); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 0))), @as(c_int, 3), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 0)))); - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 1)))] = rlLoadVertexBuffer(@as(?*const anyopaque, @ptrCast(mesh.*.texcoords)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 2)))) *% @sizeOf(f32))))), dynamic); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 1))), @as(c_int, 2), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 1)))); - if (mesh.*.normals != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - var normals: ?*anyopaque = @as(?*anyopaque, @ptrCast(if (mesh.*.animNormals != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) mesh.*.animNormals else mesh.*.normals)); - _ = &normals; - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 2)))] = rlLoadVertexBuffer(normals, @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))), dynamic); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 2))), @as(c_int, 3), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 2)))); - } else { - var value: [3]f32 = [3]f32{ - 1.0, - 1.0, - 1.0, - }; - _ = &value; - rlSetVertexAttributeDefault(@as(c_int, 2), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&value))))), SHADER_ATTRIB_VEC3, @as(c_int, 3)); - rlDisableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 2)))); - } - if (mesh.*.colors != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 3)))] = rlLoadVertexBuffer(@as(?*const anyopaque, @ptrCast(mesh.*.colors)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 4)))) *% @sizeOf(u8))))), dynamic); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 3))), @as(c_int, 4), @as(c_int, 5121), @as(c_int, 1) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 3)))); - } else { - var value: [4]f32 = [4]f32{ - 1.0, - 1.0, - 1.0, - 1.0, - }; - _ = &value; - rlSetVertexAttributeDefault(@as(c_int, 3), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&value))))), SHADER_ATTRIB_VEC4, @as(c_int, 4)); - rlDisableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 3)))); - } - if (mesh.*.tangents != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 4)))] = rlLoadVertexBuffer(@as(?*const anyopaque, @ptrCast(mesh.*.tangents)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 4)))) *% @sizeOf(f32))))), dynamic); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 4))), @as(c_int, 4), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 4)))); - } else { - var value: [4]f32 = [4]f32{ - 0.0, - 0.0, - 0.0, - 0.0, - }; - _ = &value; - rlSetVertexAttributeDefault(@as(c_int, 4), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&value))))), SHADER_ATTRIB_VEC4, @as(c_int, 4)); - rlDisableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 4)))); - } - if (mesh.*.texcoords2 != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 5)))] = rlLoadVertexBuffer(@as(?*const anyopaque, @ptrCast(mesh.*.texcoords2)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 2)))) *% @sizeOf(f32))))), dynamic); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 5))), @as(c_int, 2), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 5)))); - } else { - var value: [2]f32 = [2]f32{ - 0.0, - 0.0, - }; - _ = &value; - rlSetVertexAttributeDefault(@as(c_int, 5), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&value))))), SHADER_ATTRIB_VEC2, @as(c_int, 2)); - rlDisableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 5)))); - } - if (mesh.*.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - mesh.*.vboId[@as(c_uint, @intCast(@as(c_int, 6)))] = rlLoadVertexBufferElement(@as(?*const anyopaque, @ptrCast(mesh.*.indices)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.triangleCount * @as(c_int, 3)))) *% @sizeOf(c_ushort))))), dynamic); - } - if (mesh.*.vaoId > @as(c_uint, @bitCast(@as(c_int, 0)))) { - TraceLog(LOG_INFO, "VAO: [ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh.*.vaoId); - } else { - TraceLog(LOG_INFO, "VBO: Mesh uploaded successfully to VRAM (GPU)"); - } - rlDisableVertexArray(); -} -pub export fn UpdateMeshBuffer(arg_mesh: Mesh, arg_index_1: c_int, arg_data: ?*const anyopaque, arg_dataSize: c_int, arg_offset: c_int) void { - var mesh = arg_mesh; - _ = &mesh; - var index_1 = arg_index_1; - _ = &index_1; - var data = arg_data; - _ = &data; - var dataSize = arg_dataSize; - _ = &dataSize; - var offset = arg_offset; - _ = &offset; - rlUpdateVertexBuffer((blk: { - const tmp = index_1; - if (tmp >= 0) break :blk mesh.vboId + @as(usize, @intCast(tmp)) else break :blk mesh.vboId - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, data, dataSize, offset); -} -pub export fn UnloadMesh(arg_mesh: Mesh) void { - var mesh = arg_mesh; - _ = &mesh; - rlUnloadVertexArray(mesh.vaoId); - if (mesh.vboId != @as([*c]c_uint, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 7)) : (i += 1) { - rlUnloadVertexBuffer((blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.vboId + @as(usize, @intCast(tmp)) else break :blk mesh.vboId - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*); - } - } - free(@as(?*anyopaque, @ptrCast(mesh.vboId))); - free(@as(?*anyopaque, @ptrCast(mesh.vertices))); - free(@as(?*anyopaque, @ptrCast(mesh.texcoords))); - free(@as(?*anyopaque, @ptrCast(mesh.normals))); - free(@as(?*anyopaque, @ptrCast(mesh.colors))); - free(@as(?*anyopaque, @ptrCast(mesh.tangents))); - free(@as(?*anyopaque, @ptrCast(mesh.texcoords2))); - free(@as(?*anyopaque, @ptrCast(mesh.indices))); - free(@as(?*anyopaque, @ptrCast(mesh.animVertices))); - free(@as(?*anyopaque, @ptrCast(mesh.animNormals))); - free(@as(?*anyopaque, @ptrCast(mesh.boneWeights))); - free(@as(?*anyopaque, @ptrCast(mesh.boneIds))); -} -pub export fn DrawMesh(arg_mesh: Mesh, arg_material: Material, arg_transform: Matrix) void { - var mesh = arg_mesh; - _ = &mesh; - var material = arg_material; - _ = &material; - var transform = arg_transform; - _ = &transform; - rlEnableShader(material.shader.id); - if ((blk: { - const tmp = SHADER_LOC_COLOR_DIFFUSE; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - var values: [4]f32 = [4]f32{ - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.r)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.g)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.b)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.a)) / 255.0, - }; - _ = &values; - rlSetUniform((blk: { - const tmp = SHADER_LOC_COLOR_DIFFUSE; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&values))))), SHADER_UNIFORM_VEC4, @as(c_int, 1)); - } - if ((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - var values: [4]f32 = [4]f32{ - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.r)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.g)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.b)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.a)) / 255.0, - }; - _ = &values; - rlSetUniform((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&values))))), SHADER_UNIFORM_VEC4, @as(c_int, 1)); - } - var matModel: Matrix = MatrixIdentity(); - _ = &matModel; - var matView: Matrix = rlGetMatrixModelview(); - _ = &matView; - var matModelView: Matrix = MatrixIdentity(); - _ = &matModelView; - var matProjection: Matrix = rlGetMatrixProjection(); - _ = &matProjection; - if ((blk: { - const tmp = SHADER_LOC_MATRIX_VIEW; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_VIEW; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matView); - } - if ((blk: { - const tmp = SHADER_LOC_MATRIX_PROJECTION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_PROJECTION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matProjection); - } - matModel = MatrixMultiply(transform, rlGetMatrixTransform()); - if ((blk: { - const tmp = SHADER_LOC_MATRIX_MODEL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_MODEL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matModel); - } - matModelView = MatrixMultiply(matModel, matView); - if ((blk: { - const tmp = SHADER_LOC_MATRIX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, MatrixTranspose(MatrixInvert(matModel))); - } - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 12)) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id > @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlActiveTextureSlot(i); - if (((i == MATERIAL_MAP_IRRADIANCE) or (i == MATERIAL_MAP_PREFILTER)) or (i == MATERIAL_MAP_CUBEMAP)) { - rlEnableTextureCubemap((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id); - } else { - rlEnableTexture((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id); - } - rlSetUniform((blk: { - const tmp = SHADER_LOC_MAP_ALBEDO + i; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(&i)), SHADER_UNIFORM_INT, @as(c_int, 1)); - } - } - } - if (!rlEnableVertexArray(mesh.vaoId)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 0)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_POSITION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 3), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_POSITION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 1)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD01; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 2), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD01; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - if ((blk: { - const tmp = SHADER_LOC_VERTEX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 2)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 3), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if ((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - if (mesh.vboId[@as(c_uint, @intCast(@as(c_int, 3)))] != @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 3)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 4), @as(c_int, 5121), @as(c_int, 1) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } else { - var value: [4]f32 = [4]f32{ - 1.0, - 1.0, - 1.0, - 1.0, - }; - _ = &value; - rlSetVertexAttributeDefault((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&value))))), SHADER_ATTRIB_VEC4, @as(c_int, 4)); - rlDisableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - if ((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 4)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 4), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if ((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD02; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 5)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD02; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 2), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD02; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - rlEnableVertexBufferElement(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 6)))]); - } - } - var eyeCount: c_int = 1; - _ = &eyeCount; - if (rlIsStereoRenderEnabled()) { - eyeCount = 2; - } - { - var eye: c_int = 0; - _ = &eye; - while (eye < eyeCount) : (eye += 1) { - var matModelViewProjection: Matrix = MatrixIdentity(); - _ = &matModelViewProjection; - if (eyeCount == @as(c_int, 1)) { - matModelViewProjection = MatrixMultiply(matModelView, matProjection); - } else { - rlViewport(@divTrunc(eye * rlGetFramebufferWidth(), @as(c_int, 2)), @as(c_int, 0), @divTrunc(rlGetFramebufferWidth(), @as(c_int, 2)), rlGetFramebufferHeight()); - matModelViewProjection = MatrixMultiply(MatrixMultiply(matModelView, rlGetMatrixViewOffsetStereo(eye)), rlGetMatrixProjectionStereo(eye)); - } - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_MVP; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matModelViewProjection); - if (mesh.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - rlDrawVertexArrayElements(@as(c_int, 0), mesh.triangleCount * @as(c_int, 3), null); - } else { - rlDrawVertexArray(@as(c_int, 0), mesh.vertexCount); - } - } - } - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 12)) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id > @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlActiveTextureSlot(i); - if (((i == MATERIAL_MAP_IRRADIANCE) or (i == MATERIAL_MAP_PREFILTER)) or (i == MATERIAL_MAP_CUBEMAP)) { - rlDisableTextureCubemap(); - } else { - rlDisableTexture(); - } - } - } - } - rlDisableVertexArray(); - rlDisableVertexBuffer(); - rlDisableVertexBufferElement(); - rlDisableShader(); - rlSetMatrixModelview(matView); - rlSetMatrixProjection(matProjection); -} -pub const struct_float16 = extern struct { - v: [16]f32 = @import("std").mem.zeroes([16]f32), -}; -pub const float16 = struct_float16; -pub export fn DrawMeshInstanced(arg_mesh: Mesh, arg_material: Material, arg_transforms: [*c]const Matrix, arg_instances: c_int) void { - var mesh = arg_mesh; - _ = &mesh; - var material = arg_material; - _ = &material; - var transforms = arg_transforms; - _ = &transforms; - var instances = arg_instances; - _ = &instances; - var instanceTransforms: [*c]float16 = null; - _ = &instanceTransforms; - var instancesVboId: c_uint = 0; - _ = &instancesVboId; - rlEnableShader(material.shader.id); - if ((blk: { - const tmp = SHADER_LOC_COLOR_DIFFUSE; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - var values: [4]f32 = [4]f32{ - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.r)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.g)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.b)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.a)) / 255.0, - }; - _ = &values; - rlSetUniform((blk: { - const tmp = SHADER_LOC_COLOR_DIFFUSE; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&values))))), SHADER_UNIFORM_VEC4, @as(c_int, 1)); - } - if ((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - var values: [4]f32 = [4]f32{ - @as(f32, @floatFromInt((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.r)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.g)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.b)) / 255.0, - @as(f32, @floatFromInt((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.a)) / 255.0, - }; - _ = &values; - rlSetUniform((blk: { - const tmp = SHADER_LOC_COLOR_SPECULAR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&values))))), SHADER_UNIFORM_VEC4, @as(c_int, 1)); - } - var matModel: Matrix = MatrixIdentity(); - _ = &matModel; - var matView: Matrix = rlGetMatrixModelview(); - _ = &matView; - var matModelView: Matrix = MatrixIdentity(); - _ = &matModelView; - var matProjection: Matrix = rlGetMatrixProjection(); - _ = &matProjection; - if ((blk: { - const tmp = SHADER_LOC_MATRIX_VIEW; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_VIEW; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matView); - } - if ((blk: { - const tmp = SHADER_LOC_MATRIX_PROJECTION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_PROJECTION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matProjection); - } - instanceTransforms = @as([*c]float16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, instances))) *% @sizeOf(float16))))); - { - var i: c_int = 0; - _ = &i; - while (i < instances) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk instanceTransforms + @as(usize, @intCast(tmp)) else break :blk instanceTransforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = MatrixToFloatV((blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*); - } - } - _ = rlEnableVertexArray(mesh.vaoId); - instancesVboId = rlLoadVertexBuffer(@as(?*const anyopaque, @ptrCast(instanceTransforms)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, instances))) *% @sizeOf(float16))))), @as(c_int, 0) != 0); - { - var i: c_uint = 0; - _ = &i; - while (i < @as(c_uint, @bitCast(@as(c_int, 4)))) : (i +%= 1) { - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_MATRIX_MODEL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)) +% i); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_MATRIX_MODEL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)) +% i, @as(c_int, 4), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, @bitCast(@as(c_uint, @truncate(@sizeOf(Matrix))))), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_ulong, i))) *% @sizeOf(Vector4)))))); - rlSetVertexAttributeDivisor(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_MATRIX_MODEL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)) +% i, @as(c_int, 1)); - } - } - rlDisableVertexBuffer(); - rlDisableVertexArray(); - matModelView = MatrixMultiply(rlGetMatrixTransform(), matView); - if ((blk: { - const tmp = SHADER_LOC_MATRIX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, MatrixTranspose(MatrixInvert(matModel))); - } - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 12)) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id > @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlActiveTextureSlot(i); - if (((i == MATERIAL_MAP_IRRADIANCE) or (i == MATERIAL_MAP_PREFILTER)) or (i == MATERIAL_MAP_CUBEMAP)) { - rlEnableTextureCubemap((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id); - } else { - rlEnableTexture((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id); - } - rlSetUniform((blk: { - const tmp = SHADER_LOC_MAP_ALBEDO + i; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(&i)), SHADER_UNIFORM_INT, @as(c_int, 1)); - } - } - } - if (!rlEnableVertexArray(mesh.vaoId)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 0)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_POSITION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 3), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_POSITION; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 1)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD01; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 2), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD01; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - if ((blk: { - const tmp = SHADER_LOC_VERTEX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 2)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 3), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_NORMAL; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if ((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - if (mesh.vboId[@as(c_uint, @intCast(@as(c_int, 3)))] != @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 3)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 4), @as(c_int, 5121), @as(c_int, 1) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } else { - var value: [4]f32 = [4]f32{ - 1.0, - 1.0, - 1.0, - 1.0, - }; - _ = &value; - rlSetVertexAttributeDefault((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&value))))), SHADER_ATTRIB_VEC4, @as(c_int, 4)); - rlDisableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_COLOR; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - if ((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 4)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 4), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if ((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD02; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != -@as(c_int, 1)) { - rlEnableVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 5)))]); - rlSetVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD02; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 2), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast((blk: { - const tmp = SHADER_LOC_VERTEX_TEXCOORD02; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - rlEnableVertexBufferElement(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 6)))]); - } - } - var eyeCount: c_int = 1; - _ = &eyeCount; - if (rlIsStereoRenderEnabled()) { - eyeCount = 2; - } - { - var eye: c_int = 0; - _ = &eye; - while (eye < eyeCount) : (eye += 1) { - var matModelViewProjection: Matrix = MatrixIdentity(); - _ = &matModelViewProjection; - if (eyeCount == @as(c_int, 1)) { - matModelViewProjection = MatrixMultiply(matModelView, matProjection); - } else { - rlViewport(@divTrunc(eye * rlGetFramebufferWidth(), @as(c_int, 2)), @as(c_int, 0), @divTrunc(rlGetFramebufferWidth(), @as(c_int, 2)), rlGetFramebufferHeight()); - matModelViewProjection = MatrixMultiply(MatrixMultiply(matModelView, rlGetMatrixViewOffsetStereo(eye)), rlGetMatrixProjectionStereo(eye)); - } - rlSetUniformMatrix((blk: { - const tmp = SHADER_LOC_MATRIX_MVP; - if (tmp >= 0) break :blk material.shader.locs + @as(usize, @intCast(tmp)) else break :blk material.shader.locs - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, matModelViewProjection); - if (mesh.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - rlDrawVertexArrayElementsInstanced(@as(c_int, 0), mesh.triangleCount * @as(c_int, 3), null, instances); - } else { - rlDrawVertexArrayInstanced(@as(c_int, 0), mesh.vertexCount, instances); - } - } - } - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 12)) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id > @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlActiveTextureSlot(i); - if (((i == MATERIAL_MAP_IRRADIANCE) or (i == MATERIAL_MAP_PREFILTER)) or (i == MATERIAL_MAP_CUBEMAP)) { - rlDisableTextureCubemap(); - } else { - rlDisableTexture(); - } - } - } - } - rlDisableVertexArray(); - rlDisableVertexBuffer(); - rlDisableVertexBufferElement(); - rlDisableShader(); - rlUnloadVertexBuffer(instancesVboId); - free(@as(?*anyopaque, @ptrCast(instanceTransforms))); -} -pub export fn GetMeshBoundingBox(arg_mesh: Mesh) BoundingBox { - var mesh = arg_mesh; - _ = &mesh; - var minVertex: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &minVertex; - var maxVertex: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &maxVertex; - if (mesh.vertices != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - minVertex = Vector3{ - .x = mesh.vertices[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = mesh.vertices[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = mesh.vertices[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - maxVertex = Vector3{ - .x = mesh.vertices[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = mesh.vertices[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = mesh.vertices[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - { - var i: c_int = 1; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - minVertex = Vector3Min(minVertex, Vector3{ - .x = (blk: { - const tmp = i * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }); - maxVertex = Vector3Max(maxVertex, Vector3{ - .x = (blk: { - const tmp = i * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }); - } - } - } - var box: BoundingBox = BoundingBox{ - .min = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }, - .max = @import("std").mem.zeroes(Vector3), - }; - _ = &box; - box.min = minVertex; - box.max = maxVertex; - return box; -} -pub export fn GenMeshTangents(arg_mesh: [*c]Mesh) void { - var mesh = arg_mesh; - _ = &mesh; - if ((mesh.*.vertices == @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) or (mesh.*.texcoords == @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - TraceLog(LOG_WARNING, "MESH: Tangents generation requires texcoord vertex attribute data"); - return; - } - if (mesh.*.tangents == @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - mesh.*.tangents = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 4)))) *% @sizeOf(f32))))); - } else { - free(@as(?*anyopaque, @ptrCast(mesh.*.tangents))); - mesh.*.tangents = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 4)))) *% @sizeOf(f32))))); - } - var tan1: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount))) *% @sizeOf(Vector3))))); - _ = &tan1; - var tan2: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount))) *% @sizeOf(Vector3))))); - _ = &tan2; - if (@import("std").zig.c_translation.signedRemainder(mesh.*.vertexCount, @as(c_int, 3)) != @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MESH: vertexCount expected to be a multiple of 3. Expect uninitialized values."); - } - { - var i: c_int = 0; - _ = &i; - while (i <= (mesh.*.vertexCount - @as(c_int, 3))) : (i += @as(c_int, 3)) { - var v1: Vector3 = Vector3{ - .x = (blk: { - const tmp = ((i + @as(c_int, 0)) * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = ((i + @as(c_int, 0)) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = ((i + @as(c_int, 0)) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &v1; - var v2: Vector3 = Vector3{ - .x = (blk: { - const tmp = ((i + @as(c_int, 1)) * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = ((i + @as(c_int, 1)) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = ((i + @as(c_int, 1)) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &v2; - var v3: Vector3 = Vector3{ - .x = (blk: { - const tmp = ((i + @as(c_int, 2)) * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = ((i + @as(c_int, 2)) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = ((i + @as(c_int, 2)) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.*.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &v3; - var uv1: Vector2 = Vector2{ - .x = (blk: { - const tmp = ((i + @as(c_int, 0)) * @as(c_int, 2)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = ((i + @as(c_int, 0)) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &uv1; - var uv2: Vector2 = Vector2{ - .x = (blk: { - const tmp = ((i + @as(c_int, 1)) * @as(c_int, 2)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = ((i + @as(c_int, 1)) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &uv2; - var uv3: Vector2 = Vector2{ - .x = (blk: { - const tmp = ((i + @as(c_int, 2)) * @as(c_int, 2)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = ((i + @as(c_int, 2)) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &uv3; - var x1: f32 = v2.x - v1.x; - _ = &x1; - var y1_1: f32 = v2.y - v1.y; - _ = &y1_1; - var z1: f32 = v2.z - v1.z; - _ = &z1; - var x2: f32 = v3.x - v1.x; - _ = &x2; - var y2: f32 = v3.y - v1.y; - _ = &y2; - var z2: f32 = v3.z - v1.z; - _ = &z2; - var s1: f32 = uv2.x - uv1.x; - _ = &s1; - var t1: f32 = uv2.y - uv1.y; - _ = &t1; - var s2: f32 = uv3.x - uv1.x; - _ = &s2; - var t2: f32 = uv3.y - uv1.y; - _ = &t2; - var div_2: f32 = (s1 * t2) - (s2 * t1); - _ = &div_2; - var r: f32 = if (div_2 == 0.0) 0.0 else 1.0 / div_2; - _ = &r; - var sdir: Vector3 = Vector3{ - .x = ((t2 * x1) - (t1 * x2)) * r, - .y = ((t2 * y1_1) - (t1 * y2)) * r, - .z = ((t2 * z1) - (t1 * z2)) * r, - }; - _ = &sdir; - var tdir: Vector3 = Vector3{ - .x = ((s1 * x2) - (s2 * x1)) * r, - .y = ((s1 * y2) - (s2 * y1_1)) * r, - .z = ((s1 * z2) - (s2 * z1)) * r, - }; - _ = &tdir; - (blk: { - const tmp = i + @as(c_int, 0); - if (tmp >= 0) break :blk tan1 + @as(usize, @intCast(tmp)) else break :blk tan1 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = sdir; - (blk: { - const tmp = i + @as(c_int, 1); - if (tmp >= 0) break :blk tan1 + @as(usize, @intCast(tmp)) else break :blk tan1 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = sdir; - (blk: { - const tmp = i + @as(c_int, 2); - if (tmp >= 0) break :blk tan1 + @as(usize, @intCast(tmp)) else break :blk tan1 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = sdir; - (blk: { - const tmp = i + @as(c_int, 0); - if (tmp >= 0) break :blk tan2 + @as(usize, @intCast(tmp)) else break :blk tan2 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = tdir; - (blk: { - const tmp = i + @as(c_int, 1); - if (tmp >= 0) break :blk tan2 + @as(usize, @intCast(tmp)) else break :blk tan2 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = tdir; - (blk: { - const tmp = i + @as(c_int, 2); - if (tmp >= 0) break :blk tan2 + @as(usize, @intCast(tmp)) else break :blk tan2 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = tdir; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.vertexCount) : (i += 1) { - var normal: Vector3 = Vector3{ - .x = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.normals + @as(usize, @intCast(tmp)) else break :blk mesh.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.normals + @as(usize, @intCast(tmp)) else break :blk mesh.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.*.normals + @as(usize, @intCast(tmp)) else break :blk mesh.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - _ = &normal; - var tangent: Vector3 = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tan1 + @as(usize, @intCast(tmp)) else break :blk tan1 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &tangent; - Vector3OrthoNormalize(&normal, &tangent); - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.*.tangents + @as(usize, @intCast(tmp)) else break :blk mesh.*.tangents - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = tangent.x; - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.*.tangents + @as(usize, @intCast(tmp)) else break :blk mesh.*.tangents - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = tangent.y; - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.*.tangents + @as(usize, @intCast(tmp)) else break :blk mesh.*.tangents - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = tangent.z; - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.*.tangents + @as(usize, @intCast(tmp)) else break :blk mesh.*.tangents - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = if (Vector3DotProduct(Vector3CrossProduct(normal, tangent), (blk: { - const tmp = i; - if (tmp >= 0) break :blk tan2 + @as(usize, @intCast(tmp)) else break :blk tan2 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*) < 0.0) -1.0 else 1.0; - } - } - free(@as(?*anyopaque, @ptrCast(tan1))); - free(@as(?*anyopaque, @ptrCast(tan2))); - if (mesh.*.vboId != @as([*c]c_uint, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - if ((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk mesh.*.vboId + @as(usize, @intCast(tmp)) else break :blk mesh.*.vboId - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* != @as(c_uint, @bitCast(@as(c_int, 0)))) { - rlUpdateVertexBuffer((blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk mesh.*.vboId + @as(usize, @intCast(tmp)) else break :blk mesh.*.vboId - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, @as(?*const anyopaque, @ptrCast(mesh.*.tangents)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 4)))) *% @sizeOf(f32))))), @as(c_int, 0)); - } else { - (blk: { - const tmp = SHADER_LOC_VERTEX_TANGENT; - if (tmp >= 0) break :blk mesh.*.vboId + @as(usize, @intCast(tmp)) else break :blk mesh.*.vboId - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = rlLoadVertexBuffer(@as(?*const anyopaque, @ptrCast(mesh.*.tangents)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.*.vertexCount * @as(c_int, 4)))) *% @sizeOf(f32))))), @as(c_int, 0) != 0); - } - _ = rlEnableVertexArray(mesh.*.vaoId); - rlSetVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 4))), @as(c_int, 4), @as(c_int, 5126), @as(c_int, 0) != 0, @as(c_int, 0), @as(c_int, 0)); - rlEnableVertexAttribute(@as(c_uint, @bitCast(@as(c_int, 4)))); - rlDisableVertexArray(); - } - TraceLog(LOG_INFO, "MESH: Tangents data computed and uploaded for provided mesh"); -} -pub export fn ExportMesh(arg_mesh: Mesh, arg_fileName: [*c]const u8) bool { - var mesh = arg_mesh; - _ = &mesh; - var fileName = arg_fileName; - _ = &fileName; - var success: bool = @as(c_int, 0) != 0; - _ = &success; - if (IsFileExtension(fileName, ".obj")) { - var dataSize: c_int = (((mesh.vertexCount * @as(c_int, @bitCast(@as(c_uint, @truncate(strlen("v 0000.00f 0000.00f 0000.00f")))))) + (mesh.vertexCount * @as(c_int, @bitCast(@as(c_uint, @truncate(strlen("vt 0.000f 0.00f"))))))) + (mesh.vertexCount * @as(c_int, @bitCast(@as(c_uint, @truncate(strlen("vn 0.000f 0.00f 0.00f"))))))) + (mesh.triangleCount * @as(c_int, @bitCast(@as(c_uint, @truncate(strlen("f 00000/00000/00000 00000/00000/00000 00000/00000/00000")))))); - _ = &dataSize; - var txtData: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (dataSize * @as(c_int, 2)) + @as(c_int, 2000)))), @sizeOf(u8))))); - _ = &txtData; - var byteCount: c_int = 0; - _ = &byteCount; - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# //////////////////////////////////////////////////////////////////////////////////\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // rMeshOBJ exporter v1.0 - Mesh exported as triangle faces and not optimized //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // more info and bugs-report: github.com/raysan5/raylib //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // feedback and support: ray[at]raylib.com //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // Copyright (c) 2018-2024 Ramon Santamaria (@raysan5) //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# // //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# //////////////////////////////////////////////////////////////////////////////////\n\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# Vertex Count: %i\n", mesh.vertexCount); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "# Triangle Count: %i\n\n", mesh.triangleCount); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "g mesh\n"); - { - var i: c_int = 0; - _ = &i; - var v: c_int = 0; - _ = &v; - while (i < mesh.vertexCount) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &v; - ref.* += @as(c_int, 3); - break :blk_1 ref.*; - }; - }) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "v %.2f %.2f %.2f\n", @as(f64, @floatCast((blk: { - const tmp = v; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(f64, @floatCast((blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(f64, @floatCast((blk: { - const tmp = v + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - { - var i: c_int = 0; - _ = &i; - var v: c_int = 0; - _ = &v; - while (i < mesh.vertexCount) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &v; - ref.* += @as(c_int, 2); - break :blk_1 ref.*; - }; - }) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "vt %.3f %.3f\n", @as(f64, @floatCast((blk: { - const tmp = v; - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(f64, @floatCast((blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - { - var i: c_int = 0; - _ = &i; - var v: c_int = 0; - _ = &v; - while (i < mesh.vertexCount) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &v; - ref.* += @as(c_int, 3); - break :blk_1 ref.*; - }; - }) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "vn %.3f %.3f %.3f\n", @as(f64, @floatCast((blk: { - const tmp = v; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(f64, @floatCast((blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(f64, @floatCast((blk: { - const tmp = v + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - if (mesh.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - { - var i: c_int = 0; - _ = &i; - var v: c_int = 0; - _ = &v; - while (i < mesh.triangleCount) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &v; - ref.* += @as(c_int, 3); - break :blk_1 ref.*; - }; - }) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "f %i/%i/%i %i/%i/%i %i/%i/%i\n", @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v; - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v; - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v; - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = v + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, 1)); - } - } - } else { - { - var i: c_int = 0; - _ = &i; - var v: c_int = 1; - _ = &v; - while (i < mesh.triangleCount) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &v; - ref.* += @as(c_int, 3); - break :blk_1 ref.*; - }; - }) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "f %i/%i/%i %i/%i/%i %i/%i/%i\n", v, v, v, v + @as(c_int, 1), v + @as(c_int, 1), v + @as(c_int, 1), v + @as(c_int, 2), v + @as(c_int, 2), v + @as(c_int, 2)); - } - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "\n"); - success = SaveFileText(fileName, txtData); - free(@as(?*anyopaque, @ptrCast(txtData))); - } else if (IsFileExtension(fileName, ".raw")) {} - return success; -} -pub export fn ExportMeshAsCode(arg_mesh: Mesh, arg_fileName: [*c]const u8) bool { - var mesh = arg_mesh; - _ = &mesh; - var fileName = arg_fileName; - _ = &fileName; - var success: bool = @as(c_int, 0) != 0; - _ = &success; - var txtData: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (@as(c_int, 64) * @as(c_int, 1024)) * @as(c_int, 1024)))), @sizeOf(u8))))); - _ = &txtData; - var byteCount: c_int = 0; - _ = &byteCount; - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "////////////////////////////////////////////////////////////////////////////////////////\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// MeshAsCode exporter v1.0 - Mesh vertex data exported as arrays //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// more info and bugs-report: github.com/raysan5/raylib //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// feedback and support: ray[at]raylib.com //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// Copyright (c) 2023 Ramon Santamaria (@raysan5) //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// //\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "////////////////////////////////////////////////////////////////////////////////////////\n\n"); - var varFileName: [256]u8 = [1]u8{ - 0, - } ++ [1]u8{0} ** 255; - _ = &varFileName; - _ = strcpy(@as([*c]u8, @ptrCast(@alignCast(&varFileName))), GetFileNameWithoutExt(fileName)); - { - var i: c_int = 0; - _ = &i; - while (@as(c_int, @bitCast(@as(c_uint, varFileName[@as(c_uint, @intCast(i))]))) != @as(c_int, '\x00')) : (i += 1) if ((@as(c_int, @bitCast(@as(c_uint, varFileName[@as(c_uint, @intCast(i))]))) >= @as(c_int, 'a')) and (@as(c_int, @bitCast(@as(c_uint, varFileName[@as(c_uint, @intCast(i))]))) <= @as(c_int, 'z'))) { - varFileName[@as(c_uint, @intCast(i))] = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, varFileName[@as(c_uint, @intCast(i))]))) - @as(c_int, 32))))); - }; - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "// Mesh basic information\n"); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "#define %s_VERTEX_COUNT %i\n", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount); - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "#define %s_TRIANGLE_COUNT %i\n\n", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.triangleCount); - if (mesh.vertices != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static float %s_VERTEX_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount * @as(c_int, 3)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.vertexCount * @as(c_int, 3)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "%.3ff,\n" else "%.3ff, ", @as(f64, @floatCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "%.3ff };\n\n", @as(f64, @floatCast((blk: { - const tmp = (mesh.vertexCount * @as(c_int, 3)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.texcoords != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static float %s_TEXCOORD_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount * @as(c_int, 2)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.vertexCount * @as(c_int, 2)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "%.3ff,\n" else "%.3ff, ", @as(f64, @floatCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "%.3ff };\n\n", @as(f64, @floatCast((blk: { - const tmp = (mesh.vertexCount * @as(c_int, 2)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.texcoords2 != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static float %s_TEXCOORD2_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount * @as(c_int, 2)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.vertexCount * @as(c_int, 2)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "%.3ff,\n" else "%.3ff, ", @as(f64, @floatCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.texcoords2 + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords2 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "%.3ff };\n\n", @as(f64, @floatCast((blk: { - const tmp = (mesh.vertexCount * @as(c_int, 2)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords2 + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords2 - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.normals != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static float %s_NORMAL_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount * @as(c_int, 3)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.vertexCount * @as(c_int, 3)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "%.3ff,\n" else "%.3ff, ", @as(f64, @floatCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "%.3ff };\n\n", @as(f64, @floatCast((blk: { - const tmp = (mesh.vertexCount * @as(c_int, 3)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.tangents != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static float %s_TANGENT_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount * @as(c_int, 4)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.vertexCount * @as(c_int, 4)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "%.3ff,\n" else "%.3ff, ", @as(f64, @floatCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.tangents + @as(usize, @intCast(tmp)) else break :blk mesh.tangents - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "%.3ff };\n\n", @as(f64, @floatCast((blk: { - const tmp = (mesh.vertexCount * @as(c_int, 4)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.tangents + @as(usize, @intCast(tmp)) else break :blk mesh.tangents - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - if (mesh.colors != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static unsigned char %s_COLOR_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.vertexCount * @as(c_int, 4)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.vertexCount * @as(c_int, 4)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "0x%x,\n" else "0x%x, ", @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.colors + @as(usize, @intCast(tmp)) else break :blk mesh.colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "0x%x };\n\n", @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (mesh.vertexCount * @as(c_int, 4)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.colors + @as(usize, @intCast(tmp)) else break :blk mesh.colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))); - } - if (mesh.indices != @as([*c]c_ushort, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "static unsigned short %s_INDEX_DATA[%i] = { ", @as([*c]u8, @ptrCast(@alignCast(&varFileName))), mesh.triangleCount * @as(c_int, 3)); - { - var i: c_int = 0; - _ = &i; - while (i < ((mesh.triangleCount * @as(c_int, 3)) - @as(c_int, 1))) : (i += 1) { - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), if (@import("std").zig.c_translation.signedRemainder(i, @as(c_int, 20)) == @as(c_int, 0)) "%i,\n" else "%i, ", @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))); - } - } - byteCount += sprintf(txtData + @as(usize, @bitCast(@as(isize, @intCast(byteCount)))), "%i };\n", @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (mesh.triangleCount * @as(c_int, 3)) - @as(c_int, 1); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))); - } - success = SaveFileText(fileName, txtData); - free(@as(?*anyopaque, @ptrCast(txtData))); - return success; -} -pub export fn GenMeshPoly(arg_sides: c_int, arg_radius: f32) Mesh { - var sides = arg_sides; - _ = &sides; - var radius = arg_radius; - _ = &radius; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if (sides < @as(c_int, 3)) return mesh; - var vertexCount: c_int = sides * @as(c_int, 3); - _ = &vertexCount; - var vertices: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, vertexCount))) *% @sizeOf(Vector3))))); - _ = &vertices; - var d: f32 = 0.0; - _ = &d; - var dStep: f32 = 360.0 / @as(f32, @floatFromInt(sides)); - _ = &dStep; - { - var v: c_int = 0; - _ = &v; - while (v < (vertexCount - @as(c_int, 2))) : (v += @as(c_int, 3)) { - (blk: { - const tmp = v; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector3{ - .x = 0.0, - .y = 0.0, - .z = 0.0, - }; - (blk: { - const tmp = v + @as(c_int, 1); - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector3{ - .x = sinf((3.1415927410125732 / 180.0) * d) * radius, - .y = 0.0, - .z = cosf((3.1415927410125732 / 180.0) * d) * radius, - }; - (blk: { - const tmp = v + @as(c_int, 2); - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector3{ - .x = sinf((3.1415927410125732 / 180.0) * (d + dStep)) * radius, - .y = 0.0, - .z = cosf((3.1415927410125732 / 180.0) * (d + dStep)) * radius, - }; - d += dStep; - } - } - var normals: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, vertexCount))) *% @sizeOf(Vector3))))); - _ = &normals; - { - var n: c_int = 0; - _ = &n; - while (n < vertexCount) : (n += 1) { - (blk: { - const tmp = n; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - } - } - var texcoords: [*c]Vector2 = @as([*c]Vector2, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, vertexCount))) *% @sizeOf(Vector2))))); - _ = &texcoords; - { - var n: c_int = 0; - _ = &n; - while (n < vertexCount) : (n += 1) { - (blk: { - const tmp = n; - if (tmp >= 0) break :blk texcoords + @as(usize, @intCast(tmp)) else break :blk texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = 0.0, - .y = 0.0, - }; - } - } - mesh.vertexCount = vertexCount; - mesh.triangleCount = sides; - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - { - var i: c_int = 0; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - (blk: { - const tmp = @as(c_int, 3) * i; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - (blk: { - const tmp = @as(c_int, 2) * i; - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk texcoords + @as(usize, @intCast(tmp)) else break :blk texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = (@as(c_int, 2) * i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk texcoords + @as(usize, @intCast(tmp)) else break :blk texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - (blk: { - const tmp = @as(c_int, 3) * i; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z; - } - } - free(@as(?*anyopaque, @ptrCast(vertices))); - free(@as(?*anyopaque, @ptrCast(normals))); - free(@as(?*anyopaque, @ptrCast(texcoords))); - UploadMesh(&mesh, @as(c_int, 0) != 0); - return mesh; -} -pub export fn GenMeshPlane(arg_width: f32, arg_length: f32, arg_resX: c_int, arg_resZ: c_int) Mesh { - var width = arg_width; - _ = &width; - var length = arg_length; - _ = &length; - var resX = arg_resX; - _ = &resX; - var resZ = arg_resZ; - _ = &resZ; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - resX += 1; - resZ += 1; - var vertexCount: c_int = resX * resZ; - _ = &vertexCount; - var vertices: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, vertexCount))) *% @sizeOf(Vector3))))); - _ = &vertices; - { - var z: c_int = 0; - _ = &z; - while (z < resZ) : (z += 1) { - var zPos: f32 = ((@as(f32, @floatFromInt(z)) / @as(f32, @floatFromInt(resZ - @as(c_int, 1)))) - 0.5) * length; - _ = &zPos; - { - var x: c_int = 0; - _ = &x; - while (x < resX) : (x += 1) { - var xPos: f32 = ((@as(f32, @floatFromInt(x)) / @as(f32, @floatFromInt(resX - @as(c_int, 1)))) - 0.5) * width; - _ = &xPos; - (blk: { - const tmp = x + (z * resX); - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector3{ - .x = xPos, - .y = 0.0, - .z = zPos, - }; - } - } - } - } - var normals: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, vertexCount))) *% @sizeOf(Vector3))))); - _ = &normals; - { - var n: c_int = 0; - _ = &n; - while (n < vertexCount) : (n += 1) { - (blk: { - const tmp = n; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - } - } - var texcoords: [*c]Vector2 = @as([*c]Vector2, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, vertexCount))) *% @sizeOf(Vector2))))); - _ = &texcoords; - { - var v: c_int = 0; - _ = &v; - while (v < resZ) : (v += 1) { - { - var u: c_int = 0; - _ = &u; - while (u < resX) : (u += 1) { - (blk: { - const tmp = u + (v * resX); - if (tmp >= 0) break :blk texcoords + @as(usize, @intCast(tmp)) else break :blk texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = @as(f32, @floatFromInt(u)) / @as(f32, @floatFromInt(resX - @as(c_int, 1))), - .y = @as(f32, @floatFromInt(v)) / @as(f32, @floatFromInt(resZ - @as(c_int, 1))), - }; - } - } - } - } - var numFaces: c_int = (resX - @as(c_int, 1)) * (resZ - @as(c_int, 1)); - _ = &numFaces; - var triangles: [*c]c_int = @as([*c]c_int, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, numFaces * @as(c_int, 6)))) *% @sizeOf(c_int))))); - _ = &triangles; - var t: c_int = 0; - _ = &t; - { - var face: c_int = 0; - _ = &face; - while (face < numFaces) : (face += 1) { - var i: c_int = face + @divTrunc(face, resX - @as(c_int, 1)); - _ = &i; - (blk: { - const tmp = blk_1: { - const ref = &t; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = i + resX; - (blk: { - const tmp = blk_1: { - const ref = &t; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = i + @as(c_int, 1); - (blk: { - const tmp = blk_1: { - const ref = &t; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = i; - (blk: { - const tmp = blk_1: { - const ref = &t; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = i + resX; - (blk: { - const tmp = blk_1: { - const ref = &t; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (i + resX) + @as(c_int, 1); - (blk: { - const tmp = blk_1: { - const ref = &t; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = i + @as(c_int, 1); - } - } - mesh.vertexCount = vertexCount; - mesh.triangleCount = numFaces * @as(c_int, 2); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.indices = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.triangleCount * @as(c_int, 3)))) *% @sizeOf(c_ushort))))); - { - var i: c_int = 0; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - (blk: { - const tmp = @as(c_int, 3) * i; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk vertices + @as(usize, @intCast(tmp)) else break :blk vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - (blk: { - const tmp = @as(c_int, 2) * i; - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk texcoords + @as(usize, @intCast(tmp)) else break :blk texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = (@as(c_int, 2) * i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk texcoords + @as(usize, @intCast(tmp)) else break :blk texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.vertexCount) : (i += 1) { - (blk: { - const tmp = @as(c_int, 3) * i; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - (blk: { - const tmp = (@as(c_int, 3) * i) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk normals + @as(usize, @intCast(tmp)) else break :blk normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < (mesh.triangleCount * @as(c_int, 3))) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate((blk: { - const tmp = i; - if (tmp >= 0) break :blk triangles + @as(usize, @intCast(tmp)) else break :blk triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))); - } - } - free(@as(?*anyopaque, @ptrCast(vertices))); - free(@as(?*anyopaque, @ptrCast(normals))); - free(@as(?*anyopaque, @ptrCast(texcoords))); - free(@as(?*anyopaque, @ptrCast(triangles))); - UploadMesh(&mesh, @as(c_int, 0) != 0); - return mesh; -} -pub export fn GenMeshCube(arg_width: f32, arg_height: f32, arg_length: f32) Mesh { - var width = arg_width; - _ = &width; - var height = arg_height; - _ = &height; - var length = arg_length; - _ = &length; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - var vertices: [72]f32 = [72]f32{ - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - -height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - length / @as(f32, @floatFromInt(@as(c_int, 2))), - -width / @as(f32, @floatFromInt(@as(c_int, 2))), - height / @as(f32, @floatFromInt(@as(c_int, 2))), - -length / @as(f32, @floatFromInt(@as(c_int, 2))), - }; - _ = &vertices; - var texcoords: [48]f32 = [48]f32{ - 0.0, - 0.0, - 1.0, - 0.0, - 1.0, - 1.0, - 0.0, - 1.0, - 1.0, - 0.0, - 1.0, - 1.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 1.0, - 1.0, - 1.0, - 1.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 1.0, - 0.0, - 1.0, - 1.0, - 0.0, - 1.0, - 0.0, - 0.0, - 0.0, - 0.0, - 1.0, - 0.0, - 1.0, - 1.0, - 0.0, - 1.0, - }; - _ = &texcoords; - var normals: [72]f32 = [72]f32{ - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - 1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - -1.0, - 0.0, - 0.0, - }; - _ = &normals; - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 24) * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.vertices)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&vertices))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 24) * @as(c_int, 3)))) *% @sizeOf(f32)); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 24) * @as(c_int, 2)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.texcoords)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&texcoords))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 24) * @as(c_int, 2)))) *% @sizeOf(f32)); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 24) * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.normals)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&normals))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 24) * @as(c_int, 3)))) *% @sizeOf(f32)); - mesh.indices = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 36)))) *% @sizeOf(c_ushort))))); - var k: c_int = 0; - _ = &k; - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 36)) : (i += @as(c_int, 6)) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate(@as(c_int, 4) * k)))); - (blk: { - const tmp = i + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate((@as(c_int, 4) * k) + @as(c_int, 1))))); - (blk: { - const tmp = i + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate((@as(c_int, 4) * k) + @as(c_int, 2))))); - (blk: { - const tmp = i + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate(@as(c_int, 4) * k)))); - (blk: { - const tmp = i + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate((@as(c_int, 4) * k) + @as(c_int, 2))))); - (blk: { - const tmp = i + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_short, @truncate((@as(c_int, 4) * k) + @as(c_int, 3))))); - k += 1; - } - } - mesh.vertexCount = 24; - mesh.triangleCount = 12; - UploadMesh(&mesh, @as(c_int, 0) != 0); - return mesh; -} -pub const struct_par_shapes_mesh_s = extern struct { - points: [*c]f32 = @import("std").mem.zeroes([*c]f32), - npoints: c_int = @import("std").mem.zeroes(c_int), - triangles: [*c]u16 = @import("std").mem.zeroes([*c]u16), - ntriangles: c_int = @import("std").mem.zeroes(c_int), - normals: [*c]f32 = @import("std").mem.zeroes([*c]f32), - tcoords: [*c]f32 = @import("std").mem.zeroes([*c]f32), -}; -pub const par_shapes_mesh = struct_par_shapes_mesh_s; -pub export fn GenMeshSphere(arg_radius: f32, arg_rings: c_int, arg_slices: c_int) Mesh { - var radius = arg_radius; - _ = &radius; - var rings = arg_rings; - _ = &rings; - var slices = arg_slices; - _ = &slices; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if ((rings >= @as(c_int, 3)) and (slices >= @as(c_int, 3))) { - var sphere: [*c]par_shapes_mesh = par_shapes_create_parametric_sphere(slices, rings); - _ = &sphere; - par_shapes_scale(sphere, radius, radius, radius); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (sphere.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (sphere.*.ntriangles * @as(c_int, 3)) * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (sphere.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.vertexCount = sphere.*.ntriangles * @as(c_int, 3); - mesh.triangleCount = sphere.*.ntriangles; - { - var k: c_int = 0; - _ = &k; - while (k < mesh.vertexCount) : (k += 1) { - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk sphere.*.points + @as(usize, @intCast(tmp)) else break :blk sphere.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk sphere.*.points + @as(usize, @intCast(tmp)) else break :blk sphere.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk sphere.*.points + @as(usize, @intCast(tmp)) else break :blk sphere.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk sphere.*.normals + @as(usize, @intCast(tmp)) else break :blk sphere.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk sphere.*.normals + @as(usize, @intCast(tmp)) else break :blk sphere.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk sphere.*.normals + @as(usize, @intCast(tmp)) else break :blk sphere.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2); - if (tmp >= 0) break :blk sphere.*.tcoords + @as(usize, @intCast(tmp)) else break :blk sphere.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk sphere.*.tcoords + @as(usize, @intCast(tmp)) else break :blk sphere.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - par_shapes_free_mesh(sphere); - UploadMesh(&mesh, @as(c_int, 0) != 0); - } else { - TraceLog(LOG_WARNING, "MESH: Failed to generate mesh: sphere"); - } - return mesh; -} -pub export fn GenMeshHemiSphere(arg_radius: f32, arg_rings: c_int, arg_slices: c_int) Mesh { - var radius = arg_radius; - _ = &radius; - var rings = arg_rings; - _ = &rings; - var slices = arg_slices; - _ = &slices; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if ((rings >= @as(c_int, 3)) and (slices >= @as(c_int, 3))) { - if (radius < 0.0) { - radius = 0.0; - } - var sphere: [*c]par_shapes_mesh = par_shapes_create_hemisphere(slices, rings); - _ = &sphere; - par_shapes_scale(sphere, radius, radius, radius); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (sphere.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (sphere.*.ntriangles * @as(c_int, 3)) * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (sphere.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.vertexCount = sphere.*.ntriangles * @as(c_int, 3); - mesh.triangleCount = sphere.*.ntriangles; - { - var k: c_int = 0; - _ = &k; - while (k < mesh.vertexCount) : (k += 1) { - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk sphere.*.points + @as(usize, @intCast(tmp)) else break :blk sphere.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk sphere.*.points + @as(usize, @intCast(tmp)) else break :blk sphere.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk sphere.*.points + @as(usize, @intCast(tmp)) else break :blk sphere.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk sphere.*.normals + @as(usize, @intCast(tmp)) else break :blk sphere.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk sphere.*.normals + @as(usize, @intCast(tmp)) else break :blk sphere.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk sphere.*.normals + @as(usize, @intCast(tmp)) else break :blk sphere.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2); - if (tmp >= 0) break :blk sphere.*.tcoords + @as(usize, @intCast(tmp)) else break :blk sphere.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 sphere.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 sphere.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk sphere.*.tcoords + @as(usize, @intCast(tmp)) else break :blk sphere.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - par_shapes_free_mesh(sphere); - UploadMesh(&mesh, @as(c_int, 0) != 0); - } else { - TraceLog(LOG_WARNING, "MESH: Failed to generate mesh: hemisphere"); - } - return mesh; -} -pub export fn GenMeshCylinder(arg_radius: f32, arg_height: f32, arg_slices: c_int) Mesh { - var radius = arg_radius; - _ = &radius; - var height = arg_height; - _ = &height; - var slices = arg_slices; - _ = &slices; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if (slices >= @as(c_int, 3)) { - var cylinder: [*c]par_shapes_mesh = par_shapes_create_cylinder(slices, @as(c_int, 8)); - _ = &cylinder; - par_shapes_scale(cylinder, radius, radius, height); - par_shapes_rotate(cylinder, -3.1415927410125732 / 2.0, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 1, - 0, - 0, - }))))); - var capTop: [*c]par_shapes_mesh = par_shapes_create_disk(radius, slices, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 0, - 0, - })))), @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 0, - 1, - }))))); - _ = &capTop; - capTop.*.tcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2) * capTop.*.npoints))) *% @sizeOf(f32))))); - { - var i: c_int = 0; - _ = &i; - while (i < (@as(c_int, 2) * capTop.*.npoints)) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk capTop.*.tcoords + @as(usize, @intCast(tmp)) else break :blk capTop.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0.0; - } - } - par_shapes_rotate(capTop, -3.1415927410125732 / 2.0, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 1, - 0, - 0, - }))))); - par_shapes_rotate(capTop, @as(f32, @floatFromInt(@as(c_int, 90))) * (3.1415927410125732 / 180.0), @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 1, - 0, - }))))); - par_shapes_translate(capTop, @as(f32, @floatFromInt(@as(c_int, 0))), height, @as(f32, @floatFromInt(@as(c_int, 0)))); - var capBottom: [*c]par_shapes_mesh = par_shapes_create_disk(radius, slices, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 0, - 0, - })))), @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 0, - @as(f32, @floatFromInt(-@as(c_int, 1))), - }))))); - _ = &capBottom; - capBottom.*.tcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2) * capBottom.*.npoints))) *% @sizeOf(f32))))); - { - var i: c_int = 0; - _ = &i; - while (i < (@as(c_int, 2) * capBottom.*.npoints)) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk capBottom.*.tcoords + @as(usize, @intCast(tmp)) else break :blk capBottom.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0.949999988079071; - } - } - par_shapes_rotate(capBottom, 3.1415927410125732 / 2.0, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 1, - 0, - 0, - }))))); - par_shapes_rotate(capBottom, @as(f32, @floatFromInt(-@as(c_int, 90))) * (3.1415927410125732 / 180.0), @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 1, - 0, - }))))); - par_shapes_merge_and_free(cylinder, capTop); - par_shapes_merge_and_free(cylinder, capBottom); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (cylinder.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (cylinder.*.ntriangles * @as(c_int, 3)) * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (cylinder.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.vertexCount = cylinder.*.ntriangles * @as(c_int, 3); - mesh.triangleCount = cylinder.*.ntriangles; - { - var k: c_int = 0; - _ = &k; - while (k < mesh.vertexCount) : (k += 1) { - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk cylinder.*.points + @as(usize, @intCast(tmp)) else break :blk cylinder.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk cylinder.*.points + @as(usize, @intCast(tmp)) else break :blk cylinder.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk cylinder.*.points + @as(usize, @intCast(tmp)) else break :blk cylinder.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk cylinder.*.normals + @as(usize, @intCast(tmp)) else break :blk cylinder.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk cylinder.*.normals + @as(usize, @intCast(tmp)) else break :blk cylinder.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk cylinder.*.normals + @as(usize, @intCast(tmp)) else break :blk cylinder.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2); - if (tmp >= 0) break :blk cylinder.*.tcoords + @as(usize, @intCast(tmp)) else break :blk cylinder.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cylinder.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cylinder.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk cylinder.*.tcoords + @as(usize, @intCast(tmp)) else break :blk cylinder.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - par_shapes_free_mesh(cylinder); - UploadMesh(&mesh, @as(c_int, 0) != 0); - } else { - TraceLog(LOG_WARNING, "MESH: Failed to generate mesh: cylinder"); - } - return mesh; -} -pub export fn GenMeshCone(arg_radius: f32, arg_height: f32, arg_slices: c_int) Mesh { - var radius = arg_radius; - _ = &radius; - var height = arg_height; - _ = &height; - var slices = arg_slices; - _ = &slices; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if (slices >= @as(c_int, 3)) { - var cone: [*c]par_shapes_mesh = par_shapes_create_cone(slices, @as(c_int, 8)); - _ = &cone; - par_shapes_scale(cone, radius, radius, height); - par_shapes_rotate(cone, -3.1415927410125732 / 2.0, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 1, - 0, - 0, - }))))); - par_shapes_rotate(cone, 3.1415927410125732 / 2.0, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 1, - 0, - }))))); - var capBottom: [*c]par_shapes_mesh = par_shapes_create_disk(radius, slices, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 0, - 0, - })))), @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 0, - 0, - @as(f32, @floatFromInt(-@as(c_int, 1))), - }))))); - _ = &capBottom; - capBottom.*.tcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2) * capBottom.*.npoints))) *% @sizeOf(f32))))); - { - var i: c_int = 0; - _ = &i; - while (i < (@as(c_int, 2) * capBottom.*.npoints)) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk capBottom.*.tcoords + @as(usize, @intCast(tmp)) else break :blk capBottom.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0.949999988079071; - } - } - par_shapes_rotate(capBottom, 3.1415927410125732 / 2.0, @as([*c]f32, @ptrCast(@alignCast(&([3]f32{ - 1, - 0, - 0, - }))))); - par_shapes_merge_and_free(cone, capBottom); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (cone.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (cone.*.ntriangles * @as(c_int, 3)) * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (cone.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.vertexCount = cone.*.ntriangles * @as(c_int, 3); - mesh.triangleCount = cone.*.ntriangles; - { - var k: c_int = 0; - _ = &k; - while (k < mesh.vertexCount) : (k += 1) { - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk cone.*.points + @as(usize, @intCast(tmp)) else break :blk cone.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk cone.*.points + @as(usize, @intCast(tmp)) else break :blk cone.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk cone.*.points + @as(usize, @intCast(tmp)) else break :blk cone.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk cone.*.normals + @as(usize, @intCast(tmp)) else break :blk cone.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk cone.*.normals + @as(usize, @intCast(tmp)) else break :blk cone.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk cone.*.normals + @as(usize, @intCast(tmp)) else break :blk cone.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2); - if (tmp >= 0) break :blk cone.*.tcoords + @as(usize, @intCast(tmp)) else break :blk cone.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 cone.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 cone.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk cone.*.tcoords + @as(usize, @intCast(tmp)) else break :blk cone.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - par_shapes_free_mesh(cone); - UploadMesh(&mesh, @as(c_int, 0) != 0); - } else { - TraceLog(LOG_WARNING, "MESH: Failed to generate mesh: cone"); - } - return mesh; -} -pub export fn GenMeshTorus(arg_radius: f32, arg_size: f32, arg_radSeg: c_int, arg_sides: c_int) Mesh { - var radius = arg_radius; - _ = &radius; - var size = arg_size; - _ = &size; - var radSeg = arg_radSeg; - _ = &radSeg; - var sides = arg_sides; - _ = &sides; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if ((sides >= @as(c_int, 3)) and (radSeg >= @as(c_int, 3))) { - if (radius > 1.0) { - radius = 1.0; - } else if (radius < 0.10000000149011612) { - radius = 0.10000000149011612; - } - var torus: [*c]par_shapes_mesh = par_shapes_create_torus(radSeg, sides, radius); - _ = &torus; - par_shapes_scale(torus, size / @as(f32, @floatFromInt(@as(c_int, 2))), size / @as(f32, @floatFromInt(@as(c_int, 2))), size / @as(f32, @floatFromInt(@as(c_int, 2)))); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (torus.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (torus.*.ntriangles * @as(c_int, 3)) * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (torus.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.vertexCount = torus.*.ntriangles * @as(c_int, 3); - mesh.triangleCount = torus.*.ntriangles; - { - var k: c_int = 0; - _ = &k; - while (k < mesh.vertexCount) : (k += 1) { - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk torus.*.points + @as(usize, @intCast(tmp)) else break :blk torus.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk torus.*.points + @as(usize, @intCast(tmp)) else break :blk torus.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk torus.*.points + @as(usize, @intCast(tmp)) else break :blk torus.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk torus.*.normals + @as(usize, @intCast(tmp)) else break :blk torus.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk torus.*.normals + @as(usize, @intCast(tmp)) else break :blk torus.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk torus.*.normals + @as(usize, @intCast(tmp)) else break :blk torus.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2); - if (tmp >= 0) break :blk torus.*.tcoords + @as(usize, @intCast(tmp)) else break :blk torus.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 torus.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 torus.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk torus.*.tcoords + @as(usize, @intCast(tmp)) else break :blk torus.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - par_shapes_free_mesh(torus); - UploadMesh(&mesh, @as(c_int, 0) != 0); - } else { - TraceLog(LOG_WARNING, "MESH: Failed to generate mesh: torus"); - } - return mesh; -} -pub export fn GenMeshKnot(arg_radius: f32, arg_size: f32, arg_radSeg: c_int, arg_sides: c_int) Mesh { - var radius = arg_radius; - _ = &radius; - var size = arg_size; - _ = &size; - var radSeg = arg_radSeg; - _ = &radSeg; - var sides = arg_sides; - _ = &sides; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - if ((sides >= @as(c_int, 3)) and (radSeg >= @as(c_int, 3))) { - if (radius > 3.0) { - radius = 3.0; - } else if (radius < 0.5) { - radius = 0.5; - } - var knot: [*c]par_shapes_mesh = par_shapes_create_trefoil_knot(radSeg, sides, radius); - _ = &knot; - par_shapes_scale(knot, size, size, size); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (knot.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (knot.*.ntriangles * @as(c_int, 3)) * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, (knot.*.ntriangles * @as(c_int, 3)) * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.vertexCount = knot.*.ntriangles * @as(c_int, 3); - mesh.triangleCount = knot.*.ntriangles; - { - var k: c_int = 0; - _ = &k; - while (k < mesh.vertexCount) : (k += 1) { - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk knot.*.points + @as(usize, @intCast(tmp)) else break :blk knot.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk knot.*.points + @as(usize, @intCast(tmp)) else break :blk knot.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk knot.*.points + @as(usize, @intCast(tmp)) else break :blk knot.*.points - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3); - if (tmp >= 0) break :blk knot.*.normals + @as(usize, @intCast(tmp)) else break :blk knot.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk knot.*.normals + @as(usize, @intCast(tmp)) else break :blk knot.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk knot.*.normals + @as(usize, @intCast(tmp)) else break :blk knot.*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = k * @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2); - if (tmp >= 0) break :blk knot.*.tcoords + @as(usize, @intCast(tmp)) else break :blk knot.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (k * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_uint, (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 knot.*.triangles + @as(usize, @intCast(tmp_2)) else break :blk_1 knot.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk knot.*.tcoords + @as(usize, @intCast(tmp)) else break :blk knot.*.tcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - par_shapes_free_mesh(knot); - UploadMesh(&mesh, @as(c_int, 0) != 0); - } else { - TraceLog(LOG_WARNING, "MESH: Failed to generate mesh: knot"); - } - return mesh; -} -pub export fn GenMeshHeightmap(arg_heightmap: Image, arg_size: Vector3) Mesh { - var heightmap = arg_heightmap; - _ = &heightmap; - var size = arg_size; - _ = &size; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - var mapX: c_int = heightmap.width; - _ = &mapX; - var mapZ: c_int = heightmap.height; - _ = &mapZ; - var pixels: [*c]Color = LoadImageColors(heightmap); - _ = &pixels; - mesh.triangleCount = ((mapX - @as(c_int, 1)) * (mapZ - @as(c_int, 1))) * @as(c_int, 2); - mesh.vertexCount = mesh.triangleCount * @as(c_int, 3); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.colors = null; - var vCounter: c_int = 0; - _ = &vCounter; - var tcCounter: c_int = 0; - _ = &tcCounter; - var nCounter: c_int = 0; - _ = &nCounter; - var scaleFactor: Vector3 = Vector3{ - .x = size.x / @as(f32, @floatFromInt(mapX - @as(c_int, 1))), - .y = size.y / 255.0, - .z = size.z / @as(f32, @floatFromInt(mapZ - @as(c_int, 1))), - }; - _ = &scaleFactor; - var vA: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &vA; - var vB: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &vB; - var vC: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &vC; - var vN: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &vN; - { - var z: c_int = 0; - _ = &z; - while (z < (mapZ - @as(c_int, 1))) : (z += 1) { - { - var x: c_int = 0; - _ = &x; - while (x < (mapX - @as(c_int, 1))) : (x += 1) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x)) * scaleFactor.x; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (@as(f32, @floatFromInt((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = x + (z * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = x + (z * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g)))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = x + (z * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))))) / 3.0) * scaleFactor.y; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z)) * scaleFactor.z; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x)) * scaleFactor.x; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (@as(f32, @floatFromInt((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = x + ((z + @as(c_int, 1)) * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = x + ((z + @as(c_int, 1)) * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g)))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = x + ((z + @as(c_int, 1)) * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))))) / 3.0) * scaleFactor.y; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z + @as(c_int, 1))) * scaleFactor.z; - (blk: { - const tmp = vCounter + @as(c_int, 6); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x + @as(c_int, 1))) * scaleFactor.x; - (blk: { - const tmp = vCounter + @as(c_int, 7); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (@as(f32, @floatFromInt((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (x + @as(c_int, 1)) + (z * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (x + @as(c_int, 1)) + (z * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g)))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (x + @as(c_int, 1)) + (z * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))))) / 3.0) * scaleFactor.y; - (blk: { - const tmp = vCounter + @as(c_int, 8); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z)) * scaleFactor.z; - (blk: { - const tmp = vCounter + @as(c_int, 9); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = vCounter + @as(c_int, 6); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = vCounter + @as(c_int, 10); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = vCounter + @as(c_int, 7); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = vCounter + @as(c_int, 11); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = vCounter + @as(c_int, 8); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = vCounter + @as(c_int, 12); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = vCounter + @as(c_int, 13); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = vCounter + @as(c_int, 14); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = vCounter + @as(c_int, 15); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x + @as(c_int, 1))) * scaleFactor.x; - (blk: { - const tmp = vCounter + @as(c_int, 16); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (@as(f32, @floatFromInt((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (x + @as(c_int, 1)) + ((z + @as(c_int, 1)) * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (x + @as(c_int, 1)) + ((z + @as(c_int, 1)) * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g)))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (x + @as(c_int, 1)) + ((z + @as(c_int, 1)) * mapX); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))))) / 3.0) * scaleFactor.y; - (blk: { - const tmp = vCounter + @as(c_int, 17); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z + @as(c_int, 1))) * scaleFactor.z; - vCounter += @as(c_int, 18); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x)) / @as(f32, @floatFromInt(mapX - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z)) / @as(f32, @floatFromInt(mapZ - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x)) / @as(f32, @floatFromInt(mapX - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z + @as(c_int, 1))) / @as(f32, @floatFromInt(mapZ - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x + @as(c_int, 1))) / @as(f32, @floatFromInt(mapX - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z)) / @as(f32, @floatFromInt(mapZ - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 6); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = tcCounter + @as(c_int, 7); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = tcCounter + @as(c_int, 8); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = tcCounter + @as(c_int, 9); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = tcCounter + @as(c_int, 10); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(x + @as(c_int, 1))) / @as(f32, @floatFromInt(mapX - @as(c_int, 1))); - (blk: { - const tmp = tcCounter + @as(c_int, 11); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(z + @as(c_int, 1))) / @as(f32, @floatFromInt(mapZ - @as(c_int, 1))); - tcCounter += @as(c_int, 12); - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 18)) : (i += @as(c_int, 9)) { - vA.x = (blk: { - const tmp = nCounter + i; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vA.y = (blk: { - const tmp = (nCounter + i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vA.z = (blk: { - const tmp = (nCounter + i) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vB.x = (blk: { - const tmp = (nCounter + i) + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vB.y = (blk: { - const tmp = (nCounter + i) + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vB.z = (blk: { - const tmp = (nCounter + i) + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vC.x = (blk: { - const tmp = (nCounter + i) + @as(c_int, 6); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vC.y = (blk: { - const tmp = (nCounter + i) + @as(c_int, 7); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vC.z = (blk: { - const tmp = (nCounter + i) + @as(c_int, 8); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - vN = Vector3Normalize(Vector3CrossProduct(Vector3Subtract(vB, vA), Vector3Subtract(vC, vA))); - (blk: { - const tmp = nCounter + i; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.x; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.y; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.z; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 3); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.x; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 4); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.y; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 5); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.z; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 6); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.x; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 7); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.y; - (blk: { - const tmp = (nCounter + i) + @as(c_int, 8); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vN.z; - } - } - nCounter += @as(c_int, 18); - } - } - } - } - UnloadImageColors(pixels); - UploadMesh(&mesh, @as(c_int, 0) != 0); - return mesh; -} -pub export fn GenMeshCubicmap(arg_cubicmap: Image, arg_cubeSize: Vector3) Mesh { - var cubicmap = arg_cubicmap; - _ = &cubicmap; - var cubeSize = arg_cubeSize; - _ = &cubeSize; - var mesh: Mesh = Mesh{ - .vertexCount = @as(c_int, 0), - .triangleCount = 0, - .vertices = null, - .texcoords = null, - .texcoords2 = null, - .normals = null, - .tangents = null, - .colors = null, - .indices = null, - .animVertices = null, - .animNormals = null, - .boneIds = null, - .boneWeights = null, - .vaoId = 0, - .vboId = null, - }; - _ = &mesh; - var pixels: [*c]Color = LoadImageColors(cubicmap); - _ = &pixels; - var maxTriangles: c_int = (cubicmap.width * cubicmap.height) * @as(c_int, 12); - _ = &maxTriangles; - var vCounter: c_int = 0; - _ = &vCounter; - var tcCounter: c_int = 0; - _ = &tcCounter; - var nCounter: c_int = 0; - _ = &nCounter; - var w: f32 = cubeSize.x; - _ = &w; - var h: f32 = cubeSize.z; - _ = &h; - var h2: f32 = cubeSize.y; - _ = &h2; - var mapVertices: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, maxTriangles * @as(c_int, 3)))) *% @sizeOf(Vector3))))); - _ = &mapVertices; - var mapTexcoords: [*c]Vector2 = @as([*c]Vector2, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, maxTriangles * @as(c_int, 3)))) *% @sizeOf(Vector2))))); - _ = &mapTexcoords; - var mapNormals: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, maxTriangles * @as(c_int, 3)))) *% @sizeOf(Vector3))))); - _ = &mapNormals; - var n1: Vector3 = Vector3{ - .x = 1.0, - .y = 0.0, - .z = 0.0, - }; - _ = &n1; - var n2: Vector3 = Vector3{ - .x = -1.0, - .y = 0.0, - .z = 0.0, - }; - _ = &n2; - var n3: Vector3 = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - _ = &n3; - var n4: Vector3 = Vector3{ - .x = 0.0, - .y = -1.0, - .z = 0.0, - }; - _ = &n4; - var n5: Vector3 = Vector3{ - .x = 0.0, - .y = 0.0, - .z = -1.0, - }; - _ = &n5; - var n6: Vector3 = Vector3{ - .x = 0.0, - .y = 0.0, - .z = 1.0, - }; - _ = &n6; - const struct_RectangleF = extern struct { - x: f32 = @import("std").mem.zeroes(f32), - y: f32 = @import("std").mem.zeroes(f32), - width: f32 = @import("std").mem.zeroes(f32), - height: f32 = @import("std").mem.zeroes(f32), - }; - _ = &struct_RectangleF; - const RectangleF = struct_RectangleF; - _ = &RectangleF; - var rightTexUV: RectangleF = RectangleF{ - .x = 0.0, - .y = 0.0, - .width = 0.5, - .height = 0.5, - }; - _ = &rightTexUV; - var leftTexUV: RectangleF = RectangleF{ - .x = 0.5, - .y = 0.0, - .width = 0.5, - .height = 0.5, - }; - _ = &leftTexUV; - var frontTexUV: RectangleF = RectangleF{ - .x = 0.0, - .y = 0.0, - .width = 0.5, - .height = 0.5, - }; - _ = &frontTexUV; - var backTexUV: RectangleF = RectangleF{ - .x = 0.5, - .y = 0.0, - .width = 0.5, - .height = 0.5, - }; - _ = &backTexUV; - var topTexUV: RectangleF = RectangleF{ - .x = 0.0, - .y = 0.5, - .width = 0.5, - .height = 0.5, - }; - _ = &topTexUV; - var bottomTexUV: RectangleF = RectangleF{ - .x = 0.5, - .y = 0.5, - .width = 0.5, - .height = 0.5, - }; - _ = &bottomTexUV; - { - var z: c_int = 0; - _ = &z; - while (z < cubicmap.height) : (z += 1) { - { - var x: c_int = 0; - _ = &x; - while (x < cubicmap.width) : (x += 1) { - var v1: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) - 0.5), - .y = h2, - .z = h * (@as(f32, @floatFromInt(z)) - 0.5), - }; - _ = &v1; - var v2: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) - 0.5), - .y = h2, - .z = h * (@as(f32, @floatFromInt(z)) + 0.5), - }; - _ = &v2; - var v3: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) + 0.5), - .y = h2, - .z = h * (@as(f32, @floatFromInt(z)) + 0.5), - }; - _ = &v3; - var v4: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) + 0.5), - .y = h2, - .z = h * (@as(f32, @floatFromInt(z)) - 0.5), - }; - _ = &v4; - var v5: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) + 0.5), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = h * (@as(f32, @floatFromInt(z)) - 0.5), - }; - _ = &v5; - var v6: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) - 0.5), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = h * (@as(f32, @floatFromInt(z)) - 0.5), - }; - _ = &v6; - var v7: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) - 0.5), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = h * (@as(f32, @floatFromInt(z)) + 0.5), - }; - _ = &v7; - var v8: Vector3 = Vector3{ - .x = w * (@as(f32, @floatFromInt(x)) + 0.5), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = h * (@as(f32, @floatFromInt(z)) + 0.5), - }; - _ = &v8; - if ((((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).r)))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).g))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).b))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.a))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).a))))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v2; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v4; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x, - .y = topTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x, - .y = topTexUV.y + topTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x + topTexUV.width, - .y = topTexUV.y + topTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x, - .y = topTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x + topTexUV.width, - .y = topTexUV.y + topTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x + topTexUV.width, - .y = topTexUV.y, - }; - tcCounter += @as(c_int, 6); - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v6; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v7; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v6; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v5; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x + bottomTexUV.width, - .y = bottomTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x, - .y = bottomTexUV.y + bottomTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x + bottomTexUV.width, - .y = bottomTexUV.y + bottomTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x + bottomTexUV.width, - .y = bottomTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x, - .y = bottomTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x, - .y = bottomTexUV.y + bottomTexUV.height, - }; - tcCounter += @as(c_int, 6); - if (((z < (cubicmap.height - @as(c_int, 1))) and ((((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z + @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).r)))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z + @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).g))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z + @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).b))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z + @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.a))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).a)))))) or (z == (cubicmap.height - @as(c_int, 1)))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v2; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v7; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v7; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n6; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n6; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n6; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n6; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n6; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n6; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = frontTexUV.x, - .y = frontTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = frontTexUV.x, - .y = frontTexUV.y + frontTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = frontTexUV.x + frontTexUV.width, - .y = frontTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = frontTexUV.x + frontTexUV.width, - .y = frontTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = frontTexUV.x, - .y = frontTexUV.y + frontTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = frontTexUV.x + frontTexUV.width, - .y = frontTexUV.y + frontTexUV.height, - }; - tcCounter += @as(c_int, 6); - } - if (((z > @as(c_int, 0)) and ((((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z - @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).r)))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z - @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).g))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z - @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).b))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = ((z - @as(c_int, 1)) * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.a))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).a)))))) or (z == @as(c_int, 0))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v5; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v6; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v4; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v5; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n5; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n5; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n5; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n5; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n5; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n5; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = backTexUV.x + backTexUV.width, - .y = backTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = backTexUV.x, - .y = backTexUV.y + backTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = backTexUV.x + backTexUV.width, - .y = backTexUV.y + backTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = backTexUV.x + backTexUV.width, - .y = backTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = backTexUV.x, - .y = backTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = backTexUV.x, - .y = backTexUV.y + backTexUV.height, - }; - tcCounter += @as(c_int, 6); - } - if (((x < (cubicmap.width - @as(c_int, 1))) and ((((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x + @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).r)))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x + @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).g))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x + @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).b))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x + @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.a))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).a)))))) or (x == (cubicmap.width - @as(c_int, 1)))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v4; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v4; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v5; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n1; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n1; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n1; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n1; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n1; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n1; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = rightTexUV.x, - .y = rightTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = rightTexUV.x, - .y = rightTexUV.y + rightTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = rightTexUV.x + rightTexUV.width, - .y = rightTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = rightTexUV.x + rightTexUV.width, - .y = rightTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = rightTexUV.x, - .y = rightTexUV.y + rightTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = rightTexUV.x + rightTexUV.width, - .y = rightTexUV.y + rightTexUV.height, - }; - tcCounter += @as(c_int, 6); - } - if (((x > @as(c_int, 0)) and ((((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x - @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).r)))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x - @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).g))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x - @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).b))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + (x - @as(c_int, 1)); - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.a))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).a)))))) or (x == @as(c_int, 0))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v7; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v2; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v6; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v7; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n2; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n2; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n2; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n2; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n2; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n2; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = leftTexUV.x, - .y = leftTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = leftTexUV.x + leftTexUV.width, - .y = leftTexUV.y + leftTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = leftTexUV.x + leftTexUV.width, - .y = leftTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = leftTexUV.x, - .y = leftTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = leftTexUV.x, - .y = leftTexUV.y + leftTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = leftTexUV.x + leftTexUV.width, - .y = leftTexUV.y + leftTexUV.height, - }; - tcCounter += @as(c_int, 6); - } - } else if ((((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.r))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).r)))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.g))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).g))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.b))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).b))))) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = (z * cubicmap.width) + x; - if (tmp >= 0) break :blk pixels + @as(usize, @intCast(tmp)) else break :blk pixels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.a))) == @as(c_int, @bitCast(@as(c_uint, (Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }).a))))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v2; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v1; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v4; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v3; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n4; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x, - .y = topTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x + topTexUV.width, - .y = topTexUV.y + topTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x, - .y = topTexUV.y + topTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x, - .y = topTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x + topTexUV.width, - .y = topTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = topTexUV.x + topTexUV.width, - .y = topTexUV.y + topTexUV.height, - }; - tcCounter += @as(c_int, 6); - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v6; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v7; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - (blk: { - const tmp = vCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v6; - (blk: { - const tmp = vCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v8; - (blk: { - const tmp = vCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = v5; - vCounter += @as(c_int, 6); - (blk: { - const tmp = nCounter; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - (blk: { - const tmp = nCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = n3; - nCounter += @as(c_int, 6); - (blk: { - const tmp = tcCounter; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x + bottomTexUV.width, - .y = bottomTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x + bottomTexUV.width, - .y = bottomTexUV.y + bottomTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x, - .y = bottomTexUV.y + bottomTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 3); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x + bottomTexUV.width, - .y = bottomTexUV.y, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 4); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x, - .y = bottomTexUV.y + bottomTexUV.height, - }; - (blk: { - const tmp = tcCounter + @as(c_int, 5); - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Vector2{ - .x = bottomTexUV.x, - .y = bottomTexUV.y, - }; - tcCounter += @as(c_int, 6); - } - } - } - } - } - mesh.vertexCount = vCounter; - mesh.triangleCount = @divTrunc(vCounter, @as(c_int, 3)); - mesh.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))); - mesh.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 2)))) *% @sizeOf(f32))))); - mesh.colors = null; - var fCounter: c_int = 0; - _ = &fCounter; - { - var i: c_int = 0; - _ = &i; - while (i < vCounter) : (i += 1) { - (blk: { - const tmp = fCounter; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = fCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - (blk: { - const tmp = fCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapVertices + @as(usize, @intCast(tmp)) else break :blk mapVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z; - fCounter += @as(c_int, 3); - } - } - fCounter = 0; - { - var i: c_int = 0; - _ = &i; - while (i < nCounter) : (i += 1) { - (blk: { - const tmp = fCounter; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = fCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - (blk: { - const tmp = fCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapNormals + @as(usize, @intCast(tmp)) else break :blk mapNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.z; - fCounter += @as(c_int, 3); - } - } - fCounter = 0; - { - var i: c_int = 0; - _ = &i; - while (i < tcCounter) : (i += 1) { - (blk: { - const tmp = fCounter; - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.x; - (blk: { - const tmp = fCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.texcoords + @as(usize, @intCast(tmp)) else break :blk mesh.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = i; - if (tmp >= 0) break :blk mapTexcoords + @as(usize, @intCast(tmp)) else break :blk mapTexcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.y; - fCounter += @as(c_int, 2); - } - } - free(@as(?*anyopaque, @ptrCast(mapVertices))); - free(@as(?*anyopaque, @ptrCast(mapNormals))); - free(@as(?*anyopaque, @ptrCast(mapTexcoords))); - UnloadImageColors(pixels); - UploadMesh(&mesh, @as(c_int, 0) != 0); - return mesh; -} -pub export fn LoadMaterials(arg_fileName: [*c]const u8, arg_materialCount: [*c]c_int) [*c]Material { - var fileName = arg_fileName; - _ = &fileName; - var materialCount = arg_materialCount; - _ = &materialCount; - var materials: [*c]Material = null; - _ = &materials; - var count: c_uint = 0; - _ = &count; - if (IsFileExtension(fileName, ".mtl")) { - var mats: [*c]tinyobj_material_t = null; - _ = &mats; - var result: c_int = tinyobj_parse_mtl_file(&mats, &count, fileName); - _ = &result; - if (result != @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MATERIAL: [%s] Failed to parse materials file", fileName); - } - materials = @as([*c]Material, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, count))) *% @sizeOf(Material))))); - ProcessMaterialsOBJ(materials, mats, @as(c_int, @bitCast(count))); - tinyobj_materials_free(mats, count); - } - materialCount.* = @as(c_int, @bitCast(count)); - return materials; -} -pub export fn LoadMaterialDefault() Material { - var material: Material = Material{ - .shader = Shader{ - .id = @as(c_uint, @bitCast(@as(c_int, 0))), - .locs = null, - }, - .maps = null, - .params = @import("std").mem.zeroes([4]f32), - }; - _ = &material; - material.maps = @as([*c]MaterialMap, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 12)))), @sizeOf(MaterialMap))))); - material.shader.id = rlGetShaderIdDefault(); - material.shader.locs = rlGetShaderLocsDefault(); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = Texture2D{ - .id = rlGetTextureIdDefault(), - .width = @as(c_int, 1), - .height = @as(c_int, 1), - .mipmaps = @as(c_int, 1), - .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, - }; - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - return material; -} -pub export fn IsMaterialReady(arg_material: Material) bool { - var material = arg_material; - _ = &material; - var result: bool = @as(c_int, 0) != 0; - _ = &result; - if ((material.maps != @as([*c]MaterialMap, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) and (material.shader.id > @as(c_uint, @bitCast(@as(c_int, 0))))) { - result = @as(c_int, 1) != 0; - } - return result; -} -pub export fn UnloadMaterial(arg_material: Material) void { - var material = arg_material; - _ = &material; - if (material.shader.id != rlGetShaderIdDefault()) { - UnloadShader(material.shader); - } - if (material.maps != @as([*c]MaterialMap, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 12)) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id != rlGetTextureIdDefault()) { - rlUnloadTexture((blk: { - const tmp = i; - if (tmp >= 0) break :blk material.maps + @as(usize, @intCast(tmp)) else break :blk material.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture.id); - } - } - } - } - free(@as(?*anyopaque, @ptrCast(material.maps))); -} -pub export fn SetMaterialTexture(arg_material: [*c]Material, arg_mapType: c_int, arg_texture: Texture2D) void { - var material = arg_material; - _ = &material; - var mapType = arg_mapType; - _ = &mapType; - var texture = arg_texture; - _ = &texture; - (blk: { - const tmp = mapType; - if (tmp >= 0) break :blk material.*.maps + @as(usize, @intCast(tmp)) else break :blk material.*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = texture; -} -pub export fn SetModelMeshMaterial(arg_model: [*c]Model, arg_meshId: c_int, arg_materialId: c_int) void { - var model = arg_model; - _ = &model; - var meshId = arg_meshId; - _ = &meshId; - var materialId = arg_materialId; - _ = &materialId; - if (meshId >= model.*.meshCount) { - TraceLog(LOG_WARNING, "MESH: Id greater than mesh count"); - } else if (materialId >= model.*.materialCount) { - TraceLog(LOG_WARNING, "MATERIAL: Id greater than material count"); - } else { - (blk: { - const tmp = meshId; - if (tmp >= 0) break :blk model.*.meshMaterial + @as(usize, @intCast(tmp)) else break :blk model.*.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = materialId; - } -} -pub export fn LoadModelAnimations(arg_fileName: [*c]const u8, arg_animCount: [*c]c_int) [*c]ModelAnimation { - var fileName = arg_fileName; - _ = &fileName; - var animCount = arg_animCount; - _ = &animCount; - var animations: [*c]ModelAnimation = null; - _ = &animations; - if (IsFileExtension(fileName, ".iqm")) { - animations = LoadModelAnimationsIQM(fileName, animCount); - } - if (IsFileExtension(fileName, ".m3d")) { - animations = LoadModelAnimationsM3D(fileName, animCount); - } - if (IsFileExtension(fileName, ".gltf;.glb")) { - animations = LoadModelAnimationsGLTF(fileName, animCount); - } - return animations; -} -pub export fn UpdateModelAnimation(arg_model: Model, arg_anim: ModelAnimation, arg_frame: c_int) void { - var model = arg_model; - _ = &model; - var anim = arg_anim; - _ = &anim; - var frame = arg_frame; - _ = &frame; - if (((anim.frameCount > @as(c_int, 0)) and (anim.bones != @as([*c]BoneInfo, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) and (anim.framePoses != @as([*c][*c]Transform, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - if (frame >= anim.frameCount) { - frame = @import("std").zig.c_translation.signedRemainder(frame, anim.frameCount); - } - { - var m: c_int = 0; - _ = &m; - while (m < model.meshCount) : (m += 1) { - var mesh: Mesh = (blk: { - const tmp = m; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &mesh; - if ((mesh.boneIds == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) or (mesh.boneWeights == @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - TraceLog(LOG_WARNING, "MODEL: UpdateModelAnimation(): Mesh %i has no connection to bones", m); - continue; - } - var updated: bool = @as(c_int, 0) != 0; - _ = &updated; - var animVertex: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &animVertex; - var animNormal: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &animNormal; - var inTranslation: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &inTranslation; - var inRotation: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &inRotation; - var outTranslation: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &outTranslation; - var outRotation: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &outRotation; - var outScale: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &outScale; - var boneId: c_int = 0; - _ = &boneId; - var boneCounter: c_int = 0; - _ = &boneCounter; - var boneWeight: f32 = @as(f32, @floatCast(0.0)); - _ = &boneWeight; - const vValues: c_int = mesh.vertexCount * @as(c_int, 3); - _ = &vValues; - { - var vCounter: c_int = 0; - _ = &vCounter; - while (vCounter < vValues) : (vCounter += @as(c_int, 3)) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.animVertices + @as(usize, @intCast(tmp)) else break :blk mesh.animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.animVertices + @as(usize, @intCast(tmp)) else break :blk mesh.animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.animVertices + @as(usize, @intCast(tmp)) else break :blk mesh.animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - if (mesh.animNormals != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.animNormals + @as(usize, @intCast(tmp)) else break :blk mesh.animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.animNormals + @as(usize, @intCast(tmp)) else break :blk mesh.animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.animNormals + @as(usize, @intCast(tmp)) else break :blk mesh.animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - } - { - var j: c_int = 0; - _ = &j; - while (j < @as(c_int, 4)) : (_ = blk: { - j += 1; - break :blk blk_1: { - const ref = &boneCounter; - const tmp = ref.*; - ref.* += 1; - break :blk_1 tmp; - }; - }) { - boneWeight = (blk: { - const tmp = boneCounter; - if (tmp >= 0) break :blk mesh.boneWeights + @as(usize, @intCast(tmp)) else break :blk mesh.boneWeights - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - if (boneWeight == 0.0) continue; - boneId = @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = boneCounter; - if (tmp >= 0) break :blk mesh.boneIds + @as(usize, @intCast(tmp)) else break :blk mesh.boneIds - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - inTranslation = (blk: { - const tmp = boneId; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation; - inRotation = (blk: { - const tmp = boneId; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation; - outTranslation = (blk: { - const tmp = boneId; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = frame; - if (tmp_2 >= 0) break :blk_1 anim.framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = frame; - if (tmp_2 >= 0) break :blk_1 anim.framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation; - outRotation = (blk: { - const tmp = boneId; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = frame; - if (tmp_2 >= 0) break :blk_1 anim.framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = frame; - if (tmp_2 >= 0) break :blk_1 anim.framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation; - outScale = (blk: { - const tmp = boneId; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = frame; - if (tmp_2 >= 0) break :blk_1 anim.framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = frame; - if (tmp_2 >= 0) break :blk_1 anim.framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale; - animVertex = Vector3{ - .x = (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.vertices + @as(usize, @intCast(tmp)) else break :blk mesh.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - animVertex = Vector3Subtract(animVertex, inTranslation); - animVertex = Vector3Multiply(animVertex, outScale); - animVertex = Vector3RotateByQuaternion(animVertex, QuaternionMultiply(outRotation, QuaternionInvert(inRotation))); - animVertex = Vector3Add(animVertex, outTranslation); - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.animVertices + @as(usize, @intCast(tmp)) else break :blk mesh.animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* += animVertex.x * boneWeight; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.animVertices + @as(usize, @intCast(tmp)) else break :blk mesh.animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* += animVertex.y * boneWeight; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.animVertices + @as(usize, @intCast(tmp)) else break :blk mesh.animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* += animVertex.z * boneWeight; - updated = @as(c_int, 1) != 0; - if (mesh.normals != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - animNormal = Vector3{ - .x = (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .y = (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - .z = (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.normals + @as(usize, @intCast(tmp)) else break :blk mesh.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, - }; - animNormal = Vector3RotateByQuaternion(animNormal, QuaternionMultiply(outRotation, QuaternionInvert(inRotation))); - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk mesh.animNormals + @as(usize, @intCast(tmp)) else break :blk mesh.animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* += animNormal.x * boneWeight; - (blk: { - const tmp = vCounter + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.animNormals + @as(usize, @intCast(tmp)) else break :blk mesh.animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* += animNormal.y * boneWeight; - (blk: { - const tmp = vCounter + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.animNormals + @as(usize, @intCast(tmp)) else break :blk mesh.animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* += animNormal.z * boneWeight; - } - } - } - } - } - if (updated) { - rlUpdateVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 0)))], @as(?*const anyopaque, @ptrCast(mesh.animVertices)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))), @as(c_int, 0)); - rlUpdateVertexBuffer(mesh.vboId[@as(c_uint, @intCast(@as(c_int, 2)))], @as(?*const anyopaque, @ptrCast(mesh.animNormals)), @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, mesh.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32))))), @as(c_int, 0)); - } - } - } - } -} -pub export fn UnloadModelAnimation(arg_anim: ModelAnimation) void { - var anim = arg_anim; - _ = &anim; - { - var i: c_int = 0; - _ = &i; - while (i < anim.frameCount) : (i += 1) { - free(@as(?*anyopaque, @ptrCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk anim.framePoses + @as(usize, @intCast(tmp)) else break :blk anim.framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - } - } - free(@as(?*anyopaque, @ptrCast(anim.bones))); - free(@as(?*anyopaque, @ptrCast(anim.framePoses))); -} -pub export fn UnloadModelAnimations(arg_animations: [*c]ModelAnimation, arg_animCount: c_int) void { - var animations = arg_animations; - _ = &animations; - var animCount = arg_animCount; - _ = &animCount; - { - var i: c_int = 0; - _ = &i; - while (i < animCount) : (i += 1) { - UnloadModelAnimation((blk: { - const tmp = i; - if (tmp >= 0) break :blk animations + @as(usize, @intCast(tmp)) else break :blk animations - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*); - } - } - free(@as(?*anyopaque, @ptrCast(animations))); -} -pub export fn IsModelAnimationValid(arg_model: Model, arg_anim: ModelAnimation) bool { - var model = arg_model; - _ = &model; - var anim = arg_anim; - _ = &anim; - var result: c_int = 1; - _ = &result; - if (model.boneCount != anim.boneCount) { - result = 0; - } else { - { - var i: c_int = 0; - _ = &i; - while (i < model.boneCount) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bones + @as(usize, @intCast(tmp)) else break :blk model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent != (blk: { - const tmp = i; - if (tmp >= 0) break :blk anim.bones + @as(usize, @intCast(tmp)) else break :blk anim.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent) { - result = 0; - break; - } - } - } - } - return result != 0; -} -pub export fn CheckCollisionSpheres(arg_center1: Vector3, arg_radius1: f32, arg_center2: Vector3, arg_radius2: f32) bool { - var center1 = arg_center1; - _ = ¢er1; - var radius1 = arg_radius1; - _ = &radius1; - var center2 = arg_center2; - _ = ¢er2; - var radius2 = arg_radius2; - _ = &radius2; - var collision: bool = @as(c_int, 0) != 0; - _ = &collision; - if (Vector3DotProduct(Vector3Subtract(center2, center1), Vector3Subtract(center2, center1)) <= ((radius1 + radius2) * (radius1 + radius2))) { - collision = @as(c_int, 1) != 0; - } - return collision; -} -pub export fn CheckCollisionBoxes(arg_box1: BoundingBox, arg_box2: BoundingBox) bool { - var box1 = arg_box1; - _ = &box1; - var box2 = arg_box2; - _ = &box2; - var collision: bool = @as(c_int, 1) != 0; - _ = &collision; - if ((box1.max.x >= box2.min.x) and (box1.min.x <= box2.max.x)) { - if ((box1.max.y < box2.min.y) or (box1.min.y > box2.max.y)) { - collision = @as(c_int, 0) != 0; - } - if ((box1.max.z < box2.min.z) or (box1.min.z > box2.max.z)) { - collision = @as(c_int, 0) != 0; - } - } else { - collision = @as(c_int, 0) != 0; - } - return collision; -} -pub export fn CheckCollisionBoxSphere(arg_box: BoundingBox, arg_center: Vector3, arg_radius: f32) bool { - var box = arg_box; - _ = &box; - var center = arg_center; - _ = ¢er; - var radius = arg_radius; - _ = &radius; - var collision: bool = @as(c_int, 0) != 0; - _ = &collision; - var dmin: f32 = 0; - _ = &dmin; - if (center.x < box.min.x) { - dmin += powf(center.x - box.min.x, @as(f32, @floatFromInt(@as(c_int, 2)))); - } else if (center.x > box.max.x) { - dmin += powf(center.x - box.max.x, @as(f32, @floatFromInt(@as(c_int, 2)))); - } - if (center.y < box.min.y) { - dmin += powf(center.y - box.min.y, @as(f32, @floatFromInt(@as(c_int, 2)))); - } else if (center.y > box.max.y) { - dmin += powf(center.y - box.max.y, @as(f32, @floatFromInt(@as(c_int, 2)))); - } - if (center.z < box.min.z) { - dmin += powf(center.z - box.min.z, @as(f32, @floatFromInt(@as(c_int, 2)))); - } else if (center.z > box.max.z) { - dmin += powf(center.z - box.max.z, @as(f32, @floatFromInt(@as(c_int, 2)))); - } - if (dmin <= (radius * radius)) { - collision = @as(c_int, 1) != 0; - } - return collision; -} -pub export fn GetRayCollisionSphere(arg_ray: Ray, arg_center: Vector3, arg_radius: f32) RayCollision { - var ray = arg_ray; - _ = &ray; - var center = arg_center; - _ = ¢er; - var radius = arg_radius; - _ = &radius; - var collision: RayCollision = RayCollision{ - .hit = @as(c_int, 0) != 0, - .distance = 0, - .point = @import("std").mem.zeroes(Vector3), - .normal = @import("std").mem.zeroes(Vector3), - }; - _ = &collision; - var raySpherePos: Vector3 = Vector3Subtract(center, ray.position); - _ = &raySpherePos; - var vector: f32 = Vector3DotProduct(raySpherePos, ray.direction); - _ = &vector; - var distance: f32 = Vector3Length(raySpherePos); - _ = &distance; - var d: f32 = (radius * radius) - ((distance * distance) - (vector * vector)); - _ = &d; - collision.hit = d >= 0.0; - if (distance < radius) { - collision.distance = vector + sqrtf(d); - collision.point = Vector3Add(ray.position, Vector3Scale(ray.direction, collision.distance)); - collision.normal = Vector3Negate(Vector3Normalize(Vector3Subtract(collision.point, center))); - } else { - collision.distance = vector - sqrtf(d); - collision.point = Vector3Add(ray.position, Vector3Scale(ray.direction, collision.distance)); - collision.normal = Vector3Normalize(Vector3Subtract(collision.point, center)); - } - return collision; -} -pub export fn GetRayCollisionBox(arg_ray: Ray, arg_box: BoundingBox) RayCollision { - var ray = arg_ray; - _ = &ray; - var box = arg_box; - _ = &box; - var collision: RayCollision = RayCollision{ - .hit = @as(c_int, 0) != 0, - .distance = 0, - .point = @import("std").mem.zeroes(Vector3), - .normal = @import("std").mem.zeroes(Vector3), - }; - _ = &collision; - var insideBox: bool = (((((ray.position.x > box.min.x) and (ray.position.x < box.max.x)) and (ray.position.y > box.min.y)) and (ray.position.y < box.max.y)) and (ray.position.z > box.min.z)) and (ray.position.z < box.max.z); - _ = &insideBox; - if (insideBox) { - ray.direction = Vector3Negate(ray.direction); - } - var t: [11]f32 = [1]f32{ - 0, - } ++ [1]f32{0} ** 10; - _ = &t; - t[@as(c_uint, @intCast(@as(c_int, 8)))] = 1.0 / ray.direction.x; - t[@as(c_uint, @intCast(@as(c_int, 9)))] = 1.0 / ray.direction.y; - t[@as(c_uint, @intCast(@as(c_int, 10)))] = 1.0 / ray.direction.z; - t[@as(c_uint, @intCast(@as(c_int, 0)))] = (box.min.x - ray.position.x) * t[@as(c_uint, @intCast(@as(c_int, 8)))]; - t[@as(c_uint, @intCast(@as(c_int, 1)))] = (box.max.x - ray.position.x) * t[@as(c_uint, @intCast(@as(c_int, 8)))]; - t[@as(c_uint, @intCast(@as(c_int, 2)))] = (box.min.y - ray.position.y) * t[@as(c_uint, @intCast(@as(c_int, 9)))]; - t[@as(c_uint, @intCast(@as(c_int, 3)))] = (box.max.y - ray.position.y) * t[@as(c_uint, @intCast(@as(c_int, 9)))]; - t[@as(c_uint, @intCast(@as(c_int, 4)))] = (box.min.z - ray.position.z) * t[@as(c_uint, @intCast(@as(c_int, 10)))]; - t[@as(c_uint, @intCast(@as(c_int, 5)))] = (box.max.z - ray.position.z) * t[@as(c_uint, @intCast(@as(c_int, 10)))]; - t[@as(c_uint, @intCast(@as(c_int, 6)))] = @as(f32, @floatCast(fmax(fmax(fmin(@as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 1)))]))), fmin(@as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 2)))])), @as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 3)))])))), fmin(@as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 4)))])), @as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 5)))])))))); - t[@as(c_uint, @intCast(@as(c_int, 7)))] = @as(f32, @floatCast(fmin(fmin(fmax(@as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 1)))]))), fmax(@as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 2)))])), @as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 3)))])))), fmax(@as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 4)))])), @as(f64, @floatCast(t[@as(c_uint, @intCast(@as(c_int, 5)))])))))); - collision.hit = !((t[@as(c_uint, @intCast(@as(c_int, 7)))] < @as(f32, @floatFromInt(@as(c_int, 0)))) or (t[@as(c_uint, @intCast(@as(c_int, 6)))] > t[@as(c_uint, @intCast(@as(c_int, 7)))])); - collision.distance = t[@as(c_uint, @intCast(@as(c_int, 6)))]; - collision.point = Vector3Add(ray.position, Vector3Scale(ray.direction, collision.distance)); - collision.normal = Vector3Lerp(box.min, box.max, 0.5); - collision.normal = Vector3Subtract(collision.point, collision.normal); - collision.normal = Vector3Scale(collision.normal, 2.009999990463257); - collision.normal = Vector3Divide(collision.normal, Vector3Subtract(box.max, box.min)); - collision.normal.x = @as(f32, @floatFromInt(@as(c_int, @intFromFloat(collision.normal.x)))); - collision.normal.y = @as(f32, @floatFromInt(@as(c_int, @intFromFloat(collision.normal.y)))); - collision.normal.z = @as(f32, @floatFromInt(@as(c_int, @intFromFloat(collision.normal.z)))); - collision.normal = Vector3Normalize(collision.normal); - if (insideBox) { - ray.direction = Vector3Negate(ray.direction); - collision.distance *= -1.0; - collision.normal = Vector3Negate(collision.normal); - } - return collision; -} -pub export fn GetRayCollisionMesh(arg_ray: Ray, arg_mesh: Mesh, arg_transform: Matrix) RayCollision { - var ray = arg_ray; - _ = &ray; - var mesh = arg_mesh; - _ = &mesh; - var transform = arg_transform; - _ = &transform; - var collision: RayCollision = RayCollision{ - .hit = @as(c_int, 0) != 0, - .distance = 0, - .point = @import("std").mem.zeroes(Vector3), - .normal = @import("std").mem.zeroes(Vector3), - }; - _ = &collision; - if (mesh.vertices != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - var triangleCount: c_int = mesh.triangleCount; - _ = &triangleCount; - { - var i: c_int = 0; - _ = &i; - while (i < triangleCount) : (i += 1) { - var a: Vector3 = undefined; - _ = &a; - var b: Vector3 = undefined; - _ = &b; - var c: Vector3 = undefined; - _ = &c; - var vertdata: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(mesh.vertices))); - _ = &vertdata; - if (mesh.indices != null) { - a = vertdata[(blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*]; - b = vertdata[(blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*]; - c = vertdata[(blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk mesh.indices + @as(usize, @intCast(tmp)) else break :blk mesh.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*]; - } else { - a = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk vertdata + @as(usize, @intCast(tmp)) else break :blk vertdata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - b = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk vertdata + @as(usize, @intCast(tmp)) else break :blk vertdata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - c = (blk: { - const tmp = (i * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk vertdata + @as(usize, @intCast(tmp)) else break :blk vertdata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - a = Vector3Transform(a, transform); - b = Vector3Transform(b, transform); - c = Vector3Transform(c, transform); - var triHitInfo: RayCollision = GetRayCollisionTriangle(ray, a, b, c); - _ = &triHitInfo; - if (triHitInfo.hit) { - if (!collision.hit or (collision.distance > triHitInfo.distance)) { - collision = triHitInfo; - } - } - } - } - } - return collision; -} -pub export fn GetRayCollisionTriangle(arg_ray: Ray, arg_p1: Vector3, arg_p2: Vector3, arg_p3: Vector3) RayCollision { - var ray = arg_ray; - _ = &ray; - var p1 = arg_p1; - _ = &p1; - var p2 = arg_p2; - _ = &p2; - var p3 = arg_p3; - _ = &p3; - var collision: RayCollision = RayCollision{ - .hit = @as(c_int, 0) != 0, - .distance = 0, - .point = @import("std").mem.zeroes(Vector3), - .normal = @import("std").mem.zeroes(Vector3), - }; - _ = &collision; - var edge1: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &edge1; - var edge2: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &edge2; - var p: Vector3 = undefined; - _ = &p; - var q: Vector3 = undefined; - _ = &q; - var tv: Vector3 = undefined; - _ = &tv; - var det: f32 = undefined; - _ = &det; - var invDet: f32 = undefined; - _ = &invDet; - var u: f32 = undefined; - _ = &u; - var v: f32 = undefined; - _ = &v; - var t: f32 = undefined; - _ = &t; - edge1 = Vector3Subtract(p2, p1); - edge2 = Vector3Subtract(p3, p1); - p = Vector3CrossProduct(ray.direction, edge2); - det = Vector3DotProduct(edge1, p); - if ((det > -0.0000009999999974752427) and (det < 0.0000009999999974752427)) return collision; - invDet = 1.0 / det; - tv = Vector3Subtract(ray.position, p1); - u = Vector3DotProduct(tv, p) * invDet; - if ((u < 0.0) or (u > 1.0)) return collision; - q = Vector3CrossProduct(tv, edge1); - v = Vector3DotProduct(ray.direction, q) * invDet; - if ((v < 0.0) or ((u + v) > 1.0)) return collision; - t = Vector3DotProduct(edge2, q) * invDet; - if (t > 0.0000009999999974752427) { - collision.hit = @as(c_int, 1) != 0; - collision.distance = t; - collision.normal = Vector3Normalize(Vector3CrossProduct(edge1, edge2)); - collision.point = Vector3Add(ray.position, Vector3Scale(ray.direction, t)); - } - return collision; -} -pub export fn GetRayCollisionQuad(arg_ray: Ray, arg_p1: Vector3, arg_p2: Vector3, arg_p3: Vector3, arg_p4: Vector3) RayCollision { - var ray = arg_ray; - _ = &ray; - var p1 = arg_p1; - _ = &p1; - var p2 = arg_p2; - _ = &p2; - var p3 = arg_p3; - _ = &p3; - var p4 = arg_p4; - _ = &p4; - var collision: RayCollision = RayCollision{ - .hit = @as(c_int, 0) != 0, - .distance = 0, - .point = @import("std").mem.zeroes(Vector3), - .normal = @import("std").mem.zeroes(Vector3), - }; - _ = &collision; - collision = GetRayCollisionTriangle(ray, p1, p2, p4); - if (!collision.hit) { - collision = GetRayCollisionTriangle(ray, p2, p3, p4); - } - return collision; -} -pub const AudioCallback = ?*const fn (?*anyopaque, c_uint) callconv(.C) void; -pub extern fn InitAudioDevice() void; -pub extern fn CloseAudioDevice() void; -pub extern fn IsAudioDeviceReady() bool; -pub extern fn SetMasterVolume(volume: f32) void; -pub extern fn GetMasterVolume() f32; -pub extern fn LoadWave(fileName: [*c]const u8) Wave; -pub extern fn LoadWaveFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) Wave; -pub extern fn IsWaveReady(wave: Wave) bool; -pub extern fn LoadSound(fileName: [*c]const u8) Sound; -pub extern fn LoadSoundFromWave(wave: Wave) Sound; -pub extern fn LoadSoundAlias(source: Sound) Sound; -pub extern fn IsSoundReady(sound: Sound) bool; -pub extern fn UpdateSound(sound: Sound, data: ?*const anyopaque, sampleCount: c_int) void; -pub extern fn UnloadWave(wave: Wave) void; -pub extern fn UnloadSound(sound: Sound) void; -pub extern fn UnloadSoundAlias(alias: Sound) void; -pub extern fn ExportWave(wave: Wave, fileName: [*c]const u8) bool; -pub extern fn ExportWaveAsCode(wave: Wave, fileName: [*c]const u8) bool; -pub extern fn PlaySound(sound: Sound) void; -pub extern fn StopSound(sound: Sound) void; -pub extern fn PauseSound(sound: Sound) void; -pub extern fn ResumeSound(sound: Sound) void; -pub extern fn IsSoundPlaying(sound: Sound) bool; -pub extern fn SetSoundVolume(sound: Sound, volume: f32) void; -pub extern fn SetSoundPitch(sound: Sound, pitch: f32) void; -pub extern fn SetSoundPan(sound: Sound, pan: f32) void; -pub extern fn WaveCopy(wave: Wave) Wave; -pub extern fn WaveCrop(wave: [*c]Wave, initFrame: c_int, finalFrame: c_int) void; -pub extern fn WaveFormat(wave: [*c]Wave, sampleRate: c_int, sampleSize: c_int, channels: c_int) void; -pub extern fn LoadWaveSamples(wave: Wave) [*c]f32; -pub extern fn UnloadWaveSamples(samples: [*c]f32) void; -pub extern fn LoadMusicStream(fileName: [*c]const u8) Music; -pub extern fn LoadMusicStreamFromMemory(fileType: [*c]const u8, data: [*c]const u8, dataSize: c_int) Music; -pub extern fn IsMusicReady(music: Music) bool; -pub extern fn UnloadMusicStream(music: Music) void; -pub extern fn PlayMusicStream(music: Music) void; -pub extern fn IsMusicStreamPlaying(music: Music) bool; -pub extern fn UpdateMusicStream(music: Music) void; -pub extern fn StopMusicStream(music: Music) void; -pub extern fn PauseMusicStream(music: Music) void; -pub extern fn ResumeMusicStream(music: Music) void; -pub extern fn SeekMusicStream(music: Music, position: f32) void; -pub extern fn SetMusicVolume(music: Music, volume: f32) void; -pub extern fn SetMusicPitch(music: Music, pitch: f32) void; -pub extern fn SetMusicPan(music: Music, pan: f32) void; -pub extern fn GetMusicTimeLength(music: Music) f32; -pub extern fn GetMusicTimePlayed(music: Music) f32; -pub extern fn LoadAudioStream(sampleRate: c_uint, sampleSize: c_uint, channels: c_uint) AudioStream; -pub extern fn IsAudioStreamReady(stream: AudioStream) bool; -pub extern fn UnloadAudioStream(stream: AudioStream) void; -pub extern fn UpdateAudioStream(stream: AudioStream, data: ?*const anyopaque, frameCount: c_int) void; -pub extern fn IsAudioStreamProcessed(stream: AudioStream) bool; -pub extern fn PlayAudioStream(stream: AudioStream) void; -pub extern fn PauseAudioStream(stream: AudioStream) void; -pub extern fn ResumeAudioStream(stream: AudioStream) void; -pub extern fn IsAudioStreamPlaying(stream: AudioStream) bool; -pub extern fn StopAudioStream(stream: AudioStream) void; -pub extern fn SetAudioStreamVolume(stream: AudioStream, volume: f32) void; -pub extern fn SetAudioStreamPitch(stream: AudioStream, pitch: f32) void; -pub extern fn SetAudioStreamPan(stream: AudioStream, pan: f32) void; -pub extern fn SetAudioStreamBufferSizeDefault(size: c_int) void; -pub extern fn SetAudioStreamCallback(stream: AudioStream, callback: AudioCallback) void; -pub extern fn AttachAudioStreamProcessor(stream: AudioStream, processor: AudioCallback) void; -pub extern fn DetachAudioStreamProcessor(stream: AudioStream, processor: AudioCallback) void; -pub extern fn AttachAudioMixedProcessor(processor: AudioCallback) void; -pub extern fn DetachAudioMixedProcessor(processor: AudioCallback) void; -pub const struct_rlVertexBuffer = extern struct { - elementCount: c_int = @import("std").mem.zeroes(c_int), - vertices: [*c]f32 = @import("std").mem.zeroes([*c]f32), - texcoords: [*c]f32 = @import("std").mem.zeroes([*c]f32), - normals: [*c]f32 = @import("std").mem.zeroes([*c]f32), - colors: [*c]u8 = @import("std").mem.zeroes([*c]u8), - indices: [*c]c_uint = @import("std").mem.zeroes([*c]c_uint), - vaoId: c_uint = @import("std").mem.zeroes(c_uint), - vboId: [5]c_uint = @import("std").mem.zeroes([5]c_uint), -}; -pub const rlVertexBuffer = struct_rlVertexBuffer; -pub const struct_rlDrawCall = extern struct { - mode: c_int = @import("std").mem.zeroes(c_int), - vertexCount: c_int = @import("std").mem.zeroes(c_int), - vertexAlignment: c_int = @import("std").mem.zeroes(c_int), - textureId: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub const rlDrawCall = struct_rlDrawCall; -pub const struct_rlRenderBatch = extern struct { - bufferCount: c_int = @import("std").mem.zeroes(c_int), - currentBuffer: c_int = @import("std").mem.zeroes(c_int), - vertexBuffer: [*c]rlVertexBuffer = @import("std").mem.zeroes([*c]rlVertexBuffer), - draws: [*c]rlDrawCall = @import("std").mem.zeroes([*c]rlDrawCall), - drawCounter: c_int = @import("std").mem.zeroes(c_int), - currentDepth: f32 = @import("std").mem.zeroes(f32), -}; -pub const rlRenderBatch = struct_rlRenderBatch; -pub const RL_OPENGL_11: c_int = 1; -pub const RL_OPENGL_21: c_int = 2; -pub const RL_OPENGL_33: c_int = 3; -pub const RL_OPENGL_43: c_int = 4; -pub const RL_OPENGL_ES_20: c_int = 5; -pub const RL_OPENGL_ES_30: c_int = 6; -pub const rlGlVersion = c_uint; -pub const RL_LOG_ALL: c_int = 0; -pub const RL_LOG_TRACE: c_int = 1; -pub const RL_LOG_DEBUG: c_int = 2; -pub const RL_LOG_INFO: c_int = 3; -pub const RL_LOG_WARNING: c_int = 4; -pub const RL_LOG_ERROR: c_int = 5; -pub const RL_LOG_FATAL: c_int = 6; -pub const RL_LOG_NONE: c_int = 7; -pub const rlTraceLogLevel = c_uint; -pub const RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: c_int = 1; -pub const RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: c_int = 2; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: c_int = 3; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: c_int = 4; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: c_int = 5; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: c_int = 6; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: c_int = 7; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R32: c_int = 8; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: c_int = 9; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: c_int = 10; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R16: c_int = 11; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: c_int = 12; -pub const RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: c_int = 13; -pub const RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: c_int = 14; -pub const RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: c_int = 15; -pub const RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: c_int = 16; -pub const RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA: c_int = 17; -pub const RL_PIXELFORMAT_COMPRESSED_ETC1_RGB: c_int = 18; -pub const RL_PIXELFORMAT_COMPRESSED_ETC2_RGB: c_int = 19; -pub const RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA: c_int = 20; -pub const RL_PIXELFORMAT_COMPRESSED_PVRT_RGB: c_int = 21; -pub const RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: c_int = 22; -pub const RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: c_int = 23; -pub const RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: c_int = 24; -pub const rlPixelFormat = c_uint; -pub const RL_TEXTURE_FILTER_POINT: c_int = 0; -pub const RL_TEXTURE_FILTER_BILINEAR: c_int = 1; -pub const RL_TEXTURE_FILTER_TRILINEAR: c_int = 2; -pub const RL_TEXTURE_FILTER_ANISOTROPIC_4X: c_int = 3; -pub const RL_TEXTURE_FILTER_ANISOTROPIC_8X: c_int = 4; -pub const RL_TEXTURE_FILTER_ANISOTROPIC_16X: c_int = 5; -pub const rlTextureFilter = c_uint; -pub const RL_BLEND_ALPHA: c_int = 0; -pub const RL_BLEND_ADDITIVE: c_int = 1; -pub const RL_BLEND_MULTIPLIED: c_int = 2; -pub const RL_BLEND_ADD_COLORS: c_int = 3; -pub const RL_BLEND_SUBTRACT_COLORS: c_int = 4; -pub const RL_BLEND_ALPHA_PREMULTIPLY: c_int = 5; -pub const RL_BLEND_CUSTOM: c_int = 6; -pub const RL_BLEND_CUSTOM_SEPARATE: c_int = 7; -pub const rlBlendMode = c_uint; -pub const RL_SHADER_LOC_VERTEX_POSITION: c_int = 0; -pub const RL_SHADER_LOC_VERTEX_TEXCOORD01: c_int = 1; -pub const RL_SHADER_LOC_VERTEX_TEXCOORD02: c_int = 2; -pub const RL_SHADER_LOC_VERTEX_NORMAL: c_int = 3; -pub const RL_SHADER_LOC_VERTEX_TANGENT: c_int = 4; -pub const RL_SHADER_LOC_VERTEX_COLOR: c_int = 5; -pub const RL_SHADER_LOC_MATRIX_MVP: c_int = 6; -pub const RL_SHADER_LOC_MATRIX_VIEW: c_int = 7; -pub const RL_SHADER_LOC_MATRIX_PROJECTION: c_int = 8; -pub const RL_SHADER_LOC_MATRIX_MODEL: c_int = 9; -pub const RL_SHADER_LOC_MATRIX_NORMAL: c_int = 10; -pub const RL_SHADER_LOC_VECTOR_VIEW: c_int = 11; -pub const RL_SHADER_LOC_COLOR_DIFFUSE: c_int = 12; -pub const RL_SHADER_LOC_COLOR_SPECULAR: c_int = 13; -pub const RL_SHADER_LOC_COLOR_AMBIENT: c_int = 14; -pub const RL_SHADER_LOC_MAP_ALBEDO: c_int = 15; -pub const RL_SHADER_LOC_MAP_METALNESS: c_int = 16; -pub const RL_SHADER_LOC_MAP_NORMAL: c_int = 17; -pub const RL_SHADER_LOC_MAP_ROUGHNESS: c_int = 18; -pub const RL_SHADER_LOC_MAP_OCCLUSION: c_int = 19; -pub const RL_SHADER_LOC_MAP_EMISSION: c_int = 20; -pub const RL_SHADER_LOC_MAP_HEIGHT: c_int = 21; -pub const RL_SHADER_LOC_MAP_CUBEMAP: c_int = 22; -pub const RL_SHADER_LOC_MAP_IRRADIANCE: c_int = 23; -pub const RL_SHADER_LOC_MAP_PREFILTER: c_int = 24; -pub const RL_SHADER_LOC_MAP_BRDF: c_int = 25; -pub const rlShaderLocationIndex = c_uint; -pub const RL_SHADER_UNIFORM_FLOAT: c_int = 0; -pub const RL_SHADER_UNIFORM_VEC2: c_int = 1; -pub const RL_SHADER_UNIFORM_VEC3: c_int = 2; -pub const RL_SHADER_UNIFORM_VEC4: c_int = 3; -pub const RL_SHADER_UNIFORM_INT: c_int = 4; -pub const RL_SHADER_UNIFORM_IVEC2: c_int = 5; -pub const RL_SHADER_UNIFORM_IVEC3: c_int = 6; -pub const RL_SHADER_UNIFORM_IVEC4: c_int = 7; -pub const RL_SHADER_UNIFORM_UINT: c_int = 8; -pub const RL_SHADER_UNIFORM_UIVEC2: c_int = 9; -pub const RL_SHADER_UNIFORM_UIVEC3: c_int = 10; -pub const RL_SHADER_UNIFORM_UIVEC4: c_int = 11; -pub const RL_SHADER_UNIFORM_SAMPLER2D: c_int = 12; -pub const rlShaderUniformDataType = c_uint; -pub const RL_SHADER_ATTRIB_FLOAT: c_int = 0; -pub const RL_SHADER_ATTRIB_VEC2: c_int = 1; -pub const RL_SHADER_ATTRIB_VEC3: c_int = 2; -pub const RL_SHADER_ATTRIB_VEC4: c_int = 3; -pub const rlShaderAttributeDataType = c_uint; -pub const RL_ATTACHMENT_COLOR_CHANNEL0: c_int = 0; -pub const RL_ATTACHMENT_COLOR_CHANNEL1: c_int = 1; -pub const RL_ATTACHMENT_COLOR_CHANNEL2: c_int = 2; -pub const RL_ATTACHMENT_COLOR_CHANNEL3: c_int = 3; -pub const RL_ATTACHMENT_COLOR_CHANNEL4: c_int = 4; -pub const RL_ATTACHMENT_COLOR_CHANNEL5: c_int = 5; -pub const RL_ATTACHMENT_COLOR_CHANNEL6: c_int = 6; -pub const RL_ATTACHMENT_COLOR_CHANNEL7: c_int = 7; -pub const RL_ATTACHMENT_DEPTH: c_int = 100; -pub const RL_ATTACHMENT_STENCIL: c_int = 200; -pub const rlFramebufferAttachType = c_uint; -pub const RL_ATTACHMENT_CUBEMAP_POSITIVE_X: c_int = 0; -pub const RL_ATTACHMENT_CUBEMAP_NEGATIVE_X: c_int = 1; -pub const RL_ATTACHMENT_CUBEMAP_POSITIVE_Y: c_int = 2; -pub const RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y: c_int = 3; -pub const RL_ATTACHMENT_CUBEMAP_POSITIVE_Z: c_int = 4; -pub const RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z: c_int = 5; -pub const RL_ATTACHMENT_TEXTURE2D: c_int = 100; -pub const RL_ATTACHMENT_RENDERBUFFER: c_int = 200; -pub const rlFramebufferAttachTextureType = c_uint; -pub const RL_CULL_FACE_FRONT: c_int = 0; -pub const RL_CULL_FACE_BACK: c_int = 1; -pub const rlCullMode = c_uint; -pub extern fn rlMatrixMode(mode: c_int) void; -pub extern fn rlPushMatrix() void; -pub extern fn rlPopMatrix() void; -pub extern fn rlLoadIdentity() void; -pub extern fn rlTranslatef(x: f32, y: f32, z: f32) void; -pub extern fn rlRotatef(angle: f32, x: f32, y: f32, z: f32) void; -pub extern fn rlScalef(x: f32, y: f32, z: f32) void; -pub extern fn rlMultMatrixf(matf: [*c]const f32) void; -pub extern fn rlFrustum(left: f64, right: f64, bottom: f64, top: f64, znear: f64, zfar: f64) void; -pub extern fn rlOrtho(left: f64, right: f64, bottom: f64, top: f64, znear: f64, zfar: f64) void; -pub extern fn rlViewport(x: c_int, y: c_int, width: c_int, height: c_int) void; -pub extern fn rlSetClipPlanes(nearPlane: f64, farPlane: f64) void; -pub extern fn rlGetCullDistanceNear() f64; -pub extern fn rlGetCullDistanceFar() f64; -pub extern fn rlBegin(mode: c_int) void; -pub extern fn rlEnd() void; -pub extern fn rlVertex2i(x: c_int, y: c_int) void; -pub extern fn rlVertex2f(x: f32, y: f32) void; -pub extern fn rlVertex3f(x: f32, y: f32, z: f32) void; -pub extern fn rlTexCoord2f(x: f32, y: f32) void; -pub extern fn rlNormal3f(x: f32, y: f32, z: f32) void; -pub extern fn rlColor4ub(r: u8, g: u8, b: u8, a: u8) void; -pub extern fn rlColor3f(x: f32, y: f32, z: f32) void; -pub extern fn rlColor4f(x: f32, y: f32, z: f32, w: f32) void; -pub extern fn rlEnableVertexArray(vaoId: c_uint) bool; -pub extern fn rlDisableVertexArray() void; -pub extern fn rlEnableVertexBuffer(id: c_uint) void; -pub extern fn rlDisableVertexBuffer() void; -pub extern fn rlEnableVertexBufferElement(id: c_uint) void; -pub extern fn rlDisableVertexBufferElement() void; -pub extern fn rlEnableVertexAttribute(index: c_uint) void; -pub extern fn rlDisableVertexAttribute(index: c_uint) void; -pub extern fn rlActiveTextureSlot(slot: c_int) void; -pub extern fn rlEnableTexture(id: c_uint) void; -pub extern fn rlDisableTexture() void; -pub extern fn rlEnableTextureCubemap(id: c_uint) void; -pub extern fn rlDisableTextureCubemap() void; -pub extern fn rlTextureParameters(id: c_uint, param: c_int, value: c_int) void; -pub extern fn rlCubemapParameters(id: c_uint, param: c_int, value: c_int) void; -pub extern fn rlEnableShader(id: c_uint) void; -pub extern fn rlDisableShader() void; -pub extern fn rlEnableFramebuffer(id: c_uint) void; -pub extern fn rlDisableFramebuffer() void; -pub extern fn rlGetActiveFramebuffer() c_uint; -pub extern fn rlActiveDrawBuffers(count: c_int) void; -pub extern fn rlBlitFramebuffer(srcX: c_int, srcY: c_int, srcWidth: c_int, srcHeight: c_int, dstX: c_int, dstY: c_int, dstWidth: c_int, dstHeight: c_int, bufferMask: c_int) void; -pub extern fn rlBindFramebuffer(target: c_uint, framebuffer: c_uint) void; -pub extern fn rlEnableColorBlend() void; -pub extern fn rlDisableColorBlend() void; -pub extern fn rlEnableDepthTest() void; -pub extern fn rlDisableDepthTest() void; -pub extern fn rlEnableDepthMask() void; -pub extern fn rlDisableDepthMask() void; -pub extern fn rlEnableBackfaceCulling() void; -pub extern fn rlDisableBackfaceCulling() void; -pub extern fn rlColorMask(r: bool, g: bool, b: bool, a: bool) void; -pub extern fn rlSetCullFace(mode: c_int) void; -pub extern fn rlEnableScissorTest() void; -pub extern fn rlDisableScissorTest() void; -pub extern fn rlScissor(x: c_int, y: c_int, width: c_int, height: c_int) void; -pub extern fn rlEnableWireMode() void; -pub extern fn rlEnablePointMode() void; -pub extern fn rlDisableWireMode() void; -pub extern fn rlSetLineWidth(width: f32) void; -pub extern fn rlGetLineWidth() f32; -pub extern fn rlEnableSmoothLines() void; -pub extern fn rlDisableSmoothLines() void; -pub extern fn rlEnableStereoRender() void; -pub extern fn rlDisableStereoRender() void; -pub extern fn rlIsStereoRenderEnabled() bool; -pub extern fn rlClearColor(r: u8, g: u8, b: u8, a: u8) void; -pub extern fn rlClearScreenBuffers() void; -pub extern fn rlCheckErrors() void; -pub extern fn rlSetBlendMode(mode: c_int) void; -pub extern fn rlSetBlendFactors(glSrcFactor: c_int, glDstFactor: c_int, glEquation: c_int) void; -pub extern fn rlSetBlendFactorsSeparate(glSrcRGB: c_int, glDstRGB: c_int, glSrcAlpha: c_int, glDstAlpha: c_int, glEqRGB: c_int, glEqAlpha: c_int) void; -pub extern fn rlglInit(width: c_int, height: c_int) void; -pub extern fn rlglClose() void; -pub extern fn rlLoadExtensions(loader: ?*anyopaque) void; -pub extern fn rlGetVersion() c_int; -pub extern fn rlSetFramebufferWidth(width: c_int) void; -pub extern fn rlGetFramebufferWidth() c_int; -pub extern fn rlSetFramebufferHeight(height: c_int) void; -pub extern fn rlGetFramebufferHeight() c_int; -pub extern fn rlGetTextureIdDefault() c_uint; -pub extern fn rlGetShaderIdDefault() c_uint; -pub extern fn rlGetShaderLocsDefault() [*c]c_int; -pub extern fn rlLoadRenderBatch(numBuffers: c_int, bufferElements: c_int) rlRenderBatch; -pub extern fn rlUnloadRenderBatch(batch: rlRenderBatch) void; -pub extern fn rlDrawRenderBatch(batch: [*c]rlRenderBatch) void; -pub extern fn rlSetRenderBatchActive(batch: [*c]rlRenderBatch) void; -pub extern fn rlDrawRenderBatchActive() void; -pub extern fn rlCheckRenderBatchLimit(vCount: c_int) bool; -pub extern fn rlSetTexture(id: c_uint) void; -pub extern fn rlLoadVertexArray() c_uint; -pub extern fn rlLoadVertexBuffer(buffer: ?*const anyopaque, size: c_int, dynamic: bool) c_uint; -pub extern fn rlLoadVertexBufferElement(buffer: ?*const anyopaque, size: c_int, dynamic: bool) c_uint; -pub extern fn rlUpdateVertexBuffer(bufferId: c_uint, data: ?*const anyopaque, dataSize: c_int, offset: c_int) void; -pub extern fn rlUpdateVertexBufferElements(id: c_uint, data: ?*const anyopaque, dataSize: c_int, offset: c_int) void; -pub extern fn rlUnloadVertexArray(vaoId: c_uint) void; -pub extern fn rlUnloadVertexBuffer(vboId: c_uint) void; -pub extern fn rlSetVertexAttribute(index: c_uint, compSize: c_int, @"type": c_int, normalized: bool, stride: c_int, offset: c_int) void; -pub extern fn rlSetVertexAttributeDivisor(index: c_uint, divisor: c_int) void; -pub extern fn rlSetVertexAttributeDefault(locIndex: c_int, value: ?*const anyopaque, attribType: c_int, count: c_int) void; -pub extern fn rlDrawVertexArray(offset: c_int, count: c_int) void; -pub extern fn rlDrawVertexArrayElements(offset: c_int, count: c_int, buffer: ?*const anyopaque) void; -pub extern fn rlDrawVertexArrayInstanced(offset: c_int, count: c_int, instances: c_int) void; -pub extern fn rlDrawVertexArrayElementsInstanced(offset: c_int, count: c_int, buffer: ?*const anyopaque, instances: c_int) void; -pub extern fn rlLoadTexture(data: ?*const anyopaque, width: c_int, height: c_int, format: c_int, mipmapCount: c_int) c_uint; -pub extern fn rlLoadTextureDepth(width: c_int, height: c_int, useRenderBuffer: bool) c_uint; -pub extern fn rlLoadTextureCubemap(data: ?*const anyopaque, size: c_int, format: c_int) c_uint; -pub extern fn rlUpdateTexture(id: c_uint, offsetX: c_int, offsetY: c_int, width: c_int, height: c_int, format: c_int, data: ?*const anyopaque) void; -pub extern fn rlGetGlTextureFormats(format: c_int, glInternalFormat: [*c]c_uint, glFormat: [*c]c_uint, glType: [*c]c_uint) void; -pub extern fn rlGetPixelFormatName(format: c_uint) [*c]const u8; -pub extern fn rlUnloadTexture(id: c_uint) void; -pub extern fn rlGenTextureMipmaps(id: c_uint, width: c_int, height: c_int, format: c_int, mipmaps: [*c]c_int) void; -pub extern fn rlReadTexturePixels(id: c_uint, width: c_int, height: c_int, format: c_int) ?*anyopaque; -pub extern fn rlReadScreenPixels(width: c_int, height: c_int) [*c]u8; -pub extern fn rlLoadFramebuffer() c_uint; -pub extern fn rlFramebufferAttach(fboId: c_uint, texId: c_uint, attachType: c_int, texType: c_int, mipLevel: c_int) void; -pub extern fn rlFramebufferComplete(id: c_uint) bool; -pub extern fn rlUnloadFramebuffer(id: c_uint) void; -pub extern fn rlLoadShaderCode(vsCode: [*c]const u8, fsCode: [*c]const u8) c_uint; -pub extern fn rlCompileShader(shaderCode: [*c]const u8, @"type": c_int) c_uint; -pub extern fn rlLoadShaderProgram(vShaderId: c_uint, fShaderId: c_uint) c_uint; -pub extern fn rlUnloadShaderProgram(id: c_uint) void; -pub extern fn rlGetLocationUniform(shaderId: c_uint, uniformName: [*c]const u8) c_int; -pub extern fn rlGetLocationAttrib(shaderId: c_uint, attribName: [*c]const u8) c_int; -pub extern fn rlSetUniform(locIndex: c_int, value: ?*const anyopaque, uniformType: c_int, count: c_int) void; -pub extern fn rlSetUniformMatrix(locIndex: c_int, mat: Matrix) void; -pub extern fn rlSetUniformSampler(locIndex: c_int, textureId: c_uint) void; -pub extern fn rlSetShader(id: c_uint, locs: [*c]c_int) void; -pub extern fn rlLoadComputeShaderProgram(shaderId: c_uint) c_uint; -pub extern fn rlComputeShaderDispatch(groupX: c_uint, groupY: c_uint, groupZ: c_uint) void; -pub extern fn rlLoadShaderBuffer(size: c_uint, data: ?*const anyopaque, usageHint: c_int) c_uint; -pub extern fn rlUnloadShaderBuffer(ssboId: c_uint) void; -pub extern fn rlUpdateShaderBuffer(id: c_uint, data: ?*const anyopaque, dataSize: c_uint, offset: c_uint) void; -pub extern fn rlBindShaderBuffer(id: c_uint, index: c_uint) void; -pub extern fn rlReadShaderBuffer(id: c_uint, dest: ?*anyopaque, count: c_uint, offset: c_uint) void; -pub extern fn rlCopyShaderBuffer(destId: c_uint, srcId: c_uint, destOffset: c_uint, srcOffset: c_uint, count: c_uint) void; -pub extern fn rlGetShaderBufferSize(id: c_uint) c_uint; -pub extern fn rlBindImageTexture(id: c_uint, index: c_uint, format: c_int, readonly: bool) void; -pub extern fn rlGetMatrixModelview() Matrix; -pub extern fn rlGetMatrixProjection() Matrix; -pub extern fn rlGetMatrixTransform() Matrix; -pub extern fn rlGetMatrixProjectionStereo(eye: c_int) Matrix; -pub extern fn rlGetMatrixViewOffsetStereo(eye: c_int) Matrix; -pub extern fn rlSetMatrixProjection(proj: Matrix) void; -pub extern fn rlSetMatrixModelview(view: Matrix) void; -pub extern fn rlSetMatrixProjectionStereo(right: Matrix, left: Matrix) void; -pub extern fn rlSetMatrixViewOffsetStereo(right: Matrix, left: Matrix) void; -pub extern fn rlLoadDrawCube() void; -pub extern fn rlLoadDrawQuad() void; -pub const struct_float3 = extern struct { - v: [3]f32 = @import("std").mem.zeroes([3]f32), -}; -pub const float3 = struct_float3; -pub const __u_char = u8; -pub const __u_short = c_ushort; -pub const __u_int = c_uint; -pub const __u_long = c_ulong; -pub const __int8_t = i8; -pub const __uint8_t = u8; -pub const __int16_t = c_short; -pub const __uint16_t = c_ushort; -pub const __int32_t = c_int; -pub const __uint32_t = c_uint; -pub const __int64_t = c_long; -pub const __uint64_t = c_ulong; -pub const __int_least8_t = __int8_t; -pub const __uint_least8_t = __uint8_t; -pub const __int_least16_t = __int16_t; -pub const __uint_least16_t = __uint16_t; -pub const __int_least32_t = __int32_t; -pub const __uint_least32_t = __uint32_t; -pub const __int_least64_t = __int64_t; -pub const __uint_least64_t = __uint64_t; -pub const __quad_t = c_long; -pub const __u_quad_t = c_ulong; -pub const __intmax_t = c_long; -pub const __uintmax_t = c_ulong; -pub const __dev_t = c_ulong; -pub const __uid_t = c_uint; -pub const __gid_t = c_uint; -pub const __ino_t = c_ulong; -pub const __ino64_t = c_ulong; -pub const __mode_t = c_uint; -pub const __nlink_t = c_ulong; -pub const __off_t = c_long; -pub const __off64_t = c_long; -pub const __pid_t = c_int; -pub const __fsid_t = extern struct { - __val: [2]c_int = @import("std").mem.zeroes([2]c_int), -}; -pub const __clock_t = c_long; -pub const __rlim_t = c_ulong; -pub const __rlim64_t = c_ulong; -pub const __id_t = c_uint; -pub const __time_t = c_long; -pub const __useconds_t = c_uint; -pub const __suseconds_t = c_long; -pub const __suseconds64_t = c_long; -pub const __daddr_t = c_int; -pub const __key_t = c_int; -pub const __clockid_t = c_int; -pub const __timer_t = ?*anyopaque; -pub const __blksize_t = c_long; -pub const __blkcnt_t = c_long; -pub const __blkcnt64_t = c_long; -pub const __fsblkcnt_t = c_ulong; -pub const __fsblkcnt64_t = c_ulong; -pub const __fsfilcnt_t = c_ulong; -pub const __fsfilcnt64_t = c_ulong; -pub const __fsword_t = c_long; -pub const __ssize_t = c_long; -pub const __syscall_slong_t = c_long; -pub const __syscall_ulong_t = c_ulong; -pub const __loff_t = __off64_t; -pub const __caddr_t = [*c]u8; -pub const __intptr_t = c_long; -pub const __socklen_t = c_uint; -pub const __sig_atomic_t = c_int; -pub const _Float32 = f32; -pub const _Float64 = f64; -pub const _Float32x = f64; -pub const _Float64x = c_longdouble; -pub const float_t = f32; -pub const double_t = f64; -pub extern fn __fpclassify(__value: f64) c_int; -pub extern fn __signbit(__value: f64) c_int; -pub extern fn __isinf(__value: f64) c_int; -pub extern fn __finite(__value: f64) c_int; -pub extern fn __isnan(__value: f64) c_int; -pub extern fn __iseqsig(__x: f64, __y: f64) c_int; -pub extern fn __issignaling(__value: f64) c_int; -pub extern fn acos(__x: f64) f64; -pub extern fn __acos(__x: f64) f64; -pub extern fn asin(__x: f64) f64; -pub extern fn __asin(__x: f64) f64; -pub extern fn atan(__x: f64) f64; -pub extern fn __atan(__x: f64) f64; -pub extern fn atan2(__y: f64, __x: f64) f64; -pub extern fn __atan2(__y: f64, __x: f64) f64; -pub extern fn cos(__x: f64) f64; -pub extern fn __cos(__x: f64) f64; -pub extern fn sin(__x: f64) f64; -pub extern fn __sin(__x: f64) f64; -pub extern fn tan(__x: f64) f64; -pub extern fn __tan(__x: f64) f64; -pub extern fn cosh(__x: f64) f64; -pub extern fn __cosh(__x: f64) f64; -pub extern fn sinh(__x: f64) f64; -pub extern fn __sinh(__x: f64) f64; -pub extern fn tanh(__x: f64) f64; -pub extern fn __tanh(__x: f64) f64; -pub extern fn acosh(__x: f64) f64; -pub extern fn __acosh(__x: f64) f64; -pub extern fn asinh(__x: f64) f64; -pub extern fn __asinh(__x: f64) f64; -pub extern fn atanh(__x: f64) f64; -pub extern fn __atanh(__x: f64) f64; -pub extern fn exp(__x: f64) f64; -pub extern fn __exp(__x: f64) f64; -pub extern fn frexp(__x: f64, __exponent: [*c]c_int) f64; -pub extern fn __frexp(__x: f64, __exponent: [*c]c_int) f64; -pub extern fn ldexp(__x: f64, __exponent: c_int) f64; -pub extern fn __ldexp(__x: f64, __exponent: c_int) f64; -pub extern fn log(__x: f64) f64; -pub extern fn __log(__x: f64) f64; -pub extern fn log10(__x: f64) f64; -pub extern fn __log10(__x: f64) f64; -pub extern fn modf(__x: f64, __iptr: [*c]f64) f64; -pub extern fn __modf(__x: f64, __iptr: [*c]f64) f64; -pub extern fn expm1(__x: f64) f64; -pub extern fn __expm1(__x: f64) f64; -pub extern fn log1p(__x: f64) f64; -pub extern fn __log1p(__x: f64) f64; -pub extern fn logb(__x: f64) f64; -pub extern fn __logb(__x: f64) f64; -pub extern fn exp2(__x: f64) f64; -pub extern fn __exp2(__x: f64) f64; -pub extern fn log2(__x: f64) f64; -pub extern fn __log2(__x: f64) f64; -pub extern fn pow(__x: f64, __y: f64) f64; -pub extern fn __pow(__x: f64, __y: f64) f64; -pub extern fn sqrt(__x: f64) f64; -pub extern fn __sqrt(__x: f64) f64; -pub extern fn hypot(__x: f64, __y: f64) f64; -pub extern fn __hypot(__x: f64, __y: f64) f64; -pub extern fn cbrt(__x: f64) f64; -pub extern fn __cbrt(__x: f64) f64; -pub extern fn ceil(__x: f64) f64; -pub extern fn __ceil(__x: f64) f64; -pub extern fn fabs(__x: f64) f64; -pub extern fn __fabs(__x: f64) f64; -pub extern fn floor(__x: f64) f64; -pub extern fn __floor(__x: f64) f64; -pub extern fn fmod(__x: f64, __y: f64) f64; -pub extern fn __fmod(__x: f64, __y: f64) f64; -pub extern fn isinf(__value: f64) c_int; -pub extern fn finite(__value: f64) c_int; -pub extern fn drem(__x: f64, __y: f64) f64; -pub extern fn __drem(__x: f64, __y: f64) f64; -pub extern fn significand(__x: f64) f64; -pub extern fn __significand(__x: f64) f64; -pub extern fn copysign(__x: f64, __y: f64) f64; -pub extern fn __copysign(__x: f64, __y: f64) f64; -pub extern fn nan(__tagb: [*c]const u8) f64; -pub extern fn __nan(__tagb: [*c]const u8) f64; -pub extern fn isnan(__value: f64) c_int; -pub extern fn j0(f64) f64; -pub extern fn __j0(f64) f64; -pub extern fn j1(f64) f64; -pub extern fn __j1(f64) f64; -pub extern fn jn(c_int, f64) f64; -pub extern fn __jn(c_int, f64) f64; -pub extern fn y0(f64) f64; -pub extern fn __y0(f64) f64; -pub extern fn y1(f64) f64; -pub extern fn __y1(f64) f64; -pub extern fn yn(c_int, f64) f64; -pub extern fn __yn(c_int, f64) f64; -pub extern fn erf(f64) f64; -pub extern fn __erf(f64) f64; -pub extern fn erfc(f64) f64; -pub extern fn __erfc(f64) f64; -pub extern fn lgamma(f64) f64; -pub extern fn __lgamma(f64) f64; -pub extern fn tgamma(f64) f64; -pub extern fn __tgamma(f64) f64; -pub extern fn gamma(f64) f64; -pub extern fn __gamma(f64) f64; -pub extern fn lgamma_r(f64, __signgamp: [*c]c_int) f64; -pub extern fn __lgamma_r(f64, __signgamp: [*c]c_int) f64; -pub extern fn rint(__x: f64) f64; -pub extern fn __rint(__x: f64) f64; -pub extern fn nextafter(__x: f64, __y: f64) f64; -pub extern fn __nextafter(__x: f64, __y: f64) f64; -pub extern fn nexttoward(__x: f64, __y: c_longdouble) f64; -pub extern fn __nexttoward(__x: f64, __y: c_longdouble) f64; -pub extern fn remainder(__x: f64, __y: f64) f64; -pub extern fn __remainder(__x: f64, __y: f64) f64; -pub extern fn scalbn(__x: f64, __n: c_int) f64; -pub extern fn __scalbn(__x: f64, __n: c_int) f64; -pub extern fn ilogb(__x: f64) c_int; -pub extern fn __ilogb(__x: f64) c_int; -pub extern fn scalbln(__x: f64, __n: c_long) f64; -pub extern fn __scalbln(__x: f64, __n: c_long) f64; -pub extern fn nearbyint(__x: f64) f64; -pub extern fn __nearbyint(__x: f64) f64; -pub extern fn round(__x: f64) f64; -pub extern fn __round(__x: f64) f64; -pub extern fn trunc(__x: f64) f64; -pub extern fn __trunc(__x: f64) f64; -pub extern fn remquo(__x: f64, __y: f64, __quo: [*c]c_int) f64; -pub extern fn __remquo(__x: f64, __y: f64, __quo: [*c]c_int) f64; -pub extern fn lrint(__x: f64) c_long; -pub extern fn __lrint(__x: f64) c_long; -pub extern fn llrint(__x: f64) c_longlong; -pub extern fn __llrint(__x: f64) c_longlong; -pub extern fn lround(__x: f64) c_long; -pub extern fn __lround(__x: f64) c_long; -pub extern fn llround(__x: f64) c_longlong; -pub extern fn __llround(__x: f64) c_longlong; -pub extern fn fdim(__x: f64, __y: f64) f64; -pub extern fn __fdim(__x: f64, __y: f64) f64; -pub extern fn fmax(__x: f64, __y: f64) f64; -pub extern fn __fmax(__x: f64, __y: f64) f64; -pub extern fn fmin(__x: f64, __y: f64) f64; -pub extern fn __fmin(__x: f64, __y: f64) f64; -pub extern fn fma(__x: f64, __y: f64, __z: f64) f64; -pub extern fn __fma(__x: f64, __y: f64, __z: f64) f64; -pub extern fn scalb(__x: f64, __n: f64) f64; -pub extern fn __scalb(__x: f64, __n: f64) f64; -pub extern fn __fpclassifyf(__value: f32) c_int; -pub extern fn __signbitf(__value: f32) c_int; -pub extern fn __isinff(__value: f32) c_int; -pub extern fn __finitef(__value: f32) c_int; -pub extern fn __isnanf(__value: f32) c_int; -pub extern fn __iseqsigf(__x: f32, __y: f32) c_int; -pub extern fn __issignalingf(__value: f32) c_int; -pub extern fn acosf(__x: f32) f32; -pub extern fn __acosf(__x: f32) f32; -pub extern fn asinf(__x: f32) f32; -pub extern fn __asinf(__x: f32) f32; -pub extern fn atanf(__x: f32) f32; -pub extern fn __atanf(__x: f32) f32; -pub extern fn atan2f(__y: f32, __x: f32) f32; -pub extern fn __atan2f(__y: f32, __x: f32) f32; -pub extern fn cosf(__x: f32) f32; -pub extern fn __cosf(__x: f32) f32; -pub extern fn sinf(__x: f32) f32; -pub extern fn __sinf(__x: f32) f32; -pub extern fn tanf(__x: f32) f32; -pub extern fn __tanf(__x: f32) f32; -pub extern fn coshf(__x: f32) f32; -pub extern fn __coshf(__x: f32) f32; -pub extern fn sinhf(__x: f32) f32; -pub extern fn __sinhf(__x: f32) f32; -pub extern fn tanhf(__x: f32) f32; -pub extern fn __tanhf(__x: f32) f32; -pub extern fn acoshf(__x: f32) f32; -pub extern fn __acoshf(__x: f32) f32; -pub extern fn asinhf(__x: f32) f32; -pub extern fn __asinhf(__x: f32) f32; -pub extern fn atanhf(__x: f32) f32; -pub extern fn __atanhf(__x: f32) f32; -pub extern fn expf(__x: f32) f32; -pub extern fn __expf(__x: f32) f32; -pub extern fn frexpf(__x: f32, __exponent: [*c]c_int) f32; -pub extern fn __frexpf(__x: f32, __exponent: [*c]c_int) f32; -pub extern fn ldexpf(__x: f32, __exponent: c_int) f32; -pub extern fn __ldexpf(__x: f32, __exponent: c_int) f32; -pub extern fn logf(__x: f32) f32; -pub extern fn __logf(__x: f32) f32; -pub extern fn log10f(__x: f32) f32; -pub extern fn __log10f(__x: f32) f32; -pub extern fn modff(__x: f32, __iptr: [*c]f32) f32; -pub extern fn __modff(__x: f32, __iptr: [*c]f32) f32; -pub extern fn expm1f(__x: f32) f32; -pub extern fn __expm1f(__x: f32) f32; -pub extern fn log1pf(__x: f32) f32; -pub extern fn __log1pf(__x: f32) f32; -pub extern fn logbf(__x: f32) f32; -pub extern fn __logbf(__x: f32) f32; -pub extern fn exp2f(__x: f32) f32; -pub extern fn __exp2f(__x: f32) f32; -pub extern fn log2f(__x: f32) f32; -pub extern fn __log2f(__x: f32) f32; -pub extern fn powf(__x: f32, __y: f32) f32; -pub extern fn __powf(__x: f32, __y: f32) f32; -pub extern fn sqrtf(__x: f32) f32; -pub extern fn __sqrtf(__x: f32) f32; -pub extern fn hypotf(__x: f32, __y: f32) f32; -pub extern fn __hypotf(__x: f32, __y: f32) f32; -pub extern fn cbrtf(__x: f32) f32; -pub extern fn __cbrtf(__x: f32) f32; -pub extern fn ceilf(__x: f32) f32; -pub extern fn __ceilf(__x: f32) f32; -pub extern fn fabsf(__x: f32) f32; -pub extern fn __fabsf(__x: f32) f32; -pub extern fn floorf(__x: f32) f32; -pub extern fn __floorf(__x: f32) f32; -pub extern fn fmodf(__x: f32, __y: f32) f32; -pub extern fn __fmodf(__x: f32, __y: f32) f32; -pub extern fn isinff(__value: f32) c_int; -pub extern fn finitef(__value: f32) c_int; -pub extern fn dremf(__x: f32, __y: f32) f32; -pub extern fn __dremf(__x: f32, __y: f32) f32; -pub extern fn significandf(__x: f32) f32; -pub extern fn __significandf(__x: f32) f32; -pub extern fn copysignf(__x: f32, __y: f32) f32; -pub extern fn __copysignf(__x: f32, __y: f32) f32; -pub extern fn nanf(__tagb: [*c]const u8) f32; -pub extern fn __nanf(__tagb: [*c]const u8) f32; -pub extern fn isnanf(__value: f32) c_int; -pub extern fn j0f(f32) f32; -pub extern fn __j0f(f32) f32; -pub extern fn j1f(f32) f32; -pub extern fn __j1f(f32) f32; -pub extern fn jnf(c_int, f32) f32; -pub extern fn __jnf(c_int, f32) f32; -pub extern fn y0f(f32) f32; -pub extern fn __y0f(f32) f32; -pub extern fn y1f(f32) f32; -pub extern fn __y1f(f32) f32; -pub extern fn ynf(c_int, f32) f32; -pub extern fn __ynf(c_int, f32) f32; -pub extern fn erff(f32) f32; -pub extern fn __erff(f32) f32; -pub extern fn erfcf(f32) f32; -pub extern fn __erfcf(f32) f32; -pub extern fn lgammaf(f32) f32; -pub extern fn __lgammaf(f32) f32; -pub extern fn tgammaf(f32) f32; -pub extern fn __tgammaf(f32) f32; -pub extern fn gammaf(f32) f32; -pub extern fn __gammaf(f32) f32; -pub extern fn lgammaf_r(f32, __signgamp: [*c]c_int) f32; -pub extern fn __lgammaf_r(f32, __signgamp: [*c]c_int) f32; -pub extern fn rintf(__x: f32) f32; -pub extern fn __rintf(__x: f32) f32; -pub extern fn nextafterf(__x: f32, __y: f32) f32; -pub extern fn __nextafterf(__x: f32, __y: f32) f32; -pub extern fn nexttowardf(__x: f32, __y: c_longdouble) f32; -pub extern fn __nexttowardf(__x: f32, __y: c_longdouble) f32; -pub extern fn remainderf(__x: f32, __y: f32) f32; -pub extern fn __remainderf(__x: f32, __y: f32) f32; -pub extern fn scalbnf(__x: f32, __n: c_int) f32; -pub extern fn __scalbnf(__x: f32, __n: c_int) f32; -pub extern fn ilogbf(__x: f32) c_int; -pub extern fn __ilogbf(__x: f32) c_int; -pub extern fn scalblnf(__x: f32, __n: c_long) f32; -pub extern fn __scalblnf(__x: f32, __n: c_long) f32; -pub extern fn nearbyintf(__x: f32) f32; -pub extern fn __nearbyintf(__x: f32) f32; -pub extern fn roundf(__x: f32) f32; -pub extern fn __roundf(__x: f32) f32; -pub extern fn truncf(__x: f32) f32; -pub extern fn __truncf(__x: f32) f32; -pub extern fn remquof(__x: f32, __y: f32, __quo: [*c]c_int) f32; -pub extern fn __remquof(__x: f32, __y: f32, __quo: [*c]c_int) f32; -pub extern fn lrintf(__x: f32) c_long; -pub extern fn __lrintf(__x: f32) c_long; -pub extern fn llrintf(__x: f32) c_longlong; -pub extern fn __llrintf(__x: f32) c_longlong; -pub extern fn lroundf(__x: f32) c_long; -pub extern fn __lroundf(__x: f32) c_long; -pub extern fn llroundf(__x: f32) c_longlong; -pub extern fn __llroundf(__x: f32) c_longlong; -pub extern fn fdimf(__x: f32, __y: f32) f32; -pub extern fn __fdimf(__x: f32, __y: f32) f32; -pub extern fn fmaxf(__x: f32, __y: f32) f32; -pub extern fn __fmaxf(__x: f32, __y: f32) f32; -pub extern fn fminf(__x: f32, __y: f32) f32; -pub extern fn __fminf(__x: f32, __y: f32) f32; -pub extern fn fmaf(__x: f32, __y: f32, __z: f32) f32; -pub extern fn __fmaf(__x: f32, __y: f32, __z: f32) f32; -pub extern fn scalbf(__x: f32, __n: f32) f32; -pub extern fn __scalbf(__x: f32, __n: f32) f32; -pub extern fn __fpclassifyl(__value: c_longdouble) c_int; -pub extern fn __signbitl(__value: c_longdouble) c_int; -pub extern fn __isinfl(__value: c_longdouble) c_int; -pub extern fn __finitel(__value: c_longdouble) c_int; -pub extern fn __isnanl(__value: c_longdouble) c_int; -pub extern fn __iseqsigl(__x: c_longdouble, __y: c_longdouble) c_int; -pub extern fn __issignalingl(__value: c_longdouble) c_int; -pub extern fn acosl(__x: c_longdouble) c_longdouble; -pub extern fn __acosl(__x: c_longdouble) c_longdouble; -pub extern fn asinl(__x: c_longdouble) c_longdouble; -pub extern fn __asinl(__x: c_longdouble) c_longdouble; -pub extern fn atanl(__x: c_longdouble) c_longdouble; -pub extern fn __atanl(__x: c_longdouble) c_longdouble; -pub extern fn atan2l(__y: c_longdouble, __x: c_longdouble) c_longdouble; -pub extern fn __atan2l(__y: c_longdouble, __x: c_longdouble) c_longdouble; -pub extern fn cosl(__x: c_longdouble) c_longdouble; -pub extern fn __cosl(__x: c_longdouble) c_longdouble; -pub extern fn sinl(__x: c_longdouble) c_longdouble; -pub extern fn __sinl(__x: c_longdouble) c_longdouble; -pub extern fn tanl(__x: c_longdouble) c_longdouble; -pub extern fn __tanl(__x: c_longdouble) c_longdouble; -pub extern fn coshl(__x: c_longdouble) c_longdouble; -pub extern fn __coshl(__x: c_longdouble) c_longdouble; -pub extern fn sinhl(__x: c_longdouble) c_longdouble; -pub extern fn __sinhl(__x: c_longdouble) c_longdouble; -pub extern fn tanhl(__x: c_longdouble) c_longdouble; -pub extern fn __tanhl(__x: c_longdouble) c_longdouble; -pub extern fn acoshl(__x: c_longdouble) c_longdouble; -pub extern fn __acoshl(__x: c_longdouble) c_longdouble; -pub extern fn asinhl(__x: c_longdouble) c_longdouble; -pub extern fn __asinhl(__x: c_longdouble) c_longdouble; -pub extern fn atanhl(__x: c_longdouble) c_longdouble; -pub extern fn __atanhl(__x: c_longdouble) c_longdouble; -pub extern fn expl(__x: c_longdouble) c_longdouble; -pub extern fn __expl(__x: c_longdouble) c_longdouble; -pub extern fn frexpl(__x: c_longdouble, __exponent: [*c]c_int) c_longdouble; -pub extern fn __frexpl(__x: c_longdouble, __exponent: [*c]c_int) c_longdouble; -pub extern fn ldexpl(__x: c_longdouble, __exponent: c_int) c_longdouble; -pub extern fn __ldexpl(__x: c_longdouble, __exponent: c_int) c_longdouble; -pub extern fn logl(__x: c_longdouble) c_longdouble; -pub extern fn __logl(__x: c_longdouble) c_longdouble; -pub extern fn log10l(__x: c_longdouble) c_longdouble; -pub extern fn __log10l(__x: c_longdouble) c_longdouble; -pub extern fn modfl(__x: c_longdouble, __iptr: [*c]c_longdouble) c_longdouble; -pub extern fn __modfl(__x: c_longdouble, __iptr: [*c]c_longdouble) c_longdouble; -pub extern fn expm1l(__x: c_longdouble) c_longdouble; -pub extern fn __expm1l(__x: c_longdouble) c_longdouble; -pub extern fn log1pl(__x: c_longdouble) c_longdouble; -pub extern fn __log1pl(__x: c_longdouble) c_longdouble; -pub extern fn logbl(__x: c_longdouble) c_longdouble; -pub extern fn __logbl(__x: c_longdouble) c_longdouble; -pub extern fn exp2l(__x: c_longdouble) c_longdouble; -pub extern fn __exp2l(__x: c_longdouble) c_longdouble; -pub extern fn log2l(__x: c_longdouble) c_longdouble; -pub extern fn __log2l(__x: c_longdouble) c_longdouble; -pub extern fn powl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __powl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn sqrtl(__x: c_longdouble) c_longdouble; -pub extern fn __sqrtl(__x: c_longdouble) c_longdouble; -pub extern fn hypotl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __hypotl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn cbrtl(__x: c_longdouble) c_longdouble; -pub extern fn __cbrtl(__x: c_longdouble) c_longdouble; -pub extern fn ceill(__x: c_longdouble) c_longdouble; -pub extern fn __ceill(__x: c_longdouble) c_longdouble; -pub extern fn fabsl(__x: c_longdouble) c_longdouble; -pub extern fn __fabsl(__x: c_longdouble) c_longdouble; -pub extern fn floorl(__x: c_longdouble) c_longdouble; -pub extern fn __floorl(__x: c_longdouble) c_longdouble; -pub extern fn fmodl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __fmodl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn isinfl(__value: c_longdouble) c_int; -pub extern fn finitel(__value: c_longdouble) c_int; -pub extern fn dreml(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __dreml(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn significandl(__x: c_longdouble) c_longdouble; -pub extern fn __significandl(__x: c_longdouble) c_longdouble; -pub extern fn copysignl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __copysignl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn nanl(__tagb: [*c]const u8) c_longdouble; -pub extern fn __nanl(__tagb: [*c]const u8) c_longdouble; -pub extern fn isnanl(__value: c_longdouble) c_int; -pub extern fn j0l(c_longdouble) c_longdouble; -pub extern fn __j0l(c_longdouble) c_longdouble; -pub extern fn j1l(c_longdouble) c_longdouble; -pub extern fn __j1l(c_longdouble) c_longdouble; -pub extern fn jnl(c_int, c_longdouble) c_longdouble; -pub extern fn __jnl(c_int, c_longdouble) c_longdouble; -pub extern fn y0l(c_longdouble) c_longdouble; -pub extern fn __y0l(c_longdouble) c_longdouble; -pub extern fn y1l(c_longdouble) c_longdouble; -pub extern fn __y1l(c_longdouble) c_longdouble; -pub extern fn ynl(c_int, c_longdouble) c_longdouble; -pub extern fn __ynl(c_int, c_longdouble) c_longdouble; -pub extern fn erfl(c_longdouble) c_longdouble; -pub extern fn __erfl(c_longdouble) c_longdouble; -pub extern fn erfcl(c_longdouble) c_longdouble; -pub extern fn __erfcl(c_longdouble) c_longdouble; -pub extern fn lgammal(c_longdouble) c_longdouble; -pub extern fn __lgammal(c_longdouble) c_longdouble; -pub extern fn tgammal(c_longdouble) c_longdouble; -pub extern fn __tgammal(c_longdouble) c_longdouble; -pub extern fn gammal(c_longdouble) c_longdouble; -pub extern fn __gammal(c_longdouble) c_longdouble; -pub extern fn lgammal_r(c_longdouble, __signgamp: [*c]c_int) c_longdouble; -pub extern fn __lgammal_r(c_longdouble, __signgamp: [*c]c_int) c_longdouble; -pub extern fn rintl(__x: c_longdouble) c_longdouble; -pub extern fn __rintl(__x: c_longdouble) c_longdouble; -pub extern fn nextafterl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __nextafterl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn nexttowardl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __nexttowardl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn remainderl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __remainderl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn scalbnl(__x: c_longdouble, __n: c_int) c_longdouble; -pub extern fn __scalbnl(__x: c_longdouble, __n: c_int) c_longdouble; -pub extern fn ilogbl(__x: c_longdouble) c_int; -pub extern fn __ilogbl(__x: c_longdouble) c_int; -pub extern fn scalblnl(__x: c_longdouble, __n: c_long) c_longdouble; -pub extern fn __scalblnl(__x: c_longdouble, __n: c_long) c_longdouble; -pub extern fn nearbyintl(__x: c_longdouble) c_longdouble; -pub extern fn __nearbyintl(__x: c_longdouble) c_longdouble; -pub extern fn roundl(__x: c_longdouble) c_longdouble; -pub extern fn __roundl(__x: c_longdouble) c_longdouble; -pub extern fn truncl(__x: c_longdouble) c_longdouble; -pub extern fn __truncl(__x: c_longdouble) c_longdouble; -pub extern fn remquol(__x: c_longdouble, __y: c_longdouble, __quo: [*c]c_int) c_longdouble; -pub extern fn __remquol(__x: c_longdouble, __y: c_longdouble, __quo: [*c]c_int) c_longdouble; -pub extern fn lrintl(__x: c_longdouble) c_long; -pub extern fn __lrintl(__x: c_longdouble) c_long; -pub extern fn llrintl(__x: c_longdouble) c_longlong; -pub extern fn __llrintl(__x: c_longdouble) c_longlong; -pub extern fn lroundl(__x: c_longdouble) c_long; -pub extern fn __lroundl(__x: c_longdouble) c_long; -pub extern fn llroundl(__x: c_longdouble) c_longlong; -pub extern fn __llroundl(__x: c_longdouble) c_longlong; -pub extern fn fdiml(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __fdiml(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn fmaxl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __fmaxl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn fminl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn __fminl(__x: c_longdouble, __y: c_longdouble) c_longdouble; -pub extern fn fmal(__x: c_longdouble, __y: c_longdouble, __z: c_longdouble) c_longdouble; -pub extern fn __fmal(__x: c_longdouble, __y: c_longdouble, __z: c_longdouble) c_longdouble; -pub extern fn scalbl(__x: c_longdouble, __n: c_longdouble) c_longdouble; -pub extern fn __scalbl(__x: c_longdouble, __n: c_longdouble) c_longdouble; -pub extern var signgam: c_int; -pub const FP_NAN: c_int = 0; -pub const FP_INFINITE: c_int = 1; -pub const FP_ZERO: c_int = 2; -pub const FP_SUBNORMAL: c_int = 3; -pub const FP_NORMAL: c_int = 4; -const enum_unnamed_2 = c_uint; -pub fn Clamp(arg_value: f32, arg_min: f32, arg_max: f32) callconv(.C) f32 { - var value = arg_value; - _ = &value; - var min = arg_min; - _ = &min; - var max = arg_max; - _ = &max; - var result: f32 = if (value < min) min else value; - _ = &result; - if (result > max) { - result = max; - } - return result; -} -pub fn Lerp(arg_start: f32, arg_end: f32, arg_amount: f32) callconv(.C) f32 { - var start = arg_start; - _ = &start; - var end = arg_end; - _ = &end; - var amount = arg_amount; - _ = &amount; - var result: f32 = start + (amount * (end - start)); - _ = &result; - return result; -} -pub fn Normalize(arg_value: f32, arg_start: f32, arg_end: f32) callconv(.C) f32 { - var value = arg_value; - _ = &value; - var start = arg_start; - _ = &start; - var end = arg_end; - _ = &end; - var result: f32 = (value - start) / (end - start); - _ = &result; - return result; -} -pub fn Remap(arg_value: f32, arg_inputStart: f32, arg_inputEnd: f32, arg_outputStart: f32, arg_outputEnd: f32) callconv(.C) f32 { - var value = arg_value; - _ = &value; - var inputStart = arg_inputStart; - _ = &inputStart; - var inputEnd = arg_inputEnd; - _ = &inputEnd; - var outputStart = arg_outputStart; - _ = &outputStart; - var outputEnd = arg_outputEnd; - _ = &outputEnd; - var result: f32 = (((value - inputStart) / (inputEnd - inputStart)) * (outputEnd - outputStart)) + outputStart; - _ = &result; - return result; -} -pub fn Wrap(arg_value: f32, arg_min: f32, arg_max: f32) callconv(.C) f32 { - var value = arg_value; - _ = &value; - var min = arg_min; - _ = &min; - var max = arg_max; - _ = &max; - var result: f32 = value - ((max - min) * floorf((value - min) / (max - min))); - _ = &result; - return result; -} -pub fn FloatEquals(arg_x: f32, arg_y: f32) callconv(.C) c_int { - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var result: c_int = @intFromBool(fabsf(x - y) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(x), fabsf(y))))); - _ = &result; - return result; -} -pub fn Vector2Zero() callconv(.C) Vector2 { - var result: Vector2 = Vector2{ - .x = 0.0, - .y = 0.0, - }; - _ = &result; - return result; -} -pub fn Vector2One() callconv(.C) Vector2 { - var result: Vector2 = Vector2{ - .x = 1.0, - .y = 1.0, - }; - _ = &result; - return result; -} -pub fn Vector2Add(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector2 = Vector2{ - .x = v1.x + v2.x, - .y = v1.y + v2.y, - }; - _ = &result; - return result; -} -pub fn Vector2AddValue(arg_v: Vector2, arg_add: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var add = arg_add; - _ = &add; - var result: Vector2 = Vector2{ - .x = v.x + add, - .y = v.y + add, - }; - _ = &result; - return result; -} -pub fn Vector2Subtract(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector2 = Vector2{ - .x = v1.x - v2.x, - .y = v1.y - v2.y, - }; - _ = &result; - return result; -} -pub fn Vector2SubtractValue(arg_v: Vector2, arg_sub: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var sub = arg_sub; - _ = ⊂ - var result: Vector2 = Vector2{ - .x = v.x - sub, - .y = v.y - sub, - }; - _ = &result; - return result; -} -pub fn Vector2Length(arg_v: Vector2) callconv(.C) f32 { - var v = arg_v; - _ = &v; - var result: f32 = sqrtf((v.x * v.x) + (v.y * v.y)); - _ = &result; - return result; -} -pub fn Vector2LengthSqr(arg_v: Vector2) callconv(.C) f32 { - var v = arg_v; - _ = &v; - var result: f32 = (v.x * v.x) + (v.y * v.y); - _ = &result; - return result; -} -pub fn Vector2DotProduct(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = (v1.x * v2.x) + (v1.y * v2.y); - _ = &result; - return result; -} -pub fn Vector2Distance(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = sqrtf(((v1.x - v2.x) * (v1.x - v2.x)) + ((v1.y - v2.y) * (v1.y - v2.y))); - _ = &result; - return result; -} -pub fn Vector2DistanceSqr(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = ((v1.x - v2.x) * (v1.x - v2.x)) + ((v1.y - v2.y) * (v1.y - v2.y)); - _ = &result; - return result; -} -pub fn Vector2Angle(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = 0.0; - _ = &result; - var dot: f32 = (v1.x * v2.x) + (v1.y * v2.y); - _ = ˙ - var det: f32 = (v1.x * v2.y) - (v1.y * v2.x); - _ = &det; - result = atan2f(det, dot); - return result; -} -pub fn Vector2LineAngle(arg_start: Vector2, arg_end: Vector2) callconv(.C) f32 { - var start = arg_start; - _ = &start; - var end = arg_end; - _ = &end; - var result: f32 = 0.0; - _ = &result; - result = -atan2f(end.y - start.y, end.x - start.x); - return result; -} -pub fn Vector2Scale(arg_v: Vector2, arg_scale: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var scale = arg_scale; - _ = &scale; - var result: Vector2 = Vector2{ - .x = v.x * scale, - .y = v.y * scale, - }; - _ = &result; - return result; -} -pub fn Vector2Multiply(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector2 = Vector2{ - .x = v1.x * v2.x, - .y = v1.y * v2.y, - }; - _ = &result; - return result; -} -pub fn Vector2Negate(arg_v: Vector2) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var result: Vector2 = Vector2{ - .x = -v.x, - .y = -v.y, - }; - _ = &result; - return result; -} -pub fn Vector2Divide(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector2 = Vector2{ - .x = v1.x / v2.x, - .y = v1.y / v2.y, - }; - _ = &result; - return result; -} -pub fn Vector2Normalize(arg_v: Vector2) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - var length: f32 = sqrtf((v.x * v.x) + (v.y * v.y)); - _ = &length; - if (length > @as(f32, @floatFromInt(@as(c_int, 0)))) { - var ilength: f32 = 1.0 / length; - _ = &ilength; - result.x = v.x * ilength; - result.y = v.y * ilength; - } - return result; -} -pub fn Vector2Transform(arg_v: Vector2, arg_mat: Matrix) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var mat = arg_mat; - _ = &mat; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - var x: f32 = v.x; - _ = &x; - var y: f32 = v.y; - _ = &y; - var z: f32 = 0; - _ = &z; - result.x = (((mat.m0 * x) + (mat.m4 * y)) + (mat.m8 * z)) + mat.m12; - result.y = (((mat.m1 * x) + (mat.m5 * y)) + (mat.m9 * z)) + mat.m13; - return result; -} -pub fn Vector2Lerp(arg_v1: Vector2, arg_v2: Vector2, arg_amount: f32) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var amount = arg_amount; - _ = &amount; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - result.x = v1.x + (amount * (v2.x - v1.x)); - result.y = v1.y + (amount * (v2.y - v1.y)); - return result; -} -pub fn Vector2Reflect(arg_v: Vector2, arg_normal: Vector2) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var normal = arg_normal; - _ = &normal; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - var dotProduct: f32 = (v.x * normal.x) + (v.y * normal.y); - _ = &dotProduct; - result.x = v.x - ((2.0 * normal.x) * dotProduct); - result.y = v.y - ((2.0 * normal.y) * dotProduct); - return result; -} -pub fn Vector2Min(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - result.x = fminf(v1.x, v2.x); - result.y = fminf(v1.y, v2.y); - return result; -} -pub fn Vector2Max(arg_v1: Vector2, arg_v2: Vector2) callconv(.C) Vector2 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - result.x = fmaxf(v1.x, v2.x); - result.y = fmaxf(v1.y, v2.y); - return result; -} -pub fn Vector2Rotate(arg_v: Vector2, arg_angle: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var angle = arg_angle; - _ = ∠ - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - var cosres: f32 = cosf(angle); - _ = &cosres; - var sinres: f32 = sinf(angle); - _ = &sinres; - result.x = (v.x * cosres) - (v.y * sinres); - result.y = (v.x * sinres) + (v.y * cosres); - return result; -} -pub fn Vector2MoveTowards(arg_v: Vector2, arg_target: Vector2, arg_maxDistance: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var target = arg_target; - _ = ⌖ - var maxDistance = arg_maxDistance; - _ = &maxDistance; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - var dx: f32 = target.x - v.x; - _ = &dx; - var dy: f32 = target.y - v.y; - _ = &dy; - var value: f32 = (dx * dx) + (dy * dy); - _ = &value; - if ((value == @as(f32, @floatFromInt(@as(c_int, 0)))) or ((maxDistance >= @as(f32, @floatFromInt(@as(c_int, 0)))) and (value <= (maxDistance * maxDistance)))) return target; - var dist: f32 = sqrtf(value); - _ = &dist; - result.x = v.x + ((dx / dist) * maxDistance); - result.y = v.y + ((dy / dist) * maxDistance); - return result; -} -pub fn Vector2Invert(arg_v: Vector2) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var result: Vector2 = Vector2{ - .x = 1.0 / v.x, - .y = 1.0 / v.y, - }; - _ = &result; - return result; -} -pub fn Vector2Clamp(arg_v: Vector2, arg_min: Vector2, arg_max: Vector2) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var min = arg_min; - _ = &min; - var max = arg_max; - _ = &max; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - result.x = fminf(max.x, fmaxf(min.x, v.x)); - result.y = fminf(max.y, fmaxf(min.y, v.y)); - return result; -} -pub fn Vector2ClampValue(arg_v: Vector2, arg_min: f32, arg_max: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var min = arg_min; - _ = &min; - var max = arg_max; - _ = &max; - var result: Vector2 = v; - _ = &result; - var length: f32 = (v.x * v.x) + (v.y * v.y); - _ = &length; - if (length > 0.0) { - length = sqrtf(length); - var scale: f32 = 1; - _ = &scale; - if (length < min) { - scale = min / length; - } else if (length > max) { - scale = max / length; - } - result.x = v.x * scale; - result.y = v.y * scale; - } - return result; -} -pub fn Vector2Equals(arg_p: Vector2, arg_q: Vector2) callconv(.C) c_int { - var p = arg_p; - _ = &p; - var q = arg_q; - _ = &q; - var result: c_int = @intFromBool((fabsf(p.x - q.x) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.x), fabsf(q.x))))) and (fabsf(p.y - q.y) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.y), fabsf(q.y)))))); - _ = &result; - return result; -} -pub fn Vector2Refract(arg_v: Vector2, arg_n: Vector2, arg_r: f32) callconv(.C) Vector2 { - var v = arg_v; - _ = &v; - var n = arg_n; - _ = &n; - var r = arg_r; - _ = &r; - var result: Vector2 = Vector2{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - }; - _ = &result; - var dot: f32 = (v.x * n.x) + (v.y * n.y); - _ = ˙ - var d: f32 = 1.0 - ((r * r) * (1.0 - (dot * dot))); - _ = &d; - if (d >= 0.0) { - d = sqrtf(d); - v.x = (r * v.x) - (((r * dot) + d) * n.x); - v.y = (r * v.y) - (((r * dot) + d) * n.y); - result = v; - } - return result; -} -pub fn Vector3Zero() callconv(.C) Vector3 { - var result: Vector3 = Vector3{ - .x = 0.0, - .y = 0.0, - .z = 0.0, - }; - _ = &result; - return result; -} -pub fn Vector3One() callconv(.C) Vector3 { - var result: Vector3 = Vector3{ - .x = 1.0, - .y = 1.0, - .z = 1.0, - }; - _ = &result; - return result; -} -pub fn Vector3Add(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = v1.x + v2.x, - .y = v1.y + v2.y, - .z = v1.z + v2.z, - }; - _ = &result; - return result; -} -pub fn Vector3AddValue(arg_v: Vector3, arg_add: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var add = arg_add; - _ = &add; - var result: Vector3 = Vector3{ - .x = v.x + add, - .y = v.y + add, - .z = v.z + add, - }; - _ = &result; - return result; -} -pub fn Vector3Subtract(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = v1.x - v2.x, - .y = v1.y - v2.y, - .z = v1.z - v2.z, - }; - _ = &result; - return result; -} -pub fn Vector3SubtractValue(arg_v: Vector3, arg_sub: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var sub = arg_sub; - _ = ⊂ - var result: Vector3 = Vector3{ - .x = v.x - sub, - .y = v.y - sub, - .z = v.z - sub, - }; - _ = &result; - return result; -} -pub fn Vector3Scale(arg_v: Vector3, arg_scalar: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var scalar = arg_scalar; - _ = &scalar; - var result: Vector3 = Vector3{ - .x = v.x * scalar, - .y = v.y * scalar, - .z = v.z * scalar, - }; - _ = &result; - return result; -} -pub fn Vector3Multiply(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = v1.x * v2.x, - .y = v1.y * v2.y, - .z = v1.z * v2.z, - }; - _ = &result; - return result; -} -pub fn Vector3CrossProduct(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = (v1.y * v2.z) - (v1.z * v2.y), - .y = (v1.z * v2.x) - (v1.x * v2.z), - .z = (v1.x * v2.y) - (v1.y * v2.x), - }; - _ = &result; - return result; -} -pub fn Vector3Perpendicular(arg_v: Vector3) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var min: f32 = fabsf(v.x); - _ = &min; - var cardinalAxis: Vector3 = Vector3{ - .x = 1.0, - .y = 0.0, - .z = 0.0, - }; - _ = &cardinalAxis; - if (fabsf(v.y) < min) { - min = fabsf(v.y); - var tmp: Vector3 = Vector3{ - .x = 0.0, - .y = 1.0, - .z = 0.0, - }; - _ = &tmp; - cardinalAxis = tmp; - } - if (fabsf(v.z) < min) { - var tmp: Vector3 = Vector3{ - .x = 0.0, - .y = 0.0, - .z = 1.0, - }; - _ = &tmp; - cardinalAxis = tmp; - } - result.x = (v.y * cardinalAxis.z) - (v.z * cardinalAxis.y); - result.y = (v.z * cardinalAxis.x) - (v.x * cardinalAxis.z); - result.z = (v.x * cardinalAxis.y) - (v.y * cardinalAxis.x); - return result; -} -pub fn Vector3Length(v: Vector3) callconv(.C) f32 { - _ = &v; - var result: f32 = sqrtf(((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)); - _ = &result; - return result; -} -pub fn Vector3LengthSqr(v: Vector3) callconv(.C) f32 { - _ = &v; - var result: f32 = ((v.x * v.x) + (v.y * v.y)) + (v.z * v.z); - _ = &result; - return result; -} -pub fn Vector3DotProduct(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = ((v1.x * v2.x) + (v1.y * v2.y)) + (v1.z * v2.z); - _ = &result; - return result; -} -pub fn Vector3Distance(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = 0.0; - _ = &result; - var dx: f32 = v2.x - v1.x; - _ = &dx; - var dy: f32 = v2.y - v1.y; - _ = &dy; - var dz: f32 = v2.z - v1.z; - _ = &dz; - result = sqrtf(((dx * dx) + (dy * dy)) + (dz * dz)); - return result; -} -pub fn Vector3DistanceSqr(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = 0.0; - _ = &result; - var dx: f32 = v2.x - v1.x; - _ = &dx; - var dy: f32 = v2.y - v1.y; - _ = &dy; - var dz: f32 = v2.z - v1.z; - _ = &dz; - result = ((dx * dx) + (dy * dy)) + (dz * dz); - return result; -} -pub fn Vector3Angle(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = 0.0; - _ = &result; - var cross: Vector3 = Vector3{ - .x = (v1.y * v2.z) - (v1.z * v2.y), - .y = (v1.z * v2.x) - (v1.x * v2.z), - .z = (v1.x * v2.y) - (v1.y * v2.x), - }; - _ = ✗ - var len: f32 = sqrtf(((cross.x * cross.x) + (cross.y * cross.y)) + (cross.z * cross.z)); - _ = &len; - var dot: f32 = ((v1.x * v2.x) + (v1.y * v2.y)) + (v1.z * v2.z); - _ = ˙ - result = atan2f(len, dot); - return result; -} -pub fn Vector3Negate(arg_v: Vector3) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var result: Vector3 = Vector3{ - .x = -v.x, - .y = -v.y, - .z = -v.z, - }; - _ = &result; - return result; -} -pub fn Vector3Divide(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = v1.x / v2.x, - .y = v1.y / v2.y, - .z = v1.z / v2.z, - }; - _ = &result; - return result; -} -pub fn Vector3Normalize(arg_v: Vector3) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var result: Vector3 = v; - _ = &result; - var length: f32 = sqrtf(((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)); - _ = &length; - if (length != 0.0) { - var ilength: f32 = 1.0 / length; - _ = &ilength; - result.x *= ilength; - result.y *= ilength; - result.z *= ilength; - } - return result; -} -pub fn Vector3Project(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var v1dv2: f32 = ((v1.x * v2.x) + (v1.y * v2.y)) + (v1.z * v2.z); - _ = &v1dv2; - var v2dv2: f32 = ((v2.x * v2.x) + (v2.y * v2.y)) + (v2.z * v2.z); - _ = &v2dv2; - var mag: f32 = v1dv2 / v2dv2; - _ = &mag; - result.x = v2.x * mag; - result.y = v2.y * mag; - result.z = v2.z * mag; - return result; -} -pub fn Vector3Reject(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var v1dv2: f32 = ((v1.x * v2.x) + (v1.y * v2.y)) + (v1.z * v2.z); - _ = &v1dv2; - var v2dv2: f32 = ((v2.x * v2.x) + (v2.y * v2.y)) + (v2.z * v2.z); - _ = &v2dv2; - var mag: f32 = v1dv2 / v2dv2; - _ = &mag; - result.x = v1.x - (v2.x * mag); - result.y = v1.y - (v2.y * mag); - result.z = v1.z - (v2.z * mag); - return result; -} -pub fn Vector3OrthoNormalize(arg_v1: [*c]Vector3, arg_v2: [*c]Vector3) callconv(.C) void { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var length: f32 = 0.0; - _ = &length; - var ilength: f32 = 0.0; - _ = &ilength; - var v: Vector3 = v1.*; - _ = &v; - length = sqrtf(((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)); - if (length == 0.0) { - length = 1.0; - } - ilength = 1.0 / length; - v1.*.x *= ilength; - v1.*.y *= ilength; - v1.*.z *= ilength; - var vn1: Vector3 = Vector3{ - .x = (v1.*.y * v2.*.z) - (v1.*.z * v2.*.y), - .y = (v1.*.z * v2.*.x) - (v1.*.x * v2.*.z), - .z = (v1.*.x * v2.*.y) - (v1.*.y * v2.*.x), - }; - _ = &vn1; - v = vn1; - length = sqrtf(((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)); - if (length == 0.0) { - length = 1.0; - } - ilength = 1.0 / length; - vn1.x *= ilength; - vn1.y *= ilength; - vn1.z *= ilength; - var vn2: Vector3 = Vector3{ - .x = (vn1.y * v1.*.z) - (vn1.z * v1.*.y), - .y = (vn1.z * v1.*.x) - (vn1.x * v1.*.z), - .z = (vn1.x * v1.*.y) - (vn1.y * v1.*.x), - }; - _ = &vn2; - v2.* = vn2; -} -pub fn Vector3Transform(arg_v: Vector3, arg_mat: Matrix) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var mat = arg_mat; - _ = &mat; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var x: f32 = v.x; - _ = &x; - var y: f32 = v.y; - _ = &y; - var z: f32 = v.z; - _ = &z; - result.x = (((mat.m0 * x) + (mat.m4 * y)) + (mat.m8 * z)) + mat.m12; - result.y = (((mat.m1 * x) + (mat.m5 * y)) + (mat.m9 * z)) + mat.m13; - result.z = (((mat.m2 * x) + (mat.m6 * y)) + (mat.m10 * z)) + mat.m14; - return result; -} -pub fn Vector3RotateByQuaternion(arg_v: Vector3, arg_q: Quaternion) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var q = arg_q; - _ = &q; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - result.x = ((v.x * ((((q.x * q.x) + (q.w * q.w)) - (q.y * q.y)) - (q.z * q.z))) + (v.y * (((@as(f32, @floatFromInt(@as(c_int, 2))) * q.x) * q.y) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * q.w) * q.z)))) + (v.z * (((@as(f32, @floatFromInt(@as(c_int, 2))) * q.x) * q.z) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * q.w) * q.y))); - result.y = ((v.x * (((@as(f32, @floatFromInt(@as(c_int, 2))) * q.w) * q.z) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * q.x) * q.y))) + (v.y * ((((q.w * q.w) - (q.x * q.x)) + (q.y * q.y)) - (q.z * q.z)))) + (v.z * (((@as(f32, @floatFromInt(-@as(c_int, 2))) * q.w) * q.x) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * q.y) * q.z))); - result.z = ((v.x * (((@as(f32, @floatFromInt(-@as(c_int, 2))) * q.w) * q.y) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * q.x) * q.z))) + (v.y * (((@as(f32, @floatFromInt(@as(c_int, 2))) * q.w) * q.x) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * q.y) * q.z)))) + (v.z * ((((q.w * q.w) - (q.x * q.x)) - (q.y * q.y)) + (q.z * q.z))); - return result; -} -pub fn Vector3RotateByAxisAngle(arg_v: Vector3, arg_axis: Vector3, arg_angle: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var axis = arg_axis; - _ = &axis; - var angle = arg_angle; - _ = ∠ - var result: Vector3 = v; - _ = &result; - var length: f32 = sqrtf(((axis.x * axis.x) + (axis.y * axis.y)) + (axis.z * axis.z)); - _ = &length; - if (length == 0.0) { - length = 1.0; - } - var ilength: f32 = 1.0 / length; - _ = &ilength; - axis.x *= ilength; - axis.y *= ilength; - axis.z *= ilength; - angle /= 2.0; - var a: f32 = sinf(angle); - _ = &a; - var b: f32 = axis.x * a; - _ = &b; - var c: f32 = axis.y * a; - _ = &c; - var d: f32 = axis.z * a; - _ = &d; - a = cosf(angle); - var w: Vector3 = Vector3{ - .x = b, - .y = c, - .z = d, - }; - _ = &w; - var wv: Vector3 = Vector3{ - .x = (w.y * v.z) - (w.z * v.y), - .y = (w.z * v.x) - (w.x * v.z), - .z = (w.x * v.y) - (w.y * v.x), - }; - _ = &wv; - var wwv: Vector3 = Vector3{ - .x = (w.y * wv.z) - (w.z * wv.y), - .y = (w.z * wv.x) - (w.x * wv.z), - .z = (w.x * wv.y) - (w.y * wv.x), - }; - _ = &wwv; - a *= @as(f32, @floatFromInt(@as(c_int, 2))); - wv.x *= a; - wv.y *= a; - wv.z *= a; - wwv.x *= @as(f32, @floatFromInt(@as(c_int, 2))); - wwv.y *= @as(f32, @floatFromInt(@as(c_int, 2))); - wwv.z *= @as(f32, @floatFromInt(@as(c_int, 2))); - result.x += wv.x; - result.y += wv.y; - result.z += wv.z; - result.x += wwv.x; - result.y += wwv.y; - result.z += wwv.z; - return result; -} -pub fn Vector3MoveTowards(arg_v: Vector3, arg_target: Vector3, arg_maxDistance: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var target = arg_target; - _ = ⌖ - var maxDistance = arg_maxDistance; - _ = &maxDistance; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var dx: f32 = target.x - v.x; - _ = &dx; - var dy: f32 = target.y - v.y; - _ = &dy; - var dz: f32 = target.z - v.z; - _ = &dz; - var value: f32 = ((dx * dx) + (dy * dy)) + (dz * dz); - _ = &value; - if ((value == @as(f32, @floatFromInt(@as(c_int, 0)))) or ((maxDistance >= @as(f32, @floatFromInt(@as(c_int, 0)))) and (value <= (maxDistance * maxDistance)))) return target; - var dist: f32 = sqrtf(value); - _ = &dist; - result.x = v.x + ((dx / dist) * maxDistance); - result.y = v.y + ((dy / dist) * maxDistance); - result.z = v.z + ((dz / dist) * maxDistance); - return result; -} -pub fn Vector3Lerp(arg_v1: Vector3, arg_v2: Vector3, arg_amount: f32) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var amount = arg_amount; - _ = &amount; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - result.x = v1.x + (amount * (v2.x - v1.x)); - result.y = v1.y + (amount * (v2.y - v1.y)); - result.z = v1.z + (amount * (v2.z - v1.z)); - return result; -} -pub fn Vector3CubicHermite(arg_v1: Vector3, arg_tangent1: Vector3, arg_v2: Vector3, arg_tangent2: Vector3, arg_amount: f32) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var tangent1 = arg_tangent1; - _ = &tangent1; - var v2 = arg_v2; - _ = &v2; - var tangent2 = arg_tangent2; - _ = &tangent2; - var amount = arg_amount; - _ = &amount; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var amountPow2: f32 = amount * amount; - _ = &amountPow2; - var amountPow3: f32 = (amount * amount) * amount; - _ = &amountPow3; - result.x = ((((((@as(f32, @floatFromInt(@as(c_int, 2))) * amountPow3) - (@as(f32, @floatFromInt(@as(c_int, 3))) * amountPow2)) + @as(f32, @floatFromInt(@as(c_int, 1)))) * v1.x) + (((amountPow3 - (@as(f32, @floatFromInt(@as(c_int, 2))) * amountPow2)) + amount) * tangent1.x)) + (((@as(f32, @floatFromInt(-@as(c_int, 2))) * amountPow3) + (@as(f32, @floatFromInt(@as(c_int, 3))) * amountPow2)) * v2.x)) + ((amountPow3 - amountPow2) * tangent2.x); - result.y = ((((((@as(f32, @floatFromInt(@as(c_int, 2))) * amountPow3) - (@as(f32, @floatFromInt(@as(c_int, 3))) * amountPow2)) + @as(f32, @floatFromInt(@as(c_int, 1)))) * v1.y) + (((amountPow3 - (@as(f32, @floatFromInt(@as(c_int, 2))) * amountPow2)) + amount) * tangent1.y)) + (((@as(f32, @floatFromInt(-@as(c_int, 2))) * amountPow3) + (@as(f32, @floatFromInt(@as(c_int, 3))) * amountPow2)) * v2.y)) + ((amountPow3 - amountPow2) * tangent2.y); - result.z = ((((((@as(f32, @floatFromInt(@as(c_int, 2))) * amountPow3) - (@as(f32, @floatFromInt(@as(c_int, 3))) * amountPow2)) + @as(f32, @floatFromInt(@as(c_int, 1)))) * v1.z) + (((amountPow3 - (@as(f32, @floatFromInt(@as(c_int, 2))) * amountPow2)) + amount) * tangent1.z)) + (((@as(f32, @floatFromInt(-@as(c_int, 2))) * amountPow3) + (@as(f32, @floatFromInt(@as(c_int, 3))) * amountPow2)) * v2.z)) + ((amountPow3 - amountPow2) * tangent2.z); - return result; -} -pub fn Vector3Reflect(arg_v: Vector3, arg_normal: Vector3) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var normal = arg_normal; - _ = &normal; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var dotProduct: f32 = ((v.x * normal.x) + (v.y * normal.y)) + (v.z * normal.z); - _ = &dotProduct; - result.x = v.x - ((2.0 * normal.x) * dotProduct); - result.y = v.y - ((2.0 * normal.y) * dotProduct); - result.z = v.z - ((2.0 * normal.z) * dotProduct); - return result; -} -pub fn Vector3Min(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - result.x = fminf(v1.x, v2.x); - result.y = fminf(v1.y, v2.y); - result.z = fminf(v1.z, v2.z); - return result; -} -pub fn Vector3Max(arg_v1: Vector3, arg_v2: Vector3) callconv(.C) Vector3 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - result.x = fmaxf(v1.x, v2.x); - result.y = fmaxf(v1.y, v2.y); - result.z = fmaxf(v1.z, v2.z); - return result; -} -pub fn Vector3Barycenter(arg_p: Vector3, arg_a: Vector3, arg_b: Vector3, arg_c: Vector3) callconv(.C) Vector3 { - var p = arg_p; - _ = &p; - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var c = arg_c; - _ = &c; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var v0: Vector3 = Vector3{ - .x = b.x - a.x, - .y = b.y - a.y, - .z = b.z - a.z, - }; - _ = &v0; - var v1: Vector3 = Vector3{ - .x = c.x - a.x, - .y = c.y - a.y, - .z = c.z - a.z, - }; - _ = &v1; - var v2: Vector3 = Vector3{ - .x = p.x - a.x, - .y = p.y - a.y, - .z = p.z - a.z, - }; - _ = &v2; - var d00: f32 = ((v0.x * v0.x) + (v0.y * v0.y)) + (v0.z * v0.z); - _ = &d00; - var d01: f32 = ((v0.x * v1.x) + (v0.y * v1.y)) + (v0.z * v1.z); - _ = &d01; - var d11: f32 = ((v1.x * v1.x) + (v1.y * v1.y)) + (v1.z * v1.z); - _ = &d11; - var d20: f32 = ((v2.x * v0.x) + (v2.y * v0.y)) + (v2.z * v0.z); - _ = &d20; - var d21: f32 = ((v2.x * v1.x) + (v2.y * v1.y)) + (v2.z * v1.z); - _ = &d21; - var denom: f32 = (d00 * d11) - (d01 * d01); - _ = &denom; - result.y = ((d11 * d20) - (d01 * d21)) / denom; - result.z = ((d00 * d21) - (d01 * d20)) / denom; - result.x = 1.0 - (result.z + result.y); - return result; -} -pub fn Vector3Unproject(arg_source: Vector3, arg_projection: Matrix, arg_view: Matrix) callconv(.C) Vector3 { - var source = arg_source; - _ = &source; - var projection = arg_projection; - _ = &projection; - var view = arg_view; - _ = &view; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var matViewProj: Matrix = Matrix{ - .m0 = (((view.m0 * projection.m0) + (view.m1 * projection.m4)) + (view.m2 * projection.m8)) + (view.m3 * projection.m12), - .m4 = (((view.m0 * projection.m1) + (view.m1 * projection.m5)) + (view.m2 * projection.m9)) + (view.m3 * projection.m13), - .m8 = (((view.m0 * projection.m2) + (view.m1 * projection.m6)) + (view.m2 * projection.m10)) + (view.m3 * projection.m14), - .m12 = (((view.m0 * projection.m3) + (view.m1 * projection.m7)) + (view.m2 * projection.m11)) + (view.m3 * projection.m15), - .m1 = (((view.m4 * projection.m0) + (view.m5 * projection.m4)) + (view.m6 * projection.m8)) + (view.m7 * projection.m12), - .m5 = (((view.m4 * projection.m1) + (view.m5 * projection.m5)) + (view.m6 * projection.m9)) + (view.m7 * projection.m13), - .m9 = (((view.m4 * projection.m2) + (view.m5 * projection.m6)) + (view.m6 * projection.m10)) + (view.m7 * projection.m14), - .m13 = (((view.m4 * projection.m3) + (view.m5 * projection.m7)) + (view.m6 * projection.m11)) + (view.m7 * projection.m15), - .m2 = (((view.m8 * projection.m0) + (view.m9 * projection.m4)) + (view.m10 * projection.m8)) + (view.m11 * projection.m12), - .m6 = (((view.m8 * projection.m1) + (view.m9 * projection.m5)) + (view.m10 * projection.m9)) + (view.m11 * projection.m13), - .m10 = (((view.m8 * projection.m2) + (view.m9 * projection.m6)) + (view.m10 * projection.m10)) + (view.m11 * projection.m14), - .m14 = (((view.m8 * projection.m3) + (view.m9 * projection.m7)) + (view.m10 * projection.m11)) + (view.m11 * projection.m15), - .m3 = (((view.m12 * projection.m0) + (view.m13 * projection.m4)) + (view.m14 * projection.m8)) + (view.m15 * projection.m12), - .m7 = (((view.m12 * projection.m1) + (view.m13 * projection.m5)) + (view.m14 * projection.m9)) + (view.m15 * projection.m13), - .m11 = (((view.m12 * projection.m2) + (view.m13 * projection.m6)) + (view.m14 * projection.m10)) + (view.m15 * projection.m14), - .m15 = (((view.m12 * projection.m3) + (view.m13 * projection.m7)) + (view.m14 * projection.m11)) + (view.m15 * projection.m15), - }; - _ = &matViewProj; - var a00: f32 = matViewProj.m0; - _ = &a00; - var a01: f32 = matViewProj.m1; - _ = &a01; - var a02: f32 = matViewProj.m2; - _ = &a02; - var a03: f32 = matViewProj.m3; - _ = &a03; - var a10: f32 = matViewProj.m4; - _ = &a10; - var a11: f32 = matViewProj.m5; - _ = &a11; - var a12: f32 = matViewProj.m6; - _ = &a12; - var a13: f32 = matViewProj.m7; - _ = &a13; - var a20: f32 = matViewProj.m8; - _ = &a20; - var a21: f32 = matViewProj.m9; - _ = &a21; - var a22: f32 = matViewProj.m10; - _ = &a22; - var a23: f32 = matViewProj.m11; - _ = &a23; - var a30: f32 = matViewProj.m12; - _ = &a30; - var a31: f32 = matViewProj.m13; - _ = &a31; - var a32: f32 = matViewProj.m14; - _ = &a32; - var a33: f32 = matViewProj.m15; - _ = &a33; - var b00: f32 = (a00 * a11) - (a01 * a10); - _ = &b00; - var b01: f32 = (a00 * a12) - (a02 * a10); - _ = &b01; - var b02: f32 = (a00 * a13) - (a03 * a10); - _ = &b02; - var b03: f32 = (a01 * a12) - (a02 * a11); - _ = &b03; - var b04: f32 = (a01 * a13) - (a03 * a11); - _ = &b04; - var b05: f32 = (a02 * a13) - (a03 * a12); - _ = &b05; - var b06: f32 = (a20 * a31) - (a21 * a30); - _ = &b06; - var b07: f32 = (a20 * a32) - (a22 * a30); - _ = &b07; - var b08: f32 = (a20 * a33) - (a23 * a30); - _ = &b08; - var b09: f32 = (a21 * a32) - (a22 * a31); - _ = &b09; - var b10: f32 = (a21 * a33) - (a23 * a31); - _ = &b10; - var b11: f32 = (a22 * a33) - (a23 * a32); - _ = &b11; - var invDet: f32 = 1.0 / ((((((b00 * b11) - (b01 * b10)) + (b02 * b09)) + (b03 * b08)) - (b04 * b07)) + (b05 * b06)); - _ = &invDet; - var matViewProjInv: Matrix = Matrix{ - .m0 = (((a11 * b11) - (a12 * b10)) + (a13 * b09)) * invDet, - .m4 = (((-a01 * b11) + (a02 * b10)) - (a03 * b09)) * invDet, - .m8 = (((a31 * b05) - (a32 * b04)) + (a33 * b03)) * invDet, - .m12 = (((-a21 * b05) + (a22 * b04)) - (a23 * b03)) * invDet, - .m1 = (((-a10 * b11) + (a12 * b08)) - (a13 * b07)) * invDet, - .m5 = (((a00 * b11) - (a02 * b08)) + (a03 * b07)) * invDet, - .m9 = (((-a30 * b05) + (a32 * b02)) - (a33 * b01)) * invDet, - .m13 = (((a20 * b05) - (a22 * b02)) + (a23 * b01)) * invDet, - .m2 = (((a10 * b10) - (a11 * b08)) + (a13 * b06)) * invDet, - .m6 = (((-a00 * b10) + (a01 * b08)) - (a03 * b06)) * invDet, - .m10 = (((a30 * b04) - (a31 * b02)) + (a33 * b00)) * invDet, - .m14 = (((-a20 * b04) + (a21 * b02)) - (a23 * b00)) * invDet, - .m3 = (((-a10 * b09) + (a11 * b07)) - (a12 * b06)) * invDet, - .m7 = (((a00 * b09) - (a01 * b07)) + (a02 * b06)) * invDet, - .m11 = (((-a30 * b03) + (a31 * b01)) - (a32 * b00)) * invDet, - .m15 = (((a20 * b03) - (a21 * b01)) + (a22 * b00)) * invDet, - }; - _ = &matViewProjInv; - var quat: Quaternion = Quaternion{ - .x = source.x, - .y = source.y, - .z = source.z, - .w = 1.0, - }; - _ = &quat; - var qtransformed: Quaternion = Quaternion{ - .x = (((matViewProjInv.m0 * quat.x) + (matViewProjInv.m4 * quat.y)) + (matViewProjInv.m8 * quat.z)) + (matViewProjInv.m12 * quat.w), - .y = (((matViewProjInv.m1 * quat.x) + (matViewProjInv.m5 * quat.y)) + (matViewProjInv.m9 * quat.z)) + (matViewProjInv.m13 * quat.w), - .z = (((matViewProjInv.m2 * quat.x) + (matViewProjInv.m6 * quat.y)) + (matViewProjInv.m10 * quat.z)) + (matViewProjInv.m14 * quat.w), - .w = (((matViewProjInv.m3 * quat.x) + (matViewProjInv.m7 * quat.y)) + (matViewProjInv.m11 * quat.z)) + (matViewProjInv.m15 * quat.w), - }; - _ = &qtransformed; - result.x = qtransformed.x / qtransformed.w; - result.y = qtransformed.y / qtransformed.w; - result.z = qtransformed.z / qtransformed.w; - return result; -} -pub fn Vector3ToFloatV(arg_v: Vector3) callconv(.C) float3 { - var v = arg_v; - _ = &v; - var buffer: float3 = float3{ - .v = [1]f32{ - 0, - } ++ [1]f32{0} ** 2, - }; - _ = &buffer; - buffer.v[@as(c_uint, @intCast(@as(c_int, 0)))] = v.x; - buffer.v[@as(c_uint, @intCast(@as(c_int, 1)))] = v.y; - buffer.v[@as(c_uint, @intCast(@as(c_int, 2)))] = v.z; - return buffer; -} -pub fn Vector3Invert(arg_v: Vector3) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var result: Vector3 = Vector3{ - .x = 1.0 / v.x, - .y = 1.0 / v.y, - .z = 1.0 / v.z, - }; - _ = &result; - return result; -} -pub fn Vector3Clamp(arg_v: Vector3, arg_min: Vector3, arg_max: Vector3) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var min = arg_min; - _ = &min; - var max = arg_max; - _ = &max; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - result.x = fminf(max.x, fmaxf(min.x, v.x)); - result.y = fminf(max.y, fmaxf(min.y, v.y)); - result.z = fminf(max.z, fmaxf(min.z, v.z)); - return result; -} -pub fn Vector3ClampValue(arg_v: Vector3, arg_min: f32, arg_max: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var min = arg_min; - _ = &min; - var max = arg_max; - _ = &max; - var result: Vector3 = v; - _ = &result; - var length: f32 = ((v.x * v.x) + (v.y * v.y)) + (v.z * v.z); - _ = &length; - if (length > 0.0) { - length = sqrtf(length); - var scale: f32 = 1; - _ = &scale; - if (length < min) { - scale = min / length; - } else if (length > max) { - scale = max / length; - } - result.x = v.x * scale; - result.y = v.y * scale; - result.z = v.z * scale; - } - return result; -} -pub fn Vector3Equals(arg_p: Vector3, arg_q: Vector3) callconv(.C) c_int { - var p = arg_p; - _ = &p; - var q = arg_q; - _ = &q; - var result: c_int = @intFromBool(((fabsf(p.x - q.x) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.x), fabsf(q.x))))) and (fabsf(p.y - q.y) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.y), fabsf(q.y)))))) and (fabsf(p.z - q.z) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.z), fabsf(q.z)))))); - _ = &result; - return result; -} -pub fn Vector3Refract(arg_v: Vector3, arg_n: Vector3, arg_r: f32) callconv(.C) Vector3 { - var v = arg_v; - _ = &v; - var n = arg_n; - _ = &n; - var r = arg_r; - _ = &r; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var dot: f32 = ((v.x * n.x) + (v.y * n.y)) + (v.z * n.z); - _ = ˙ - var d: f32 = 1.0 - ((r * r) * (1.0 - (dot * dot))); - _ = &d; - if (d >= 0.0) { - d = sqrtf(d); - v.x = (r * v.x) - (((r * dot) + d) * n.x); - v.y = (r * v.y) - (((r * dot) + d) * n.y); - v.z = (r * v.z) - (((r * dot) + d) * n.z); - result = v; - } - return result; -} -pub fn Vector4Zero() callconv(.C) Vector4 { - var result: Vector4 = Vector4{ - .x = 0.0, - .y = 0.0, - .z = 0.0, - .w = 0.0, - }; - _ = &result; - return result; -} -pub fn Vector4One() callconv(.C) Vector4 { - var result: Vector4 = Vector4{ - .x = 1.0, - .y = 1.0, - .z = 1.0, - .w = 1.0, - }; - _ = &result; - return result; -} -pub fn Vector4Add(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector4 = Vector4{ - .x = v1.x + v2.x, - .y = v1.y + v2.y, - .z = v1.z + v2.z, - .w = v1.w + v2.w, - }; - _ = &result; - return result; -} -pub fn Vector4AddValue(arg_v: Vector4, arg_add: f32) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var add = arg_add; - _ = &add; - var result: Vector4 = Vector4{ - .x = v.x + add, - .y = v.y + add, - .z = v.z + add, - .w = v.w + add, - }; - _ = &result; - return result; -} -pub fn Vector4Subtract(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector4 = Vector4{ - .x = v1.x - v2.x, - .y = v1.y - v2.y, - .z = v1.z - v2.z, - .w = v1.w - v2.w, - }; - _ = &result; - return result; -} -pub fn Vector4SubtractValue(arg_v: Vector4, arg_add: f32) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var add = arg_add; - _ = &add; - var result: Vector4 = Vector4{ - .x = v.x - add, - .y = v.y - add, - .z = v.z - add, - .w = v.w - add, - }; - _ = &result; - return result; -} -pub fn Vector4Length(arg_v: Vector4) callconv(.C) f32 { - var v = arg_v; - _ = &v; - var result: f32 = sqrtf((((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)) + (v.w * v.w)); - _ = &result; - return result; -} -pub fn Vector4LengthSqr(arg_v: Vector4) callconv(.C) f32 { - var v = arg_v; - _ = &v; - var result: f32 = (((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)) + (v.w * v.w); - _ = &result; - return result; -} -pub fn Vector4DotProduct(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = (((v1.x * v2.x) + (v1.y * v2.y)) + (v1.z * v2.z)) + (v1.w * v2.w); - _ = &result; - return result; -} -pub fn Vector4Distance(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = sqrtf(((((v1.x - v2.x) * (v1.x - v2.x)) + ((v1.y - v2.y) * (v1.y - v2.y))) + ((v1.z - v2.z) * (v1.z - v2.z))) + ((v1.w - v2.w) * (v1.w - v2.w))); - _ = &result; - return result; -} -pub fn Vector4DistanceSqr(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) f32 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: f32 = ((((v1.x - v2.x) * (v1.x - v2.x)) + ((v1.y - v2.y) * (v1.y - v2.y))) + ((v1.z - v2.z) * (v1.z - v2.z))) + ((v1.w - v2.w) * (v1.w - v2.w)); - _ = &result; - return result; -} -pub fn Vector4Scale(arg_v: Vector4, arg_scale: f32) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var scale = arg_scale; - _ = &scale; - var result: Vector4 = Vector4{ - .x = v.x * scale, - .y = v.y * scale, - .z = v.z * scale, - .w = v.w * scale, - }; - _ = &result; - return result; -} -pub fn Vector4Multiply(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector4 = Vector4{ - .x = v1.x * v2.x, - .y = v1.y * v2.y, - .z = v1.z * v2.z, - .w = v1.w * v2.w, - }; - _ = &result; - return result; -} -pub fn Vector4Negate(arg_v: Vector4) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var result: Vector4 = Vector4{ - .x = -v.x, - .y = -v.y, - .z = -v.z, - .w = -v.w, - }; - _ = &result; - return result; -} -pub fn Vector4Divide(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector4 = Vector4{ - .x = v1.x / v2.x, - .y = v1.y / v2.y, - .z = v1.z / v2.z, - .w = v1.w / v2.w, - }; - _ = &result; - return result; -} -pub fn Vector4Normalize(arg_v: Vector4) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var result: Vector4 = Vector4{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var length: f32 = sqrtf((((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)) + (v.w * v.w)); - _ = &length; - if (length > @as(f32, @floatFromInt(@as(c_int, 0)))) { - var ilength: f32 = 1.0 / length; - _ = &ilength; - result.x = v.x * ilength; - result.y = v.y * ilength; - result.z = v.z * ilength; - result.w = v.w * ilength; - } - return result; -} -pub fn Vector4Min(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector4 = Vector4{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = fminf(v1.x, v2.x); - result.y = fminf(v1.y, v2.y); - result.z = fminf(v1.z, v2.z); - result.w = fminf(v1.w, v2.w); - return result; -} -pub fn Vector4Max(arg_v1: Vector4, arg_v2: Vector4) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var result: Vector4 = Vector4{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = fmaxf(v1.x, v2.x); - result.y = fmaxf(v1.y, v2.y); - result.z = fmaxf(v1.z, v2.z); - result.w = fmaxf(v1.w, v2.w); - return result; -} -pub fn Vector4Lerp(arg_v1: Vector4, arg_v2: Vector4, arg_amount: f32) callconv(.C) Vector4 { - var v1 = arg_v1; - _ = &v1; - var v2 = arg_v2; - _ = &v2; - var amount = arg_amount; - _ = &amount; - var result: Vector4 = Vector4{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = v1.x + (amount * (v2.x - v1.x)); - result.y = v1.y + (amount * (v2.y - v1.y)); - result.z = v1.z + (amount * (v2.z - v1.z)); - result.w = v1.w + (amount * (v2.w - v1.w)); - return result; -} -pub fn Vector4MoveTowards(arg_v: Vector4, arg_target: Vector4, arg_maxDistance: f32) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var target = arg_target; - _ = ⌖ - var maxDistance = arg_maxDistance; - _ = &maxDistance; - var result: Vector4 = Vector4{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var dx: f32 = target.x - v.x; - _ = &dx; - var dy: f32 = target.y - v.y; - _ = &dy; - var dz: f32 = target.z - v.z; - _ = &dz; - var dw: f32 = target.w - v.w; - _ = &dw; - var value: f32 = (((dx * dx) + (dy * dy)) + (dz * dz)) + (dw * dw); - _ = &value; - if ((value == @as(f32, @floatFromInt(@as(c_int, 0)))) or ((maxDistance >= @as(f32, @floatFromInt(@as(c_int, 0)))) and (value <= (maxDistance * maxDistance)))) return target; - var dist: f32 = sqrtf(value); - _ = &dist; - result.x = v.x + ((dx / dist) * maxDistance); - result.y = v.y + ((dy / dist) * maxDistance); - result.z = v.z + ((dz / dist) * maxDistance); - result.w = v.w + ((dw / dist) * maxDistance); - return result; -} -pub fn Vector4Invert(arg_v: Vector4) callconv(.C) Vector4 { - var v = arg_v; - _ = &v; - var result: Vector4 = Vector4{ - .x = 1.0 / v.x, - .y = 1.0 / v.y, - .z = 1.0 / v.z, - .w = 1.0 / v.w, - }; - _ = &result; - return result; -} -pub fn Vector4Equals(arg_p: Vector4, arg_q: Vector4) callconv(.C) c_int { - var p = arg_p; - _ = &p; - var q = arg_q; - _ = &q; - var result: c_int = @intFromBool((((fabsf(p.x - q.x) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.x), fabsf(q.x))))) and (fabsf(p.y - q.y) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.y), fabsf(q.y)))))) and (fabsf(p.z - q.z) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.z), fabsf(q.z)))))) and (fabsf(p.w - q.w) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.w), fabsf(q.w)))))); - _ = &result; - return result; -} -pub fn MatrixDeterminant(arg_mat: Matrix) callconv(.C) f32 { - var mat = arg_mat; - _ = &mat; - var result: f32 = 0.0; - _ = &result; - var a00: f32 = mat.m0; - _ = &a00; - var a01: f32 = mat.m1; - _ = &a01; - var a02: f32 = mat.m2; - _ = &a02; - var a03: f32 = mat.m3; - _ = &a03; - var a10: f32 = mat.m4; - _ = &a10; - var a11: f32 = mat.m5; - _ = &a11; - var a12: f32 = mat.m6; - _ = &a12; - var a13: f32 = mat.m7; - _ = &a13; - var a20: f32 = mat.m8; - _ = &a20; - var a21: f32 = mat.m9; - _ = &a21; - var a22: f32 = mat.m10; - _ = &a22; - var a23: f32 = mat.m11; - _ = &a23; - var a30: f32 = mat.m12; - _ = &a30; - var a31: f32 = mat.m13; - _ = &a31; - var a32: f32 = mat.m14; - _ = &a32; - var a33: f32 = mat.m15; - _ = &a33; - result = (((((((((((((((((((((((((a30 * a21) * a12) * a03) - (((a20 * a31) * a12) * a03)) - (((a30 * a11) * a22) * a03)) + (((a10 * a31) * a22) * a03)) + (((a20 * a11) * a32) * a03)) - (((a10 * a21) * a32) * a03)) - (((a30 * a21) * a02) * a13)) + (((a20 * a31) * a02) * a13)) + (((a30 * a01) * a22) * a13)) - (((a00 * a31) * a22) * a13)) - (((a20 * a01) * a32) * a13)) + (((a00 * a21) * a32) * a13)) + (((a30 * a11) * a02) * a23)) - (((a10 * a31) * a02) * a23)) - (((a30 * a01) * a12) * a23)) + (((a00 * a31) * a12) * a23)) + (((a10 * a01) * a32) * a23)) - (((a00 * a11) * a32) * a23)) - (((a20 * a11) * a02) * a33)) + (((a10 * a21) * a02) * a33)) + (((a20 * a01) * a12) * a33)) - (((a00 * a21) * a12) * a33)) - (((a10 * a01) * a22) * a33)) + (((a00 * a11) * a22) * a33); - return result; -} -pub fn MatrixTrace(arg_mat: Matrix) callconv(.C) f32 { - var mat = arg_mat; - _ = &mat; - var result: f32 = ((mat.m0 + mat.m5) + mat.m10) + mat.m15; - _ = &result; - return result; -} -pub fn MatrixTranspose(arg_mat: Matrix) callconv(.C) Matrix { - var mat = arg_mat; - _ = &mat; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - result.m0 = mat.m0; - result.m1 = mat.m4; - result.m2 = mat.m8; - result.m3 = mat.m12; - result.m4 = mat.m1; - result.m5 = mat.m5; - result.m6 = mat.m9; - result.m7 = mat.m13; - result.m8 = mat.m2; - result.m9 = mat.m6; - result.m10 = mat.m10; - result.m11 = mat.m14; - result.m12 = mat.m3; - result.m13 = mat.m7; - result.m14 = mat.m11; - result.m15 = mat.m15; - return result; -} -pub fn MatrixInvert(arg_mat: Matrix) callconv(.C) Matrix { - var mat = arg_mat; - _ = &mat; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var a00: f32 = mat.m0; - _ = &a00; - var a01: f32 = mat.m1; - _ = &a01; - var a02: f32 = mat.m2; - _ = &a02; - var a03: f32 = mat.m3; - _ = &a03; - var a10: f32 = mat.m4; - _ = &a10; - var a11: f32 = mat.m5; - _ = &a11; - var a12: f32 = mat.m6; - _ = &a12; - var a13: f32 = mat.m7; - _ = &a13; - var a20: f32 = mat.m8; - _ = &a20; - var a21: f32 = mat.m9; - _ = &a21; - var a22: f32 = mat.m10; - _ = &a22; - var a23: f32 = mat.m11; - _ = &a23; - var a30: f32 = mat.m12; - _ = &a30; - var a31: f32 = mat.m13; - _ = &a31; - var a32: f32 = mat.m14; - _ = &a32; - var a33: f32 = mat.m15; - _ = &a33; - var b00: f32 = (a00 * a11) - (a01 * a10); - _ = &b00; - var b01: f32 = (a00 * a12) - (a02 * a10); - _ = &b01; - var b02: f32 = (a00 * a13) - (a03 * a10); - _ = &b02; - var b03: f32 = (a01 * a12) - (a02 * a11); - _ = &b03; - var b04: f32 = (a01 * a13) - (a03 * a11); - _ = &b04; - var b05: f32 = (a02 * a13) - (a03 * a12); - _ = &b05; - var b06: f32 = (a20 * a31) - (a21 * a30); - _ = &b06; - var b07: f32 = (a20 * a32) - (a22 * a30); - _ = &b07; - var b08: f32 = (a20 * a33) - (a23 * a30); - _ = &b08; - var b09: f32 = (a21 * a32) - (a22 * a31); - _ = &b09; - var b10: f32 = (a21 * a33) - (a23 * a31); - _ = &b10; - var b11: f32 = (a22 * a33) - (a23 * a32); - _ = &b11; - var invDet: f32 = 1.0 / ((((((b00 * b11) - (b01 * b10)) + (b02 * b09)) + (b03 * b08)) - (b04 * b07)) + (b05 * b06)); - _ = &invDet; - result.m0 = (((a11 * b11) - (a12 * b10)) + (a13 * b09)) * invDet; - result.m1 = (((-a01 * b11) + (a02 * b10)) - (a03 * b09)) * invDet; - result.m2 = (((a31 * b05) - (a32 * b04)) + (a33 * b03)) * invDet; - result.m3 = (((-a21 * b05) + (a22 * b04)) - (a23 * b03)) * invDet; - result.m4 = (((-a10 * b11) + (a12 * b08)) - (a13 * b07)) * invDet; - result.m5 = (((a00 * b11) - (a02 * b08)) + (a03 * b07)) * invDet; - result.m6 = (((-a30 * b05) + (a32 * b02)) - (a33 * b01)) * invDet; - result.m7 = (((a20 * b05) - (a22 * b02)) + (a23 * b01)) * invDet; - result.m8 = (((a10 * b10) - (a11 * b08)) + (a13 * b06)) * invDet; - result.m9 = (((-a00 * b10) + (a01 * b08)) - (a03 * b06)) * invDet; - result.m10 = (((a30 * b04) - (a31 * b02)) + (a33 * b00)) * invDet; - result.m11 = (((-a20 * b04) + (a21 * b02)) - (a23 * b00)) * invDet; - result.m12 = (((-a10 * b09) + (a11 * b07)) - (a12 * b06)) * invDet; - result.m13 = (((a00 * b09) - (a01 * b07)) + (a02 * b06)) * invDet; - result.m14 = (((-a30 * b03) + (a31 * b01)) - (a32 * b00)) * invDet; - result.m15 = (((a20 * b03) - (a21 * b01)) + (a22 * b00)) * invDet; - return result; -} -pub fn MatrixIdentity() callconv(.C) Matrix { - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - return result; -} -pub fn MatrixAdd(arg_left: Matrix, arg_right: Matrix) callconv(.C) Matrix { - var left = arg_left; - _ = &left; - var right = arg_right; - _ = &right; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - result.m0 = left.m0 + right.m0; - result.m1 = left.m1 + right.m1; - result.m2 = left.m2 + right.m2; - result.m3 = left.m3 + right.m3; - result.m4 = left.m4 + right.m4; - result.m5 = left.m5 + right.m5; - result.m6 = left.m6 + right.m6; - result.m7 = left.m7 + right.m7; - result.m8 = left.m8 + right.m8; - result.m9 = left.m9 + right.m9; - result.m10 = left.m10 + right.m10; - result.m11 = left.m11 + right.m11; - result.m12 = left.m12 + right.m12; - result.m13 = left.m13 + right.m13; - result.m14 = left.m14 + right.m14; - result.m15 = left.m15 + right.m15; - return result; -} -pub fn MatrixSubtract(arg_left: Matrix, arg_right: Matrix) callconv(.C) Matrix { - var left = arg_left; - _ = &left; - var right = arg_right; - _ = &right; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - result.m0 = left.m0 - right.m0; - result.m1 = left.m1 - right.m1; - result.m2 = left.m2 - right.m2; - result.m3 = left.m3 - right.m3; - result.m4 = left.m4 - right.m4; - result.m5 = left.m5 - right.m5; - result.m6 = left.m6 - right.m6; - result.m7 = left.m7 - right.m7; - result.m8 = left.m8 - right.m8; - result.m9 = left.m9 - right.m9; - result.m10 = left.m10 - right.m10; - result.m11 = left.m11 - right.m11; - result.m12 = left.m12 - right.m12; - result.m13 = left.m13 - right.m13; - result.m14 = left.m14 - right.m14; - result.m15 = left.m15 - right.m15; - return result; -} -pub fn MatrixMultiply(arg_left: Matrix, arg_right: Matrix) callconv(.C) Matrix { - var left = arg_left; - _ = &left; - var right = arg_right; - _ = &right; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - result.m0 = (((left.m0 * right.m0) + (left.m1 * right.m4)) + (left.m2 * right.m8)) + (left.m3 * right.m12); - result.m1 = (((left.m0 * right.m1) + (left.m1 * right.m5)) + (left.m2 * right.m9)) + (left.m3 * right.m13); - result.m2 = (((left.m0 * right.m2) + (left.m1 * right.m6)) + (left.m2 * right.m10)) + (left.m3 * right.m14); - result.m3 = (((left.m0 * right.m3) + (left.m1 * right.m7)) + (left.m2 * right.m11)) + (left.m3 * right.m15); - result.m4 = (((left.m4 * right.m0) + (left.m5 * right.m4)) + (left.m6 * right.m8)) + (left.m7 * right.m12); - result.m5 = (((left.m4 * right.m1) + (left.m5 * right.m5)) + (left.m6 * right.m9)) + (left.m7 * right.m13); - result.m6 = (((left.m4 * right.m2) + (left.m5 * right.m6)) + (left.m6 * right.m10)) + (left.m7 * right.m14); - result.m7 = (((left.m4 * right.m3) + (left.m5 * right.m7)) + (left.m6 * right.m11)) + (left.m7 * right.m15); - result.m8 = (((left.m8 * right.m0) + (left.m9 * right.m4)) + (left.m10 * right.m8)) + (left.m11 * right.m12); - result.m9 = (((left.m8 * right.m1) + (left.m9 * right.m5)) + (left.m10 * right.m9)) + (left.m11 * right.m13); - result.m10 = (((left.m8 * right.m2) + (left.m9 * right.m6)) + (left.m10 * right.m10)) + (left.m11 * right.m14); - result.m11 = (((left.m8 * right.m3) + (left.m9 * right.m7)) + (left.m10 * right.m11)) + (left.m11 * right.m15); - result.m12 = (((left.m12 * right.m0) + (left.m13 * right.m4)) + (left.m14 * right.m8)) + (left.m15 * right.m12); - result.m13 = (((left.m12 * right.m1) + (left.m13 * right.m5)) + (left.m14 * right.m9)) + (left.m15 * right.m13); - result.m14 = (((left.m12 * right.m2) + (left.m13 * right.m6)) + (left.m14 * right.m10)) + (left.m15 * right.m14); - result.m15 = (((left.m12 * right.m3) + (left.m13 * right.m7)) + (left.m14 * right.m11)) + (left.m15 * right.m15); - return result; -} -pub fn MatrixTranslate(arg_x: f32, arg_y: f32, arg_z: f32) callconv(.C) Matrix { - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = x, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = y, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = z, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - return result; -} -pub fn MatrixRotate(arg_axis: Vector3, arg_angle: f32) callconv(.C) Matrix { - var axis = arg_axis; - _ = &axis; - var angle = arg_angle; - _ = ∠ - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var x: f32 = axis.x; - _ = &x; - var y: f32 = axis.y; - _ = &y; - var z: f32 = axis.z; - _ = &z; - var lengthSquared: f32 = ((x * x) + (y * y)) + (z * z); - _ = &lengthSquared; - if ((lengthSquared != 1.0) and (lengthSquared != 0.0)) { - var ilength: f32 = 1.0 / sqrtf(lengthSquared); - _ = &ilength; - x *= ilength; - y *= ilength; - z *= ilength; - } - var sinres: f32 = sinf(angle); - _ = &sinres; - var cosres: f32 = cosf(angle); - _ = &cosres; - var t: f32 = 1.0 - cosres; - _ = &t; - result.m0 = ((x * x) * t) + cosres; - result.m1 = ((y * x) * t) + (z * sinres); - result.m2 = ((z * x) * t) - (y * sinres); - result.m3 = 0.0; - result.m4 = ((x * y) * t) - (z * sinres); - result.m5 = ((y * y) * t) + cosres; - result.m6 = ((z * y) * t) + (x * sinres); - result.m7 = 0.0; - result.m8 = ((x * z) * t) + (y * sinres); - result.m9 = ((y * z) * t) - (x * sinres); - result.m10 = ((z * z) * t) + cosres; - result.m11 = 0.0; - result.m12 = 0.0; - result.m13 = 0.0; - result.m14 = 0.0; - result.m15 = 1.0; - return result; -} -pub fn MatrixRotateX(arg_angle: f32) callconv(.C) Matrix { - var angle = arg_angle; - _ = ∠ - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - var cosres: f32 = cosf(angle); - _ = &cosres; - var sinres: f32 = sinf(angle); - _ = &sinres; - result.m5 = cosres; - result.m6 = sinres; - result.m9 = -sinres; - result.m10 = cosres; - return result; -} -pub fn MatrixRotateY(arg_angle: f32) callconv(.C) Matrix { - var angle = arg_angle; - _ = ∠ - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - var cosres: f32 = cosf(angle); - _ = &cosres; - var sinres: f32 = sinf(angle); - _ = &sinres; - result.m0 = cosres; - result.m2 = -sinres; - result.m8 = sinres; - result.m10 = cosres; - return result; -} -pub fn MatrixRotateZ(arg_angle: f32) callconv(.C) Matrix { - var angle = arg_angle; - _ = ∠ - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - var cosres: f32 = cosf(angle); - _ = &cosres; - var sinres: f32 = sinf(angle); - _ = &sinres; - result.m0 = cosres; - result.m1 = sinres; - result.m4 = -sinres; - result.m5 = cosres; - return result; -} -pub fn MatrixRotateXYZ(arg_angle: Vector3) callconv(.C) Matrix { - var angle = arg_angle; - _ = ∠ - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - var cosz: f32 = cosf(-angle.z); - _ = &cosz; - var sinz: f32 = sinf(-angle.z); - _ = &sinz; - var cosy: f32 = cosf(-angle.y); - _ = &cosy; - var siny: f32 = sinf(-angle.y); - _ = &siny; - var cosx: f32 = cosf(-angle.x); - _ = &cosx; - var sinx: f32 = sinf(-angle.x); - _ = &sinx; - result.m0 = cosz * cosy; - result.m1 = ((cosz * siny) * sinx) - (sinz * cosx); - result.m2 = ((cosz * siny) * cosx) + (sinz * sinx); - result.m4 = sinz * cosy; - result.m5 = ((sinz * siny) * sinx) + (cosz * cosx); - result.m6 = ((sinz * siny) * cosx) - (cosz * sinx); - result.m8 = -siny; - result.m9 = cosy * sinx; - result.m10 = cosy * cosx; - return result; -} -pub fn MatrixRotateZYX(arg_angle: Vector3) callconv(.C) Matrix { - var angle = arg_angle; - _ = ∠ - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var cz: f32 = cosf(angle.z); - _ = &cz; - var sz: f32 = sinf(angle.z); - _ = &sz; - var cy: f32 = cosf(angle.y); - _ = &cy; - var sy: f32 = sinf(angle.y); - _ = &sy; - var cx: f32 = cosf(angle.x); - _ = &cx; - var sx: f32 = sinf(angle.x); - _ = &sx; - result.m0 = cz * cy; - result.m4 = ((cz * sy) * sx) - (cx * sz); - result.m8 = (sz * sx) + ((cz * cx) * sy); - result.m12 = 0; - result.m1 = cy * sz; - result.m5 = (cz * cx) + ((sz * sy) * sx); - result.m9 = ((cx * sz) * sy) - (cz * sx); - result.m13 = 0; - result.m2 = -sy; - result.m6 = cy * sx; - result.m10 = cy * cx; - result.m14 = 0; - result.m3 = 0; - result.m7 = 0; - result.m11 = 0; - result.m15 = 1; - return result; -} -pub fn MatrixScale(arg_x: f32, arg_y: f32, arg_z: f32) callconv(.C) Matrix { - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var result: Matrix = Matrix{ - .m0 = x, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = y, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = z, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - return result; -} -pub fn MatrixFrustum(arg_left: f64, arg_right: f64, arg_bottom: f64, arg_top: f64, arg_nearPlane: f64, arg_farPlane: f64) callconv(.C) Matrix { - var left = arg_left; - _ = &left; - var right = arg_right; - _ = &right; - var bottom = arg_bottom; - _ = ⊥ - var top = arg_top; - _ = ⊤ - var nearPlane = arg_nearPlane; - _ = &nearPlane; - var farPlane = arg_farPlane; - _ = &farPlane; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var rl: f32 = @as(f32, @floatCast(right - left)); - _ = &rl; - var tb: f32 = @as(f32, @floatCast(top - bottom)); - _ = &tb; - var @"fn": f32 = @as(f32, @floatCast(farPlane - nearPlane)); - _ = &@"fn"; - result.m0 = (@as(f32, @floatCast(nearPlane)) * 2.0) / rl; - result.m1 = 0.0; - result.m2 = 0.0; - result.m3 = 0.0; - result.m4 = 0.0; - result.m5 = (@as(f32, @floatCast(nearPlane)) * 2.0) / tb; - result.m6 = 0.0; - result.m7 = 0.0; - result.m8 = (@as(f32, @floatCast(right)) + @as(f32, @floatCast(left))) / rl; - result.m9 = (@as(f32, @floatCast(top)) + @as(f32, @floatCast(bottom))) / tb; - result.m10 = -(@as(f32, @floatCast(farPlane)) + @as(f32, @floatCast(nearPlane))) / @"fn"; - result.m11 = -1.0; - result.m12 = 0.0; - result.m13 = 0.0; - result.m14 = -((@as(f32, @floatCast(farPlane)) * @as(f32, @floatCast(nearPlane))) * 2.0) / @"fn"; - result.m15 = 0.0; - return result; -} -pub fn MatrixPerspective(arg_fovY: f64, arg_aspect: f64, arg_nearPlane: f64, arg_farPlane: f64) callconv(.C) Matrix { - var fovY = arg_fovY; - _ = &fovY; - var aspect = arg_aspect; - _ = &aspect; - var nearPlane = arg_nearPlane; - _ = &nearPlane; - var farPlane = arg_farPlane; - _ = &farPlane; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var top: f64 = nearPlane * tan(fovY * 0.5); - _ = ⊤ - var bottom: f64 = -top; - _ = ⊥ - var right: f64 = top * aspect; - _ = &right; - var left: f64 = -right; - _ = &left; - var rl: f32 = @as(f32, @floatCast(right - left)); - _ = &rl; - var tb: f32 = @as(f32, @floatCast(top - bottom)); - _ = &tb; - var @"fn": f32 = @as(f32, @floatCast(farPlane - nearPlane)); - _ = &@"fn"; - result.m0 = (@as(f32, @floatCast(nearPlane)) * 2.0) / rl; - result.m5 = (@as(f32, @floatCast(nearPlane)) * 2.0) / tb; - result.m8 = (@as(f32, @floatCast(right)) + @as(f32, @floatCast(left))) / rl; - result.m9 = (@as(f32, @floatCast(top)) + @as(f32, @floatCast(bottom))) / tb; - result.m10 = -(@as(f32, @floatCast(farPlane)) + @as(f32, @floatCast(nearPlane))) / @"fn"; - result.m11 = -1.0; - result.m14 = -((@as(f32, @floatCast(farPlane)) * @as(f32, @floatCast(nearPlane))) * 2.0) / @"fn"; - return result; -} -pub fn MatrixOrtho(arg_left: f64, arg_right: f64, arg_bottom: f64, arg_top: f64, arg_nearPlane: f64, arg_farPlane: f64) callconv(.C) Matrix { - var left = arg_left; - _ = &left; - var right = arg_right; - _ = &right; - var bottom = arg_bottom; - _ = ⊥ - var top = arg_top; - _ = ⊤ - var nearPlane = arg_nearPlane; - _ = &nearPlane; - var farPlane = arg_farPlane; - _ = &farPlane; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var rl: f32 = @as(f32, @floatCast(right - left)); - _ = &rl; - var tb: f32 = @as(f32, @floatCast(top - bottom)); - _ = &tb; - var @"fn": f32 = @as(f32, @floatCast(farPlane - nearPlane)); - _ = &@"fn"; - result.m0 = 2.0 / rl; - result.m1 = 0.0; - result.m2 = 0.0; - result.m3 = 0.0; - result.m4 = 0.0; - result.m5 = 2.0 / tb; - result.m6 = 0.0; - result.m7 = 0.0; - result.m8 = 0.0; - result.m9 = 0.0; - result.m10 = -2.0 / @"fn"; - result.m11 = 0.0; - result.m12 = -(@as(f32, @floatCast(left)) + @as(f32, @floatCast(right))) / rl; - result.m13 = -(@as(f32, @floatCast(top)) + @as(f32, @floatCast(bottom))) / tb; - result.m14 = -(@as(f32, @floatCast(farPlane)) + @as(f32, @floatCast(nearPlane))) / @"fn"; - result.m15 = 1.0; - return result; -} -pub fn MatrixLookAt(arg_eye: Vector3, arg_target: Vector3, arg_up: Vector3) callconv(.C) Matrix { - var eye = arg_eye; - _ = &eye; - var target = arg_target; - _ = ⌖ - var up = arg_up; - _ = &up; - var result: Matrix = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }; - _ = &result; - var length: f32 = 0.0; - _ = &length; - var ilength: f32 = 0.0; - _ = &ilength; - var vz: Vector3 = Vector3{ - .x = eye.x - target.x, - .y = eye.y - target.y, - .z = eye.z - target.z, - }; - _ = &vz; - var v: Vector3 = vz; - _ = &v; - length = sqrtf(((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)); - if (length == 0.0) { - length = 1.0; - } - ilength = 1.0 / length; - vz.x *= ilength; - vz.y *= ilength; - vz.z *= ilength; - var vx: Vector3 = Vector3{ - .x = (up.y * vz.z) - (up.z * vz.y), - .y = (up.z * vz.x) - (up.x * vz.z), - .z = (up.x * vz.y) - (up.y * vz.x), - }; - _ = &vx; - v = vx; - length = sqrtf(((v.x * v.x) + (v.y * v.y)) + (v.z * v.z)); - if (length == 0.0) { - length = 1.0; - } - ilength = 1.0 / length; - vx.x *= ilength; - vx.y *= ilength; - vx.z *= ilength; - var vy: Vector3 = Vector3{ - .x = (vz.y * vx.z) - (vz.z * vx.y), - .y = (vz.z * vx.x) - (vz.x * vx.z), - .z = (vz.x * vx.y) - (vz.y * vx.x), - }; - _ = &vy; - result.m0 = vx.x; - result.m1 = vy.x; - result.m2 = vz.x; - result.m3 = 0.0; - result.m4 = vx.y; - result.m5 = vy.y; - result.m6 = vz.y; - result.m7 = 0.0; - result.m8 = vx.z; - result.m9 = vy.z; - result.m10 = vz.z; - result.m11 = 0.0; - result.m12 = -(((vx.x * eye.x) + (vx.y * eye.y)) + (vx.z * eye.z)); - result.m13 = -(((vy.x * eye.x) + (vy.y * eye.y)) + (vy.z * eye.z)); - result.m14 = -(((vz.x * eye.x) + (vz.y * eye.y)) + (vz.z * eye.z)); - result.m15 = 1.0; - return result; -} -pub fn MatrixToFloatV(arg_mat: Matrix) callconv(.C) float16 { - var mat = arg_mat; - _ = &mat; - var result: float16 = float16{ - .v = [1]f32{ - 0, - } ++ [1]f32{0} ** 15, - }; - _ = &result; - result.v[@as(c_uint, @intCast(@as(c_int, 0)))] = mat.m0; - result.v[@as(c_uint, @intCast(@as(c_int, 1)))] = mat.m1; - result.v[@as(c_uint, @intCast(@as(c_int, 2)))] = mat.m2; - result.v[@as(c_uint, @intCast(@as(c_int, 3)))] = mat.m3; - result.v[@as(c_uint, @intCast(@as(c_int, 4)))] = mat.m4; - result.v[@as(c_uint, @intCast(@as(c_int, 5)))] = mat.m5; - result.v[@as(c_uint, @intCast(@as(c_int, 6)))] = mat.m6; - result.v[@as(c_uint, @intCast(@as(c_int, 7)))] = mat.m7; - result.v[@as(c_uint, @intCast(@as(c_int, 8)))] = mat.m8; - result.v[@as(c_uint, @intCast(@as(c_int, 9)))] = mat.m9; - result.v[@as(c_uint, @intCast(@as(c_int, 10)))] = mat.m10; - result.v[@as(c_uint, @intCast(@as(c_int, 11)))] = mat.m11; - result.v[@as(c_uint, @intCast(@as(c_int, 12)))] = mat.m12; - result.v[@as(c_uint, @intCast(@as(c_int, 13)))] = mat.m13; - result.v[@as(c_uint, @intCast(@as(c_int, 14)))] = mat.m14; - result.v[@as(c_uint, @intCast(@as(c_int, 15)))] = mat.m15; - return result; -} -pub fn QuaternionAdd(arg_q1: Quaternion, arg_q2: Quaternion) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var result: Quaternion = Quaternion{ - .x = q1.x + q2.x, - .y = q1.y + q2.y, - .z = q1.z + q2.z, - .w = q1.w + q2.w, - }; - _ = &result; - return result; -} -pub fn QuaternionAddValue(arg_q: Quaternion, arg_add: f32) callconv(.C) Quaternion { - var q = arg_q; - _ = &q; - var add = arg_add; - _ = &add; - var result: Quaternion = Quaternion{ - .x = q.x + add, - .y = q.y + add, - .z = q.z + add, - .w = q.w + add, - }; - _ = &result; - return result; -} -pub fn QuaternionSubtract(arg_q1: Quaternion, arg_q2: Quaternion) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var result: Quaternion = Quaternion{ - .x = q1.x - q2.x, - .y = q1.y - q2.y, - .z = q1.z - q2.z, - .w = q1.w - q2.w, - }; - _ = &result; - return result; -} -pub fn QuaternionSubtractValue(arg_q: Quaternion, arg_sub: f32) callconv(.C) Quaternion { - var q = arg_q; - _ = &q; - var sub = arg_sub; - _ = ⊂ - var result: Quaternion = Quaternion{ - .x = q.x - sub, - .y = q.y - sub, - .z = q.z - sub, - .w = q.w - sub, - }; - _ = &result; - return result; -} -pub fn QuaternionIdentity() callconv(.C) Quaternion { - var result: Quaternion = Quaternion{ - .x = 0.0, - .y = 0.0, - .z = 0.0, - .w = 1.0, - }; - _ = &result; - return result; -} -pub fn QuaternionLength(arg_q: Quaternion) callconv(.C) f32 { - var q = arg_q; - _ = &q; - var result: f32 = sqrtf((((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w)); - _ = &result; - return result; -} -pub fn QuaternionNormalize(arg_q: Quaternion) callconv(.C) Quaternion { - var q = arg_q; - _ = &q; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var length: f32 = sqrtf((((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w)); - _ = &length; - if (length == 0.0) { - length = 1.0; - } - var ilength: f32 = 1.0 / length; - _ = &ilength; - result.x = q.x * ilength; - result.y = q.y * ilength; - result.z = q.z * ilength; - result.w = q.w * ilength; - return result; -} -pub fn QuaternionInvert(arg_q: Quaternion) callconv(.C) Quaternion { - var q = arg_q; - _ = &q; - var result: Quaternion = q; - _ = &result; - var lengthSq: f32 = (((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w); - _ = &lengthSq; - if (lengthSq != 0.0) { - var invLength: f32 = 1.0 / lengthSq; - _ = &invLength; - result.x *= -invLength; - result.y *= -invLength; - result.z *= -invLength; - result.w *= invLength; - } - return result; -} -pub fn QuaternionMultiply(arg_q1: Quaternion, arg_q2: Quaternion) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var qax: f32 = q1.x; - _ = &qax; - var qay: f32 = q1.y; - _ = &qay; - var qaz: f32 = q1.z; - _ = &qaz; - var qaw: f32 = q1.w; - _ = &qaw; - var qbx: f32 = q2.x; - _ = &qbx; - var qby: f32 = q2.y; - _ = &qby; - var qbz: f32 = q2.z; - _ = &qbz; - var qbw: f32 = q2.w; - _ = &qbw; - result.x = (((qax * qbw) + (qaw * qbx)) + (qay * qbz)) - (qaz * qby); - result.y = (((qay * qbw) + (qaw * qby)) + (qaz * qbx)) - (qax * qbz); - result.z = (((qaz * qbw) + (qaw * qbz)) + (qax * qby)) - (qay * qbx); - result.w = (((qaw * qbw) - (qax * qbx)) - (qay * qby)) - (qaz * qbz); - return result; -} -pub fn QuaternionScale(arg_q: Quaternion, arg_mul: f32) callconv(.C) Quaternion { - var q = arg_q; - _ = &q; - var mul = arg_mul; - _ = &mul; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = q.x * mul; - result.y = q.y * mul; - result.z = q.z * mul; - result.w = q.w * mul; - return result; -} -pub fn QuaternionDivide(arg_q1: Quaternion, arg_q2: Quaternion) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var result: Quaternion = Quaternion{ - .x = q1.x / q2.x, - .y = q1.y / q2.y, - .z = q1.z / q2.z, - .w = q1.w / q2.w, - }; - _ = &result; - return result; -} -pub fn QuaternionLerp(arg_q1: Quaternion, arg_q2: Quaternion, arg_amount: f32) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var amount = arg_amount; - _ = &amount; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = q1.x + (amount * (q2.x - q1.x)); - result.y = q1.y + (amount * (q2.y - q1.y)); - result.z = q1.z + (amount * (q2.z - q1.z)); - result.w = q1.w + (amount * (q2.w - q1.w)); - return result; -} -pub fn QuaternionNlerp(arg_q1: Quaternion, arg_q2: Quaternion, arg_amount: f32) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var amount = arg_amount; - _ = &amount; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = q1.x + (amount * (q2.x - q1.x)); - result.y = q1.y + (amount * (q2.y - q1.y)); - result.z = q1.z + (amount * (q2.z - q1.z)); - result.w = q1.w + (amount * (q2.w - q1.w)); - var q: Quaternion = result; - _ = &q; - var length: f32 = sqrtf((((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w)); - _ = &length; - if (length == 0.0) { - length = 1.0; - } - var ilength: f32 = 1.0 / length; - _ = &ilength; - result.x = q.x * ilength; - result.y = q.y * ilength; - result.z = q.z * ilength; - result.w = q.w * ilength; - return result; -} -pub fn QuaternionSlerp(arg_q1: Quaternion, arg_q2: Quaternion, arg_amount: f32) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var q2 = arg_q2; - _ = &q2; - var amount = arg_amount; - _ = &amount; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var cosHalfTheta: f32 = (((q1.x * q2.x) + (q1.y * q2.y)) + (q1.z * q2.z)) + (q1.w * q2.w); - _ = &cosHalfTheta; - if (cosHalfTheta < @as(f32, @floatFromInt(@as(c_int, 0)))) { - q2.x = -q2.x; - q2.y = -q2.y; - q2.z = -q2.z; - q2.w = -q2.w; - cosHalfTheta = -cosHalfTheta; - } - if (fabsf(cosHalfTheta) >= 1.0) { - result = q1; - } else if (cosHalfTheta > 0.949999988079071) { - result = QuaternionNlerp(q1, q2, amount); - } else { - var halfTheta: f32 = acosf(cosHalfTheta); - _ = &halfTheta; - var sinHalfTheta: f32 = sqrtf(1.0 - (cosHalfTheta * cosHalfTheta)); - _ = &sinHalfTheta; - if (fabsf(sinHalfTheta) < 0.0000009999999974752427) { - result.x = (q1.x * 0.5) + (q2.x * 0.5); - result.y = (q1.y * 0.5) + (q2.y * 0.5); - result.z = (q1.z * 0.5) + (q2.z * 0.5); - result.w = (q1.w * 0.5) + (q2.w * 0.5); - } else { - var ratioA: f32 = sinf((@as(f32, @floatFromInt(@as(c_int, 1))) - amount) * halfTheta) / sinHalfTheta; - _ = &ratioA; - var ratioB: f32 = sinf(amount * halfTheta) / sinHalfTheta; - _ = &ratioB; - result.x = (q1.x * ratioA) + (q2.x * ratioB); - result.y = (q1.y * ratioA) + (q2.y * ratioB); - result.z = (q1.z * ratioA) + (q2.z * ratioB); - result.w = (q1.w * ratioA) + (q2.w * ratioB); - } - } - return result; -} -pub fn QuaternionCubicHermiteSpline(arg_q1: Quaternion, arg_outTangent1: Quaternion, arg_q2: Quaternion, arg_inTangent2: Quaternion, arg_t: f32) callconv(.C) Quaternion { - var q1 = arg_q1; - _ = &q1; - var outTangent1 = arg_outTangent1; - _ = &outTangent1; - var q2 = arg_q2; - _ = &q2; - var inTangent2 = arg_inTangent2; - _ = &inTangent2; - var t = arg_t; - _ = &t; - var t2: f32 = t * t; - _ = &t2; - var t3: f32 = t2 * t; - _ = &t3; - var h00: f32 = ((@as(f32, @floatFromInt(@as(c_int, 2))) * t3) - (@as(f32, @floatFromInt(@as(c_int, 3))) * t2)) + @as(f32, @floatFromInt(@as(c_int, 1))); - _ = &h00; - var h10: f32 = (t3 - (@as(f32, @floatFromInt(@as(c_int, 2))) * t2)) + t; - _ = &h10; - var h01: f32 = (@as(f32, @floatFromInt(-@as(c_int, 2))) * t3) + (@as(f32, @floatFromInt(@as(c_int, 3))) * t2); - _ = &h01; - var h11: f32 = t3 - t2; - _ = &h11; - var p0: Quaternion = QuaternionScale(q1, h00); - _ = &p0; - var m0: Quaternion = QuaternionScale(outTangent1, h10); - _ = &m0; - var p1: Quaternion = QuaternionScale(q2, h01); - _ = &p1; - var m1: Quaternion = QuaternionScale(inTangent2, h11); - _ = &m1; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result = QuaternionAdd(p0, m0); - result = QuaternionAdd(result, p1); - result = QuaternionAdd(result, m1); - result = QuaternionNormalize(result); - return result; -} -pub fn QuaternionFromVector3ToVector3(arg_from: Vector3, arg_to: Vector3) callconv(.C) Quaternion { - var from = arg_from; - _ = &from; - var to = arg_to; - _ = &to; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var cos2Theta: f32 = ((from.x * to.x) + (from.y * to.y)) + (from.z * to.z); - _ = &cos2Theta; - var cross: Vector3 = Vector3{ - .x = (from.y * to.z) - (from.z * to.y), - .y = (from.z * to.x) - (from.x * to.z), - .z = (from.x * to.y) - (from.y * to.x), - }; - _ = ✗ - result.x = cross.x; - result.y = cross.y; - result.z = cross.z; - result.w = 1.0 + cos2Theta; - var q: Quaternion = result; - _ = &q; - var length: f32 = sqrtf((((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w)); - _ = &length; - if (length == 0.0) { - length = 1.0; - } - var ilength: f32 = 1.0 / length; - _ = &ilength; - result.x = q.x * ilength; - result.y = q.y * ilength; - result.z = q.z * ilength; - result.w = q.w * ilength; - return result; -} -pub fn QuaternionFromMatrix(arg_mat: Matrix) callconv(.C) Quaternion { - var mat = arg_mat; - _ = &mat; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var fourWSquaredMinus1: f32 = (mat.m0 + mat.m5) + mat.m10; - _ = &fourWSquaredMinus1; - var fourXSquaredMinus1: f32 = (mat.m0 - mat.m5) - mat.m10; - _ = &fourXSquaredMinus1; - var fourYSquaredMinus1: f32 = (mat.m5 - mat.m0) - mat.m10; - _ = &fourYSquaredMinus1; - var fourZSquaredMinus1: f32 = (mat.m10 - mat.m0) - mat.m5; - _ = &fourZSquaredMinus1; - var biggestIndex: c_int = 0; - _ = &biggestIndex; - var fourBiggestSquaredMinus1: f32 = fourWSquaredMinus1; - _ = &fourBiggestSquaredMinus1; - if (fourXSquaredMinus1 > fourBiggestSquaredMinus1) { - fourBiggestSquaredMinus1 = fourXSquaredMinus1; - biggestIndex = 1; - } - if (fourYSquaredMinus1 > fourBiggestSquaredMinus1) { - fourBiggestSquaredMinus1 = fourYSquaredMinus1; - biggestIndex = 2; - } - if (fourZSquaredMinus1 > fourBiggestSquaredMinus1) { - fourBiggestSquaredMinus1 = fourZSquaredMinus1; - biggestIndex = 3; - } - var biggestVal: f32 = sqrtf(fourBiggestSquaredMinus1 + 1.0) * 0.5; - _ = &biggestVal; - var mult: f32 = 0.25 / biggestVal; - _ = &mult; - while (true) { - switch (biggestIndex) { - @as(c_int, 0) => { - result.w = biggestVal; - result.x = (mat.m6 - mat.m9) * mult; - result.y = (mat.m8 - mat.m2) * mult; - result.z = (mat.m1 - mat.m4) * mult; - break; - }, - @as(c_int, 1) => { - result.x = biggestVal; - result.w = (mat.m6 - mat.m9) * mult; - result.y = (mat.m1 + mat.m4) * mult; - result.z = (mat.m8 + mat.m2) * mult; - break; - }, - @as(c_int, 2) => { - result.y = biggestVal; - result.w = (mat.m8 - mat.m2) * mult; - result.x = (mat.m1 + mat.m4) * mult; - result.z = (mat.m6 + mat.m9) * mult; - break; - }, - @as(c_int, 3) => { - result.z = biggestVal; - result.w = (mat.m1 - mat.m4) * mult; - result.x = (mat.m8 + mat.m2) * mult; - result.y = (mat.m6 + mat.m9) * mult; - break; - }, - else => {}, - } - break; - } - return result; -} -pub fn QuaternionToMatrix(arg_q: Quaternion) callconv(.C) Matrix { - var q = arg_q; - _ = &q; - var result: Matrix = Matrix{ - .m0 = 1.0, - .m4 = 0.0, - .m8 = 0.0, - .m12 = 0.0, - .m1 = 0.0, - .m5 = 1.0, - .m9 = 0.0, - .m13 = 0.0, - .m2 = 0.0, - .m6 = 0.0, - .m10 = 1.0, - .m14 = 0.0, - .m3 = 0.0, - .m7 = 0.0, - .m11 = 0.0, - .m15 = 1.0, - }; - _ = &result; - var a2: f32 = q.x * q.x; - _ = &a2; - var b2: f32 = q.y * q.y; - _ = &b2; - var c2: f32 = q.z * q.z; - _ = &c2; - var ac: f32 = q.x * q.z; - _ = ∾ - var ab: f32 = q.x * q.y; - _ = &ab; - var bc: f32 = q.y * q.z; - _ = &bc; - var ad: f32 = q.w * q.x; - _ = &ad; - var bd: f32 = q.w * q.y; - _ = &bd; - var cd: f32 = q.w * q.z; - _ = &cd; - result.m0 = @as(f32, @floatFromInt(@as(c_int, 1))) - (@as(f32, @floatFromInt(@as(c_int, 2))) * (b2 + c2)); - result.m1 = @as(f32, @floatFromInt(@as(c_int, 2))) * (ab + cd); - result.m2 = @as(f32, @floatFromInt(@as(c_int, 2))) * (ac - bd); - result.m4 = @as(f32, @floatFromInt(@as(c_int, 2))) * (ab - cd); - result.m5 = @as(f32, @floatFromInt(@as(c_int, 1))) - (@as(f32, @floatFromInt(@as(c_int, 2))) * (a2 + c2)); - result.m6 = @as(f32, @floatFromInt(@as(c_int, 2))) * (bc + ad); - result.m8 = @as(f32, @floatFromInt(@as(c_int, 2))) * (ac + bd); - result.m9 = @as(f32, @floatFromInt(@as(c_int, 2))) * (bc - ad); - result.m10 = @as(f32, @floatFromInt(@as(c_int, 1))) - (@as(f32, @floatFromInt(@as(c_int, 2))) * (a2 + b2)); - return result; -} -pub fn QuaternionFromAxisAngle(arg_axis: Vector3, arg_angle: f32) callconv(.C) Quaternion { - var axis = arg_axis; - _ = &axis; - var angle = arg_angle; - _ = ∠ - var result: Quaternion = Quaternion{ - .x = 0.0, - .y = 0.0, - .z = 0.0, - .w = 1.0, - }; - _ = &result; - var axisLength: f32 = sqrtf(((axis.x * axis.x) + (axis.y * axis.y)) + (axis.z * axis.z)); - _ = &axisLength; - if (axisLength != 0.0) { - angle *= 0.5; - var length: f32 = 0.0; - _ = &length; - var ilength: f32 = 0.0; - _ = &ilength; - length = axisLength; - if (length == 0.0) { - length = 1.0; - } - ilength = 1.0 / length; - axis.x *= ilength; - axis.y *= ilength; - axis.z *= ilength; - var sinres: f32 = sinf(angle); - _ = &sinres; - var cosres: f32 = cosf(angle); - _ = &cosres; - result.x = axis.x * sinres; - result.y = axis.y * sinres; - result.z = axis.z * sinres; - result.w = cosres; - var q: Quaternion = result; - _ = &q; - length = sqrtf((((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w)); - if (length == 0.0) { - length = 1.0; - } - ilength = 1.0 / length; - result.x = q.x * ilength; - result.y = q.y * ilength; - result.z = q.z * ilength; - result.w = q.w * ilength; - } - return result; -} -pub fn QuaternionToAxisAngle(arg_q: Quaternion, arg_outAxis: [*c]Vector3, arg_outAngle: [*c]f32) callconv(.C) void { - var q = arg_q; - _ = &q; - var outAxis = arg_outAxis; - _ = &outAxis; - var outAngle = arg_outAngle; - _ = &outAngle; - if (fabsf(q.w) > 1.0) { - var length: f32 = sqrtf((((q.x * q.x) + (q.y * q.y)) + (q.z * q.z)) + (q.w * q.w)); - _ = &length; - if (length == 0.0) { - length = 1.0; - } - var ilength: f32 = 1.0 / length; - _ = &ilength; - q.x = q.x * ilength; - q.y = q.y * ilength; - q.z = q.z * ilength; - q.w = q.w * ilength; - } - var resAxis: Vector3 = Vector3{ - .x = 0.0, - .y = 0.0, - .z = 0.0, - }; - _ = &resAxis; - var resAngle: f32 = 2.0 * acosf(q.w); - _ = &resAngle; - var den: f32 = sqrtf(1.0 - (q.w * q.w)); - _ = &den; - if (den > 0.0000009999999974752427) { - resAxis.x = q.x / den; - resAxis.y = q.y / den; - resAxis.z = q.z / den; - } else { - resAxis.x = 1.0; - } - outAxis.* = resAxis; - outAngle.* = resAngle; -} -pub fn QuaternionFromEuler(arg_pitch: f32, arg_yaw: f32, arg_roll: f32) callconv(.C) Quaternion { - var pitch = arg_pitch; - _ = &pitch; - var yaw = arg_yaw; - _ = &yaw; - var roll = arg_roll; - _ = &roll; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - var x0: f32 = cosf(pitch * 0.5); - _ = &x0; - var x1: f32 = sinf(pitch * 0.5); - _ = &x1; - var y0_1: f32 = cosf(yaw * 0.5); - _ = &y0_1; - var y1_2: f32 = sinf(yaw * 0.5); - _ = &y1_2; - var z0: f32 = cosf(roll * 0.5); - _ = &z0; - var z1: f32 = sinf(roll * 0.5); - _ = &z1; - result.x = ((x1 * y0_1) * z0) - ((x0 * y1_2) * z1); - result.y = ((x0 * y1_2) * z0) + ((x1 * y0_1) * z1); - result.z = ((x0 * y0_1) * z1) - ((x1 * y1_2) * z0); - result.w = ((x0 * y0_1) * z0) + ((x1 * y1_2) * z1); - return result; -} -pub fn QuaternionToEuler(arg_q: Quaternion) callconv(.C) Vector3 { - var q = arg_q; - _ = &q; - var result: Vector3 = Vector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - }; - _ = &result; - var x0: f32 = 2.0 * ((q.w * q.x) + (q.y * q.z)); - _ = &x0; - var x1: f32 = 1.0 - (2.0 * ((q.x * q.x) + (q.y * q.y))); - _ = &x1; - result.x = atan2f(x0, x1); - var y0_1: f32 = 2.0 * ((q.w * q.y) - (q.z * q.x)); - _ = &y0_1; - y0_1 = if (y0_1 > 1.0) 1.0 else y0_1; - y0_1 = if (y0_1 < -1.0) -1.0 else y0_1; - result.y = asinf(y0_1); - var z0: f32 = 2.0 * ((q.w * q.z) + (q.x * q.y)); - _ = &z0; - var z1: f32 = 1.0 - (2.0 * ((q.y * q.y) + (q.z * q.z))); - _ = &z1; - result.z = atan2f(z0, z1); - return result; -} -pub fn QuaternionTransform(arg_q: Quaternion, arg_mat: Matrix) callconv(.C) Quaternion { - var q = arg_q; - _ = &q; - var mat = arg_mat; - _ = &mat; - var result: Quaternion = Quaternion{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = 0, - .z = 0, - .w = 0, - }; - _ = &result; - result.x = (((mat.m0 * q.x) + (mat.m4 * q.y)) + (mat.m8 * q.z)) + (mat.m12 * q.w); - result.y = (((mat.m1 * q.x) + (mat.m5 * q.y)) + (mat.m9 * q.z)) + (mat.m13 * q.w); - result.z = (((mat.m2 * q.x) + (mat.m6 * q.y)) + (mat.m10 * q.z)) + (mat.m14 * q.w); - result.w = (((mat.m3 * q.x) + (mat.m7 * q.y)) + (mat.m11 * q.z)) + (mat.m15 * q.w); - return result; -} -pub fn QuaternionEquals(arg_p: Quaternion, arg_q: Quaternion) callconv(.C) c_int { - var p = arg_p; - _ = &p; - var q = arg_q; - _ = &q; - var result: c_int = @intFromBool(((((fabsf(p.x - q.x) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.x), fabsf(q.x))))) and (fabsf(p.y - q.y) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.y), fabsf(q.y)))))) and (fabsf(p.z - q.z) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.z), fabsf(q.z)))))) and (fabsf(p.w - q.w) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.w), fabsf(q.w)))))) or ((((fabsf(p.x + q.x) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.x), fabsf(q.x))))) and (fabsf(p.y + q.y) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.y), fabsf(q.y)))))) and (fabsf(p.z + q.z) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.z), fabsf(q.z)))))) and (fabsf(p.w + q.w) <= (0.0000009999999974752427 * fmaxf(1.0, fmaxf(fabsf(p.w), fabsf(q.w))))))); - _ = &result; - return result; -} -pub fn MatrixDecompose(arg_mat: Matrix, arg_translation: [*c]Vector3, arg_rotation: [*c]Quaternion, arg_scale: [*c]Vector3) callconv(.C) void { - var mat = arg_mat; - _ = &mat; - var translation = arg_translation; - _ = &translation; - var rotation = arg_rotation; - _ = &rotation; - var scale = arg_scale; - _ = &scale; - translation.*.x = mat.m12; - translation.*.y = mat.m13; - translation.*.z = mat.m14; - const a: f32 = mat.m0; - _ = &a; - const b: f32 = mat.m4; - _ = &b; - const c: f32 = mat.m8; - _ = &c; - const d: f32 = mat.m1; - _ = &d; - const e: f32 = mat.m5; - _ = &e; - const f: f32 = mat.m9; - _ = &f; - const g: f32 = mat.m2; - _ = &g; - const h: f32 = mat.m6; - _ = &h; - const i: f32 = mat.m10; - _ = &i; - const A: f32 = (e * i) - (f * h); - _ = &A; - const B: f32 = (f * g) - (d * i); - _ = &B; - const C: f32 = (d * h) - (e * g); - _ = &C; - const det: f32 = ((a * A) + (b * B)) + (c * C); - _ = &det; - var abc: Vector3 = Vector3{ - .x = a, - .y = b, - .z = c, - }; - _ = &abc; - var def: Vector3 = Vector3{ - .x = d, - .y = e, - .z = f, - }; - _ = &def; - var ghi: Vector3 = Vector3{ - .x = g, - .y = h, - .z = i, - }; - _ = &ghi; - var scalex: f32 = Vector3Length(abc); - _ = &scalex; - var scaley: f32 = Vector3Length(def); - _ = &scaley; - var scalez: f32 = Vector3Length(ghi); - _ = &scalez; - var s: Vector3 = Vector3{ - .x = scalex, - .y = scaley, - .z = scalez, - }; - _ = &s; - if (det < @as(f32, @floatFromInt(@as(c_int, 0)))) { - s = Vector3Negate(s); - } - scale.* = s; - var clone: Matrix = mat; - _ = &clone; - if (!(FloatEquals(det, @as(f32, @floatFromInt(@as(c_int, 0)))) != 0)) { - clone.m0 /= s.x; - clone.m5 /= s.y; - clone.m10 /= s.z; - rotation.* = QuaternionFromMatrix(clone); - } else { - rotation.* = QuaternionIdentity(); - } -} -const union_unnamed_3 = extern union { - __wch: c_uint, - __wchb: [4]u8, -}; -pub const __mbstate_t = extern struct { - __count: c_int = @import("std").mem.zeroes(c_int), - __value: union_unnamed_3 = @import("std").mem.zeroes(union_unnamed_3), -}; -pub const struct__G_fpos_t = extern struct { - __pos: __off_t = @import("std").mem.zeroes(__off_t), - __state: __mbstate_t = @import("std").mem.zeroes(__mbstate_t), -}; -pub const __fpos_t = struct__G_fpos_t; -pub const struct__G_fpos64_t = extern struct { - __pos: __off64_t = @import("std").mem.zeroes(__off64_t), - __state: __mbstate_t = @import("std").mem.zeroes(__mbstate_t), -}; -pub const __fpos64_t = struct__G_fpos64_t; -pub const struct__IO_marker = opaque {}; -pub const _IO_lock_t = anyopaque; -pub const struct__IO_codecvt = opaque {}; -pub const struct__IO_wide_data = opaque {}; -pub const struct__IO_FILE = extern struct { - _flags: c_int = @import("std").mem.zeroes(c_int), - _IO_read_ptr: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_read_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_read_base: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_write_base: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_write_ptr: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_write_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_buf_base: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_buf_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_save_base: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_backup_base: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _IO_save_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - _markers: ?*struct__IO_marker = @import("std").mem.zeroes(?*struct__IO_marker), - _chain: [*c]struct__IO_FILE = @import("std").mem.zeroes([*c]struct__IO_FILE), - _fileno: c_int = @import("std").mem.zeroes(c_int), - _flags2: c_int = @import("std").mem.zeroes(c_int), - _old_offset: __off_t = @import("std").mem.zeroes(__off_t), - _cur_column: c_ushort = @import("std").mem.zeroes(c_ushort), - _vtable_offset: i8 = @import("std").mem.zeroes(i8), - _shortbuf: [1]u8 = @import("std").mem.zeroes([1]u8), - _lock: ?*_IO_lock_t = @import("std").mem.zeroes(?*_IO_lock_t), - _offset: __off64_t = @import("std").mem.zeroes(__off64_t), - _codecvt: ?*struct__IO_codecvt = @import("std").mem.zeroes(?*struct__IO_codecvt), - _wide_data: ?*struct__IO_wide_data = @import("std").mem.zeroes(?*struct__IO_wide_data), - _freeres_list: [*c]struct__IO_FILE = @import("std").mem.zeroes([*c]struct__IO_FILE), - _freeres_buf: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - _prevchain: [*c][*c]struct__IO_FILE = @import("std").mem.zeroes([*c][*c]struct__IO_FILE), - _mode: c_int = @import("std").mem.zeroes(c_int), - _unused2: [20]u8 = @import("std").mem.zeroes([20]u8), -}; -pub const __FILE = struct__IO_FILE; -pub const FILE = struct__IO_FILE; -pub const cookie_read_function_t = fn (?*anyopaque, [*c]u8, usize) callconv(.C) __ssize_t; -pub const cookie_write_function_t = fn (?*anyopaque, [*c]const u8, usize) callconv(.C) __ssize_t; -pub const cookie_seek_function_t = fn (?*anyopaque, [*c]__off64_t, c_int) callconv(.C) c_int; -pub const cookie_close_function_t = fn (?*anyopaque) callconv(.C) c_int; -pub const struct__IO_cookie_io_functions_t = extern struct { - read: ?*const cookie_read_function_t = @import("std").mem.zeroes(?*const cookie_read_function_t), - write: ?*const cookie_write_function_t = @import("std").mem.zeroes(?*const cookie_write_function_t), - seek: ?*const cookie_seek_function_t = @import("std").mem.zeroes(?*const cookie_seek_function_t), - close: ?*const cookie_close_function_t = @import("std").mem.zeroes(?*const cookie_close_function_t), -}; -pub const cookie_io_functions_t = struct__IO_cookie_io_functions_t; -pub const off_t = __off_t; -pub const fpos_t = __fpos_t; -pub extern var stdin: [*c]FILE; -pub extern var stdout: [*c]FILE; -pub extern var stderr: [*c]FILE; -pub extern fn remove(__filename: [*c]const u8) c_int; -pub extern fn rename(__old: [*c]const u8, __new: [*c]const u8) c_int; -pub extern fn renameat(__oldfd: c_int, __old: [*c]const u8, __newfd: c_int, __new: [*c]const u8) c_int; -pub extern fn fclose(__stream: [*c]FILE) c_int; -pub extern fn tmpfile() [*c]FILE; -pub extern fn tmpnam([*c]u8) [*c]u8; -pub extern fn tmpnam_r(__s: [*c]u8) [*c]u8; -pub extern fn tempnam(__dir: [*c]const u8, __pfx: [*c]const u8) [*c]u8; -pub extern fn fflush(__stream: [*c]FILE) c_int; -pub extern fn fflush_unlocked(__stream: [*c]FILE) c_int; -pub extern fn fopen(__filename: [*c]const u8, __modes: [*c]const u8) [*c]FILE; -pub extern fn freopen(noalias __filename: [*c]const u8, noalias __modes: [*c]const u8, noalias __stream: [*c]FILE) [*c]FILE; -pub extern fn fdopen(__fd: c_int, __modes: [*c]const u8) [*c]FILE; -pub extern fn fopencookie(noalias __magic_cookie: ?*anyopaque, noalias __modes: [*c]const u8, __io_funcs: cookie_io_functions_t) [*c]FILE; -pub extern fn fmemopen(__s: ?*anyopaque, __len: usize, __modes: [*c]const u8) [*c]FILE; -pub extern fn open_memstream(__bufloc: [*c][*c]u8, __sizeloc: [*c]usize) [*c]FILE; -pub extern fn setbuf(noalias __stream: [*c]FILE, noalias __buf: [*c]u8) void; -pub extern fn setvbuf(noalias __stream: [*c]FILE, noalias __buf: [*c]u8, __modes: c_int, __n: usize) c_int; -pub extern fn setbuffer(noalias __stream: [*c]FILE, noalias __buf: [*c]u8, __size: usize) void; -pub extern fn setlinebuf(__stream: [*c]FILE) void; -pub extern fn fprintf(__stream: [*c]FILE, __format: [*c]const u8, ...) c_int; -pub extern fn printf(__format: [*c]const u8, ...) c_int; -pub extern fn sprintf(__s: [*c]u8, __format: [*c]const u8, ...) c_int; -pub extern fn vfprintf(__s: [*c]FILE, __format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn vprintf(__format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn vsprintf(__s: [*c]u8, __format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn snprintf(__s: [*c]u8, __maxlen: c_ulong, __format: [*c]const u8, ...) c_int; -pub extern fn vsnprintf(__s: [*c]u8, __maxlen: c_ulong, __format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn vasprintf(noalias __ptr: [*c][*c]u8, noalias __f: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn __asprintf(noalias __ptr: [*c][*c]u8, noalias __fmt: [*c]const u8, ...) c_int; -pub extern fn asprintf(noalias __ptr: [*c][*c]u8, noalias __fmt: [*c]const u8, ...) c_int; -pub extern fn vdprintf(__fd: c_int, noalias __fmt: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn dprintf(__fd: c_int, noalias __fmt: [*c]const u8, ...) c_int; -pub extern fn fscanf(noalias __stream: [*c]FILE, noalias __format: [*c]const u8, ...) c_int; -pub extern fn scanf(noalias __format: [*c]const u8, ...) c_int; -pub extern fn sscanf(noalias __s: [*c]const u8, noalias __format: [*c]const u8, ...) c_int; -pub extern fn vfscanf(noalias __s: [*c]FILE, noalias __format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn vscanf(noalias __format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn vsscanf(noalias __s: [*c]const u8, noalias __format: [*c]const u8, __arg: [*c]struct___va_list_tag_1) c_int; -pub extern fn fgetc(__stream: [*c]FILE) c_int; -pub extern fn getc(__stream: [*c]FILE) c_int; -pub extern fn getchar() c_int; -pub extern fn getc_unlocked(__stream: [*c]FILE) c_int; -pub extern fn getchar_unlocked() c_int; -pub extern fn fgetc_unlocked(__stream: [*c]FILE) c_int; -pub extern fn fputc(__c: c_int, __stream: [*c]FILE) c_int; -pub extern fn putc(__c: c_int, __stream: [*c]FILE) c_int; -pub extern fn putchar(__c: c_int) c_int; -pub extern fn fputc_unlocked(__c: c_int, __stream: [*c]FILE) c_int; -pub extern fn putc_unlocked(__c: c_int, __stream: [*c]FILE) c_int; -pub extern fn putchar_unlocked(__c: c_int) c_int; -pub extern fn getw(__stream: [*c]FILE) c_int; -pub extern fn putw(__w: c_int, __stream: [*c]FILE) c_int; -pub extern fn fgets(noalias __s: [*c]u8, __n: c_int, noalias __stream: [*c]FILE) [*c]u8; -pub extern fn __getdelim(noalias __lineptr: [*c][*c]u8, noalias __n: [*c]usize, __delimiter: c_int, noalias __stream: [*c]FILE) __ssize_t; -pub extern fn getdelim(noalias __lineptr: [*c][*c]u8, noalias __n: [*c]usize, __delimiter: c_int, noalias __stream: [*c]FILE) __ssize_t; -pub extern fn getline(noalias __lineptr: [*c][*c]u8, noalias __n: [*c]usize, noalias __stream: [*c]FILE) __ssize_t; -pub extern fn fputs(noalias __s: [*c]const u8, noalias __stream: [*c]FILE) c_int; -pub extern fn puts(__s: [*c]const u8) c_int; -pub extern fn ungetc(__c: c_int, __stream: [*c]FILE) c_int; -pub extern fn fread(__ptr: ?*anyopaque, __size: c_ulong, __n: c_ulong, __stream: [*c]FILE) c_ulong; -pub extern fn fwrite(__ptr: ?*const anyopaque, __size: c_ulong, __n: c_ulong, __s: [*c]FILE) c_ulong; -pub extern fn fread_unlocked(noalias __ptr: ?*anyopaque, __size: usize, __n: usize, noalias __stream: [*c]FILE) usize; -pub extern fn fwrite_unlocked(noalias __ptr: ?*const anyopaque, __size: usize, __n: usize, noalias __stream: [*c]FILE) usize; -pub extern fn fseek(__stream: [*c]FILE, __off: c_long, __whence: c_int) c_int; -pub extern fn ftell(__stream: [*c]FILE) c_long; -pub extern fn rewind(__stream: [*c]FILE) void; -pub extern fn fseeko(__stream: [*c]FILE, __off: __off_t, __whence: c_int) c_int; -pub extern fn ftello(__stream: [*c]FILE) __off_t; -pub extern fn fgetpos(noalias __stream: [*c]FILE, noalias __pos: [*c]fpos_t) c_int; -pub extern fn fsetpos(__stream: [*c]FILE, __pos: [*c]const fpos_t) c_int; -pub extern fn clearerr(__stream: [*c]FILE) void; -pub extern fn feof(__stream: [*c]FILE) c_int; -pub extern fn ferror(__stream: [*c]FILE) c_int; -pub extern fn clearerr_unlocked(__stream: [*c]FILE) void; -pub extern fn feof_unlocked(__stream: [*c]FILE) c_int; -pub extern fn ferror_unlocked(__stream: [*c]FILE) c_int; -pub extern fn perror(__s: [*c]const u8) void; -pub extern fn fileno(__stream: [*c]FILE) c_int; -pub extern fn fileno_unlocked(__stream: [*c]FILE) c_int; -pub extern fn pclose(__stream: [*c]FILE) c_int; -pub extern fn popen(__command: [*c]const u8, __modes: [*c]const u8) [*c]FILE; -pub extern fn ctermid(__s: [*c]u8) [*c]u8; -pub extern fn flockfile(__stream: [*c]FILE) void; -pub extern fn ftrylockfile(__stream: [*c]FILE) c_int; -pub extern fn funlockfile(__stream: [*c]FILE) void; -pub extern fn __uflow([*c]FILE) c_int; -pub extern fn __overflow([*c]FILE, c_int) c_int; -pub const wchar_t = c_int; -pub const div_t = extern struct { - quot: c_int = @import("std").mem.zeroes(c_int), - rem: c_int = @import("std").mem.zeroes(c_int), -}; -pub const ldiv_t = extern struct { - quot: c_long = @import("std").mem.zeroes(c_long), - rem: c_long = @import("std").mem.zeroes(c_long), -}; -pub const lldiv_t = extern struct { - quot: c_longlong = @import("std").mem.zeroes(c_longlong), - rem: c_longlong = @import("std").mem.zeroes(c_longlong), -}; -pub extern fn __ctype_get_mb_cur_max() usize; -pub extern fn atof(__nptr: [*c]const u8) f64; -pub extern fn atoi(__nptr: [*c]const u8) c_int; -pub extern fn atol(__nptr: [*c]const u8) c_long; -pub extern fn atoll(__nptr: [*c]const u8) c_longlong; -pub extern fn strtod(__nptr: [*c]const u8, __endptr: [*c][*c]u8) f64; -pub extern fn strtof(__nptr: [*c]const u8, __endptr: [*c][*c]u8) f32; -pub extern fn strtold(__nptr: [*c]const u8, __endptr: [*c][*c]u8) c_longdouble; -pub extern fn strtol(__nptr: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_long; -pub extern fn strtoul(__nptr: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_ulong; -pub extern fn strtoq(noalias __nptr: [*c]const u8, noalias __endptr: [*c][*c]u8, __base: c_int) c_longlong; -pub extern fn strtouq(noalias __nptr: [*c]const u8, noalias __endptr: [*c][*c]u8, __base: c_int) c_ulonglong; -pub extern fn strtoll(__nptr: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_longlong; -pub extern fn strtoull(__nptr: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_ulonglong; -pub extern fn l64a(__n: c_long) [*c]u8; -pub extern fn a64l(__s: [*c]const u8) c_long; -pub const u_char = __u_char; -pub const u_short = __u_short; -pub const u_int = __u_int; -pub const u_long = __u_long; -pub const quad_t = __quad_t; -pub const u_quad_t = __u_quad_t; -pub const fsid_t = __fsid_t; -pub const loff_t = __loff_t; -pub const ino_t = __ino_t; -pub const dev_t = __dev_t; -pub const gid_t = __gid_t; -pub const mode_t = __mode_t; -pub const nlink_t = __nlink_t; -pub const uid_t = __uid_t; -pub const pid_t = __pid_t; -pub const id_t = __id_t; -pub const daddr_t = __daddr_t; -pub const caddr_t = __caddr_t; -pub const key_t = __key_t; -pub const clock_t = __clock_t; -pub const clockid_t = __clockid_t; -pub const time_t = __time_t; -pub const timer_t = __timer_t; -pub const ulong = c_ulong; -pub const ushort = c_ushort; -pub const uint = c_uint; -pub const u_int8_t = __uint8_t; -pub const u_int16_t = __uint16_t; -pub const u_int32_t = __uint32_t; -pub const u_int64_t = __uint64_t; -pub const register_t = c_long; -pub fn __bswap_16(arg___bsx: __uint16_t) callconv(.C) __uint16_t { - var __bsx = arg___bsx; - _ = &__bsx; - return @as(__uint16_t, @bitCast(@as(c_short, @truncate(((@as(c_int, @bitCast(@as(c_uint, __bsx))) >> @intCast(8)) & @as(c_int, 255)) | ((@as(c_int, @bitCast(@as(c_uint, __bsx))) & @as(c_int, 255)) << @intCast(8)))))); -} -pub fn __bswap_32(arg___bsx: __uint32_t) callconv(.C) __uint32_t { - var __bsx = arg___bsx; - _ = &__bsx; - return ((((__bsx & @as(c_uint, 4278190080)) >> @intCast(24)) | ((__bsx & @as(c_uint, 16711680)) >> @intCast(8))) | ((__bsx & @as(c_uint, 65280)) << @intCast(8))) | ((__bsx & @as(c_uint, 255)) << @intCast(24)); -} -pub fn __bswap_64(arg___bsx: __uint64_t) callconv(.C) __uint64_t { - var __bsx = arg___bsx; - _ = &__bsx; - return @as(__uint64_t, @bitCast(@as(c_ulong, @truncate(((((((((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 18374686479671623680)) >> @intCast(56)) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 71776119061217280)) >> @intCast(40))) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 280375465082880)) >> @intCast(24))) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 1095216660480)) >> @intCast(8))) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 4278190080)) << @intCast(8))) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 16711680)) << @intCast(24))) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 65280)) << @intCast(40))) | ((@as(c_ulonglong, @bitCast(@as(c_ulonglong, __bsx))) & @as(c_ulonglong, 255)) << @intCast(56)))))); -} -pub fn __uint16_identity(arg___x: __uint16_t) callconv(.C) __uint16_t { - var __x = arg___x; - _ = &__x; - return __x; -} -pub fn __uint32_identity(arg___x: __uint32_t) callconv(.C) __uint32_t { - var __x = arg___x; - _ = &__x; - return __x; -} -pub fn __uint64_identity(arg___x: __uint64_t) callconv(.C) __uint64_t { - var __x = arg___x; - _ = &__x; - return __x; -} -pub const __sigset_t = extern struct { - __val: [16]c_ulong = @import("std").mem.zeroes([16]c_ulong), -}; -pub const sigset_t = __sigset_t; -pub const struct_timeval = extern struct { - tv_sec: __time_t = @import("std").mem.zeroes(__time_t), - tv_usec: __suseconds_t = @import("std").mem.zeroes(__suseconds_t), -}; -pub const struct_timespec = extern struct { - tv_sec: __time_t = @import("std").mem.zeroes(__time_t), - tv_nsec: __syscall_slong_t = @import("std").mem.zeroes(__syscall_slong_t), -}; -pub const suseconds_t = __suseconds_t; -pub const __fd_mask = c_long; -pub const fd_set = extern struct { - __fds_bits: [16]__fd_mask = @import("std").mem.zeroes([16]__fd_mask), -}; -pub const fd_mask = __fd_mask; -pub extern fn select(__nfds: c_int, noalias __readfds: [*c]fd_set, noalias __writefds: [*c]fd_set, noalias __exceptfds: [*c]fd_set, noalias __timeout: [*c]struct_timeval) c_int; -pub extern fn pselect(__nfds: c_int, noalias __readfds: [*c]fd_set, noalias __writefds: [*c]fd_set, noalias __exceptfds: [*c]fd_set, noalias __timeout: [*c]const struct_timespec, noalias __sigmask: [*c]const __sigset_t) c_int; -pub const blksize_t = __blksize_t; -pub const blkcnt_t = __blkcnt_t; -pub const fsblkcnt_t = __fsblkcnt_t; -pub const fsfilcnt_t = __fsfilcnt_t; -const struct_unnamed_4 = extern struct { - __low: c_uint = @import("std").mem.zeroes(c_uint), - __high: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub const __atomic_wide_counter = extern union { - __value64: c_ulonglong, - __value32: struct_unnamed_4, -}; -pub const struct___pthread_internal_list = extern struct { - __prev: [*c]struct___pthread_internal_list = @import("std").mem.zeroes([*c]struct___pthread_internal_list), - __next: [*c]struct___pthread_internal_list = @import("std").mem.zeroes([*c]struct___pthread_internal_list), -}; -pub const __pthread_list_t = struct___pthread_internal_list; -pub const struct___pthread_internal_slist = extern struct { - __next: [*c]struct___pthread_internal_slist = @import("std").mem.zeroes([*c]struct___pthread_internal_slist), -}; -pub const __pthread_slist_t = struct___pthread_internal_slist; -pub const struct___pthread_mutex_s = extern struct { - __lock: c_int = @import("std").mem.zeroes(c_int), - __count: c_uint = @import("std").mem.zeroes(c_uint), - __owner: c_int = @import("std").mem.zeroes(c_int), - __nusers: c_uint = @import("std").mem.zeroes(c_uint), - __kind: c_int = @import("std").mem.zeroes(c_int), - __spins: c_short = @import("std").mem.zeroes(c_short), - __elision: c_short = @import("std").mem.zeroes(c_short), - __list: __pthread_list_t = @import("std").mem.zeroes(__pthread_list_t), -}; -pub const struct___pthread_rwlock_arch_t = extern struct { - __readers: c_uint = @import("std").mem.zeroes(c_uint), - __writers: c_uint = @import("std").mem.zeroes(c_uint), - __wrphase_futex: c_uint = @import("std").mem.zeroes(c_uint), - __writers_futex: c_uint = @import("std").mem.zeroes(c_uint), - __pad3: c_uint = @import("std").mem.zeroes(c_uint), - __pad4: c_uint = @import("std").mem.zeroes(c_uint), - __cur_writer: c_int = @import("std").mem.zeroes(c_int), - __shared: c_int = @import("std").mem.zeroes(c_int), - __rwelision: i8 = @import("std").mem.zeroes(i8), - __pad1: [7]u8 = @import("std").mem.zeroes([7]u8), - __pad2: c_ulong = @import("std").mem.zeroes(c_ulong), - __flags: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub const struct___pthread_cond_s = extern struct { - __wseq: __atomic_wide_counter = @import("std").mem.zeroes(__atomic_wide_counter), - __g1_start: __atomic_wide_counter = @import("std").mem.zeroes(__atomic_wide_counter), - __g_refs: [2]c_uint = @import("std").mem.zeroes([2]c_uint), - __g_size: [2]c_uint = @import("std").mem.zeroes([2]c_uint), - __g1_orig_size: c_uint = @import("std").mem.zeroes(c_uint), - __wrefs: c_uint = @import("std").mem.zeroes(c_uint), - __g_signals: [2]c_uint = @import("std").mem.zeroes([2]c_uint), -}; -pub const __tss_t = c_uint; -pub const __thrd_t = c_ulong; -pub const __once_flag = extern struct { - __data: c_int = @import("std").mem.zeroes(c_int), -}; -pub const pthread_t = c_ulong; -pub const pthread_mutexattr_t = extern union { - __size: [4]u8, - __align: c_int, -}; -pub const pthread_condattr_t = extern union { - __size: [4]u8, - __align: c_int, -}; -pub const pthread_key_t = c_uint; -pub const pthread_once_t = c_int; -pub const union_pthread_attr_t = extern union { - __size: [56]u8, - __align: c_long, -}; -pub const pthread_attr_t = union_pthread_attr_t; -pub const pthread_mutex_t = extern union { - __data: struct___pthread_mutex_s, - __size: [40]u8, - __align: c_long, -}; -pub const pthread_cond_t = extern union { - __data: struct___pthread_cond_s, - __size: [48]u8, - __align: c_longlong, -}; -pub const pthread_rwlock_t = extern union { - __data: struct___pthread_rwlock_arch_t, - __size: [56]u8, - __align: c_long, -}; -pub const pthread_rwlockattr_t = extern union { - __size: [8]u8, - __align: c_long, -}; -pub const pthread_spinlock_t = c_int; -pub const pthread_barrier_t = extern union { - __size: [32]u8, - __align: c_long, -}; -pub const pthread_barrierattr_t = extern union { - __size: [4]u8, - __align: c_int, -}; -pub extern fn random() c_long; -pub extern fn srandom(__seed: c_uint) void; -pub extern fn initstate(__seed: c_uint, __statebuf: [*c]u8, __statelen: usize) [*c]u8; -pub extern fn setstate(__statebuf: [*c]u8) [*c]u8; -pub const struct_random_data = extern struct { - fptr: [*c]i32 = @import("std").mem.zeroes([*c]i32), - rptr: [*c]i32 = @import("std").mem.zeroes([*c]i32), - state: [*c]i32 = @import("std").mem.zeroes([*c]i32), - rand_type: c_int = @import("std").mem.zeroes(c_int), - rand_deg: c_int = @import("std").mem.zeroes(c_int), - rand_sep: c_int = @import("std").mem.zeroes(c_int), - end_ptr: [*c]i32 = @import("std").mem.zeroes([*c]i32), -}; -pub extern fn random_r(noalias __buf: [*c]struct_random_data, noalias __result: [*c]i32) c_int; -pub extern fn srandom_r(__seed: c_uint, __buf: [*c]struct_random_data) c_int; -pub extern fn initstate_r(__seed: c_uint, noalias __statebuf: [*c]u8, __statelen: usize, noalias __buf: [*c]struct_random_data) c_int; -pub extern fn setstate_r(noalias __statebuf: [*c]u8, noalias __buf: [*c]struct_random_data) c_int; -pub extern fn rand() c_int; -pub extern fn srand(__seed: c_uint) void; -pub extern fn rand_r(__seed: [*c]c_uint) c_int; -pub extern fn drand48() f64; -pub extern fn erand48(__xsubi: [*c]c_ushort) f64; -pub extern fn lrand48() c_long; -pub extern fn nrand48(__xsubi: [*c]c_ushort) c_long; -pub extern fn mrand48() c_long; -pub extern fn jrand48(__xsubi: [*c]c_ushort) c_long; -pub extern fn srand48(__seedval: c_long) void; -pub extern fn seed48(__seed16v: [*c]c_ushort) [*c]c_ushort; -pub extern fn lcong48(__param: [*c]c_ushort) void; -pub const struct_drand48_data = extern struct { - __x: [3]c_ushort = @import("std").mem.zeroes([3]c_ushort), - __old_x: [3]c_ushort = @import("std").mem.zeroes([3]c_ushort), - __c: c_ushort = @import("std").mem.zeroes(c_ushort), - __init: c_ushort = @import("std").mem.zeroes(c_ushort), - __a: c_ulonglong = @import("std").mem.zeroes(c_ulonglong), -}; -pub extern fn drand48_r(noalias __buffer: [*c]struct_drand48_data, noalias __result: [*c]f64) c_int; -pub extern fn erand48_r(__xsubi: [*c]c_ushort, noalias __buffer: [*c]struct_drand48_data, noalias __result: [*c]f64) c_int; -pub extern fn lrand48_r(noalias __buffer: [*c]struct_drand48_data, noalias __result: [*c]c_long) c_int; -pub extern fn nrand48_r(__xsubi: [*c]c_ushort, noalias __buffer: [*c]struct_drand48_data, noalias __result: [*c]c_long) c_int; -pub extern fn mrand48_r(noalias __buffer: [*c]struct_drand48_data, noalias __result: [*c]c_long) c_int; -pub extern fn jrand48_r(__xsubi: [*c]c_ushort, noalias __buffer: [*c]struct_drand48_data, noalias __result: [*c]c_long) c_int; -pub extern fn srand48_r(__seedval: c_long, __buffer: [*c]struct_drand48_data) c_int; -pub extern fn seed48_r(__seed16v: [*c]c_ushort, __buffer: [*c]struct_drand48_data) c_int; -pub extern fn lcong48_r(__param: [*c]c_ushort, __buffer: [*c]struct_drand48_data) c_int; -pub extern fn arc4random() __uint32_t; -pub extern fn arc4random_buf(__buf: ?*anyopaque, __size: usize) void; -pub extern fn arc4random_uniform(__upper_bound: __uint32_t) __uint32_t; -pub extern fn malloc(__size: c_ulong) ?*anyopaque; -pub extern fn calloc(__nmemb: c_ulong, __size: c_ulong) ?*anyopaque; -pub extern fn realloc(__ptr: ?*anyopaque, __size: c_ulong) ?*anyopaque; -pub extern fn free(__ptr: ?*anyopaque) void; -pub extern fn reallocarray(__ptr: ?*anyopaque, __nmemb: usize, __size: usize) ?*anyopaque; -pub extern fn alloca(__size: c_ulong) ?*anyopaque; -pub extern fn valloc(__size: usize) ?*anyopaque; -pub extern fn posix_memalign(__memptr: [*c]?*anyopaque, __alignment: usize, __size: usize) c_int; -pub extern fn aligned_alloc(__alignment: c_ulong, __size: c_ulong) ?*anyopaque; -pub extern fn abort() noreturn; -pub extern fn atexit(__func: ?*const fn () callconv(.C) void) c_int; -pub extern fn at_quick_exit(__func: ?*const fn () callconv(.C) void) c_int; -pub extern fn on_exit(__func: ?*const fn (c_int, ?*anyopaque) callconv(.C) void, __arg: ?*anyopaque) c_int; -pub extern fn exit(__status: c_int) noreturn; -pub extern fn quick_exit(__status: c_int) noreturn; -pub extern fn _Exit(__status: c_int) noreturn; -pub extern fn getenv(__name: [*c]const u8) [*c]u8; -pub extern fn putenv(__string: [*c]u8) c_int; -pub extern fn setenv(__name: [*c]const u8, __value: [*c]const u8, __replace: c_int) c_int; -pub extern fn unsetenv(__name: [*c]const u8) c_int; -pub extern fn clearenv() c_int; -pub extern fn mktemp(__template: [*c]u8) [*c]u8; -pub extern fn mkstemp(__template: [*c]u8) c_int; -pub extern fn mkstemps(__template: [*c]u8, __suffixlen: c_int) c_int; -pub extern fn mkdtemp(__template: [*c]u8) [*c]u8; -pub extern fn system(__command: [*c]const u8) c_int; -pub extern fn realpath(noalias __name: [*c]const u8, noalias __resolved: [*c]u8) [*c]u8; -pub const __compar_fn_t = ?*const fn (?*const anyopaque, ?*const anyopaque) callconv(.C) c_int; -pub extern fn bsearch(__key: ?*const anyopaque, __base: ?*const anyopaque, __nmemb: usize, __size: usize, __compar: __compar_fn_t) ?*anyopaque; -pub extern fn qsort(__base: ?*anyopaque, __nmemb: usize, __size: usize, __compar: __compar_fn_t) void; -pub extern fn abs(__x: c_int) c_int; -pub extern fn labs(__x: c_long) c_long; -pub extern fn llabs(__x: c_longlong) c_longlong; -pub extern fn div(__numer: c_int, __denom: c_int) div_t; -pub extern fn ldiv(__numer: c_long, __denom: c_long) ldiv_t; -pub extern fn lldiv(__numer: c_longlong, __denom: c_longlong) lldiv_t; -pub extern fn ecvt(__value: f64, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int) [*c]u8; -pub extern fn fcvt(__value: f64, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int) [*c]u8; -pub extern fn gcvt(__value: f64, __ndigit: c_int, __buf: [*c]u8) [*c]u8; -pub extern fn qecvt(__value: c_longdouble, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int) [*c]u8; -pub extern fn qfcvt(__value: c_longdouble, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int) [*c]u8; -pub extern fn qgcvt(__value: c_longdouble, __ndigit: c_int, __buf: [*c]u8) [*c]u8; -pub extern fn ecvt_r(__value: f64, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int, noalias __buf: [*c]u8, __len: usize) c_int; -pub extern fn fcvt_r(__value: f64, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int, noalias __buf: [*c]u8, __len: usize) c_int; -pub extern fn qecvt_r(__value: c_longdouble, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int, noalias __buf: [*c]u8, __len: usize) c_int; -pub extern fn qfcvt_r(__value: c_longdouble, __ndigit: c_int, noalias __decpt: [*c]c_int, noalias __sign: [*c]c_int, noalias __buf: [*c]u8, __len: usize) c_int; -pub extern fn mblen(__s: [*c]const u8, __n: usize) c_int; -pub extern fn mbtowc(noalias __pwc: [*c]wchar_t, noalias __s: [*c]const u8, __n: usize) c_int; -pub extern fn wctomb(__s: [*c]u8, __wchar: wchar_t) c_int; -pub extern fn mbstowcs(noalias __pwcs: [*c]wchar_t, noalias __s: [*c]const u8, __n: usize) usize; -pub extern fn wcstombs(noalias __s: [*c]u8, noalias __pwcs: [*c]const wchar_t, __n: usize) usize; -pub extern fn rpmatch(__response: [*c]const u8) c_int; -pub extern fn getsubopt(noalias __optionp: [*c][*c]u8, noalias __tokens: [*c]const [*c]u8, noalias __valuep: [*c][*c]u8) c_int; -pub extern fn getloadavg(__loadavg: [*c]f64, __nelem: c_int) c_int; -pub extern fn memcpy(__dest: ?*anyopaque, __src: ?*const anyopaque, __n: c_ulong) ?*anyopaque; -pub extern fn memmove(__dest: ?*anyopaque, __src: ?*const anyopaque, __n: c_ulong) ?*anyopaque; -pub extern fn memccpy(__dest: ?*anyopaque, __src: ?*const anyopaque, __c: c_int, __n: c_ulong) ?*anyopaque; -pub extern fn memset(__s: ?*anyopaque, __c: c_int, __n: c_ulong) ?*anyopaque; -pub extern fn memcmp(__s1: ?*const anyopaque, __s2: ?*const anyopaque, __n: c_ulong) c_int; -pub extern fn __memcmpeq(__s1: ?*const anyopaque, __s2: ?*const anyopaque, __n: usize) c_int; -pub extern fn memchr(__s: ?*const anyopaque, __c: c_int, __n: c_ulong) ?*anyopaque; -pub extern fn strcpy(__dest: [*c]u8, __src: [*c]const u8) [*c]u8; -pub extern fn strncpy(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8; -pub extern fn strcat(__dest: [*c]u8, __src: [*c]const u8) [*c]u8; -pub extern fn strncat(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8; -pub extern fn strcmp(__s1: [*c]const u8, __s2: [*c]const u8) c_int; -pub extern fn strncmp(__s1: [*c]const u8, __s2: [*c]const u8, __n: c_ulong) c_int; -pub extern fn strcoll(__s1: [*c]const u8, __s2: [*c]const u8) c_int; -pub extern fn strxfrm(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) c_ulong; -pub const struct___locale_data_5 = opaque {}; -pub const struct___locale_struct = extern struct { - __locales: [13]?*struct___locale_data_5 = @import("std").mem.zeroes([13]?*struct___locale_data_5), - __ctype_b: [*c]const c_ushort = @import("std").mem.zeroes([*c]const c_ushort), - __ctype_tolower: [*c]const c_int = @import("std").mem.zeroes([*c]const c_int), - __ctype_toupper: [*c]const c_int = @import("std").mem.zeroes([*c]const c_int), - __names: [13][*c]const u8 = @import("std").mem.zeroes([13][*c]const u8), -}; -pub const __locale_t = [*c]struct___locale_struct; -pub const locale_t = __locale_t; -pub extern fn strcoll_l(__s1: [*c]const u8, __s2: [*c]const u8, __l: locale_t) c_int; -pub extern fn strxfrm_l(__dest: [*c]u8, __src: [*c]const u8, __n: usize, __l: locale_t) usize; -pub extern fn strdup(__s: [*c]const u8) [*c]u8; -pub extern fn strndup(__string: [*c]const u8, __n: c_ulong) [*c]u8; -pub extern fn strchr(__s: [*c]const u8, __c: c_int) [*c]u8; -pub extern fn strrchr(__s: [*c]const u8, __c: c_int) [*c]u8; -pub extern fn strchrnul(__s: [*c]const u8, __c: c_int) [*c]u8; -pub extern fn strcspn(__s: [*c]const u8, __reject: [*c]const u8) c_ulong; -pub extern fn strspn(__s: [*c]const u8, __accept: [*c]const u8) c_ulong; -pub extern fn strpbrk(__s: [*c]const u8, __accept: [*c]const u8) [*c]u8; -pub extern fn strstr(__haystack: [*c]const u8, __needle: [*c]const u8) [*c]u8; -pub extern fn strtok(__s: [*c]u8, __delim: [*c]const u8) [*c]u8; -pub extern fn __strtok_r(noalias __s: [*c]u8, noalias __delim: [*c]const u8, noalias __save_ptr: [*c][*c]u8) [*c]u8; -pub extern fn strtok_r(noalias __s: [*c]u8, noalias __delim: [*c]const u8, noalias __save_ptr: [*c][*c]u8) [*c]u8; -pub extern fn strcasestr(__haystack: [*c]const u8, __needle: [*c]const u8) [*c]u8; -pub extern fn memmem(__haystack: ?*const anyopaque, __haystacklen: usize, __needle: ?*const anyopaque, __needlelen: usize) ?*anyopaque; -pub extern fn __mempcpy(noalias __dest: ?*anyopaque, noalias __src: ?*const anyopaque, __n: usize) ?*anyopaque; -pub extern fn mempcpy(__dest: ?*anyopaque, __src: ?*const anyopaque, __n: c_ulong) ?*anyopaque; -pub extern fn strlen(__s: [*c]const u8) c_ulong; -pub extern fn strnlen(__string: [*c]const u8, __maxlen: usize) usize; -pub extern fn strerror(__errnum: c_int) [*c]u8; -pub extern fn strerror_r(__errnum: c_int, __buf: [*c]u8, __buflen: usize) c_int; -pub extern fn strerror_l(__errnum: c_int, __l: locale_t) [*c]u8; -pub extern fn bcmp(__s1: ?*const anyopaque, __s2: ?*const anyopaque, __n: c_ulong) c_int; -pub extern fn bcopy(__src: ?*const anyopaque, __dest: ?*anyopaque, __n: c_ulong) void; -pub extern fn bzero(__s: ?*anyopaque, __n: c_ulong) void; -pub extern fn index(__s: [*c]const u8, __c: c_int) [*c]u8; -pub extern fn rindex(__s: [*c]const u8, __c: c_int) [*c]u8; -pub extern fn ffs(__i: c_int) c_int; -pub extern fn ffsl(__l: c_long) c_int; -pub extern fn ffsll(__ll: c_longlong) c_int; -pub extern fn strcasecmp(__s1: [*c]const u8, __s2: [*c]const u8) c_int; -pub extern fn strncasecmp(__s1: [*c]const u8, __s2: [*c]const u8, __n: c_ulong) c_int; -pub extern fn strcasecmp_l(__s1: [*c]const u8, __s2: [*c]const u8, __loc: locale_t) c_int; -pub extern fn strncasecmp_l(__s1: [*c]const u8, __s2: [*c]const u8, __n: usize, __loc: locale_t) c_int; -pub extern fn explicit_bzero(__s: ?*anyopaque, __n: usize) void; -pub extern fn strsep(noalias __stringp: [*c][*c]u8, noalias __delim: [*c]const u8) [*c]u8; -pub extern fn strsignal(__sig: c_int) [*c]u8; -pub extern fn __stpcpy(noalias __dest: [*c]u8, noalias __src: [*c]const u8) [*c]u8; -pub extern fn stpcpy(__dest: [*c]u8, __src: [*c]const u8) [*c]u8; -pub extern fn __stpncpy(noalias __dest: [*c]u8, noalias __src: [*c]const u8, __n: usize) [*c]u8; -pub extern fn stpncpy(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8; -pub extern fn strlcpy(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) c_ulong; -pub extern fn strlcat(__dest: [*c]u8, __src: [*c]const u8, __n: c_ulong) c_ulong; -pub const tinyobj_material_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - ambient: [3]f32 = @import("std").mem.zeroes([3]f32), - diffuse: [3]f32 = @import("std").mem.zeroes([3]f32), - specular: [3]f32 = @import("std").mem.zeroes([3]f32), - transmittance: [3]f32 = @import("std").mem.zeroes([3]f32), - emission: [3]f32 = @import("std").mem.zeroes([3]f32), - shininess: f32 = @import("std").mem.zeroes(f32), - ior: f32 = @import("std").mem.zeroes(f32), - dissolve: f32 = @import("std").mem.zeroes(f32), - illum: c_int = @import("std").mem.zeroes(c_int), - pad0: c_int = @import("std").mem.zeroes(c_int), - ambient_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), - diffuse_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), - specular_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), - specular_highlight_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), - bump_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), - displacement_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), - alpha_texname: [*c]u8 = @import("std").mem.zeroes([*c]u8), -}; -pub const tinyobj_shape_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - face_offset: c_uint = @import("std").mem.zeroes(c_uint), - length: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub const tinyobj_vertex_index_t = extern struct { - v_idx: c_int = @import("std").mem.zeroes(c_int), - vt_idx: c_int = @import("std").mem.zeroes(c_int), - vn_idx: c_int = @import("std").mem.zeroes(c_int), -}; -pub const tinyobj_attrib_t = extern struct { - num_vertices: c_uint = @import("std").mem.zeroes(c_uint), - num_normals: c_uint = @import("std").mem.zeroes(c_uint), - num_texcoords: c_uint = @import("std").mem.zeroes(c_uint), - num_faces: c_uint = @import("std").mem.zeroes(c_uint), - num_face_num_verts: c_uint = @import("std").mem.zeroes(c_uint), - pad0: c_int = @import("std").mem.zeroes(c_int), - vertices: [*c]f32 = @import("std").mem.zeroes([*c]f32), - normals: [*c]f32 = @import("std").mem.zeroes([*c]f32), - texcoords: [*c]f32 = @import("std").mem.zeroes([*c]f32), - faces: [*c]tinyobj_vertex_index_t = @import("std").mem.zeroes([*c]tinyobj_vertex_index_t), - face_num_verts: [*c]c_int = @import("std").mem.zeroes([*c]c_int), - material_ids: [*c]c_int = @import("std").mem.zeroes([*c]c_int), -}; -pub export fn tinyobj_parse_obj(arg_attrib: [*c]tinyobj_attrib_t, arg_shapes: [*c][*c]tinyobj_shape_t, arg_num_shapes: [*c]c_uint, arg_materials_out: [*c][*c]tinyobj_material_t, arg_num_materials_out: [*c]c_uint, arg_buf: [*c]const u8, arg_len: c_uint, arg_flags: c_uint) c_int { - var attrib = arg_attrib; - _ = &attrib; - var shapes = arg_shapes; - _ = &shapes; - var num_shapes = arg_num_shapes; - _ = &num_shapes; - var materials_out = arg_materials_out; - _ = &materials_out; - var num_materials_out = arg_num_materials_out; - _ = &num_materials_out; - var buf = arg_buf; - _ = &buf; - var len = arg_len; - _ = &len; - var flags = arg_flags; - _ = &flags; - var line_infos: [*c]LineInfo = null; - _ = &line_infos; - var commands: [*c]Command = null; - _ = &commands; - var num_lines: c_uint = 0; - _ = &num_lines; - var num_v: c_uint = 0; - _ = &num_v; - var num_vn: c_uint = 0; - _ = &num_vn; - var num_vt: c_uint = 0; - _ = &num_vt; - var num_f: c_uint = 0; - _ = &num_f; - var num_faces: c_uint = 0; - _ = &num_faces; - var mtllib_line_index: c_int = -@as(c_int, 1); - _ = &mtllib_line_index; - var materials: [*c]tinyobj_material_t = null; - _ = &materials; - var num_materials: c_uint = 0; - _ = &num_materials; - var material_table: hash_table_t = undefined; - _ = &material_table; - if (len < @as(c_uint, @bitCast(@as(c_int, 1)))) return -@as(c_int, 2); - if (attrib == @as([*c]tinyobj_attrib_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return -@as(c_int, 2); - if (shapes == @as([*c][*c]tinyobj_shape_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return -@as(c_int, 2); - if (num_shapes == @as([*c]c_uint, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return -@as(c_int, 2); - if (buf == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return -@as(c_int, 2); - if (materials_out == @as([*c][*c]tinyobj_material_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return -@as(c_int, 2); - if (num_materials_out == @as([*c]c_uint, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return -@as(c_int, 2); - tinyobj_attrib_init(attrib); - { - var i: c_uint = undefined; - _ = &i; - var end_idx: c_uint = len; - _ = &end_idx; - var prev_pos: c_uint = 0; - _ = &prev_pos; - var line_no: c_uint = 0; - _ = &line_no; - var last_line_ending: c_uint = 0; - _ = &last_line_ending; - { - i = 0; - while (i < end_idx) : (i +%= 1) { - if (is_line_ending(buf, i, end_idx) != 0) { - num_lines +%= 1; - last_line_ending = i; - } - } - } - if ((end_idx -% last_line_ending) > @as(c_uint, @bitCast(@as(c_int, 0)))) { - num_lines +%= 1; - } - if (num_lines == @as(c_uint, @bitCast(@as(c_int, 0)))) return -@as(c_int, 1); - line_infos = @as([*c]LineInfo, @ptrCast(@alignCast(malloc(@sizeOf(LineInfo) *% @as(c_ulong, @bitCast(@as(c_ulong, num_lines))))))); - { - i = 0; - while (i < end_idx) : (i +%= 1) { - if (is_line_ending(buf, i, end_idx) != 0) { - line_infos[line_no].pos = prev_pos; - line_infos[line_no].len = i -% prev_pos; - if ((i > @as(c_uint, @bitCast(@as(c_int, 0)))) and (@as(c_int, @bitCast(@as(c_uint, buf[i -% @as(c_uint, @bitCast(@as(c_int, 1)))]))) == @as(c_int, '\r'))) { - line_infos[line_no].len -%= 1; - } - prev_pos = i +% @as(c_uint, @bitCast(@as(c_int, 1))); - line_no +%= 1; - } - } - } - if ((end_idx -% last_line_ending) > @as(c_uint, @bitCast(@as(c_int, 0)))) { - line_infos[line_no].pos = prev_pos; - line_infos[line_no].len = (end_idx -% @as(c_uint, @bitCast(@as(c_int, 1)))) -% last_line_ending; - } - } - commands = @as([*c]Command, @ptrCast(@alignCast(malloc(@sizeOf(Command) *% @as(c_ulong, @bitCast(@as(c_ulong, num_lines))))))); - create_hash_table(@as(c_uint, @bitCast(@as(c_int, 10))), &material_table); - { - var i: c_uint = 0; - _ = &i; - { - i = 0; - while (i < num_lines) : (i +%= 1) { - var ret: c_int = parseLine(&commands[i], &buf[line_infos[i].pos], line_infos[i].len, @as(c_int, @bitCast(flags & @as(c_uint, @bitCast(@as(c_int, 1) << @intCast(0)))))); - _ = &ret; - if (ret != 0) { - if (commands[i].type == @as(c_uint, @bitCast(COMMAND_V))) { - num_v +%= 1; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_VN))) { - num_vn +%= 1; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_VT))) { - num_vt +%= 1; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_F))) { - num_f +%= commands[i].num_f; - num_faces +%= commands[i].num_f_num_verts; - } - if (commands[i].type == @as(c_uint, @bitCast(COMMAND_MTLLIB))) { - mtllib_line_index = @as(c_int, @bitCast(i)); - } - } - } - } - } - if (line_infos != null) { - free(@as(?*anyopaque, @ptrCast(line_infos))); - } - if (((mtllib_line_index >= @as(c_int, 0)) and ((blk: { - const tmp = mtllib_line_index; - if (tmp >= 0) break :blk commands + @as(usize, @intCast(tmp)) else break :blk commands - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.mtllib_name != null)) and ((blk: { - const tmp = mtllib_line_index; - if (tmp >= 0) break :blk commands + @as(usize, @intCast(tmp)) else break :blk commands - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.mtllib_name_len > @as(c_uint, @bitCast(@as(c_int, 0))))) { - var filename: [*c]u8 = my_strndup((blk: { - const tmp = mtllib_line_index; - if (tmp >= 0) break :blk commands + @as(usize, @intCast(tmp)) else break :blk commands - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.mtllib_name, (blk: { - const tmp = mtllib_line_index; - if (tmp >= 0) break :blk commands + @as(usize, @intCast(tmp)) else break :blk commands - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.mtllib_name_len); - _ = &filename; - var ret: c_int = tinyobj_parse_and_index_mtl_file(&materials, &num_materials, filename, &material_table); - _ = &ret; - if (ret != @as(c_int, 0)) { - _ = fprintf(stderr, "TINYOBJ: Failed to parse material file '%s': %d\n", filename, ret); - } - free(@as(?*anyopaque, @ptrCast(filename))); - } - { - var v_count: c_uint = 0; - _ = &v_count; - var n_count: c_uint = 0; - _ = &n_count; - var t_count: c_uint = 0; - _ = &t_count; - var f_count: c_uint = 0; - _ = &f_count; - var face_count: c_uint = 0; - _ = &face_count; - var material_id: c_int = -@as(c_int, 1); - _ = &material_id; - var i: c_uint = 0; - _ = &i; - attrib.*.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc((@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_ulong, num_v)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - attrib.*.num_vertices = num_v; - attrib.*.normals = @as([*c]f32, @ptrCast(@alignCast(malloc((@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_ulong, num_vn)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - attrib.*.num_normals = num_vn; - attrib.*.texcoords = @as([*c]f32, @ptrCast(@alignCast(malloc((@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_ulong, num_vt)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2)))))))); - attrib.*.num_texcoords = num_vt; - attrib.*.faces = @as([*c]tinyobj_vertex_index_t, @ptrCast(@alignCast(malloc(@sizeOf(tinyobj_vertex_index_t) *% @as(c_ulong, @bitCast(@as(c_ulong, num_f))))))); - attrib.*.face_num_verts = @as([*c]c_int, @ptrCast(@alignCast(malloc(@sizeOf(c_int) *% @as(c_ulong, @bitCast(@as(c_ulong, num_faces))))))); - attrib.*.num_faces = num_faces; - attrib.*.num_face_num_verts = num_f; - attrib.*.material_ids = @as([*c]c_int, @ptrCast(@alignCast(malloc(@sizeOf(c_int) *% @as(c_ulong, @bitCast(@as(c_ulong, num_faces))))))); - { - i = 0; - while (i < num_lines) : (i +%= 1) { - if (commands[i].type == @as(c_uint, @bitCast(COMMAND_EMPTY))) { - continue; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_USEMTL))) { - if ((commands[i].material_name != null) and (commands[i].material_name_len > @as(c_uint, @bitCast(@as(c_int, 0))))) { - var material_name_null_term: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, commands[i].material_name_len +% @as(c_uint, @bitCast(@as(c_int, 1)))))))))); - _ = &material_name_null_term; - _ = memcpy(@as(?*anyopaque, @ptrCast(material_name_null_term)), @as(?*const anyopaque, @ptrCast(commands[i].material_name)), @as(c_ulong, @bitCast(@as(c_ulong, commands[i].material_name_len)))); - material_name_null_term[commands[i].material_name_len] = 0; - if (hash_table_exists(material_name_null_term, &material_table) != 0) { - material_id = @as(c_int, @bitCast(@as(c_int, @truncate(hash_table_get(material_name_null_term, &material_table))))); - } else { - material_id = -@as(c_int, 1); - } - free(@as(?*anyopaque, @ptrCast(material_name_null_term))); - } - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_V))) { - attrib.*.vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% v_count) +% @as(c_uint, @bitCast(@as(c_int, 0)))] = commands[i].vx; - attrib.*.vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% v_count) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = commands[i].vy; - attrib.*.vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% v_count) +% @as(c_uint, @bitCast(@as(c_int, 2)))] = commands[i].vz; - v_count +%= 1; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_VN))) { - attrib.*.normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% n_count) +% @as(c_uint, @bitCast(@as(c_int, 0)))] = commands[i].nx; - attrib.*.normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% n_count) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = commands[i].ny; - attrib.*.normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% n_count) +% @as(c_uint, @bitCast(@as(c_int, 2)))] = commands[i].nz; - n_count +%= 1; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_VT))) { - attrib.*.texcoords[(@as(c_uint, @bitCast(@as(c_int, 2))) *% t_count) +% @as(c_uint, @bitCast(@as(c_int, 0)))] = commands[i].tx; - attrib.*.texcoords[(@as(c_uint, @bitCast(@as(c_int, 2))) *% t_count) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = commands[i].ty; - t_count +%= 1; - } else if (commands[i].type == @as(c_uint, @bitCast(COMMAND_F))) { - var k: c_uint = 0; - _ = &k; - { - k = 0; - while (k < commands[i].num_f) : (k +%= 1) { - var vi: tinyobj_vertex_index_t = commands[i].f[k]; - _ = &vi; - var v_idx: c_int = fixIndex(vi.v_idx, v_count); - _ = &v_idx; - var vn_idx: c_int = fixIndex(vi.vn_idx, n_count); - _ = &vn_idx; - var vt_idx: c_int = fixIndex(vi.vt_idx, t_count); - _ = &vt_idx; - attrib.*.faces[f_count +% k].v_idx = v_idx; - attrib.*.faces[f_count +% k].vn_idx = vn_idx; - attrib.*.faces[f_count +% k].vt_idx = vt_idx; - } - } - { - k = 0; - while (k < commands[i].num_f_num_verts) : (k +%= 1) { - attrib.*.material_ids[face_count +% k] = material_id; - attrib.*.face_num_verts[face_count +% k] = commands[i].f_num_verts[k]; - } - } - f_count +%= commands[i].num_f; - face_count +%= commands[i].num_f_num_verts; - } - } - } - } - { - var face_count: c_uint = 0; - _ = &face_count; - var i: c_uint = 0; - _ = &i; - var n: c_uint = 0; - _ = &n; - var shape_idx: c_uint = 0; - _ = &shape_idx; - var shape_name: [*c]const u8 = null; - _ = &shape_name; - var shape_name_len: c_uint = 0; - _ = &shape_name_len; - var prev_shape_name: [*c]const u8 = null; - _ = &prev_shape_name; - var prev_shape_name_len: c_uint = 0; - _ = &prev_shape_name_len; - var prev_shape_face_offset: c_uint = 0; - _ = &prev_shape_face_offset; - var prev_face_offset: c_uint = 0; - _ = &prev_face_offset; - var prev_shape: tinyobj_shape_t = tinyobj_shape_t{ - .name = null, - .face_offset = @as(c_uint, @bitCast(@as(c_int, 0))), - .length = @as(c_uint, @bitCast(@as(c_int, 0))), - }; - _ = &prev_shape; - { - i = 0; - while (i < num_lines) : (i +%= 1) { - if ((commands[i].type == @as(c_uint, @bitCast(COMMAND_O))) or (commands[i].type == @as(c_uint, @bitCast(COMMAND_G)))) { - n +%= 1; - } - } - } - shapes.* = @as([*c]tinyobj_shape_t, @ptrCast(@alignCast(malloc(@sizeOf(tinyobj_shape_t) *% @as(c_ulong, @bitCast(@as(c_ulong, n +% @as(c_uint, @bitCast(@as(c_int, 1)))))))))); - { - i = 0; - while (i < num_lines) : (i +%= 1) { - if ((commands[i].type == @as(c_uint, @bitCast(COMMAND_O))) or (commands[i].type == @as(c_uint, @bitCast(COMMAND_G)))) { - if (commands[i].type == @as(c_uint, @bitCast(COMMAND_O))) { - shape_name = commands[i].object_name; - shape_name_len = commands[i].object_name_len; - } else { - shape_name = commands[i].group_name; - shape_name_len = commands[i].group_name_len; - } - if (face_count == @as(c_uint, @bitCast(@as(c_int, 0)))) { - prev_shape_name = shape_name; - prev_shape_name_len = shape_name_len; - prev_shape_face_offset = face_count; - prev_face_offset = face_count; - } else { - if (shape_idx == @as(c_uint, @bitCast(@as(c_int, 0)))) { - shapes.*[shape_idx].name = my_strndup(prev_shape_name, prev_shape_name_len); - shapes.*[shape_idx].face_offset = prev_shape.face_offset; - shapes.*[shape_idx].length = face_count -% prev_face_offset; - shape_idx +%= 1; - prev_face_offset = face_count; - } else { - if ((face_count -% prev_face_offset) > @as(c_uint, @bitCast(@as(c_int, 0)))) { - shapes.*[shape_idx].name = my_strndup(prev_shape_name, prev_shape_name_len); - shapes.*[shape_idx].face_offset = prev_face_offset; - shapes.*[shape_idx].length = face_count -% prev_face_offset; - shape_idx +%= 1; - prev_face_offset = face_count; - } - } - prev_shape_name = shape_name; - prev_shape_name_len = shape_name_len; - prev_shape_face_offset = face_count; - } - } - if (commands[i].type == @as(c_uint, @bitCast(COMMAND_F))) { - face_count +%= 1; - } - } - } - if ((face_count -% prev_face_offset) > @as(c_uint, @bitCast(@as(c_int, 0)))) { - var length: c_uint = face_count -% prev_shape_face_offset; - _ = &length; - if (length > @as(c_uint, @bitCast(@as(c_int, 0)))) { - shapes.*[shape_idx].name = my_strndup(prev_shape_name, prev_shape_name_len); - shapes.*[shape_idx].face_offset = prev_face_offset; - shapes.*[shape_idx].length = face_count -% prev_face_offset; - shape_idx +%= 1; - } - } else {} - num_shapes.* = shape_idx; - } - if (commands != null) { - free(@as(?*anyopaque, @ptrCast(commands))); - } - destroy_hash_table(&material_table); - materials_out.* = materials; - num_materials_out.* = num_materials; - return @as(c_int, 0); -} -pub export fn tinyobj_parse_mtl_file(arg_materials_out: [*c][*c]tinyobj_material_t, arg_num_materials_out: [*c]c_uint, arg_filename: [*c]const u8) c_int { - var materials_out = arg_materials_out; - _ = &materials_out; - var num_materials_out = arg_num_materials_out; - _ = &num_materials_out; - var filename = arg_filename; - _ = &filename; - return tinyobj_parse_and_index_mtl_file(materials_out, num_materials_out, filename, null); -} -pub export fn tinyobj_attrib_init(arg_attrib: [*c]tinyobj_attrib_t) void { - var attrib = arg_attrib; - _ = &attrib; - attrib.*.vertices = null; - attrib.*.num_vertices = 0; - attrib.*.normals = null; - attrib.*.num_normals = 0; - attrib.*.texcoords = null; - attrib.*.num_texcoords = 0; - attrib.*.faces = null; - attrib.*.num_faces = 0; - attrib.*.face_num_verts = null; - attrib.*.num_face_num_verts = 0; - attrib.*.material_ids = null; -} -pub export fn tinyobj_attrib_free(arg_attrib: [*c]tinyobj_attrib_t) void { - var attrib = arg_attrib; - _ = &attrib; - if (attrib.*.vertices != null) { - free(@as(?*anyopaque, @ptrCast(attrib.*.vertices))); - } - if (attrib.*.normals != null) { - free(@as(?*anyopaque, @ptrCast(attrib.*.normals))); - } - if (attrib.*.texcoords != null) { - free(@as(?*anyopaque, @ptrCast(attrib.*.texcoords))); - } - if (attrib.*.faces != null) { - free(@as(?*anyopaque, @ptrCast(attrib.*.faces))); - } - if (attrib.*.face_num_verts != null) { - free(@as(?*anyopaque, @ptrCast(attrib.*.face_num_verts))); - } - if (attrib.*.material_ids != null) { - free(@as(?*anyopaque, @ptrCast(attrib.*.material_ids))); - } -} -pub export fn tinyobj_shapes_free(arg_shapes: [*c]tinyobj_shape_t, arg_num_shapes: c_uint) void { - var shapes = arg_shapes; - _ = &shapes; - var num_shapes = arg_num_shapes; - _ = &num_shapes; - var i: c_uint = undefined; - _ = &i; - if (shapes == @as([*c]tinyobj_shape_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return; - { - i = 0; - while (i < num_shapes) : (i +%= 1) { - if (shapes[i].name != null) { - free(@as(?*anyopaque, @ptrCast(shapes[i].name))); - } - } - } - free(@as(?*anyopaque, @ptrCast(shapes))); -} -pub export fn tinyobj_materials_free(arg_materials: [*c]tinyobj_material_t, arg_num_materials: c_uint) void { - var materials = arg_materials; - _ = &materials; - var num_materials = arg_num_materials; - _ = &num_materials; - var i: c_uint = undefined; - _ = &i; - if (materials == @as([*c]tinyobj_material_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return; - { - i = 0; - while (i < num_materials) : (i +%= 1) { - if (materials[i].name != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].name))); - } - if (materials[i].ambient_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].ambient_texname))); - } - if (materials[i].diffuse_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].diffuse_texname))); - } - if (materials[i].specular_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].specular_texname))); - } - if (materials[i].specular_highlight_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].specular_highlight_texname))); - } - if (materials[i].bump_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].bump_texname))); - } - if (materials[i].displacement_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].displacement_texname))); - } - if (materials[i].alpha_texname != null) { - free(@as(?*anyopaque, @ptrCast(materials[i].alpha_texname))); - } - } - } - free(@as(?*anyopaque, @ptrCast(materials))); -} -pub extern fn __assert_fail(__assertion: [*c]const u8, __file: [*c]const u8, __line: c_uint, __function: [*c]const u8) noreturn; -pub extern fn __assert_perror_fail(__errnum: c_int, __file: [*c]const u8, __line: c_uint, __function: [*c]const u8) noreturn; -pub extern fn __assert(__assertion: [*c]const u8, __file: [*c]const u8, __line: c_int) noreturn; -pub extern fn __errno_location() [*c]c_int; -pub fn skip_space(arg_token: [*c][*c]const u8) callconv(.C) void { - var token = arg_token; - _ = &token; - while ((@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\t'))) { - token.* += 1; - } -} -pub fn skip_space_and_cr(arg_token: [*c][*c]const u8) callconv(.C) void { - var token = arg_token; - _ = &token; - while (((@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\t'))) or (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\r'))) { - token.* += 1; - } -} -pub fn until_space(arg_token: [*c]const u8) callconv(.C) c_int { - var token = arg_token; - _ = &token; - var p: [*c]const u8 = token; - _ = &p; - while ((((@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\x00')) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, ' '))) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\t'))) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\r'))) { - p += 1; - } - return @as(c_int, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(p) -% @intFromPtr(token))), @sizeOf(u8)))))); -} -pub fn length_until_newline(arg_token: [*c]const u8, arg_n: c_uint) callconv(.C) c_uint { - var token = arg_token; - _ = &token; - var n = arg_n; - _ = &n; - var len: c_uint = 0; - _ = &len; - { - len = 0; - while (len < (n -% @as(c_uint, @bitCast(@as(c_int, 1))))) : (len +%= 1) { - if (@as(c_int, @bitCast(@as(c_uint, token[len]))) == @as(c_int, '\n')) { - break; - } - if ((@as(c_int, @bitCast(@as(c_uint, token[len]))) == @as(c_int, '\r')) and ((len < (n -% @as(c_uint, @bitCast(@as(c_int, 2))))) and (@as(c_int, @bitCast(@as(c_uint, token[len +% @as(c_uint, @bitCast(@as(c_int, 1)))]))) != @as(c_int, '\n')))) { - break; - } - } - } - return len; -} -pub fn length_until_line_feed(arg_token: [*c]const u8, arg_n: c_uint) callconv(.C) c_uint { - var token = arg_token; - _ = &token; - var n = arg_n; - _ = &n; - var len: c_uint = 0; - _ = &len; - { - len = 0; - while (len < n) : (len +%= 1) { - if ((@as(c_int, @bitCast(@as(c_uint, token[len]))) == @as(c_int, '\n')) or (@as(c_int, @bitCast(@as(c_uint, token[len]))) == @as(c_int, '\r'))) { - break; - } - } - } - return len; -} -pub fn my_atoi(arg_c: [*c]const u8) callconv(.C) c_int { - var c = arg_c; - _ = &c; - var value: c_int = 0; - _ = &value; - var sign: c_int = 1; - _ = &sign; - if ((@as(c_int, @bitCast(@as(c_uint, c.*))) == @as(c_int, '+')) or (@as(c_int, @bitCast(@as(c_uint, c.*))) == @as(c_int, '-'))) { - if (@as(c_int, @bitCast(@as(c_uint, c.*))) == @as(c_int, '-')) { - sign = -@as(c_int, 1); - } - c += 1; - } - while ((@as(c_int, @bitCast(@as(c_uint, c.*))) >= @as(c_int, '0')) and (@as(c_int, @bitCast(@as(c_uint, c.*))) <= @as(c_int, '9'))) { - value *= @as(c_int, 10); - value += @as(c_int, @bitCast(@as(c_uint, c.*))) - @as(c_int, '0'); - c += 1; - } - return value * sign; -} -pub fn fixIndex(arg_idx: c_int, arg_n: c_uint) callconv(.C) c_int { - var idx = arg_idx; - _ = &idx; - var n = arg_n; - _ = &n; - if (idx > @as(c_int, 0)) return idx - @as(c_int, 1); - if (idx == @as(c_int, 0)) return 0; - return @as(c_int, @bitCast(n)) + idx; -} -pub fn parseRawTriple(arg_token: [*c][*c]const u8) callconv(.C) tinyobj_vertex_index_t { - var token = arg_token; - _ = &token; - var vi: tinyobj_vertex_index_t = undefined; - _ = &vi; - vi.v_idx = @as(c_int, @bitCast(@as(c_uint, 2147483648))); - vi.vn_idx = @as(c_int, @bitCast(@as(c_uint, 2147483648))); - vi.vt_idx = @as(c_int, @bitCast(@as(c_uint, 2147483648))); - vi.v_idx = my_atoi(token.*); - while (((((@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\x00')) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '/'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, ' '))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\t'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\r'))) { - token.* += 1; - } - if (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '/')) { - return vi; - } - token.* += 1; - if (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '/')) { - token.* += 1; - vi.vn_idx = my_atoi(token.*); - while (((((@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\x00')) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '/'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, ' '))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\t'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\r'))) { - token.* += 1; - } - return vi; - } - vi.vt_idx = my_atoi(token.*); - while (((((@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\x00')) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '/'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, ' '))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\t'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\r'))) { - token.* += 1; - } - if (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '/')) { - return vi; - } - token.* += 1; - vi.vn_idx = my_atoi(token.*); - while (((((@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\x00')) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '/'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, ' '))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\t'))) and (@as(c_int, @bitCast(@as(c_uint, token.*[@as(c_uint, @intCast(@as(c_int, 0)))]))) != @as(c_int, '\r'))) { - token.* += 1; - } - return vi; -} -pub fn parseInt(arg_token: [*c][*c]const u8) callconv(.C) c_int { - var token = arg_token; - _ = &token; - var i: c_int = 0; - _ = &i; - skip_space(token); - i = my_atoi(token.*); - token.* += @as(usize, @bitCast(@as(isize, @intCast(until_space(token.*))))); - return i; -} -// ./external/tinyobj_loader_c.h:334:5: warning: TODO implement translation of stmt class GotoStmtClass - -// ./external/tinyobj_loader_c.h:296:12: warning: unable to translate function, demoted to extern -pub extern fn tryParseDouble(arg_s: [*c]const u8, arg_s_end: [*c]const u8, arg_result: [*c]f64) callconv(.C) c_int; -pub fn parseFloat(arg_token: [*c][*c]const u8) callconv(.C) f32 { - var token = arg_token; - _ = &token; - var end: [*c]const u8 = undefined; - _ = &end; - var val: f64 = 0.0; - _ = &val; - var f: f32 = 0.0; - _ = &f; - skip_space(token); - end = token.* + @as(usize, @bitCast(@as(isize, @intCast(until_space(token.*))))); - val = 0.0; - _ = tryParseDouble(token.*, end, &val); - f = @as(f32, @floatCast(val)); - token.* = end; - return f; -} -pub fn parseFloat2(arg_x: [*c]f32, arg_y: [*c]f32, arg_token: [*c][*c]const u8) callconv(.C) void { - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var token = arg_token; - _ = &token; - x.* = parseFloat(token); - y.* = parseFloat(token); -} -pub fn parseFloat3(arg_x: [*c]f32, arg_y: [*c]f32, arg_z: [*c]f32, arg_token: [*c][*c]const u8) callconv(.C) void { - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var token = arg_token; - _ = &token; - x.* = parseFloat(token); - y.* = parseFloat(token); - z.* = parseFloat(token); -} -pub fn my_strnlen(arg_s: [*c]const u8, arg_n: c_uint) callconv(.C) c_uint { - var s = arg_s; - _ = &s; - var n = arg_n; - _ = &n; - var p: [*c]const u8 = @as([*c]const u8, @ptrCast(@alignCast(memchr(@as(?*const anyopaque, @ptrCast(s)), @as(c_int, 0), @as(c_ulong, @bitCast(@as(c_ulong, n))))))); - _ = &p; - return if (p != null) @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(p) -% @intFromPtr(s))), @sizeOf(u8)))))) else n; -} -pub fn my_strdup(arg_s: [*c]const u8, arg_max_length: c_uint) callconv(.C) [*c]u8 { - var s = arg_s; - _ = &s; - var max_length = arg_max_length; - _ = &max_length; - var d: [*c]u8 = undefined; - _ = &d; - var len: c_uint = undefined; - _ = &len; - if (s == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return null; - len = length_until_line_feed(s, max_length); - d = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, len +% @as(c_uint, @bitCast(@as(c_int, 1)))))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(d)), @as(?*const anyopaque, @ptrCast(s)), @as(c_ulong, @bitCast(@as(c_ulong, len)))); - d[len] = '\x00'; - return d; -} -pub fn my_strndup(arg_s: [*c]const u8, arg_len: c_uint) callconv(.C) [*c]u8 { - var s = arg_s; - _ = &s; - var len = arg_len; - _ = &len; - var d: [*c]u8 = undefined; - _ = &d; - var slen: c_uint = undefined; - _ = &slen; - if (s == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return null; - if (len == @as(c_uint, @bitCast(@as(c_int, 0)))) return null; - slen = my_strnlen(s, len); - d = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, slen +% @as(c_uint, @bitCast(@as(c_int, 1)))))))))); - if (!(d != null)) { - return null; - } - _ = memcpy(@as(?*anyopaque, @ptrCast(d)), @as(?*const anyopaque, @ptrCast(s)), @as(c_ulong, @bitCast(@as(c_ulong, slen)))); - d[slen] = '\x00'; - return d; -} -pub export fn dynamic_fgets(arg_buf: [*c][*c]u8, arg_size: [*c]c_uint, arg_file: [*c]FILE) [*c]u8 { - var buf = arg_buf; - _ = &buf; - var size = arg_size; - _ = &size; - var file = arg_file; - _ = &file; - var offset: [*c]u8 = undefined; - _ = &offset; - var ret: [*c]u8 = undefined; - _ = &ret; - var old_size: c_uint = undefined; - _ = &old_size; - if (!((blk: { - const tmp = fgets(buf.*, @as(c_int, @bitCast(size.*)), file); - ret = tmp; - break :blk tmp; - }) != null)) { - return ret; - } - if (@as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))) != strchr(buf.*, @as(c_int, '\n'))) { - return ret; - } - while (true) { - old_size = size.*; - size.* *%= @as(c_uint, @bitCast(@as(c_int, 2))); - buf.* = @as([*c]u8, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(buf.*)), @as(c_ulong, @bitCast(@as(c_ulong, size.*))))))); - offset = &buf.*[old_size -% @as(c_uint, @bitCast(@as(c_int, 1)))]; - ret = fgets(offset, @as(c_int, @bitCast(old_size +% @as(c_uint, @bitCast(@as(c_int, 1))))), file); - if (!((ret != null) and (@as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))) == strchr(buf.*, @as(c_int, '\n'))))) break; - } - return ret; -} -pub fn initMaterial(arg_material: [*c]tinyobj_material_t) callconv(.C) void { - var material = arg_material; - _ = &material; - var i: c_int = undefined; - _ = &i; - material.*.name = null; - material.*.ambient_texname = null; - material.*.diffuse_texname = null; - material.*.specular_texname = null; - material.*.specular_highlight_texname = null; - material.*.bump_texname = null; - material.*.displacement_texname = null; - material.*.alpha_texname = null; - { - i = 0; - while (i < @as(c_int, 3)) : (i += 1) { - material.*.ambient[@as(c_uint, @intCast(i))] = 0.0; - material.*.diffuse[@as(c_uint, @intCast(i))] = 0.0; - material.*.specular[@as(c_uint, @intCast(i))] = 0.0; - material.*.transmittance[@as(c_uint, @intCast(i))] = 0.0; - material.*.emission[@as(c_uint, @intCast(i))] = 0.0; - } - } - material.*.illum = 0; - material.*.dissolve = 1.0; - material.*.shininess = 1.0; - material.*.ior = 1.0; -} -pub const struct_hash_table_entry_t = extern struct { - hash: c_ulong = @import("std").mem.zeroes(c_ulong), - filled: c_int = @import("std").mem.zeroes(c_int), - pad0: c_int = @import("std").mem.zeroes(c_int), - value: c_long = @import("std").mem.zeroes(c_long), - next: [*c]struct_hash_table_entry_t = @import("std").mem.zeroes([*c]struct_hash_table_entry_t), -}; -pub const hash_table_entry_t = struct_hash_table_entry_t; -pub const hash_table_t = extern struct { - hashes: [*c]c_ulong = @import("std").mem.zeroes([*c]c_ulong), - entries: [*c]hash_table_entry_t = @import("std").mem.zeroes([*c]hash_table_entry_t), - capacity: c_uint = @import("std").mem.zeroes(c_uint), - n: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub fn hash_djb2(arg_str: [*c]const u8) callconv(.C) c_ulong { - var str = arg_str; - _ = &str; - var hash: c_ulong = @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5381)))); - _ = &hash; - var c: c_int = undefined; - _ = &c; - while ((blk: { - const tmp = @as(c_int, @bitCast(@as(c_uint, (blk_1: { - const ref = &str; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }).*))); - c = tmp; - break :blk tmp; - }) != 0) { - hash = ((hash << @intCast(5)) +% hash) +% @as(c_ulong, @bitCast(@as(c_long, c))); - } - return hash; -} -pub fn create_hash_table(arg_start_capacity: c_uint, arg_hash_table: [*c]hash_table_t) callconv(.C) void { - var start_capacity = arg_start_capacity; - _ = &start_capacity; - var hash_table = arg_hash_table; - _ = &hash_table; - if (start_capacity < @as(c_uint, @bitCast(@as(c_int, 1)))) { - start_capacity = 10; - } - hash_table.*.hashes = @as([*c]c_ulong, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, start_capacity))) *% @sizeOf(c_ulong))))); - hash_table.*.entries = @as([*c]hash_table_entry_t, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_ulong, start_capacity))), @sizeOf(hash_table_entry_t))))); - hash_table.*.capacity = start_capacity; - hash_table.*.n = 0; -} -pub fn destroy_hash_table(arg_hash_table: [*c]hash_table_t) callconv(.C) void { - var hash_table = arg_hash_table; - _ = &hash_table; - free(@as(?*anyopaque, @ptrCast(hash_table.*.entries))); - free(@as(?*anyopaque, @ptrCast(hash_table.*.hashes))); -} -pub fn hash_table_insert_value(arg_hash: c_ulong, arg_value: c_long, arg_hash_table: [*c]hash_table_t) callconv(.C) c_int { - var hash = arg_hash; - _ = &hash; - var value = arg_value; - _ = &value; - var hash_table = arg_hash_table; - _ = &hash_table; - var start_index: c_uint = @as(c_uint, @bitCast(@as(c_uint, @truncate(hash % @as(c_ulong, @bitCast(@as(c_ulong, hash_table.*.capacity))))))); - _ = &start_index; - var index_1: c_uint = start_index; - _ = &index_1; - var start_entry: [*c]hash_table_entry_t = hash_table.*.entries + start_index; - _ = &start_entry; - var i: c_uint = undefined; - _ = &i; - var entry: [*c]hash_table_entry_t = undefined; - _ = &entry; - { - i = 1; - while (hash_table.*.entries[index_1].filled != 0) : (i +%= 1) { - if (i >= hash_table.*.capacity) return 1; - index_1 = (start_index +% (i *% i)) % hash_table.*.capacity; - } - } - entry = hash_table.*.entries + index_1; - entry.*.hash = hash; - entry.*.filled = 1; - entry.*.value = value; - if (index_1 != start_index) { - entry.*.next = start_entry.*.next; - start_entry.*.next = entry; - } - return 0; -} -pub fn hash_table_insert(arg_hash: c_ulong, arg_value: c_long, arg_hash_table: [*c]hash_table_t) callconv(.C) c_int { - var hash = arg_hash; - _ = &hash; - var value = arg_value; - _ = &value; - var hash_table = arg_hash_table; - _ = &hash_table; - var ret: c_int = hash_table_insert_value(hash, value, hash_table); - _ = &ret; - if (ret == @as(c_int, 0)) { - hash_table.*.hashes[hash_table.*.n] = hash; - hash_table.*.n +%= 1; - } - return ret; -} -pub fn hash_table_find(arg_hash: c_ulong, arg_hash_table: [*c]hash_table_t) callconv(.C) [*c]hash_table_entry_t { - var hash = arg_hash; - _ = &hash; - var hash_table = arg_hash_table; - _ = &hash_table; - var entry: [*c]hash_table_entry_t = hash_table.*.entries + (hash % @as(c_ulong, @bitCast(@as(c_ulong, hash_table.*.capacity)))); - _ = &entry; - while (entry != null) { - if ((entry.*.hash == hash) and (entry.*.filled != 0)) { - return entry; - } - entry = entry.*.next; - } - return null; -} -pub fn hash_table_maybe_grow(arg_new_n: c_uint, arg_hash_table: [*c]hash_table_t) callconv(.C) void { - var new_n = arg_new_n; - _ = &new_n; - var hash_table = arg_hash_table; - _ = &hash_table; - var new_capacity: c_uint = undefined; - _ = &new_capacity; - var new_hash_table: hash_table_t = undefined; - _ = &new_hash_table; - var i: c_uint = undefined; - _ = &i; - if (new_n <= hash_table.*.capacity) { - return; - } - new_capacity = @as(c_uint, @bitCast(@as(c_int, 2))) *% (if ((@as(c_uint, @bitCast(@as(c_int, 2))) *% hash_table.*.capacity) > new_n) hash_table.*.capacity else new_n); - new_hash_table.hashes = blk: { - const tmp = @as([*c]c_ulong, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(hash_table.*.hashes)), @sizeOf(c_ulong) *% @as(c_ulong, @bitCast(@as(c_ulong, new_capacity))))))); - hash_table.*.hashes = tmp; - break :blk tmp; - }; - new_hash_table.entries = @as([*c]hash_table_entry_t, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_ulong, new_capacity))), @sizeOf(hash_table_entry_t))))); - new_hash_table.capacity = new_capacity; - new_hash_table.n = hash_table.*.n; - { - i = 0; - while (i < hash_table.*.capacity) : (i +%= 1) { - var entry: [*c]hash_table_entry_t = hash_table_find(hash_table.*.hashes[i], hash_table); - _ = &entry; - _ = hash_table_insert_value(hash_table.*.hashes[i], entry.*.value, &new_hash_table); - } - } - free(@as(?*anyopaque, @ptrCast(hash_table.*.entries))); - hash_table.* = new_hash_table; -} -pub fn hash_table_exists(arg_name: [*c]const u8, arg_hash_table: [*c]hash_table_t) callconv(.C) c_int { - var name = arg_name; - _ = &name; - var hash_table = arg_hash_table; - _ = &hash_table; - return @intFromBool(hash_table_find(hash_djb2(@as([*c]const u8, @ptrCast(@alignCast(name)))), hash_table) != @as([*c]hash_table_entry_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))); -} -pub fn hash_table_set(arg_name: [*c]const u8, arg_val: c_uint, arg_hash_table: [*c]hash_table_t) callconv(.C) void { - var name = arg_name; - _ = &name; - var val = arg_val; - _ = &val; - var hash_table = arg_hash_table; - _ = &hash_table; - var hash: c_ulong = hash_djb2(@as([*c]const u8, @ptrCast(@alignCast(name)))); - _ = &hash; - var entry: [*c]hash_table_entry_t = hash_table_find(hash, hash_table); - _ = &entry; - if (entry != null) { - entry.*.value = @as(c_long, @bitCast(@as(c_ulong, val))); - return; - } - while (true) { - hash_table_maybe_grow(hash_table.*.n +% @as(c_uint, @bitCast(@as(c_int, 1))), hash_table); - if (!(hash_table_insert(hash, @as(c_long, @bitCast(@as(c_ulong, val))), hash_table) != @as(c_int, 0))) break; - } -} -pub fn hash_table_get(arg_name: [*c]const u8, arg_hash_table: [*c]hash_table_t) callconv(.C) c_long { - var name = arg_name; - _ = &name; - var hash_table = arg_hash_table; - _ = &hash_table; - var ret: [*c]hash_table_entry_t = hash_table_find(hash_djb2(@as([*c]const u8, @ptrCast(@alignCast(name)))), hash_table); - _ = &ret; - return ret.*.value; -} -pub fn tinyobj_material_add(arg_prev: [*c]tinyobj_material_t, arg_num_materials: c_uint, arg_new_mat: [*c]tinyobj_material_t) callconv(.C) [*c]tinyobj_material_t { - var prev = arg_prev; - _ = &prev; - var num_materials = arg_num_materials; - _ = &num_materials; - var new_mat = arg_new_mat; - _ = &new_mat; - var dst: [*c]tinyobj_material_t = undefined; - _ = &dst; - dst = @as([*c]tinyobj_material_t, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(prev)), @sizeOf(tinyobj_material_t) *% @as(c_ulong, @bitCast(@as(c_ulong, num_materials +% @as(c_uint, @bitCast(@as(c_int, 1)))))))))); - dst[num_materials] = new_mat.*; - return dst; -} -pub fn tinyobj_parse_and_index_mtl_file(arg_materials_out: [*c][*c]tinyobj_material_t, arg_num_materials_out: [*c]c_uint, arg_filename: [*c]const u8, arg_material_table: [*c]hash_table_t) callconv(.C) c_int { - var materials_out = arg_materials_out; - _ = &materials_out; - var num_materials_out = arg_num_materials_out; - _ = &num_materials_out; - var filename = arg_filename; - _ = &filename; - var material_table = arg_material_table; - _ = &material_table; - var material: tinyobj_material_t = undefined; - _ = &material; - var buffer_size: c_uint = 128; - _ = &buffer_size; - var linebuf: [*c]u8 = undefined; - _ = &linebuf; - var fp: [*c]FILE = undefined; - _ = &fp; - var num_materials: c_uint = 0; - _ = &num_materials; - var materials: [*c]tinyobj_material_t = null; - _ = &materials; - var has_previous_material: c_int = 0; - _ = &has_previous_material; - var line_end: [*c]const u8 = null; - _ = &line_end; - if (materials_out == @as([*c][*c]tinyobj_material_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return -@as(c_int, 2); - } - if (num_materials_out == @as([*c]c_uint, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return -@as(c_int, 2); - } - materials_out.* = null; - num_materials_out.* = 0; - fp = fopen(filename, "rt"); - if (!(fp != null)) { - _ = fprintf(stderr, "TINYOBJ: Error reading file '%s': %s (%d)\n", filename, strerror(__errno_location().*), __errno_location().*); - return -@as(c_int, 3); - } - initMaterial(&material); - linebuf = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, buffer_size))))))); - while (@as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))) != dynamic_fgets(&linebuf, &buffer_size, fp)) { - var token: [*c]const u8 = linebuf; - _ = &token; - line_end = token + strlen(token); - token += @as([*c]const u8, @ptrFromInt(strspn(token, " \t"))); - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (token != null) {} else { - __assert_fail("token", "./external/tinyobj_loader_c.h", @as(c_uint, @bitCast(@as(c_int, 767))), "int tinyobj_parse_and_index_mtl_file(tinyobj_material_t **, unsigned int *, const char *, hash_table_t *)"); - }; - }; - }; - if (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\x00')) continue; - if (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '#')) continue; - if ((@as(c_int, 0) == strncmp(token, "newmtl", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - var namebuf: [4096]u8 = undefined; - _ = &namebuf; - if (has_previous_material != 0) { - materials = tinyobj_material_add(materials, num_materials, &material); - num_materials +%= 1; - } else { - has_previous_material = 1; - } - initMaterial(&material); - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - _ = sscanf(token, "%s", @as([*c]u8, @ptrCast(@alignCast(&namebuf)))); - material.name = my_strdup(@as([*c]u8, @ptrCast(@alignCast(&namebuf))), @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - if (material_table != null) { - hash_table_set(material.name, num_materials, material_table); - } - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'K')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'a'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var r: f32 = undefined; - _ = &r; - var g: f32 = undefined; - _ = &g; - var b: f32 = undefined; - _ = &b; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - parseFloat3(&r, &g, &b, &token); - material.ambient[@as(c_uint, @intCast(@as(c_int, 0)))] = r; - material.ambient[@as(c_uint, @intCast(@as(c_int, 1)))] = g; - material.ambient[@as(c_uint, @intCast(@as(c_int, 2)))] = b; - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'K')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'd'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var r: f32 = undefined; - _ = &r; - var g: f32 = undefined; - _ = &g; - var b: f32 = undefined; - _ = &b; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - parseFloat3(&r, &g, &b, &token); - material.diffuse[@as(c_uint, @intCast(@as(c_int, 0)))] = r; - material.diffuse[@as(c_uint, @intCast(@as(c_int, 1)))] = g; - material.diffuse[@as(c_uint, @intCast(@as(c_int, 2)))] = b; - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'K')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 's'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var r: f32 = undefined; - _ = &r; - var g: f32 = undefined; - _ = &g; - var b: f32 = undefined; - _ = &b; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - parseFloat3(&r, &g, &b, &token); - material.specular[@as(c_uint, @intCast(@as(c_int, 0)))] = r; - material.specular[@as(c_uint, @intCast(@as(c_int, 1)))] = g; - material.specular[@as(c_uint, @intCast(@as(c_int, 2)))] = b; - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'K')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 't'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var r: f32 = undefined; - _ = &r; - var g: f32 = undefined; - _ = &g; - var b: f32 = undefined; - _ = &b; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - parseFloat3(&r, &g, &b, &token); - material.transmittance[@as(c_uint, @intCast(@as(c_int, 0)))] = r; - material.transmittance[@as(c_uint, @intCast(@as(c_int, 1)))] = g; - material.transmittance[@as(c_uint, @intCast(@as(c_int, 2)))] = b; - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'N')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'i'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - material.ior = parseFloat(&token); - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'K')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'e'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var r: f32 = undefined; - _ = &r; - var g: f32 = undefined; - _ = &g; - var b: f32 = undefined; - _ = &b; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - parseFloat3(&r, &g, &b, &token); - material.emission[@as(c_uint, @intCast(@as(c_int, 0)))] = r; - material.emission[@as(c_uint, @intCast(@as(c_int, 1)))] = g; - material.emission[@as(c_uint, @intCast(@as(c_int, 2)))] = b; - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'N')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 's'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - material.shininess = parseFloat(&token); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "illum", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 5)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 5)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))); - material.illum = parseInt(&token); - continue; - } - if ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'd')) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - material.dissolve = parseFloat(&token); - continue; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'T')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'r'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - material.dissolve = 1.0 - parseFloat(&token); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "map_Ka", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - material.ambient_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "map_Kd", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - material.diffuse_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "map_Ks", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - material.specular_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "map_Ns", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - material.specular_highlight_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "map_bump", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 8)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 8)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 8)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 9))))); - material.bump_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "map_d", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 5)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 5)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))); - material.alpha_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "bump", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 4)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 4)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 5))))); - material.bump_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - if ((@as(c_int, 0) == strncmp(token, "disp", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 4)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 4)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 5))))); - material.displacement_texname = my_strdup(token, @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(line_end) -% @intFromPtr(token))), @sizeOf(u8))))))); - continue; - } - } - _ = fclose(fp); - if (material.name != null) { - materials = tinyobj_material_add(materials, num_materials, &material); - num_materials +%= 1; - } - num_materials_out.* = num_materials; - materials_out.* = materials; - if (linebuf != null) { - free(@as(?*anyopaque, @ptrCast(linebuf))); - } - return @as(c_int, 0); -} -pub const COMMAND_EMPTY: c_int = 0; -pub const COMMAND_V: c_int = 1; -pub const COMMAND_VN: c_int = 2; -pub const COMMAND_VT: c_int = 3; -pub const COMMAND_F: c_int = 4; -pub const COMMAND_G: c_int = 5; -pub const COMMAND_O: c_int = 6; -pub const COMMAND_USEMTL: c_int = 7; -pub const COMMAND_MTLLIB: c_int = 8; -pub const CommandType = c_uint; -pub const Command = extern struct { - vx: f32 = @import("std").mem.zeroes(f32), - vy: f32 = @import("std").mem.zeroes(f32), - vz: f32 = @import("std").mem.zeroes(f32), - nx: f32 = @import("std").mem.zeroes(f32), - ny: f32 = @import("std").mem.zeroes(f32), - nz: f32 = @import("std").mem.zeroes(f32), - tx: f32 = @import("std").mem.zeroes(f32), - ty: f32 = @import("std").mem.zeroes(f32), - f: [16]tinyobj_vertex_index_t = @import("std").mem.zeroes([16]tinyobj_vertex_index_t), - num_f: c_uint = @import("std").mem.zeroes(c_uint), - f_num_verts: [16]c_int = @import("std").mem.zeroes([16]c_int), - num_f_num_verts: c_uint = @import("std").mem.zeroes(c_uint), - group_name: [*c]const u8 = @import("std").mem.zeroes([*c]const u8), - group_name_len: c_uint = @import("std").mem.zeroes(c_uint), - pad0: c_int = @import("std").mem.zeroes(c_int), - object_name: [*c]const u8 = @import("std").mem.zeroes([*c]const u8), - object_name_len: c_uint = @import("std").mem.zeroes(c_uint), - pad1: c_int = @import("std").mem.zeroes(c_int), - material_name: [*c]const u8 = @import("std").mem.zeroes([*c]const u8), - material_name_len: c_uint = @import("std").mem.zeroes(c_uint), - pad2: c_int = @import("std").mem.zeroes(c_int), - mtllib_name: [*c]const u8 = @import("std").mem.zeroes([*c]const u8), - mtllib_name_len: c_uint = @import("std").mem.zeroes(c_uint), - type: CommandType = @import("std").mem.zeroes(CommandType), -}; -pub fn parseLine(arg_command: [*c]Command, arg_p: [*c]const u8, arg_p_len: c_uint, arg_triangulate: c_int) callconv(.C) c_int { - var command = arg_command; - _ = &command; - var p = arg_p; - _ = &p; - var p_len = arg_p_len; - _ = &p_len; - var triangulate = arg_triangulate; - _ = &triangulate; - var linebuf: [4096]u8 = undefined; - _ = &linebuf; - var token: [*c]const u8 = undefined; - _ = &token; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (p_len < @as(c_uint, @bitCast(@as(c_int, 4095)))) {} else { - __assert_fail("p_len < 4095", "./external/tinyobj_loader_c.h", @as(c_uint, @bitCast(@as(c_int, 1023))), "int parseLine(Command *, const char *, unsigned int, int)"); - }; - }; - }; - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&linebuf))))), @as(?*const anyopaque, @ptrCast(p)), @as(c_ulong, @bitCast(@as(c_ulong, p_len)))); - linebuf[p_len] = '\x00'; - token = @as([*c]u8, @ptrCast(@alignCast(&linebuf))); - command.*.type = @as(c_uint, @bitCast(COMMAND_EMPTY)); - skip_space(&token); - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (token != null) {} else { - __assert_fail("token", "./external/tinyobj_loader_c.h", @as(c_uint, @bitCast(@as(c_int, 1035))), "int parseLine(Command *, const char *, unsigned int, int)"); - }; - }; - }; - if (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\x00')) { - return 0; - } - if (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '#')) { - return 0; - } - if ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'v')) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, '\t')))) { - var x: f32 = undefined; - _ = &x; - var y: f32 = undefined; - _ = &y; - var z: f32 = undefined; - _ = &z; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - parseFloat3(&x, &y, &z, &token); - command.*.vx = x; - command.*.vy = y; - command.*.vz = z; - command.*.type = @as(c_uint, @bitCast(COMMAND_V)); - return 1; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'v')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'n'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var x: f32 = undefined; - _ = &x; - var y: f32 = undefined; - _ = &y; - var z: f32 = undefined; - _ = &z; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - parseFloat3(&x, &y, &z, &token); - command.*.nx = x; - command.*.ny = y; - command.*.nz = z; - command.*.type = @as(c_uint, @bitCast(COMMAND_VN)); - return 1; - } - if (((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'v')) and (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 't'))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, '\t')))) { - var x: f32 = undefined; - _ = &x; - var y: f32 = undefined; - _ = &y; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - parseFloat2(&x, &y, &token); - command.*.tx = x; - command.*.ty = y; - command.*.type = @as(c_uint, @bitCast(COMMAND_VT)); - return 1; - } - if ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'f')) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, '\t')))) { - var num_f: c_uint = 0; - _ = &num_f; - var f: [16]tinyobj_vertex_index_t = undefined; - _ = &f; - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - skip_space(&token); - while (!(((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\r')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\n'))) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, '\x00')))) { - var vi: tinyobj_vertex_index_t = parseRawTriple(&token); - _ = &vi; - skip_space_and_cr(&token); - f[num_f] = vi; - num_f +%= 1; - } - command.*.type = @as(c_uint, @bitCast(COMMAND_F)); - if (triangulate != 0) { - var k: c_uint = undefined; - _ = &k; - var n: c_uint = 0; - _ = &n; - var @"i0": tinyobj_vertex_index_t = f[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &@"i0"; - var @"i1": tinyobj_vertex_index_t = undefined; - _ = &@"i1"; - var @"i2": tinyobj_vertex_index_t = f[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &@"i2"; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((@as(c_uint, @bitCast(@as(c_int, 3))) *% num_f) < @as(c_uint, @bitCast(@as(c_int, 16)))) {} else { - __assert_fail("3 * num_f < TINYOBJ_MAX_FACES_PER_F_LINE", "./external/tinyobj_loader_c.h", @as(c_uint, @bitCast(@as(c_int, 1105))), "int parseLine(Command *, const char *, unsigned int, int)"); - }; - }; - }; - { - k = 2; - while (k < num_f) : (k +%= 1) { - @"i1" = @"i2"; - @"i2" = f[k]; - command.*.f[(@as(c_uint, @bitCast(@as(c_int, 3))) *% n) +% @as(c_uint, @bitCast(@as(c_int, 0)))] = @"i0"; - command.*.f[(@as(c_uint, @bitCast(@as(c_int, 3))) *% n) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = @"i1"; - command.*.f[(@as(c_uint, @bitCast(@as(c_int, 3))) *% n) +% @as(c_uint, @bitCast(@as(c_int, 2)))] = @"i2"; - command.*.f_num_verts[n] = 3; - n +%= 1; - } - } - command.*.num_f = @as(c_uint, @bitCast(@as(c_int, 3))) *% n; - command.*.num_f_num_verts = n; - } else { - var k: c_uint = 0; - _ = &k; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (num_f < @as(c_uint, @bitCast(@as(c_int, 16)))) {} else { - __assert_fail("num_f < TINYOBJ_MAX_FACES_PER_F_LINE", "./external/tinyobj_loader_c.h", @as(c_uint, @bitCast(@as(c_int, 1122))), "int parseLine(Command *, const char *, unsigned int, int)"); - }; - }; - }; - { - k = 0; - while (k < num_f) : (k +%= 1) { - command.*.f[k] = f[k]; - } - } - command.*.num_f = num_f; - command.*.f_num_verts[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(c_int, @bitCast(num_f)); - command.*.num_f_num_verts = 1; - } - return 1; - } - if ((@as(c_int, 0) == strncmp(token, "usemtl", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - skip_space(&token); - command.*.material_name = p + @as(usize, @bitCast(@as(isize, @intCast(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8)))))); - command.*.material_name_len = length_until_newline(token, (p_len -% @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8))))))) +% @as(c_uint, @bitCast(@as(c_int, 1)))); - command.*.type = @as(c_uint, @bitCast(COMMAND_USEMTL)); - return 1; - } - if ((@as(c_int, 0) == strncmp(token, "mtllib", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6)))))) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 6)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))); - skip_space(&token); - command.*.mtllib_name = p + @as(usize, @bitCast(@as(isize, @intCast(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8)))))); - command.*.mtllib_name_len = length_until_newline(token, p_len -% @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8))))))) +% @as(c_uint, @bitCast(@as(c_int, 1))); - command.*.type = @as(c_uint, @bitCast(COMMAND_MTLLIB)); - return 1; - } - if ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'g')) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - command.*.group_name = p + @as(usize, @bitCast(@as(isize, @intCast(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8)))))); - command.*.group_name_len = length_until_newline(token, p_len -% @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8))))))) +% @as(c_uint, @bitCast(@as(c_int, 1))); - command.*.type = @as(c_uint, @bitCast(COMMAND_G)); - return 1; - } - if ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'o')) and ((@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, token[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, '\t')))) { - token += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - command.*.object_name = p + @as(usize, @bitCast(@as(isize, @intCast(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8)))))); - command.*.object_name_len = length_until_newline(token, p_len -% @as(c_uint, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(token) -% @intFromPtr(@as([*c]u8, @ptrCast(@alignCast(&linebuf)))))), @sizeOf(u8))))))) +% @as(c_uint, @bitCast(@as(c_int, 1))); - command.*.type = @as(c_uint, @bitCast(COMMAND_O)); - return 1; - } - return 0; -} -pub const LineInfo = extern struct { - pos: c_uint = @import("std").mem.zeroes(c_uint), - len: c_uint = @import("std").mem.zeroes(c_uint), -}; -pub fn is_line_ending(arg_p: [*c]const u8, arg_i: c_uint, arg_end_i: c_uint) callconv(.C) c_int { - var p = arg_p; - _ = &p; - var i = arg_i; - _ = &i; - var end_i = arg_end_i; - _ = &end_i; - if (@as(c_int, @bitCast(@as(c_uint, p[i]))) == @as(c_int, '\x00')) return 1; - if (@as(c_int, @bitCast(@as(c_uint, p[i]))) == @as(c_int, '\n')) return 1; - if (@as(c_int, @bitCast(@as(c_uint, p[i]))) == @as(c_int, '\r')) { - if (((i +% @as(c_uint, @bitCast(@as(c_int, 1)))) < end_i) and (@as(c_int, @bitCast(@as(c_uint, p[i +% @as(c_uint, @bitCast(@as(c_int, 1)))]))) != @as(c_int, '\n'))) { - return 1; - } - } - return 0; -} -pub const ptrdiff_t = c_long; -pub const max_align_t = extern struct { - __clang_max_align_nonce1: c_longlong align(8) = @import("std").mem.zeroes(c_longlong), - __clang_max_align_nonce2: c_longdouble align(16) = @import("std").mem.zeroes(c_longdouble), -}; -pub const int_least8_t = __int_least8_t; -pub const int_least16_t = __int_least16_t; -pub const int_least32_t = __int_least32_t; -pub const int_least64_t = __int_least64_t; -pub const uint_least8_t = __uint_least8_t; -pub const uint_least16_t = __uint_least16_t; -pub const uint_least32_t = __uint_least32_t; -pub const uint_least64_t = __uint_least64_t; -pub const int_fast8_t = i8; -pub const int_fast16_t = c_long; -pub const int_fast32_t = c_long; -pub const int_fast64_t = c_long; -pub const uint_fast8_t = u8; -pub const uint_fast16_t = c_ulong; -pub const uint_fast32_t = c_ulong; -pub const uint_fast64_t = c_ulong; -pub const intmax_t = __intmax_t; -pub const uintmax_t = __uintmax_t; -pub const cgltf_size = usize; -pub const cgltf_ssize = c_longlong; -pub const cgltf_float = f32; -pub const cgltf_int = c_int; -pub const cgltf_uint = c_uint; -pub const cgltf_bool = c_int; -pub const cgltf_file_type_invalid: c_int = 0; -pub const cgltf_file_type_gltf: c_int = 1; -pub const cgltf_file_type_glb: c_int = 2; -pub const cgltf_file_type_max_enum: c_int = 3; -pub const enum_cgltf_file_type = c_uint; -pub const cgltf_file_type = enum_cgltf_file_type; -pub const cgltf_result_success: c_int = 0; -pub const cgltf_result_data_too_short: c_int = 1; -pub const cgltf_result_unknown_format: c_int = 2; -pub const cgltf_result_invalid_json: c_int = 3; -pub const cgltf_result_invalid_gltf: c_int = 4; -pub const cgltf_result_invalid_options: c_int = 5; -pub const cgltf_result_file_not_found: c_int = 6; -pub const cgltf_result_io_error: c_int = 7; -pub const cgltf_result_out_of_memory: c_int = 8; -pub const cgltf_result_legacy_gltf: c_int = 9; -pub const cgltf_result_max_enum: c_int = 10; -pub const enum_cgltf_result = c_uint; -pub const cgltf_result = enum_cgltf_result; -pub const struct_cgltf_memory_options = extern struct { - alloc_func: ?*const fn (?*anyopaque, cgltf_size) callconv(.C) ?*anyopaque = @import("std").mem.zeroes(?*const fn (?*anyopaque, cgltf_size) callconv(.C) ?*anyopaque), - free_func: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = @import("std").mem.zeroes(?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void), - user_data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), -}; -pub const cgltf_memory_options = struct_cgltf_memory_options; -pub const struct_cgltf_file_options = extern struct { - read: ?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, [*c]const u8, [*c]cgltf_size, [*c]?*anyopaque) callconv(.C) cgltf_result = @import("std").mem.zeroes(?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, [*c]const u8, [*c]cgltf_size, [*c]?*anyopaque) callconv(.C) cgltf_result), - release: ?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, ?*anyopaque) callconv(.C) void = @import("std").mem.zeroes(?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, ?*anyopaque) callconv(.C) void), - user_data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), -}; -pub const cgltf_file_options = struct_cgltf_file_options; -pub const struct_cgltf_options = extern struct { - type: cgltf_file_type = @import("std").mem.zeroes(cgltf_file_type), - json_token_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - memory: cgltf_memory_options = @import("std").mem.zeroes(cgltf_memory_options), - file: cgltf_file_options = @import("std").mem.zeroes(cgltf_file_options), -}; -pub const cgltf_options = struct_cgltf_options; -pub const cgltf_buffer_view_type_invalid: c_int = 0; -pub const cgltf_buffer_view_type_indices: c_int = 1; -pub const cgltf_buffer_view_type_vertices: c_int = 2; -pub const cgltf_buffer_view_type_max_enum: c_int = 3; -pub const enum_cgltf_buffer_view_type = c_uint; -pub const cgltf_buffer_view_type = enum_cgltf_buffer_view_type; -pub const cgltf_attribute_type_invalid: c_int = 0; -pub const cgltf_attribute_type_position: c_int = 1; -pub const cgltf_attribute_type_normal: c_int = 2; -pub const cgltf_attribute_type_tangent: c_int = 3; -pub const cgltf_attribute_type_texcoord: c_int = 4; -pub const cgltf_attribute_type_color: c_int = 5; -pub const cgltf_attribute_type_joints: c_int = 6; -pub const cgltf_attribute_type_weights: c_int = 7; -pub const cgltf_attribute_type_custom: c_int = 8; -pub const cgltf_attribute_type_max_enum: c_int = 9; -pub const enum_cgltf_attribute_type = c_uint; -pub const cgltf_attribute_type = enum_cgltf_attribute_type; -pub const cgltf_component_type_invalid: c_int = 0; -pub const cgltf_component_type_r_8: c_int = 1; -pub const cgltf_component_type_r_8u: c_int = 2; -pub const cgltf_component_type_r_16: c_int = 3; -pub const cgltf_component_type_r_16u: c_int = 4; -pub const cgltf_component_type_r_32u: c_int = 5; -pub const cgltf_component_type_r_32f: c_int = 6; -pub const cgltf_component_type_max_enum: c_int = 7; -pub const enum_cgltf_component_type = c_uint; -pub const cgltf_component_type = enum_cgltf_component_type; -pub const cgltf_type_invalid: c_int = 0; -pub const cgltf_type_scalar: c_int = 1; -pub const cgltf_type_vec2: c_int = 2; -pub const cgltf_type_vec3: c_int = 3; -pub const cgltf_type_vec4: c_int = 4; -pub const cgltf_type_mat2: c_int = 5; -pub const cgltf_type_mat3: c_int = 6; -pub const cgltf_type_mat4: c_int = 7; -pub const cgltf_type_max_enum: c_int = 8; -pub const enum_cgltf_type = c_uint; -pub const cgltf_type = enum_cgltf_type; -pub const cgltf_primitive_type_invalid: c_int = 0; -pub const cgltf_primitive_type_points: c_int = 1; -pub const cgltf_primitive_type_lines: c_int = 2; -pub const cgltf_primitive_type_line_loop: c_int = 3; -pub const cgltf_primitive_type_line_strip: c_int = 4; -pub const cgltf_primitive_type_triangles: c_int = 5; -pub const cgltf_primitive_type_triangle_strip: c_int = 6; -pub const cgltf_primitive_type_triangle_fan: c_int = 7; -pub const cgltf_primitive_type_max_enum: c_int = 8; -pub const enum_cgltf_primitive_type = c_uint; -pub const cgltf_primitive_type = enum_cgltf_primitive_type; -pub const cgltf_alpha_mode_opaque: c_int = 0; -pub const cgltf_alpha_mode_mask: c_int = 1; -pub const cgltf_alpha_mode_blend: c_int = 2; -pub const cgltf_alpha_mode_max_enum: c_int = 3; -pub const enum_cgltf_alpha_mode = c_uint; -pub const cgltf_alpha_mode = enum_cgltf_alpha_mode; -pub const cgltf_animation_path_type_invalid: c_int = 0; -pub const cgltf_animation_path_type_translation: c_int = 1; -pub const cgltf_animation_path_type_rotation: c_int = 2; -pub const cgltf_animation_path_type_scale: c_int = 3; -pub const cgltf_animation_path_type_weights: c_int = 4; -pub const cgltf_animation_path_type_max_enum: c_int = 5; -pub const enum_cgltf_animation_path_type = c_uint; -pub const cgltf_animation_path_type = enum_cgltf_animation_path_type; -pub const cgltf_interpolation_type_linear: c_int = 0; -pub const cgltf_interpolation_type_step: c_int = 1; -pub const cgltf_interpolation_type_cubic_spline: c_int = 2; -pub const cgltf_interpolation_type_max_enum: c_int = 3; -pub const enum_cgltf_interpolation_type = c_uint; -pub const cgltf_interpolation_type = enum_cgltf_interpolation_type; -pub const cgltf_camera_type_invalid: c_int = 0; -pub const cgltf_camera_type_perspective: c_int = 1; -pub const cgltf_camera_type_orthographic: c_int = 2; -pub const cgltf_camera_type_max_enum: c_int = 3; -pub const enum_cgltf_camera_type = c_uint; -pub const cgltf_camera_type = enum_cgltf_camera_type; -pub const cgltf_light_type_invalid: c_int = 0; -pub const cgltf_light_type_directional: c_int = 1; -pub const cgltf_light_type_point: c_int = 2; -pub const cgltf_light_type_spot: c_int = 3; -pub const cgltf_light_type_max_enum: c_int = 4; -pub const enum_cgltf_light_type = c_uint; -pub const cgltf_light_type = enum_cgltf_light_type; -pub const cgltf_data_free_method_none: c_int = 0; -pub const cgltf_data_free_method_file_release: c_int = 1; -pub const cgltf_data_free_method_memory_free: c_int = 2; -pub const cgltf_data_free_method_max_enum: c_int = 3; -pub const enum_cgltf_data_free_method = c_uint; -pub const cgltf_data_free_method = enum_cgltf_data_free_method; -pub const struct_cgltf_extras = extern struct { - start_offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), - end_offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), - data: [*c]u8 = @import("std").mem.zeroes([*c]u8), -}; -pub const cgltf_extras = struct_cgltf_extras; -pub const struct_cgltf_extension = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - data: [*c]u8 = @import("std").mem.zeroes([*c]u8), -}; -pub const cgltf_extension = struct_cgltf_extension; -pub const struct_cgltf_buffer = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - size: cgltf_size = @import("std").mem.zeroes(cgltf_size), - uri: [*c]u8 = @import("std").mem.zeroes([*c]u8), - data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - data_free_method: cgltf_data_free_method = @import("std").mem.zeroes(cgltf_data_free_method), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_buffer = struct_cgltf_buffer; -pub const cgltf_meshopt_compression_mode_invalid: c_int = 0; -pub const cgltf_meshopt_compression_mode_attributes: c_int = 1; -pub const cgltf_meshopt_compression_mode_triangles: c_int = 2; -pub const cgltf_meshopt_compression_mode_indices: c_int = 3; -pub const cgltf_meshopt_compression_mode_max_enum: c_int = 4; -pub const enum_cgltf_meshopt_compression_mode = c_uint; -pub const cgltf_meshopt_compression_mode = enum_cgltf_meshopt_compression_mode; -pub const cgltf_meshopt_compression_filter_none: c_int = 0; -pub const cgltf_meshopt_compression_filter_octahedral: c_int = 1; -pub const cgltf_meshopt_compression_filter_quaternion: c_int = 2; -pub const cgltf_meshopt_compression_filter_exponential: c_int = 3; -pub const cgltf_meshopt_compression_filter_max_enum: c_int = 4; -pub const enum_cgltf_meshopt_compression_filter = c_uint; -pub const cgltf_meshopt_compression_filter = enum_cgltf_meshopt_compression_filter; -pub const struct_cgltf_meshopt_compression = extern struct { - buffer: [*c]cgltf_buffer = @import("std").mem.zeroes([*c]cgltf_buffer), - offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), - size: cgltf_size = @import("std").mem.zeroes(cgltf_size), - stride: cgltf_size = @import("std").mem.zeroes(cgltf_size), - count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - mode: cgltf_meshopt_compression_mode = @import("std").mem.zeroes(cgltf_meshopt_compression_mode), - filter: cgltf_meshopt_compression_filter = @import("std").mem.zeroes(cgltf_meshopt_compression_filter), -}; -pub const cgltf_meshopt_compression = struct_cgltf_meshopt_compression; -pub const struct_cgltf_buffer_view = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - buffer: [*c]cgltf_buffer = @import("std").mem.zeroes([*c]cgltf_buffer), - offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), - size: cgltf_size = @import("std").mem.zeroes(cgltf_size), - stride: cgltf_size = @import("std").mem.zeroes(cgltf_size), - type: cgltf_buffer_view_type = @import("std").mem.zeroes(cgltf_buffer_view_type), - data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - has_meshopt_compression: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - meshopt_compression: cgltf_meshopt_compression = @import("std").mem.zeroes(cgltf_meshopt_compression), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_buffer_view = struct_cgltf_buffer_view; -pub const struct_cgltf_accessor_sparse = extern struct { - count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - indices_buffer_view: [*c]cgltf_buffer_view = @import("std").mem.zeroes([*c]cgltf_buffer_view), - indices_byte_offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), - indices_component_type: cgltf_component_type = @import("std").mem.zeroes(cgltf_component_type), - values_buffer_view: [*c]cgltf_buffer_view = @import("std").mem.zeroes([*c]cgltf_buffer_view), - values_byte_offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), -}; -pub const cgltf_accessor_sparse = struct_cgltf_accessor_sparse; -pub const struct_cgltf_accessor = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - component_type: cgltf_component_type = @import("std").mem.zeroes(cgltf_component_type), - normalized: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - type: cgltf_type = @import("std").mem.zeroes(cgltf_type), - offset: cgltf_size = @import("std").mem.zeroes(cgltf_size), - count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - stride: cgltf_size = @import("std").mem.zeroes(cgltf_size), - buffer_view: [*c]cgltf_buffer_view = @import("std").mem.zeroes([*c]cgltf_buffer_view), - has_min: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - min: [16]cgltf_float = @import("std").mem.zeroes([16]cgltf_float), - has_max: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - max: [16]cgltf_float = @import("std").mem.zeroes([16]cgltf_float), - is_sparse: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - sparse: cgltf_accessor_sparse = @import("std").mem.zeroes(cgltf_accessor_sparse), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_accessor = struct_cgltf_accessor; -pub const struct_cgltf_attribute = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - type: cgltf_attribute_type = @import("std").mem.zeroes(cgltf_attribute_type), - index: cgltf_int = @import("std").mem.zeroes(cgltf_int), - data: [*c]cgltf_accessor = @import("std").mem.zeroes([*c]cgltf_accessor), -}; -pub const cgltf_attribute = struct_cgltf_attribute; -pub const struct_cgltf_image = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - uri: [*c]u8 = @import("std").mem.zeroes([*c]u8), - buffer_view: [*c]cgltf_buffer_view = @import("std").mem.zeroes([*c]cgltf_buffer_view), - mime_type: [*c]u8 = @import("std").mem.zeroes([*c]u8), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_image = struct_cgltf_image; -pub const struct_cgltf_sampler = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - mag_filter: cgltf_int = @import("std").mem.zeroes(cgltf_int), - min_filter: cgltf_int = @import("std").mem.zeroes(cgltf_int), - wrap_s: cgltf_int = @import("std").mem.zeroes(cgltf_int), - wrap_t: cgltf_int = @import("std").mem.zeroes(cgltf_int), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_sampler = struct_cgltf_sampler; -pub const struct_cgltf_texture = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - image: [*c]cgltf_image = @import("std").mem.zeroes([*c]cgltf_image), - sampler: [*c]cgltf_sampler = @import("std").mem.zeroes([*c]cgltf_sampler), - has_basisu: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - basisu_image: [*c]cgltf_image = @import("std").mem.zeroes([*c]cgltf_image), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_texture = struct_cgltf_texture; -pub const struct_cgltf_texture_transform = extern struct { - offset: [2]cgltf_float = @import("std").mem.zeroes([2]cgltf_float), - rotation: cgltf_float = @import("std").mem.zeroes(cgltf_float), - scale: [2]cgltf_float = @import("std").mem.zeroes([2]cgltf_float), - has_texcoord: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - texcoord: cgltf_int = @import("std").mem.zeroes(cgltf_int), -}; -pub const cgltf_texture_transform = struct_cgltf_texture_transform; -pub const struct_cgltf_texture_view = extern struct { - texture: [*c]cgltf_texture = @import("std").mem.zeroes([*c]cgltf_texture), - texcoord: cgltf_int = @import("std").mem.zeroes(cgltf_int), - scale: cgltf_float = @import("std").mem.zeroes(cgltf_float), - has_transform: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - transform: cgltf_texture_transform = @import("std").mem.zeroes(cgltf_texture_transform), -}; -pub const cgltf_texture_view = struct_cgltf_texture_view; -pub const struct_cgltf_pbr_metallic_roughness = extern struct { - base_color_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - metallic_roughness_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - base_color_factor: [4]cgltf_float = @import("std").mem.zeroes([4]cgltf_float), - metallic_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), - roughness_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_pbr_metallic_roughness = struct_cgltf_pbr_metallic_roughness; -pub const struct_cgltf_pbr_specular_glossiness = extern struct { - diffuse_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - specular_glossiness_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - diffuse_factor: [4]cgltf_float = @import("std").mem.zeroes([4]cgltf_float), - specular_factor: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - glossiness_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_pbr_specular_glossiness = struct_cgltf_pbr_specular_glossiness; -pub const struct_cgltf_clearcoat = extern struct { - clearcoat_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - clearcoat_roughness_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - clearcoat_normal_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - clearcoat_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), - clearcoat_roughness_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_clearcoat = struct_cgltf_clearcoat; -pub const struct_cgltf_transmission = extern struct { - transmission_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - transmission_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_transmission = struct_cgltf_transmission; -pub const struct_cgltf_ior = extern struct { - ior: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_ior = struct_cgltf_ior; -pub const struct_cgltf_specular = extern struct { - specular_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - specular_color_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - specular_color_factor: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - specular_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_specular = struct_cgltf_specular; -pub const struct_cgltf_volume = extern struct { - thickness_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - thickness_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), - attenuation_color: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - attenuation_distance: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_volume = struct_cgltf_volume; -pub const struct_cgltf_sheen = extern struct { - sheen_color_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - sheen_color_factor: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - sheen_roughness_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - sheen_roughness_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_sheen = struct_cgltf_sheen; -pub const struct_cgltf_emissive_strength = extern struct { - emissive_strength: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_emissive_strength = struct_cgltf_emissive_strength; -pub const struct_cgltf_iridescence = extern struct { - iridescence_factor: cgltf_float = @import("std").mem.zeroes(cgltf_float), - iridescence_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - iridescence_ior: cgltf_float = @import("std").mem.zeroes(cgltf_float), - iridescence_thickness_min: cgltf_float = @import("std").mem.zeroes(cgltf_float), - iridescence_thickness_max: cgltf_float = @import("std").mem.zeroes(cgltf_float), - iridescence_thickness_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), -}; -pub const cgltf_iridescence = struct_cgltf_iridescence; -pub const struct_cgltf_anisotropy = extern struct { - anisotropy_strength: cgltf_float = @import("std").mem.zeroes(cgltf_float), - anisotropy_rotation: cgltf_float = @import("std").mem.zeroes(cgltf_float), - anisotropy_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), -}; -pub const cgltf_anisotropy = struct_cgltf_anisotropy; -pub const struct_cgltf_dispersion = extern struct { - dispersion: cgltf_float = @import("std").mem.zeroes(cgltf_float), -}; -pub const cgltf_dispersion = struct_cgltf_dispersion; -pub const struct_cgltf_material = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - has_pbr_metallic_roughness: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_pbr_specular_glossiness: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_clearcoat: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_transmission: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_volume: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_ior: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_specular: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_sheen: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_emissive_strength: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_iridescence: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_anisotropy: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_dispersion: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - pbr_metallic_roughness: cgltf_pbr_metallic_roughness = @import("std").mem.zeroes(cgltf_pbr_metallic_roughness), - pbr_specular_glossiness: cgltf_pbr_specular_glossiness = @import("std").mem.zeroes(cgltf_pbr_specular_glossiness), - clearcoat: cgltf_clearcoat = @import("std").mem.zeroes(cgltf_clearcoat), - ior: cgltf_ior = @import("std").mem.zeroes(cgltf_ior), - specular: cgltf_specular = @import("std").mem.zeroes(cgltf_specular), - sheen: cgltf_sheen = @import("std").mem.zeroes(cgltf_sheen), - transmission: cgltf_transmission = @import("std").mem.zeroes(cgltf_transmission), - volume: cgltf_volume = @import("std").mem.zeroes(cgltf_volume), - emissive_strength: cgltf_emissive_strength = @import("std").mem.zeroes(cgltf_emissive_strength), - iridescence: cgltf_iridescence = @import("std").mem.zeroes(cgltf_iridescence), - anisotropy: cgltf_anisotropy = @import("std").mem.zeroes(cgltf_anisotropy), - dispersion: cgltf_dispersion = @import("std").mem.zeroes(cgltf_dispersion), - normal_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - occlusion_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - emissive_texture: cgltf_texture_view = @import("std").mem.zeroes(cgltf_texture_view), - emissive_factor: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - alpha_mode: cgltf_alpha_mode = @import("std").mem.zeroes(cgltf_alpha_mode), - alpha_cutoff: cgltf_float = @import("std").mem.zeroes(cgltf_float), - double_sided: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - unlit: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_material = struct_cgltf_material; -pub const struct_cgltf_material_mapping = extern struct { - variant: cgltf_size = @import("std").mem.zeroes(cgltf_size), - material: [*c]cgltf_material = @import("std").mem.zeroes([*c]cgltf_material), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), -}; -pub const cgltf_material_mapping = struct_cgltf_material_mapping; -pub const struct_cgltf_morph_target = extern struct { - attributes: [*c]cgltf_attribute = @import("std").mem.zeroes([*c]cgltf_attribute), - attributes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), -}; -pub const cgltf_morph_target = struct_cgltf_morph_target; -pub const struct_cgltf_draco_mesh_compression = extern struct { - buffer_view: [*c]cgltf_buffer_view = @import("std").mem.zeroes([*c]cgltf_buffer_view), - attributes: [*c]cgltf_attribute = @import("std").mem.zeroes([*c]cgltf_attribute), - attributes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), -}; -pub const cgltf_draco_mesh_compression = struct_cgltf_draco_mesh_compression; -pub const struct_cgltf_mesh_gpu_instancing = extern struct { - attributes: [*c]cgltf_attribute = @import("std").mem.zeroes([*c]cgltf_attribute), - attributes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), -}; -pub const cgltf_mesh_gpu_instancing = struct_cgltf_mesh_gpu_instancing; -pub const struct_cgltf_primitive = extern struct { - type: cgltf_primitive_type = @import("std").mem.zeroes(cgltf_primitive_type), - indices: [*c]cgltf_accessor = @import("std").mem.zeroes([*c]cgltf_accessor), - material: [*c]cgltf_material = @import("std").mem.zeroes([*c]cgltf_material), - attributes: [*c]cgltf_attribute = @import("std").mem.zeroes([*c]cgltf_attribute), - attributes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - targets: [*c]cgltf_morph_target = @import("std").mem.zeroes([*c]cgltf_morph_target), - targets_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - has_draco_mesh_compression: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - draco_mesh_compression: cgltf_draco_mesh_compression = @import("std").mem.zeroes(cgltf_draco_mesh_compression), - mappings: [*c]cgltf_material_mapping = @import("std").mem.zeroes([*c]cgltf_material_mapping), - mappings_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_primitive = struct_cgltf_primitive; -pub const struct_cgltf_mesh = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - primitives: [*c]cgltf_primitive = @import("std").mem.zeroes([*c]cgltf_primitive), - primitives_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - weights: [*c]cgltf_float = @import("std").mem.zeroes([*c]cgltf_float), - weights_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - target_names: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), - target_names_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_mesh = struct_cgltf_mesh; -pub const cgltf_node = struct_cgltf_node; -pub const struct_cgltf_skin = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - joints: [*c][*c]cgltf_node = @import("std").mem.zeroes([*c][*c]cgltf_node), - joints_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - skeleton: [*c]cgltf_node = @import("std").mem.zeroes([*c]cgltf_node), - inverse_bind_matrices: [*c]cgltf_accessor = @import("std").mem.zeroes([*c]cgltf_accessor), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_skin = struct_cgltf_skin; -pub const struct_cgltf_camera_perspective = extern struct { - has_aspect_ratio: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - aspect_ratio: cgltf_float = @import("std").mem.zeroes(cgltf_float), - yfov: cgltf_float = @import("std").mem.zeroes(cgltf_float), - has_zfar: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - zfar: cgltf_float = @import("std").mem.zeroes(cgltf_float), - znear: cgltf_float = @import("std").mem.zeroes(cgltf_float), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), -}; -pub const cgltf_camera_perspective = struct_cgltf_camera_perspective; -pub const struct_cgltf_camera_orthographic = extern struct { - xmag: cgltf_float = @import("std").mem.zeroes(cgltf_float), - ymag: cgltf_float = @import("std").mem.zeroes(cgltf_float), - zfar: cgltf_float = @import("std").mem.zeroes(cgltf_float), - znear: cgltf_float = @import("std").mem.zeroes(cgltf_float), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), -}; -pub const cgltf_camera_orthographic = struct_cgltf_camera_orthographic; -const union_unnamed_6 = extern union { - perspective: cgltf_camera_perspective, - orthographic: cgltf_camera_orthographic, -}; -pub const struct_cgltf_camera = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - type: cgltf_camera_type = @import("std").mem.zeroes(cgltf_camera_type), - data: union_unnamed_6 = @import("std").mem.zeroes(union_unnamed_6), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_camera = struct_cgltf_camera; -pub const struct_cgltf_light = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - color: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - intensity: cgltf_float = @import("std").mem.zeroes(cgltf_float), - type: cgltf_light_type = @import("std").mem.zeroes(cgltf_light_type), - range: cgltf_float = @import("std").mem.zeroes(cgltf_float), - spot_inner_cone_angle: cgltf_float = @import("std").mem.zeroes(cgltf_float), - spot_outer_cone_angle: cgltf_float = @import("std").mem.zeroes(cgltf_float), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), -}; -pub const cgltf_light = struct_cgltf_light; -pub const struct_cgltf_node = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - parent: [*c]cgltf_node = @import("std").mem.zeroes([*c]cgltf_node), - children: [*c][*c]cgltf_node = @import("std").mem.zeroes([*c][*c]cgltf_node), - children_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - skin: [*c]cgltf_skin = @import("std").mem.zeroes([*c]cgltf_skin), - mesh: [*c]cgltf_mesh = @import("std").mem.zeroes([*c]cgltf_mesh), - camera: [*c]cgltf_camera = @import("std").mem.zeroes([*c]cgltf_camera), - light: [*c]cgltf_light = @import("std").mem.zeroes([*c]cgltf_light), - weights: [*c]cgltf_float = @import("std").mem.zeroes([*c]cgltf_float), - weights_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - has_translation: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_rotation: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_scale: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - has_matrix: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - translation: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - rotation: [4]cgltf_float = @import("std").mem.zeroes([4]cgltf_float), - scale: [3]cgltf_float = @import("std").mem.zeroes([3]cgltf_float), - matrix: [16]cgltf_float = @import("std").mem.zeroes([16]cgltf_float), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - has_mesh_gpu_instancing: cgltf_bool = @import("std").mem.zeroes(cgltf_bool), - mesh_gpu_instancing: cgltf_mesh_gpu_instancing = @import("std").mem.zeroes(cgltf_mesh_gpu_instancing), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const struct_cgltf_scene = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - nodes: [*c][*c]cgltf_node = @import("std").mem.zeroes([*c][*c]cgltf_node), - nodes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_scene = struct_cgltf_scene; -pub const struct_cgltf_animation_sampler = extern struct { - input: [*c]cgltf_accessor = @import("std").mem.zeroes([*c]cgltf_accessor), - output: [*c]cgltf_accessor = @import("std").mem.zeroes([*c]cgltf_accessor), - interpolation: cgltf_interpolation_type = @import("std").mem.zeroes(cgltf_interpolation_type), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_animation_sampler = struct_cgltf_animation_sampler; -pub const struct_cgltf_animation_channel = extern struct { - sampler: [*c]cgltf_animation_sampler = @import("std").mem.zeroes([*c]cgltf_animation_sampler), - target_node: [*c]cgltf_node = @import("std").mem.zeroes([*c]cgltf_node), - target_path: cgltf_animation_path_type = @import("std").mem.zeroes(cgltf_animation_path_type), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_animation_channel = struct_cgltf_animation_channel; -pub const struct_cgltf_animation = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - samplers: [*c]cgltf_animation_sampler = @import("std").mem.zeroes([*c]cgltf_animation_sampler), - samplers_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - channels: [*c]cgltf_animation_channel = @import("std").mem.zeroes([*c]cgltf_animation_channel), - channels_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_animation = struct_cgltf_animation; -pub const struct_cgltf_material_variant = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), -}; -pub const cgltf_material_variant = struct_cgltf_material_variant; -pub const struct_cgltf_asset = extern struct { - copyright: [*c]u8 = @import("std").mem.zeroes([*c]u8), - generator: [*c]u8 = @import("std").mem.zeroes([*c]u8), - version: [*c]u8 = @import("std").mem.zeroes([*c]u8), - min_version: [*c]u8 = @import("std").mem.zeroes([*c]u8), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), -}; -pub const cgltf_asset = struct_cgltf_asset; -pub const struct_cgltf_data = extern struct { - file_type: cgltf_file_type = @import("std").mem.zeroes(cgltf_file_type), - file_data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - asset: cgltf_asset = @import("std").mem.zeroes(cgltf_asset), - meshes: [*c]cgltf_mesh = @import("std").mem.zeroes([*c]cgltf_mesh), - meshes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - materials: [*c]cgltf_material = @import("std").mem.zeroes([*c]cgltf_material), - materials_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - accessors: [*c]cgltf_accessor = @import("std").mem.zeroes([*c]cgltf_accessor), - accessors_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - buffer_views: [*c]cgltf_buffer_view = @import("std").mem.zeroes([*c]cgltf_buffer_view), - buffer_views_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - buffers: [*c]cgltf_buffer = @import("std").mem.zeroes([*c]cgltf_buffer), - buffers_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - images: [*c]cgltf_image = @import("std").mem.zeroes([*c]cgltf_image), - images_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - textures: [*c]cgltf_texture = @import("std").mem.zeroes([*c]cgltf_texture), - textures_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - samplers: [*c]cgltf_sampler = @import("std").mem.zeroes([*c]cgltf_sampler), - samplers_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - skins: [*c]cgltf_skin = @import("std").mem.zeroes([*c]cgltf_skin), - skins_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - cameras: [*c]cgltf_camera = @import("std").mem.zeroes([*c]cgltf_camera), - cameras_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - lights: [*c]cgltf_light = @import("std").mem.zeroes([*c]cgltf_light), - lights_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - nodes: [*c]cgltf_node = @import("std").mem.zeroes([*c]cgltf_node), - nodes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - scenes: [*c]cgltf_scene = @import("std").mem.zeroes([*c]cgltf_scene), - scenes_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - scene: [*c]cgltf_scene = @import("std").mem.zeroes([*c]cgltf_scene), - animations: [*c]cgltf_animation = @import("std").mem.zeroes([*c]cgltf_animation), - animations_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - variants: [*c]cgltf_material_variant = @import("std").mem.zeroes([*c]cgltf_material_variant), - variants_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extras: cgltf_extras = @import("std").mem.zeroes(cgltf_extras), - data_extensions_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - data_extensions: [*c]cgltf_extension = @import("std").mem.zeroes([*c]cgltf_extension), - extensions_used: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), - extensions_used_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - extensions_required: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), - extensions_required_count: cgltf_size = @import("std").mem.zeroes(cgltf_size), - json: [*c]const u8 = @import("std").mem.zeroes([*c]const u8), - json_size: cgltf_size = @import("std").mem.zeroes(cgltf_size), - bin: ?*const anyopaque = @import("std").mem.zeroes(?*const anyopaque), - bin_size: cgltf_size = @import("std").mem.zeroes(cgltf_size), - memory: cgltf_memory_options = @import("std").mem.zeroes(cgltf_memory_options), - file: cgltf_file_options = @import("std").mem.zeroes(cgltf_file_options), -}; -pub const cgltf_data = struct_cgltf_data; -pub export fn cgltf_parse(arg_options: [*c]const cgltf_options, arg_data: ?*const anyopaque, arg_size: cgltf_size, arg_out_data: [*c][*c]cgltf_data) cgltf_result { - var options = arg_options; - _ = &options; - var data = arg_data; - _ = &data; - var size = arg_size; - _ = &size; - var out_data = arg_out_data; - _ = &out_data; - if (size < @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 12))))) { - return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - if (options == @as([*c]const cgltf_options, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return @as(c_uint, @bitCast(cgltf_result_invalid_options)); - } - var fixed_options: cgltf_options = options.*; - _ = &fixed_options; - if (fixed_options.memory.alloc_func == @as(?*const fn (?*anyopaque, cgltf_size) callconv(.C) ?*anyopaque, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - fixed_options.memory.alloc_func = &cgltf_default_alloc; - } - if (fixed_options.memory.free_func == @as(?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - fixed_options.memory.free_func = &cgltf_default_free; - } - var tmp: u32 = undefined; - _ = &tmp; - _ = memcpy(@as(?*anyopaque, @ptrCast(&tmp)), data, @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - if (tmp != GlbMagic) { - if (fixed_options.type == @as(c_uint, @bitCast(cgltf_file_type_invalid))) { - fixed_options.type = @as(c_uint, @bitCast(cgltf_file_type_gltf)); - } else if (fixed_options.type == @as(c_uint, @bitCast(cgltf_file_type_glb))) { - return @as(c_uint, @bitCast(cgltf_result_unknown_format)); - } - } - if (fixed_options.type == @as(c_uint, @bitCast(cgltf_file_type_gltf))) { - var json_result: cgltf_result = cgltf_parse_json(&fixed_options, @as([*c]const u8, @ptrCast(@alignCast(data))), size, out_data); - _ = &json_result; - if (json_result != @as(c_uint, @bitCast(cgltf_result_success))) { - return json_result; - } - out_data.*.*.file_type = @as(c_uint, @bitCast(cgltf_file_type_gltf)); - return @as(c_uint, @bitCast(cgltf_result_success)); - } - var ptr: [*c]const u8 = @as([*c]const u8, @ptrCast(@alignCast(data))); - _ = &ptr; - _ = memcpy(@as(?*anyopaque, @ptrCast(&tmp)), @as(?*const anyopaque, @ptrCast(ptr + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - var version: u32 = tmp; - _ = &version; - if (version != GlbVersion) { - return @as(c_uint, @bitCast(if (version < GlbVersion) cgltf_result_legacy_gltf else cgltf_result_unknown_format)); - } - _ = memcpy(@as(?*anyopaque, @ptrCast(&tmp)), @as(?*const anyopaque, @ptrCast(ptr + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 8))))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - if (@as(cgltf_size, @bitCast(@as(c_ulong, tmp))) > size) { - return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - var json_chunk: [*c]const u8 = ptr + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 12))))); - _ = &json_chunk; - if (@as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 12) + @as(c_int, 8)))) > size) { - return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - var json_length: u32 = undefined; - _ = &json_length; - _ = memcpy(@as(?*anyopaque, @ptrCast(&json_length)), @as(?*const anyopaque, @ptrCast(json_chunk)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - if (@as(cgltf_size, @bitCast(@as(c_ulong, json_length))) > ((size -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 12))))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8)))))) { - return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - _ = memcpy(@as(?*anyopaque, @ptrCast(&tmp)), @as(?*const anyopaque, @ptrCast(json_chunk + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - if (tmp != GlbMagicJsonChunk) { - return @as(c_uint, @bitCast(cgltf_result_unknown_format)); - } - json_chunk += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 8))))); - var bin: ?*const anyopaque = null; - _ = &bin; - var bin_size: cgltf_size = 0; - _ = &bin_size; - if (@as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8)))) <= (((size -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 12))))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8))))) -% @as(cgltf_size, @bitCast(@as(c_ulong, json_length))))) { - var bin_chunk: [*c]const u8 = json_chunk + json_length; - _ = &bin_chunk; - var bin_length: u32 = undefined; - _ = &bin_length; - _ = memcpy(@as(?*anyopaque, @ptrCast(&bin_length)), @as(?*const anyopaque, @ptrCast(bin_chunk)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - if (@as(cgltf_size, @bitCast(@as(c_ulong, bin_length))) > ((((size -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 12))))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8))))) -% @as(cgltf_size, @bitCast(@as(c_ulong, json_length)))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8)))))) { - return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - _ = memcpy(@as(?*anyopaque, @ptrCast(&tmp)), @as(?*const anyopaque, @ptrCast(bin_chunk + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))))), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - if (tmp != GlbMagicBinChunk) { - return @as(c_uint, @bitCast(cgltf_result_unknown_format)); - } - bin_chunk += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 8))))); - bin = @as(?*const anyopaque, @ptrCast(bin_chunk)); - bin_size = @as(cgltf_size, @bitCast(@as(c_ulong, bin_length))); - } - var json_result: cgltf_result = cgltf_parse_json(&fixed_options, json_chunk, @as(cgltf_size, @bitCast(@as(c_ulong, json_length))), out_data); - _ = &json_result; - if (json_result != @as(c_uint, @bitCast(cgltf_result_success))) { - return json_result; - } - out_data.*.*.file_type = @as(c_uint, @bitCast(cgltf_file_type_glb)); - out_data.*.*.bin = bin; - out_data.*.*.bin_size = bin_size; - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub export fn cgltf_parse_file(arg_options: [*c]const cgltf_options, arg_path: [*c]const u8, arg_out_data: [*c][*c]cgltf_data) cgltf_result { - var options = arg_options; - _ = &options; - var path = arg_path; - _ = &path; - var out_data = arg_out_data; - _ = &out_data; - if (options == @as([*c]const cgltf_options, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return @as(c_uint, @bitCast(cgltf_result_invalid_options)); - } - var file_read: ?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, [*c]const u8, [*c]cgltf_size, [*c]?*anyopaque) callconv(.C) cgltf_result = if (options.*.file.read != null) options.*.file.read else &cgltf_default_file_read; - _ = &file_read; - var file_release: ?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, ?*anyopaque) callconv(.C) void = if (options.*.file.release != null) options.*.file.release else &cgltf_default_file_release; - _ = &file_release; - var file_data: ?*anyopaque = @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - _ = &file_data; - var file_size: cgltf_size = 0; - _ = &file_size; - var result: cgltf_result = file_read.?(&options.*.memory, &options.*.file, path, &file_size, &file_data); - _ = &result; - if (result != @as(c_uint, @bitCast(cgltf_result_success))) { - return result; - } - result = cgltf_parse(options, file_data, file_size, out_data); - if (result != @as(c_uint, @bitCast(cgltf_result_success))) { - file_release.?(&options.*.memory, &options.*.file, file_data); - return result; - } - out_data.*.*.file_data = file_data; - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub export fn cgltf_load_buffers(arg_options: [*c]const cgltf_options, arg_data: [*c]cgltf_data, arg_gltf_path: [*c]const u8) cgltf_result { - var options = arg_options; - _ = &options; - var data = arg_data; - _ = &data; - var gltf_path = arg_gltf_path; - _ = &gltf_path; - if (options == @as([*c]const cgltf_options, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return @as(c_uint, @bitCast(cgltf_result_invalid_options)); - } - if ((((data.*.buffers_count != 0) and (data.*.buffers[@as(c_uint, @intCast(@as(c_int, 0)))].data == @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))) and (data.*.buffers[@as(c_uint, @intCast(@as(c_int, 0)))].uri == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) and (data.*.bin != null)) { - if (data.*.bin_size < data.*.buffers[@as(c_uint, @intCast(@as(c_int, 0)))].size) { - return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - data.*.buffers[@as(c_uint, @intCast(@as(c_int, 0)))].data = @as(?*anyopaque, @ptrCast(@volatileCast(@constCast(data.*.bin)))); - data.*.buffers[@as(c_uint, @intCast(@as(c_int, 0)))].data_free_method = @as(c_uint, @bitCast(cgltf_data_free_method_none)); - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.buffers_count) : (i +%= 1) { - if (data.*.buffers[i].data != null) { - continue; - } - var uri: [*c]const u8 = data.*.buffers[i].uri; - _ = &uri; - if (uri == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - continue; - } - if (strncmp(uri, "data:", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5))))) == @as(c_int, 0)) { - var comma: [*c]const u8 = strchr(uri, @as(c_int, ',')); - _ = , - if (((comma != null) and (@divExact(@as(c_long, @bitCast(@intFromPtr(comma) -% @intFromPtr(uri))), @sizeOf(u8)) >= @as(c_long, @bitCast(@as(c_long, @as(c_int, 7)))))) and (strncmp(comma - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 7))))), ";base64", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 7))))) == @as(c_int, 0))) { - var res: cgltf_result = cgltf_load_buffer_base64(options, data.*.buffers[i].size, comma + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))), &data.*.buffers[i].data); - _ = &res; - data.*.buffers[i].data_free_method = @as(c_uint, @bitCast(cgltf_data_free_method_memory_free)); - if (res != @as(c_uint, @bitCast(cgltf_result_success))) { - return res; - } - } else { - return @as(c_uint, @bitCast(cgltf_result_unknown_format)); - } - } else if ((strstr(uri, "://") == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) and (gltf_path != null)) { - var res: cgltf_result = cgltf_load_buffer_file(options, data.*.buffers[i].size, uri, gltf_path, &data.*.buffers[i].data); - _ = &res; - data.*.buffers[i].data_free_method = @as(c_uint, @bitCast(cgltf_data_free_method_file_release)); - if (res != @as(c_uint, @bitCast(cgltf_result_success))) { - return res; - } - } else { - return @as(c_uint, @bitCast(cgltf_result_unknown_format)); - } - } - } - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub export fn cgltf_load_buffer_base64(arg_options: [*c]const cgltf_options, arg_size: cgltf_size, arg_base64: [*c]const u8, arg_out_data: [*c]?*anyopaque) cgltf_result { - var options = arg_options; - _ = &options; - var size = arg_size; - _ = &size; - var base64 = arg_base64; - _ = &base64; - var out_data = arg_out_data; - _ = &out_data; - var memory_alloc: ?*const fn (?*anyopaque, cgltf_size) callconv(.C) ?*anyopaque = if (options.*.memory.alloc_func != null) options.*.memory.alloc_func else &cgltf_default_alloc; - _ = &memory_alloc; - var memory_free: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = if (options.*.memory.free_func != null) options.*.memory.free_func else &cgltf_default_free; - _ = &memory_free; - var data: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(memory_alloc.?(options.*.memory.user_data, size)))); - _ = &data; - if (!(data != null)) { - return @as(c_uint, @bitCast(cgltf_result_out_of_memory)); - } - var buffer: c_uint = 0; - _ = &buffer; - var buffer_bits: c_uint = 0; - _ = &buffer_bits; - { - var i: cgltf_size = 0; - _ = &i; - while (i < size) : (i +%= 1) { - while (buffer_bits < @as(c_uint, @bitCast(@as(c_int, 8)))) { - var ch: u8 = (blk: { - const ref = &base64; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - _ = &ch; - var index_1: c_int = if (@as(c_uint, @bitCast(@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'A'))) < @as(c_uint, @bitCast(@as(c_int, 26)))) @as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'A') else if (@as(c_uint, @bitCast(@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'a'))) < @as(c_uint, @bitCast(@as(c_int, 26)))) (@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'a')) + @as(c_int, 26) else if (@as(c_uint, @bitCast(@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, '0'))) < @as(c_uint, @bitCast(@as(c_int, 10)))) (@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, '0')) + @as(c_int, 52) else if (@as(c_int, @bitCast(@as(c_uint, ch))) == @as(c_int, '+')) @as(c_int, 62) else if (@as(c_int, @bitCast(@as(c_uint, ch))) == @as(c_int, '/')) @as(c_int, 63) else -@as(c_int, 1); - _ = &index_1; - if (index_1 < @as(c_int, 0)) { - memory_free.?(options.*.memory.user_data, @as(?*anyopaque, @ptrCast(data))); - return @as(c_uint, @bitCast(cgltf_result_io_error)); - } - buffer = (buffer << @intCast(6)) | @as(c_uint, @bitCast(index_1)); - buffer_bits +%= @as(c_uint, @bitCast(@as(c_int, 6))); - } - data[i] = @as(u8, @bitCast(@as(u8, @truncate(buffer >> @intCast(buffer_bits -% @as(c_uint, @bitCast(@as(c_int, 8)))))))); - buffer_bits -%= @as(c_uint, @bitCast(@as(c_int, 8))); - } - } - out_data.* = @as(?*anyopaque, @ptrCast(data)); - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub export fn cgltf_decode_string(arg_string: [*c]u8) cgltf_size { - var string = arg_string; - _ = &string; - var read_1: [*c]u8 = string + strcspn(string, "\\"); - _ = &read_1; - if (@as(c_int, @bitCast(@as(c_uint, read_1.*))) == @as(c_int, 0)) { - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(read_1) -% @intFromPtr(string))), @sizeOf(u8)))); - } - var write_2: [*c]u8 = string; - _ = &write_2; - var last: [*c]u8 = string; - _ = &last; - while (true) { - var written: cgltf_size = @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(read_1) -% @intFromPtr(last))), @sizeOf(u8)))); - _ = &written; - _ = memmove(@as(?*anyopaque, @ptrCast(write_2)), @as(?*const anyopaque, @ptrCast(last)), written); - write_2 += @as([*c]u8, @ptrFromInt(written)); - if (@as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &read_1; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))) == @as(c_int, 0)) { - break; - } - while (true) { - switch (@as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &read_1; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*)))) { - @as(c_int, 34) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '"'; - break; - }, - @as(c_int, 47) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '/'; - break; - }, - @as(c_int, 92) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\\'; - break; - }, - @as(c_int, 98) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\x08'; - break; - }, - @as(c_int, 102) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\x0c'; - break; - }, - @as(c_int, 114) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\r'; - break; - }, - @as(c_int, 110) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\n'; - break; - }, - @as(c_int, 116) => { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\t'; - break; - }, - @as(c_int, 117) => { - { - var character: c_int = 0; - _ = &character; - { - var i: cgltf_size = 0; - _ = &i; - while (i < @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) : (i +%= 1) { - character = (character << @intCast(4)) + cgltf_unhex((blk: { - const ref = &read_1; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*); - } - } - if (character <= @as(c_int, 127)) { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(character & @as(c_int, 255))))); - } else if (character <= @as(c_int, 2047)) { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 192) | ((character >> @intCast(6)) & @as(c_int, 255)))))); - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 128) | (character & @as(c_int, 63)))))); - } else { - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 224) | ((character >> @intCast(12)) & @as(c_int, 255)))))); - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 128) | ((character >> @intCast(6)) & @as(c_int, 63)))))); - (blk: { - const ref = &write_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 128) | (character & @as(c_int, 63)))))); - } - break; - } - }, - else => break, - } - break; - } - last = read_1; - read_1 += @as([*c]u8, @ptrFromInt(strcspn(read_1, "\\"))); - } - write_2.* = 0; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(write_2) -% @intFromPtr(string))), @sizeOf(u8)))); -} -pub export fn cgltf_decode_uri(arg_uri: [*c]u8) cgltf_size { - var uri = arg_uri; - _ = &uri; - var write_1: [*c]u8 = uri; - _ = &write_1; - var i: [*c]u8 = uri; - _ = &i; - while (i.* != 0) { - if (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '%')) { - var ch1: c_int = cgltf_unhex(i[@as(c_uint, @intCast(@as(c_int, 1)))]); - _ = &ch1; - if (ch1 >= @as(c_int, 0)) { - var ch2: c_int = cgltf_unhex(i[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &ch2; - if (ch2 >= @as(c_int, 0)) { - (blk: { - const ref = &write_1; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate((ch1 * @as(c_int, 16)) + ch2)))); - i += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - continue; - } - } - } - (blk: { - const ref = &write_1; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = &i; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - } - write_1.* = 0; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(write_1) -% @intFromPtr(uri))), @sizeOf(u8)))); -} -pub export fn cgltf_validate(arg_data: [*c]cgltf_data) cgltf_result { - var data = arg_data; - _ = &data; - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.accessors_count) : (i +%= 1) { - var accessor: [*c]cgltf_accessor = &data.*.accessors[i]; - _ = &accessor; - if (data.*.accessors[i].component_type == @as(c_uint, @bitCast(cgltf_component_type_invalid))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (data.*.accessors[i].type == @as(c_uint, @bitCast(cgltf_type_invalid))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - var element_size: cgltf_size = cgltf_calc_size(accessor.*.type, accessor.*.component_type); - _ = &element_size; - if (accessor.*.buffer_view != null) { - var req_size: cgltf_size = (accessor.*.offset +% (accessor.*.stride *% (accessor.*.count -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))))) +% element_size; - _ = &req_size; - if (accessor.*.buffer_view.*.size < req_size) return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - if (accessor.*.is_sparse != 0) { - var sparse: [*c]cgltf_accessor_sparse = &accessor.*.sparse; - _ = &sparse; - var indices_component_size: cgltf_size = cgltf_component_size(sparse.*.indices_component_type); - _ = &indices_component_size; - var indices_req_size: cgltf_size = sparse.*.indices_byte_offset +% (indices_component_size *% sparse.*.count); - _ = &indices_req_size; - var values_req_size: cgltf_size = sparse.*.values_byte_offset +% (element_size *% sparse.*.count); - _ = &values_req_size; - if ((sparse.*.indices_buffer_view.*.size < indices_req_size) or (sparse.*.values_buffer_view.*.size < values_req_size)) return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - if (((sparse.*.indices_component_type != @as(c_uint, @bitCast(cgltf_component_type_r_8u))) and (sparse.*.indices_component_type != @as(c_uint, @bitCast(cgltf_component_type_r_16u)))) and (sparse.*.indices_component_type != @as(c_uint, @bitCast(cgltf_component_type_r_32u)))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (sparse.*.indices_buffer_view.*.buffer.*.data != null) { - var index_bound: cgltf_size = cgltf_calc_index_bound(sparse.*.indices_buffer_view, sparse.*.indices_byte_offset, sparse.*.indices_component_type, sparse.*.count); - _ = &index_bound; - if (index_bound >= accessor.*.count) return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.buffer_views_count) : (i +%= 1) { - var req_size: cgltf_size = data.*.buffer_views[i].offset +% data.*.buffer_views[i].size; - _ = &req_size; - if ((data.*.buffer_views[i].buffer != null) and (data.*.buffer_views[i].buffer.*.size < req_size)) return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - if (data.*.buffer_views[i].has_meshopt_compression != 0) { - var mc: [*c]cgltf_meshopt_compression = &data.*.buffer_views[i].meshopt_compression; - _ = &mc; - if ((mc.*.buffer == @as([*c]cgltf_buffer, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) or (mc.*.buffer.*.size < (mc.*.offset +% mc.*.size))) return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - if ((data.*.buffer_views[i].stride != 0) and (mc.*.stride != data.*.buffer_views[i].stride)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (data.*.buffer_views[i].size != (mc.*.stride *% mc.*.count)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_invalid))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if ((mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_attributes))) and !(((mc.*.stride % @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0))))) and (mc.*.stride <= @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 256))))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if ((mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_triangles))) and ((mc.*.count % @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))) != @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0)))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if ((((mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_triangles))) or (mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_indices)))) and (mc.*.stride != @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2)))))) and (mc.*.stride != @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (((mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_triangles))) or (mc.*.mode == @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_indices)))) and (mc.*.filter != @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_none)))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (((mc.*.filter == @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_octahedral))) and (mc.*.stride != @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))))) and (mc.*.stride != @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8)))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if ((mc.*.filter == @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_quaternion))) and (mc.*.stride != @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8)))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.meshes_count) : (i +%= 1) { - if (data.*.meshes[i].weights != null) { - if ((data.*.meshes[i].primitives_count != 0) and (data.*.meshes[i].primitives[@as(c_uint, @intCast(@as(c_int, 0)))].targets_count != data.*.meshes[i].weights_count)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - if (data.*.meshes[i].target_names != null) { - if ((data.*.meshes[i].primitives_count != 0) and (data.*.meshes[i].primitives[@as(c_uint, @intCast(@as(c_int, 0)))].targets_count != data.*.meshes[i].target_names_count)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.meshes[i].primitives_count) : (j +%= 1) { - if (data.*.meshes[i].primitives[j].type == @as(c_uint, @bitCast(cgltf_primitive_type_invalid))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (data.*.meshes[i].primitives[j].targets_count != data.*.meshes[i].primitives[@as(c_uint, @intCast(@as(c_int, 0)))].targets_count) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (data.*.meshes[i].primitives[j].attributes_count == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - var first: [*c]cgltf_accessor = data.*.meshes[i].primitives[j].attributes[@as(c_uint, @intCast(@as(c_int, 0)))].data; - _ = &first; - if (first.*.count == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0))))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].attributes_count) : (k +%= 1) { - if (data.*.meshes[i].primitives[j].attributes[k].data.*.count != first.*.count) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].targets_count) : (k +%= 1) { - { - var m: cgltf_size = 0; - _ = &m; - while (m < data.*.meshes[i].primitives[j].targets[k].attributes_count) : (m +%= 1) { - if (data.*.meshes[i].primitives[j].targets[k].attributes[m].data.*.count != first.*.count) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - } - } - var indices: [*c]cgltf_accessor = data.*.meshes[i].primitives[j].indices; - _ = &indices; - if ((((indices != null) and (indices.*.component_type != @as(c_uint, @bitCast(cgltf_component_type_r_8u)))) and (indices.*.component_type != @as(c_uint, @bitCast(cgltf_component_type_r_16u)))) and (indices.*.component_type != @as(c_uint, @bitCast(cgltf_component_type_r_32u)))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if ((indices != null) and (indices.*.type != @as(c_uint, @bitCast(cgltf_type_scalar)))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if ((indices != null) and (indices.*.stride != cgltf_component_size(indices.*.component_type))) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - if (((indices != null) and (indices.*.buffer_view != null)) and (indices.*.buffer_view.*.buffer.*.data != null)) { - var index_bound: cgltf_size = cgltf_calc_index_bound(indices.*.buffer_view, indices.*.offset, indices.*.component_type, indices.*.count); - _ = &index_bound; - if (index_bound >= first.*.count) return @as(c_uint, @bitCast(cgltf_result_data_too_short)); - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].mappings_count) : (k +%= 1) { - if (data.*.meshes[i].primitives[j].mappings[k].variant >= data.*.variants_count) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - } - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.nodes_count) : (i +%= 1) { - if ((data.*.nodes[i].weights != null) and (data.*.nodes[i].mesh != null)) { - if ((data.*.nodes[i].mesh.*.primitives_count != 0) and (data.*.nodes[i].mesh.*.primitives[@as(c_uint, @intCast(@as(c_int, 0)))].targets_count != data.*.nodes[i].weights_count)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.nodes_count) : (i +%= 1) { - var p1: [*c]cgltf_node = data.*.nodes[i].parent; - _ = &p1; - var p2: [*c]cgltf_node = if (p1 != null) p1.*.parent else null; - _ = &p2; - while ((p1 != null) and (p2 != null)) { - if (p1 == p2) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - p1 = p1.*.parent; - p2 = if (p2.*.parent != null) p2.*.parent.*.parent else null; - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.scenes_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.scenes[i].nodes_count) : (j +%= 1) { - if (data.*.scenes[i].nodes[j].*.parent != null) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.animations_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.animations[i].channels_count) : (j +%= 1) { - var channel: [*c]cgltf_animation_channel = &data.*.animations[i].channels[j]; - _ = &channel; - if (!(channel.*.target_node != null)) { - continue; - } - var components: cgltf_size = 1; - _ = &components; - if (channel.*.target_path == @as(c_uint, @bitCast(cgltf_animation_path_type_weights))) { - if (!(channel.*.target_node.*.mesh != null) or !(channel.*.target_node.*.mesh.*.primitives_count != 0)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - components = channel.*.target_node.*.mesh.*.primitives[@as(c_uint, @intCast(@as(c_int, 0)))].targets_count; - } - var values: cgltf_size = @as(cgltf_size, @bitCast(@as(c_long, if (channel.*.sampler.*.interpolation == @as(c_uint, @bitCast(cgltf_interpolation_type_cubic_spline))) @as(c_int, 3) else @as(c_int, 1)))); - _ = &values; - if (((channel.*.sampler.*.input.*.count *% components) *% values) != channel.*.sampler.*.output.*.count) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.variants_count) : (i +%= 1) { - if (!(data.*.variants[i].name != null)) return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - } - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub export fn cgltf_free(arg_data: [*c]cgltf_data) void { - var data = arg_data; - _ = &data; - if (!(data != null)) { - return; - } - var file_release: ?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, ?*anyopaque) callconv(.C) void = if (data.*.file.release != null) data.*.file.release else &cgltf_default_file_release; - _ = &file_release; - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.asset.copyright))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.asset.generator))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.asset.version))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.asset.min_version))); - cgltf_free_extensions(data, data.*.asset.extensions, data.*.asset.extensions_count); - cgltf_free_extras(data, &data.*.asset.extras); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.accessors_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.accessors[i].name))); - cgltf_free_extensions(data, data.*.accessors[i].extensions, data.*.accessors[i].extensions_count); - cgltf_free_extras(data, &data.*.accessors[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.accessors))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.buffer_views_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.buffer_views[i].name))); - data.*.memory.free_func.?(data.*.memory.user_data, data.*.buffer_views[i].data); - cgltf_free_extensions(data, data.*.buffer_views[i].extensions, data.*.buffer_views[i].extensions_count); - cgltf_free_extras(data, &data.*.buffer_views[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.buffer_views))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.buffers_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.buffers[i].name))); - if (data.*.buffers[i].data_free_method == @as(c_uint, @bitCast(cgltf_data_free_method_file_release))) { - file_release.?(&data.*.memory, &data.*.file, data.*.buffers[i].data); - } else if (data.*.buffers[i].data_free_method == @as(c_uint, @bitCast(cgltf_data_free_method_memory_free))) { - data.*.memory.free_func.?(data.*.memory.user_data, data.*.buffers[i].data); - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.buffers[i].uri))); - cgltf_free_extensions(data, data.*.buffers[i].extensions, data.*.buffers[i].extensions_count); - cgltf_free_extras(data, &data.*.buffers[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.buffers))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.meshes_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].name))); - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.meshes[i].primitives_count) : (j +%= 1) { - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].attributes_count) : (k +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].attributes[k].name))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].attributes))); - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].targets_count) : (k +%= 1) { - { - var m: cgltf_size = 0; - _ = &m; - while (m < data.*.meshes[i].primitives[j].targets[k].attributes_count) : (m +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].targets[k].attributes[m].name))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].targets[k].attributes))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].targets))); - if (data.*.meshes[i].primitives[j].has_draco_mesh_compression != 0) { - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].draco_mesh_compression.attributes_count) : (k +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].draco_mesh_compression.attributes[k].name))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].draco_mesh_compression.attributes))); - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].mappings_count) : (k +%= 1) { - cgltf_free_extras(data, &data.*.meshes[i].primitives[j].mappings[k].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives[j].mappings))); - cgltf_free_extensions(data, data.*.meshes[i].primitives[j].extensions, data.*.meshes[i].primitives[j].extensions_count); - cgltf_free_extras(data, &data.*.meshes[i].primitives[j].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].primitives))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].weights))); - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.meshes[i].target_names_count) : (j +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].target_names[j]))); - } - } - cgltf_free_extensions(data, data.*.meshes[i].extensions, data.*.meshes[i].extensions_count); - cgltf_free_extras(data, &data.*.meshes[i].extras); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes[i].target_names))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.meshes))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.materials_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.materials[i].name))); - cgltf_free_extensions(data, data.*.materials[i].extensions, data.*.materials[i].extensions_count); - cgltf_free_extras(data, &data.*.materials[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.materials))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.images_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.images[i].name))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.images[i].uri))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.images[i].mime_type))); - cgltf_free_extensions(data, data.*.images[i].extensions, data.*.images[i].extensions_count); - cgltf_free_extras(data, &data.*.images[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.images))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.textures_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.textures[i].name))); - cgltf_free_extensions(data, data.*.textures[i].extensions, data.*.textures[i].extensions_count); - cgltf_free_extras(data, &data.*.textures[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.textures))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.samplers_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.samplers[i].name))); - cgltf_free_extensions(data, data.*.samplers[i].extensions, data.*.samplers[i].extensions_count); - cgltf_free_extras(data, &data.*.samplers[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.samplers))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.skins_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.skins[i].name))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.skins[i].joints))); - cgltf_free_extensions(data, data.*.skins[i].extensions, data.*.skins[i].extensions_count); - cgltf_free_extras(data, &data.*.skins[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.skins))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.cameras_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.cameras[i].name))); - if (data.*.cameras[i].type == @as(c_uint, @bitCast(cgltf_camera_type_perspective))) { - cgltf_free_extras(data, &data.*.cameras[i].data.perspective.extras); - } else if (data.*.cameras[i].type == @as(c_uint, @bitCast(cgltf_camera_type_orthographic))) { - cgltf_free_extras(data, &data.*.cameras[i].data.orthographic.extras); - } - cgltf_free_extensions(data, data.*.cameras[i].extensions, data.*.cameras[i].extensions_count); - cgltf_free_extras(data, &data.*.cameras[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.cameras))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.lights_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.lights[i].name))); - cgltf_free_extras(data, &data.*.lights[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.lights))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.nodes_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.nodes[i].name))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.nodes[i].children))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.nodes[i].weights))); - if (data.*.nodes[i].has_mesh_gpu_instancing != 0) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.nodes[i].mesh_gpu_instancing.attributes_count) : (j +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.nodes[i].mesh_gpu_instancing.attributes[j].name))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.nodes[i].mesh_gpu_instancing.attributes))); - } - cgltf_free_extensions(data, data.*.nodes[i].extensions, data.*.nodes[i].extensions_count); - cgltf_free_extras(data, &data.*.nodes[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.nodes))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.scenes_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.scenes[i].name))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.scenes[i].nodes))); - cgltf_free_extensions(data, data.*.scenes[i].extensions, data.*.scenes[i].extensions_count); - cgltf_free_extras(data, &data.*.scenes[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.scenes))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.animations_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.animations[i].name))); - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.animations[i].samplers_count) : (j +%= 1) { - cgltf_free_extensions(data, data.*.animations[i].samplers[j].extensions, data.*.animations[i].samplers[j].extensions_count); - cgltf_free_extras(data, &data.*.animations[i].samplers[j].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.animations[i].samplers))); - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.animations[i].channels_count) : (j +%= 1) { - cgltf_free_extensions(data, data.*.animations[i].channels[j].extensions, data.*.animations[i].channels[j].extensions_count); - cgltf_free_extras(data, &data.*.animations[i].channels[j].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.animations[i].channels))); - cgltf_free_extensions(data, data.*.animations[i].extensions, data.*.animations[i].extensions_count); - cgltf_free_extras(data, &data.*.animations[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.animations))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.variants_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.variants[i].name))); - cgltf_free_extras(data, &data.*.variants[i].extras); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.variants))); - cgltf_free_extensions(data, data.*.data_extensions, data.*.data_extensions_count); - cgltf_free_extras(data, &data.*.extras); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.extensions_used_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.extensions_used[i]))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.extensions_used))); - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.extensions_required_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.extensions_required[i]))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data.*.extensions_required))); - file_release.?(&data.*.memory, &data.*.file, data.*.file_data); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(data))); -} -pub export fn cgltf_node_transform_local(arg_node: [*c]const cgltf_node, arg_out_matrix: [*c]cgltf_float) void { - var node = arg_node; - _ = &node; - var out_matrix = arg_out_matrix; - _ = &out_matrix; - var lm: [*c]cgltf_float = out_matrix; - _ = &lm; - if (node.*.has_matrix != 0) { - _ = memcpy(@as(?*anyopaque, @ptrCast(lm)), @as(?*const anyopaque, @ptrCast(@as([*c]const cgltf_float, @ptrCast(@alignCast(&node.*.matrix))))), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 16))))); - } else { - var tx: f32 = node.*.translation[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &tx; - var ty: f32 = node.*.translation[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &ty; - var tz: f32 = node.*.translation[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &tz; - var qx: f32 = node.*.rotation[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &qx; - var qy: f32 = node.*.rotation[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &qy; - var qz: f32 = node.*.rotation[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &qz; - var qw: f32 = node.*.rotation[@as(c_uint, @intCast(@as(c_int, 3)))]; - _ = &qw; - var sx: f32 = node.*.scale[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &sx; - var sy: f32 = node.*.scale[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &sy; - var sz: f32 = node.*.scale[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &sz; - lm[@as(c_uint, @intCast(@as(c_int, 0)))] = ((@as(f32, @floatFromInt(@as(c_int, 1))) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qy) * qy)) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qz) * qz)) * sx; - lm[@as(c_uint, @intCast(@as(c_int, 1)))] = (((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qy) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * qz) * qw)) * sx; - lm[@as(c_uint, @intCast(@as(c_int, 2)))] = (((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qz) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qy) * qw)) * sx; - lm[@as(c_uint, @intCast(@as(c_int, 3)))] = 0.0; - lm[@as(c_uint, @intCast(@as(c_int, 4)))] = (((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qy) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qz) * qw)) * sy; - lm[@as(c_uint, @intCast(@as(c_int, 5)))] = ((@as(f32, @floatFromInt(@as(c_int, 1))) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qx)) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qz) * qz)) * sy; - lm[@as(c_uint, @intCast(@as(c_int, 6)))] = (((@as(f32, @floatFromInt(@as(c_int, 2))) * qy) * qz) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qw)) * sy; - lm[@as(c_uint, @intCast(@as(c_int, 7)))] = 0.0; - lm[@as(c_uint, @intCast(@as(c_int, 8)))] = (((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qz) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * qy) * qw)) * sz; - lm[@as(c_uint, @intCast(@as(c_int, 9)))] = (((@as(f32, @floatFromInt(@as(c_int, 2))) * qy) * qz) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qw)) * sz; - lm[@as(c_uint, @intCast(@as(c_int, 10)))] = ((@as(f32, @floatFromInt(@as(c_int, 1))) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qx) * qx)) - ((@as(f32, @floatFromInt(@as(c_int, 2))) * qy) * qy)) * sz; - lm[@as(c_uint, @intCast(@as(c_int, 11)))] = 0.0; - lm[@as(c_uint, @intCast(@as(c_int, 12)))] = tx; - lm[@as(c_uint, @intCast(@as(c_int, 13)))] = ty; - lm[@as(c_uint, @intCast(@as(c_int, 14)))] = tz; - lm[@as(c_uint, @intCast(@as(c_int, 15)))] = 1.0; - } -} -pub export fn cgltf_node_transform_world(arg_node: [*c]const cgltf_node, arg_out_matrix: [*c]cgltf_float) void { - var node = arg_node; - _ = &node; - var out_matrix = arg_out_matrix; - _ = &out_matrix; - var lm: [*c]cgltf_float = out_matrix; - _ = &lm; - cgltf_node_transform_local(node, lm); - var parent: [*c]const cgltf_node = node.*.parent; - _ = &parent; - while (parent != null) { - var pm: [16]f32 = undefined; - _ = ± - cgltf_node_transform_local(parent, @as([*c]f32, @ptrCast(@alignCast(&pm)))); - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 4)) : (i += 1) { - var l0: f32 = (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 0); - if (tmp >= 0) break :blk lm + @as(usize, @intCast(tmp)) else break :blk lm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &l0; - var l1: f32 = (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 1); - if (tmp >= 0) break :blk lm + @as(usize, @intCast(tmp)) else break :blk lm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &l1; - var l2: f32 = (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 2); - if (tmp >= 0) break :blk lm + @as(usize, @intCast(tmp)) else break :blk lm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &l2; - var r0: f32 = ((l0 * pm[@as(c_uint, @intCast(@as(c_int, 0)))]) + (l1 * pm[@as(c_uint, @intCast(@as(c_int, 4)))])) + (l2 * pm[@as(c_uint, @intCast(@as(c_int, 8)))]); - _ = &r0; - var r1: f32 = ((l0 * pm[@as(c_uint, @intCast(@as(c_int, 1)))]) + (l1 * pm[@as(c_uint, @intCast(@as(c_int, 5)))])) + (l2 * pm[@as(c_uint, @intCast(@as(c_int, 9)))]); - _ = &r1; - var r2: f32 = ((l0 * pm[@as(c_uint, @intCast(@as(c_int, 2)))]) + (l1 * pm[@as(c_uint, @intCast(@as(c_int, 6)))])) + (l2 * pm[@as(c_uint, @intCast(@as(c_int, 10)))]); - _ = &r2; - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 0); - if (tmp >= 0) break :blk lm + @as(usize, @intCast(tmp)) else break :blk lm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = r0; - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 1); - if (tmp >= 0) break :blk lm + @as(usize, @intCast(tmp)) else break :blk lm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = r1; - (blk: { - const tmp = (i * @as(c_int, 4)) + @as(c_int, 2); - if (tmp >= 0) break :blk lm + @as(usize, @intCast(tmp)) else break :blk lm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = r2; - } - } - lm[@as(c_uint, @intCast(@as(c_int, 12)))] += @as(cgltf_float, @floatCast(pm[@as(c_uint, @intCast(@as(c_int, 12)))])); - lm[@as(c_uint, @intCast(@as(c_int, 13)))] += @as(cgltf_float, @floatCast(pm[@as(c_uint, @intCast(@as(c_int, 13)))])); - lm[@as(c_uint, @intCast(@as(c_int, 14)))] += @as(cgltf_float, @floatCast(pm[@as(c_uint, @intCast(@as(c_int, 14)))])); - parent = parent.*.parent; - } -} -pub export fn cgltf_buffer_view_data(arg_view: [*c]const cgltf_buffer_view) [*c]const u8 { - var view = arg_view; - _ = &view; - if (view.*.data != null) return @as([*c]const u8, @ptrCast(@alignCast(view.*.data))); - if (!(view.*.buffer.*.data != null)) return null; - var result: [*c]const u8 = @as([*c]const u8, @ptrCast(@alignCast(view.*.buffer.*.data))); - _ = &result; - result += @as([*c]const u8, @ptrFromInt(view.*.offset)); - return result; -} -pub export fn cgltf_accessor_read_float(arg_accessor: [*c]const cgltf_accessor, arg_index_1: cgltf_size, arg_out: [*c]cgltf_float, arg_element_size: cgltf_size) cgltf_bool { - var accessor = arg_accessor; - _ = &accessor; - var index_1 = arg_index_1; - _ = &index_1; - var out = arg_out; - _ = &out; - var element_size = arg_element_size; - _ = &element_size; - if (accessor.*.is_sparse != 0) { - return 0; - } - if (accessor.*.buffer_view == @as([*c]cgltf_buffer_view, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - _ = memset(@as(?*anyopaque, @ptrCast(out)), @as(c_int, 0), element_size *% @sizeOf(cgltf_float)); - return 1; - } - var element: [*c]const u8 = cgltf_buffer_view_data(accessor.*.buffer_view); - _ = &element; - if (element == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - element += @as([*c]const u8, @ptrFromInt(accessor.*.offset +% (accessor.*.stride *% index_1))); - return cgltf_element_read_float(element, accessor.*.type, accessor.*.component_type, accessor.*.normalized, out, element_size); -} -pub export fn cgltf_accessor_read_uint(arg_accessor: [*c]const cgltf_accessor, arg_index_1: cgltf_size, arg_out: [*c]cgltf_uint, arg_element_size: cgltf_size) cgltf_bool { - var accessor = arg_accessor; - _ = &accessor; - var index_1 = arg_index_1; - _ = &index_1; - var out = arg_out; - _ = &out; - var element_size = arg_element_size; - _ = &element_size; - if (accessor.*.is_sparse != 0) { - return 0; - } - if (accessor.*.buffer_view == @as([*c]cgltf_buffer_view, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - _ = memset(@as(?*anyopaque, @ptrCast(out)), @as(c_int, 0), element_size *% @sizeOf(cgltf_uint)); - return 1; - } - var element: [*c]const u8 = cgltf_buffer_view_data(accessor.*.buffer_view); - _ = &element; - if (element == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - element += @as([*c]const u8, @ptrFromInt(accessor.*.offset +% (accessor.*.stride *% index_1))); - return cgltf_element_read_uint(element, accessor.*.type, accessor.*.component_type, out, element_size); -} -pub export fn cgltf_accessor_read_index(arg_accessor: [*c]const cgltf_accessor, arg_index_1: cgltf_size) cgltf_size { - var accessor = arg_accessor; - _ = &accessor; - var index_1 = arg_index_1; - _ = &index_1; - if (accessor.*.is_sparse != 0) { - return 0; - } - if (accessor.*.buffer_view == @as([*c]cgltf_buffer_view, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - var element: [*c]const u8 = cgltf_buffer_view_data(accessor.*.buffer_view); - _ = &element; - if (element == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - element += @as([*c]const u8, @ptrFromInt(accessor.*.offset +% (accessor.*.stride *% index_1))); - return cgltf_component_read_index(@as(?*const anyopaque, @ptrCast(element)), accessor.*.component_type); -} -pub export fn cgltf_num_components(arg_type: cgltf_type) cgltf_size { - var @"type" = arg_type; - _ = &@"type"; - while (true) { - switch (@"type") { - @as(c_uint, @bitCast(@as(c_int, 2))) => return 2, - @as(c_uint, @bitCast(@as(c_int, 3))) => return 3, - @as(c_uint, @bitCast(@as(c_int, 4))) => return 4, - @as(c_uint, @bitCast(@as(c_int, 5))) => return 4, - @as(c_uint, @bitCast(@as(c_int, 6))) => return 9, - @as(c_uint, @bitCast(@as(c_int, 7))) => return 16, - else => return 1, - } - break; - } - return @import("std").mem.zeroes(cgltf_size); -} -pub export fn cgltf_component_size(arg_component_type: cgltf_component_type) cgltf_size { - var component_type = arg_component_type; - _ = &component_type; - while (true) { - switch (component_type) { - @as(c_uint, @bitCast(@as(c_int, 1))), @as(c_uint, @bitCast(@as(c_int, 2))) => return 1, - @as(c_uint, @bitCast(@as(c_int, 3))), @as(c_uint, @bitCast(@as(c_int, 4))) => return 2, - @as(c_uint, @bitCast(@as(c_int, 5))), @as(c_uint, @bitCast(@as(c_int, 6))) => return 4, - else => return 0, - } - break; - } - return @import("std").mem.zeroes(cgltf_size); -} -pub export fn cgltf_calc_size(arg_type: cgltf_type, arg_component_type: cgltf_component_type) cgltf_size { - var @"type" = arg_type; - _ = &@"type"; - var component_type = arg_component_type; - _ = &component_type; - var component_size: cgltf_size = cgltf_component_size(component_type); - _ = &component_size; - if ((@"type" == @as(c_uint, @bitCast(cgltf_type_mat2))) and (component_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))) { - return @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 8)))) *% component_size; - } else if ((@"type" == @as(c_uint, @bitCast(cgltf_type_mat3))) and ((component_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))) or (component_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2))))))) { - return @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 12)))) *% component_size; - } - return component_size *% cgltf_num_components(@"type"); -} -pub export fn cgltf_accessor_unpack_floats(arg_accessor: [*c]const cgltf_accessor, arg_out: [*c]cgltf_float, arg_float_count: cgltf_size) cgltf_size { - var accessor = arg_accessor; - _ = &accessor; - var out = arg_out; - _ = &out; - var float_count = arg_float_count; - _ = &float_count; - var floats_per_element: cgltf_size = cgltf_num_components(accessor.*.type); - _ = &floats_per_element; - var available_floats: cgltf_size = accessor.*.count *% floats_per_element; - _ = &available_floats; - if (out == @as([*c]cgltf_float, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return available_floats; - } - float_count = if (available_floats < float_count) available_floats else float_count; - var element_count: cgltf_size = float_count / floats_per_element; - _ = &element_count; - if (accessor.*.buffer_view == @as([*c]cgltf_buffer_view, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - _ = memset(@as(?*anyopaque, @ptrCast(out)), @as(c_int, 0), (element_count *% floats_per_element) *% @sizeOf(cgltf_float)); - } else { - var element: [*c]const u8 = cgltf_buffer_view_data(accessor.*.buffer_view); - _ = &element; - if (element == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - element += @as([*c]const u8, @ptrFromInt(accessor.*.offset)); - if ((accessor.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f))) and (accessor.*.stride == (floats_per_element *% @sizeOf(cgltf_float)))) { - _ = memcpy(@as(?*anyopaque, @ptrCast(out)), @as(?*const anyopaque, @ptrCast(element)), (element_count *% floats_per_element) *% @sizeOf(cgltf_float)); - } else { - var dest: [*c]cgltf_float = out; - _ = &dest; - { - var index_1: cgltf_size = 0; - _ = &index_1; - while (index_1 < element_count) : (_ = blk: { - _ = blk_1: { - index_1 +%= 1; - break :blk_1 blk_2: { - const ref = &dest; - ref.* += @as([*c]cgltf_float, @ptrFromInt(floats_per_element)); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &element; - ref.* += @as([*c]const u8, @ptrFromInt(accessor.*.stride)); - break :blk_1 ref.*; - }; - }) { - if (!(cgltf_element_read_float(element, accessor.*.type, accessor.*.component_type, accessor.*.normalized, dest, floats_per_element) != 0)) { - return 0; - } - } - } - } - } - if (accessor.*.is_sparse != 0) { - var sparse: [*c]const cgltf_accessor_sparse = &accessor.*.sparse; - _ = &sparse; - var index_data: [*c]const u8 = cgltf_buffer_view_data(sparse.*.indices_buffer_view); - _ = &index_data; - var reader_head: [*c]const u8 = cgltf_buffer_view_data(sparse.*.values_buffer_view); - _ = &reader_head; - if ((index_data == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) or (reader_head == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - return 0; - } - index_data += @as([*c]const u8, @ptrFromInt(sparse.*.indices_byte_offset)); - reader_head += @as([*c]const u8, @ptrFromInt(sparse.*.values_byte_offset)); - var index_stride: cgltf_size = cgltf_component_size(sparse.*.indices_component_type); - _ = &index_stride; - { - var reader_index: cgltf_size = 0; - _ = &reader_index; - while (reader_index < sparse.*.count) : (_ = blk: { - _ = blk_1: { - reader_index +%= 1; - break :blk_1 blk_2: { - const ref = &index_data; - ref.* += @as([*c]const u8, @ptrFromInt(index_stride)); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &reader_head; - ref.* += @as([*c]const u8, @ptrFromInt(accessor.*.stride)); - break :blk_1 ref.*; - }; - }) { - var writer_index: usize = cgltf_component_read_index(@as(?*const anyopaque, @ptrCast(index_data)), sparse.*.indices_component_type); - _ = &writer_index; - var writer_head: [*c]f32 = out + (writer_index *% floats_per_element); - _ = &writer_head; - if (!(cgltf_element_read_float(reader_head, accessor.*.type, accessor.*.component_type, accessor.*.normalized, writer_head, floats_per_element) != 0)) { - return 0; - } - } - } - } - return element_count *% floats_per_element; -} -pub export fn cgltf_accessor_unpack_indices(arg_accessor: [*c]const cgltf_accessor, arg_out: ?*anyopaque, arg_out_component_size: cgltf_size, arg_index_count: cgltf_size) cgltf_size { - var accessor = arg_accessor; - _ = &accessor; - var out = arg_out; - _ = &out; - var out_component_size = arg_out_component_size; - _ = &out_component_size; - var index_count = arg_index_count; - _ = &index_count; - if (out == @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - return accessor.*.count; - } - index_count = if (accessor.*.count < index_count) accessor.*.count else index_count; - var index_component_size: cgltf_size = cgltf_component_size(accessor.*.component_type); - _ = &index_component_size; - if (accessor.*.is_sparse != 0) { - return 0; - } - if (accessor.*.buffer_view == @as([*c]cgltf_buffer_view, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - if (index_component_size > out_component_size) { - return 0; - } - var element: [*c]const u8 = cgltf_buffer_view_data(accessor.*.buffer_view); - _ = &element; - if (element == @as([*c]const u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - element += @as([*c]const u8, @ptrFromInt(accessor.*.offset)); - if ((index_component_size == out_component_size) and (accessor.*.stride == out_component_size)) { - _ = memcpy(out, @as(?*const anyopaque, @ptrCast(element)), index_count *% index_component_size); - return index_count; - } - while (true) { - switch (out_component_size) { - @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2)))) => { - { - var index_1: cgltf_size = 0; - _ = &index_1; - while (index_1 < index_count) : (_ = blk: { - index_1 +%= 1; - break :blk blk_1: { - const ref = &element; - ref.* += @as([*c]const u8, @ptrFromInt(accessor.*.stride)); - break :blk_1 ref.*; - }; - }) { - @as([*c]u16, @ptrCast(@alignCast(out)))[index_1] = @as(u16, @bitCast(@as(c_ushort, @truncate(cgltf_component_read_index(@as(?*const anyopaque, @ptrCast(element)), accessor.*.component_type))))); - } - } - break; - }, - @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))) => { - { - var index_1: cgltf_size = 0; - _ = &index_1; - while (index_1 < index_count) : (_ = blk: { - index_1 +%= 1; - break :blk blk_1: { - const ref = &element; - ref.* += @as([*c]const u8, @ptrFromInt(accessor.*.stride)); - break :blk_1 ref.*; - }; - }) { - @as([*c]u32, @ptrCast(@alignCast(out)))[index_1] = @as(u32, @bitCast(@as(c_uint, @truncate(cgltf_component_read_index(@as(?*const anyopaque, @ptrCast(element)), accessor.*.component_type))))); - } - } - break; - }, - else => break, - } - break; - } - return index_count; -} -pub export fn cgltf_copy_extras_json(arg_data: [*c]const cgltf_data, arg_extras: [*c]const cgltf_extras, arg_dest: [*c]u8, arg_dest_size: [*c]cgltf_size) cgltf_result { - var data = arg_data; - _ = &data; - var extras = arg_extras; - _ = &extras; - var dest = arg_dest; - _ = &dest; - var dest_size = arg_dest_size; - _ = &dest_size; - var json_size: cgltf_size = extras.*.end_offset -% extras.*.start_offset; - _ = &json_size; - if (!(dest != null)) { - if (dest_size != null) { - dest_size.* = json_size +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))); - return @as(c_uint, @bitCast(cgltf_result_success)); - } - return @as(c_uint, @bitCast(cgltf_result_invalid_options)); - } - if ((dest_size.* +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))) < json_size) { - _ = strncpy(dest, data.*.json + extras.*.start_offset, dest_size.* -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))); - dest[dest_size.* -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))] = 0; - } else { - _ = strncpy(dest, data.*.json + extras.*.start_offset, json_size); - dest[json_size] = 0; - } - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub export fn cgltf_mesh_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_mesh) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.meshes))), @sizeOf(cgltf_mesh)))) < data.*.meshes_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->meshes) < data->meshes_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2485))), "cgltf_size cgltf_mesh_index(const cgltf_data *, const cgltf_mesh *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.meshes))), @sizeOf(cgltf_mesh)))); -} -pub export fn cgltf_material_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_material) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.materials))), @sizeOf(cgltf_material)))) < data.*.materials_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->materials) < data->materials_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2491))), "cgltf_size cgltf_material_index(const cgltf_data *, const cgltf_material *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.materials))), @sizeOf(cgltf_material)))); -} -pub export fn cgltf_accessor_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_accessor) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.accessors))), @sizeOf(cgltf_accessor)))) < data.*.accessors_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->accessors) < data->accessors_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2497))), "cgltf_size cgltf_accessor_index(const cgltf_data *, const cgltf_accessor *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.accessors))), @sizeOf(cgltf_accessor)))); -} -pub export fn cgltf_buffer_view_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_buffer_view) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.buffer_views))), @sizeOf(cgltf_buffer_view)))) < data.*.buffer_views_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->buffer_views) < data->buffer_views_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2503))), "cgltf_size cgltf_buffer_view_index(const cgltf_data *, const cgltf_buffer_view *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.buffer_views))), @sizeOf(cgltf_buffer_view)))); -} -pub export fn cgltf_buffer_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_buffer) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.buffers))), @sizeOf(cgltf_buffer)))) < data.*.buffers_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->buffers) < data->buffers_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2509))), "cgltf_size cgltf_buffer_index(const cgltf_data *, const cgltf_buffer *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.buffers))), @sizeOf(cgltf_buffer)))); -} -pub export fn cgltf_image_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_image) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.images))), @sizeOf(cgltf_image)))) < data.*.images_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->images) < data->images_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2515))), "cgltf_size cgltf_image_index(const cgltf_data *, const cgltf_image *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.images))), @sizeOf(cgltf_image)))); -} -pub export fn cgltf_texture_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_texture) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.textures))), @sizeOf(cgltf_texture)))) < data.*.textures_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->textures) < data->textures_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2521))), "cgltf_size cgltf_texture_index(const cgltf_data *, const cgltf_texture *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.textures))), @sizeOf(cgltf_texture)))); -} -pub export fn cgltf_sampler_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_sampler) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.samplers))), @sizeOf(cgltf_sampler)))) < data.*.samplers_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->samplers) < data->samplers_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2527))), "cgltf_size cgltf_sampler_index(const cgltf_data *, const cgltf_sampler *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.samplers))), @sizeOf(cgltf_sampler)))); -} -pub export fn cgltf_skin_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_skin) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.skins))), @sizeOf(cgltf_skin)))) < data.*.skins_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->skins) < data->skins_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2533))), "cgltf_size cgltf_skin_index(const cgltf_data *, const cgltf_skin *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.skins))), @sizeOf(cgltf_skin)))); -} -pub export fn cgltf_camera_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_camera) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.cameras))), @sizeOf(cgltf_camera)))) < data.*.cameras_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->cameras) < data->cameras_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2539))), "cgltf_size cgltf_camera_index(const cgltf_data *, const cgltf_camera *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.cameras))), @sizeOf(cgltf_camera)))); -} -pub export fn cgltf_light_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_light) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.lights))), @sizeOf(cgltf_light)))) < data.*.lights_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->lights) < data->lights_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2545))), "cgltf_size cgltf_light_index(const cgltf_data *, const cgltf_light *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.lights))), @sizeOf(cgltf_light)))); -} -pub export fn cgltf_node_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_node) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.nodes))), @sizeOf(cgltf_node)))) < data.*.nodes_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->nodes) < data->nodes_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2551))), "cgltf_size cgltf_node_index(const cgltf_data *, const cgltf_node *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.nodes))), @sizeOf(cgltf_node)))); -} -pub export fn cgltf_scene_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_scene) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.scenes))), @sizeOf(cgltf_scene)))) < data.*.scenes_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->scenes) < data->scenes_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2557))), "cgltf_size cgltf_scene_index(const cgltf_data *, const cgltf_scene *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.scenes))), @sizeOf(cgltf_scene)))); -} -pub export fn cgltf_animation_index(arg_data: [*c]const cgltf_data, arg_object: [*c]const cgltf_animation) cgltf_size { - var data = arg_data; - _ = &data; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.animations))), @sizeOf(cgltf_animation)))) < data.*.animations_count)) {} else { - __assert_fail("object && (cgltf_size)(object - data->animations) < data->animations_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2563))), "cgltf_size cgltf_animation_index(const cgltf_data *, const cgltf_animation *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(data.*.animations))), @sizeOf(cgltf_animation)))); -} -pub export fn cgltf_animation_sampler_index(arg_animation: [*c]const cgltf_animation, arg_object: [*c]const cgltf_animation_sampler) cgltf_size { - var animation = arg_animation; - _ = &animation; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(animation.*.samplers))), @sizeOf(cgltf_animation_sampler)))) < animation.*.samplers_count)) {} else { - __assert_fail("object && (cgltf_size)(object - animation->samplers) < animation->samplers_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2569))), "cgltf_size cgltf_animation_sampler_index(const cgltf_animation *, const cgltf_animation_sampler *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(animation.*.samplers))), @sizeOf(cgltf_animation_sampler)))); -} -pub export fn cgltf_animation_channel_index(arg_animation: [*c]const cgltf_animation, arg_object: [*c]const cgltf_animation_channel) cgltf_size { - var animation = arg_animation; - _ = &animation; - var object = arg_object; - _ = &object; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((object != null) and (@as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(animation.*.channels))), @sizeOf(cgltf_animation_channel)))) < animation.*.channels_count)) {} else { - __assert_fail("object && (cgltf_size)(object - animation->channels) < animation->channels_count", "./external/cgltf.h", @as(c_uint, @bitCast(@as(c_int, 2575))), "cgltf_size cgltf_animation_channel_index(const cgltf_animation *, const cgltf_animation_channel *)"); - }; - }; - }; - return @as(cgltf_size, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(object) -% @intFromPtr(animation.*.channels))), @sizeOf(cgltf_animation_channel)))); -} -pub const JSMN_UNDEFINED: c_int = 0; -pub const JSMN_OBJECT: c_int = 1; -pub const JSMN_ARRAY: c_int = 2; -pub const JSMN_STRING: c_int = 3; -pub const JSMN_PRIMITIVE: c_int = 4; -pub const jsmntype_t = c_uint; -pub const JSMN_ERROR_NOMEM: c_int = -1; -pub const JSMN_ERROR_INVAL: c_int = -2; -pub const JSMN_ERROR_PART: c_int = -3; -pub const enum_jsmnerr = c_int; -pub const jsmntok_t = extern struct { - type: jsmntype_t = @import("std").mem.zeroes(jsmntype_t), - start: ptrdiff_t = @import("std").mem.zeroes(ptrdiff_t), - end: ptrdiff_t = @import("std").mem.zeroes(ptrdiff_t), - size: c_int = @import("std").mem.zeroes(c_int), - parent: c_int = @import("std").mem.zeroes(c_int), -}; -pub const jsmn_parser = extern struct { - pos: usize = @import("std").mem.zeroes(usize), - toknext: c_uint = @import("std").mem.zeroes(c_uint), - toksuper: c_int = @import("std").mem.zeroes(c_int), -}; -pub fn jsmn_init(arg_parser: [*c]jsmn_parser) callconv(.C) void { - var parser = arg_parser; - _ = &parser; - parser.*.pos = 0; - parser.*.toknext = 0; - parser.*.toksuper = -@as(c_int, 1); -} -pub fn jsmn_parse(arg_parser: [*c]jsmn_parser, arg_js: [*c]const u8, arg_len: usize, arg_tokens: [*c]jsmntok_t, arg_num_tokens: usize) callconv(.C) c_int { - var parser = arg_parser; - _ = &parser; - var js = arg_js; - _ = &js; - var len = arg_len; - _ = &len; - var tokens = arg_tokens; - _ = &tokens; - var num_tokens = arg_num_tokens; - _ = &num_tokens; - var r: c_int = undefined; - _ = &r; - var i: c_int = undefined; - _ = &i; - var token: [*c]jsmntok_t = undefined; - _ = &token; - var count: c_int = @as(c_int, @bitCast(parser.*.toknext)); - _ = &count; - while ((parser.*.pos < len) and (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) != @as(c_int, '\x00'))) : (parser.*.pos +%= 1) { - var c: u8 = undefined; - _ = &c; - var @"type": jsmntype_t = undefined; - _ = &@"type"; - c = js[parser.*.pos]; - while (true) { - switch (@as(c_int, @bitCast(@as(c_uint, c)))) { - @as(c_int, 123), @as(c_int, 91) => { - count += 1; - if (tokens == @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - break; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return JSMN_ERROR_NOMEM; - if (parser.*.toksuper != -@as(c_int, 1)) { - (blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size += 1; - token.*.parent = parser.*.toksuper; - } - token.*.type = @as(c_uint, @bitCast(if (@as(c_int, @bitCast(@as(c_uint, c))) == @as(c_int, '{')) JSMN_OBJECT else JSMN_ARRAY)); - token.*.start = @as(ptrdiff_t, @bitCast(parser.*.pos)); - parser.*.toksuper = @as(c_int, @bitCast(parser.*.toknext -% @as(c_uint, @bitCast(@as(c_int, 1))))); - break; - }, - @as(c_int, 125), @as(c_int, 93) => { - if (tokens == @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) break; - @"type" = @as(c_uint, @bitCast(if (@as(c_int, @bitCast(@as(c_uint, c))) == @as(c_int, '}')) JSMN_OBJECT else JSMN_ARRAY)); - if (parser.*.toknext < @as(c_uint, @bitCast(@as(c_int, 1)))) { - return JSMN_ERROR_INVAL; - } - token = &tokens[parser.*.toknext -% @as(c_uint, @bitCast(@as(c_int, 1)))]; - while (true) { - if ((token.*.start != @as(ptrdiff_t, @bitCast(@as(c_long, -@as(c_int, 1))))) and (token.*.end == @as(ptrdiff_t, @bitCast(@as(c_long, -@as(c_int, 1)))))) { - if (token.*.type != @"type") { - return JSMN_ERROR_INVAL; - } - token.*.end = @as(ptrdiff_t, @bitCast(parser.*.pos +% @as(usize, @bitCast(@as(c_long, @as(c_int, 1)))))); - parser.*.toksuper = token.*.parent; - break; - } - if (token.*.parent == -@as(c_int, 1)) { - if ((token.*.type != @"type") or (parser.*.toksuper == -@as(c_int, 1))) { - return JSMN_ERROR_INVAL; - } - break; - } - token = &(blk: { - const tmp = token.*.parent; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - break; - }, - @as(c_int, 34) => { - r = jsmn_parse_string(parser, js, len, tokens, num_tokens); - if (r < @as(c_int, 0)) return r; - count += 1; - if ((parser.*.toksuper != -@as(c_int, 1)) and (tokens != @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - (blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size += 1; - } - break; - }, - @as(c_int, 9), @as(c_int, 13), @as(c_int, 10), @as(c_int, 32) => break, - @as(c_int, 58) => { - parser.*.toksuper = @as(c_int, @bitCast(parser.*.toknext -% @as(c_uint, @bitCast(@as(c_int, 1))))); - break; - }, - @as(c_int, 44) => { - if ((((tokens != @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) and (parser.*.toksuper != -@as(c_int, 1))) and ((blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_ARRAY)))) and ((blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT)))) { - parser.*.toksuper = (blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent; - } - break; - }, - @as(c_int, 45), @as(c_int, 48), @as(c_int, 49), @as(c_int, 50), @as(c_int, 51), @as(c_int, 52), @as(c_int, 53), @as(c_int, 54), @as(c_int, 55), @as(c_int, 56), @as(c_int, 57), @as(c_int, 116), @as(c_int, 102), @as(c_int, 110) => { - if ((tokens != @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) and (parser.*.toksuper != -@as(c_int, 1))) { - var t: [*c]jsmntok_t = &(blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &t; - if ((t.*.type == @as(c_uint, @bitCast(JSMN_OBJECT))) or ((t.*.type == @as(c_uint, @bitCast(JSMN_STRING))) and (t.*.size != @as(c_int, 0)))) { - return JSMN_ERROR_INVAL; - } - } - r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); - if (r < @as(c_int, 0)) return r; - count += 1; - if ((parser.*.toksuper != -@as(c_int, 1)) and (tokens != @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - (blk: { - const tmp = parser.*.toksuper; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size += 1; - } - break; - }, - else => return JSMN_ERROR_INVAL, - } - break; - } - } - if (tokens != @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - { - i = @as(c_int, @bitCast(parser.*.toknext -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (i -= 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start != @as(ptrdiff_t, @bitCast(@as(c_long, -@as(c_int, 1))))) and ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end == @as(ptrdiff_t, @bitCast(@as(c_long, -@as(c_int, 1)))))) { - return JSMN_ERROR_PART; - } - } - } - } - return count; -} -pub const GlbVersion: u32 = 2; -pub const GlbMagic: u32 = @as(u32, @bitCast(@as(c_int, 1179937895))); -pub const GlbMagicJsonChunk: u32 = @as(u32, @bitCast(@as(c_int, 1313821514))); -pub const GlbMagicBinChunk: u32 = @as(u32, @bitCast(@as(c_int, 5130562))); -pub fn cgltf_default_alloc(arg_user: ?*anyopaque, arg_size: cgltf_size) callconv(.C) ?*anyopaque { - var user = arg_user; - _ = &user; - var size = arg_size; - _ = &size; - _ = &user; - return malloc(size); -} -pub fn cgltf_default_free(arg_user: ?*anyopaque, arg_ptr: ?*anyopaque) callconv(.C) void { - var user = arg_user; - _ = &user; - var ptr = arg_ptr; - _ = &ptr; - _ = &user; - free(ptr); -} -pub fn cgltf_calloc(arg_options: [*c]cgltf_options, arg_element_size: usize, arg_count: cgltf_size) callconv(.C) ?*anyopaque { - var options = arg_options; - _ = &options; - var element_size = arg_element_size; - _ = &element_size; - var count = arg_count; - _ = &count; - if ((@as(c_ulong, 18446744073709551615) / element_size) < count) { - return @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - } - var result: ?*anyopaque = options.*.memory.alloc_func.?(options.*.memory.user_data, element_size *% count); - _ = &result; - if (!(result != null)) { - return @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - } - _ = memset(result, @as(c_int, 0), element_size *% count); - return result; -} -pub fn cgltf_default_file_read(arg_memory_options: [*c]const struct_cgltf_memory_options, arg_file_options: [*c]const struct_cgltf_file_options, arg_path: [*c]const u8, arg_size: [*c]cgltf_size, arg_data: [*c]?*anyopaque) callconv(.C) cgltf_result { - var memory_options = arg_memory_options; - _ = &memory_options; - var file_options = arg_file_options; - _ = &file_options; - var path = arg_path; - _ = &path; - var size = arg_size; - _ = &size; - var data = arg_data; - _ = &data; - _ = &file_options; - var memory_alloc: ?*const fn (?*anyopaque, cgltf_size) callconv(.C) ?*anyopaque = if (memory_options.*.alloc_func != null) memory_options.*.alloc_func else &cgltf_default_alloc; - _ = &memory_alloc; - var memory_free: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = if (memory_options.*.free_func != null) memory_options.*.free_func else &cgltf_default_free; - _ = &memory_free; - var file: [*c]FILE = fopen(path, "rb"); - _ = &file; - if (!(file != null)) { - return @as(c_uint, @bitCast(cgltf_result_file_not_found)); - } - var file_size: cgltf_size = if (size != null) size.* else @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0)))); - _ = &file_size; - if (file_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0))))) { - _ = fseek(file, @as(c_long, @bitCast(@as(c_long, @as(c_int, 0)))), @as(c_int, 2)); - var length: c_long = ftell(file); - _ = &length; - if (length < @as(c_long, @bitCast(@as(c_long, @as(c_int, 0))))) { - _ = fclose(file); - return @as(c_uint, @bitCast(cgltf_result_io_error)); - } - _ = fseek(file, @as(c_long, @bitCast(@as(c_long, @as(c_int, 0)))), @as(c_int, 0)); - file_size = @as(cgltf_size, @bitCast(length)); - } - var file_data: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(memory_alloc.?(memory_options.*.user_data, file_size)))); - _ = &file_data; - if (!(file_data != null)) { - _ = fclose(file); - return @as(c_uint, @bitCast(cgltf_result_out_of_memory)); - } - var read_size: cgltf_size = fread(@as(?*anyopaque, @ptrCast(file_data)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))), file_size, file); - _ = &read_size; - _ = fclose(file); - if (read_size != file_size) { - memory_free.?(memory_options.*.user_data, @as(?*anyopaque, @ptrCast(file_data))); - return @as(c_uint, @bitCast(cgltf_result_io_error)); - } - if (size != null) { - size.* = file_size; - } - if (data != null) { - data.* = @as(?*anyopaque, @ptrCast(file_data)); - } - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub fn cgltf_default_file_release(arg_memory_options: [*c]const struct_cgltf_memory_options, arg_file_options: [*c]const struct_cgltf_file_options, arg_data: ?*anyopaque) callconv(.C) void { - var memory_options = arg_memory_options; - _ = &memory_options; - var file_options = arg_file_options; - _ = &file_options; - var data = arg_data; - _ = &data; - _ = &file_options; - var memfree: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = if (memory_options.*.free_func != null) memory_options.*.free_func else &cgltf_default_free; - _ = &memfree; - memfree.?(memory_options.*.user_data, data); -} -pub export fn cgltf_parse_json(arg_options: [*c]cgltf_options, arg_json_chunk: [*c]const u8, arg_size: cgltf_size, arg_out_data: [*c][*c]cgltf_data) cgltf_result { - var options = arg_options; - _ = &options; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var size = arg_size; - _ = &size; - var out_data = arg_out_data; - _ = &out_data; - var parser: jsmn_parser = jsmn_parser{ - .pos = @as(usize, @bitCast(@as(c_long, @as(c_int, 0)))), - .toknext = @as(c_uint, @bitCast(@as(c_int, 0))), - .toksuper = @as(c_int, 0), - }; - _ = &parser; - if (options.*.json_token_count == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0))))) { - var token_count: c_int = jsmn_parse(&parser, @as([*c]const u8, @ptrCast(@alignCast(json_chunk))), size, null, @as(usize, @bitCast(@as(c_long, @as(c_int, 0))))); - _ = &token_count; - if (token_count <= @as(c_int, 0)) { - return @as(c_uint, @bitCast(cgltf_result_invalid_json)); - } - options.*.json_token_count = @as(cgltf_size, @bitCast(@as(c_long, token_count))); - } - var tokens: [*c]jsmntok_t = @as([*c]jsmntok_t, @ptrCast(@alignCast(options.*.memory.alloc_func.?(options.*.memory.user_data, @sizeOf(jsmntok_t) *% (options.*.json_token_count +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))))))); - _ = &tokens; - if (!(tokens != null)) { - return @as(c_uint, @bitCast(cgltf_result_out_of_memory)); - } - jsmn_init(&parser); - var token_count: c_int = jsmn_parse(&parser, @as([*c]const u8, @ptrCast(@alignCast(json_chunk))), size, tokens, options.*.json_token_count); - _ = &token_count; - if (token_count <= @as(c_int, 0)) { - options.*.memory.free_func.?(options.*.memory.user_data, @as(?*anyopaque, @ptrCast(tokens))); - return @as(c_uint, @bitCast(cgltf_result_invalid_json)); - } - (blk: { - const tmp = token_count; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type = @as(c_uint, @bitCast(JSMN_UNDEFINED)); - var data: [*c]cgltf_data = @as([*c]cgltf_data, @ptrCast(@alignCast(options.*.memory.alloc_func.?(options.*.memory.user_data, @sizeOf(cgltf_data))))); - _ = &data; - if (!(data != null)) { - options.*.memory.free_func.?(options.*.memory.user_data, @as(?*anyopaque, @ptrCast(tokens))); - return @as(c_uint, @bitCast(cgltf_result_out_of_memory)); - } - _ = memset(@as(?*anyopaque, @ptrCast(data)), @as(c_int, 0), @sizeOf(cgltf_data)); - data.*.memory = options.*.memory; - data.*.file = options.*.file; - var i: c_int = cgltf_parse_json_root(options, tokens, @as(c_int, 0), json_chunk, data); - _ = &i; - options.*.memory.free_func.?(options.*.memory.user_data, @as(?*anyopaque, @ptrCast(tokens))); - if (i < @as(c_int, 0)) { - cgltf_free(data); - while (true) { - switch (i) { - @as(c_int, -2) => return @as(c_uint, @bitCast(cgltf_result_out_of_memory)), - @as(c_int, -3) => return @as(c_uint, @bitCast(cgltf_result_legacy_gltf)), - else => return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)), - } - break; - } - } - if (cgltf_fixup_pointers(data) < @as(c_int, 0)) { - cgltf_free(data); - return @as(c_uint, @bitCast(cgltf_result_invalid_gltf)); - } - data.*.json = @as([*c]const u8, @ptrCast(@alignCast(json_chunk))); - data.*.json_size = size; - out_data.* = data; - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub fn cgltf_combine_paths(arg_path: [*c]u8, arg_base: [*c]const u8, arg_uri: [*c]const u8) callconv(.C) void { - var path = arg_path; - _ = &path; - var base = arg_base; - _ = &base; - var uri = arg_uri; - _ = &uri; - var s0: [*c]const u8 = strrchr(base, @as(c_int, '/')); - _ = &s0; - var s1: [*c]const u8 = strrchr(base, @as(c_int, '\\')); - _ = &s1; - var slash: [*c]const u8 = if (s0 != null) if ((s1 != null) and (s1 > s0)) s1 else s0 else s1; - _ = &slash; - if (slash != null) { - var prefix: usize = @as(usize, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(slash) -% @intFromPtr(base))), @sizeOf(u8)) + @as(c_long, @bitCast(@as(c_long, @as(c_int, 1)))))); - _ = &prefix; - _ = strncpy(path, base, prefix); - _ = strcpy(path + prefix, uri); - } else { - _ = strcpy(path, uri); - } -} -pub fn cgltf_load_buffer_file(arg_options: [*c]const cgltf_options, arg_size: cgltf_size, arg_uri: [*c]const u8, arg_gltf_path: [*c]const u8, arg_out_data: [*c]?*anyopaque) callconv(.C) cgltf_result { - var options = arg_options; - _ = &options; - var size = arg_size; - _ = &size; - var uri = arg_uri; - _ = &uri; - var gltf_path = arg_gltf_path; - _ = &gltf_path; - var out_data = arg_out_data; - _ = &out_data; - var memory_alloc: ?*const fn (?*anyopaque, cgltf_size) callconv(.C) ?*anyopaque = if (options.*.memory.alloc_func != null) options.*.memory.alloc_func else &cgltf_default_alloc; - _ = &memory_alloc; - var memory_free: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = if (options.*.memory.free_func != null) options.*.memory.free_func else &cgltf_default_free; - _ = &memory_free; - var file_read: ?*const fn ([*c]const struct_cgltf_memory_options, [*c]const struct_cgltf_file_options, [*c]const u8, [*c]cgltf_size, [*c]?*anyopaque) callconv(.C) cgltf_result = if (options.*.file.read != null) options.*.file.read else &cgltf_default_file_read; - _ = &file_read; - var path: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(memory_alloc.?(options.*.memory.user_data, (strlen(uri) +% strlen(gltf_path)) +% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &path; - if (!(path != null)) { - return @as(c_uint, @bitCast(cgltf_result_out_of_memory)); - } - cgltf_combine_paths(path, gltf_path, uri); - _ = cgltf_decode_uri((path + strlen(path)) - strlen(uri)); - var file_data: ?*anyopaque = @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - _ = &file_data; - var result: cgltf_result = file_read.?(&options.*.memory, &options.*.file, path, &size, &file_data); - _ = &result; - memory_free.?(options.*.memory.user_data, @as(?*anyopaque, @ptrCast(path))); - out_data.* = if (result == @as(c_uint, @bitCast(cgltf_result_success))) file_data else @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - return result; -} -pub fn cgltf_unhex(arg_ch: u8) callconv(.C) c_int { - var ch = arg_ch; - _ = &ch; - return if (@as(c_uint, @bitCast(@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, '0'))) < @as(c_uint, @bitCast(@as(c_int, 10)))) @as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, '0') else if (@as(c_uint, @bitCast(@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'A'))) < @as(c_uint, @bitCast(@as(c_int, 6)))) (@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'A')) + @as(c_int, 10) else if (@as(c_uint, @bitCast(@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'a'))) < @as(c_uint, @bitCast(@as(c_int, 6)))) (@as(c_int, @bitCast(@as(c_uint, ch))) - @as(c_int, 'a')) + @as(c_int, 10) else -@as(c_int, 1); -} -pub fn cgltf_calc_index_bound(arg_buffer_view: [*c]cgltf_buffer_view, arg_offset: cgltf_size, arg_component_type: cgltf_component_type, arg_count: cgltf_size) callconv(.C) cgltf_size { - var buffer_view = arg_buffer_view; - _ = &buffer_view; - var offset = arg_offset; - _ = &offset; - var component_type = arg_component_type; - _ = &component_type; - var count = arg_count; - _ = &count; - var data: [*c]u8 = (@as([*c]u8, @ptrCast(@alignCast(buffer_view.*.buffer.*.data))) + offset) + buffer_view.*.offset; - _ = &data; - var bound: cgltf_size = 0; - _ = &bound; - while (true) { - switch (component_type) { - @as(c_uint, @bitCast(@as(c_int, 2))) => { - { - var i: usize = 0; - _ = &i; - while (i < count) : (i +%= 1) { - var v: cgltf_size = @as(cgltf_size, @bitCast(@as(c_ulong, @as([*c]u8, @ptrCast(@alignCast(data)))[i]))); - _ = &v; - bound = if (bound > v) bound else v; - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 4))) => { - { - var i: usize = 0; - _ = &i; - while (i < count) : (i +%= 1) { - var v: cgltf_size = @as(cgltf_size, @bitCast(@as(c_ulong, @as([*c]c_ushort, @ptrCast(@alignCast(data)))[i]))); - _ = &v; - bound = if (bound > v) bound else v; - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 5))) => { - { - var i: usize = 0; - _ = &i; - while (i < count) : (i +%= 1) { - var v: cgltf_size = @as(cgltf_size, @bitCast(@as(c_ulong, @as([*c]c_uint, @ptrCast(@alignCast(data)))[i]))); - _ = &v; - bound = if (bound > v) bound else v; - } - } - break; - }, - else => { - {} - }, - } - break; - } - return bound; -} -pub fn cgltf_free_extras(arg_data: [*c]cgltf_data, arg_extras: [*c]cgltf_extras) callconv(.C) void { - var data = arg_data; - _ = &data; - var extras = arg_extras; - _ = &extras; - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(extras.*.data))); -} -pub fn cgltf_free_extensions(arg_data: [*c]cgltf_data, arg_extensions: [*c]cgltf_extension, arg_extensions_count: cgltf_size) callconv(.C) void { - var data = arg_data; - _ = &data; - var extensions = arg_extensions; - _ = &extensions; - var extensions_count = arg_extensions_count; - _ = &extensions_count; - { - var i: cgltf_size = 0; - _ = &i; - while (i < extensions_count) : (i +%= 1) { - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(extensions[i].name))); - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(extensions[i].data))); - } - } - data.*.memory.free_func.?(data.*.memory.user_data, @as(?*anyopaque, @ptrCast(extensions))); -} -pub fn cgltf_component_read_integer(arg_in: ?*const anyopaque, arg_component_type: cgltf_component_type) callconv(.C) cgltf_ssize { - var in = arg_in; - _ = ∈ - var component_type = arg_component_type; - _ = &component_type; - while (true) { - switch (component_type) { - @as(c_uint, @bitCast(@as(c_int, 3))) => return @as(cgltf_ssize, @bitCast(@as(c_longlong, @as([*c]const i16, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 4))) => return @as(cgltf_ssize, @bitCast(@as(c_ulonglong, @as([*c]const u16, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 5))) => return @as(cgltf_ssize, @bitCast(@as(c_ulonglong, @as([*c]const u32, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 1))) => return @as(cgltf_ssize, @bitCast(@as(c_longlong, @as([*c]const i8, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 2))) => return @as(cgltf_ssize, @bitCast(@as(c_ulonglong, @as([*c]const u8, @ptrCast(@alignCast(in))).*))), - else => return 0, - } - break; - } - return @import("std").mem.zeroes(cgltf_ssize); -} -pub fn cgltf_component_read_index(arg_in: ?*const anyopaque, arg_component_type: cgltf_component_type) callconv(.C) cgltf_size { - var in = arg_in; - _ = ∈ - var component_type = arg_component_type; - _ = &component_type; - while (true) { - switch (component_type) { - @as(c_uint, @bitCast(@as(c_int, 4))) => return @as(cgltf_size, @bitCast(@as(c_ulong, @as([*c]const u16, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 5))) => return @as(cgltf_size, @bitCast(@as(c_ulong, @as([*c]const u32, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 2))) => return @as(cgltf_size, @bitCast(@as(c_ulong, @as([*c]const u8, @ptrCast(@alignCast(in))).*))), - else => return 0, - } - break; - } - return @import("std").mem.zeroes(cgltf_size); -} -pub fn cgltf_component_read_float(arg_in: ?*const anyopaque, arg_component_type: cgltf_component_type, arg_normalized: cgltf_bool) callconv(.C) cgltf_float { - var in = arg_in; - _ = ∈ - var component_type = arg_component_type; - _ = &component_type; - var normalized = arg_normalized; - _ = &normalized; - if (component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f))) { - return @as([*c]const f32, @ptrCast(@alignCast(in))).*; - } - if (normalized != 0) { - while (true) { - switch (component_type) { - @as(c_uint, @bitCast(@as(c_int, 3))) => return @as(cgltf_float, @floatFromInt(@as(c_int, @bitCast(@as(c_int, @as([*c]const i16, @ptrCast(@alignCast(in))).*))))) / @as(cgltf_float, @floatFromInt(@as(c_int, 32767))), - @as(c_uint, @bitCast(@as(c_int, 4))) => return @as(cgltf_float, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, @as([*c]const u16, @ptrCast(@alignCast(in))).*))))) / @as(cgltf_float, @floatFromInt(@as(c_int, 65535))), - @as(c_uint, @bitCast(@as(c_int, 1))) => return @as(cgltf_float, @floatFromInt(@as(c_int, @bitCast(@as(c_int, @as([*c]const i8, @ptrCast(@alignCast(in))).*))))) / @as(cgltf_float, @floatFromInt(@as(c_int, 127))), - @as(c_uint, @bitCast(@as(c_int, 2))) => return @as(cgltf_float, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, @as([*c]const u8, @ptrCast(@alignCast(in))).*))))) / @as(cgltf_float, @floatFromInt(@as(c_int, 255))), - else => return 0, - } - break; - } - } - return @as(cgltf_float, @floatFromInt(cgltf_component_read_integer(in, component_type))); -} -pub fn cgltf_element_read_float(arg_element: [*c]const u8, arg_type: cgltf_type, arg_component_type: cgltf_component_type, arg_normalized: cgltf_bool, arg_out: [*c]cgltf_float, arg_element_size: cgltf_size) callconv(.C) cgltf_bool { - var element = arg_element; - _ = &element; - var @"type" = arg_type; - _ = &@"type"; - var component_type = arg_component_type; - _ = &component_type; - var normalized = arg_normalized; - _ = &normalized; - var out = arg_out; - _ = &out; - var element_size = arg_element_size; - _ = &element_size; - var num_components: cgltf_size = cgltf_num_components(@"type"); - _ = &num_components; - if (element_size < num_components) { - return 0; - } - var component_size: cgltf_size = cgltf_component_size(component_type); - _ = &component_size; - if ((@"type" == @as(c_uint, @bitCast(cgltf_type_mat2))) and (component_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))) { - out[@as(c_uint, @intCast(@as(c_int, 0)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element)), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 1)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 2)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 3)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 5))))))), component_type, normalized); - return 1; - } - if ((@"type" == @as(c_uint, @bitCast(cgltf_type_mat3))) and (component_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))) { - out[@as(c_uint, @intCast(@as(c_int, 0)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element)), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 1)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 2)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 3)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 4)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 5))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 5)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 6)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 8))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 7)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 9))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 8)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 10))))))), component_type, normalized); - return 1; - } - if ((@"type" == @as(c_uint, @bitCast(cgltf_type_mat3))) and (component_size == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2)))))) { - out[@as(c_uint, @intCast(@as(c_int, 0)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element)), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 1)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 2)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 3)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 8))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 4)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 10))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 5)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 12))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 6)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 16))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 7)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 18))))))), component_type, normalized); - out[@as(c_uint, @intCast(@as(c_int, 8)))] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 20))))))), component_type, normalized); - return 1; - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < num_components) : (i +%= 1) { - out[i] = cgltf_component_read_float(@as(?*const anyopaque, @ptrCast(element + (component_size *% i))), component_type, normalized); - } - } - return 1; -} -pub fn cgltf_component_read_uint(arg_in: ?*const anyopaque, arg_component_type: cgltf_component_type) callconv(.C) cgltf_uint { - var in = arg_in; - _ = ∈ - var component_type = arg_component_type; - _ = &component_type; - while (true) { - switch (component_type) { - @as(c_uint, @bitCast(@as(c_int, 1))) => return @as(cgltf_uint, @bitCast(@as(c_int, @as([*c]const i8, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 2))) => return @as(cgltf_uint, @bitCast(@as(c_uint, @as([*c]const u8, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 3))) => return @as(cgltf_uint, @bitCast(@as(c_int, @as([*c]const i16, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 4))) => return @as(cgltf_uint, @bitCast(@as(c_uint, @as([*c]const u16, @ptrCast(@alignCast(in))).*))), - @as(c_uint, @bitCast(@as(c_int, 5))) => return @as([*c]const u32, @ptrCast(@alignCast(in))).*, - else => return 0, - } - break; - } - return @import("std").mem.zeroes(cgltf_uint); -} -pub fn cgltf_element_read_uint(arg_element: [*c]const u8, arg_type: cgltf_type, arg_component_type: cgltf_component_type, arg_out: [*c]cgltf_uint, arg_element_size: cgltf_size) callconv(.C) cgltf_bool { - var element = arg_element; - _ = &element; - var @"type" = arg_type; - _ = &@"type"; - var component_type = arg_component_type; - _ = &component_type; - var out = arg_out; - _ = &out; - var element_size = arg_element_size; - _ = &element_size; - var num_components: cgltf_size = cgltf_num_components(@"type"); - _ = &num_components; - if (element_size < num_components) { - return 0; - } - if (((@"type" == @as(c_uint, @bitCast(cgltf_type_mat2))) or (@"type" == @as(c_uint, @bitCast(cgltf_type_mat3)))) or (@"type" == @as(c_uint, @bitCast(cgltf_type_mat4)))) { - return 0; - } - var component_size: cgltf_size = cgltf_component_size(component_type); - _ = &component_size; - { - var i: cgltf_size = 0; - _ = &i; - while (i < num_components) : (i +%= 1) { - out[i] = cgltf_component_read_uint(@as(?*const anyopaque, @ptrCast(element + (component_size *% i))), component_type); - } - } - return 1; -} -pub fn cgltf_json_strcmp(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8, arg_str: [*c]const u8) callconv(.C) c_int { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var str = arg_str; - _ = &str; - if (tok.*.type != @as(c_uint, @bitCast(JSMN_STRING))) { - return -@as(c_int, 1); - } - const str_len: usize = strlen(str); - _ = &str_len; - const name_length: usize = @as(usize, @bitCast(tok.*.end - tok.*.start)); - _ = &name_length; - return if (str_len == name_length) strncmp(@as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + @as(usize, @bitCast(@as(isize, @intCast(tok.*.start)))), str, str_len) else @as(c_int, 128); -} -pub fn cgltf_json_to_int(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8) callconv(.C) c_int { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - if (tok.*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - var tmp: [128]u8 = undefined; - _ = &tmp; - var size: c_int = if (@as(usize, @bitCast(tok.*.end - tok.*.start)) < @sizeOf([128]u8)) @as(c_int, @bitCast(@as(c_int, @truncate(tok.*.end - tok.*.start)))) else @as(c_int, @bitCast(@as(c_uint, @truncate(@sizeOf([128]u8) -% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &size; - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&tmp))), @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + @as(usize, @bitCast(@as(isize, @intCast(tok.*.start)))), @as(c_ulong, @bitCast(@as(c_long, size)))); - tmp[@as(c_uint, @intCast(size))] = 0; - return atoi(@as([*c]u8, @ptrCast(@alignCast(&tmp)))); -} -pub fn cgltf_json_to_size(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8) callconv(.C) cgltf_size { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - if (tok.*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return 0; - } - var tmp: [128]u8 = undefined; - _ = &tmp; - var size: c_int = if (@as(usize, @bitCast(tok.*.end - tok.*.start)) < @sizeOf([128]u8)) @as(c_int, @bitCast(@as(c_int, @truncate(tok.*.end - tok.*.start)))) else @as(c_int, @bitCast(@as(c_uint, @truncate(@sizeOf([128]u8) -% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &size; - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&tmp))), @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + @as(usize, @bitCast(@as(isize, @intCast(tok.*.start)))), @as(c_ulong, @bitCast(@as(c_long, size)))); - tmp[@as(c_uint, @intCast(size))] = 0; - var res: c_longlong = atoll(@as([*c]u8, @ptrCast(@alignCast(&tmp)))); - _ = &res; - return if (res < @as(c_longlong, @bitCast(@as(c_longlong, @as(c_int, 0))))) @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0)))) else @as(cgltf_size, @bitCast(@as(c_long, @truncate(res)))); -} -pub fn cgltf_json_to_float(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8) callconv(.C) cgltf_float { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - if (tok.*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return @as(cgltf_float, @floatFromInt(-@as(c_int, 1))); - } - var tmp: [128]u8 = undefined; - _ = &tmp; - var size: c_int = if (@as(usize, @bitCast(tok.*.end - tok.*.start)) < @sizeOf([128]u8)) @as(c_int, @bitCast(@as(c_int, @truncate(tok.*.end - tok.*.start)))) else @as(c_int, @bitCast(@as(c_uint, @truncate(@sizeOf([128]u8) -% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &size; - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&tmp))), @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + @as(usize, @bitCast(@as(isize, @intCast(tok.*.start)))), @as(c_ulong, @bitCast(@as(c_long, size)))); - tmp[@as(c_uint, @intCast(size))] = 0; - return @as(cgltf_float, @floatCast(atof(@as([*c]u8, @ptrCast(@alignCast(&tmp)))))); -} -pub fn cgltf_json_to_bool(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8) callconv(.C) cgltf_bool { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var size: c_int = @as(c_int, @bitCast(@as(c_int, @truncate(tok.*.end - tok.*.start)))); - _ = &size; - return @intFromBool((size == @as(c_int, 4)) and (memcmp(@as(?*const anyopaque, @ptrCast(json_chunk + @as(usize, @bitCast(@as(isize, @intCast(tok.*.start)))))), @as(?*const anyopaque, @ptrCast("true")), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))) == @as(c_int, 0))); -} -pub fn cgltf_skip_json(arg_tokens: [*c]const jsmntok_t, arg_i: c_int) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var end: c_int = i + @as(c_int, 1); - _ = &end; - while (i < end) { - while (true) { - switch ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type) { - @as(c_uint, @bitCast(@as(c_int, 1))) => { - end += (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size * @as(c_int, 2); - break; - }, - @as(c_uint, @bitCast(@as(c_int, 2))) => { - end += (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - break; - }, - @as(c_uint, @bitCast(@as(c_int, 4))), @as(c_uint, @bitCast(@as(c_int, 3))) => break, - else => return -@as(c_int, 1), - } - break; - } - i += 1; - } - return i; -} -pub fn cgltf_fill_float_array(arg_out_array: [*c]f32, arg_size: c_int, arg_value: f32) callconv(.C) void { - var out_array = arg_out_array; - _ = &out_array; - var size = arg_size; - _ = &size; - var value = arg_value; - _ = &value; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - (blk: { - const tmp = j; - if (tmp >= 0) break :blk out_array + @as(usize, @intCast(tmp)) else break :blk out_array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = value; - } - } -} -pub fn cgltf_parse_json_float_array(arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_array: [*c]f32, arg_size: c_int) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_array = arg_out_array; - _ = &out_array; - var size = arg_size; - _ = &size; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_ARRAY))) { - return -@as(c_int, 1); - } - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size != size) { - return -@as(c_int, 1); - } - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - (blk: { - const tmp = j; - if (tmp >= 0) break :blk out_array + @as(usize, @intCast(tmp)) else break :blk out_array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } - } - return i; -} -pub fn cgltf_parse_json_string(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_string: [*c][*c]u8) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_string = arg_out_string; - _ = &out_string; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) { - return -@as(c_int, 1); - } - if (out_string.* != null) { - return -@as(c_int, 1); - } - var size: c_int = @as(c_int, @bitCast(@as(c_int, @truncate((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end - (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)))); - _ = &size; - var result: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(options.*.memory.alloc_func.?(options.*.memory.user_data, @as(cgltf_size, @bitCast(@as(c_long, size + @as(c_int, 1)))))))); - _ = &result; - if (!(result != null)) { - return -@as(c_int, 2); - } - _ = strncpy(result, @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + @as(usize, @bitCast(@as(isize, @intCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)))), @as(c_ulong, @bitCast(@as(c_long, size)))); - (blk: { - const tmp = size; - if (tmp >= 0) break :blk result + @as(usize, @intCast(tmp)) else break :blk result - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - out_string.* = result; - return i + @as(c_int, 1); -} -pub fn cgltf_parse_json_array(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_element_size: usize, arg_out_array: [*c]?*anyopaque, arg_out_size: [*c]cgltf_size) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var element_size = arg_element_size; - _ = &element_size; - var out_array = arg_out_array; - _ = &out_array; - var out_size = arg_out_size; - _ = &out_size; - _ = &json_chunk; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_ARRAY))) { - return if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type == @as(c_uint, @bitCast(JSMN_OBJECT))) -@as(c_int, 3) else -@as(c_int, 1); - } - if (out_array.* != null) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - var result: ?*anyopaque = cgltf_calloc(options, element_size, @as(cgltf_size, @bitCast(@as(c_long, size)))); - _ = &result; - if (!(result != null)) { - return -@as(c_int, 2); - } - out_array.* = result; - out_size.* = @as(cgltf_size, @bitCast(@as(c_long, size))); - return i + @as(c_int, 1); -} -pub fn cgltf_parse_json_string_array(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_array: [*c][*c][*c]u8, arg_out_size: [*c]cgltf_size) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_array = arg_out_array; - _ = &out_array; - var out_size = arg_out_size; - _ = &out_size; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_ARRAY))) { - return -@as(c_int, 1); - } - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf([*c]u8), @as([*c]?*anyopaque, @ptrCast(@alignCast(out_array))), out_size); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_size.*) : (j +%= 1) { - i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + out_array.*); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_attribute_type(arg_name: [*c]const u8, arg_out_type: [*c]cgltf_attribute_type, arg_out_index: [*c]c_int) callconv(.C) void { - var name = arg_name; - _ = &name; - var out_type = arg_out_type; - _ = &out_type; - var out_index = arg_out_index; - _ = &out_index; - if (@as(c_int, @bitCast(@as(c_uint, name.*))) == @as(c_int, '_')) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_custom)); - return; - } - var us: [*c]const u8 = strchr(name, @as(c_int, '_')); - _ = &us; - var len: usize = if (us != null) @as(usize, @bitCast(@divExact(@as(c_long, @bitCast(@intFromPtr(us) -% @intFromPtr(name))), @sizeOf(u8)))) else strlen(name); - _ = &len; - if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 8))))) and (strncmp(name, "POSITION", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 8))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_position)); - } else if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 6))))) and (strncmp(name, "NORMAL", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_normal)); - } else if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 7))))) and (strncmp(name, "TANGENT", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 7))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_tangent)); - } else if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 8))))) and (strncmp(name, "TEXCOORD", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 8))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_texcoord)); - } else if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 5))))) and (strncmp(name, "COLOR", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_color)); - } else if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 6))))) and (strncmp(name, "JOINTS", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 6))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_joints)); - } else if ((len == @as(usize, @bitCast(@as(c_long, @as(c_int, 7))))) and (strncmp(name, "WEIGHTS", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 7))))) == @as(c_int, 0))) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_weights)); - } else { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_invalid)); - } - if ((us != null) and (out_type.* != @as(c_uint, @bitCast(cgltf_attribute_type_invalid)))) { - out_index.* = atoi(us + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))); - if (out_index.* < @as(c_int, 0)) { - out_type.* = @as(c_uint, @bitCast(cgltf_attribute_type_invalid)); - out_index.* = 0; - } - } -} -pub fn cgltf_parse_json_attribute_list(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_attributes: [*c][*c]cgltf_attribute, arg_out_attributes_count: [*c]cgltf_size) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_attributes = arg_out_attributes; - _ = &out_attributes; - var out_attributes_count = arg_out_attributes_count; - _ = &out_attributes_count; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_attributes.* != null) { - return -@as(c_int, 1); - } - out_attributes_count.* = @as(cgltf_size, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size))); - out_attributes.* = @as([*c]cgltf_attribute, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_attribute), out_attributes_count.*)))); - i += 1; - if (!(out_attributes.* != null)) { - return -@as(c_int, 2); - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_attributes_count.*) : (j +%= 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - i = cgltf_parse_json_string(options, tokens, i, json_chunk, &out_attributes.*[j].name); - if (i < @as(c_int, 0)) { - return -@as(c_int, 1); - } - cgltf_parse_attribute_type(out_attributes.*[j].name, &out_attributes.*[j].type, &out_attributes.*[j].index); - out_attributes.*[j].data = @as([*c]cgltf_accessor, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } - } - return i; -} -pub fn cgltf_parse_json_extras(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_extras: [*c]cgltf_extras) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_extras = arg_out_extras; - _ = &out_extras; - if (out_extras.*.data != null) { - return -@as(c_int, 1); - } - out_extras.*.start_offset = @as(cgltf_size, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)); - out_extras.*.end_offset = @as(cgltf_size, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end)); - var start: usize = @as(usize, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)); - _ = &start; - var size: usize = @as(usize, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end)) -% start; - _ = &size; - out_extras.*.data = @as([*c]u8, @ptrCast(@alignCast(options.*.memory.alloc_func.?(options.*.memory.user_data, size +% @as(usize, @bitCast(@as(c_long, @as(c_int, 1)))))))); - if (!(out_extras.*.data != null)) { - return -@as(c_int, 2); - } - _ = strncpy(out_extras.*.data, @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + start, size); - out_extras.*.data[size] = '\x00'; - i = cgltf_skip_json(tokens, i); - return i; -} -pub fn cgltf_parse_json_unprocessed_extension(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_extension: [*c]cgltf_extension) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_extension = arg_out_extension; - _ = &out_extension; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) { - return -@as(c_int, 1); - } - if ((blk: { - const tmp = i + @as(c_int, 1); - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_extension.*.name != null) { - return -@as(c_int, 1); - } - var name_length: cgltf_size = @as(cgltf_size, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end - (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)); - _ = &name_length; - out_extension.*.name = @as([*c]u8, @ptrCast(@alignCast(options.*.memory.alloc_func.?(options.*.memory.user_data, name_length +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))))); - if (!(out_extension.*.name != null)) { - return -@as(c_int, 2); - } - _ = strncpy(out_extension.*.name, @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + @as(usize, @bitCast(@as(isize, @intCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)))), name_length); - out_extension.*.name[name_length] = 0; - i += 1; - var start: usize = @as(usize, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)); - _ = &start; - var size: usize = @as(usize, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end)) -% start; - _ = &size; - out_extension.*.data = @as([*c]u8, @ptrCast(@alignCast(options.*.memory.alloc_func.?(options.*.memory.user_data, size +% @as(usize, @bitCast(@as(c_long, @as(c_int, 1)))))))); - if (!(out_extension.*.data != null)) { - return -@as(c_int, 2); - } - _ = strncpy(out_extension.*.data, @as([*c]const u8, @ptrCast(@alignCast(json_chunk))) + start, size); - out_extension.*.data[size] = '\x00'; - i = cgltf_skip_json(tokens, i); - return i; -} -pub fn cgltf_parse_json_unprocessed_extensions(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_extensions_count: [*c]cgltf_size, arg_out_extensions: [*c][*c]cgltf_extension) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_extensions_count = arg_out_extensions_count; - _ = &out_extensions_count; - var out_extensions = arg_out_extensions; - _ = &out_extensions; - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_extensions.* != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - out_extensions_count.* = 0; - out_extensions.* = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - if (!(out_extensions.* != null)) { - return -@as(c_int, 2); - } - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < extensions_size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - var extension_index: cgltf_size = blk: { - const ref = &out_extensions_count.*; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }; - _ = &extension_index; - var extension: [*c]cgltf_extension = &out_extensions.*[extension_index]; - _ = &extension; - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_draco_mesh_compression(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_draco_mesh_compression: [*c]cgltf_draco_mesh_compression) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_draco_mesh_compression = arg_out_draco_mesh_compression; - _ = &out_draco_mesh_compression; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "attributes") == @as(c_int, 0)) { - i = cgltf_parse_json_attribute_list(options, tokens, i + @as(c_int, 1), json_chunk, &out_draco_mesh_compression.*.attributes, &out_draco_mesh_compression.*.attributes_count); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "bufferView") == @as(c_int, 0)) { - i += 1; - out_draco_mesh_compression.*.buffer_view = @as([*c]cgltf_buffer_view, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_mesh_gpu_instancing(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_mesh_gpu_instancing: [*c]cgltf_mesh_gpu_instancing) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_mesh_gpu_instancing = arg_out_mesh_gpu_instancing; - _ = &out_mesh_gpu_instancing; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "attributes") == @as(c_int, 0)) { - i = cgltf_parse_json_attribute_list(options, tokens, i + @as(c_int, 1), json_chunk, &out_mesh_gpu_instancing.*.attributes, &out_mesh_gpu_instancing.*.attributes_count); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_material_mapping_data(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_mappings: [*c]cgltf_material_mapping, arg_offset: [*c]cgltf_size) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_mappings = arg_out_mappings; - _ = &out_mappings; - var offset = arg_offset; - _ = &offset; - _ = &options; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_ARRAY))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var obj_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &obj_size; - i += 1; - var material: c_int = -@as(c_int, 1); - _ = &material; - var variants_tok: c_int = -@as(c_int, 1); - _ = &variants_tok; - var extras_tok: c_int = -@as(c_int, 1); - _ = &extras_tok; - { - var k: c_int = 0; - _ = &k; - while (k < obj_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "material") == @as(c_int, 0)) { - i += 1; - material = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "variants") == @as(c_int, 0)) { - variants_tok = i + @as(c_int, 1); - if ((blk: { - const tmp = variants_tok; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_ARRAY))) { - return -@as(c_int, 1); - } - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - extras_tok = i + @as(c_int, 1); - i = cgltf_skip_json(tokens, extras_tok); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - if ((material < @as(c_int, 0)) or (variants_tok < @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (out_mappings != null) { - { - var k: c_int = 0; - _ = &k; - while (k < (blk: { - const tmp = variants_tok; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size) : (k += 1) { - var variant: c_int = cgltf_json_to_int(&(blk: { - const tmp = (variants_tok + @as(c_int, 1)) + k; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*, json_chunk); - _ = &variant; - if (variant < @as(c_int, 0)) return variant; - out_mappings[offset.*].material = @as([*c]cgltf_material, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, material))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - out_mappings[offset.*].variant = @as(cgltf_size, @bitCast(@as(c_long, variant))); - if (extras_tok >= @as(c_int, 0)) { - var e: c_int = cgltf_parse_json_extras(options, tokens, extras_tok, json_chunk, &out_mappings[offset.*].extras); - _ = &e; - if (e < @as(c_int, 0)) return e; - } - offset.* +%= 1; - } - } - } else { - offset.* +%= @as(cgltf_size, @bitCast(@as(c_long, (blk: { - const tmp = variants_tok; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size))); - } - } - } - return i; -} -pub fn cgltf_parse_json_material_mappings(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_prim: [*c]cgltf_primitive) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_prim = arg_out_prim; - _ = &out_prim; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "mappings") == @as(c_int, 0)) { - if (out_prim.*.mappings != null) { - return -@as(c_int, 1); - } - var mappings_offset: cgltf_size = 0; - _ = &mappings_offset; - var k: c_int = cgltf_parse_json_material_mapping_data(options, tokens, i + @as(c_int, 1), json_chunk, null, &mappings_offset); - _ = &k; - if (k < @as(c_int, 0)) { - return k; - } - out_prim.*.mappings_count = mappings_offset; - out_prim.*.mappings = @as([*c]cgltf_material_mapping, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_material_mapping), out_prim.*.mappings_count)))); - mappings_offset = 0; - i = cgltf_parse_json_material_mapping_data(options, tokens, i + @as(c_int, 1), json_chunk, out_prim.*.mappings, &mappings_offset); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_json_to_primitive_type(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8) callconv(.C) cgltf_primitive_type { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var @"type": c_int = cgltf_json_to_int(tok, json_chunk); - _ = &@"type"; - while (true) { - switch (@"type") { - @as(c_int, 0) => return @as(c_uint, @bitCast(cgltf_primitive_type_points)), - @as(c_int, 1) => return @as(c_uint, @bitCast(cgltf_primitive_type_lines)), - @as(c_int, 2) => return @as(c_uint, @bitCast(cgltf_primitive_type_line_loop)), - @as(c_int, 3) => return @as(c_uint, @bitCast(cgltf_primitive_type_line_strip)), - @as(c_int, 4) => return @as(c_uint, @bitCast(cgltf_primitive_type_triangles)), - @as(c_int, 5) => return @as(c_uint, @bitCast(cgltf_primitive_type_triangle_strip)), - @as(c_int, 6) => return @as(c_uint, @bitCast(cgltf_primitive_type_triangle_fan)), - else => return @as(c_uint, @bitCast(cgltf_primitive_type_invalid)), - } - break; - } - return @import("std").mem.zeroes(cgltf_primitive_type); -} -pub fn cgltf_parse_json_primitive(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_prim: [*c]cgltf_primitive) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_prim = arg_out_prim; - _ = &out_prim; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - out_prim.*.type = @as(c_uint, @bitCast(cgltf_primitive_type_triangles)); - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "mode") == @as(c_int, 0)) { - i += 1; - out_prim.*.type = cgltf_json_to_primitive_type(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "indices") == @as(c_int, 0)) { - i += 1; - out_prim.*.indices = @as([*c]cgltf_accessor, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "material") == @as(c_int, 0)) { - i += 1; - out_prim.*.material = @as([*c]cgltf_material, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "attributes") == @as(c_int, 0)) { - i = cgltf_parse_json_attribute_list(options, tokens, i + @as(c_int, 1), json_chunk, &out_prim.*.attributes, &out_prim.*.attributes_count); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "targets") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf(cgltf_morph_target), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_prim.*.targets))), &out_prim.*.targets_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < out_prim.*.targets_count) : (k +%= 1) { - i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim.*.targets[k].attributes, &out_prim.*.targets[k].attributes_count); - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_prim.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_prim.*.extensions != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - out_prim.*.extensions_count = 0; - out_prim.*.extensions = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - if (!(out_prim.*.extensions != null)) { - return -@as(c_int, 2); - } - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_draco_mesh_compression") == @as(c_int, 0)) { - out_prim.*.has_draco_mesh_compression = 1; - i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + @as(c_int, 1), json_chunk, &out_prim.*.draco_mesh_compression); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_variants") == @as(c_int, 0)) { - i = cgltf_parse_json_material_mappings(options, tokens, i + @as(c_int, 1), json_chunk, out_prim); - } else { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &out_prim.*.extensions[blk: { - const ref = &out_prim.*.extensions_count; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_mesh(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_mesh: [*c]cgltf_mesh) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_mesh = arg_out_mesh; - _ = &out_mesh; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_mesh.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "primitives") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf(cgltf_primitive), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_mesh.*.primitives))), &out_mesh.*.primitives_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var prim_index: cgltf_size = 0; - _ = &prim_index; - while (prim_index < out_mesh.*.primitives_count) : (prim_index +%= 1) { - i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh.*.primitives[prim_index]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "weights") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf(cgltf_float), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_mesh.*.weights))), &out_mesh.*.weights_count); - if (i < @as(c_int, 0)) { - return i; - } - i = cgltf_parse_json_float_array(tokens, i - @as(c_int, 1), json_chunk, out_mesh.*.weights, @as(c_int, @bitCast(@as(c_uint, @truncate(out_mesh.*.weights_count))))); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i += 1; - out_mesh.*.extras.start_offset = @as(cgltf_size, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.start)); - out_mesh.*.extras.end_offset = @as(cgltf_size, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.end)); - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type == @as(c_uint, @bitCast(JSMN_OBJECT))) { - var extras_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extras_size; - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < extras_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if ((cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "targetNames") == @as(c_int, 0)) and ((blk: { - const tmp = i + @as(c_int, 1); - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type == @as(c_uint, @bitCast(JSMN_ARRAY)))) { - i = cgltf_parse_json_string_array(options, tokens, i + @as(c_int, 1), json_chunk, &out_mesh.*.target_names, &out_mesh.*.target_names_count); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i); - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh.*.extensions_count, &out_mesh.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_meshes(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_mesh), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.meshes))), &out_data.*.meshes_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.meshes_count) : (j +%= 1) { - i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data.*.meshes[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_json_to_component_type(arg_tok: [*c]const jsmntok_t, arg_json_chunk: [*c]const u8) callconv(.C) cgltf_component_type { - var tok = arg_tok; - _ = &tok; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var @"type": c_int = cgltf_json_to_int(tok, json_chunk); - _ = &@"type"; - while (true) { - switch (@"type") { - @as(c_int, 5120) => return @as(c_uint, @bitCast(cgltf_component_type_r_8)), - @as(c_int, 5121) => return @as(c_uint, @bitCast(cgltf_component_type_r_8u)), - @as(c_int, 5122) => return @as(c_uint, @bitCast(cgltf_component_type_r_16)), - @as(c_int, 5123) => return @as(c_uint, @bitCast(cgltf_component_type_r_16u)), - @as(c_int, 5125) => return @as(c_uint, @bitCast(cgltf_component_type_r_32u)), - @as(c_int, 5126) => return @as(c_uint, @bitCast(cgltf_component_type_r_32f)), - else => return @as(c_uint, @bitCast(cgltf_component_type_invalid)), - } - break; - } - return @import("std").mem.zeroes(cgltf_component_type); -} -pub fn cgltf_parse_json_accessor_sparse(arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_sparse: [*c]cgltf_accessor_sparse) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_sparse = arg_out_sparse; - _ = &out_sparse; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "count") == @as(c_int, 0)) { - i += 1; - out_sparse.*.count = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "indices") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var indices_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &indices_size; - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < indices_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "bufferView") == @as(c_int, 0)) { - i += 1; - out_sparse.*.indices_buffer_view = @as([*c]cgltf_buffer_view, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteOffset") == @as(c_int, 0)) { - i += 1; - out_sparse.*.indices_byte_offset = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "componentType") == @as(c_int, 0)) { - i += 1; - out_sparse.*.indices_component_type = cgltf_json_to_component_type(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "values") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var values_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &values_size; - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < values_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "bufferView") == @as(c_int, 0)) { - i += 1; - out_sparse.*.values_buffer_view = @as([*c]cgltf_buffer_view, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteOffset") == @as(c_int, 0)) { - i += 1; - out_sparse.*.values_byte_offset = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_accessor(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_accessor: [*c]cgltf_accessor) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_accessor = arg_out_accessor; - _ = &out_accessor; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_accessor.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "bufferView") == @as(c_int, 0)) { - i += 1; - out_accessor.*.buffer_view = @as([*c]cgltf_buffer_view, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteOffset") == @as(c_int, 0)) { - i += 1; - out_accessor.*.offset = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "componentType") == @as(c_int, 0)) { - i += 1; - out_accessor.*.component_type = cgltf_json_to_component_type(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "normalized") == @as(c_int, 0)) { - i += 1; - out_accessor.*.normalized = cgltf_json_to_bool(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "count") == @as(c_int, 0)) { - i += 1; - out_accessor.*.count = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "type") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "SCALAR") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_scalar)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "VEC2") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_vec2)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "VEC3") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_vec3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "VEC4") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_vec4)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "MAT2") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_mat2)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "MAT3") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_mat3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "MAT4") == @as(c_int, 0)) { - out_accessor.*.type = @as(c_uint, @bitCast(cgltf_type_mat4)); - } - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "min") == @as(c_int, 0)) { - i += 1; - out_accessor.*.has_min = 1; - var min_size: c_int = if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size > @as(c_int, 16)) @as(c_int, 16) else (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &min_size; - i = cgltf_parse_json_float_array(tokens, i, json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_accessor.*.min))), min_size); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "max") == @as(c_int, 0)) { - i += 1; - out_accessor.*.has_max = 1; - var max_size: c_int = if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size > @as(c_int, 16)) @as(c_int, 16) else (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &max_size; - i = cgltf_parse_json_float_array(tokens, i, json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_accessor.*.max))), max_size); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sparse") == @as(c_int, 0)) { - out_accessor.*.is_sparse = 1; - i = cgltf_parse_json_accessor_sparse(tokens, i + @as(c_int, 1), json_chunk, &out_accessor.*.sparse); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_accessor.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor.*.extensions_count, &out_accessor.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_texture_transform(arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_texture_transform: [*c]cgltf_texture_transform) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_texture_transform = arg_out_texture_transform; - _ = &out_texture_transform; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "offset") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_texture_transform.*.offset))), @as(c_int, 2)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "rotation") == @as(c_int, 0)) { - i += 1; - out_texture_transform.*.rotation = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "scale") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_texture_transform.*.scale))), @as(c_int, 2)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "texCoord") == @as(c_int, 0)) { - i += 1; - out_texture_transform.*.has_texcoord = 1; - out_texture_transform.*.texcoord = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_texture_view(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_texture_view: [*c]cgltf_texture_view) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_texture_view = arg_out_texture_view; - _ = &out_texture_view; - _ = &options; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - out_texture_view.*.scale = 1.0; - cgltf_fill_float_array(@as([*c]cgltf_float, @ptrCast(@alignCast(&out_texture_view.*.transform.scale))), @as(c_int, 2), 1.0); - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "index") == @as(c_int, 0)) { - i += 1; - out_texture_view.*.texture = @as([*c]cgltf_texture, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "texCoord") == @as(c_int, 0)) { - i += 1; - out_texture_view.*.texcoord = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "scale") == @as(c_int, 0)) { - i += 1; - out_texture_view.*.scale = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "strength") == @as(c_int, 0)) { - i += 1; - out_texture_view.*.scale = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_texture_transform") == @as(c_int, 0)) { - out_texture_view.*.has_transform = 1; - i = cgltf_parse_json_texture_transform(tokens, i + @as(c_int, 1), json_chunk, &out_texture_view.*.transform); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_pbr_metallic_roughness(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_pbr: [*c]cgltf_pbr_metallic_roughness) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_pbr = arg_out_pbr; - _ = &out_pbr; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "metallicFactor") == @as(c_int, 0)) { - i += 1; - out_pbr.*.metallic_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "roughnessFactor") == @as(c_int, 0)) { - i += 1; - out_pbr.*.roughness_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "baseColorFactor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_pbr.*.base_color_factor))), @as(c_int, 4)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "baseColorTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_pbr.*.base_color_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "metallicRoughnessTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_pbr.*.metallic_roughness_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_pbr_specular_glossiness(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_pbr: [*c]cgltf_pbr_specular_glossiness) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_pbr = arg_out_pbr; - _ = &out_pbr; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "diffuseFactor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_pbr.*.diffuse_factor))), @as(c_int, 4)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "specularFactor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_pbr.*.specular_factor))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "glossinessFactor") == @as(c_int, 0)) { - i += 1; - out_pbr.*.glossiness_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "diffuseTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_pbr.*.diffuse_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "specularGlossinessTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_pbr.*.specular_glossiness_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_clearcoat(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_clearcoat: [*c]cgltf_clearcoat) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_clearcoat = arg_out_clearcoat; - _ = &out_clearcoat; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "clearcoatFactor") == @as(c_int, 0)) { - i += 1; - out_clearcoat.*.clearcoat_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "clearcoatRoughnessFactor") == @as(c_int, 0)) { - i += 1; - out_clearcoat.*.clearcoat_roughness_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "clearcoatTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_clearcoat.*.clearcoat_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "clearcoatRoughnessTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_clearcoat.*.clearcoat_roughness_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "clearcoatNormalTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_clearcoat.*.clearcoat_normal_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_ior(arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_ior: [*c]cgltf_ior) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_ior = arg_out_ior; - _ = &out_ior; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - out_ior.*.ior = 1.5; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "ior") == @as(c_int, 0)) { - i += 1; - out_ior.*.ior = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_specular(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_specular: [*c]cgltf_specular) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_specular = arg_out_specular; - _ = &out_specular; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - out_specular.*.specular_factor = 1.0; - cgltf_fill_float_array(@as([*c]cgltf_float, @ptrCast(@alignCast(&out_specular.*.specular_color_factor))), @as(c_int, 3), 1.0); - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "specularFactor") == @as(c_int, 0)) { - i += 1; - out_specular.*.specular_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "specularColorFactor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_specular.*.specular_color_factor))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "specularTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_specular.*.specular_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "specularColorTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_specular.*.specular_color_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_transmission(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_transmission: [*c]cgltf_transmission) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_transmission = arg_out_transmission; - _ = &out_transmission; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "transmissionFactor") == @as(c_int, 0)) { - i += 1; - out_transmission.*.transmission_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "transmissionTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_transmission.*.transmission_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_volume(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_volume: [*c]cgltf_volume) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_volume = arg_out_volume; - _ = &out_volume; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "thicknessFactor") == @as(c_int, 0)) { - i += 1; - out_volume.*.thickness_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "thicknessTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_volume.*.thickness_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "attenuationColor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_volume.*.attenuation_color))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "attenuationDistance") == @as(c_int, 0)) { - i += 1; - out_volume.*.attenuation_distance = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_sheen(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_sheen: [*c]cgltf_sheen) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_sheen = arg_out_sheen; - _ = &out_sheen; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sheenColorFactor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_sheen.*.sheen_color_factor))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sheenColorTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_sheen.*.sheen_color_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sheenRoughnessFactor") == @as(c_int, 0)) { - i += 1; - out_sheen.*.sheen_roughness_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sheenRoughnessTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_sheen.*.sheen_roughness_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_emissive_strength(arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_emissive_strength: [*c]cgltf_emissive_strength) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_emissive_strength = arg_out_emissive_strength; - _ = &out_emissive_strength; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - out_emissive_strength.*.emissive_strength = 1.0; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "emissiveStrength") == @as(c_int, 0)) { - i += 1; - out_emissive_strength.*.emissive_strength = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_iridescence(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_iridescence: [*c]cgltf_iridescence) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_iridescence = arg_out_iridescence; - _ = &out_iridescence; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - out_iridescence.*.iridescence_ior = 1.2999999523162842; - out_iridescence.*.iridescence_thickness_min = 100.0; - out_iridescence.*.iridescence_thickness_max = 400.0; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "iridescenceFactor") == @as(c_int, 0)) { - i += 1; - out_iridescence.*.iridescence_factor = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "iridescenceTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_iridescence.*.iridescence_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "iridescenceIor") == @as(c_int, 0)) { - i += 1; - out_iridescence.*.iridescence_ior = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "iridescenceThicknessMinimum") == @as(c_int, 0)) { - i += 1; - out_iridescence.*.iridescence_thickness_min = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "iridescenceThicknessMaximum") == @as(c_int, 0)) { - i += 1; - out_iridescence.*.iridescence_thickness_max = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "iridescenceThicknessTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_iridescence.*.iridescence_thickness_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_anisotropy(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_anisotropy: [*c]cgltf_anisotropy) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_anisotropy = arg_out_anisotropy; - _ = &out_anisotropy; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "anisotropyStrength") == @as(c_int, 0)) { - i += 1; - out_anisotropy.*.anisotropy_strength = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "anisotropyRotation") == @as(c_int, 0)) { - i += 1; - out_anisotropy.*.anisotropy_rotation = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "anisotropyTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_anisotropy.*.anisotropy_texture); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_dispersion(arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_dispersion: [*c]cgltf_dispersion) callconv(.C) c_int { - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_dispersion = arg_out_dispersion; - _ = &out_dispersion; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "dispersion") == @as(c_int, 0)) { - i += 1; - out_dispersion.*.dispersion = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_image(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_image: [*c]cgltf_image) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_image = arg_out_image; - _ = &out_image; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "uri") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_image.*.uri); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "bufferView") == @as(c_int, 0)) { - i += 1; - out_image.*.buffer_view = @as([*c]cgltf_buffer_view, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "mimeType") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_image.*.mime_type); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_image.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_image.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image.*.extensions_count, &out_image.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_sampler(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_sampler: [*c]cgltf_sampler) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_sampler = arg_out_sampler; - _ = &out_sampler; - _ = &options; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - out_sampler.*.wrap_s = 10497; - out_sampler.*.wrap_t = 10497; - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_sampler.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "magFilter") == @as(c_int, 0)) { - i += 1; - out_sampler.*.mag_filter = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "minFilter") == @as(c_int, 0)) { - i += 1; - out_sampler.*.min_filter = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "wrapS") == @as(c_int, 0)) { - i += 1; - out_sampler.*.wrap_s = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "wrapT") == @as(c_int, 0)) { - i += 1; - out_sampler.*.wrap_t = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_sampler.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler.*.extensions_count, &out_sampler.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_texture(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_texture: [*c]cgltf_texture) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_texture = arg_out_texture; - _ = &out_texture; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_texture.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sampler") == @as(c_int, 0)) { - i += 1; - out_texture.*.sampler = @as([*c]cgltf_sampler, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "source") == @as(c_int, 0)) { - i += 1; - out_texture.*.image = @as([*c]cgltf_image, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_texture.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_texture.*.extensions != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - i += 1; - out_texture.*.extensions = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - out_texture.*.extensions_count = 0; - if (!(out_texture.*.extensions != null)) { - return -@as(c_int, 2); - } - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_texture_basisu") == @as(c_int, 0)) { - out_texture.*.has_basisu = 1; - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var num_properties: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &num_properties; - i += 1; - { - var t: c_int = 0; - _ = &t; - while (t < num_properties) : (t += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "source") == @as(c_int, 0)) { - i += 1; - out_texture.*.basisu_image = @as([*c]cgltf_image, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &out_texture.*.extensions[blk: { - const ref = &out_texture.*.extensions_count; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_material(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_material: [*c]cgltf_material) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_material = arg_out_material; - _ = &out_material; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - cgltf_fill_float_array(@as([*c]cgltf_float, @ptrCast(@alignCast(&out_material.*.pbr_metallic_roughness.base_color_factor))), @as(c_int, 4), 1.0); - out_material.*.pbr_metallic_roughness.metallic_factor = 1.0; - out_material.*.pbr_metallic_roughness.roughness_factor = 1.0; - cgltf_fill_float_array(@as([*c]cgltf_float, @ptrCast(@alignCast(&out_material.*.pbr_specular_glossiness.diffuse_factor))), @as(c_int, 4), 1.0); - cgltf_fill_float_array(@as([*c]cgltf_float, @ptrCast(@alignCast(&out_material.*.pbr_specular_glossiness.specular_factor))), @as(c_int, 3), 1.0); - out_material.*.pbr_specular_glossiness.glossiness_factor = 1.0; - cgltf_fill_float_array(@as([*c]cgltf_float, @ptrCast(@alignCast(&out_material.*.volume.attenuation_color))), @as(c_int, 3), 1.0); - out_material.*.volume.attenuation_distance = 340282346638528860000000000000000000000.0; - out_material.*.alpha_cutoff = 0.5; - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "pbrMetallicRoughness") == @as(c_int, 0)) { - out_material.*.has_pbr_metallic_roughness = 1; - i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.pbr_metallic_roughness); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "emissiveFactor") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_material.*.emissive_factor))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "normalTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.normal_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "occlusionTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.occlusion_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "emissiveTexture") == @as(c_int, 0)) { - i = cgltf_parse_json_texture_view(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.emissive_texture); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "alphaMode") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "OPAQUE") == @as(c_int, 0)) { - out_material.*.alpha_mode = @as(c_uint, @bitCast(cgltf_alpha_mode_opaque)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "MASK") == @as(c_int, 0)) { - out_material.*.alpha_mode = @as(c_uint, @bitCast(cgltf_alpha_mode_mask)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "BLEND") == @as(c_int, 0)) { - out_material.*.alpha_mode = @as(c_uint, @bitCast(cgltf_alpha_mode_blend)); - } - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "alphaCutoff") == @as(c_int, 0)) { - i += 1; - out_material.*.alpha_cutoff = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "doubleSided") == @as(c_int, 0)) { - i += 1; - out_material.*.double_sided = cgltf_json_to_bool(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_material.*.extensions != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - i += 1; - out_material.*.extensions = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - out_material.*.extensions_count = 0; - if (!(out_material.*.extensions != null)) { - return -@as(c_int, 2); - } - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_pbrSpecularGlossiness") == @as(c_int, 0)) { - out_material.*.has_pbr_specular_glossiness = 1; - i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.pbr_specular_glossiness); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_unlit") == @as(c_int, 0)) { - out_material.*.unlit = 1; - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_clearcoat") == @as(c_int, 0)) { - out_material.*.has_clearcoat = 1; - i = cgltf_parse_json_clearcoat(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.clearcoat); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_ior") == @as(c_int, 0)) { - out_material.*.has_ior = 1; - i = cgltf_parse_json_ior(tokens, i + @as(c_int, 1), json_chunk, &out_material.*.ior); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_specular") == @as(c_int, 0)) { - out_material.*.has_specular = 1; - i = cgltf_parse_json_specular(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.specular); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_transmission") == @as(c_int, 0)) { - out_material.*.has_transmission = 1; - i = cgltf_parse_json_transmission(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.transmission); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_volume") == @as(c_int, 0)) { - out_material.*.has_volume = 1; - i = cgltf_parse_json_volume(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.volume); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_sheen") == @as(c_int, 0)) { - out_material.*.has_sheen = 1; - i = cgltf_parse_json_sheen(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.sheen); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_emissive_strength") == @as(c_int, 0)) { - out_material.*.has_emissive_strength = 1; - i = cgltf_parse_json_emissive_strength(tokens, i + @as(c_int, 1), json_chunk, &out_material.*.emissive_strength); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_iridescence") == @as(c_int, 0)) { - out_material.*.has_iridescence = 1; - i = cgltf_parse_json_iridescence(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.iridescence); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_anisotropy") == @as(c_int, 0)) { - out_material.*.has_anisotropy = 1; - i = cgltf_parse_json_anisotropy(options, tokens, i + @as(c_int, 1), json_chunk, &out_material.*.anisotropy); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_dispersion") == @as(c_int, 0)) { - out_material.*.has_dispersion = 1; - i = cgltf_parse_json_dispersion(tokens, i + @as(c_int, 1), json_chunk, &out_material.*.dispersion); - } else { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &out_material.*.extensions[blk: { - const ref = &out_material.*.extensions_count; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_accessors(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_accessor), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.accessors))), &out_data.*.accessors_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.accessors_count) : (j +%= 1) { - i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data.*.accessors[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_materials(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_material), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.materials))), &out_data.*.materials_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.materials_count) : (j +%= 1) { - i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data.*.materials[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_images(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_image), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.images))), &out_data.*.images_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.images_count) : (j +%= 1) { - i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data.*.images[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_textures(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_texture), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.textures))), &out_data.*.textures_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.textures_count) : (j +%= 1) { - i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data.*.textures[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_samplers(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_sampler), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.samplers))), &out_data.*.samplers_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.samplers_count) : (j +%= 1) { - i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data.*.samplers[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_meshopt_compression(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_meshopt_compression: [*c]cgltf_meshopt_compression) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_meshopt_compression = arg_out_meshopt_compression; - _ = &out_meshopt_compression; - _ = &options; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "buffer") == @as(c_int, 0)) { - i += 1; - out_meshopt_compression.*.buffer = @as([*c]cgltf_buffer, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteOffset") == @as(c_int, 0)) { - i += 1; - out_meshopt_compression.*.offset = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteLength") == @as(c_int, 0)) { - i += 1; - out_meshopt_compression.*.size = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteStride") == @as(c_int, 0)) { - i += 1; - out_meshopt_compression.*.stride = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "count") == @as(c_int, 0)) { - i += 1; - out_meshopt_compression.*.count = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "mode") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "ATTRIBUTES") == @as(c_int, 0)) { - out_meshopt_compression.*.mode = @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_attributes)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "TRIANGLES") == @as(c_int, 0)) { - out_meshopt_compression.*.mode = @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_triangles)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "INDICES") == @as(c_int, 0)) { - out_meshopt_compression.*.mode = @as(c_uint, @bitCast(cgltf_meshopt_compression_mode_indices)); - } - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "filter") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "NONE") == @as(c_int, 0)) { - out_meshopt_compression.*.filter = @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_none)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "OCTAHEDRAL") == @as(c_int, 0)) { - out_meshopt_compression.*.filter = @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_octahedral)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "QUATERNION") == @as(c_int, 0)) { - out_meshopt_compression.*.filter = @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_quaternion)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "EXPONENTIAL") == @as(c_int, 0)) { - out_meshopt_compression.*.filter = @as(c_uint, @bitCast(cgltf_meshopt_compression_filter_exponential)); - } - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_buffer_view(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_buffer_view: [*c]cgltf_buffer_view) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_buffer_view = arg_out_buffer_view; - _ = &out_buffer_view; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_buffer_view.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "buffer") == @as(c_int, 0)) { - i += 1; - out_buffer_view.*.buffer = @as([*c]cgltf_buffer, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteOffset") == @as(c_int, 0)) { - i += 1; - out_buffer_view.*.offset = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteLength") == @as(c_int, 0)) { - i += 1; - out_buffer_view.*.size = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteStride") == @as(c_int, 0)) { - i += 1; - out_buffer_view.*.stride = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "target") == @as(c_int, 0)) { - i += 1; - var @"type": c_int = cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - _ = &@"type"; - while (true) { - switch (@"type") { - @as(c_int, 34962) => { - @"type" = cgltf_buffer_view_type_vertices; - break; - }, - @as(c_int, 34963) => { - @"type" = cgltf_buffer_view_type_indices; - break; - }, - else => { - @"type" = cgltf_buffer_view_type_invalid; - break; - }, - } - break; - } - out_buffer_view.*.type = @as(c_uint, @bitCast(@"type")); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_buffer_view.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_buffer_view.*.extensions != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - out_buffer_view.*.extensions_count = 0; - out_buffer_view.*.extensions = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - if (!(out_buffer_view.*.extensions != null)) { - return -@as(c_int, 2); - } - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "EXT_meshopt_compression") == @as(c_int, 0)) { - out_buffer_view.*.has_meshopt_compression = 1; - i = cgltf_parse_json_meshopt_compression(options, tokens, i + @as(c_int, 1), json_chunk, &out_buffer_view.*.meshopt_compression); - } else { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &out_buffer_view.*.extensions[blk: { - const ref = &out_buffer_view.*.extensions_count; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_buffer_views(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_buffer_view), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.buffer_views))), &out_data.*.buffer_views_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.buffer_views_count) : (j +%= 1) { - i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data.*.buffer_views[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_buffer(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_buffer: [*c]cgltf_buffer) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_buffer = arg_out_buffer; - _ = &out_buffer; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_buffer.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "byteLength") == @as(c_int, 0)) { - i += 1; - out_buffer.*.size = cgltf_json_to_size(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "uri") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_buffer.*.uri); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_buffer.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer.*.extensions_count, &out_buffer.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_buffers(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_buffer), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.buffers))), &out_data.*.buffers_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.buffers_count) : (j +%= 1) { - i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data.*.buffers[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_skin(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_skin: [*c]cgltf_skin) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_skin = arg_out_skin; - _ = &out_skin; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_skin.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "joints") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf([*c]cgltf_node), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_skin.*.joints))), &out_skin.*.joints_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < out_skin.*.joints_count) : (k +%= 1) { - out_skin.*.joints[k] = @as([*c]cgltf_node, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "skeleton") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - out_skin.*.skeleton = @as([*c]cgltf_node, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "inverseBindMatrices") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - out_skin.*.inverse_bind_matrices = @as([*c]cgltf_accessor, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_skin.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin.*.extensions_count, &out_skin.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_skins(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_skin), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.skins))), &out_data.*.skins_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.skins_count) : (j +%= 1) { - i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data.*.skins[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_camera(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_camera: [*c]cgltf_camera) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_camera = arg_out_camera; - _ = &out_camera; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_camera.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "perspective") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var data_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &data_size; - i += 1; - if (out_camera.*.type != @as(c_uint, @bitCast(cgltf_camera_type_invalid))) { - return -@as(c_int, 1); - } - out_camera.*.type = @as(c_uint, @bitCast(cgltf_camera_type_perspective)); - { - var k: c_int = 0; - _ = &k; - while (k < data_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "aspectRatio") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.perspective.has_aspect_ratio = 1; - out_camera.*.data.perspective.aspect_ratio = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "yfov") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.perspective.yfov = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "zfar") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.perspective.has_zfar = 1; - out_camera.*.data.perspective.zfar = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "znear") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.perspective.znear = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_camera.*.data.perspective.extras); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "orthographic") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var data_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &data_size; - i += 1; - if (out_camera.*.type != @as(c_uint, @bitCast(cgltf_camera_type_invalid))) { - return -@as(c_int, 1); - } - out_camera.*.type = @as(c_uint, @bitCast(cgltf_camera_type_orthographic)); - { - var k: c_int = 0; - _ = &k; - while (k < data_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "xmag") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.orthographic.xmag = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "ymag") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.orthographic.ymag = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "zfar") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.orthographic.zfar = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "znear") == @as(c_int, 0)) { - i += 1; - out_camera.*.data.orthographic.znear = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_camera.*.data.orthographic.extras); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_camera.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera.*.extensions_count, &out_camera.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_cameras(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_camera), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.cameras))), &out_data.*.cameras_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.cameras_count) : (j +%= 1) { - i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data.*.cameras[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_light(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_light: [*c]cgltf_light) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_light = arg_out_light; - _ = &out_light; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - out_light.*.color[@as(c_uint, @intCast(@as(c_int, 0)))] = 1.0; - out_light.*.color[@as(c_uint, @intCast(@as(c_int, 1)))] = 1.0; - out_light.*.color[@as(c_uint, @intCast(@as(c_int, 2)))] = 1.0; - out_light.*.intensity = 1.0; - out_light.*.spot_inner_cone_angle = 0.0; - out_light.*.spot_outer_cone_angle = 3.1415927410125732 / 4.0; - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_light.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "color") == @as(c_int, 0)) { - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_light.*.color))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "intensity") == @as(c_int, 0)) { - i += 1; - out_light.*.intensity = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "type") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "directional") == @as(c_int, 0)) { - out_light.*.type = @as(c_uint, @bitCast(cgltf_light_type_directional)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "point") == @as(c_int, 0)) { - out_light.*.type = @as(c_uint, @bitCast(cgltf_light_type_point)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "spot") == @as(c_int, 0)) { - out_light.*.type = @as(c_uint, @bitCast(cgltf_light_type_spot)); - } - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "range") == @as(c_int, 0)) { - i += 1; - out_light.*.range = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "spot") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var data_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &data_size; - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < data_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "innerConeAngle") == @as(c_int, 0)) { - i += 1; - out_light.*.spot_inner_cone_angle = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "outerConeAngle") == @as(c_int, 0)) { - i += 1; - out_light.*.spot_outer_cone_angle = cgltf_json_to_float(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_light.*.extras); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_lights(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_light), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.lights))), &out_data.*.lights_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.lights_count) : (j +%= 1) { - i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data.*.lights[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_node(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_node: [*c]cgltf_node) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_node = arg_out_node; - _ = &out_node; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - out_node.*.rotation[@as(c_uint, @intCast(@as(c_int, 3)))] = 1.0; - out_node.*.scale[@as(c_uint, @intCast(@as(c_int, 0)))] = 1.0; - out_node.*.scale[@as(c_uint, @intCast(@as(c_int, 1)))] = 1.0; - out_node.*.scale[@as(c_uint, @intCast(@as(c_int, 2)))] = 1.0; - out_node.*.matrix[@as(c_uint, @intCast(@as(c_int, 0)))] = 1.0; - out_node.*.matrix[@as(c_uint, @intCast(@as(c_int, 5)))] = 1.0; - out_node.*.matrix[@as(c_uint, @intCast(@as(c_int, 10)))] = 1.0; - out_node.*.matrix[@as(c_uint, @intCast(@as(c_int, 15)))] = 1.0; - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_node.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "children") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf([*c]cgltf_node), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_node.*.children))), &out_node.*.children_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < out_node.*.children_count) : (k +%= 1) { - out_node.*.children[k] = @as([*c]cgltf_node, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "mesh") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - out_node.*.mesh = @as([*c]cgltf_mesh, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "skin") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - out_node.*.skin = @as([*c]cgltf_skin, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "camera") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - out_node.*.camera = @as([*c]cgltf_camera, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "translation") == @as(c_int, 0)) { - out_node.*.has_translation = 1; - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_node.*.translation))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "rotation") == @as(c_int, 0)) { - out_node.*.has_rotation = 1; - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_node.*.rotation))), @as(c_int, 4)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "scale") == @as(c_int, 0)) { - out_node.*.has_scale = 1; - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_node.*.scale))), @as(c_int, 3)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "matrix") == @as(c_int, 0)) { - out_node.*.has_matrix = 1; - i = cgltf_parse_json_float_array(tokens, i + @as(c_int, 1), json_chunk, @as([*c]cgltf_float, @ptrCast(@alignCast(&out_node.*.matrix))), @as(c_int, 16)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "weights") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf(cgltf_float), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_node.*.weights))), &out_node.*.weights_count); - if (i < @as(c_int, 0)) { - return i; - } - i = cgltf_parse_json_float_array(tokens, i - @as(c_int, 1), json_chunk, out_node.*.weights, @as(c_int, @bitCast(@as(c_uint, @truncate(out_node.*.weights_count))))); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_node.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_node.*.extensions != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - out_node.*.extensions_count = 0; - out_node.*.extensions = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - if (!(out_node.*.extensions != null)) { - return -@as(c_int, 2); - } - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_lights_punctual") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var data_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &data_size; - i += 1; - { - var m: c_int = 0; - _ = &m; - while (m < data_size) : (m += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "light") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_PRIMITIVE))) { - return -@as(c_int, 1); - } - out_node.*.light = @as([*c]cgltf_light, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "EXT_mesh_gpu_instancing") == @as(c_int, 0)) { - out_node.*.has_mesh_gpu_instancing = 1; - i = cgltf_parse_json_mesh_gpu_instancing(options, tokens, i + @as(c_int, 1), json_chunk, &out_node.*.mesh_gpu_instancing); - } else { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &out_node.*.extensions[blk: { - const ref = &out_node.*.extensions_count; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_nodes(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_node), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.nodes))), &out_data.*.nodes_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.nodes_count) : (j +%= 1) { - i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data.*.nodes[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_scene(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_scene: [*c]cgltf_scene) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_scene = arg_out_scene; - _ = &out_scene; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_scene.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "nodes") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf([*c]cgltf_node), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_scene.*.nodes))), &out_scene.*.nodes_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < out_scene.*.nodes_count) : (k +%= 1) { - out_scene.*.nodes[k] = @as([*c]cgltf_node, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_scene.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene.*.extensions_count, &out_scene.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_scenes(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_scene), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.scenes))), &out_data.*.scenes_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.scenes_count) : (j +%= 1) { - i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data.*.scenes[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_animation_sampler(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_sampler: [*c]cgltf_animation_sampler) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_sampler = arg_out_sampler; - _ = &out_sampler; - _ = &options; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "input") == @as(c_int, 0)) { - i += 1; - out_sampler.*.input = @as([*c]cgltf_accessor, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "output") == @as(c_int, 0)) { - i += 1; - out_sampler.*.output = @as([*c]cgltf_accessor, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "interpolation") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "LINEAR") == @as(c_int, 0)) { - out_sampler.*.interpolation = @as(c_uint, @bitCast(cgltf_interpolation_type_linear)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "STEP") == @as(c_int, 0)) { - out_sampler.*.interpolation = @as(c_uint, @bitCast(cgltf_interpolation_type_step)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "CUBICSPLINE") == @as(c_int, 0)) { - out_sampler.*.interpolation = @as(c_uint, @bitCast(cgltf_interpolation_type_cubic_spline)); - } - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_sampler.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler.*.extensions_count, &out_sampler.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_animation_channel(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_channel: [*c]cgltf_animation_channel) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_channel = arg_out_channel; - _ = &out_channel; - _ = &options; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "sampler") == @as(c_int, 0)) { - i += 1; - out_channel.*.sampler = @as([*c]cgltf_animation_sampler, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "target") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var target_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &target_size; - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < target_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "node") == @as(c_int, 0)) { - i += 1; - out_channel.*.target_node = @as([*c]cgltf_node, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "path") == @as(c_int, 0)) { - i += 1; - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "translation") == @as(c_int, 0)) { - out_channel.*.target_path = @as(c_uint, @bitCast(cgltf_animation_path_type_translation)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "rotation") == @as(c_int, 0)) { - out_channel.*.target_path = @as(c_uint, @bitCast(cgltf_animation_path_type_rotation)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "scale") == @as(c_int, 0)) { - out_channel.*.target_path = @as(c_uint, @bitCast(cgltf_animation_path_type_scale)); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "weights") == @as(c_int, 0)) { - out_channel.*.target_path = @as(c_uint, @bitCast(cgltf_animation_path_type_weights)); - } - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_channel.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel.*.extensions_count, &out_channel.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_animation(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_animation: [*c]cgltf_animation) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_animation = arg_out_animation; - _ = &out_animation; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_animation.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "samplers") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf(cgltf_animation_sampler), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_animation.*.samplers))), &out_animation.*.samplers_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < out_animation.*.samplers_count) : (k +%= 1) { - i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation.*.samplers[k]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "channels") == @as(c_int, 0)) { - i = cgltf_parse_json_array(options, tokens, i + @as(c_int, 1), json_chunk, @sizeOf(cgltf_animation_channel), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_animation.*.channels))), &out_animation.*.channels_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < out_animation.*.channels_count) : (k +%= 1) { - i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation.*.channels[k]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_animation.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation.*.extensions_count, &out_animation.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_animations(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_animation), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.animations))), &out_data.*.animations_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.animations_count) : (j +%= 1) { - i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data.*.animations[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_variant(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_variant: [*c]cgltf_material_variant) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_variant = arg_out_variant; - _ = &out_variant; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "name") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_variant.*.name); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_variant.*.extras); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_variants(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - i = cgltf_parse_json_array(options, tokens, i, json_chunk, @sizeOf(cgltf_material_variant), @as([*c]?*anyopaque, @ptrCast(@alignCast(&out_data.*.variants))), &out_data.*.variants_count); - if (i < @as(c_int, 0)) { - return i; - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < out_data.*.variants_count) : (j +%= 1) { - i = cgltf_parse_json_variant(options, tokens, i, json_chunk, &out_data.*.variants[j]); - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn cgltf_parse_json_asset(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_asset: [*c]cgltf_asset) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_asset = arg_out_asset; - _ = &out_asset; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "copyright") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_asset.*.copyright); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "generator") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_asset.*.generator); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "version") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_asset.*.version); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "minVersion") == @as(c_int, 0)) { - i = cgltf_parse_json_string(options, tokens, i + @as(c_int, 1), json_chunk, &out_asset.*.min_version); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_asset.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset.*.extensions_count, &out_asset.*.extensions); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - if ((out_asset.*.version != null) and (atof(out_asset.*.version) < @as(f64, @floatFromInt(@as(c_int, 2))))) { - return -@as(c_int, 3); - } - return i; -} -pub fn cgltf_fixup_pointers(arg_data: [*c]cgltf_data) callconv(.C) c_int { - var data = arg_data; - _ = &data; - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.meshes_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.meshes[i].primitives_count) : (j +%= 1) { - if (data.*.meshes[i].primitives[j].indices != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].indices))) > data.*.accessors_count) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].indices = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].indices))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.meshes[i].primitives[j].material != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].material))) > data.*.materials_count) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].material = &data.*.materials[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].material))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].attributes_count) : (k +%= 1) { - if (!(data.*.meshes[i].primitives[j].attributes[k].data != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].attributes[k].data))) > data.*.accessors_count)) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].attributes[k].data = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].attributes[k].data))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].targets_count) : (k +%= 1) { - { - var m: cgltf_size = 0; - _ = &m; - while (m < data.*.meshes[i].primitives[j].targets[k].attributes_count) : (m +%= 1) { - if (!(data.*.meshes[i].primitives[j].targets[k].attributes[m].data != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].targets[k].attributes[m].data))) > data.*.accessors_count)) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].targets[k].attributes[m].data = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].targets[k].attributes[m].data))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - } - if (data.*.meshes[i].primitives[j].has_draco_mesh_compression != 0) { - if (!(data.*.meshes[i].primitives[j].draco_mesh_compression.buffer_view != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].draco_mesh_compression.buffer_view))) > data.*.buffer_views_count)) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].draco_mesh_compression.buffer_view = &data.*.buffer_views[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].draco_mesh_compression.buffer_view))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - { - var m: cgltf_size = 0; - _ = &m; - while (m < data.*.meshes[i].primitives[j].draco_mesh_compression.attributes_count) : (m +%= 1) { - if (!(data.*.meshes[i].primitives[j].draco_mesh_compression.attributes[m].data != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].draco_mesh_compression.attributes[m].data))) > data.*.accessors_count)) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].draco_mesh_compression.attributes[m].data = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].draco_mesh_compression.attributes[m].data))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - { - var k: cgltf_size = 0; - _ = &k; - while (k < data.*.meshes[i].primitives[j].mappings_count) : (k +%= 1) { - if (!(data.*.meshes[i].primitives[j].mappings[k].material != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].mappings[k].material))) > data.*.materials_count)) { - return -@as(c_int, 1); - } - data.*.meshes[i].primitives[j].mappings[k].material = &data.*.materials[@as(cgltf_size, @intCast(@intFromPtr(data.*.meshes[i].primitives[j].mappings[k].material))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.accessors_count) : (i +%= 1) { - if (data.*.accessors[i].buffer_view != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.accessors[i].buffer_view))) > data.*.buffer_views_count) { - return -@as(c_int, 1); - } - data.*.accessors[i].buffer_view = &data.*.buffer_views[@as(cgltf_size, @intCast(@intFromPtr(data.*.accessors[i].buffer_view))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.accessors[i].is_sparse != 0) { - if (!(data.*.accessors[i].sparse.indices_buffer_view != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.accessors[i].sparse.indices_buffer_view))) > data.*.buffer_views_count)) { - return -@as(c_int, 1); - } - data.*.accessors[i].sparse.indices_buffer_view = &data.*.buffer_views[@as(cgltf_size, @intCast(@intFromPtr(data.*.accessors[i].sparse.indices_buffer_view))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - if (!(data.*.accessors[i].sparse.values_buffer_view != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.accessors[i].sparse.values_buffer_view))) > data.*.buffer_views_count)) { - return -@as(c_int, 1); - } - data.*.accessors[i].sparse.values_buffer_view = &data.*.buffer_views[@as(cgltf_size, @intCast(@intFromPtr(data.*.accessors[i].sparse.values_buffer_view))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.accessors[i].buffer_view != null) { - data.*.accessors[i].stride = data.*.accessors[i].buffer_view.*.stride; - } - if (data.*.accessors[i].stride == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 0))))) { - data.*.accessors[i].stride = cgltf_calc_size(data.*.accessors[i].type, data.*.accessors[i].component_type); - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.textures_count) : (i +%= 1) { - if (data.*.textures[i].image != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.textures[i].image))) > data.*.images_count) { - return -@as(c_int, 1); - } - data.*.textures[i].image = &data.*.images[@as(cgltf_size, @intCast(@intFromPtr(data.*.textures[i].image))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.textures[i].basisu_image != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.textures[i].basisu_image))) > data.*.images_count) { - return -@as(c_int, 1); - } - data.*.textures[i].basisu_image = &data.*.images[@as(cgltf_size, @intCast(@intFromPtr(data.*.textures[i].basisu_image))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.textures[i].sampler != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.textures[i].sampler))) > data.*.samplers_count) { - return -@as(c_int, 1); - } - data.*.textures[i].sampler = &data.*.samplers[@as(cgltf_size, @intCast(@intFromPtr(data.*.textures[i].sampler))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.images_count) : (i +%= 1) { - if (data.*.images[i].buffer_view != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.images[i].buffer_view))) > data.*.buffer_views_count) { - return -@as(c_int, 1); - } - data.*.images[i].buffer_view = &data.*.buffer_views[@as(cgltf_size, @intCast(@intFromPtr(data.*.images[i].buffer_view))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.materials_count) : (i +%= 1) { - if (data.*.materials[i].normal_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].normal_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].normal_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].normal_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].emissive_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].emissive_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].emissive_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].emissive_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].occlusion_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].occlusion_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].occlusion_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].occlusion_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].pbr_metallic_roughness.base_color_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_metallic_roughness.base_color_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].pbr_metallic_roughness.base_color_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_metallic_roughness.base_color_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].pbr_specular_glossiness.diffuse_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_specular_glossiness.diffuse_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].pbr_specular_glossiness.diffuse_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_specular_glossiness.diffuse_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].clearcoat.clearcoat_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].clearcoat.clearcoat_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].clearcoat.clearcoat_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].clearcoat.clearcoat_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].clearcoat.clearcoat_roughness_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].clearcoat.clearcoat_roughness_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].clearcoat.clearcoat_roughness_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].clearcoat.clearcoat_roughness_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].clearcoat.clearcoat_normal_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].clearcoat.clearcoat_normal_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].clearcoat.clearcoat_normal_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].clearcoat.clearcoat_normal_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].specular.specular_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].specular.specular_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].specular.specular_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].specular.specular_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].specular.specular_color_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].specular.specular_color_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].specular.specular_color_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].specular.specular_color_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].transmission.transmission_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].transmission.transmission_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].transmission.transmission_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].transmission.transmission_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].volume.thickness_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].volume.thickness_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].volume.thickness_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].volume.thickness_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].sheen.sheen_color_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].sheen.sheen_color_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].sheen.sheen_color_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].sheen.sheen_color_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].sheen.sheen_roughness_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].sheen.sheen_roughness_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].sheen.sheen_roughness_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].sheen.sheen_roughness_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].iridescence.iridescence_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].iridescence.iridescence_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].iridescence.iridescence_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].iridescence.iridescence_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].iridescence.iridescence_thickness_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].iridescence.iridescence_thickness_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].iridescence.iridescence_thickness_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].iridescence.iridescence_thickness_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.materials[i].anisotropy.anisotropy_texture.texture != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].anisotropy.anisotropy_texture.texture))) > data.*.textures_count) { - return -@as(c_int, 1); - } - data.*.materials[i].anisotropy.anisotropy_texture.texture = &data.*.textures[@as(cgltf_size, @intCast(@intFromPtr(data.*.materials[i].anisotropy.anisotropy_texture.texture))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.buffer_views_count) : (i +%= 1) { - if (!(data.*.buffer_views[i].buffer != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.buffer_views[i].buffer))) > data.*.buffers_count)) { - return -@as(c_int, 1); - } - data.*.buffer_views[i].buffer = &data.*.buffers[@as(cgltf_size, @intCast(@intFromPtr(data.*.buffer_views[i].buffer))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - if (data.*.buffer_views[i].has_meshopt_compression != 0) { - if (!(data.*.buffer_views[i].meshopt_compression.buffer != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.buffer_views[i].meshopt_compression.buffer))) > data.*.buffers_count)) { - return -@as(c_int, 1); - } - data.*.buffer_views[i].meshopt_compression.buffer = &data.*.buffers[@as(cgltf_size, @intCast(@intFromPtr(data.*.buffer_views[i].meshopt_compression.buffer))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.skins_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.skins[i].joints_count) : (j +%= 1) { - if (!(data.*.skins[i].joints[j] != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.skins[i].joints[j]))) > data.*.nodes_count)) { - return -@as(c_int, 1); - } - data.*.skins[i].joints[j] = &data.*.nodes[@as(cgltf_size, @intCast(@intFromPtr(data.*.skins[i].joints[j]))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - if (data.*.skins[i].skeleton != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.skins[i].skeleton))) > data.*.nodes_count) { - return -@as(c_int, 1); - } - data.*.skins[i].skeleton = &data.*.nodes[@as(cgltf_size, @intCast(@intFromPtr(data.*.skins[i].skeleton))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.skins[i].inverse_bind_matrices != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.skins[i].inverse_bind_matrices))) > data.*.accessors_count) { - return -@as(c_int, 1); - } - data.*.skins[i].inverse_bind_matrices = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.skins[i].inverse_bind_matrices))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.nodes_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.nodes[i].children_count) : (j +%= 1) { - if (!(data.*.nodes[i].children[j] != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].children[j]))) > data.*.nodes_count)) { - return -@as(c_int, 1); - } - data.*.nodes[i].children[j] = &data.*.nodes[@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].children[j]))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - if (data.*.nodes[i].children[j].*.parent != null) { - return -@as(c_int, 1); - } - data.*.nodes[i].children[j].*.parent = &data.*.nodes[i]; - } - } - if (data.*.nodes[i].mesh != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].mesh))) > data.*.meshes_count) { - return -@as(c_int, 1); - } - data.*.nodes[i].mesh = &data.*.meshes[@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].mesh))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.nodes[i].skin != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].skin))) > data.*.skins_count) { - return -@as(c_int, 1); - } - data.*.nodes[i].skin = &data.*.skins[@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].skin))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.nodes[i].camera != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].camera))) > data.*.cameras_count) { - return -@as(c_int, 1); - } - data.*.nodes[i].camera = &data.*.cameras[@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].camera))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.nodes[i].light != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].light))) > data.*.lights_count) { - return -@as(c_int, 1); - } - data.*.nodes[i].light = &data.*.lights[@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].light))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - if (data.*.nodes[i].has_mesh_gpu_instancing != 0) { - { - var m: cgltf_size = 0; - _ = &m; - while (m < data.*.nodes[i].mesh_gpu_instancing.attributes_count) : (m +%= 1) { - if (!(data.*.nodes[i].mesh_gpu_instancing.attributes[m].data != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].mesh_gpu_instancing.attributes[m].data))) > data.*.accessors_count)) { - return -@as(c_int, 1); - } - data.*.nodes[i].mesh_gpu_instancing.attributes[m].data = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.nodes[i].mesh_gpu_instancing.attributes[m].data))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - } - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.scenes_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.scenes[i].nodes_count) : (j +%= 1) { - if (!(data.*.scenes[i].nodes[j] != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.scenes[i].nodes[j]))) > data.*.nodes_count)) { - return -@as(c_int, 1); - } - data.*.scenes[i].nodes[j] = &data.*.nodes[@as(cgltf_size, @intCast(@intFromPtr(data.*.scenes[i].nodes[j]))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - if (data.*.scenes[i].nodes[j].*.parent != null) { - return -@as(c_int, 1); - } - } - } - } - } - if (data.*.scene != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.scene))) > data.*.scenes_count) { - return -@as(c_int, 1); - } - data.*.scene = &data.*.scenes[@as(cgltf_size, @intCast(@intFromPtr(data.*.scene))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - { - var i: cgltf_size = 0; - _ = &i; - while (i < data.*.animations_count) : (i +%= 1) { - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.animations[i].samplers_count) : (j +%= 1) { - if (!(data.*.animations[i].samplers[j].input != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].samplers[j].input))) > data.*.accessors_count)) { - return -@as(c_int, 1); - } - data.*.animations[i].samplers[j].input = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].samplers[j].input))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - if (!(data.*.animations[i].samplers[j].output != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].samplers[j].output))) > data.*.accessors_count)) { - return -@as(c_int, 1); - } - data.*.animations[i].samplers[j].output = &data.*.accessors[@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].samplers[j].output))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - { - var j: cgltf_size = 0; - _ = &j; - while (j < data.*.animations[i].channels_count) : (j +%= 1) { - if (!(data.*.animations[i].channels[j].sampler != null) or (@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].channels[j].sampler))) > data.*.animations[i].samplers_count)) { - return -@as(c_int, 1); - } - data.*.animations[i].channels[j].sampler = &data.*.animations[i].samplers[@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].channels[j].sampler))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - if (data.*.animations[i].channels[j].target_node != null) { - if (@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].channels[j].target_node))) > data.*.nodes_count) { - return -@as(c_int, 1); - } - data.*.animations[i].channels[j].target_node = &data.*.nodes[@as(cgltf_size, @intCast(@intFromPtr(data.*.animations[i].channels[j].target_node))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))]; - } - } - } - } - } - return 0; -} -pub fn cgltf_parse_json_root(arg_options: [*c]cgltf_options, arg_tokens: [*c]const jsmntok_t, arg_i: c_int, arg_json_chunk: [*c]const u8, arg_out_data: [*c]cgltf_data) callconv(.C) c_int { - var options = arg_options; - _ = &options; - var tokens = arg_tokens; - _ = &tokens; - var i = arg_i; - _ = &i; - var json_chunk = arg_json_chunk; - _ = &json_chunk; - var out_data = arg_out_data; - _ = &out_data; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &size; - i += 1; - { - var j: c_int = 0; - _ = &j; - while (j < size) : (j += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "asset") == @as(c_int, 0)) { - i = cgltf_parse_json_asset(options, tokens, i + @as(c_int, 1), json_chunk, &out_data.*.asset); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "meshes") == @as(c_int, 0)) { - i = cgltf_parse_json_meshes(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "accessors") == @as(c_int, 0)) { - i = cgltf_parse_json_accessors(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "bufferViews") == @as(c_int, 0)) { - i = cgltf_parse_json_buffer_views(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "buffers") == @as(c_int, 0)) { - i = cgltf_parse_json_buffers(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "materials") == @as(c_int, 0)) { - i = cgltf_parse_json_materials(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "images") == @as(c_int, 0)) { - i = cgltf_parse_json_images(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "textures") == @as(c_int, 0)) { - i = cgltf_parse_json_textures(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "samplers") == @as(c_int, 0)) { - i = cgltf_parse_json_samplers(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "skins") == @as(c_int, 0)) { - i = cgltf_parse_json_skins(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "cameras") == @as(c_int, 0)) { - i = cgltf_parse_json_cameras(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "nodes") == @as(c_int, 0)) { - i = cgltf_parse_json_nodes(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "scenes") == @as(c_int, 0)) { - i = cgltf_parse_json_scenes(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "scene") == @as(c_int, 0)) { - i += 1; - out_data.*.scene = @as([*c]cgltf_scene, @ptrFromInt(@as(cgltf_size, @bitCast(@as(c_long, cgltf_json_to_int(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk)))) +% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))))); - i += 1; - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "animations") == @as(c_int, 0)) { - i = cgltf_parse_json_animations(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extras") == @as(c_int, 0)) { - i = cgltf_parse_json_extras(options, tokens, i + @as(c_int, 1), json_chunk, &out_data.*.extras); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensions") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - if (out_data.*.data_extensions != null) { - return -@as(c_int, 1); - } - var extensions_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &extensions_size; - out_data.*.data_extensions_count = 0; - out_data.*.data_extensions = @as([*c]cgltf_extension, @ptrCast(@alignCast(cgltf_calloc(options, @sizeOf(cgltf_extension), @as(cgltf_size, @bitCast(@as(c_long, extensions_size))))))); - if (!(out_data.*.data_extensions != null)) { - return -@as(c_int, 2); - } - i += 1; - { - var k: c_int = 0; - _ = &k; - while (k < extensions_size) : (k += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_lights_punctual") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var data_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &data_size; - i += 1; - { - var m: c_int = 0; - _ = &m; - while (m < data_size) : (m += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "lights") == @as(c_int, 0)) { - i = cgltf_parse_json_lights(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "KHR_materials_variants") == @as(c_int, 0)) { - i += 1; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_OBJECT))) { - return -@as(c_int, 1); - } - var data_size: c_int = (blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size; - _ = &data_size; - i += 1; - { - var m: c_int = 0; - _ = &m; - while (m < data_size) : (m += 1) { - if (((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.type != @as(c_uint, @bitCast(JSMN_STRING))) or ((blk: { - const tmp = i; - if (tmp >= 0) break :blk tokens + @as(usize, @intCast(tmp)) else break :blk tokens - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.size == @as(c_int, 0))) { - return -@as(c_int, 1); - } - if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "variants") == @as(c_int, 0)) { - i = cgltf_parse_json_variants(options, tokens, i + @as(c_int, 1), json_chunk, out_data); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else { - i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &out_data.*.data_extensions[blk: { - const ref = &out_data.*.data_extensions_count; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensionsUsed") == @as(c_int, 0)) { - i = cgltf_parse_json_string_array(options, tokens, i + @as(c_int, 1), json_chunk, &out_data.*.extensions_used, &out_data.*.extensions_used_count); - } else if (cgltf_json_strcmp(tokens + @as(usize, @bitCast(@as(isize, @intCast(i)))), json_chunk, "extensionsRequired") == @as(c_int, 0)) { - i = cgltf_parse_json_string_array(options, tokens, i + @as(c_int, 1), json_chunk, &out_data.*.extensions_required, &out_data.*.extensions_required_count); - } else { - i = cgltf_skip_json(tokens, i + @as(c_int, 1)); - } - if (i < @as(c_int, 0)) { - return i; - } - } - } - return i; -} -pub fn jsmn_alloc_token(arg_parser: [*c]jsmn_parser, arg_tokens: [*c]jsmntok_t, arg_num_tokens: usize) callconv(.C) [*c]jsmntok_t { - var parser = arg_parser; - _ = &parser; - var tokens = arg_tokens; - _ = &tokens; - var num_tokens = arg_num_tokens; - _ = &num_tokens; - var tok: [*c]jsmntok_t = undefined; - _ = &tok; - if (@as(usize, @bitCast(@as(c_ulong, parser.*.toknext))) >= num_tokens) { - return null; - } - tok = &tokens[blk: { - const ref = &parser.*.toknext; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }]; - tok.*.start = blk: { - const tmp = @as(ptrdiff_t, @bitCast(@as(c_long, -@as(c_int, 1)))); - tok.*.end = tmp; - break :blk tmp; - }; - tok.*.size = 0; - tok.*.parent = -@as(c_int, 1); - return tok; -} -pub fn jsmn_fill_token(arg_token: [*c]jsmntok_t, arg_type: jsmntype_t, arg_start: ptrdiff_t, arg_end: ptrdiff_t) callconv(.C) void { - var token = arg_token; - _ = &token; - var @"type" = arg_type; - _ = &@"type"; - var start = arg_start; - _ = &start; - var end = arg_end; - _ = &end; - token.*.type = @"type"; - token.*.start = start; - token.*.end = end; - token.*.size = 0; -} -// ./external/cgltf.h:6746:4: warning: TODO implement translation of stmt class GotoStmtClass - -// ./external/cgltf.h:6731:12: warning: unable to translate function, demoted to extern -pub extern fn jsmn_parse_primitive(arg_parser: [*c]jsmn_parser, arg_js: [*c]const u8, arg_len: usize, arg_tokens: [*c]jsmntok_t, arg_num_tokens: usize) callconv(.C) c_int; -pub fn jsmn_parse_string(arg_parser: [*c]jsmn_parser, arg_js: [*c]const u8, arg_len: usize, arg_tokens: [*c]jsmntok_t, arg_num_tokens: usize) callconv(.C) c_int { - var parser = arg_parser; - _ = &parser; - var js = arg_js; - _ = &js; - var len = arg_len; - _ = &len; - var tokens = arg_tokens; - _ = &tokens; - var num_tokens = arg_num_tokens; - _ = &num_tokens; - var token: [*c]jsmntok_t = undefined; - _ = &token; - var start: ptrdiff_t = @as(ptrdiff_t, @bitCast(parser.*.pos)); - _ = &start; - parser.*.pos +%= 1; - while ((parser.*.pos < len) and (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) != @as(c_int, '\x00'))) : (parser.*.pos +%= 1) { - var c: u8 = js[parser.*.pos]; - _ = &c; - if (@as(c_int, @bitCast(@as(c_uint, c))) == @as(c_int, '"')) { - if (tokens == @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - return 0; - } - token = jsmn_alloc_token(parser, tokens, num_tokens); - if (token == @as([*c]jsmntok_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - parser.*.pos = @as(usize, @bitCast(start)); - return JSMN_ERROR_NOMEM; - } - jsmn_fill_token(token, @as(c_uint, @bitCast(JSMN_STRING)), start + @as(ptrdiff_t, @bitCast(@as(c_long, @as(c_int, 1)))), @as(ptrdiff_t, @bitCast(parser.*.pos))); - token.*.parent = parser.*.toksuper; - return 0; - } - if ((@as(c_int, @bitCast(@as(c_uint, c))) == @as(c_int, '\\')) and ((parser.*.pos +% @as(usize, @bitCast(@as(c_long, @as(c_int, 1))))) < len)) { - var i: c_int = undefined; - _ = &i; - parser.*.pos +%= 1; - while (true) { - switch (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos])))) { - @as(c_int, 34), @as(c_int, 47), @as(c_int, 92), @as(c_int, 98), @as(c_int, 102), @as(c_int, 114), @as(c_int, 110), @as(c_int, 116) => break, - @as(c_int, 117) => { - parser.*.pos +%= 1; - { - i = 0; - while (((i < @as(c_int, 4)) and (parser.*.pos < len)) and (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) != @as(c_int, '\x00'))) : (i += 1) { - if (!((((@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) >= @as(c_int, 48)) and (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) <= @as(c_int, 57))) or ((@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) >= @as(c_int, 65)) and (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) <= @as(c_int, 70)))) or ((@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) >= @as(c_int, 97)) and (@as(c_int, @bitCast(@as(c_uint, js[parser.*.pos]))) <= @as(c_int, 102))))) { - parser.*.pos = @as(usize, @bitCast(start)); - return JSMN_ERROR_INVAL; - } - parser.*.pos +%= 1; - } - } - parser.*.pos -%= 1; - break; - }, - else => { - parser.*.pos = @as(usize, @bitCast(start)); - return JSMN_ERROR_INVAL; - }, - } - break; - } - } - } - parser.*.pos = @as(usize, @bitCast(start)); - return JSMN_ERROR_PART; -} -pub const VoxColor = extern struct { - r: u8 = @import("std").mem.zeroes(u8), - g: u8 = @import("std").mem.zeroes(u8), - b: u8 = @import("std").mem.zeroes(u8), - a: u8 = @import("std").mem.zeroes(u8), -}; -pub const VoxVector3 = extern struct { - x: f32 = @import("std").mem.zeroes(f32), - y: f32 = @import("std").mem.zeroes(f32), - z: f32 = @import("std").mem.zeroes(f32), -}; -pub const ArrayVector3 = extern struct { - array: [*c]VoxVector3 = @import("std").mem.zeroes([*c]VoxVector3), - used: c_int = @import("std").mem.zeroes(c_int), - size: c_int = @import("std").mem.zeroes(c_int), -}; -pub const ArrayColor = extern struct { - array: [*c]VoxColor = @import("std").mem.zeroes([*c]VoxColor), - used: c_int = @import("std").mem.zeroes(c_int), - size: c_int = @import("std").mem.zeroes(c_int), -}; -pub const ArrayUShort = extern struct { - array: [*c]c_ushort = @import("std").mem.zeroes([*c]c_ushort), - used: c_int = @import("std").mem.zeroes(c_int), - size: c_int = @import("std").mem.zeroes(c_int), -}; -pub const CubeChunk3D = extern struct { - m_array: [*c]u8 = @import("std").mem.zeroes([*c]u8), - arraySize: c_int = @import("std").mem.zeroes(c_int), -}; -pub const VoxArray3D = extern struct { - sizeX: c_int = @import("std").mem.zeroes(c_int), - sizeY: c_int = @import("std").mem.zeroes(c_int), - sizeZ: c_int = @import("std").mem.zeroes(c_int), - chunksSizeX: c_int = @import("std").mem.zeroes(c_int), - chunksSizeY: c_int = @import("std").mem.zeroes(c_int), - chunksSizeZ: c_int = @import("std").mem.zeroes(c_int), - m_arrayChunks: [*c]CubeChunk3D = @import("std").mem.zeroes([*c]CubeChunk3D), - arrayChunksSize: c_int = @import("std").mem.zeroes(c_int), - ChunkFlattenOffset: c_int = @import("std").mem.zeroes(c_int), - chunksAllocated: c_int = @import("std").mem.zeroes(c_int), - chunksTotal: c_int = @import("std").mem.zeroes(c_int), - vertices: ArrayVector3 = @import("std").mem.zeroes(ArrayVector3), - normals: ArrayVector3 = @import("std").mem.zeroes(ArrayVector3), - indices: ArrayUShort = @import("std").mem.zeroes(ArrayUShort), - colors: ArrayColor = @import("std").mem.zeroes(ArrayColor), - palette: [256]VoxColor = @import("std").mem.zeroes([256]VoxColor), -}; -pub export fn Vox_LoadFromMemory(arg_pvoxData: [*c]u8, arg_voxDataSize: c_uint, arg_pvoxarray: [*c]VoxArray3D) c_int { - var pvoxData = arg_pvoxData; - _ = &pvoxData; - var voxDataSize = arg_voxDataSize; - _ = &voxDataSize; - var pvoxarray = arg_pvoxarray; - _ = &pvoxarray; - var fileData: [*c]u8 = pvoxData; - _ = &fileData; - var fileDataPtr: [*c]u8 = fileData; - _ = &fileDataPtr; - var endfileDataPtr: [*c]u8 = fileData + voxDataSize; - _ = &endfileDataPtr; - if (strncmp(@as([*c]u8, @ptrCast(@alignCast(fileDataPtr))), "VOX ", @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))) != @as(c_int, 0)) { - return -@as(c_int, 2); - } - fileDataPtr += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - var version: c_uint = 0; - _ = &version; - version = @as([*c]c_uint, @ptrCast(@alignCast(fileDataPtr)))[@as(c_uint, @intCast(@as(c_int, 0)))]; - fileDataPtr += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - if ((version != @as(c_uint, @bitCast(@as(c_int, 150)))) and (version != @as(c_uint, @bitCast(@as(c_int, 200))))) { - return -@as(c_int, 3); - } - var sizeX: c_uint = undefined; - _ = &sizeX; - var sizeY: c_uint = undefined; - _ = &sizeY; - var sizeZ: c_uint = undefined; - _ = &sizeZ; - sizeX = blk: { - const tmp = blk_1: { - const tmp_2 = @as(c_uint, @bitCast(@as(c_int, 0))); - sizeZ = tmp_2; - break :blk_1 tmp_2; - }; - sizeY = tmp; - break :blk tmp; - }; - var numVoxels: c_uint = 0; - _ = &numVoxels; - while (fileDataPtr < endfileDataPtr) { - var szChunkName: [5]u8 = undefined; - _ = &szChunkName; - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&szChunkName))))), @as(?*const anyopaque, @ptrCast(fileDataPtr)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - szChunkName[@as(c_uint, @intCast(@as(c_int, 4)))] = 0; - fileDataPtr += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - var chunkSize: c_uint = @as([*c]c_uint, @ptrCast(@alignCast(fileDataPtr))).*; - _ = &chunkSize; - fileDataPtr += @as([*c]u8, @ptrFromInt(@sizeOf(c_uint))); - fileDataPtr += @as([*c]u8, @ptrFromInt(@sizeOf(c_uint))); - if (strcmp(@as([*c]u8, @ptrCast(@alignCast(&szChunkName))), "SIZE") == @as(c_int, 0)) { - sizeX = @as([*c]c_uint, @ptrCast(@alignCast(fileDataPtr))).*; - fileDataPtr += @as([*c]u8, @ptrFromInt(@sizeOf(c_uint))); - sizeY = @as([*c]c_uint, @ptrCast(@alignCast(fileDataPtr))).*; - fileDataPtr += @as([*c]u8, @ptrFromInt(@sizeOf(c_uint))); - sizeZ = @as([*c]c_uint, @ptrCast(@alignCast(fileDataPtr))).*; - fileDataPtr += @as([*c]u8, @ptrFromInt(@sizeOf(c_uint))); - Vox_AllocArray(pvoxarray, @as(c_int, @bitCast(sizeX)), @as(c_int, @bitCast(sizeZ)), @as(c_int, @bitCast(sizeY))); - } else if (strcmp(@as([*c]u8, @ptrCast(@alignCast(&szChunkName))), "XYZI") == @as(c_int, 0)) { - var vx: u8 = undefined; - _ = &vx; - var vy: u8 = undefined; - _ = &vy; - var vz: u8 = undefined; - _ = &vz; - var vi: u8 = undefined; - _ = &vi; - numVoxels = @as([*c]c_uint, @ptrCast(@alignCast(fileDataPtr))).*; - fileDataPtr += @as([*c]u8, @ptrFromInt(@sizeOf(c_uint))); - while (numVoxels > @as(c_uint, @bitCast(@as(c_int, 0)))) { - vx = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - vy = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - vz = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - vi = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - Vox_SetVoxel(pvoxarray, @as(c_int, @bitCast(@as(c_uint, vx))), @as(c_int, @bitCast(@as(c_uint, vz))), (pvoxarray.*.sizeZ - @as(c_int, @bitCast(@as(c_uint, vy)))) - @as(c_int, 1), vi); - numVoxels -%= 1; - } - } else if (strcmp(@as([*c]u8, @ptrCast(@alignCast(&szChunkName))), "RGBA") == @as(c_int, 0)) { - var col: VoxColor = undefined; - _ = &col; - { - var i: c_int = 0; - _ = &i; - while (i < (@as(c_int, 256) - @as(c_int, 1))) : (i += 1) { - col.r = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - col.g = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - col.b = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - col.a = (blk: { - const ref = &fileDataPtr; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - pvoxarray.*.palette[@as(c_uint, @intCast(i + @as(c_int, 1)))] = col; - } - } - } else { - fileDataPtr += @as([*c]u8, @ptrFromInt(chunkSize)); - } - } - initArrayVector3(&pvoxarray.*.vertices, @as(c_int, 3) * @as(c_int, 1024)); - initArrayVector3(&pvoxarray.*.normals, @as(c_int, 3) * @as(c_int, 1024)); - initArrayUShort(&pvoxarray.*.indices, @as(c_int, 3) * @as(c_int, 1024)); - initArrayColor(&pvoxarray.*.colors, @as(c_int, 3) * @as(c_int, 1024)); - var x: c_int = undefined; - _ = &x; - var y: c_int = undefined; - _ = &y; - var z: c_int = undefined; - _ = &z; - { - x = 0; - while (x <= pvoxarray.*.sizeX) : (x += 1) { - { - z = 0; - while (z <= pvoxarray.*.sizeZ) : (z += 1) { - { - y = 0; - while (y <= pvoxarray.*.sizeY) : (y += 1) { - var matID: u8 = Vox_GetVoxel(pvoxarray, x, y, z); - _ = &matID; - if (@as(c_int, @bitCast(@as(c_uint, matID))) != @as(c_int, 0)) { - Vox_Build_Voxel(pvoxarray, x, y, z, @as(c_int, @bitCast(@as(c_uint, matID)))); - } - } - } - } - } - } - } - return @as(c_int, 0); -} -pub export fn Vox_FreeArrays(arg_voxarray: [*c]VoxArray3D) void { - var voxarray = arg_voxarray; - _ = &voxarray; - if (voxarray.*.m_arrayChunks != null) { - { - var i: c_int = 0; - _ = &i; - while (i < voxarray.*.chunksTotal) : (i += 1) { - var chunk: [*c]CubeChunk3D = &(blk: { - const tmp = i; - if (tmp >= 0) break :blk voxarray.*.m_arrayChunks + @as(usize, @intCast(tmp)) else break :blk voxarray.*.m_arrayChunks - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &chunk; - if (chunk.*.m_array != null) { - chunk.*.arraySize = 0; - free(@as(?*anyopaque, @ptrCast(chunk.*.m_array))); - } - } - } - free(@as(?*anyopaque, @ptrCast(voxarray.*.m_arrayChunks))); - voxarray.*.m_arrayChunks = null; - voxarray.*.arrayChunksSize = 0; - voxarray.*.chunksSizeX = blk: { - const tmp = blk_1: { - const tmp_2 = @as(c_int, 0); - voxarray.*.chunksSizeZ = tmp_2; - break :blk_1 tmp_2; - }; - voxarray.*.chunksSizeY = tmp; - break :blk tmp; - }; - voxarray.*.chunksTotal = 0; - voxarray.*.chunksAllocated = 0; - voxarray.*.ChunkFlattenOffset = 0; - voxarray.*.sizeX = blk: { - const tmp = blk_1: { - const tmp_2 = @as(c_int, 0); - voxarray.*.sizeZ = tmp_2; - break :blk_1 tmp_2; - }; - voxarray.*.sizeY = tmp; - break :blk tmp; - }; - } - freeArrayVector3(&voxarray.*.vertices); - freeArrayUShort(&voxarray.*.indices); - freeArrayColor(&voxarray.*.colors); -} -pub fn initArrayUShort(arg_a: [*c]ArrayUShort, arg_initialSize: c_int) callconv(.C) void { - var a = arg_a; - _ = &a; - var initialSize = arg_initialSize; - _ = &initialSize; - a.*.array = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, initialSize))) *% @sizeOf(c_ushort))))); - a.*.used = 0; - a.*.size = initialSize; -} -pub fn insertArrayUShort(arg_a: [*c]ArrayUShort, arg_element: c_ushort) callconv(.C) void { - var a = arg_a; - _ = &a; - var element = arg_element; - _ = &element; - if (a.*.used == a.*.size) { - a.*.size *= @as(c_int, 2); - a.*.array = @as([*c]c_ushort, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(a.*.array)), @as(c_ulong, @bitCast(@as(c_long, a.*.size))) *% @sizeOf(c_ushort))))); - } - (blk: { - const tmp = blk_1: { - const ref = &a.*.used; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk a.*.array + @as(usize, @intCast(tmp)) else break :blk a.*.array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = element; -} -pub fn freeArrayUShort(arg_a: [*c]ArrayUShort) callconv(.C) void { - var a = arg_a; - _ = &a; - free(@as(?*anyopaque, @ptrCast(a.*.array))); - a.*.array = null; - a.*.used = blk: { - const tmp = @as(c_int, 0); - a.*.size = tmp; - break :blk tmp; - }; -} -pub fn initArrayVector3(arg_a: [*c]ArrayVector3, arg_initialSize: c_int) callconv(.C) void { - var a = arg_a; - _ = &a; - var initialSize = arg_initialSize; - _ = &initialSize; - a.*.array = @as([*c]VoxVector3, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, initialSize))) *% @sizeOf(VoxVector3))))); - a.*.used = 0; - a.*.size = initialSize; -} -pub fn insertArrayVector3(arg_a: [*c]ArrayVector3, arg_element: VoxVector3) callconv(.C) void { - var a = arg_a; - _ = &a; - var element = arg_element; - _ = &element; - if (a.*.used == a.*.size) { - a.*.size *= @as(c_int, 2); - a.*.array = @as([*c]VoxVector3, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(a.*.array)), @as(c_ulong, @bitCast(@as(c_long, a.*.size))) *% @sizeOf(VoxVector3))))); - } - (blk: { - const tmp = blk_1: { - const ref = &a.*.used; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk a.*.array + @as(usize, @intCast(tmp)) else break :blk a.*.array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = element; -} -pub fn freeArrayVector3(arg_a: [*c]ArrayVector3) callconv(.C) void { - var a = arg_a; - _ = &a; - free(@as(?*anyopaque, @ptrCast(a.*.array))); - a.*.array = null; - a.*.used = blk: { - const tmp = @as(c_int, 0); - a.*.size = tmp; - break :blk tmp; - }; -} -pub fn initArrayColor(arg_a: [*c]ArrayColor, arg_initialSize: c_int) callconv(.C) void { - var a = arg_a; - _ = &a; - var initialSize = arg_initialSize; - _ = &initialSize; - a.*.array = @as([*c]VoxColor, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, initialSize))) *% @sizeOf(VoxColor))))); - a.*.used = 0; - a.*.size = initialSize; -} -pub fn insertArrayColor(arg_a: [*c]ArrayColor, arg_element: VoxColor) callconv(.C) void { - var a = arg_a; - _ = &a; - var element = arg_element; - _ = &element; - if (a.*.used == a.*.size) { - a.*.size *= @as(c_int, 2); - a.*.array = @as([*c]VoxColor, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(a.*.array)), @as(c_ulong, @bitCast(@as(c_long, a.*.size))) *% @sizeOf(VoxColor))))); - } - (blk: { - const tmp = blk_1: { - const ref = &a.*.used; - const tmp_2 = ref.*; - ref.* += 1; - break :blk_1 tmp_2; - }; - if (tmp >= 0) break :blk a.*.array + @as(usize, @intCast(tmp)) else break :blk a.*.array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = element; -} -pub fn freeArrayColor(arg_a: [*c]ArrayColor) callconv(.C) void { - var a = arg_a; - _ = &a; - free(@as(?*anyopaque, @ptrCast(a.*.array))); - a.*.array = null; - a.*.used = blk: { - const tmp = @as(c_int, 0); - a.*.size = tmp; - break :blk tmp; - }; -} -pub export const fv: [6][4]c_int = [6][4]c_int{ - [4]c_int{ - 0, - 2, - 6, - 4, - }, - [4]c_int{ - 5, - 7, - 3, - 1, - }, - [4]c_int{ - 0, - 4, - 5, - 1, - }, - [4]c_int{ - 6, - 2, - 3, - 7, - }, - [4]c_int{ - 1, - 3, - 2, - 0, - }, - [4]c_int{ - 4, - 6, - 7, - 5, - }, -}; -pub export const SolidVertex: [8]VoxVector3 = [8]VoxVector3{ - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 1))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 1))), - .y = @as(f32, @floatFromInt(@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 1))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 1))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 1))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 1))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 1))), - .y = @as(f32, @floatFromInt(@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 1))), - }, -}; -pub export const FacesPerSideNormal: [6]VoxVector3 = [6]VoxVector3{ - VoxVector3{ - .x = @as(f32, @floatFromInt(-@as(c_int, 1))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 1))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(-@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 1))), - .z = @as(f32, @floatFromInt(@as(c_int, 0))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(-@as(c_int, 1))), - }, - VoxVector3{ - .x = @as(f32, @floatFromInt(@as(c_int, 0))), - .y = @as(f32, @floatFromInt(@as(c_int, 0))), - .z = @as(f32, @floatFromInt(@as(c_int, 1))), - }, -}; -pub fn Vox_AllocArray(arg_pvoxarray: [*c]VoxArray3D, arg__sx: c_int, arg__sy: c_int, arg__sz: c_int) callconv(.C) void { - var pvoxarray = arg_pvoxarray; - _ = &pvoxarray; - var _sx = arg__sx; - _ = &_sx; - var _sy = arg__sy; - _ = &_sy; - var _sz = arg__sz; - _ = &_sz; - var sx: c_int = _sx + @import("std").zig.c_translation.signedRemainder(@as(c_int, 16) - @import("std").zig.c_translation.signedRemainder(_sx, @as(c_int, 16)), @as(c_int, 16)); - _ = &sx; - var sy: c_int = _sy + @import("std").zig.c_translation.signedRemainder(@as(c_int, 16) - @import("std").zig.c_translation.signedRemainder(_sy, @as(c_int, 16)), @as(c_int, 16)); - _ = &sy; - var sz: c_int = _sz + @import("std").zig.c_translation.signedRemainder(@as(c_int, 16) - @import("std").zig.c_translation.signedRemainder(_sz, @as(c_int, 16)), @as(c_int, 16)); - _ = &sz; - var chx: c_int = sx >> @intCast(4); - _ = &chx; - var chy: c_int = sy >> @intCast(4); - _ = &chy; - var chz: c_int = sz >> @intCast(4); - _ = &chz; - pvoxarray.*.sizeX = sx; - pvoxarray.*.sizeY = sy; - pvoxarray.*.sizeZ = sz; - pvoxarray.*.chunksSizeX = chx; - pvoxarray.*.chunksSizeY = chy; - pvoxarray.*.chunksSizeZ = chz; - pvoxarray.*.ChunkFlattenOffset = chy * chz; - var size: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate(((@sizeOf(CubeChunk3D) *% @as(c_ulong, @bitCast(@as(c_long, chx)))) *% @as(c_ulong, @bitCast(@as(c_long, chy)))) *% @as(c_ulong, @bitCast(@as(c_long, chz))))))); - _ = &size; - pvoxarray.*.m_arrayChunks = @as([*c]CubeChunk3D, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, size))))))); - pvoxarray.*.arrayChunksSize = size; - size = (chx * chy) * chz; - pvoxarray.*.chunksTotal = size; - pvoxarray.*.chunksAllocated = 0; - { - var i: c_int = 0; - _ = &i; - while (i < size) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk pvoxarray.*.m_arrayChunks + @as(usize, @intCast(tmp)) else break :blk pvoxarray.*.m_arrayChunks - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.m_array = null; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk pvoxarray.*.m_arrayChunks + @as(usize, @intCast(tmp)) else break :blk pvoxarray.*.m_arrayChunks - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.arraySize = 0; - } - } -} -pub fn Vox_SetVoxel(arg_pvoxarray: [*c]VoxArray3D, arg_x: c_int, arg_y: c_int, arg_z: c_int, arg_id: u8) callconv(.C) void { - var pvoxarray = arg_pvoxarray; - _ = &pvoxarray; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var id = arg_id; - _ = &id; - var chX: c_int = x >> @intCast(4); - _ = &chX; - var chY: c_int = y >> @intCast(4); - _ = &chY; - var chZ: c_int = z >> @intCast(4); - _ = &chZ; - var offset: c_int = ((chX * pvoxarray.*.ChunkFlattenOffset) + (chZ * pvoxarray.*.chunksSizeY)) + chY; - _ = &offset; - var chunk: [*c]CubeChunk3D = &(blk: { - const tmp = offset; - if (tmp >= 0) break :blk pvoxarray.*.m_arrayChunks + @as(usize, @intCast(tmp)) else break :blk pvoxarray.*.m_arrayChunks - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &chunk; - chX = x - (chX << @intCast(4)); - chY = y - (chY << @intCast(4)); - chZ = z - (chZ << @intCast(4)); - if (chunk.*.m_array == null) { - var size: c_int = (@as(c_int, 16) * @as(c_int, 16)) * @as(c_int, 16); - _ = &size; - chunk.*.m_array = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, size))))))); - chunk.*.arraySize = size; - _ = memset(@as(?*anyopaque, @ptrCast(chunk.*.m_array)), @as(c_int, 0), @as(c_ulong, @bitCast(@as(c_long, size)))); - pvoxarray.*.chunksAllocated += 1; - } - offset = ((chX << @intCast(8)) + (chZ << @intCast(4))) + chY; - (blk: { - const tmp = offset; - if (tmp >= 0) break :blk chunk.*.m_array + @as(usize, @intCast(tmp)) else break :blk chunk.*.m_array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = id; -} -pub fn Vox_GetVoxel(arg_pvoxarray: [*c]VoxArray3D, arg_x: c_int, arg_y: c_int, arg_z: c_int) callconv(.C) u8 { - var pvoxarray = arg_pvoxarray; - _ = &pvoxarray; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - if (((x < @as(c_int, 0)) or (y < @as(c_int, 0))) or (z < @as(c_int, 0))) return 0; - if (((x >= pvoxarray.*.sizeX) or (y >= pvoxarray.*.sizeY)) or (z >= pvoxarray.*.sizeZ)) return 0; - var chX: c_int = x >> @intCast(4); - _ = &chX; - var chY: c_int = y >> @intCast(4); - _ = &chY; - var chZ: c_int = z >> @intCast(4); - _ = &chZ; - var offset: c_int = ((chX * pvoxarray.*.ChunkFlattenOffset) + (chZ * pvoxarray.*.chunksSizeY)) + chY; - _ = &offset; - var chunk: [*c]CubeChunk3D = &(blk: { - const tmp = offset; - if (tmp >= 0) break :blk pvoxarray.*.m_arrayChunks + @as(usize, @intCast(tmp)) else break :blk pvoxarray.*.m_arrayChunks - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &chunk; - chX = x - (chX << @intCast(4)); - chY = y - (chY << @intCast(4)); - chZ = z - (chZ << @intCast(4)); - if (chunk.*.m_array == null) { - return 0; - } - offset = ((chX << @intCast(8)) + (chZ << @intCast(4))) + chY; - return (blk: { - const tmp = offset; - if (tmp >= 0) break :blk chunk.*.m_array + @as(usize, @intCast(tmp)) else break :blk chunk.*.m_array - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; -} -pub fn Vox_CalcFacesVisible(arg_pvoxArray: [*c]VoxArray3D, arg_cx: c_int, arg_cy: c_int, arg_cz: c_int) callconv(.C) u8 { - var pvoxArray = arg_pvoxArray; - _ = &pvoxArray; - var cx = arg_cx; - _ = &cx; - var cy = arg_cy; - _ = &cy; - var cz = arg_cz; - _ = &cz; - var idXm1: u8 = Vox_GetVoxel(pvoxArray, cx - @as(c_int, 1), cy, cz); - _ = &idXm1; - var idXp1: u8 = Vox_GetVoxel(pvoxArray, cx + @as(c_int, 1), cy, cz); - _ = &idXp1; - var idYm1: u8 = Vox_GetVoxel(pvoxArray, cx, cy - @as(c_int, 1), cz); - _ = &idYm1; - var idYp1: u8 = Vox_GetVoxel(pvoxArray, cx, cy + @as(c_int, 1), cz); - _ = &idYp1; - var idZm1: u8 = Vox_GetVoxel(pvoxArray, cx, cy, cz - @as(c_int, 1)); - _ = &idZm1; - var idZp1: u8 = Vox_GetVoxel(pvoxArray, cx, cy, cz + @as(c_int, 1)); - _ = &idZp1; - var byVFMask: u8 = 0; - _ = &byVFMask; - if (@as(c_int, @bitCast(@as(c_uint, idXm1))) == @as(c_int, 0)) { - byVFMask |= @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1) << @intCast(0))))); - } - if (@as(c_int, @bitCast(@as(c_uint, idXp1))) == @as(c_int, 0)) { - byVFMask |= @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1) << @intCast(1))))); - } - if (@as(c_int, @bitCast(@as(c_uint, idYm1))) == @as(c_int, 0)) { - byVFMask |= @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1) << @intCast(2))))); - } - if (@as(c_int, @bitCast(@as(c_uint, idYp1))) == @as(c_int, 0)) { - byVFMask |= @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1) << @intCast(3))))); - } - if (@as(c_int, @bitCast(@as(c_uint, idZm1))) == @as(c_int, 0)) { - byVFMask |= @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1) << @intCast(4))))); - } - if (@as(c_int, @bitCast(@as(c_uint, idZp1))) == @as(c_int, 0)) { - byVFMask |= @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1) << @intCast(5))))); - } - return byVFMask; -} -pub fn Vox_GetVertexPosition(arg__wcx: c_int, arg__wcy: c_int, arg__wcz: c_int, arg__nNumVertex: c_int) callconv(.C) VoxVector3 { - var _wcx = arg__wcx; - _ = &_wcx; - var _wcy = arg__wcy; - _ = &_wcy; - var _wcz = arg__wcz; - _ = &_wcz; - var _nNumVertex = arg__nNumVertex; - _ = &_nNumVertex; - var scale: f32 = @as(f32, @floatCast(0.25)); - _ = &scale; - var vtx: VoxVector3 = SolidVertex[@as(c_uint, @intCast(_nNumVertex))]; - _ = &vtx; - vtx.x = (vtx.x + @as(f32, @floatFromInt(_wcx))) * scale; - vtx.y = (vtx.y + @as(f32, @floatFromInt(_wcy))) * scale; - vtx.z = (vtx.z + @as(f32, @floatFromInt(_wcz))) * scale; - return vtx; -} -pub fn Vox_Build_Voxel(arg_pvoxArray: [*c]VoxArray3D, arg_x: c_int, arg_y: c_int, arg_z: c_int, arg_matID: c_int) callconv(.C) void { - var pvoxArray = arg_pvoxArray; - _ = &pvoxArray; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var matID = arg_matID; - _ = &matID; - var byVFMask: u8 = Vox_CalcFacesVisible(pvoxArray, x, y, z); - _ = &byVFMask; - if (@as(c_int, @bitCast(@as(c_uint, byVFMask))) == @as(c_int, 0)) return; - var i: c_int = undefined; - _ = &i; - var j: c_int = undefined; - _ = &j; - var vertComputed: [8]VoxVector3 = undefined; - _ = &vertComputed; - var bVertexComputed: [8]c_int = undefined; - _ = &bVertexComputed; - _ = memset(@as(?*anyopaque, @ptrCast(@as([*c]VoxVector3, @ptrCast(@alignCast(&vertComputed))))), @as(c_int, 0), @sizeOf([8]VoxVector3)); - _ = memset(@as(?*anyopaque, @ptrCast(@as([*c]c_int, @ptrCast(@alignCast(&bVertexComputed))))), @as(c_int, 0), @sizeOf([8]c_int)); - { - i = 0; - while (i < @as(c_int, 6)) : (i += 1) { - if ((@as(c_int, @bitCast(@as(c_uint, byVFMask))) & (@as(c_int, 1) << @intCast(i))) != @as(c_int, 0)) { - { - j = 0; - while (j < @as(c_int, 4)) : (j += 1) { - var nNumVertex: c_int = fv[@as(c_uint, @intCast(i))][@as(c_uint, @intCast(j))]; - _ = &nNumVertex; - if (bVertexComputed[@as(c_uint, @intCast(nNumVertex))] == @as(c_int, 0)) { - bVertexComputed[@as(c_uint, @intCast(nNumVertex))] = 1; - vertComputed[@as(c_uint, @intCast(nNumVertex))] = Vox_GetVertexPosition(x, y, z, nNumVertex); - } - } - } - } - } - } - { - i = 0; - while (i < @as(c_int, 6)) : (i += 1) { - if ((@as(c_int, @bitCast(@as(c_uint, byVFMask))) & (@as(c_int, 1) << @intCast(i))) == @as(c_int, 0)) continue; - var v0: c_int = fv[@as(c_uint, @intCast(i))][@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &v0; - var v1: c_int = fv[@as(c_uint, @intCast(i))][@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &v1; - var v2: c_int = fv[@as(c_uint, @intCast(i))][@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &v2; - var v3: c_int = fv[@as(c_uint, @intCast(i))][@as(c_uint, @intCast(@as(c_int, 3)))]; - _ = &v3; - var idx: c_int = pvoxArray.*.vertices.used; - _ = &idx; - insertArrayVector3(&pvoxArray.*.vertices, vertComputed[@as(c_uint, @intCast(v0))]); - insertArrayVector3(&pvoxArray.*.vertices, vertComputed[@as(c_uint, @intCast(v1))]); - insertArrayVector3(&pvoxArray.*.vertices, vertComputed[@as(c_uint, @intCast(v2))]); - insertArrayVector3(&pvoxArray.*.vertices, vertComputed[@as(c_uint, @intCast(v3))]); - insertArrayVector3(&pvoxArray.*.normals, FacesPerSideNormal[@as(c_uint, @intCast(i))]); - insertArrayVector3(&pvoxArray.*.normals, FacesPerSideNormal[@as(c_uint, @intCast(i))]); - insertArrayVector3(&pvoxArray.*.normals, FacesPerSideNormal[@as(c_uint, @intCast(i))]); - insertArrayVector3(&pvoxArray.*.normals, FacesPerSideNormal[@as(c_uint, @intCast(i))]); - var col: VoxColor = pvoxArray.*.palette[@as(c_uint, @intCast(matID))]; - _ = &col; - insertArrayColor(&pvoxArray.*.colors, col); - insertArrayColor(&pvoxArray.*.colors, col); - insertArrayColor(&pvoxArray.*.colors, col); - insertArrayColor(&pvoxArray.*.colors, col); - insertArrayUShort(&pvoxArray.*.indices, @as(c_ushort, @bitCast(@as(c_short, @truncate(idx + @as(c_int, 0)))))); - insertArrayUShort(&pvoxArray.*.indices, @as(c_ushort, @bitCast(@as(c_short, @truncate(idx + @as(c_int, 2)))))); - insertArrayUShort(&pvoxArray.*.indices, @as(c_ushort, @bitCast(@as(c_short, @truncate(idx + @as(c_int, 1)))))); - insertArrayUShort(&pvoxArray.*.indices, @as(c_ushort, @bitCast(@as(c_short, @truncate(idx + @as(c_int, 0)))))); - insertArrayUShort(&pvoxArray.*.indices, @as(c_ushort, @bitCast(@as(c_short, @truncate(idx + @as(c_int, 3)))))); - insertArrayUShort(&pvoxArray.*.indices, @as(c_ushort, @bitCast(@as(c_short, @truncate(idx + @as(c_int, 2)))))); - } - } -} -pub const M3D_FLOAT = f32; -pub const M3D_INDEX = u32; -pub const M3D_VOXEL = u16; -pub const m3dhdr_t = extern struct { - magic: [4]u8 align(1) = @import("std").mem.zeroes([4]u8), - length: u32 align(1) = @import("std").mem.zeroes(u32), - scale: f32 align(1) = @import("std").mem.zeroes(f32), - types: u32 align(1) = @import("std").mem.zeroes(u32), -}; -pub const m3dchunk_t = extern struct { - magic: [4]u8 align(1) = @import("std").mem.zeroes([4]u8), - length: u32 align(1) = @import("std").mem.zeroes(u32), -}; -pub const m3dti_t = extern struct { - u: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), - v: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), -}; -pub const m3dtx_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - d: [*c]u8 = @import("std").mem.zeroes([*c]u8), - w: u16 = @import("std").mem.zeroes(u16), - h: u16 = @import("std").mem.zeroes(u16), - f: u8 = @import("std").mem.zeroes(u8), -}; -pub const m3dw_t = extern struct { - vertexid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - weight: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), -}; -pub const m3db_t = extern struct { - parent: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - pos: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - ori: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - numweight: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - weight: [*c]m3dw_t = @import("std").mem.zeroes([*c]m3dw_t), - mat4: [16]M3D_FLOAT = @import("std").mem.zeroes([16]M3D_FLOAT), -}; -pub const m3ds_t = extern struct { - boneid: [4]M3D_INDEX = @import("std").mem.zeroes([4]M3D_INDEX), - weight: [4]M3D_FLOAT = @import("std").mem.zeroes([4]M3D_FLOAT), -}; -pub const m3dv_t = extern struct { - x: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), - y: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), - z: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), - w: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), - color: u32 = @import("std").mem.zeroes(u32), - skinid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), -}; -pub const m3dpf_color: c_int = 0; -pub const m3dpf_uint8: c_int = 1; -pub const m3dpf_uint16: c_int = 2; -pub const m3dpf_uint32: c_int = 3; -pub const m3dpf_float: c_int = 4; -pub const m3dpf_map: c_int = 5; -const enum_unnamed_7 = c_uint; -pub const m3dpd_t = extern struct { - format: u8 = @import("std").mem.zeroes(u8), - id: u8 = @import("std").mem.zeroes(u8), -}; -pub const m3dp_Kd: c_int = 0; -pub const m3dp_Ka: c_int = 1; -pub const m3dp_Ks: c_int = 2; -pub const m3dp_Ns: c_int = 3; -pub const m3dp_Ke: c_int = 4; -pub const m3dp_Tf: c_int = 5; -pub const m3dp_Km: c_int = 6; -pub const m3dp_d: c_int = 7; -pub const m3dp_il: c_int = 8; -pub const m3dp_Pr: c_int = 64; -pub const m3dp_Pm: c_int = 65; -pub const m3dp_Ps: c_int = 66; -pub const m3dp_Ni: c_int = 67; -pub const m3dp_Nt: c_int = 68; -pub const m3dp_map_Kd: c_int = 128; -pub const m3dp_map_Ka: c_int = 129; -pub const m3dp_map_Ks: c_int = 130; -pub const m3dp_map_Ns: c_int = 131; -pub const m3dp_map_Ke: c_int = 132; -pub const m3dp_map_Tf: c_int = 133; -pub const m3dp_map_Km: c_int = 134; -pub const m3dp_map_D: c_int = 135; -pub const m3dp_map_N: c_int = 136; -pub const m3dp_map_Pr: c_int = 192; -pub const m3dp_map_Pm: c_int = 193; -pub const m3dp_map_Ps: c_int = 194; -pub const m3dp_map_Ni: c_int = 195; -pub const m3dp_map_Nt: c_int = 196; -const enum_unnamed_8 = c_uint; -pub const m3dp_bump: c_int = 134; -pub const m3dp_map_il: c_int = 136; -pub const m3dp_refl: c_int = 193; -const enum_unnamed_9 = c_uint; -const union_unnamed_10 = extern union { - color: u32, - num: u32, - fnum: f32, - textureid: M3D_INDEX, -}; -pub const m3dp_t = extern struct { - type: u8 = @import("std").mem.zeroes(u8), - value: union_unnamed_10 = @import("std").mem.zeroes(union_unnamed_10), -}; -pub const m3dm_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - numprop: u8 = @import("std").mem.zeroes(u8), - prop: [*c]m3dp_t = @import("std").mem.zeroes([*c]m3dp_t), -}; -pub const m3df_t = extern struct { - materialid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - vertex: [3]M3D_INDEX = @import("std").mem.zeroes([3]M3D_INDEX), - normal: [3]M3D_INDEX = @import("std").mem.zeroes([3]M3D_INDEX), - texcoord: [3]M3D_INDEX = @import("std").mem.zeroes([3]M3D_INDEX), -}; -pub const m3dvi_t = extern struct { - count: u16 = @import("std").mem.zeroes(u16), - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), -}; -pub const m3dvt_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - rotation: u8 = @import("std").mem.zeroes(u8), - voxshape: u16 = @import("std").mem.zeroes(u16), - materialid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - color: u32 = @import("std").mem.zeroes(u32), - skinid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - numitem: u8 = @import("std").mem.zeroes(u8), - item: [*c]m3dvi_t = @import("std").mem.zeroes([*c]m3dvi_t), -}; -pub const m3dvx_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - x: i32 = @import("std").mem.zeroes(i32), - y: i32 = @import("std").mem.zeroes(i32), - z: i32 = @import("std").mem.zeroes(i32), - w: u32 = @import("std").mem.zeroes(u32), - h: u32 = @import("std").mem.zeroes(u32), - d: u32 = @import("std").mem.zeroes(u32), - uncertain: u8 = @import("std").mem.zeroes(u8), - groupid: u8 = @import("std").mem.zeroes(u8), - data: [*c]M3D_VOXEL = @import("std").mem.zeroes([*c]M3D_VOXEL), -}; -pub const m3dc_use: c_int = 0; -pub const m3dc_inc: c_int = 1; -pub const m3dc_mesh: c_int = 2; -pub const m3dc_div: c_int = 3; -pub const m3dc_sub: c_int = 4; -pub const m3dc_len: c_int = 5; -pub const m3dc_dist: c_int = 6; -pub const m3dc_degu: c_int = 7; -pub const m3dc_deg: c_int = 8; -pub const m3dc_rangeu: c_int = 9; -pub const m3dc_range: c_int = 10; -pub const m3dc_paru: c_int = 11; -pub const m3dc_parv: c_int = 12; -pub const m3dc_trim: c_int = 13; -pub const m3dc_hole: c_int = 14; -pub const m3dc_scrv: c_int = 15; -pub const m3dc_sp: c_int = 16; -pub const m3dc_bez1: c_int = 17; -pub const m3dc_bsp1: c_int = 18; -pub const m3dc_bez2: c_int = 19; -pub const m3dc_bsp2: c_int = 20; -pub const m3dc_bezun: c_int = 21; -pub const m3dc_bezu: c_int = 22; -pub const m3dc_bezn: c_int = 23; -pub const m3dc_bez: c_int = 24; -pub const m3dc_nurbsun: c_int = 25; -pub const m3dc_nurbsu: c_int = 26; -pub const m3dc_nurbsn: c_int = 27; -pub const m3dc_nurbs: c_int = 28; -pub const m3dc_conn: c_int = 29; -pub const m3dc_line: c_int = 30; -pub const m3dc_polygon: c_int = 31; -pub const m3dc_circle: c_int = 32; -pub const m3dc_cylinder: c_int = 33; -pub const m3dc_shpere: c_int = 34; -pub const m3dc_torus: c_int = 35; -pub const m3dc_cone: c_int = 36; -pub const m3dc_cube: c_int = 37; -const enum_unnamed_11 = c_uint; -pub const m3dcp_mi_t: c_int = 1; -pub const m3dcp_hi_t: c_int = 2; -pub const m3dcp_fi_t: c_int = 3; -pub const m3dcp_ti_t: c_int = 4; -pub const m3dcp_vi_t: c_int = 5; -pub const m3dcp_qi_t: c_int = 6; -pub const m3dcp_vc_t: c_int = 7; -pub const m3dcp_i1_t: c_int = 8; -pub const m3dcp_i2_t: c_int = 9; -pub const m3dcp_i4_t: c_int = 10; -pub const m3dcp_va_t: c_int = 11; -const enum_unnamed_12 = c_uint; -pub const m3dcd_t = extern struct { - p: u8 = @import("std").mem.zeroes(u8), - a: [8]u8 = @import("std").mem.zeroes([8]u8), -}; -pub const m3dc_t = extern struct { - type: u16 = @import("std").mem.zeroes(u16), - arg: [*c]u32 = @import("std").mem.zeroes([*c]u32), -}; -pub const m3dh_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - group: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - numcmd: u32 = @import("std").mem.zeroes(u32), - cmd: [*c]m3dc_t = @import("std").mem.zeroes([*c]m3dc_t), -}; -pub const m3dl_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - lang: [*c]u8 = @import("std").mem.zeroes([*c]u8), - text: [*c]u8 = @import("std").mem.zeroes([*c]u8), - color: u32 = @import("std").mem.zeroes(u32), - vertexid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), -}; -pub const m3dtr_t = extern struct { - boneid: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - pos: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - ori: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), -}; -pub const m3dfr_t = extern struct { - msec: u32 = @import("std").mem.zeroes(u32), - numtransform: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - transform: [*c]m3dtr_t = @import("std").mem.zeroes([*c]m3dtr_t), -}; -pub const m3da_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - durationmsec: u32 = @import("std").mem.zeroes(u32), - numframe: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - frame: [*c]m3dfr_t = @import("std").mem.zeroes([*c]m3dfr_t), -}; -pub const m3di_t = extern struct { - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - data: [*c]u8 = @import("std").mem.zeroes([*c]u8), - length: u32 = @import("std").mem.zeroes(u32), -}; -pub const m3d_t = extern struct { - raw: [*c]m3dhdr_t = @import("std").mem.zeroes([*c]m3dhdr_t), - flags: u8 = @import("std").mem.zeroes(u8), - errcode: i8 = @import("std").mem.zeroes(i8), - vc_s: u8 = @import("std").mem.zeroes(u8), - vi_s: u8 = @import("std").mem.zeroes(u8), - si_s: u8 = @import("std").mem.zeroes(u8), - ci_s: u8 = @import("std").mem.zeroes(u8), - ti_s: u8 = @import("std").mem.zeroes(u8), - bi_s: u8 = @import("std").mem.zeroes(u8), - nb_s: u8 = @import("std").mem.zeroes(u8), - sk_s: u8 = @import("std").mem.zeroes(u8), - fc_s: u8 = @import("std").mem.zeroes(u8), - hi_s: u8 = @import("std").mem.zeroes(u8), - fi_s: u8 = @import("std").mem.zeroes(u8), - vd_s: u8 = @import("std").mem.zeroes(u8), - vp_s: u8 = @import("std").mem.zeroes(u8), - name: [*c]u8 = @import("std").mem.zeroes([*c]u8), - license: [*c]u8 = @import("std").mem.zeroes([*c]u8), - author: [*c]u8 = @import("std").mem.zeroes([*c]u8), - desc: [*c]u8 = @import("std").mem.zeroes([*c]u8), - scale: M3D_FLOAT = @import("std").mem.zeroes(M3D_FLOAT), - numcmap: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - cmap: [*c]u32 = @import("std").mem.zeroes([*c]u32), - numtmap: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - tmap: [*c]m3dti_t = @import("std").mem.zeroes([*c]m3dti_t), - numtexture: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - texture: [*c]m3dtx_t = @import("std").mem.zeroes([*c]m3dtx_t), - numbone: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - bone: [*c]m3db_t = @import("std").mem.zeroes([*c]m3db_t), - numvertex: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - vertex: [*c]m3dv_t = @import("std").mem.zeroes([*c]m3dv_t), - numskin: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - skin: [*c]m3ds_t = @import("std").mem.zeroes([*c]m3ds_t), - nummaterial: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - material: [*c]m3dm_t = @import("std").mem.zeroes([*c]m3dm_t), - numface: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - face: [*c]m3df_t = @import("std").mem.zeroes([*c]m3df_t), - numvoxtype: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - voxtype: [*c]m3dvt_t = @import("std").mem.zeroes([*c]m3dvt_t), - numvoxel: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - voxel: [*c]m3dvx_t = @import("std").mem.zeroes([*c]m3dvx_t), - numshape: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - shape: [*c]m3dh_t = @import("std").mem.zeroes([*c]m3dh_t), - numlabel: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - label: [*c]m3dl_t = @import("std").mem.zeroes([*c]m3dl_t), - numaction: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - action: [*c]m3da_t = @import("std").mem.zeroes([*c]m3da_t), - numinlined: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - inlined: [*c]m3di_t = @import("std").mem.zeroes([*c]m3di_t), - numextra: M3D_INDEX = @import("std").mem.zeroes(M3D_INDEX), - extra: [*c][*c]m3dchunk_t = @import("std").mem.zeroes([*c][*c]m3dchunk_t), - preview: m3di_t = @import("std").mem.zeroes(m3di_t), -}; -pub const m3dread_t = ?*const fn ([*c]u8, [*c]c_uint) callconv(.C) [*c]u8; -pub const m3dfree_t = ?*const fn (?*anyopaque) callconv(.C) void; -pub const m3dtxsc_t = ?*const fn ([*c]const u8, ?*const anyopaque, u32, [*c]m3dtx_t) callconv(.C) c_int; -pub const m3dprsc_t = ?*const fn ([*c]const u8, ?*const anyopaque, u32, [*c]m3d_t) callconv(.C) c_int; -// ./external/m3d.h:3306:1: warning: TODO implement translation of stmt class LabelStmtClass - -// ./external/m3d.h:2382:8: warning: unable to translate function, demoted to extern -pub extern fn m3d_load(arg_data: [*c]u8, arg_readfilecb: m3dread_t, arg_freecb: m3dfree_t, arg_mtllib: [*c]m3d_t) [*c]m3d_t; -pub extern fn m3d_save(model: [*c]m3d_t, quality: c_int, flags: c_int, size: [*c]c_uint) [*c]u8; -pub export fn m3d_free(arg_model: [*c]m3d_t) void { - var model = arg_model; - _ = &model; - var i: c_uint = undefined; - _ = &i; - var j: c_uint = undefined; - _ = &j; - if (!(model != null)) return; - if ((@as(c_int, @bitCast(@as(c_uint, model.*.flags))) & (@as(c_int, 1) << @intCast(0))) != 0) { - free(@as(?*anyopaque, @ptrCast(model.*.raw))); - } - if (model.*.tmap != null) { - free(@as(?*anyopaque, @ptrCast(model.*.tmap))); - } - if (model.*.bone != null) { - { - i = 0; - while (i < model.*.numbone) : (i +%= 1) if (model.*.bone[i].weight != null) { - free(@as(?*anyopaque, @ptrCast(model.*.bone[i].weight))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.bone))); - } - if (model.*.skin != null) { - free(@as(?*anyopaque, @ptrCast(model.*.skin))); - } - if (model.*.vertex != null) { - free(@as(?*anyopaque, @ptrCast(model.*.vertex))); - } - if (model.*.face != null) { - free(@as(?*anyopaque, @ptrCast(model.*.face))); - } - if (model.*.voxtype != null) { - { - i = 0; - while (i < model.*.numvoxtype) : (i +%= 1) if (model.*.voxtype[i].item != null) { - free(@as(?*anyopaque, @ptrCast(model.*.voxtype[i].item))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.voxtype))); - } - if (model.*.voxel != null) { - { - i = 0; - while (i < model.*.numvoxel) : (i +%= 1) if (model.*.voxel[i].data != null) { - free(@as(?*anyopaque, @ptrCast(model.*.voxel[i].data))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.voxel))); - } - if (model.*.shape != null) { - { - i = 0; - while (i < model.*.numshape) : (i +%= 1) { - if (model.*.shape[i].cmd != null) { - { - j = 0; - while (j < model.*.shape[i].numcmd) : (j +%= 1) if (model.*.shape[i].cmd[j].arg != null) { - free(@as(?*anyopaque, @ptrCast(model.*.shape[i].cmd[j].arg))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.shape[i].cmd))); - } - } - } - free(@as(?*anyopaque, @ptrCast(model.*.shape))); - } - if ((model.*.material != null) and !((@as(c_int, @bitCast(@as(c_uint, model.*.flags))) & (@as(c_int, 1) << @intCast(2))) != 0)) { - { - i = 0; - while (i < model.*.nummaterial) : (i +%= 1) if (model.*.material[i].prop != null) { - free(@as(?*anyopaque, @ptrCast(model.*.material[i].prop))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.material))); - } - if (model.*.texture != null) { - { - i = 0; - while (i < model.*.numtexture) : (i +%= 1) if (model.*.texture[i].d != null) { - free(@as(?*anyopaque, @ptrCast(model.*.texture[i].d))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.texture))); - } - if (model.*.action != null) { - { - i = 0; - while (i < model.*.numaction) : (i +%= 1) { - if (model.*.action[i].frame != null) { - { - j = 0; - while (j < model.*.action[i].numframe) : (j +%= 1) if (model.*.action[i].frame[j].transform != null) { - free(@as(?*anyopaque, @ptrCast(model.*.action[i].frame[j].transform))); - }; - } - free(@as(?*anyopaque, @ptrCast(model.*.action[i].frame))); - } - } - } - free(@as(?*anyopaque, @ptrCast(model.*.action))); - } - if (model.*.label != null) { - free(@as(?*anyopaque, @ptrCast(model.*.label))); - } - if (model.*.inlined != null) { - free(@as(?*anyopaque, @ptrCast(model.*.inlined))); - } - if (model.*.extra != null) { - free(@as(?*anyopaque, @ptrCast(model.*.extra))); - } - free(@as(?*anyopaque, @ptrCast(model))); -} -// ./external/m3d.h:4218:9: warning: TODO implement translation of stmt class GotoStmtClass - -// ./external/m3d.h:4200:10: warning: unable to translate function, demoted to extern -pub extern fn m3d_frame(arg_model: [*c]m3d_t, arg_actionid: M3D_INDEX, arg_frameid: M3D_INDEX, arg_skeleton: [*c]m3dtr_t) [*c]m3dtr_t; -pub export fn m3d_pose(arg_model: [*c]m3d_t, arg_actionid: M3D_INDEX, arg_msec: u32) [*c]m3db_t { - var model = arg_model; - _ = &model; - var actionid = arg_actionid; - _ = &actionid; - var msec = arg_msec; - _ = &msec; - var i: c_uint = undefined; - _ = &i; - var j: c_uint = undefined; - _ = &j; - var l: c_uint = undefined; - _ = &l; - var r: [16]M3D_FLOAT = undefined; - _ = &r; - var t: M3D_FLOAT = undefined; - _ = &t; - var c: M3D_FLOAT = undefined; - _ = &c; - var d: M3D_FLOAT = undefined; - _ = &d; - var s: M3D_FLOAT = undefined; - _ = &s; - var ret: [*c]m3db_t = undefined; - _ = &ret; - var v: [*c]m3dv_t = undefined; - _ = &v; - var p: [*c]m3dv_t = undefined; - _ = &p; - var f: [*c]m3dv_t = undefined; - _ = &f; - var tmp: [*c]m3dtr_t = undefined; - _ = &tmp; - var fr: [*c]m3dfr_t = undefined; - _ = &fr; - if ((!(model != null) or !(model.*.numbone != 0)) or !(model.*.bone != null)) { - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 69))))); - return null; - } - ret = @as([*c]m3db_t, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, model.*.numbone))) *% @sizeOf(m3db_t))))); - if (!(ret != null)) { - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))); - return null; - } - _ = memcpy(@as(?*anyopaque, @ptrCast(ret)), @as(?*const anyopaque, @ptrCast(model.*.bone)), @as(c_ulong, @bitCast(@as(c_ulong, model.*.numbone))) *% @sizeOf(m3db_t)); - { - i = 0; - while (i < model.*.numbone) : (i +%= 1) { - _m3d_inv(@as([*c]M3D_FLOAT, @ptrCast(@alignCast(&ret[i].mat4)))); - } - } - if (!(model.*.action != null) or (actionid >= model.*.numaction)) { - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 69))))); - return ret; - } - msec %= model.*.action[actionid].durationmsec; - model.*.errcode = 0; - fr = &model.*.action[actionid].frame[@as(c_uint, @intCast(@as(c_int, 0)))]; - { - j = blk: { - const tmp_1 = @as(c_uint, @bitCast(@as(c_int, 0))); - l = tmp_1; - break :blk tmp_1; - }; - while ((j < model.*.action[actionid].numframe) and (model.*.action[actionid].frame[j].msec <= msec)) : (j +%= 1) { - fr = &model.*.action[actionid].frame[j]; - l = fr.*.msec; - { - i = 0; - while (i < fr.*.numtransform) : (i +%= 1) { - ret[fr.*.transform[i].boneid].pos = fr.*.transform[i].pos; - ret[fr.*.transform[i].boneid].ori = fr.*.transform[i].ori; - } - } - } - } - if (l != msec) { - model.*.vertex = @as([*c]m3dv_t, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(model.*.vertex)), @as(c_ulong, @bitCast(@as(c_ulong, model.*.numvertex +% (@as(M3D_INDEX, @bitCast(@as(c_int, 2))) *% model.*.numbone)))) *% @sizeOf(m3dv_t))))); - if (!(model.*.vertex != null)) { - free(@as(?*anyopaque, @ptrCast(ret))); - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))); - return null; - } - tmp = @as([*c]m3dtr_t, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, model.*.numbone))) *% @sizeOf(m3dtr_t))))); - if (tmp != null) { - { - i = 0; - while (i < model.*.numbone) : (i +%= 1) { - tmp[i].pos = ret[i].pos; - tmp[i].ori = ret[i].ori; - } - } - fr = &model.*.action[actionid].frame[j % model.*.action[actionid].numframe]; - t = if (l >= fr.*.msec) @as(M3D_FLOAT, @floatCast(1.0)) else @as(M3D_FLOAT, @floatFromInt(msec -% l)) / @as(M3D_FLOAT, @floatFromInt(fr.*.msec -% l)); - { - i = 0; - while (i < fr.*.numtransform) : (i +%= 1) { - tmp[fr.*.transform[i].boneid].pos = fr.*.transform[i].pos; - tmp[fr.*.transform[i].boneid].ori = fr.*.transform[i].ori; - } - } - { - _ = blk: { - i = 0; - break :blk blk_1: { - const tmp_2 = model.*.numvertex; - j = tmp_2; - break :blk_1 tmp_2; - }; - }; - while (i < model.*.numbone) : (i +%= 1) { - if (ret[i].pos != tmp[i].pos) { - p = &model.*.vertex[ret[i].pos]; - f = &model.*.vertex[tmp[i].pos]; - v = &model.*.vertex[j]; - v.*.x = p.*.x + (t * (f.*.x - p.*.x)); - v.*.y = p.*.y + (t * (f.*.y - p.*.y)); - v.*.z = p.*.z + (t * (f.*.z - p.*.z)); - ret[i].pos = blk: { - const ref = &j; - const tmp_1 = ref.*; - ref.* +%= 1; - break :blk tmp_1; - }; - } - if (ret[i].ori != tmp[i].ori) { - p = &model.*.vertex[ret[i].ori]; - f = &model.*.vertex[tmp[i].ori]; - v = &model.*.vertex[j]; - d = (((p.*.w * f.*.w) + (p.*.x * f.*.x)) + (p.*.y * f.*.y)) + (p.*.z * f.*.z); - if (d < @as(M3D_FLOAT, @floatFromInt(@as(c_int, 0)))) { - d = -d; - s = @as(M3D_FLOAT, @floatCast(-1.0)); - } else { - s = @as(M3D_FLOAT, @floatCast(1.0)); - } - c = t - @as(M3D_FLOAT, @floatCast(0.5)); - t += ((t * c) * (t - @as(M3D_FLOAT, @floatCast(1.0)))) * ((((@as(M3D_FLOAT, @floatCast(1.0904)) + (d * (@as(M3D_FLOAT, @floatCast(-3.2452)) + (d * (@as(M3D_FLOAT, @floatCast(3.55645)) - (d * @as(M3D_FLOAT, @floatCast(1.43519)))))))) * c) * c) + (@as(M3D_FLOAT, @floatCast(0.848013)) + (d * (@as(M3D_FLOAT, @floatCast(-1.06021)) + (d * @as(M3D_FLOAT, @floatCast(0.215638))))))); - v.*.x = p.*.x + (t * ((s * f.*.x) - p.*.x)); - v.*.y = p.*.y + (t * ((s * f.*.y) - p.*.y)); - v.*.z = p.*.z + (t * ((s * f.*.z) - p.*.z)); - v.*.w = p.*.w + (t * ((s * f.*.w) - p.*.w)); - d = _m3d_rsq((((v.*.w * v.*.w) + (v.*.x * v.*.x)) + (v.*.y * v.*.y)) + (v.*.z * v.*.z)); - v.*.x *= d; - v.*.y *= d; - v.*.z *= d; - v.*.w *= d; - ret[i].ori = blk: { - const ref = &j; - const tmp_1 = ref.*; - ref.* +%= 1; - break :blk tmp_1; - }; - } - } - } - free(@as(?*anyopaque, @ptrCast(tmp))); - } - } - { - i = 0; - while (i < model.*.numbone) : (i +%= 1) { - if (ret[i].parent == @as(c_uint, 4294967295)) { - _m3d_mat(@as([*c]M3D_FLOAT, @ptrCast(@alignCast(&ret[i].mat4))), &model.*.vertex[ret[i].pos], &model.*.vertex[ret[i].ori]); - } else { - _m3d_mat(@as([*c]M3D_FLOAT, @ptrCast(@alignCast(&r))), &model.*.vertex[ret[i].pos], &model.*.vertex[ret[i].ori]); - _m3d_mul(@as([*c]M3D_FLOAT, @ptrCast(@alignCast(&ret[i].mat4))), @as([*c]M3D_FLOAT, @ptrCast(@alignCast(&ret[ret[i].parent].mat4))), @as([*c]M3D_FLOAT, @ptrCast(@alignCast(&r)))); - } - } - } - return ret; -} -pub export fn _m3d_safestr(arg_in: [*c]u8, arg_morelines: c_int) [*c]u8 { - var in = arg_in; - _ = ∈ - var morelines = arg_morelines; - _ = &morelines; - var out: [*c]u8 = undefined; - _ = &out; - var o: [*c]u8 = undefined; - _ = &o; - var i: [*c]u8 = in; - _ = &i; - var l: c_int = undefined; - _ = &l; - if (!(in != null) or !(in.* != 0)) { - out = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - if (!(out != null)) return null; - out[@as(c_uint, @intCast(@as(c_int, 0)))] = 0; - } else { - { - _ = blk: { - o = in; - break :blk blk_1: { - const tmp = @as(c_int, 0); - l = tmp; - break :blk_1 tmp; - }; - }; - while (((@as(c_int, @bitCast(@as(c_uint, o.*))) != 0) and (((morelines & @as(c_int, 1)) != 0) or ((@as(c_int, @bitCast(@as(c_uint, o.*))) != @as(c_int, '\r')) and (@as(c_int, @bitCast(@as(c_uint, o.*))) != @as(c_int, '\n'))))) and (l < @as(c_int, 256))) : (_ = blk: { - o += 1; - break :blk blk_1: { - const ref = &l; - const tmp = ref.*; - ref.* += 1; - break :blk_1 tmp; - }; - }) {} - } - out = blk: { - const tmp = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, l + @as(c_int, 1)))))))); - o = tmp; - break :blk tmp; - }; - if (!(out != null)) return null; - while ((((@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\t'))) or (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\r'))) or ((morelines != 0) and (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\n')))) { - i += 1; - } - while ((@as(c_int, @bitCast(@as(c_uint, i.*))) != 0) and ((morelines != 0) or ((@as(c_int, @bitCast(@as(c_uint, i.*))) != @as(c_int, '\r')) and (@as(c_int, @bitCast(@as(c_uint, i.*))) != @as(c_int, '\n'))))) : (i += 1) { - if (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\r')) continue; - if (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\n')) { - if (((morelines >= @as(c_int, 3)) and (o > out)) and (@as(c_int, @bitCast(@as(c_uint, (o - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))).*))) == @as(c_int, '\n'))) break; - if ((i > in) and (@as(c_int, @bitCast(@as(c_uint, (i - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))).*))) == @as(c_int, '\n'))) continue; - if ((morelines & @as(c_int, 1)) != 0) { - if (morelines == @as(c_int, 1)) { - (blk: { - const ref = &o; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\r'; - } - (blk: { - const ref = &o; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = '\n'; - } else break; - } else if ((@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\t'))) { - (blk: { - const ref = &o; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(if (morelines != 0) @as(c_int, ' ') else @as(c_int, '_'))))); - } else { - (blk: { - const ref = &o; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(if (!(morelines != 0) and ((@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '/')) or (@as(c_int, @bitCast(@as(c_uint, i.*))) == @as(c_int, '\\')))) @as(c_int, '_') else @as(c_int, @bitCast(@as(c_uint, i.*))))))); - } - } - while ((o > out) and ((((@as(c_int, @bitCast(@as(c_uint, (o - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))).*))) == @as(c_int, ' ')) or (@as(c_int, @bitCast(@as(c_uint, (o - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))).*))) == @as(c_int, '\t'))) or (@as(c_int, @bitCast(@as(c_uint, (o - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))).*))) == @as(c_int, '\r'))) or (@as(c_int, @bitCast(@as(c_uint, (o - @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))).*))) == @as(c_int, '\n')))) : (o -= 1) {} - o.* = 0; - out = @as([*c]u8, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(out)), (@as(usize, @intCast(@intFromPtr(o))) -% @as(usize, @intCast(@intFromPtr(out)))) +% @as(usize, @bitCast(@as(c_long, @as(c_int, 1)))))))); - } - return out; -} -pub var m3d_propertytypes: [17]m3dpd_t = [17]m3dpd_t{ - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_color)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Kd)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_color)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Ka)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_color)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Ks)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Ns)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_color)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Ke)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_color)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Tf)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Km)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_d)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_uint8)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_il)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Pr)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Pm)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Ps)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Ni)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_float)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_Nt)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_map)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_map_Km)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_map)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_map_N)))), - }, - m3dpd_t{ - .format = @as(u8, @bitCast(@as(i8, @truncate(m3dpf_map)))), - .id = @as(u8, @bitCast(@as(i8, @truncate(m3dp_map_Pm)))), - }, -}; -pub var m3d_commandtypes: [38]m3dcd_t = [38]m3dcd_t{ - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_mi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_hi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_qi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_fi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_fi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_qi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i1_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i1_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i1_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 1))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 4))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 4))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 6))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_ti_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_i2_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_va_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_qi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 6))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_qi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_qi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 2))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 4))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_qi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vc_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, - m3dcd_t{ - .p = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 3))))), - .a = [8]u8{ - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(m3dcp_vi_t)))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 0))))), - }, - }, -}; -pub var _m3dstbi__g_failure_reason: [*c]const u8 = @import("std").mem.zeroes([*c]const u8); -pub const STBI_default: c_int = 0; -pub const STBI_grey: c_int = 1; -pub const STBI_grey_alpha: c_int = 2; -pub const STBI_rgb: c_int = 3; -pub const STBI_rgb_alpha: c_int = 4; -const enum_unnamed_13 = c_uint; -pub const STBI__SCAN_load: c_int = 0; -pub const STBI__SCAN_type: c_int = 1; -pub const STBI__SCAN_header: c_int = 2; -const enum_unnamed_14 = c_uint; -pub const _m3dstbi_us = c_ushort; -pub const _m3dstbi__uint16 = u16; -pub const _m3dstbi__int16 = i16; -pub const _m3dstbi__uint32 = u32; -pub const _m3dstbi__int32 = i32; -pub const _m3dstbi__context = extern struct { - img_x: _m3dstbi__uint32 = @import("std").mem.zeroes(_m3dstbi__uint32), - img_y: _m3dstbi__uint32 = @import("std").mem.zeroes(_m3dstbi__uint32), - img_n: c_int = @import("std").mem.zeroes(c_int), - img_out_n: c_int = @import("std").mem.zeroes(c_int), - io_user_data: ?*anyopaque = @import("std").mem.zeroes(?*anyopaque), - read_from_callbacks: c_int = @import("std").mem.zeroes(c_int), - buflen: c_int = @import("std").mem.zeroes(c_int), - buffer_start: [128]u8 = @import("std").mem.zeroes([128]u8), - img_buffer: [*c]u8 = @import("std").mem.zeroes([*c]u8), - img_buffer_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - img_buffer_original: [*c]u8 = @import("std").mem.zeroes([*c]u8), - img_buffer_original_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), -}; -pub const _m3dstbi__result_info = extern struct { - bits_per_channel: c_int = @import("std").mem.zeroes(c_int), - num_channels: c_int = @import("std").mem.zeroes(c_int), - channel_order: c_int = @import("std").mem.zeroes(c_int), -}; -pub fn _m3dstbi__get8(arg_s: [*c]_m3dstbi__context) callconv(.C) u8 { - var s = arg_s; - _ = &s; - if (s.*.img_buffer < s.*.img_buffer_end) return (blk: { - const ref = &s.*.img_buffer; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - return 0; -} -pub fn _m3dstbi__at_eof(arg_s: [*c]_m3dstbi__context) callconv(.C) c_int { - var s = arg_s; - _ = &s; - return @intFromBool(s.*.img_buffer >= s.*.img_buffer_end); -} -pub fn _m3dstbi__skip(arg_s: [*c]_m3dstbi__context, arg_n: c_int) callconv(.C) void { - var s = arg_s; - _ = &s; - var n = arg_n; - _ = &n; - if (n < @as(c_int, 0)) { - s.*.img_buffer = s.*.img_buffer_end; - return; - } - s.*.img_buffer += @as(usize, @bitCast(@as(isize, @intCast(n)))); -} -pub fn _m3dstbi__getn(arg_s: [*c]_m3dstbi__context, arg_buffer: [*c]u8, arg_n: c_int) callconv(.C) c_int { - var s = arg_s; - _ = &s; - var buffer = arg_buffer; - _ = &buffer; - var n = arg_n; - _ = &n; - if ((s.*.img_buffer + @as(usize, @bitCast(@as(isize, @intCast(n))))) <= s.*.img_buffer_end) { - _ = memcpy(@as(?*anyopaque, @ptrCast(buffer)), @as(?*const anyopaque, @ptrCast(s.*.img_buffer)), @as(c_ulong, @bitCast(@as(c_long, n)))); - s.*.img_buffer += @as(usize, @bitCast(@as(isize, @intCast(n)))); - return 1; - } else return 0; - return 0; -} -pub fn _m3dstbi__get16be(arg_s: [*c]_m3dstbi__context) callconv(.C) c_int { - var s = arg_s; - _ = &s; - var z: c_int = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); - _ = &z; - return (z << @intCast(8)) + @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); -} -pub fn _m3dstbi__get32be(arg_s: [*c]_m3dstbi__context) callconv(.C) _m3dstbi__uint32 { - var s = arg_s; - _ = &s; - var z: _m3dstbi__uint32 = @as(_m3dstbi__uint32, @bitCast(_m3dstbi__get16be(s))); - _ = &z; - return (z << @intCast(16)) +% @as(_m3dstbi__uint32, @bitCast(_m3dstbi__get16be(s))); -} -pub fn _m3dstbi__errstr(arg_str: [*c]const u8) callconv(.C) c_int { - var str = arg_str; - _ = &str; - _m3dstbi__g_failure_reason = str; - return 0; -} -pub fn _m3dstbi__malloc(arg_size: usize) callconv(.C) ?*anyopaque { - var size = arg_size; - _ = &size; - return malloc(size); -} -pub fn _m3dstbi__addsizes_valid(arg_a: c_int, arg_b: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - if (b < @as(c_int, 0)) return 0; - return @intFromBool(a <= (@as(c_int, 2147483647) - b)); -} -pub fn _m3dstbi__mul2sizes_valid(arg_a: c_int, arg_b: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - if ((a < @as(c_int, 0)) or (b < @as(c_int, 0))) return 0; - if (b == @as(c_int, 0)) return 1; - return @intFromBool(a <= @divTrunc(@as(c_int, 2147483647), b)); -} -pub fn _m3dstbi__mad2sizes_valid(arg_a: c_int, arg_b: c_int, arg_add: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var add = arg_add; - _ = &add; - return @intFromBool((_m3dstbi__mul2sizes_valid(a, b) != 0) and (_m3dstbi__addsizes_valid(a * b, add) != 0)); -} -pub fn _m3dstbi__mad3sizes_valid(arg_a: c_int, arg_b: c_int, arg_c: c_int, arg_add: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var c = arg_c; - _ = &c; - var add = arg_add; - _ = &add; - return @intFromBool(((_m3dstbi__mul2sizes_valid(a, b) != 0) and (_m3dstbi__mul2sizes_valid(a * b, c) != 0)) and (_m3dstbi__addsizes_valid((a * b) * c, add) != 0)); -} -pub fn _m3dstbi__malloc_mad2(arg_a: c_int, arg_b: c_int, arg_add: c_int) callconv(.C) ?*anyopaque { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var add = arg_add; - _ = &add; - if (!(_m3dstbi__mad2sizes_valid(a, b, add) != 0)) return @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - return _m3dstbi__malloc(@as(usize, @bitCast(@as(c_long, (a * b) + add)))); -} -pub fn _m3dstbi__malloc_mad3(arg_a: c_int, arg_b: c_int, arg_c: c_int, arg_add: c_int) callconv(.C) ?*anyopaque { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var c = arg_c; - _ = &c; - var add = arg_add; - _ = &add; - if (!(_m3dstbi__mad3sizes_valid(a, b, c, add) != 0)) return @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - return _m3dstbi__malloc(@as(usize, @bitCast(@as(c_long, ((a * b) * c) + add)))); -} -pub fn _m3dstbi__compute_y(arg_r: c_int, arg_g: c_int, arg_b: c_int) callconv(.C) u8 { - var r = arg_r; - _ = &r; - var g = arg_g; - _ = &g; - var b = arg_b; - _ = &b; - return @as(u8, @bitCast(@as(i8, @truncate((((r * @as(c_int, 77)) + (g * @as(c_int, 150))) + (@as(c_int, 29) * b)) >> @intCast(8))))); -} -pub fn _m3dstbi__convert_format(arg_data: [*c]u8, arg_img_n: c_int, arg_req_comp: c_int, arg_x: c_uint, arg_y: c_uint) callconv(.C) [*c]u8 { - var data = arg_data; - _ = &data; - var img_n = arg_img_n; - _ = &img_n; - var req_comp = arg_req_comp; - _ = &req_comp; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var i: c_int = undefined; - _ = &i; - var j: c_int = undefined; - _ = &j; - var good: [*c]u8 = undefined; - _ = &good; - if (req_comp == img_n) return data; - good = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi__malloc_mad3(req_comp, @as(c_int, @bitCast(x)), @as(c_int, @bitCast(y)), @as(c_int, 0))))); - if (good == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - free(@as(?*anyopaque, @ptrCast(data))); - _ = _m3dstbi__errstr("Out of memory"); - return null; - } - { - j = 0; - while (j < @as(c_int, @bitCast(y))) : (j += 1) { - var src: [*c]u8 = data + ((@as(c_uint, @bitCast(j)) *% x) *% @as(c_uint, @bitCast(img_n))); - _ = &src; - var dest: [*c]u8 = good + ((@as(c_uint, @bitCast(j)) *% x) *% @as(c_uint, @bitCast(req_comp))); - _ = &dest; - while (true) { - switch ((img_n * @as(c_int, 8)) + req_comp) { - @as(c_int, 10) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - break :blk blk_1: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 11) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk: { - const tmp = blk_1: { - const tmp_2 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_2; - break :blk_1 tmp_2; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk tmp; - }; - } - } - break; - }, - @as(c_int, 12) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk_1: { - const tmp = blk_2: { - const tmp_3 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_3; - break :blk_2 tmp_3; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - break :blk blk_1: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - dest[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 17) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - } - } - break; - }, - @as(c_int, 19) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk: { - const tmp = blk_1: { - const tmp_2 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_2; - break :blk_1 tmp_2; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk tmp; - }; - } - } - break; - }, - @as(c_int, 20) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk_1: { - const tmp = blk_2: { - const tmp_3 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_3; - break :blk_2 tmp_3; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - break :blk blk_1: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - dest[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 28) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - _ = blk_1: { - _ = blk_2: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - break :blk_2 blk_3: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_3 tmp; - }; - }; - break :blk_1 blk_2: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp; - break :blk_2 tmp; - }; - }; - break :blk blk_1: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - dest[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 25) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - } - } - break; - }, - @as(c_int, 26) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - break :blk blk_1: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 33) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - } - } - break; - }, - @as(c_int, 34) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - break :blk blk_1: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 3)))]; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 35) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - _ = blk_1: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - break :blk_1 blk_2: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_2 tmp; - }; - }; - break :blk blk_1: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - else => { - {} - }, - } - break; - } - } - } - free(@as(?*anyopaque, @ptrCast(data))); - return good; -} -pub fn _m3dstbi__compute_y_16(arg_r: c_int, arg_g: c_int, arg_b: c_int) callconv(.C) _m3dstbi__uint16 { - var r = arg_r; - _ = &r; - var g = arg_g; - _ = &g; - var b = arg_b; - _ = &b; - return @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate((((r * @as(c_int, 77)) + (g * @as(c_int, 150))) + (@as(c_int, 29) * b)) >> @intCast(8))))); -} -pub fn _m3dstbi__convert_format16(arg_data: [*c]_m3dstbi__uint16, arg_img_n: c_int, arg_req_comp: c_int, arg_x: c_uint, arg_y: c_uint) callconv(.C) [*c]_m3dstbi__uint16 { - var data = arg_data; - _ = &data; - var img_n = arg_img_n; - _ = &img_n; - var req_comp = arg_req_comp; - _ = &req_comp; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var i: c_int = undefined; - _ = &i; - var j: c_int = undefined; - _ = &j; - var good: [*c]_m3dstbi__uint16 = undefined; - _ = &good; - if (req_comp == img_n) return data; - good = @as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(_m3dstbi__malloc(@as(usize, @bitCast(@as(c_ulong, ((@as(c_uint, @bitCast(req_comp)) *% x) *% y) *% @as(c_uint, @bitCast(@as(c_int, 2)))))))))); - if (good == @as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - free(@as(?*anyopaque, @ptrCast(data))); - _ = _m3dstbi__errstr("Out of memory"); - return null; - } - { - j = 0; - while (j < @as(c_int, @bitCast(y))) : (j += 1) { - var src: [*c]_m3dstbi__uint16 = data + ((@as(c_uint, @bitCast(j)) *% x) *% @as(c_uint, @bitCast(img_n))); - _ = &src; - var dest: [*c]_m3dstbi__uint16 = good + ((@as(c_uint, @bitCast(j)) *% x) *% @as(c_uint, @bitCast(req_comp))); - _ = &dest; - while (true) { - switch ((img_n * @as(c_int, 8)) + req_comp) { - @as(c_int, 10) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - break :blk blk_1: { - const tmp = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(@as(c_int, 65535))))); - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 11) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk: { - const tmp = blk_1: { - const tmp_2 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_2; - break :blk_1 tmp_2; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk tmp; - }; - } - } - break; - }, - @as(c_int, 12) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk_1: { - const tmp = blk_2: { - const tmp_3 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_3; - break :blk_2 tmp_3; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - break :blk blk_1: { - const tmp = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(@as(c_int, 65535))))); - dest[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 17) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - } - } - break; - }, - @as(c_int, 19) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk: { - const tmp = blk_1: { - const tmp_2 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_2; - break :blk_1 tmp_2; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk tmp; - }; - } - } - break; - }, - @as(c_int, 20) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = blk_1: { - const tmp = blk_2: { - const tmp_3 = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp_3; - break :blk_2 tmp_3; - }; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - break :blk blk_1: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - dest[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 28) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - _ = blk_1: { - _ = blk_2: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - break :blk_2 blk_3: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_3 tmp; - }; - }; - break :blk_1 blk_2: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp; - break :blk_2 tmp; - }; - }; - break :blk blk_1: { - const tmp = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(@as(c_int, 65535))))); - dest[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 25) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y_16(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - } - } - break; - }, - @as(c_int, 26) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y_16(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - break :blk blk_1: { - const tmp = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(@as(c_int, 65535))))); - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 33) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - break :blk_1 ref.*; - }; - }) { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y_16(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - } - } - break; - }, - @as(c_int, 34) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = _m3dstbi__compute_y_16(@as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))), @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))])))); - break :blk blk_1: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 3)))]; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - @as(c_int, 35) => { - { - i = @as(c_int, @bitCast(x -% @as(c_uint, @bitCast(@as(c_int, 1))))); - while (i >= @as(c_int, 0)) : (_ = blk: { - _ = blk_1: { - i -= 1; - break :blk_1 blk_2: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dest; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - _ = blk: { - _ = blk_1: { - dest[@as(c_uint, @intCast(@as(c_int, 0)))] = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - break :blk_1 blk_2: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - dest[@as(c_uint, @intCast(@as(c_int, 1)))] = tmp; - break :blk_2 tmp; - }; - }; - break :blk blk_1: { - const tmp = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - dest[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp; - break :blk_1 tmp; - }; - }; - } - } - break; - }, - else => { - {} - }, - } - break; - } - } - } - free(@as(?*anyopaque, @ptrCast(data))); - return good; -} -pub const _m3dstbi__zhuffman = extern struct { - fast: [512]_m3dstbi__uint16 = @import("std").mem.zeroes([512]_m3dstbi__uint16), - firstcode: [16]_m3dstbi__uint16 = @import("std").mem.zeroes([16]_m3dstbi__uint16), - maxcode: [17]c_int = @import("std").mem.zeroes([17]c_int), - firstsymbol: [16]_m3dstbi__uint16 = @import("std").mem.zeroes([16]_m3dstbi__uint16), - size: [288]u8 = @import("std").mem.zeroes([288]u8), - value: [288]_m3dstbi__uint16 = @import("std").mem.zeroes([288]_m3dstbi__uint16), -}; -pub fn _m3dstbi__bitreverse16(arg_n: c_int) callconv(.C) c_int { - var n = arg_n; - _ = &n; - n = ((n & @as(c_int, 43690)) >> @intCast(1)) | ((n & @as(c_int, 21845)) << @intCast(1)); - n = ((n & @as(c_int, 52428)) >> @intCast(2)) | ((n & @as(c_int, 13107)) << @intCast(2)); - n = ((n & @as(c_int, 61680)) >> @intCast(4)) | ((n & @as(c_int, 3855)) << @intCast(4)); - n = ((n & @as(c_int, 65280)) >> @intCast(8)) | ((n & @as(c_int, 255)) << @intCast(8)); - return n; -} -pub fn _m3dstbi__bit_reverse(arg_v: c_int, arg_bits: c_int) callconv(.C) c_int { - var v = arg_v; - _ = &v; - var bits = arg_bits; - _ = &bits; - return _m3dstbi__bitreverse16(v) >> @intCast(@as(c_int, 16) - bits); -} -pub fn _m3dstbi__zbuild_huffman(arg_z: [*c]_m3dstbi__zhuffman, arg_sizelist: [*c]u8, arg_num: c_int) callconv(.C) c_int { - var z = arg_z; - _ = &z; - var sizelist = arg_sizelist; - _ = &sizelist; - var num = arg_num; - _ = # - var i: c_int = undefined; - _ = &i; - var k: c_int = 0; - _ = &k; - var code: c_int = undefined; - _ = &code; - var next_code: [16]c_int = undefined; - _ = &next_code; - var sizes: [17]c_int = undefined; - _ = &sizes; - _ = memset(@as(?*anyopaque, @ptrCast(@as([*c]c_int, @ptrCast(@alignCast(&sizes))))), @as(c_int, 0), @sizeOf([17]c_int)); - _ = memset(@as(?*anyopaque, @ptrCast(@as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(&z.*.fast))))), @as(c_int, 0), @sizeOf([512]_m3dstbi__uint16)); - { - i = 0; - while (i < num) : (i += 1) { - sizes[(blk: { - const tmp = i; - if (tmp >= 0) break :blk sizelist + @as(usize, @intCast(tmp)) else break :blk sizelist - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*] += 1; - } - } - sizes[@as(c_uint, @intCast(@as(c_int, 0)))] = 0; - { - i = 1; - while (i < @as(c_int, 16)) : (i += 1) if (sizes[@as(c_uint, @intCast(i))] > (@as(c_int, 1) << @intCast(i))) return _m3dstbi__errstr("Corrupt PNG"); - } - code = 0; - { - i = 1; - while (i < @as(c_int, 16)) : (i += 1) { - next_code[@as(c_uint, @intCast(i))] = code; - z.*.firstcode[@as(c_uint, @intCast(i))] = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(code)))); - z.*.firstsymbol[@as(c_uint, @intCast(i))] = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(k)))); - code = code + sizes[@as(c_uint, @intCast(i))]; - if (sizes[@as(c_uint, @intCast(i))] != 0) if ((code - @as(c_int, 1)) >= (@as(c_int, 1) << @intCast(i))) return _m3dstbi__errstr("Corrupt PNG"); - z.*.maxcode[@as(c_uint, @intCast(i))] = code << @intCast(@as(c_int, 16) - i); - code <<= @intCast(@as(c_int, 1)); - k += sizes[@as(c_uint, @intCast(i))]; - } - } - z.*.maxcode[@as(c_uint, @intCast(@as(c_int, 16)))] = 65536; - { - i = 0; - while (i < num) : (i += 1) { - var s: c_int = @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk sizelist + @as(usize, @intCast(tmp)) else break :blk sizelist - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - _ = &s; - if (s != 0) { - var c: c_int = (next_code[@as(c_uint, @intCast(s))] - @as(c_int, @bitCast(@as(c_uint, z.*.firstcode[@as(c_uint, @intCast(s))])))) + @as(c_int, @bitCast(@as(c_uint, z.*.firstsymbol[@as(c_uint, @intCast(s))]))); - _ = &c; - var fastv: _m3dstbi__uint16 = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate((s << @intCast(9)) | i)))); - _ = &fastv; - z.*.size[@as(c_uint, @intCast(c))] = @as(u8, @bitCast(@as(i8, @truncate(s)))); - z.*.value[@as(c_uint, @intCast(c))] = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(i)))); - if (s <= @as(c_int, 9)) { - var j: c_int = _m3dstbi__bit_reverse(next_code[@as(c_uint, @intCast(s))], s); - _ = &j; - while (j < (@as(c_int, 1) << @intCast(9))) { - z.*.fast[@as(c_uint, @intCast(j))] = fastv; - j += @as(c_int, 1) << @intCast(s); - } - } - next_code[@as(c_uint, @intCast(s))] += 1; - } - } - } - return 1; -} -pub const _m3dstbi__zbuf = extern struct { - zbuffer: [*c]u8 = @import("std").mem.zeroes([*c]u8), - zbuffer_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - num_bits: c_int = @import("std").mem.zeroes(c_int), - code_buffer: _m3dstbi__uint32 = @import("std").mem.zeroes(_m3dstbi__uint32), - zout: [*c]u8 = @import("std").mem.zeroes([*c]u8), - zout_start: [*c]u8 = @import("std").mem.zeroes([*c]u8), - zout_end: [*c]u8 = @import("std").mem.zeroes([*c]u8), - z_expandable: c_int = @import("std").mem.zeroes(c_int), - z_length: _m3dstbi__zhuffman = @import("std").mem.zeroes(_m3dstbi__zhuffman), - z_distance: _m3dstbi__zhuffman = @import("std").mem.zeroes(_m3dstbi__zhuffman), -}; -pub fn _m3dstbi__zget8(arg_z: [*c]_m3dstbi__zbuf) callconv(.C) u8 { - var z = arg_z; - _ = &z; - if (z.*.zbuffer >= z.*.zbuffer_end) return 0; - return (blk: { - const ref = &z.*.zbuffer; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; -} -pub fn _m3dstbi__fill_bits(arg_z: [*c]_m3dstbi__zbuf) callconv(.C) void { - var z = arg_z; - _ = &z; - while (true) { - z.*.code_buffer |= @as(_m3dstbi__uint32, @bitCast(@as(c_uint, @bitCast(@as(c_uint, _m3dstbi__zget8(z)))) << @intCast(z.*.num_bits))); - z.*.num_bits += @as(c_int, 8); - if (!(z.*.num_bits <= @as(c_int, 24))) break; - } -} -pub fn _m3dstbi__zreceive(arg_z: [*c]_m3dstbi__zbuf, arg_n: c_int) callconv(.C) c_uint { - var z = arg_z; - _ = &z; - var n = arg_n; - _ = &n; - var k: c_uint = undefined; - _ = &k; - if (z.*.num_bits < n) { - _m3dstbi__fill_bits(z); - } - k = z.*.code_buffer & @as(_m3dstbi__uint32, @bitCast((@as(c_int, 1) << @intCast(n)) - @as(c_int, 1))); - z.*.code_buffer >>= @intCast(n); - z.*.num_bits -= n; - return k; -} -pub fn _m3dstbi__zhuffman_decode_slowpath(arg_a: [*c]_m3dstbi__zbuf, arg_z: [*c]_m3dstbi__zhuffman) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var z = arg_z; - _ = &z; - var b: c_int = undefined; - _ = &b; - var s: c_int = undefined; - _ = &s; - var k: c_int = undefined; - _ = &k; - k = _m3dstbi__bit_reverse(@as(c_int, @bitCast(a.*.code_buffer)), @as(c_int, 16)); - { - s = @as(c_int, 9) + @as(c_int, 1); - while (true) : (s += 1) if (k < z.*.maxcode[@as(c_uint, @intCast(s))]) break; - } - if (s == @as(c_int, 16)) return -@as(c_int, 1); - b = ((k >> @intCast(@as(c_int, 16) - s)) - @as(c_int, @bitCast(@as(c_uint, z.*.firstcode[@as(c_uint, @intCast(s))])))) + @as(c_int, @bitCast(@as(c_uint, z.*.firstsymbol[@as(c_uint, @intCast(s))]))); - a.*.code_buffer >>= @intCast(s); - a.*.num_bits -= s; - return @as(c_int, @bitCast(@as(c_uint, z.*.value[@as(c_uint, @intCast(b))]))); -} -pub fn _m3dstbi__zhuffman_decode(arg_a: [*c]_m3dstbi__zbuf, arg_z: [*c]_m3dstbi__zhuffman) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var z = arg_z; - _ = &z; - var b: c_int = undefined; - _ = &b; - var s: c_int = undefined; - _ = &s; - if (a.*.num_bits < @as(c_int, 16)) { - _m3dstbi__fill_bits(a); - } - b = @as(c_int, @bitCast(@as(c_uint, z.*.fast[a.*.code_buffer & @as(_m3dstbi__uint32, @bitCast((@as(c_int, 1) << @intCast(9)) - @as(c_int, 1)))]))); - if (b != 0) { - s = b >> @intCast(9); - a.*.code_buffer >>= @intCast(s); - a.*.num_bits -= s; - return b & @as(c_int, 511); - } - return _m3dstbi__zhuffman_decode_slowpath(a, z); -} -pub fn _m3dstbi__zexpand(arg_z: [*c]_m3dstbi__zbuf, arg_zout: [*c]u8, arg_n: c_int) callconv(.C) c_int { - var z = arg_z; - _ = &z; - var zout = arg_zout; - _ = &zout; - var n = arg_n; - _ = &n; - var q: [*c]u8 = undefined; - _ = &q; - var cur: c_int = undefined; - _ = &cur; - var limit: c_int = undefined; - _ = &limit; - var old_limit: c_int = undefined; - _ = &old_limit; - z.*.zout = zout; - if (!(z.*.z_expandable != 0)) return _m3dstbi__errstr("Corrupt PNG"); - cur = @as(c_int, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(z.*.zout) -% @intFromPtr(z.*.zout_start))), @sizeOf(u8)))))); - limit = blk: { - const tmp = @as(c_int, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(z.*.zout_end) -% @intFromPtr(z.*.zout_start))), @sizeOf(u8)))))); - old_limit = tmp; - break :blk tmp; - }; - while ((cur + n) > limit) { - limit *= @as(c_int, 2); - } - q = @as([*c]u8, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(z.*.zout_start)), @as(c_ulong, @bitCast(@as(c_long, limit))))))); - _ = @sizeOf(c_int); - if (q == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return _m3dstbi__errstr("Out of memory"); - z.*.zout_start = q; - z.*.zout = q + @as(usize, @bitCast(@as(isize, @intCast(cur)))); - z.*.zout_end = q + @as(usize, @bitCast(@as(isize, @intCast(limit)))); - return 1; -} -pub var _m3dstbi__zlength_base: [31]c_int = [31]c_int{ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 13, - 15, - 17, - 19, - 23, - 27, - 31, - 35, - 43, - 51, - 59, - 67, - 83, - 99, - 115, - 131, - 163, - 195, - 227, - 258, - 0, - 0, -}; -pub var _m3dstbi__zlength_extra: [31]c_int = [31]c_int{ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 5, - 5, - 5, - 5, - 0, - 0, - 0, -}; -pub var _m3dstbi__zdist_base: [32]c_int = [32]c_int{ - 1, - 2, - 3, - 4, - 5, - 7, - 9, - 13, - 17, - 25, - 33, - 49, - 65, - 97, - 129, - 193, - 257, - 385, - 513, - 769, - 1025, - 1537, - 2049, - 3073, - 4097, - 6145, - 8193, - 12289, - 16385, - 24577, - 0, - 0, -}; -pub var _m3dstbi__zdist_extra: [32]c_int = [30]c_int{ - 0, - 0, - 0, - 0, - 1, - 1, - 2, - 2, - 3, - 3, - 4, - 4, - 5, - 5, - 6, - 6, - 7, - 7, - 8, - 8, - 9, - 9, - 10, - 10, - 11, - 11, - 12, - 12, - 13, - 13, -} ++ [1]c_int{0} ** 2; -pub fn _m3dstbi__parse_huffman_block(arg_a: [*c]_m3dstbi__zbuf) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var zout: [*c]u8 = a.*.zout; - _ = &zout; - while (true) { - var z: c_int = _m3dstbi__zhuffman_decode(a, &a.*.z_length); - _ = &z; - if (z < @as(c_int, 256)) { - if (z < @as(c_int, 0)) return _m3dstbi__errstr("Corrupt PNG"); - if (zout >= a.*.zout_end) { - if (!(_m3dstbi__zexpand(a, zout, @as(c_int, 1)) != 0)) return 0; - zout = a.*.zout; - } - (blk: { - const ref = &zout; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(z)))); - } else { - var p: [*c]u8 = undefined; - _ = &p; - var len: c_int = undefined; - _ = &len; - var dist: c_int = undefined; - _ = &dist; - if (z == @as(c_int, 256)) { - a.*.zout = zout; - return 1; - } - z -= @as(c_int, 257); - len = _m3dstbi__zlength_base[@as(c_uint, @intCast(z))]; - if (_m3dstbi__zlength_extra[@as(c_uint, @intCast(z))] != 0) { - len += @as(c_int, @bitCast(_m3dstbi__zreceive(a, _m3dstbi__zlength_extra[@as(c_uint, @intCast(z))]))); - } - z = _m3dstbi__zhuffman_decode(a, &a.*.z_distance); - if (z < @as(c_int, 0)) return _m3dstbi__errstr("Corrupt PNG"); - dist = _m3dstbi__zdist_base[@as(c_uint, @intCast(z))]; - if (_m3dstbi__zdist_extra[@as(c_uint, @intCast(z))] != 0) { - dist += @as(c_int, @bitCast(_m3dstbi__zreceive(a, _m3dstbi__zdist_extra[@as(c_uint, @intCast(z))]))); - } - if (@divExact(@as(c_long, @bitCast(@intFromPtr(zout) -% @intFromPtr(a.*.zout_start))), @sizeOf(u8)) < @as(c_long, @bitCast(@as(c_long, dist)))) return _m3dstbi__errstr("Corrupt PNG"); - if ((zout + @as(usize, @bitCast(@as(isize, @intCast(len))))) > a.*.zout_end) { - if (!(_m3dstbi__zexpand(a, zout, len) != 0)) return 0; - zout = a.*.zout; - } - p = @as([*c]u8, @ptrCast(@alignCast(zout - @as(usize, @bitCast(@as(isize, @intCast(dist))))))); - if (dist == @as(c_int, 1)) { - var v: u8 = p.*; - _ = &v; - if (len != 0) { - while (true) { - (blk: { - const ref = &zout; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(v)); - if (!((blk: { - const ref = &len; - ref.* -= 1; - break :blk ref.*; - }) != 0)) break; - } - } - } else { - if (len != 0) { - while (true) { - (blk: { - const ref = &zout; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast((blk: { - const ref = &p; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*)); - if (!((blk: { - const ref = &len; - ref.* -= 1; - break :blk ref.*; - }) != 0)) break; - } - } - } - } - } - return 0; -} -pub fn _m3dstbi__compute_huffman_codes(arg_a: [*c]_m3dstbi__zbuf) callconv(.C) c_int { - var a = arg_a; - _ = &a; - const length_dezigzag = struct { - var static: [19]u8 = [19]u8{ - 16, - 17, - 18, - 0, - 8, - 7, - 9, - 6, - 10, - 5, - 11, - 4, - 12, - 3, - 13, - 2, - 14, - 1, - 15, - }; - }; - _ = &length_dezigzag; - var z_codelength: _m3dstbi__zhuffman = undefined; - _ = &z_codelength; - var lencodes: [455]u8 = undefined; - _ = &lencodes; - var codelength_sizes: [19]u8 = undefined; - _ = &codelength_sizes; - var i: c_int = undefined; - _ = &i; - var n: c_int = undefined; - _ = &n; - var hlit: c_int = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 5)) +% @as(c_uint, @bitCast(@as(c_int, 257))))); - _ = &hlit; - var hdist: c_int = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 5)) +% @as(c_uint, @bitCast(@as(c_int, 1))))); - _ = &hdist; - var hclen: c_int = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 4)) +% @as(c_uint, @bitCast(@as(c_int, 4))))); - _ = &hclen; - var ntot: c_int = hlit + hdist; - _ = &ntot; - _ = memset(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&codelength_sizes))))), @as(c_int, 0), @sizeOf([19]u8)); - { - i = 0; - while (i < hclen) : (i += 1) { - var s: c_int = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 3)))); - _ = &s; - codelength_sizes[length_dezigzag.static[@as(c_uint, @intCast(i))]] = @as(u8, @bitCast(@as(i8, @truncate(s)))); - } - } - if (!(_m3dstbi__zbuild_huffman(&z_codelength, @as([*c]u8, @ptrCast(@alignCast(&codelength_sizes))), @as(c_int, 19)) != 0)) return 0; - n = 0; - while (n < ntot) { - var c: c_int = _m3dstbi__zhuffman_decode(a, &z_codelength); - _ = &c; - if ((c < @as(c_int, 0)) or (c >= @as(c_int, 19))) return _m3dstbi__errstr("Corrupt PNG"); - if (c < @as(c_int, 16)) { - lencodes[@as(c_uint, @intCast(blk: { - const ref = &n; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }))] = @as(u8, @bitCast(@as(i8, @truncate(c)))); - } else { - var fill: u8 = 0; - _ = &fill; - if (c == @as(c_int, 16)) { - c = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 2)) +% @as(c_uint, @bitCast(@as(c_int, 3))))); - if (n == @as(c_int, 0)) return _m3dstbi__errstr("Corrupt PNG"); - fill = lencodes[@as(c_uint, @intCast(n - @as(c_int, 1)))]; - } else if (c == @as(c_int, 17)) { - c = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 3)) +% @as(c_uint, @bitCast(@as(c_int, 3))))); - } else { - c = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 7)) +% @as(c_uint, @bitCast(@as(c_int, 11))))); - } - if ((ntot - n) < c) return _m3dstbi__errstr("Corrupt PNG"); - _ = memset(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&lencodes))) + @as(usize, @bitCast(@as(isize, @intCast(n)))))), @as(c_int, @bitCast(@as(c_uint, fill))), @as(c_ulong, @bitCast(@as(c_long, c)))); - n += c; - } - } - if (n != ntot) return _m3dstbi__errstr("Corrupt PNG"); - if (!(_m3dstbi__zbuild_huffman(&a.*.z_length, @as([*c]u8, @ptrCast(@alignCast(&lencodes))), hlit) != 0)) return 0; - if (!(_m3dstbi__zbuild_huffman(&a.*.z_distance, @as([*c]u8, @ptrCast(@alignCast(&lencodes))) + @as(usize, @bitCast(@as(isize, @intCast(hlit)))), hdist) != 0)) return 0; - return 1; -} -pub fn _m3dstbi__parse_uncompressed_block(arg_a: [*c]_m3dstbi__zbuf) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var header: [4]u8 = undefined; - _ = &header; - var len: c_int = undefined; - _ = &len; - var nlen: c_int = undefined; - _ = &nlen; - var k: c_int = undefined; - _ = &k; - if ((a.*.num_bits & @as(c_int, 7)) != 0) { - _ = _m3dstbi__zreceive(a, a.*.num_bits & @as(c_int, 7)); - } - k = 0; - while (a.*.num_bits > @as(c_int, 0)) { - header[@as(c_uint, @intCast(blk: { - const ref = &k; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }))] = @as(u8, @bitCast(@as(u8, @truncate(a.*.code_buffer & @as(_m3dstbi__uint32, @bitCast(@as(c_int, 255))))))); - a.*.code_buffer >>= @intCast(@as(c_int, 8)); - a.*.num_bits -= @as(c_int, 8); - } - while (k < @as(c_int, 4)) { - header[@as(c_uint, @intCast(blk: { - const ref = &k; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }))] = _m3dstbi__zget8(a); - } - len = (@as(c_int, @bitCast(@as(c_uint, header[@as(c_uint, @intCast(@as(c_int, 1)))]))) * @as(c_int, 256)) + @as(c_int, @bitCast(@as(c_uint, header[@as(c_uint, @intCast(@as(c_int, 0)))]))); - nlen = (@as(c_int, @bitCast(@as(c_uint, header[@as(c_uint, @intCast(@as(c_int, 3)))]))) * @as(c_int, 256)) + @as(c_int, @bitCast(@as(c_uint, header[@as(c_uint, @intCast(@as(c_int, 2)))]))); - if (nlen != (len ^ @as(c_int, 65535))) return _m3dstbi__errstr("Corrupt PNG"); - if ((a.*.zbuffer + @as(usize, @bitCast(@as(isize, @intCast(len))))) > a.*.zbuffer_end) return _m3dstbi__errstr("Corrupt PNG"); - if ((a.*.zout + @as(usize, @bitCast(@as(isize, @intCast(len))))) > a.*.zout_end) if (!(_m3dstbi__zexpand(a, a.*.zout, len) != 0)) return 0; - _ = memcpy(@as(?*anyopaque, @ptrCast(a.*.zout)), @as(?*const anyopaque, @ptrCast(a.*.zbuffer)), @as(c_ulong, @bitCast(@as(c_long, len)))); - a.*.zbuffer += @as(usize, @bitCast(@as(isize, @intCast(len)))); - a.*.zout += @as(usize, @bitCast(@as(isize, @intCast(len)))); - return 1; -} -pub fn _m3dstbi__parse_zlib_header(arg_a: [*c]_m3dstbi__zbuf) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var cmf: c_int = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__zget8(a)))); - _ = &cmf; - var cm: c_int = cmf & @as(c_int, 15); - _ = &cm; - var flg: c_int = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__zget8(a)))); - _ = &flg; - if (@import("std").zig.c_translation.signedRemainder((cmf * @as(c_int, 256)) + flg, @as(c_int, 31)) != @as(c_int, 0)) return _m3dstbi__errstr("Corrupt PNG"); - if ((flg & @as(c_int, 32)) != 0) return _m3dstbi__errstr("Corrupt PNG"); - if (cm != @as(c_int, 8)) return _m3dstbi__errstr("Corrupt PNG"); - return 1; -} -pub var _m3dstbi__zdefault_length: [288]u8 = @import("std").mem.zeroes([288]u8); -pub var _m3dstbi__zdefault_distance: [32]u8 = @import("std").mem.zeroes([32]u8); -pub fn _m3dstbi__init_zdefaults() callconv(.C) void { - var i: c_int = undefined; - _ = &i; - { - i = 0; - while (i <= @as(c_int, 143)) : (i += 1) { - _m3dstbi__zdefault_length[@as(c_uint, @intCast(i))] = 8; - } - } - while (i <= @as(c_int, 255)) : (i += 1) { - _m3dstbi__zdefault_length[@as(c_uint, @intCast(i))] = 9; - } - while (i <= @as(c_int, 279)) : (i += 1) { - _m3dstbi__zdefault_length[@as(c_uint, @intCast(i))] = 7; - } - while (i <= @as(c_int, 287)) : (i += 1) { - _m3dstbi__zdefault_length[@as(c_uint, @intCast(i))] = 8; - } - { - i = 0; - while (i <= @as(c_int, 31)) : (i += 1) { - _m3dstbi__zdefault_distance[@as(c_uint, @intCast(i))] = 5; - } - } -} -pub fn _m3dstbi__parse_zlib(arg_a: [*c]_m3dstbi__zbuf, arg_parse_header: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var parse_header = arg_parse_header; - _ = &parse_header; - var final: c_int = undefined; - _ = &final; - var @"type": c_int = undefined; - _ = &@"type"; - if (parse_header != 0) if (!(_m3dstbi__parse_zlib_header(a) != 0)) return 0; - a.*.num_bits = 0; - a.*.code_buffer = 0; - while (true) { - final = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 1)))); - @"type" = @as(c_int, @bitCast(_m3dstbi__zreceive(a, @as(c_int, 2)))); - if (@"type" == @as(c_int, 0)) { - if (!(_m3dstbi__parse_uncompressed_block(a) != 0)) return 0; - } else if (@"type" == @as(c_int, 3)) { - return 0; - } else { - if (@"type" == @as(c_int, 1)) { - if (!(_m3dstbi__zbuild_huffman(&a.*.z_length, @as([*c]u8, @ptrCast(@alignCast(&_m3dstbi__zdefault_length))), @as(c_int, 288)) != 0)) return 0; - if (!(_m3dstbi__zbuild_huffman(&a.*.z_distance, @as([*c]u8, @ptrCast(@alignCast(&_m3dstbi__zdefault_distance))), @as(c_int, 32)) != 0)) return 0; - } else { - if (!(_m3dstbi__compute_huffman_codes(a) != 0)) return 0; - } - if (!(_m3dstbi__parse_huffman_block(a) != 0)) return 0; - } - if (!!(final != 0)) break; - } - return 1; -} -pub fn _m3dstbi__do_zlib(arg_a: [*c]_m3dstbi__zbuf, arg_obuf: [*c]u8, arg_olen: c_int, arg_exp_1: c_int, arg_parse_header: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var obuf = arg_obuf; - _ = &obuf; - var olen = arg_olen; - _ = &olen; - var exp_1 = arg_exp_1; - _ = &exp_1; - var parse_header = arg_parse_header; - _ = &parse_header; - a.*.zout_start = obuf; - a.*.zout = obuf; - a.*.zout_end = obuf + @as(usize, @bitCast(@as(isize, @intCast(olen)))); - a.*.z_expandable = exp_1; - _m3dstbi__init_zdefaults(); - return _m3dstbi__parse_zlib(a, parse_header); -} -pub export fn _m3dstbi_zlib_decode_malloc_guesssize_headerflag(arg_buffer: [*c]const u8, arg_len: c_int, arg_initial_size: c_int, arg_outlen: [*c]c_int, arg_parse_header: c_int) [*c]u8 { - var buffer = arg_buffer; - _ = &buffer; - var len = arg_len; - _ = &len; - var initial_size = arg_initial_size; - _ = &initial_size; - var outlen = arg_outlen; - _ = &outlen; - var parse_header = arg_parse_header; - _ = &parse_header; - var a: _m3dstbi__zbuf = undefined; - _ = &a; - var p: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi__malloc(@as(usize, @bitCast(@as(c_long, initial_size))))))); - _ = &p; - if (p == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return null; - a.zbuffer = @as([*c]u8, @ptrCast(@volatileCast(@constCast(buffer)))); - a.zbuffer_end = @as([*c]u8, @ptrCast(@volatileCast(@constCast(buffer)))) + @as(usize, @bitCast(@as(isize, @intCast(len)))); - if (_m3dstbi__do_zlib(&a, p, initial_size, @as(c_int, 1), parse_header) != 0) { - if (outlen != null) { - outlen.* = @as(c_int, @bitCast(@as(c_int, @truncate(@divExact(@as(c_long, @bitCast(@intFromPtr(a.zout) -% @intFromPtr(a.zout_start))), @sizeOf(u8)))))); - } - return a.zout_start; - } else { - free(@as(?*anyopaque, @ptrCast(a.zout_start))); - return null; - } - return null; -} -pub const _m3dstbi__pngchunk = extern struct { - length: _m3dstbi__uint32 = @import("std").mem.zeroes(_m3dstbi__uint32), - type: _m3dstbi__uint32 = @import("std").mem.zeroes(_m3dstbi__uint32), -}; -pub fn _m3dstbi__get_chunk_header(arg_s: [*c]_m3dstbi__context) callconv(.C) _m3dstbi__pngchunk { - var s = arg_s; - _ = &s; - var c: _m3dstbi__pngchunk = undefined; - _ = &c; - c.length = _m3dstbi__get32be(s); - c.type = _m3dstbi__get32be(s); - return c; -} -pub fn _m3dstbi__check_png_header(arg_s: [*c]_m3dstbi__context) callconv(.C) c_int { - var s = arg_s; - _ = &s; - const png_sig = struct { - var static: [8]u8 = [8]u8{ - 137, - 80, - 78, - 71, - 13, - 10, - 26, - 10, - }; - }; - _ = &png_sig; - var i: c_int = undefined; - _ = &i; - { - i = 0; - while (i < @as(c_int, 8)) : (i += 1) if (@as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))) != @as(c_int, @bitCast(@as(c_uint, png_sig.static[@as(c_uint, @intCast(i))])))) return _m3dstbi__errstr("Not a PNG"); - } - return 1; -} -pub const _m3dstbi__png = extern struct { - s: [*c]_m3dstbi__context = @import("std").mem.zeroes([*c]_m3dstbi__context), - idata: [*c]u8 = @import("std").mem.zeroes([*c]u8), - expanded: [*c]u8 = @import("std").mem.zeroes([*c]u8), - out: [*c]u8 = @import("std").mem.zeroes([*c]u8), - depth: c_int = @import("std").mem.zeroes(c_int), -}; -pub const STBI__F_none: c_int = 0; -pub const STBI__F_sub: c_int = 1; -pub const STBI__F_up: c_int = 2; -pub const STBI__F_avg: c_int = 3; -pub const STBI__F_paeth: c_int = 4; -pub const STBI__F_avg_first: c_int = 5; -pub const STBI__F_paeth_first: c_int = 6; -const enum_unnamed_15 = c_uint; -pub var first_row_filter: [5]u8 = [5]u8{ - @as(u8, @bitCast(@as(i8, @truncate(STBI__F_none)))), - @as(u8, @bitCast(@as(i8, @truncate(STBI__F_sub)))), - @as(u8, @bitCast(@as(i8, @truncate(STBI__F_none)))), - @as(u8, @bitCast(@as(i8, @truncate(STBI__F_avg_first)))), - @as(u8, @bitCast(@as(i8, @truncate(STBI__F_paeth_first)))), -}; -pub fn _m3dstbi__paeth(arg_a: c_int, arg_b: c_int, arg_c: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var c = arg_c; - _ = &c; - var p: c_int = (a + b) - c; - _ = &p; - var pa: c_int = abs(p - a); - _ = &pa; - var pb: c_int = abs(p - b); - _ = &pb; - var pc: c_int = abs(p - c); - _ = &pc; - if ((pa <= pb) and (pa <= pc)) return a; - if (pb <= pc) return b; - return c; -} -pub var _m3dstbi__depth_scale_table: [9]u8 = [9]u8{ - 0, - 255, - 85, - 0, - 17, - 0, - 0, - 0, - 1, -}; -pub fn _m3dstbi__create_png_image_raw(arg_a: [*c]_m3dstbi__png, arg_raw: [*c]u8, arg_raw_len: _m3dstbi__uint32, arg_out_n: c_int, arg_x: _m3dstbi__uint32, arg_y: _m3dstbi__uint32, arg_depth: c_int, arg_color: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var raw = arg_raw; - _ = &raw; - var raw_len = arg_raw_len; - _ = &raw_len; - var out_n = arg_out_n; - _ = &out_n; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var depth = arg_depth; - _ = &depth; - var color = arg_color; - _ = &color; - var bytes: c_int = if (depth == @as(c_int, 16)) @as(c_int, 2) else @as(c_int, 1); - _ = &bytes; - var s: [*c]_m3dstbi__context = a.*.s; - _ = &s; - var i: _m3dstbi__uint32 = undefined; - _ = &i; - var j: _m3dstbi__uint32 = undefined; - _ = &j; - var stride: _m3dstbi__uint32 = (x *% @as(_m3dstbi__uint32, @bitCast(out_n))) *% @as(_m3dstbi__uint32, @bitCast(bytes)); - _ = &stride; - var img_len: _m3dstbi__uint32 = undefined; - _ = &img_len; - var img_width_bytes: _m3dstbi__uint32 = undefined; - _ = &img_width_bytes; - var k: c_int = undefined; - _ = &k; - var img_n: c_int = s.*.img_n; - _ = &img_n; - var output_bytes: c_int = out_n * bytes; - _ = &output_bytes; - var filter_bytes: c_int = img_n * bytes; - _ = &filter_bytes; - var width: c_int = @as(c_int, @bitCast(x)); - _ = &width; - a.*.out = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi__malloc_mad3(@as(c_int, @bitCast(x)), @as(c_int, @bitCast(y)), output_bytes, @as(c_int, 0))))); - if (!(a.*.out != null)) return _m3dstbi__errstr("Out of memory"); - if (!(_m3dstbi__mad3sizes_valid(img_n, @as(c_int, @bitCast(x)), depth, @as(c_int, 7)) != 0)) return _m3dstbi__errstr("Corrupt PNG"); - img_width_bytes = (((@as(_m3dstbi__uint32, @bitCast(img_n)) *% x) *% @as(_m3dstbi__uint32, @bitCast(depth))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 7)))) >> @intCast(3); - img_len = (img_width_bytes +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) *% y; - if ((s.*.img_x == x) and (s.*.img_y == y)) { - if (raw_len != img_len) return _m3dstbi__errstr("Corrupt PNG"); - } else { - if (raw_len < img_len) return _m3dstbi__errstr("Corrupt PNG"); - } - { - j = 0; - while (j < y) : (j +%= 1) { - var cur: [*c]u8 = a.*.out + (stride *% j); - _ = &cur; - var prior: [*c]u8 = cur - stride; - _ = &prior; - var filter: c_int = @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &raw; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &filter; - if (filter > @as(c_int, 4)) return _m3dstbi__errstr("Corrupt PNG"); - if (depth < @as(c_int, 8)) { - cur += @as([*c]u8, @ptrFromInt((x *% @as(_m3dstbi__uint32, @bitCast(out_n))) -% img_width_bytes)); - filter_bytes = 1; - width = @as(c_int, @bitCast(img_width_bytes)); - } - prior = cur - stride; - if (j == @as(_m3dstbi__uint32, @bitCast(@as(c_int, 0)))) { - filter = @as(c_int, @bitCast(@as(c_uint, first_row_filter[@as(c_uint, @intCast(filter))]))); - } - { - k = 0; - while (k < filter_bytes) : (k += 1) { - while (true) { - switch (filter) { - @as(c_int, 0) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - break; - }, - @as(c_int, 1) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - break; - }, - @as(c_int, 2) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) & @as(c_int, 255))))); - break; - }, - @as(c_int, 3) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) >> @intCast(1))) & @as(c_int, 255))))); - break; - }, - @as(c_int, 4) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + _m3dstbi__paeth(@as(c_int, 0), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, 0))) & @as(c_int, 255))))); - break; - }, - @as(c_int, 5) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - break; - }, - @as(c_int, 6) => { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - break; - }, - else => {}, - } - break; - } - } - } - if (depth == @as(c_int, 8)) { - if (img_n != out_n) { - (blk: { - const tmp = img_n; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - } - raw += @as(usize, @bitCast(@as(isize, @intCast(img_n)))); - cur += @as(usize, @bitCast(@as(isize, @intCast(out_n)))); - prior += @as(usize, @bitCast(@as(isize, @intCast(out_n)))); - } else if (depth == @as(c_int, 16)) { - if (img_n != out_n) { - (blk: { - const tmp = filter_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - (blk: { - const tmp = filter_bytes + @as(c_int, 1); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - } - raw += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - cur += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - prior += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - } else { - raw += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - cur += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - prior += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))); - } - if ((depth < @as(c_int, 8)) or (img_n == out_n)) { - var nk: c_int = (width - @as(c_int, 1)) * filter_bytes; - _ = &nk; - while (true) { - switch (filter) { - @as(c_int, 0) => { - _ = memcpy(@as(?*anyopaque, @ptrCast(cur)), @as(?*const anyopaque, @ptrCast(raw)), @as(c_ulong, @bitCast(@as(c_long, nk)))); - break; - }, - @as(c_int, 1) => { - { - k = 0; - while (k < nk) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - filter_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) & @as(c_int, 255))))); - } - } - break; - }, - @as(c_int, 2) => { - { - k = 0; - while (k < nk) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) & @as(c_int, 255))))); - } - } - break; - }, - @as(c_int, 3) => { - { - k = 0; - while (k < nk) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + ((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - filter_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) >> @intCast(1))) & @as(c_int, 255))))); - } - } - break; - }, - @as(c_int, 4) => { - { - k = 0; - while (k < nk) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + _m3dstbi__paeth(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - filter_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - filter_bytes; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) & @as(c_int, 255))))); - } - } - break; - }, - @as(c_int, 5) => { - { - k = 0; - while (k < nk) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - filter_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) >> @intCast(1))) & @as(c_int, 255))))); - } - } - break; - }, - @as(c_int, 6) => { - { - k = 0; - while (k < nk) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + _m3dstbi__paeth(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - filter_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, 0), @as(c_int, 0))) & @as(c_int, 255))))); - } - } - break; - }, - else => {}, - } - break; - } - raw += @as(usize, @bitCast(@as(isize, @intCast(nk)))); - } else { - while (true) { - switch (filter) { - @as(c_int, 0) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - } - break; - }, - @as(c_int, 1) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - output_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) & @as(c_int, 255))))); - } - } - } - break; - }, - @as(c_int, 2) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) & @as(c_int, 255))))); - } - } - } - break; - }, - @as(c_int, 3) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + ((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - output_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))) >> @intCast(1))) & @as(c_int, 255))))); - } - } - } - break; - }, - @as(c_int, 4) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + _m3dstbi__paeth(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - output_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - output_bytes; - if (tmp >= 0) break :blk prior + @as(usize, @intCast(tmp)) else break :blk prior - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) & @as(c_int, 255))))); - } - } - } - break; - }, - @as(c_int, 5) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - output_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) >> @intCast(1))) & @as(c_int, 255))))); - } - } - } - break; - }, - @as(c_int, 6) => { - { - i = x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))); - while (i >= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) : (_ = blk: { - _ = blk_1: { - _ = blk_2: { - _ = blk_3: { - i -%= 1; - break :blk_3 blk_4: { - const tmp = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))); - (blk_5: { - const tmp_6 = filter_bytes; - if (tmp_6 >= 0) break :blk_5 cur + @as(usize, @intCast(tmp_6)) else break :blk_5 cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_6)) +% -1)); - }).* = tmp; - break :blk_4 tmp; - }; - }; - break :blk_2 blk_3: { - const ref = &raw; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(filter_bytes)))); - break :blk_3 ref.*; - }; - }; - break :blk_1 blk_2: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &prior; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - k = 0; - while (k < filter_bytes) : (k += 1) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(i8, @truncate((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k; - if (tmp >= 0) break :blk raw + @as(usize, @intCast(tmp)) else break :blk raw - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) + _m3dstbi__paeth(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = k - output_bytes; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))), @as(c_int, 0), @as(c_int, 0))) & @as(c_int, 255))))); - } - } - } - break; - }, - else => {}, - } - break; - } - if (depth == @as(c_int, 16)) { - cur = a.*.out + (stride *% j); - { - i = 0; - while (i < x) : (_ = blk: { - i +%= 1; - break :blk blk_1: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(output_bytes)))); - break :blk_1 ref.*; - }; - }) { - (blk: { - const tmp = filter_bytes + @as(c_int, 1); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - } - } - } - } - } - } - if (depth < @as(c_int, 8)) { - { - j = 0; - while (j < y) : (j +%= 1) { - var cur: [*c]u8 = a.*.out + (stride *% j); - _ = &cur; - var in: [*c]u8 = ((a.*.out + (stride *% j)) + (x *% @as(_m3dstbi__uint32, @bitCast(out_n)))) - img_width_bytes; - _ = ∈ - var scale: u8 = @as(u8, @bitCast(@as(i8, @truncate(if (color == @as(c_int, 0)) @as(c_int, @bitCast(@as(c_uint, _m3dstbi__depth_scale_table[@as(c_uint, @intCast(depth))]))) else @as(c_int, 1))))); - _ = &scale; - if (depth == @as(c_int, 4)) { - { - k = @as(c_int, @bitCast(x *% @as(_m3dstbi__uint32, @bitCast(img_n)))); - while (k >= @as(c_int, 2)) : (_ = blk: { - k -= @as(c_int, 2); - break :blk blk_1: { - const ref = ∈ - ref.* += 1; - break :blk_1 ref.*; - }; - }) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(4)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) & @as(c_int, 15)))))); - } - } - if (k > @as(c_int, 0)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(4)))))); - } - } else if (depth == @as(c_int, 2)) { - { - k = @as(c_int, @bitCast(x *% @as(_m3dstbi__uint32, @bitCast(img_n)))); - while (k >= @as(c_int, 4)) : (_ = blk: { - k -= @as(c_int, 4); - break :blk blk_1: { - const ref = ∈ - ref.* += 1; - break :blk_1 ref.*; - }; - }) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(6)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(4)) & @as(c_int, 3)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(2)) & @as(c_int, 3)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) & @as(c_int, 3)))))); - } - } - if (k > @as(c_int, 0)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(6)))))); - } - if (k > @as(c_int, 1)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(4)) & @as(c_int, 3)))))); - } - if (k > @as(c_int, 2)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(2)) & @as(c_int, 3)))))); - } - } else if (depth == @as(c_int, 1)) { - { - k = @as(c_int, @bitCast(x *% @as(_m3dstbi__uint32, @bitCast(img_n)))); - while (k >= @as(c_int, 8)) : (_ = blk: { - k -= @as(c_int, 8); - break :blk blk_1: { - const ref = ∈ - ref.* += 1; - break :blk_1 ref.*; - }; - }) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(7)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(6)) & @as(c_int, 1)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(5)) & @as(c_int, 1)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(4)) & @as(c_int, 1)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(3)) & @as(c_int, 1)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(2)) & @as(c_int, 1)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(1)) & @as(c_int, 1)))))); - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) & @as(c_int, 1)))))); - } - } - if (k > @as(c_int, 0)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * (@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(7)))))); - } - if (k > @as(c_int, 1)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(6)) & @as(c_int, 1)))))); - } - if (k > @as(c_int, 2)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(5)) & @as(c_int, 1)))))); - } - if (k > @as(c_int, 3)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(4)) & @as(c_int, 1)))))); - } - if (k > @as(c_int, 4)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(3)) & @as(c_int, 1)))))); - } - if (k > @as(c_int, 5)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(2)) & @as(c_int, 1)))))); - } - if (k > @as(c_int, 6)) { - (blk: { - const ref = &cur; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, scale))) * ((@as(c_int, @bitCast(@as(c_uint, in.*))) >> @intCast(1)) & @as(c_int, 1)))))); - } - } - if (img_n != out_n) { - var q: c_int = undefined; - _ = &q; - cur = a.*.out + (stride *% j); - if (img_n == @as(c_int, 1)) { - { - q = @as(c_int, @bitCast(x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))))); - while (q >= @as(c_int, 0)) : (q -= 1) { - (blk: { - const tmp = (q * @as(c_int, 2)) + @as(c_int, 1); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - (blk: { - const tmp = (q * @as(c_int, 2)) + @as(c_int, 0); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = q; - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - } else { - { - q = @as(c_int, @bitCast(x -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1))))); - while (q >= @as(c_int, 0)) : (q -= 1) { - (blk: { - const tmp = (q * @as(c_int, 4)) + @as(c_int, 3); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - (blk: { - const tmp = (q * @as(c_int, 4)) + @as(c_int, 2); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (q * @as(c_int, 3)) + @as(c_int, 2); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (q * @as(c_int, 4)) + @as(c_int, 1); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (q * @as(c_int, 3)) + @as(c_int, 1); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - (blk: { - const tmp = (q * @as(c_int, 4)) + @as(c_int, 0); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = (q * @as(c_int, 3)) + @as(c_int, 0); - if (tmp >= 0) break :blk cur + @as(usize, @intCast(tmp)) else break :blk cur - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - } - } - } - } - } else if (depth == @as(c_int, 16)) { - var cur: [*c]u8 = a.*.out; - _ = &cur; - var cur16: [*c]_m3dstbi__uint16 = @as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(cur))); - _ = &cur16; - { - i = 0; - while (i < ((x *% y) *% @as(_m3dstbi__uint32, @bitCast(out_n)))) : (_ = blk: { - _ = blk_1: { - i +%= 1; - break :blk_1 blk_2: { - const ref = &cur16; - const tmp = ref.*; - ref.* += 1; - break :blk_2 tmp; - }; - }; - break :blk blk_1: { - const ref = &cur; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break :blk_1 ref.*; - }; - }) { - cur16.* = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate((@as(c_int, @bitCast(@as(c_uint, cur[@as(c_uint, @intCast(@as(c_int, 0)))]))) << @intCast(8)) | @as(c_int, @bitCast(@as(c_uint, cur[@as(c_uint, @intCast(@as(c_int, 1)))]))))))); - } - } - } - return 1; -} -pub fn _m3dstbi__create_png_image(arg_a: [*c]_m3dstbi__png, arg_image_data: [*c]u8, arg_image_data_len: _m3dstbi__uint32, arg_out_n: c_int, arg_depth: c_int, arg_color: c_int, arg_interlaced: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var image_data = arg_image_data; - _ = &image_data; - var image_data_len = arg_image_data_len; - _ = &image_data_len; - var out_n = arg_out_n; - _ = &out_n; - var depth = arg_depth; - _ = &depth; - var color = arg_color; - _ = &color; - var interlaced = arg_interlaced; - _ = &interlaced; - var bytes: c_int = if (depth == @as(c_int, 16)) @as(c_int, 2) else @as(c_int, 1); - _ = &bytes; - var out_bytes: c_int = out_n * bytes; - _ = &out_bytes; - var final: [*c]u8 = undefined; - _ = &final; - var p: c_int = undefined; - _ = &p; - if (!(interlaced != 0)) return _m3dstbi__create_png_image_raw(a, image_data, image_data_len, out_n, a.*.s.*.img_x, a.*.s.*.img_y, depth, color); - final = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi__malloc_mad3(@as(c_int, @bitCast(a.*.s.*.img_x)), @as(c_int, @bitCast(a.*.s.*.img_y)), out_bytes, @as(c_int, 0))))); - { - p = 0; - while (p < @as(c_int, 7)) : (p += 1) { - var xorig: [7]c_int = [7]c_int{ - 0, - 4, - 0, - 2, - 0, - 1, - 0, - }; - _ = &xorig; - var yorig: [7]c_int = [7]c_int{ - 0, - 0, - 4, - 0, - 2, - 0, - 1, - }; - _ = &yorig; - var xspc: [7]c_int = [7]c_int{ - 8, - 8, - 4, - 4, - 2, - 2, - 1, - }; - _ = &xspc; - var yspc: [7]c_int = [7]c_int{ - 8, - 8, - 8, - 4, - 4, - 2, - 2, - }; - _ = &yspc; - var i: c_int = undefined; - _ = &i; - var j: c_int = undefined; - _ = &j; - var x: c_int = undefined; - _ = &x; - var y: c_int = undefined; - _ = &y; - x = @as(c_int, @bitCast((((a.*.s.*.img_x -% @as(_m3dstbi__uint32, @bitCast(xorig[@as(c_uint, @intCast(p))]))) +% @as(_m3dstbi__uint32, @bitCast(xspc[@as(c_uint, @intCast(p))]))) -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) / @as(_m3dstbi__uint32, @bitCast(xspc[@as(c_uint, @intCast(p))])))); - y = @as(c_int, @bitCast((((a.*.s.*.img_y -% @as(_m3dstbi__uint32, @bitCast(yorig[@as(c_uint, @intCast(p))]))) +% @as(_m3dstbi__uint32, @bitCast(yspc[@as(c_uint, @intCast(p))]))) -% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))) / @as(_m3dstbi__uint32, @bitCast(yspc[@as(c_uint, @intCast(p))])))); - if ((x != 0) and (y != 0)) { - var img_len: _m3dstbi__uint32 = @as(_m3dstbi__uint32, @bitCast((((((a.*.s.*.img_n * x) * depth) + @as(c_int, 7)) >> @intCast(3)) + @as(c_int, 1)) * y)); - _ = &img_len; - if (!(_m3dstbi__create_png_image_raw(a, image_data, image_data_len, out_n, @as(_m3dstbi__uint32, @bitCast(x)), @as(_m3dstbi__uint32, @bitCast(y)), depth, color) != 0)) { - free(@as(?*anyopaque, @ptrCast(final))); - return 0; - } - { - j = 0; - while (j < y) : (j += 1) { - { - i = 0; - while (i < x) : (i += 1) { - var out_y: c_int = (j * yspc[@as(c_uint, @intCast(p))]) + yorig[@as(c_uint, @intCast(p))]; - _ = &out_y; - var out_x: c_int = (i * xspc[@as(c_uint, @intCast(p))]) + xorig[@as(c_uint, @intCast(p))]; - _ = &out_x; - _ = memcpy(@as(?*anyopaque, @ptrCast((final + ((@as(_m3dstbi__uint32, @bitCast(out_y)) *% a.*.s.*.img_x) *% @as(_m3dstbi__uint32, @bitCast(out_bytes)))) + @as(usize, @bitCast(@as(isize, @intCast(out_x * out_bytes)))))), @as(?*const anyopaque, @ptrCast(a.*.out + @as(usize, @bitCast(@as(isize, @intCast(((j * x) + i) * out_bytes)))))), @as(c_ulong, @bitCast(@as(c_long, out_bytes)))); - } - } - } - } - free(@as(?*anyopaque, @ptrCast(a.*.out))); - image_data += @as([*c]u8, @ptrFromInt(img_len)); - image_data_len -%= img_len; - } - } - } - a.*.out = final; - return 1; -} -pub fn _m3dstbi__compute_transparency(arg_z: [*c]_m3dstbi__png, arg_tc: [*c]u8, arg_out_n: c_int) callconv(.C) c_int { - var z = arg_z; - _ = &z; - var tc = arg_tc; - _ = &tc; - var out_n = arg_out_n; - _ = &out_n; - var s: [*c]_m3dstbi__context = z.*.s; - _ = &s; - var i: _m3dstbi__uint32 = undefined; - _ = &i; - var pixel_count: _m3dstbi__uint32 = s.*.img_x *% s.*.img_y; - _ = &pixel_count; - var p: [*c]u8 = z.*.out; - _ = &p; - if (out_n == @as(c_int, 2)) { - { - i = 0; - while (i < pixel_count) : (i +%= 1) { - p[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(u8, @bitCast(@as(i8, @truncate(if (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 0)))])))) @as(c_int, 0) else @as(c_int, 255))))); - p += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - } - } - } else { - { - i = 0; - while (i < pixel_count) : (i +%= 1) { - if (((@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 0)))])))) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 1)))]))))) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 2)))]))))) { - p[@as(c_uint, @intCast(@as(c_int, 3)))] = 0; - } - p += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - } - } - } - return 1; -} -pub fn _m3dstbi__compute_transparency16(arg_z: [*c]_m3dstbi__png, arg_tc: [*c]_m3dstbi__uint16, arg_out_n: c_int) callconv(.C) c_int { - var z = arg_z; - _ = &z; - var tc = arg_tc; - _ = &tc; - var out_n = arg_out_n; - _ = &out_n; - var s: [*c]_m3dstbi__context = z.*.s; - _ = &s; - var i: _m3dstbi__uint32 = undefined; - _ = &i; - var pixel_count: _m3dstbi__uint32 = s.*.img_x *% s.*.img_y; - _ = &pixel_count; - var p: [*c]_m3dstbi__uint16 = @as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(z.*.out))); - _ = &p; - if (out_n == @as(c_int, 2)) { - { - i = 0; - while (i < pixel_count) : (i +%= 1) { - p[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(if (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 0)))])))) @as(c_int, 0) else @as(c_int, 65535))))); - p += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - } - } - } else { - { - i = 0; - while (i < pixel_count) : (i +%= 1) { - if (((@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 0)))])))) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 1)))]))))) and (@as(c_int, @bitCast(@as(c_uint, p[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, @bitCast(@as(c_uint, tc[@as(c_uint, @intCast(@as(c_int, 2)))]))))) { - p[@as(c_uint, @intCast(@as(c_int, 3)))] = 0; - } - p += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - } - } - } - return 1; -} -pub fn _m3dstbi__expand_png_palette(arg_a: [*c]_m3dstbi__png, arg_palette: [*c]u8, arg_len: c_int, arg_pal_img_n: c_int) callconv(.C) c_int { - var a = arg_a; - _ = &a; - var palette = arg_palette; - _ = &palette; - var len = arg_len; - _ = &len; - var pal_img_n = arg_pal_img_n; - _ = &pal_img_n; - var i: _m3dstbi__uint32 = undefined; - _ = &i; - var pixel_count: _m3dstbi__uint32 = a.*.s.*.img_x *% a.*.s.*.img_y; - _ = &pixel_count; - var p: [*c]u8 = undefined; - _ = &p; - var temp_out: [*c]u8 = undefined; - _ = &temp_out; - var orig: [*c]u8 = a.*.out; - _ = &orig; - p = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi__malloc_mad2(@as(c_int, @bitCast(pixel_count)), pal_img_n, @as(c_int, 0))))); - if (p == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return _m3dstbi__errstr("Out of memory"); - temp_out = p; - if (pal_img_n == @as(c_int, 3)) { - { - i = 0; - while (i < pixel_count) : (i +%= 1) { - var n: c_int = @as(c_int, @bitCast(@as(c_uint, orig[i]))) * @as(c_int, 4); - _ = &n; - p[@as(c_uint, @intCast(@as(c_int, 0)))] = (blk: { - const tmp = n; - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p[@as(c_uint, @intCast(@as(c_int, 1)))] = (blk: { - const tmp = n + @as(c_int, 1); - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p[@as(c_uint, @intCast(@as(c_int, 2)))] = (blk: { - const tmp = n + @as(c_int, 2); - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - } - } - } else { - { - i = 0; - while (i < pixel_count) : (i +%= 1) { - var n: c_int = @as(c_int, @bitCast(@as(c_uint, orig[i]))) * @as(c_int, 4); - _ = &n; - p[@as(c_uint, @intCast(@as(c_int, 0)))] = (blk: { - const tmp = n; - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p[@as(c_uint, @intCast(@as(c_int, 1)))] = (blk: { - const tmp = n + @as(c_int, 1); - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p[@as(c_uint, @intCast(@as(c_int, 2)))] = (blk: { - const tmp = n + @as(c_int, 2); - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p[@as(c_uint, @intCast(@as(c_int, 3)))] = (blk: { - const tmp = n + @as(c_int, 3); - if (tmp >= 0) break :blk palette + @as(usize, @intCast(tmp)) else break :blk palette - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - p += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - } - } - } - free(@as(?*anyopaque, @ptrCast(a.*.out))); - a.*.out = temp_out; - _ = @sizeOf(c_int); - return 1; -} -pub fn _m3dstbi__parse_png_file(arg_z: [*c]_m3dstbi__png, arg_scan: c_int, arg_req_comp: c_int) callconv(.C) c_int { - var z = arg_z; - _ = &z; - var scan = arg_scan; - _ = &scan; - var req_comp = arg_req_comp; - _ = &req_comp; - var palette: [1024]u8 = undefined; - _ = &palette; - var pal_img_n: u8 = 0; - _ = &pal_img_n; - var has_trans: u8 = 0; - _ = &has_trans; - var tc: [3]u8 = undefined; - _ = &tc; - var tc16: [3]_m3dstbi__uint16 = undefined; - _ = &tc16; - var ioff: _m3dstbi__uint32 = 0; - _ = &ioff; - var idata_limit: _m3dstbi__uint32 = 0; - _ = &idata_limit; - var i: _m3dstbi__uint32 = undefined; - _ = &i; - var pal_len: _m3dstbi__uint32 = 0; - _ = &pal_len; - var first: c_int = 1; - _ = &first; - var k: c_int = undefined; - _ = &k; - var interlace: c_int = 0; - _ = &interlace; - var color: c_int = 0; - _ = &color; - var s: [*c]_m3dstbi__context = z.*.s; - _ = &s; - z.*.expanded = null; - z.*.idata = null; - z.*.out = null; - if (!(_m3dstbi__check_png_header(s) != 0)) return 0; - if (scan == STBI__SCAN_type) return 1; - while (true) { - var c: _m3dstbi__pngchunk = _m3dstbi__get_chunk_header(s); - _ = &c; - while (true) { - switch (c.type) { - @as(c_uint, 1130840649) => { - _m3dstbi__skip(s, @as(c_int, @bitCast(c.length))); - break; - }, - @as(c_uint, 1229472850) => { - { - var comp: c_int = undefined; - _ = ∁ - var filter: c_int = undefined; - _ = &filter; - if (!(first != 0)) return _m3dstbi__errstr("Corrupt PNG"); - first = 0; - if (c.length != @as(_m3dstbi__uint32, @bitCast(@as(c_int, 13)))) return _m3dstbi__errstr("Corrupt PNG"); - s.*.img_x = _m3dstbi__get32be(s); - if (s.*.img_x > @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1) << @intCast(24)))) return _m3dstbi__errstr("Very large image (corrupt?)"); - s.*.img_y = _m3dstbi__get32be(s); - if (s.*.img_y > @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1) << @intCast(24)))) return _m3dstbi__errstr("Very large image (corrupt?)"); - z.*.depth = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); - if (((((z.*.depth != @as(c_int, 1)) and (z.*.depth != @as(c_int, 2))) and (z.*.depth != @as(c_int, 4))) and (z.*.depth != @as(c_int, 8))) and (z.*.depth != @as(c_int, 16))) return _m3dstbi__errstr("PNG not supported: 1/2/4/8/16-bit only"); - color = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); - if (color > @as(c_int, 6)) return _m3dstbi__errstr("Corrupt PNG"); - if ((color == @as(c_int, 3)) and (z.*.depth == @as(c_int, 16))) return _m3dstbi__errstr("Corrupt PNG"); - if (color == @as(c_int, 3)) { - pal_img_n = 3; - } else if ((color & @as(c_int, 1)) != 0) return _m3dstbi__errstr("Corrupt PNG"); - comp = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); - if (comp != 0) return _m3dstbi__errstr("Corrupt PNG"); - filter = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); - if (filter != 0) return _m3dstbi__errstr("Corrupt PNG"); - interlace = @as(c_int, @bitCast(@as(c_uint, _m3dstbi__get8(s)))); - if (interlace > @as(c_int, 1)) return _m3dstbi__errstr("Corrupt PNG"); - if (!(s.*.img_x != 0) or !(s.*.img_y != 0)) return _m3dstbi__errstr("Corrupt PNG"); - if (!(pal_img_n != 0)) { - s.*.img_n = (if ((color & @as(c_int, 2)) != 0) @as(c_int, 3) else @as(c_int, 1)) + (if ((color & @as(c_int, 4)) != 0) @as(c_int, 1) else @as(c_int, 0)); - if (((@as(_m3dstbi__uint32, @bitCast(@as(c_int, 1) << @intCast(30))) / s.*.img_x) / @as(_m3dstbi__uint32, @bitCast(s.*.img_n))) < s.*.img_y) return _m3dstbi__errstr("Image too large to decode"); - if (scan == STBI__SCAN_header) return 1; - } else { - s.*.img_n = 1; - if (((@as(_m3dstbi__uint32, @bitCast(@as(c_int, 1) << @intCast(30))) / s.*.img_x) / @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4)))) < s.*.img_y) return _m3dstbi__errstr("Corrupt PNG"); - } - break; - } - }, - @as(c_uint, 1347179589) => { - { - if (first != 0) return _m3dstbi__errstr("Corrupt PNG"); - if (c.length > @as(_m3dstbi__uint32, @bitCast(@as(c_int, 256) * @as(c_int, 3)))) return _m3dstbi__errstr("Corrupt PNG"); - pal_len = c.length / @as(_m3dstbi__uint32, @bitCast(@as(c_int, 3))); - if ((pal_len *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 3)))) != c.length) return _m3dstbi__errstr("Corrupt PNG"); - { - i = 0; - while (i < pal_len) : (i +%= 1) { - palette[(i *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4)))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 0)))] = _m3dstbi__get8(s); - palette[(i *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4)))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1)))] = _m3dstbi__get8(s); - palette[(i *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4)))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 2)))] = _m3dstbi__get8(s); - palette[(i *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4)))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 3)))] = 255; - } - } - break; - } - }, - @as(c_uint, 1951551059) => { - { - if (first != 0) return _m3dstbi__errstr("Corrupt PNG"); - if (z.*.idata != null) return _m3dstbi__errstr("Corrupt PNG"); - if (pal_img_n != 0) { - if (scan == STBI__SCAN_header) { - s.*.img_n = 4; - return 1; - } - if (pal_len == @as(_m3dstbi__uint32, @bitCast(@as(c_int, 0)))) return _m3dstbi__errstr("Corrupt PNG"); - if (c.length > pal_len) return _m3dstbi__errstr("Corrupt PNG"); - pal_img_n = 4; - { - i = 0; - while (i < c.length) : (i +%= 1) { - palette[(i *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4)))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 3)))] = _m3dstbi__get8(s); - } - } - } else { - if (!((s.*.img_n & @as(c_int, 1)) != 0)) return _m3dstbi__errstr("Corrupt PNG"); - if (c.length != (@as(_m3dstbi__uint32, @bitCast(s.*.img_n)) *% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 2))))) return _m3dstbi__errstr("Corrupt PNG"); - has_trans = 1; - if (z.*.depth == @as(c_int, 16)) { - { - k = 0; - while (k < s.*.img_n) : (k += 1) { - tc16[@as(c_uint, @intCast(k))] = @as(_m3dstbi__uint16, @bitCast(@as(c_short, @truncate(_m3dstbi__get16be(s))))); - } - } - } else { - { - k = 0; - while (k < s.*.img_n) : (k += 1) { - tc[@as(c_uint, @intCast(k))] = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, @bitCast(@as(c_uint, @as(u8, @bitCast(@as(i8, @truncate(_m3dstbi__get16be(s) & @as(c_int, 255)))))))) * @as(c_int, @bitCast(@as(c_uint, _m3dstbi__depth_scale_table[@as(c_uint, @intCast(z.*.depth))]))))))); - } - } - } - } - break; - } - }, - @as(c_uint, 1229209940) => { - { - if (first != 0) return _m3dstbi__errstr("Corrupt PNG"); - if ((@as(c_int, @bitCast(@as(c_uint, pal_img_n))) != 0) and !(pal_len != 0)) return _m3dstbi__errstr("Corrupt PNG"); - if (scan == STBI__SCAN_header) { - s.*.img_n = @as(c_int, @bitCast(@as(c_uint, pal_img_n))); - return 1; - } - if (@as(c_int, @bitCast(ioff +% c.length)) < @as(c_int, @bitCast(ioff))) return 0; - if ((ioff +% c.length) > idata_limit) { - var idata_limit_old: _m3dstbi__uint32 = idata_limit; - _ = &idata_limit_old; - var p: [*c]u8 = undefined; - _ = &p; - if (idata_limit == @as(_m3dstbi__uint32, @bitCast(@as(c_int, 0)))) { - idata_limit = if (c.length > @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4096)))) c.length else @as(_m3dstbi__uint32, @bitCast(@as(c_int, 4096))); - } - while ((ioff +% c.length) > idata_limit) { - idata_limit *%= @as(_m3dstbi__uint32, @bitCast(@as(c_int, 2))); - } - _ = @sizeOf(_m3dstbi__uint32); - p = @as([*c]u8, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(z.*.idata)), @as(c_ulong, @bitCast(@as(c_ulong, idata_limit))))))); - if (p == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return _m3dstbi__errstr("Out of memory"); - z.*.idata = p; - } - if (!(_m3dstbi__getn(s, z.*.idata + ioff, @as(c_int, @bitCast(c.length))) != 0)) return _m3dstbi__errstr("Corrupt PNG"); - ioff +%= c.length; - break; - } - }, - @as(c_uint, 1229278788) => { - { - var raw_len: _m3dstbi__uint32 = undefined; - _ = &raw_len; - var bpl: _m3dstbi__uint32 = undefined; - _ = &bpl; - if (first != 0) return _m3dstbi__errstr("Corrupt PNG"); - if (scan != STBI__SCAN_load) return 1; - if (z.*.idata == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return _m3dstbi__errstr("Corrupt PNG"); - bpl = ((s.*.img_x *% @as(_m3dstbi__uint32, @bitCast(z.*.depth))) +% @as(_m3dstbi__uint32, @bitCast(@as(c_int, 7)))) / @as(_m3dstbi__uint32, @bitCast(@as(c_int, 8))); - raw_len = ((bpl *% s.*.img_y) *% @as(_m3dstbi__uint32, @bitCast(s.*.img_n))) +% s.*.img_y; - z.*.expanded = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi_zlib_decode_malloc_guesssize_headerflag(@as([*c]u8, @ptrCast(@alignCast(z.*.idata))), @as(c_int, @bitCast(ioff)), @as(c_int, @bitCast(raw_len)), @as([*c]c_int, @ptrCast(@alignCast(&raw_len))), @as(c_int, 1))))); - if (z.*.expanded == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return 0; - free(@as(?*anyopaque, @ptrCast(z.*.idata))); - z.*.idata = null; - if ((((req_comp == (s.*.img_n + @as(c_int, 1))) and (req_comp != @as(c_int, 3))) and !(pal_img_n != 0)) or (@as(c_int, @bitCast(@as(c_uint, has_trans))) != 0)) { - s.*.img_out_n = s.*.img_n + @as(c_int, 1); - } else { - s.*.img_out_n = s.*.img_n; - } - if (!(_m3dstbi__create_png_image(z, z.*.expanded, raw_len, s.*.img_out_n, z.*.depth, color, interlace) != 0)) return 0; - if (has_trans != 0) { - if (z.*.depth == @as(c_int, 16)) { - if (!(_m3dstbi__compute_transparency16(z, @as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(&tc16))), s.*.img_out_n) != 0)) return 0; - } else { - if (!(_m3dstbi__compute_transparency(z, @as([*c]u8, @ptrCast(@alignCast(&tc))), s.*.img_out_n) != 0)) return 0; - } - } - if (pal_img_n != 0) { - s.*.img_n = @as(c_int, @bitCast(@as(c_uint, pal_img_n))); - s.*.img_out_n = @as(c_int, @bitCast(@as(c_uint, pal_img_n))); - if (req_comp >= @as(c_int, 3)) { - s.*.img_out_n = req_comp; - } - if (!(_m3dstbi__expand_png_palette(z, @as([*c]u8, @ptrCast(@alignCast(&palette))), @as(c_int, @bitCast(pal_len)), s.*.img_out_n) != 0)) return 0; - } else if (has_trans != 0) { - s.*.img_n += 1; - } - free(@as(?*anyopaque, @ptrCast(z.*.expanded))); - z.*.expanded = null; - return 1; - } - }, - else => { - if (first != 0) return _m3dstbi__errstr("Corrupt PNG"); - if ((c.type & @as(_m3dstbi__uint32, @bitCast(@as(c_int, 1) << @intCast(29)))) == @as(_m3dstbi__uint32, @bitCast(@as(c_int, 0)))) { - return _m3dstbi__errstr("PNG not supported: unknown PNG chunk type"); - } - _m3dstbi__skip(s, @as(c_int, @bitCast(c.length))); - break; - }, - } - break; - } - _ = _m3dstbi__get32be(s); - } - return 0; -} -pub fn _m3dstbi__do_png(arg_p: [*c]_m3dstbi__png, arg_x: [*c]c_int, arg_y: [*c]c_int, arg_n: [*c]c_int, arg_req_comp: c_int, arg_ri: [*c]_m3dstbi__result_info) callconv(.C) ?*anyopaque { - var p = arg_p; - _ = &p; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var n = arg_n; - _ = &n; - var req_comp = arg_req_comp; - _ = &req_comp; - var ri = arg_ri; - _ = &ri; - var result: ?*anyopaque = @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - _ = &result; - if ((req_comp < @as(c_int, 0)) or (req_comp > @as(c_int, 4))) { - _ = _m3dstbi__errstr("Internal error"); - return @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - } - if (_m3dstbi__parse_png_file(p, STBI__SCAN_load, req_comp) != 0) { - if (p.*.depth < @as(c_int, 8)) { - ri.*.bits_per_channel = 8; - } else { - ri.*.bits_per_channel = p.*.depth; - } - result = @as(?*anyopaque, @ptrCast(p.*.out)); - p.*.out = null; - if ((req_comp != 0) and (req_comp != p.*.s.*.img_out_n)) { - if (ri.*.bits_per_channel == @as(c_int, 8)) { - result = @as(?*anyopaque, @ptrCast(_m3dstbi__convert_format(@as([*c]u8, @ptrCast(@alignCast(result))), p.*.s.*.img_out_n, req_comp, p.*.s.*.img_x, p.*.s.*.img_y))); - } else { - result = @as(?*anyopaque, @ptrCast(_m3dstbi__convert_format16(@as([*c]_m3dstbi__uint16, @ptrCast(@alignCast(result))), p.*.s.*.img_out_n, req_comp, p.*.s.*.img_x, p.*.s.*.img_y))); - } - p.*.s.*.img_out_n = req_comp; - if (result == @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) return result; - } - x.* = @as(c_int, @bitCast(p.*.s.*.img_x)); - y.* = @as(c_int, @bitCast(p.*.s.*.img_y)); - if (n != null) { - n.* = p.*.s.*.img_n; - } - } - free(@as(?*anyopaque, @ptrCast(p.*.out))); - p.*.out = null; - free(@as(?*anyopaque, @ptrCast(p.*.expanded))); - p.*.expanded = null; - free(@as(?*anyopaque, @ptrCast(p.*.idata))); - p.*.idata = null; - return result; -} -pub fn _m3dstbi__png_load(arg_s: [*c]_m3dstbi__context, arg_x: [*c]c_int, arg_y: [*c]c_int, arg_comp: [*c]c_int, arg_req_comp: c_int, arg_ri: [*c]_m3dstbi__result_info) callconv(.C) ?*anyopaque { - var s = arg_s; - _ = &s; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var comp = arg_comp; - _ = ∁ - var req_comp = arg_req_comp; - _ = &req_comp; - var ri = arg_ri; - _ = &ri; - var p: _m3dstbi__png = undefined; - _ = &p; - p.s = s; - return _m3dstbi__do_png(&p, x, y, comp, req_comp, ri); -} -pub extern fn _m3dstbi_zlib_compress(data: [*c]u8, data_len: c_int, out_len: [*c]c_int, quality: c_int) [*c]u8; -pub export fn _m3d_gettx(arg_model: [*c]m3d_t, arg_readfilecb: m3dread_t, arg_freecb: m3dfree_t, arg_fn: [*c]u8) M3D_INDEX { - var model = arg_model; - _ = &model; - var readfilecb = arg_readfilecb; - _ = &readfilecb; - var freecb = arg_freecb; - _ = &freecb; - var @"fn" = arg_fn; - _ = &@"fn"; - var i: c_uint = undefined; - _ = &i; - var len: c_uint = 0; - _ = &len; - var buff: [*c]u8 = null; - _ = &buff; - var fn2: [*c]u8 = undefined; - _ = &fn2; - var w: c_uint = undefined; - _ = &w; - var h: c_uint = undefined; - _ = &h; - var s: _m3dstbi__context = undefined; - _ = &s; - var ri: _m3dstbi__result_info = undefined; - _ = &ri; - if (!(@"fn" != null) or !(@"fn".* != 0)) return 4294967295; - { - i = 0; - while (i < model.*.numtexture) : (i +%= 1) if (!(strcmp(@"fn", model.*.texture[i].name) != 0)) return i; - } - if (model.*.inlined != null) { - { - i = 0; - while (i < model.*.numinlined) : (i +%= 1) if (!(strcmp(@"fn", model.*.inlined[i].name) != 0)) { - buff = model.*.inlined[i].data; - len = model.*.inlined[i].length; - freecb = null; - break; - }; - } - } - if (!(buff != null) and (readfilecb != null)) { - i = @as(c_uint, @bitCast(@as(c_uint, @truncate(strlen(@"fn"))))); - if ((i < @as(c_uint, @bitCast(@as(c_int, 5)))) or (@as(c_int, @bitCast(@as(c_uint, @"fn"[i -% @as(c_uint, @bitCast(@as(c_int, 4)))]))) != @as(c_int, '.'))) { - fn2 = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, i +% @as(c_uint, @bitCast(@as(c_int, 5)))))))))); - if (!(fn2 != null)) { - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))); - return 4294967295; - } - _ = memcpy(@as(?*anyopaque, @ptrCast(fn2)), @as(?*const anyopaque, @ptrCast(@"fn")), @as(c_ulong, @bitCast(@as(c_ulong, i)))); - _ = memcpy(@as(?*anyopaque, @ptrCast(fn2 + i)), @as(?*const anyopaque, @ptrCast(".png")), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5))))); - buff = readfilecb.?(fn2, &len); - free(@as(?*anyopaque, @ptrCast(fn2))); - } - if (!(buff != null)) { - buff = readfilecb.?(@"fn", &len); - if (!(buff != null)) return 4294967295; - } - } - i = blk: { - const ref = &model.*.numtexture; - const tmp = ref.*; - ref.* +%= 1; - break :blk tmp; - }; - model.*.texture = @as([*c]m3dtx_t, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(model.*.texture)), @as(c_ulong, @bitCast(@as(c_ulong, model.*.numtexture))) *% @sizeOf(m3dtx_t))))); - if (!(model.*.texture != null)) { - if ((buff != null) and (freecb != null)) { - freecb.?(@as(?*anyopaque, @ptrCast(buff))); - } - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))); - return 4294967295; - } - model.*.texture[i].name = @"fn"; - model.*.texture[i].w = blk: { - const tmp = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, 0))))); - model.*.texture[i].h = tmp; - break :blk tmp; - }; - model.*.texture[i].d = null; - if (buff != null) { - if ((((@as(c_int, @bitCast(@as(c_uint, buff[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 137)) and (@as(c_int, @bitCast(@as(c_uint, buff[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'P'))) and (@as(c_int, @bitCast(@as(c_uint, buff[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, 'N'))) and (@as(c_int, @bitCast(@as(c_uint, buff[@as(c_uint, @intCast(@as(c_int, 3)))]))) == @as(c_int, 'G'))) { - s.read_from_callbacks = 0; - s.img_buffer = blk: { - const tmp = buff; - s.img_buffer_original = tmp; - break :blk tmp; - }; - s.img_buffer_end = blk: { - const tmp = buff + len; - s.img_buffer_original_end = tmp; - break :blk tmp; - }; - w = blk: { - const tmp = blk_1: { - const tmp_2 = @as(c_uint, @bitCast(@as(c_int, 0))); - len = tmp_2; - break :blk_1 tmp_2; - }; - h = tmp; - break :blk tmp; - }; - ri.bits_per_channel = 8; - model.*.texture[i].d = @as([*c]u8, @ptrCast(@alignCast(_m3dstbi__png_load(&s, @as([*c]c_int, @ptrCast(@alignCast(&w))), @as([*c]c_int, @ptrCast(@alignCast(&h))), @as([*c]c_int, @ptrCast(@alignCast(&len))), @as(c_int, 0), &ri)))); - model.*.texture[i].w = @as(u16, @bitCast(@as(c_ushort, @truncate(w)))); - model.*.texture[i].h = @as(u16, @bitCast(@as(c_ushort, @truncate(h)))); - model.*.texture[i].f = @as(u8, @bitCast(@as(u8, @truncate(len)))); - } else {} - if (freecb != null) { - freecb.?(@as(?*anyopaque, @ptrCast(buff))); - } - } - if (!(model.*.texture[i].d != null)) { - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 68))))); - } - return i; -} -pub export fn _m3d_getpr(arg_model: [*c]m3d_t, arg_readfilecb: m3dread_t, arg_freecb: m3dfree_t, arg_fn: [*c]u8) void { - var model = arg_model; - _ = &model; - var readfilecb = arg_readfilecb; - _ = &readfilecb; - var freecb = arg_freecb; - _ = &freecb; - var @"fn" = arg_fn; - _ = &@"fn"; - _ = &readfilecb; - _ = &freecb; - _ = &@"fn"; - model.*.errcode = @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 65))))); -} -pub fn _m3d_getidx(arg_data: [*c]u8, arg_type: u8, arg_idx: [*c]M3D_INDEX) callconv(.C) [*c]u8 { - var data = arg_data; - _ = &data; - var @"type" = arg_type; - _ = &@"type"; - var idx = arg_idx; - _ = &idx; - while (true) { - switch (@as(c_int, @bitCast(@as(c_uint, @"type")))) { - @as(c_int, 1) => { - idx.* = @as(M3D_INDEX, @bitCast(if (@as(c_int, @bitCast(@as(c_uint, data[@as(c_uint, @intCast(@as(c_int, 0)))]))) > @as(c_int, 253)) @as(c_int, @bitCast(@as(c_int, @as(i8, @bitCast(data[@as(c_uint, @intCast(@as(c_int, 0)))]))))) else @as(c_int, @bitCast(@as(c_uint, data[@as(c_uint, @intCast(@as(c_int, 0)))]))))); - data += 1; - break; - }, - @as(c_int, 2) => { - idx.* = @as(M3D_INDEX, @bitCast(if (@as(c_int, @bitCast(@as(c_uint, @as([*c]u16, @ptrCast(@alignCast(data))).*))) > @as(c_int, 65533)) @as(c_int, @bitCast(@as(c_int, @as([*c]i16, @ptrCast(@alignCast(data))).*))) else @as(c_int, @bitCast(@as(c_uint, @as([*c]u16, @ptrCast(@alignCast(data))).*))))); - data += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - break; - }, - @as(c_int, 4) => { - idx.* = @as(M3D_INDEX, @bitCast(@as([*c]i32, @ptrCast(@alignCast(data))).*)); - data += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break; - }, - else => {}, - } - break; - } - return data; -} -pub export fn _m3d_mul(arg_r: [*c]M3D_FLOAT, arg_a: [*c]M3D_FLOAT, arg_b: [*c]M3D_FLOAT) void { - var r = arg_r; - _ = &r; - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - r[@as(c_uint, @intCast(@as(c_int, 0)))] = (((b[@as(c_uint, @intCast(@as(c_int, 0)))] * a[@as(c_uint, @intCast(@as(c_int, 0)))]) + (b[@as(c_uint, @intCast(@as(c_int, 4)))] * a[@as(c_uint, @intCast(@as(c_int, 1)))])) + (b[@as(c_uint, @intCast(@as(c_int, 8)))] * a[@as(c_uint, @intCast(@as(c_int, 2)))])) + (b[@as(c_uint, @intCast(@as(c_int, 12)))] * a[@as(c_uint, @intCast(@as(c_int, 3)))]); - r[@as(c_uint, @intCast(@as(c_int, 1)))] = (((b[@as(c_uint, @intCast(@as(c_int, 1)))] * a[@as(c_uint, @intCast(@as(c_int, 0)))]) + (b[@as(c_uint, @intCast(@as(c_int, 5)))] * a[@as(c_uint, @intCast(@as(c_int, 1)))])) + (b[@as(c_uint, @intCast(@as(c_int, 9)))] * a[@as(c_uint, @intCast(@as(c_int, 2)))])) + (b[@as(c_uint, @intCast(@as(c_int, 13)))] * a[@as(c_uint, @intCast(@as(c_int, 3)))]); - r[@as(c_uint, @intCast(@as(c_int, 2)))] = (((b[@as(c_uint, @intCast(@as(c_int, 2)))] * a[@as(c_uint, @intCast(@as(c_int, 0)))]) + (b[@as(c_uint, @intCast(@as(c_int, 6)))] * a[@as(c_uint, @intCast(@as(c_int, 1)))])) + (b[@as(c_uint, @intCast(@as(c_int, 10)))] * a[@as(c_uint, @intCast(@as(c_int, 2)))])) + (b[@as(c_uint, @intCast(@as(c_int, 14)))] * a[@as(c_uint, @intCast(@as(c_int, 3)))]); - r[@as(c_uint, @intCast(@as(c_int, 3)))] = (((b[@as(c_uint, @intCast(@as(c_int, 3)))] * a[@as(c_uint, @intCast(@as(c_int, 0)))]) + (b[@as(c_uint, @intCast(@as(c_int, 7)))] * a[@as(c_uint, @intCast(@as(c_int, 1)))])) + (b[@as(c_uint, @intCast(@as(c_int, 11)))] * a[@as(c_uint, @intCast(@as(c_int, 2)))])) + (b[@as(c_uint, @intCast(@as(c_int, 15)))] * a[@as(c_uint, @intCast(@as(c_int, 3)))]); - r[@as(c_uint, @intCast(@as(c_int, 4)))] = (((b[@as(c_uint, @intCast(@as(c_int, 0)))] * a[@as(c_uint, @intCast(@as(c_int, 4)))]) + (b[@as(c_uint, @intCast(@as(c_int, 4)))] * a[@as(c_uint, @intCast(@as(c_int, 5)))])) + (b[@as(c_uint, @intCast(@as(c_int, 8)))] * a[@as(c_uint, @intCast(@as(c_int, 6)))])) + (b[@as(c_uint, @intCast(@as(c_int, 12)))] * a[@as(c_uint, @intCast(@as(c_int, 7)))]); - r[@as(c_uint, @intCast(@as(c_int, 5)))] = (((b[@as(c_uint, @intCast(@as(c_int, 1)))] * a[@as(c_uint, @intCast(@as(c_int, 4)))]) + (b[@as(c_uint, @intCast(@as(c_int, 5)))] * a[@as(c_uint, @intCast(@as(c_int, 5)))])) + (b[@as(c_uint, @intCast(@as(c_int, 9)))] * a[@as(c_uint, @intCast(@as(c_int, 6)))])) + (b[@as(c_uint, @intCast(@as(c_int, 13)))] * a[@as(c_uint, @intCast(@as(c_int, 7)))]); - r[@as(c_uint, @intCast(@as(c_int, 6)))] = (((b[@as(c_uint, @intCast(@as(c_int, 2)))] * a[@as(c_uint, @intCast(@as(c_int, 4)))]) + (b[@as(c_uint, @intCast(@as(c_int, 6)))] * a[@as(c_uint, @intCast(@as(c_int, 5)))])) + (b[@as(c_uint, @intCast(@as(c_int, 10)))] * a[@as(c_uint, @intCast(@as(c_int, 6)))])) + (b[@as(c_uint, @intCast(@as(c_int, 14)))] * a[@as(c_uint, @intCast(@as(c_int, 7)))]); - r[@as(c_uint, @intCast(@as(c_int, 7)))] = (((b[@as(c_uint, @intCast(@as(c_int, 3)))] * a[@as(c_uint, @intCast(@as(c_int, 4)))]) + (b[@as(c_uint, @intCast(@as(c_int, 7)))] * a[@as(c_uint, @intCast(@as(c_int, 5)))])) + (b[@as(c_uint, @intCast(@as(c_int, 11)))] * a[@as(c_uint, @intCast(@as(c_int, 6)))])) + (b[@as(c_uint, @intCast(@as(c_int, 15)))] * a[@as(c_uint, @intCast(@as(c_int, 7)))]); - r[@as(c_uint, @intCast(@as(c_int, 8)))] = (((b[@as(c_uint, @intCast(@as(c_int, 0)))] * a[@as(c_uint, @intCast(@as(c_int, 8)))]) + (b[@as(c_uint, @intCast(@as(c_int, 4)))] * a[@as(c_uint, @intCast(@as(c_int, 9)))])) + (b[@as(c_uint, @intCast(@as(c_int, 8)))] * a[@as(c_uint, @intCast(@as(c_int, 10)))])) + (b[@as(c_uint, @intCast(@as(c_int, 12)))] * a[@as(c_uint, @intCast(@as(c_int, 11)))]); - r[@as(c_uint, @intCast(@as(c_int, 9)))] = (((b[@as(c_uint, @intCast(@as(c_int, 1)))] * a[@as(c_uint, @intCast(@as(c_int, 8)))]) + (b[@as(c_uint, @intCast(@as(c_int, 5)))] * a[@as(c_uint, @intCast(@as(c_int, 9)))])) + (b[@as(c_uint, @intCast(@as(c_int, 9)))] * a[@as(c_uint, @intCast(@as(c_int, 10)))])) + (b[@as(c_uint, @intCast(@as(c_int, 13)))] * a[@as(c_uint, @intCast(@as(c_int, 11)))]); - r[@as(c_uint, @intCast(@as(c_int, 10)))] = (((b[@as(c_uint, @intCast(@as(c_int, 2)))] * a[@as(c_uint, @intCast(@as(c_int, 8)))]) + (b[@as(c_uint, @intCast(@as(c_int, 6)))] * a[@as(c_uint, @intCast(@as(c_int, 9)))])) + (b[@as(c_uint, @intCast(@as(c_int, 10)))] * a[@as(c_uint, @intCast(@as(c_int, 10)))])) + (b[@as(c_uint, @intCast(@as(c_int, 14)))] * a[@as(c_uint, @intCast(@as(c_int, 11)))]); - r[@as(c_uint, @intCast(@as(c_int, 11)))] = (((b[@as(c_uint, @intCast(@as(c_int, 3)))] * a[@as(c_uint, @intCast(@as(c_int, 8)))]) + (b[@as(c_uint, @intCast(@as(c_int, 7)))] * a[@as(c_uint, @intCast(@as(c_int, 9)))])) + (b[@as(c_uint, @intCast(@as(c_int, 11)))] * a[@as(c_uint, @intCast(@as(c_int, 10)))])) + (b[@as(c_uint, @intCast(@as(c_int, 15)))] * a[@as(c_uint, @intCast(@as(c_int, 11)))]); - r[@as(c_uint, @intCast(@as(c_int, 12)))] = (((b[@as(c_uint, @intCast(@as(c_int, 0)))] * a[@as(c_uint, @intCast(@as(c_int, 12)))]) + (b[@as(c_uint, @intCast(@as(c_int, 4)))] * a[@as(c_uint, @intCast(@as(c_int, 13)))])) + (b[@as(c_uint, @intCast(@as(c_int, 8)))] * a[@as(c_uint, @intCast(@as(c_int, 14)))])) + (b[@as(c_uint, @intCast(@as(c_int, 12)))] * a[@as(c_uint, @intCast(@as(c_int, 15)))]); - r[@as(c_uint, @intCast(@as(c_int, 13)))] = (((b[@as(c_uint, @intCast(@as(c_int, 1)))] * a[@as(c_uint, @intCast(@as(c_int, 12)))]) + (b[@as(c_uint, @intCast(@as(c_int, 5)))] * a[@as(c_uint, @intCast(@as(c_int, 13)))])) + (b[@as(c_uint, @intCast(@as(c_int, 9)))] * a[@as(c_uint, @intCast(@as(c_int, 14)))])) + (b[@as(c_uint, @intCast(@as(c_int, 13)))] * a[@as(c_uint, @intCast(@as(c_int, 15)))]); - r[@as(c_uint, @intCast(@as(c_int, 14)))] = (((b[@as(c_uint, @intCast(@as(c_int, 2)))] * a[@as(c_uint, @intCast(@as(c_int, 12)))]) + (b[@as(c_uint, @intCast(@as(c_int, 6)))] * a[@as(c_uint, @intCast(@as(c_int, 13)))])) + (b[@as(c_uint, @intCast(@as(c_int, 10)))] * a[@as(c_uint, @intCast(@as(c_int, 14)))])) + (b[@as(c_uint, @intCast(@as(c_int, 14)))] * a[@as(c_uint, @intCast(@as(c_int, 15)))]); - r[@as(c_uint, @intCast(@as(c_int, 15)))] = (((b[@as(c_uint, @intCast(@as(c_int, 3)))] * a[@as(c_uint, @intCast(@as(c_int, 12)))]) + (b[@as(c_uint, @intCast(@as(c_int, 7)))] * a[@as(c_uint, @intCast(@as(c_int, 13)))])) + (b[@as(c_uint, @intCast(@as(c_int, 11)))] * a[@as(c_uint, @intCast(@as(c_int, 14)))])) + (b[@as(c_uint, @intCast(@as(c_int, 15)))] * a[@as(c_uint, @intCast(@as(c_int, 15)))]); -} -pub export fn _m3d_inv(arg_m: [*c]M3D_FLOAT) void { - var m = arg_m; - _ = &m; - var r: [16]M3D_FLOAT = undefined; - _ = &r; - var det: M3D_FLOAT = (((((((((((((((((((((((((m[@as(c_uint, @intCast(@as(c_int, 0)))] * m[@as(c_uint, @intCast(@as(c_int, 5)))]) * m[@as(c_uint, @intCast(@as(c_int, 10)))]) * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * m[@as(c_uint, @intCast(@as(c_int, 5)))]) * m[@as(c_uint, @intCast(@as(c_int, 11)))]) * m[@as(c_uint, @intCast(@as(c_int, 14)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * m[@as(c_uint, @intCast(@as(c_int, 6)))]) * m[@as(c_uint, @intCast(@as(c_int, 11)))]) * m[@as(c_uint, @intCast(@as(c_int, 13)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * m[@as(c_uint, @intCast(@as(c_int, 6)))]) * m[@as(c_uint, @intCast(@as(c_int, 9)))]) * m[@as(c_uint, @intCast(@as(c_int, 15)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * m[@as(c_uint, @intCast(@as(c_int, 7)))]) * m[@as(c_uint, @intCast(@as(c_int, 9)))]) * m[@as(c_uint, @intCast(@as(c_int, 14)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * m[@as(c_uint, @intCast(@as(c_int, 7)))]) * m[@as(c_uint, @intCast(@as(c_int, 10)))]) * m[@as(c_uint, @intCast(@as(c_int, 13)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * m[@as(c_uint, @intCast(@as(c_int, 6)))]) * m[@as(c_uint, @intCast(@as(c_int, 11)))]) * m[@as(c_uint, @intCast(@as(c_int, 12)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * m[@as(c_uint, @intCast(@as(c_int, 6)))]) * m[@as(c_uint, @intCast(@as(c_int, 8)))]) * m[@as(c_uint, @intCast(@as(c_int, 15)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * m[@as(c_uint, @intCast(@as(c_int, 7)))]) * m[@as(c_uint, @intCast(@as(c_int, 8)))]) * m[@as(c_uint, @intCast(@as(c_int, 14)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * m[@as(c_uint, @intCast(@as(c_int, 7)))]) * m[@as(c_uint, @intCast(@as(c_int, 10)))]) * m[@as(c_uint, @intCast(@as(c_int, 12)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * m[@as(c_uint, @intCast(@as(c_int, 4)))]) * m[@as(c_uint, @intCast(@as(c_int, 10)))]) * m[@as(c_uint, @intCast(@as(c_int, 15)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * m[@as(c_uint, @intCast(@as(c_int, 4)))]) * m[@as(c_uint, @intCast(@as(c_int, 11)))]) * m[@as(c_uint, @intCast(@as(c_int, 14)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 2)))] * m[@as(c_uint, @intCast(@as(c_int, 7)))]) * m[@as(c_uint, @intCast(@as(c_int, 8)))]) * m[@as(c_uint, @intCast(@as(c_int, 13)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 2)))] * m[@as(c_uint, @intCast(@as(c_int, 7)))]) * m[@as(c_uint, @intCast(@as(c_int, 9)))]) * m[@as(c_uint, @intCast(@as(c_int, 12)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 2)))] * m[@as(c_uint, @intCast(@as(c_int, 4)))]) * m[@as(c_uint, @intCast(@as(c_int, 9)))]) * m[@as(c_uint, @intCast(@as(c_int, 15)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 2)))] * m[@as(c_uint, @intCast(@as(c_int, 4)))]) * m[@as(c_uint, @intCast(@as(c_int, 11)))]) * m[@as(c_uint, @intCast(@as(c_int, 13)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 2)))] * m[@as(c_uint, @intCast(@as(c_int, 5)))]) * m[@as(c_uint, @intCast(@as(c_int, 11)))]) * m[@as(c_uint, @intCast(@as(c_int, 12)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 2)))] * m[@as(c_uint, @intCast(@as(c_int, 5)))]) * m[@as(c_uint, @intCast(@as(c_int, 8)))]) * m[@as(c_uint, @intCast(@as(c_int, 15)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 3)))] * m[@as(c_uint, @intCast(@as(c_int, 4)))]) * m[@as(c_uint, @intCast(@as(c_int, 9)))]) * m[@as(c_uint, @intCast(@as(c_int, 14)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 3)))] * m[@as(c_uint, @intCast(@as(c_int, 4)))]) * m[@as(c_uint, @intCast(@as(c_int, 10)))]) * m[@as(c_uint, @intCast(@as(c_int, 13)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 3)))] * m[@as(c_uint, @intCast(@as(c_int, 5)))]) * m[@as(c_uint, @intCast(@as(c_int, 10)))]) * m[@as(c_uint, @intCast(@as(c_int, 12)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 3)))] * m[@as(c_uint, @intCast(@as(c_int, 5)))]) * m[@as(c_uint, @intCast(@as(c_int, 8)))]) * m[@as(c_uint, @intCast(@as(c_int, 14)))])) - (((m[@as(c_uint, @intCast(@as(c_int, 3)))] * m[@as(c_uint, @intCast(@as(c_int, 6)))]) * m[@as(c_uint, @intCast(@as(c_int, 8)))]) * m[@as(c_uint, @intCast(@as(c_int, 13)))])) + (((m[@as(c_uint, @intCast(@as(c_int, 3)))] * m[@as(c_uint, @intCast(@as(c_int, 6)))]) * m[@as(c_uint, @intCast(@as(c_int, 9)))]) * m[@as(c_uint, @intCast(@as(c_int, 12)))]); - _ = &det; - if ((det == @as(M3D_FLOAT, @floatCast(0.0))) or (det == @as(M3D_FLOAT, @floatCast(-0.0)))) { - det = @as(M3D_FLOAT, @floatCast(1.0)); - } else { - det = @as(M3D_FLOAT, @floatCast(1.0)) / det; - } - r[@as(c_uint, @intCast(@as(c_int, 0)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 5)))] * ((m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 6)))] * ((m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 7)))] * ((m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))])))); - r[@as(c_uint, @intCast(@as(c_int, 1)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))])))); - r[@as(c_uint, @intCast(@as(c_int, 2)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))])))); - r[@as(c_uint, @intCast(@as(c_int, 3)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 11)))]) - (m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 10)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 9)))]) - (m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 11)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 10)))]) - (m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 9)))])))); - r[@as(c_uint, @intCast(@as(c_int, 4)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 4)))] * ((m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 6)))] * ((m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 7)))] * ((m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 5)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 6)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 7)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 11)))]) - (m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 10)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 8)))]) - (m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 11)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 10)))]) - (m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 8)))])))); - r[@as(c_uint, @intCast(@as(c_int, 8)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 4)))] * ((m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 5)))] * ((m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 7)))] * ((m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 9)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 11)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 10)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))]) - (m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 15)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 11)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 11)))]) - (m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 9)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 7)))] * m[@as(c_uint, @intCast(@as(c_int, 8)))]) - (m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 11)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 3)))] * ((m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 9)))]) - (m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 8)))])))); - r[@as(c_uint, @intCast(@as(c_int, 12)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 4)))] * ((m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 5)))] * ((m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 6)))] * ((m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 13)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 10)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 8)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 9)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 14)))] = -det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))]) - (m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))]) - (m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 14)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 13)))]) - (m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 12)))])))); - r[@as(c_uint, @intCast(@as(c_int, 15)))] = det * (((m[@as(c_uint, @intCast(@as(c_int, 0)))] * ((m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 10)))]) - (m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 9)))]))) + (m[@as(c_uint, @intCast(@as(c_int, 1)))] * ((m[@as(c_uint, @intCast(@as(c_int, 6)))] * m[@as(c_uint, @intCast(@as(c_int, 8)))]) - (m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 10)))])))) + (m[@as(c_uint, @intCast(@as(c_int, 2)))] * ((m[@as(c_uint, @intCast(@as(c_int, 4)))] * m[@as(c_uint, @intCast(@as(c_int, 9)))]) - (m[@as(c_uint, @intCast(@as(c_int, 5)))] * m[@as(c_uint, @intCast(@as(c_int, 8)))])))); - _ = memcpy(@as(?*anyopaque, @ptrCast(m)), @as(?*const anyopaque, @ptrCast(&r)), @sizeOf([16]M3D_FLOAT)); -} -pub export fn _m3d_mat(arg_r: [*c]M3D_FLOAT, arg_p: [*c]m3dv_t, arg_q: [*c]m3dv_t) void { - var r = arg_r; - _ = &r; - var p = arg_p; - _ = &p; - var q = arg_q; - _ = &q; - if (((((q.*.x == @as(M3D_FLOAT, @floatCast(0.0))) and (q.*.y == @as(M3D_FLOAT, @floatCast(0.0)))) and (q.*.z >= @as(M3D_FLOAT, @floatCast(0.7071065)))) and (q.*.z <= @as(M3D_FLOAT, @floatCast(0.7071075)))) and (q.*.w == @as(M3D_FLOAT, @floatCast(0.0)))) { - r[@as(c_uint, @intCast(@as(c_int, 1)))] = blk: { - const tmp = blk_1: { - const tmp_2 = blk_2: { - const tmp_3 = blk_3: { - const tmp_4 = blk_4: { - const tmp_5 = @as(M3D_FLOAT, @floatCast(0.0)); - r[@as(c_uint, @intCast(@as(c_int, 9)))] = tmp_5; - break :blk_4 tmp_5; - }; - r[@as(c_uint, @intCast(@as(c_int, 8)))] = tmp_4; - break :blk_3 tmp_4; - }; - r[@as(c_uint, @intCast(@as(c_int, 6)))] = tmp_3; - break :blk_2 tmp_3; - }; - r[@as(c_uint, @intCast(@as(c_int, 4)))] = tmp_2; - break :blk_1 tmp_2; - }; - r[@as(c_uint, @intCast(@as(c_int, 2)))] = tmp; - break :blk tmp; - }; - r[@as(c_uint, @intCast(@as(c_int, 0)))] = blk: { - const tmp = blk_1: { - const tmp_2 = @as(M3D_FLOAT, @floatCast(-1.0)); - r[@as(c_uint, @intCast(@as(c_int, 10)))] = tmp_2; - break :blk_1 tmp_2; - }; - r[@as(c_uint, @intCast(@as(c_int, 5)))] = tmp; - break :blk tmp; - }; - } else { - r[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 1))) - (@as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.y * q.*.y) + (q.*.z * q.*.z))); - if ((r[@as(c_uint, @intCast(@as(c_int, 0)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 0)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.x * q.*.y) - (q.*.z * q.*.w)); - if ((r[@as(c_uint, @intCast(@as(c_int, 1)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 1)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 2)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.x * q.*.z) + (q.*.y * q.*.w)); - if ((r[@as(c_uint, @intCast(@as(c_int, 2)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 2)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 2)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 4)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.x * q.*.y) + (q.*.z * q.*.w)); - if ((r[@as(c_uint, @intCast(@as(c_int, 4)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 4)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 4)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 5)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 1))) - (@as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.x * q.*.x) + (q.*.z * q.*.z))); - if ((r[@as(c_uint, @intCast(@as(c_int, 5)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 5)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 5)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 6)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.y * q.*.z) - (q.*.x * q.*.w)); - if ((r[@as(c_uint, @intCast(@as(c_int, 6)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 6)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 6)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 8)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.x * q.*.z) - (q.*.y * q.*.w)); - if ((r[@as(c_uint, @intCast(@as(c_int, 8)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 8)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 8)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 9)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.y * q.*.z) + (q.*.x * q.*.w)); - if ((r[@as(c_uint, @intCast(@as(c_int, 9)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 9)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 9)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - r[@as(c_uint, @intCast(@as(c_int, 10)))] = @as(M3D_FLOAT, @floatFromInt(@as(c_int, 1))) - (@as(M3D_FLOAT, @floatFromInt(@as(c_int, 2))) * ((q.*.x * q.*.x) + (q.*.y * q.*.y))); - if ((r[@as(c_uint, @intCast(@as(c_int, 10)))] > -@as(M3D_FLOAT, @floatCast(0.0000001))) and (r[@as(c_uint, @intCast(@as(c_int, 10)))] < @as(M3D_FLOAT, @floatCast(0.0000001)))) { - r[@as(c_uint, @intCast(@as(c_int, 10)))] = @as(M3D_FLOAT, @floatCast(0.0)); - } - } - r[@as(c_uint, @intCast(@as(c_int, 3)))] = p.*.x; - r[@as(c_uint, @intCast(@as(c_int, 7)))] = p.*.y; - r[@as(c_uint, @intCast(@as(c_int, 11)))] = p.*.z; - r[@as(c_uint, @intCast(@as(c_int, 12)))] = 0; - r[@as(c_uint, @intCast(@as(c_int, 13)))] = 0; - r[@as(c_uint, @intCast(@as(c_int, 14)))] = 0; - r[@as(c_uint, @intCast(@as(c_int, 15)))] = 1; -} -pub fn _m3d_rsq(arg_x: M3D_FLOAT) callconv(.C) M3D_FLOAT { - var x = arg_x; - _ = &x; - var x2: f32 = x * 0.5; - _ = &x2; - var i: [*c]u32 = @as([*c]u32, @ptrCast(@alignCast(&x))); - _ = &i; - i.* = @as(u32, @bitCast(@as(c_int, 1597463007))) -% (i.* >> @intCast(1)); - return x * (1.5 - ((x2 * x) * x)); -} -pub export fn par_shapes_free_mesh(arg_mesh: [*c]par_shapes_mesh) void { - var mesh = arg_mesh; - _ = &mesh; - free(@as(?*anyopaque, @ptrCast(mesh.*.points))); - free(@as(?*anyopaque, @ptrCast(mesh.*.triangles))); - free(@as(?*anyopaque, @ptrCast(mesh.*.normals))); - free(@as(?*anyopaque, @ptrCast(mesh.*.tcoords))); - free(@as(?*anyopaque, @ptrCast(mesh))); -} -pub export fn par_shapes_create_cylinder(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 1))) { - return null; - } - return par_shapes_create_parametric(&par_shapes__cylinder, slices, stacks, null); -} -pub export fn par_shapes_create_cone(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 1))) { - return null; - } - return par_shapes_create_parametric(&par_shapes__cone, slices, stacks, null); -} -pub export fn par_shapes_create_parametric_disk(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - var m: [*c]par_shapes_mesh = par_shapes_create_cone(slices, stacks); - _ = &m; - if (m != null) { - par_shapes_scale(m, 1.0, 1.0, 0.0); - } - return m; -} -pub export fn par_shapes_create_torus(arg_slices: c_int, arg_stacks: c_int, arg_radius: f32) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - var radius = arg_radius; - _ = &radius; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 3))) { - return null; - } - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((@as(f64, @floatCast(radius)) <= 1.0) and (@intFromPtr("Use smaller radius to avoid self-intersection.") != 0)) {} else { - __assert_fail("radius <= 1.0 && \"Use smaller radius to avoid self-intersection.\"", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 395))), "par_shapes_mesh *par_shapes_create_torus(int, int, float)"); - }; - }; - }; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((@as(f64, @floatCast(radius)) >= 0.1) and (@intFromPtr("Use larger radius to avoid self-intersection.") != 0)) {} else { - __assert_fail("radius >= 0.1 && \"Use larger radius to avoid self-intersection.\"", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 396))), "par_shapes_mesh *par_shapes_create_torus(int, int, float)"); - }; - }; - }; - var userdata: ?*anyopaque = @as(?*anyopaque, @ptrCast(&radius)); - _ = &userdata; - return par_shapes_create_parametric(&par_shapes__torus, slices, stacks, userdata); -} -pub export fn par_shapes_create_parametric_sphere(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 3))) { - return null; - } - var m: [*c]par_shapes_mesh = par_shapes_create_parametric(&par_shapes__sphere, slices, stacks, null); - _ = &m; - par_shapes_remove_degenerate(m, par_shapes__epsilon_degenerate_sphere); - return m; -} -pub export fn par_shapes_create_subdivided_sphere(arg_nsubd: c_int) [*c]par_shapes_mesh { - var nsubd = arg_nsubd; - _ = &nsubd; - var mesh: [*c]par_shapes_mesh = par_shapes_create_icosahedron(); - _ = &mesh; - par_shapes_unweld(mesh, @as(c_int, 0) != 0); - free(@as(?*anyopaque, @ptrCast(mesh.*.triangles))); - mesh.*.triangles = null; - while ((blk: { - const ref = &nsubd; - const tmp = ref.*; - ref.* -= 1; - break :blk tmp; - }) != 0) { - par_shapes__subdivide(mesh); - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (i += 1) { - par_shapes__normalize3(mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(i * @as(c_int, 3)))))); - } - } - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.ntriangles))) *% @sizeOf(u16))))); - { - var i: c_int = 0; - _ = &i; - while (i < (mesh.*.ntriangles * @as(c_int, 3))) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk mesh.*.triangles + @as(usize, @intCast(tmp)) else break :blk mesh.*.triangles - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u16, @bitCast(@as(c_short, @truncate(i)))); - } - } - var tmp: [*c]par_shapes_mesh = mesh; - _ = &tmp; - mesh = par_shapes_weld(mesh, @as(f32, @floatCast(0.01)), null); - par_shapes_free_mesh(tmp); - par_shapes_compute_normals(mesh); - return mesh; -} -pub export fn par_shapes_create_klein_bottle(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 3))) { - return null; - } - var mesh: [*c]par_shapes_mesh = par_shapes_create_parametric(&par_shapes__klein, slices, stacks, null); - _ = &mesh; - var face: c_int = 0; - _ = &face; - { - var stack: c_int = 0; - _ = &stack; - while (stack < stacks) : (stack += 1) { - { - var slice: c_int = 0; - _ = &slice; - while (slice < slices) : (_ = blk: { - slice += 1; - break :blk blk_1: { - const ref = &face; - ref.* += @as(c_int, 2); - break :blk_1 ref.*; - }; - }) { - if (stack < @divTrunc(@as(c_int, 27) * stacks, @as(c_int, 32))) { - par_shapes_invert(mesh, face, @as(c_int, 2)); - } - } - } - } - } - par_shapes__compute_welded_normals(mesh); - return mesh; -} -pub export fn par_shapes_create_trefoil_knot(arg_slices: c_int, arg_stacks: c_int, arg_radius: f32) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - var radius = arg_radius; - _ = &radius; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 3))) { - return null; - } - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((@as(f64, @floatCast(radius)) <= 3.0) and (@intFromPtr("Use smaller radius to avoid self-intersection.") != 0)) {} else { - __assert_fail("radius <= 3.0 && \"Use smaller radius to avoid self-intersection.\"", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 427))), "par_shapes_mesh *par_shapes_create_trefoil_knot(int, int, float)"); - }; - }; - }; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((@as(f64, @floatCast(radius)) >= 0.5) and (@intFromPtr("Use larger radius to avoid self-intersection.") != 0)) {} else { - __assert_fail("radius >= 0.5 && \"Use larger radius to avoid self-intersection.\"", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 428))), "par_shapes_mesh *par_shapes_create_trefoil_knot(int, int, float)"); - }; - }; - }; - var userdata: ?*anyopaque = @as(?*anyopaque, @ptrCast(&radius)); - _ = &userdata; - return par_shapes_create_parametric(&par_shapes__trefoil, slices, stacks, userdata); -} -pub export fn par_shapes_create_hemisphere(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - if ((slices < @as(c_int, 3)) or (stacks < @as(c_int, 3))) { - return null; - } - var m: [*c]par_shapes_mesh = par_shapes_create_parametric(&par_shapes__hemisphere, slices, stacks, null); - _ = &m; - par_shapes_remove_degenerate(m, par_shapes__epsilon_degenerate_sphere); - return m; -} -pub export fn par_shapes_create_plane(arg_slices: c_int, arg_stacks: c_int) [*c]par_shapes_mesh { - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - if ((slices < @as(c_int, 1)) or (stacks < @as(c_int, 1))) { - return null; - } - return par_shapes_create_parametric(&par_shapes__plane, slices, stacks, null); -} -pub const par_shapes_fn = ?*const fn ([*c]const f32, [*c]f32, ?*anyopaque) callconv(.C) void; -pub export fn par_shapes_create_parametric(arg_fn: par_shapes_fn, arg_slices: c_int, arg_stacks: c_int, arg_userdata: ?*anyopaque) [*c]par_shapes_mesh { - var @"fn" = arg_fn; - _ = &@"fn"; - var slices = arg_slices; - _ = &slices; - var stacks = arg_stacks; - _ = &stacks; - var userdata = arg_userdata; - _ = &userdata; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - mesh.*.npoints = (slices + @as(c_int, 1)) * (stacks + @as(c_int, 1)); - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.npoints))) *% @sizeOf(f32), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - var uv: [2]f32 = undefined; - _ = &uv; - var xyz: [3]f32 = undefined; - _ = &xyz; - var points: [*c]f32 = mesh.*.points; - _ = &points; - { - var stack: c_int = 0; - _ = &stack; - while (stack < (stacks + @as(c_int, 1))) : (stack += 1) { - uv[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(f32, @floatFromInt(stack)) / @as(f32, @floatFromInt(stacks)); - { - var slice: c_int = 0; - _ = &slice; - while (slice < (slices + @as(c_int, 1))) : (slice += 1) { - uv[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(f32, @floatFromInt(slice)) / @as(f32, @floatFromInt(slices)); - @"fn".?(@as([*c]f32, @ptrCast(@alignCast(&uv))), @as([*c]f32, @ptrCast(@alignCast(&xyz))), userdata); - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = xyz[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = xyz[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = xyz[@as(c_uint, @intCast(@as(c_int, 2)))]; - } - } - } - } - mesh.*.tcoords = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2) * mesh.*.npoints))) *% @sizeOf(f32), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - var uvs: [*c]f32 = mesh.*.tcoords; - _ = &uvs; - { - var stack: c_int = 0; - _ = &stack; - while (stack < (stacks + @as(c_int, 1))) : (stack += 1) { - uv[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(f32, @floatFromInt(stack)) / @as(f32, @floatFromInt(stacks)); - { - var slice: c_int = 0; - _ = &slice; - while (slice < (slices + @as(c_int, 1))) : (slice += 1) { - uv[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(f32, @floatFromInt(slice)) / @as(f32, @floatFromInt(slices)); - (blk: { - const ref = &uvs; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = uv[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &uvs; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = uv[@as(c_uint, @intCast(@as(c_int, 1)))]; - } - } - } - } - mesh.*.ntriangles = (@as(c_int, 2) * slices) * stacks; - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.ntriangles))) *% @sizeOf(u16), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - var v: c_int = 0; - _ = &v; - var face: [*c]u16 = mesh.*.triangles; - _ = &face; - { - var stack: c_int = 0; - _ = &stack; - while (stack < stacks) : (stack += 1) { - { - var slice: c_int = 0; - _ = &slice; - while (slice < slices) : (slice += 1) { - var next: c_int = slice + @as(c_int, 1); - _ = &next; - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(((v + slice) + slices) + @as(c_int, 1))))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(v + next)))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(v + slice)))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(((v + slice) + slices) + @as(c_int, 1))))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(((v + next) + slices) + @as(c_int, 1))))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(v + next)))); - } - } - v += slices + @as(c_int, 1); - } - } - par_shapes__compute_welded_normals(mesh); - return mesh; -} -pub export fn par_shapes_create_icosahedron() [*c]par_shapes_mesh { - const verts = struct { - var static: [36]f32 = [36]f32{ - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(1.0)), - @as(f32, @floatCast(0.894)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.447)), - @as(f32, @floatCast(0.276)), - @as(f32, @floatCast(0.851)), - @as(f32, @floatCast(0.447)), - @as(f32, @floatCast(-0.724)), - @as(f32, @floatCast(0.526)), - @as(f32, @floatCast(0.447)), - @as(f32, @floatCast(-0.724)), - @as(f32, @floatCast(-0.526)), - @as(f32, @floatCast(0.447)), - @as(f32, @floatCast(0.276)), - @as(f32, @floatCast(-0.851)), - @as(f32, @floatCast(0.447)), - @as(f32, @floatCast(0.724)), - @as(f32, @floatCast(0.526)), - @as(f32, @floatCast(-0.447)), - @as(f32, @floatCast(-0.276)), - @as(f32, @floatCast(0.851)), - @as(f32, @floatCast(-0.447)), - @as(f32, @floatCast(-0.894)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-0.447)), - @as(f32, @floatCast(-0.276)), - @as(f32, @floatCast(-0.851)), - @as(f32, @floatCast(-0.447)), - @as(f32, @floatCast(0.724)), - @as(f32, @floatCast(-0.526)), - @as(f32, @floatCast(-0.447)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-1.0)), - }; - }; - _ = &verts; - const faces = struct { - var static: [60]u16 = [60]u16{ - 0, - 1, - 2, - 0, - 2, - 3, - 0, - 3, - 4, - 0, - 4, - 5, - 0, - 5, - 1, - 7, - 6, - 11, - 8, - 7, - 11, - 9, - 8, - 11, - 10, - 9, - 11, - 6, - 10, - 11, - 6, - 2, - 1, - 7, - 3, - 2, - 8, - 4, - 3, - 9, - 5, - 4, - 10, - 1, - 5, - 6, - 7, - 2, - 7, - 8, - 3, - 8, - 9, - 4, - 9, - 10, - 5, - 10, - 6, - 1, - }; - }; - _ = &faces; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - mesh.*.npoints = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([36]f32) / @sizeOf(f32)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(malloc((@sizeOf([36]f32) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.*.points)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&verts.static))))), @sizeOf([36]f32)); - mesh.*.ntriangles = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([60]u16) / @sizeOf(u16)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc((@sizeOf([60]u16) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2))))) *% @sizeOf(u16))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.*.triangles)), @as(?*const anyopaque, @ptrCast(@as([*c]u16, @ptrCast(@alignCast(&faces.static))))), @sizeOf([60]u16)); - return mesh; -} -pub export fn par_shapes_create_dodecahedron() [*c]par_shapes_mesh { - const verts = struct { - var static: [60]f32 = [60]f32{ - @as(f32, @floatCast(0.607)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(0.577)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(-0.491)), - @as(f32, @floatCast(0.357)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(-0.491)), - @as(f32, @floatCast(-0.357)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(-0.577)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(0.982)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(0.304)), - @as(f32, @floatCast(0.934)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(-0.795)), - @as(f32, @floatCast(0.577)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(-0.795)), - @as(f32, @floatCast(-0.577)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(0.304)), - @as(f32, @floatCast(-0.934)), - @as(f32, @floatCast(0.188)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(0.577)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(-0.304)), - @as(f32, @floatCast(0.934)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(-0.982)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(-0.304)), - @as(f32, @floatCast(-0.934)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(0.795)), - @as(f32, @floatCast(-0.577)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(0.491)), - @as(f32, @floatCast(0.357)), - @as(f32, @floatCast(-0.795)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(0.577)), - @as(f32, @floatCast(-0.795)), - @as(f32, @floatCast(-0.607)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-0.795)), - @as(f32, @floatCast(-0.188)), - @as(f32, @floatCast(-0.577)), - @as(f32, @floatCast(-0.795)), - @as(f32, @floatCast(0.491)), - @as(f32, @floatCast(-0.357)), - @as(f32, @floatCast(-0.795)), - }; - }; - _ = &verts; - const pentagons = struct { - var static: [60]u16 = [60]u16{ - 0, - 1, - 2, - 3, - 4, - 5, - 10, - 6, - 1, - 0, - 6, - 11, - 7, - 2, - 1, - 7, - 12, - 8, - 3, - 2, - 8, - 13, - 9, - 4, - 3, - 9, - 14, - 5, - 0, - 4, - 15, - 16, - 11, - 6, - 10, - 16, - 17, - 12, - 7, - 11, - 17, - 18, - 13, - 8, - 12, - 18, - 19, - 14, - 9, - 13, - 19, - 15, - 10, - 5, - 14, - 19, - 18, - 17, - 16, - 15, - }; - }; - _ = &pentagons; - var npentagons: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([60]u16) / @sizeOf(u16)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5)))))))); - _ = &npentagons; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - var ncorners: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([60]f32) / @sizeOf(f32)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &ncorners; - mesh.*.npoints = ncorners; - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.*.points)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&verts.static))))), @sizeOf([60]f32)); - var pentagon: [*c]const u16 = @as([*c]u16, @ptrCast(@alignCast(&pentagons.static))); - _ = &pentagon; - mesh.*.ntriangles = npentagons * @as(c_int, 3); - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - var tris: [*c]u16 = mesh.*.triangles; - _ = &tris; - { - var p: c_int = 0; - _ = &p; - while (p < npentagons) : (_ = blk: { - p += 1; - break :blk blk_1: { - const ref = &pentagon; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 5))))); - break :blk_1 ref.*; - }; - }) { - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 2)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 2)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 3)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 3)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = pentagon[@as(c_uint, @intCast(@as(c_int, 4)))]; - } - } - return mesh; -} -pub export fn par_shapes_create_octahedron() [*c]par_shapes_mesh { - const verts = struct { - var static: [18]f32 = [18]f32{ - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(1.0)), - @as(f32, @floatCast(1.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(1.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-1.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-1.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(-1.0)), - }; - }; - _ = &verts; - const triangles = struct { - var static: [24]u16 = [24]u16{ - 0, - 1, - 2, - 0, - 2, - 3, - 0, - 3, - 4, - 0, - 4, - 1, - 2, - 1, - 5, - 3, - 2, - 5, - 4, - 3, - 5, - 1, - 4, - 5, - }; - }; - _ = &triangles; - var ntris: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([24]u16) / @sizeOf(u16)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &ntris; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - var ncorners: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([18]f32) / @sizeOf(f32)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &ncorners; - mesh.*.npoints = ncorners; - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.*.points)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&verts.static))))), @sizeOf([18]f32)); - var triangle: [*c]const u16 = @as([*c]u16, @ptrCast(@alignCast(&triangles.static))); - _ = ▵ - mesh.*.ntriangles = ntris; - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - var tris: [*c]u16 = mesh.*.triangles; - _ = &tris; - { - var p: c_int = 0; - _ = &p; - while (p < ntris) : (p += 1) { - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = ▵ - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = ▵ - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = ▵ - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - } - } - return mesh; -} -pub export fn par_shapes_create_tetrahedron() [*c]par_shapes_mesh { - const verts = struct { - var static: [12]f32 = [12]f32{ - @as(f32, @floatCast(0.0)), - @as(f32, @floatCast(1.333)), - 0, - @as(f32, @floatCast(0.943)), - 0, - 0, - @as(f32, @floatCast(-0.471)), - 0, - @as(f32, @floatCast(0.816)), - @as(f32, @floatCast(-0.471)), - 0, - @as(f32, @floatCast(-0.816)), - }; - }; - _ = &verts; - const triangles = struct { - var static: [12]u16 = [12]u16{ - 2, - 1, - 0, - 3, - 2, - 0, - 1, - 3, - 0, - 1, - 2, - 3, - }; - }; - _ = &triangles; - var ntris: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([12]u16) / @sizeOf(u16)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &ntris; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - var ncorners: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([12]f32) / @sizeOf(f32)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &ncorners; - mesh.*.npoints = ncorners; - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.*.points)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&verts.static))))), @sizeOf([12]f32)); - var triangle: [*c]const u16 = @as([*c]u16, @ptrCast(@alignCast(&triangles.static))); - _ = ▵ - mesh.*.ntriangles = ntris; - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - var tris: [*c]u16 = mesh.*.triangles; - _ = &tris; - { - var p: c_int = 0; - _ = &p; - while (p < ntris) : (p += 1) { - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = ▵ - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = ▵ - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = ▵ - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - } - } - return mesh; -} -pub export fn par_shapes_create_cube() [*c]par_shapes_mesh { - const verts = struct { - var static: [24]f32 = [24]f32{ - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - }; - }; - _ = &verts; - const quads = struct { - var static: [24]u16 = [24]u16{ - 7, - 6, - 5, - 4, - 0, - 1, - 2, - 3, - 6, - 7, - 3, - 2, - 5, - 6, - 2, - 1, - 4, - 5, - 1, - 0, - 7, - 4, - 0, - 3, - }; - }; - _ = &quads; - var nquads: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([24]u16) / @sizeOf(u16)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4)))))))); - _ = &nquads; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - var ncorners: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate((@sizeOf([24]f32) / @sizeOf(f32)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &ncorners; - mesh.*.npoints = ncorners; - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(mesh.*.points)), @as(?*const anyopaque, @ptrCast(@as([*c]f32, @ptrCast(@alignCast(&verts.static))))), @sizeOf([24]f32)); - var quad: [*c]const u16 = @as([*c]u16, @ptrCast(@alignCast(&quads.static))); - _ = &quad; - mesh.*.ntriangles = nquads * @as(c_int, 2); - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - var tris: [*c]u16 = mesh.*.triangles; - _ = &tris; - { - var p: c_int = 0; - _ = &p; - while (p < nquads) : (_ = blk: { - p += 1; - break :blk blk_1: { - const ref = &quad; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 4))))); - break :blk_1 ref.*; - }; - }) { - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = quad[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = quad[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = quad[@as(c_uint, @intCast(@as(c_int, 2)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = quad[@as(c_uint, @intCast(@as(c_int, 2)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = quad[@as(c_uint, @intCast(@as(c_int, 3)))]; - (blk: { - const ref = &tris; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = quad[@as(c_uint, @intCast(@as(c_int, 0)))]; - } - } - return mesh; -} -pub export fn par_shapes_create_disk(arg_radius: f32, arg_slices: c_int, arg_center: [*c]const f32, arg_normal: [*c]const f32) [*c]par_shapes_mesh { - var radius = arg_radius; - _ = &radius; - var slices = arg_slices; - _ = &slices; - var center = arg_center; - _ = ¢er; - var normal = arg_normal; - _ = &normal; - var mesh: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &mesh; - mesh.*.npoints = slices + @as(c_int, 1); - mesh.*.points = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.npoints))) *% @sizeOf(f32))))); - var points: [*c]f32 = mesh.*.points; - _ = &points; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = 0; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = 0; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = 0; - { - var i: c_int = 0; - _ = &i; - while (i < slices) : (i += 1) { - var theta: f32 = @as(f32, @floatCast(((@as(f64, @floatFromInt(i)) * 3.14159265359) * @as(f64, @floatFromInt(@as(c_int, 2)))) / @as(f64, @floatFromInt(slices)))); - _ = θ - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(f32, @floatCast(@as(f64, @floatCast(radius)) * cos(@as(f64, @floatCast(theta))))); - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(f32, @floatCast(@as(f64, @floatCast(radius)) * sin(@as(f64, @floatCast(theta))))); - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = 0; - } - } - var nnormal: [3]f32 = [3]f32{ - normal[@as(c_uint, @intCast(@as(c_int, 0)))], - normal[@as(c_uint, @intCast(@as(c_int, 1)))], - normal[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &nnormal; - par_shapes__normalize3(@as([*c]f32, @ptrCast(@alignCast(&nnormal)))); - mesh.*.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.npoints))) *% @sizeOf(f32))))); - var norms: [*c]f32 = mesh.*.normals; - _ = &norms; - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (i += 1) { - (blk: { - const ref = &norms; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = nnormal[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &norms; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = nnormal[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &norms; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = nnormal[@as(c_uint, @intCast(@as(c_int, 2)))]; - } - } - mesh.*.ntriangles = slices; - mesh.*.triangles = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.ntriangles))) *% @sizeOf(u16))))); - var triangles: [*c]u16 = mesh.*.triangles; - _ = &triangles; - { - var i: c_int = 0; - _ = &i; - while (i < slices) : (i += 1) { - (blk: { - const ref = &triangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = 0; - (blk: { - const ref = &triangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, 1) + i)))); - (blk: { - const ref = &triangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, 1) + @import("std").zig.c_translation.signedRemainder(i + @as(c_int, 1), slices))))); - } - } - var k: [3]f32 = [3]f32{ - 0, - 0, - @as(f32, @floatFromInt(-@as(c_int, 1))), - }; - _ = &k; - var axis: [3]f32 = undefined; - _ = &axis; - par_shapes__cross3(@as([*c]f32, @ptrCast(@alignCast(&axis))), @as([*c]f32, @ptrCast(@alignCast(&nnormal))), @as([*c]f32, @ptrCast(@alignCast(&k)))); - par_shapes__normalize3(@as([*c]f32, @ptrCast(@alignCast(&axis)))); - par_shapes_rotate(mesh, @as(f32, @floatCast(acos(@as(f64, @floatCast(nnormal[@as(c_uint, @intCast(@as(c_int, 2)))]))))), @as([*c]f32, @ptrCast(@alignCast(&axis)))); - par_shapes_translate(mesh, center[@as(c_uint, @intCast(@as(c_int, 0)))], center[@as(c_uint, @intCast(@as(c_int, 1)))], center[@as(c_uint, @intCast(@as(c_int, 2)))]); - return mesh; -} -pub export fn par_shapes_create_empty() [*c]par_shapes_mesh { - return @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); -} -pub const struct_osn_context = extern struct { - perm: [*c]i16 = @import("std").mem.zeroes([*c]i16), - permGradIndex3D: [*c]i16 = @import("std").mem.zeroes([*c]i16), -}; -pub export fn par_shapes_create_rock(arg_seed: c_int, arg_subd: c_int) [*c]par_shapes_mesh { - var seed = arg_seed; - _ = &seed; - var subd = arg_subd; - _ = &subd; - var mesh: [*c]par_shapes_mesh = par_shapes_create_subdivided_sphere(subd); - _ = &mesh; - var ctx: [*c]struct_osn_context = undefined; - _ = &ctx; - _ = par__simplex_noise(@as(i64, @bitCast(@as(c_long, seed))), &ctx); - { - var p: c_int = 0; - _ = &p; - while (p < mesh.*.npoints) : (p += 1) { - var pt: [*c]f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(p * @as(c_int, 3))))); - _ = &pt; - var a: f32 = @as(f32, @floatCast(0.25)); - _ = &a; - var f: f32 = @as(f32, @floatCast(1.0)); - _ = &f; - var n: f64 = @as(f64, @floatCast(a)) * par__simplex_noise2(ctx, @as(f64, @floatCast(f * pt[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(f * pt[@as(c_uint, @intCast(@as(c_int, 2)))]))); - _ = &n; - a *= @as(f32, @floatCast(0.5)); - f *= @as(f32, @floatFromInt(@as(c_int, 2))); - n += @as(f64, @floatCast(a)) * par__simplex_noise2(ctx, @as(f64, @floatCast(f * pt[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(f * pt[@as(c_uint, @intCast(@as(c_int, 2)))]))); - pt[@as(c_uint, @intCast(@as(c_int, 0)))] *= @as(f32, @floatCast(@as(f64, @floatFromInt(@as(c_int, 1))) + (@as(f64, @floatFromInt(@as(c_int, 2))) * n))); - pt[@as(c_uint, @intCast(@as(c_int, 1)))] *= @as(f32, @floatCast(@as(f64, @floatFromInt(@as(c_int, 1))) + n)); - pt[@as(c_uint, @intCast(@as(c_int, 2)))] *= @as(f32, @floatCast(@as(f64, @floatFromInt(@as(c_int, 1))) + (@as(f64, @floatFromInt(@as(c_int, 2))) * n))); - if (pt[@as(c_uint, @intCast(@as(c_int, 1)))] < @as(f32, @floatFromInt(@as(c_int, 0)))) { - pt[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(f32, @floatCast(-pow(@as(f64, @floatCast(-pt[@as(c_uint, @intCast(@as(c_int, 1)))])), 0.5) / @as(f64, @floatFromInt(@as(c_int, 2))))); - } - } - } - par__simplex_noise_free(ctx); - par_shapes_compute_normals(mesh); - return mesh; -} -pub export fn par_shapes_create_lsystem(arg_text: [*c]const u8, arg_slices: c_int, arg_maxdepth: c_int) [*c]par_shapes_mesh { - var text = arg_text; - _ = &text; - var slices = arg_slices; - _ = &slices; - var maxdepth = arg_maxdepth; - _ = &maxdepth; - var program: [*c]u8 = undefined; - _ = &program; - program = @as([*c]u8, @ptrCast(@alignCast(malloc(strlen(text) +% (@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(u8)))))); - _ = strcpy(program, text); - var cmd: [*c]u8 = strtok(program, " "); - _ = &cmd; - var nrules: c_int = 1; - _ = &nrules; - var ncommands: c_int = 0; - _ = &ncommands; - while (cmd != null) { - var arg: [*c]u8 = strtok(null, " "); - _ = &arg; - if (!(arg != null)) { - _ = puts("lsystem error: unexpected end of program."); - break; - } - if (!(strcmp(cmd, "rule") != 0)) { - nrules += 1; - } else { - ncommands += 1; - } - cmd = strtok(null, " "); - } - var rules: [*c]par_shapes__rule = @as([*c]par_shapes__rule, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, nrules))) *% @sizeOf(par_shapes__rule))))); - _ = &rules; - var commands: [*c]par_shapes__command = @as([*c]par_shapes__command, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, ncommands))) *% @sizeOf(par_shapes__command))))); - _ = &commands; - var current_rule: [*c]par_shapes__rule = &rules[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = ¤t_rule; - var current_command: [*c]par_shapes__command = &commands[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = ¤t_command; - current_rule.*.name = "entry"; - current_rule.*.weight = 1; - current_rule.*.ncommands = 0; - current_rule.*.commands = current_command; - _ = strcpy(program, text); - cmd = strtok(program, " "); - while (cmd != null) { - var arg: [*c]u8 = strtok(null, " "); - _ = &arg; - if (!(strcmp(cmd, "rule") != 0)) { - current_rule += 1; - var dot: [*c]u8 = strchr(arg, @as(c_int, '.')); - _ = ˙ - if (dot != null) { - current_rule.*.weight = atoi(dot + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))); - dot.* = 0; - } else { - current_rule.*.weight = 1; - } - current_rule.*.name = arg; - current_rule.*.ncommands = 0; - current_rule.*.commands = current_command; - } else { - current_rule.*.ncommands += 1; - current_command.*.cmd = cmd; - current_command.*.arg = arg; - current_command += 1; - } - cmd = strtok(null, " "); - } - var scene: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &scene; - var tube: [*c]par_shapes_mesh = par_shapes_create_cylinder(slices, @as(c_int, 1)); - _ = &tube; - var turtle: [*c]par_shapes_mesh = par_shapes__create_turtle(); - _ = &turtle; - free(@as(?*anyopaque, @ptrCast(tube.*.normals))); - free(@as(?*anyopaque, @ptrCast(tube.*.tcoords))); - tube.*.normals = null; - tube.*.tcoords = null; - const xaxis: [3]f32 = [3]f32{ - 1, - 0, - 0, - }; - _ = &xaxis; - const yaxis: [3]f32 = [3]f32{ - 0, - 1, - 0, - }; - _ = &yaxis; - const zaxis: [3]f32 = [3]f32{ - 0, - 0, - 1, - }; - _ = &zaxis; - const units: [3]f32 = [3]f32{ - 1, - 1, - 1, - }; - _ = &units; - var stack: [*c]par_shapes__stackframe = @as([*c]par_shapes__stackframe, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, maxdepth))) *% @sizeOf(par_shapes__stackframe), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &stack; - var stackptr: c_int = 0; - _ = &stackptr; - stack[@as(c_uint, @intCast(@as(c_int, 0)))].orientation = turtle; - stack[@as(c_uint, @intCast(@as(c_int, 0)))].rule = &rules[@as(c_uint, @intCast(@as(c_int, 0)))]; - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&stack[@as(c_uint, @intCast(@as(c_int, 0)))].scale))), @as([*c]const f32, @ptrCast(@alignCast(&units)))); - while (stackptr >= @as(c_int, 0)) { - var frame: [*c]par_shapes__stackframe = &(blk: { - const tmp = stackptr; - if (tmp >= 0) break :blk stack + @as(usize, @intCast(tmp)) else break :blk stack - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &frame; - var rule: [*c]par_shapes__rule = frame.*.rule; - _ = &rule; - var turtle_1: [*c]par_shapes_mesh = frame.*.orientation; - _ = &turtle_1; - var position: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(&frame.*.position))); - _ = &position; - var scale: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(&frame.*.scale))); - _ = &scale; - if (frame.*.pc >= rule.*.ncommands) { - par_shapes_free_mesh(turtle_1); - stackptr -= 1; - continue; - } - var cmd_2: [*c]par_shapes__command = rule.*.commands + @as(usize, @bitCast(@as(isize, @intCast(blk: { - const ref = &frame.*.pc; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - })))); - _ = &cmd_2; - var value: f32 = undefined; - _ = &value; - if (!(strcmp(cmd_2.*.cmd, "shape") != 0)) { - var m: [*c]par_shapes_mesh = par_shapes__apply_turtle(tube, turtle_1, position, scale); - _ = &m; - if (!(strcmp(cmd_2.*.arg, "connect") != 0)) { - par_shapes__connect(scene, m, slices); - } else { - par_shapes_merge(scene, m); - } - par_shapes_free_mesh(m); - } else if (!(strcmp(cmd_2.*.cmd, "call") != 0) and (stackptr < (maxdepth - @as(c_int, 1)))) { - rule = par_shapes__pick_rule(cmd_2.*.arg, rules, nrules); - frame = &(blk: { - const tmp = blk_1: { - const ref = &stackptr; - ref.* += 1; - break :blk_1 ref.*; - }; - if (tmp >= 0) break :blk stack + @as(usize, @intCast(tmp)) else break :blk stack - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - frame.*.rule = rule; - frame.*.orientation = par_shapes_clone(turtle_1, null); - frame.*.pc = 0; - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&frame.*.scale))), scale); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&frame.*.position))), position); - continue; - } else { - value = @as(f32, @floatCast(atof(cmd_2.*.arg))); - if (!(strcmp(cmd_2.*.cmd, "rx") != 0)) { - par_shapes_rotate(turtle_1, @as(f32, @floatCast((@as(f64, @floatCast(value)) * 3.14159265359) / 180.0)), @as([*c]const f32, @ptrCast(@alignCast(&xaxis)))); - } else if (!(strcmp(cmd_2.*.cmd, "ry") != 0)) { - par_shapes_rotate(turtle_1, @as(f32, @floatCast((@as(f64, @floatCast(value)) * 3.14159265359) / 180.0)), @as([*c]const f32, @ptrCast(@alignCast(&yaxis)))); - } else if (!(strcmp(cmd_2.*.cmd, "rz") != 0)) { - par_shapes_rotate(turtle_1, @as(f32, @floatCast((@as(f64, @floatCast(value)) * 3.14159265359) / 180.0)), @as([*c]const f32, @ptrCast(@alignCast(&zaxis)))); - } else if (!(strcmp(cmd_2.*.cmd, "tx") != 0)) { - var vec: [3]f32 = [3]f32{ - value, - 0, - 0, - }; - _ = &vec; - var t: [3]f32 = [3]f32{ - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 0))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - }; - _ = &t; - par_shapes__add3(position, @as([*c]f32, @ptrCast(@alignCast(&t)))); - } else if (!(strcmp(cmd_2.*.cmd, "ty") != 0)) { - var vec: [3]f32 = [3]f32{ - 0, - value, - 0, - }; - _ = &vec; - var t: [3]f32 = [3]f32{ - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 0))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - }; - _ = &t; - par_shapes__add3(position, @as([*c]f32, @ptrCast(@alignCast(&t)))); - } else if (!(strcmp(cmd_2.*.cmd, "tz") != 0)) { - var vec: [3]f32 = [3]f32{ - 0, - 0, - value, - }; - _ = &vec; - var t: [3]f32 = [3]f32{ - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 0))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - par_shapes__dot3(turtle_1.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))), @as([*c]f32, @ptrCast(@alignCast(&vec)))), - }; - _ = &t; - par_shapes__add3(position, @as([*c]f32, @ptrCast(@alignCast(&t)))); - } else if (!(strcmp(cmd_2.*.cmd, "sx") != 0)) { - scale[@as(c_uint, @intCast(@as(c_int, 0)))] *= value; - } else if (!(strcmp(cmd_2.*.cmd, "sy") != 0)) { - scale[@as(c_uint, @intCast(@as(c_int, 1)))] *= value; - } else if (!(strcmp(cmd_2.*.cmd, "sz") != 0)) { - scale[@as(c_uint, @intCast(@as(c_int, 2)))] *= value; - } else if (!(strcmp(cmd_2.*.cmd, "sa") != 0)) { - scale[@as(c_uint, @intCast(@as(c_int, 0)))] *= value; - scale[@as(c_uint, @intCast(@as(c_int, 1)))] *= value; - scale[@as(c_uint, @intCast(@as(c_int, 2)))] *= value; - } - } - } - free(@as(?*anyopaque, @ptrCast(stack))); - free(@as(?*anyopaque, @ptrCast(program))); - free(@as(?*anyopaque, @ptrCast(rules))); - free(@as(?*anyopaque, @ptrCast(commands))); - return scene; -} -pub export fn par_shapes_export(arg_mesh: [*c]const par_shapes_mesh, arg_filename: [*c]const u8) void { - var mesh = arg_mesh; - _ = &mesh; - var filename = arg_filename; - _ = &filename; - var objfile: [*c]FILE = fopen(filename, "wt"); - _ = &objfile; - var points: [*c]const f32 = mesh.*.points; - _ = &points; - var tcoords: [*c]const f32 = mesh.*.tcoords; - _ = &tcoords; - var norms: [*c]const f32 = mesh.*.normals; - _ = &norms; - var indices: [*c]const u16 = mesh.*.triangles; - _ = &indices; - if ((tcoords != null) and (norms != null)) { - { - var nvert: c_int = 0; - _ = &nvert; - while (nvert < mesh.*.npoints) : (nvert += 1) { - _ = fprintf(objfile, "v %f %f %f\n", @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 1)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 2)))]))); - _ = fprintf(objfile, "vt %f %f\n", @as(f64, @floatCast(tcoords[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(tcoords[@as(c_uint, @intCast(@as(c_int, 1)))]))); - _ = fprintf(objfile, "vn %f %f %f\n", @as(f64, @floatCast(norms[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(norms[@as(c_uint, @intCast(@as(c_int, 1)))])), @as(f64, @floatCast(norms[@as(c_uint, @intCast(@as(c_int, 2)))]))); - points += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - norms += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - tcoords += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - } - } - { - var nface: c_int = 0; - _ = &nface; - while (nface < mesh.*.ntriangles) : (nface += 1) { - var a: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &a; - var b: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &b; - var c: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &c; - _ = fprintf(objfile, "f %d/%d/%d %d/%d/%d %d/%d/%d\n", a, a, a, b, b, b, c, c, c); - } - } - } else if (norms != null) { - { - var nvert: c_int = 0; - _ = &nvert; - while (nvert < mesh.*.npoints) : (nvert += 1) { - _ = fprintf(objfile, "v %f %f %f\n", @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 1)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 2)))]))); - _ = fprintf(objfile, "vn %f %f %f\n", @as(f64, @floatCast(norms[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(norms[@as(c_uint, @intCast(@as(c_int, 1)))])), @as(f64, @floatCast(norms[@as(c_uint, @intCast(@as(c_int, 2)))]))); - points += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - norms += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - } - } - { - var nface: c_int = 0; - _ = &nface; - while (nface < mesh.*.ntriangles) : (nface += 1) { - var a: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &a; - var b: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &b; - var c: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &c; - _ = fprintf(objfile, "f %d//%d %d//%d %d//%d\n", a, a, b, b, c, c); - } - } - } else if (tcoords != null) { - { - var nvert: c_int = 0; - _ = &nvert; - while (nvert < mesh.*.npoints) : (nvert += 1) { - _ = fprintf(objfile, "v %f %f %f\n", @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 1)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 2)))]))); - _ = fprintf(objfile, "vt %f %f\n", @as(f64, @floatCast(tcoords[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(tcoords[@as(c_uint, @intCast(@as(c_int, 1)))]))); - points += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - tcoords += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2))))); - } - } - { - var nface: c_int = 0; - _ = &nface; - while (nface < mesh.*.ntriangles) : (nface += 1) { - var a: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &a; - var b: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &b; - var c: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &c; - _ = fprintf(objfile, "f %d/%d %d/%d %d/%d\n", a, a, b, b, c, c); - } - } - } else { - { - var nvert: c_int = 0; - _ = &nvert; - while (nvert < mesh.*.npoints) : (nvert += 1) { - _ = fprintf(objfile, "v %f %f %f\n", @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 0)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 1)))])), @as(f64, @floatCast(points[@as(c_uint, @intCast(@as(c_int, 2)))]))); - points += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - } - } - { - var nface: c_int = 0; - _ = &nface; - while (nface < mesh.*.ntriangles) : (nface += 1) { - var a: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &a; - var b: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &b; - var c: c_int = @as(c_int, 1) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &indices; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))); - _ = &c; - _ = fprintf(objfile, "f %d %d %d\n", a, b, c); - } - } - } - _ = fclose(objfile); -} -pub export fn par_shapes_compute_aabb(arg_m: [*c]const par_shapes_mesh, arg_aabb: [*c]f32) void { - var m = arg_m; - _ = &m; - var aabb = arg_aabb; - _ = &aabb; - var points: [*c]f32 = m.*.points; - _ = &points; - aabb[@as(c_uint, @intCast(@as(c_int, 0)))] = blk: { - const tmp = points[@as(c_uint, @intCast(@as(c_int, 0)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 3)))] = tmp; - break :blk tmp; - }; - aabb[@as(c_uint, @intCast(@as(c_int, 1)))] = blk: { - const tmp = points[@as(c_uint, @intCast(@as(c_int, 1)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 4)))] = tmp; - break :blk tmp; - }; - aabb[@as(c_uint, @intCast(@as(c_int, 2)))] = blk: { - const tmp = points[@as(c_uint, @intCast(@as(c_int, 2)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 5)))] = tmp; - break :blk tmp; - }; - points += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - { - var i: c_int = 1; - _ = &i; - while (i < m.*.npoints) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &points; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - aabb[@as(c_uint, @intCast(@as(c_int, 0)))] = if (points[@as(c_uint, @intCast(@as(c_int, 0)))] > aabb[@as(c_uint, @intCast(@as(c_int, 0)))]) aabb[@as(c_uint, @intCast(@as(c_int, 0)))] else points[@as(c_uint, @intCast(@as(c_int, 0)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 1)))] = if (points[@as(c_uint, @intCast(@as(c_int, 1)))] > aabb[@as(c_uint, @intCast(@as(c_int, 1)))]) aabb[@as(c_uint, @intCast(@as(c_int, 1)))] else points[@as(c_uint, @intCast(@as(c_int, 1)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 2)))] = if (points[@as(c_uint, @intCast(@as(c_int, 2)))] > aabb[@as(c_uint, @intCast(@as(c_int, 2)))]) aabb[@as(c_uint, @intCast(@as(c_int, 2)))] else points[@as(c_uint, @intCast(@as(c_int, 2)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 3)))] = if (points[@as(c_uint, @intCast(@as(c_int, 0)))] > aabb[@as(c_uint, @intCast(@as(c_int, 3)))]) points[@as(c_uint, @intCast(@as(c_int, 0)))] else aabb[@as(c_uint, @intCast(@as(c_int, 3)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 4)))] = if (points[@as(c_uint, @intCast(@as(c_int, 1)))] > aabb[@as(c_uint, @intCast(@as(c_int, 4)))]) points[@as(c_uint, @intCast(@as(c_int, 1)))] else aabb[@as(c_uint, @intCast(@as(c_int, 4)))]; - aabb[@as(c_uint, @intCast(@as(c_int, 5)))] = if (points[@as(c_uint, @intCast(@as(c_int, 2)))] > aabb[@as(c_uint, @intCast(@as(c_int, 5)))]) points[@as(c_uint, @intCast(@as(c_int, 2)))] else aabb[@as(c_uint, @intCast(@as(c_int, 5)))]; - } - } -} -pub export fn par_shapes_clone(arg_mesh: [*c]const par_shapes_mesh, arg_clone: [*c]par_shapes_mesh) [*c]par_shapes_mesh { - var mesh = arg_mesh; - _ = &mesh; - var clone = arg_clone; - _ = &clone; - if (!(clone != null)) { - clone = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - } - clone.*.npoints = mesh.*.npoints; - clone.*.points = @as([*c]f32, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(clone.*.points)), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * clone.*.npoints))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(clone.*.points)), @as(?*const anyopaque, @ptrCast(mesh.*.points)), (@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3))))) *% @as(c_ulong, @bitCast(@as(c_long, clone.*.npoints)))); - clone.*.ntriangles = mesh.*.ntriangles; - clone.*.triangles = @as([*c]u16, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(clone.*.triangles)), @sizeOf(u16) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * clone.*.ntriangles))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(clone.*.triangles)), @as(?*const anyopaque, @ptrCast(mesh.*.triangles)), (@sizeOf(u16) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3))))) *% @as(c_ulong, @bitCast(@as(c_long, clone.*.ntriangles)))); - if (mesh.*.normals != null) { - clone.*.normals = @as([*c]f32, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(clone.*.normals)), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * clone.*.npoints))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(clone.*.normals)), @as(?*const anyopaque, @ptrCast(mesh.*.normals)), (@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3))))) *% @as(c_ulong, @bitCast(@as(c_long, clone.*.npoints)))); - } - if (mesh.*.tcoords != null) { - clone.*.tcoords = @as([*c]f32, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(clone.*.tcoords)), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2) * clone.*.npoints))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(clone.*.tcoords)), @as(?*const anyopaque, @ptrCast(mesh.*.tcoords)), (@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2))))) *% @as(c_ulong, @bitCast(@as(c_long, clone.*.npoints)))); - } - return clone; -} -pub export fn par_shapes_merge(arg_dst: [*c]par_shapes_mesh, arg_src: [*c]const par_shapes_mesh) void { - var dst = arg_dst; - _ = &dst; - var src = arg_src; - _ = &src; - var offset: u16 = @as(u16, @bitCast(@as(c_short, @truncate(dst.*.npoints)))); - _ = &offset; - var npoints: c_int = dst.*.npoints + src.*.npoints; - _ = &npoints; - var vecsize: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate(@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - _ = &vecsize; - dst.*.points = @as([*c]f32, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(dst.*.points)), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * npoints))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(dst.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * dst.*.npoints)))))), @as(?*const anyopaque, @ptrCast(src.*.points)), @as(c_ulong, @bitCast(@as(c_long, vecsize * src.*.npoints)))); - dst.*.npoints = npoints; - if ((src.*.normals != null) or (dst.*.normals != null)) { - dst.*.normals = @as([*c]f32, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(dst.*.normals)), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * npoints))))))); - if (src.*.normals != null) { - _ = memcpy(@as(?*anyopaque, @ptrCast(dst.*.normals + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, offset))))))))), @as(?*const anyopaque, @ptrCast(src.*.normals)), @as(c_ulong, @bitCast(@as(c_long, vecsize * src.*.npoints)))); - } - } - if ((src.*.tcoords != null) or (dst.*.tcoords != null)) { - var uvsize: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate(@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2)))))))); - _ = &uvsize; - dst.*.tcoords = @as([*c]f32, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(dst.*.tcoords)), @sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2) * npoints))))))); - if (src.*.tcoords != null) { - _ = memcpy(@as(?*anyopaque, @ptrCast(dst.*.tcoords + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 2) * @as(c_int, @bitCast(@as(c_uint, offset))))))))), @as(?*const anyopaque, @ptrCast(src.*.tcoords)), @as(c_ulong, @bitCast(@as(c_long, uvsize * src.*.npoints)))); - } - } - var ntriangles: c_int = dst.*.ntriangles + src.*.ntriangles; - _ = &ntriangles; - dst.*.triangles = @as([*c]u16, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(dst.*.triangles)), @sizeOf(u16) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * ntriangles))))))); - var ptriangles: [*c]u16 = dst.*.triangles + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * dst.*.ntriangles)))); - _ = &ptriangles; - var striangles: [*c]const u16 = src.*.triangles; - _ = &striangles; - { - var i: c_int = 0; - _ = &i; - while (i < src.*.ntriangles) : (i += 1) { - (blk: { - const ref = &ptriangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, @bitCast(@as(c_uint, offset))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &striangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))))))); - (blk: { - const ref = &ptriangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, @bitCast(@as(c_uint, offset))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &striangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))))))); - (blk: { - const ref = &ptriangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, @bitCast(@as(c_uint, offset))) + @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &striangles; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))))))); - } - } - dst.*.ntriangles = ntriangles; -} -pub export fn par_shapes_translate(arg_m: [*c]par_shapes_mesh, arg_x: f32, arg_y: f32, arg_z: f32) void { - var m = arg_m; - _ = &m; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var points: [*c]f32 = m.*.points; - _ = &points; - { - var i: c_int = 0; - _ = &i; - while (i < m.*.npoints) : (i += 1) { - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* += x; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* += y; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* += z; - } - } -} -pub export fn par_shapes_rotate(arg_mesh: [*c]par_shapes_mesh, arg_radians: f32, arg_axis: [*c]const f32) void { - var mesh = arg_mesh; - _ = &mesh; - var radians = arg_radians; - _ = &radians; - var axis = arg_axis; - _ = &axis; - var s: f32 = sinf(radians); - _ = &s; - var c: f32 = cosf(radians); - _ = &c; - var x: f32 = axis[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &x; - var y: f32 = axis[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &y; - var z: f32 = axis[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &z; - var xy: f32 = x * y; - _ = &xy; - var yz: f32 = y * z; - _ = &yz; - var zx: f32 = z * x; - _ = &zx; - var oneMinusC: f32 = 1.0 - c; - _ = &oneMinusC; - var col0: [3]f32 = [3]f32{ - ((x * x) * oneMinusC) + c, - (xy * oneMinusC) + (z * s), - (zx * oneMinusC) - (y * s), - }; - _ = &col0; - var col1: [3]f32 = [3]f32{ - (xy * oneMinusC) - (z * s), - ((y * y) * oneMinusC) + c, - (yz * oneMinusC) + (x * s), - }; - _ = &col1; - var col2: [3]f32 = [3]f32{ - (zx * oneMinusC) + (y * s), - (yz * oneMinusC) - (x * s), - ((z * z) * oneMinusC) + c, - }; - _ = &col2; - var p: [*c]f32 = mesh.*.points; - _ = &p; - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &p; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var x_1: f32 = ((col0[@as(c_uint, @intCast(@as(c_int, 0)))] * p[@as(c_uint, @intCast(@as(c_int, 0)))]) + (col1[@as(c_uint, @intCast(@as(c_int, 0)))] * p[@as(c_uint, @intCast(@as(c_int, 1)))])) + (col2[@as(c_uint, @intCast(@as(c_int, 0)))] * p[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &x_1; - var y_2: f32 = ((col0[@as(c_uint, @intCast(@as(c_int, 1)))] * p[@as(c_uint, @intCast(@as(c_int, 0)))]) + (col1[@as(c_uint, @intCast(@as(c_int, 1)))] * p[@as(c_uint, @intCast(@as(c_int, 1)))])) + (col2[@as(c_uint, @intCast(@as(c_int, 1)))] * p[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &y_2; - var z_3: f32 = ((col0[@as(c_uint, @intCast(@as(c_int, 2)))] * p[@as(c_uint, @intCast(@as(c_int, 0)))]) + (col1[@as(c_uint, @intCast(@as(c_int, 2)))] * p[@as(c_uint, @intCast(@as(c_int, 1)))])) + (col2[@as(c_uint, @intCast(@as(c_int, 2)))] * p[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &z_3; - p[@as(c_uint, @intCast(@as(c_int, 0)))] = x_1; - p[@as(c_uint, @intCast(@as(c_int, 1)))] = y_2; - p[@as(c_uint, @intCast(@as(c_int, 2)))] = z_3; - } - } - var n: [*c]f32 = mesh.*.normals; - _ = &n; - if (n != null) { - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &n; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var x_1: f32 = ((col0[@as(c_uint, @intCast(@as(c_int, 0)))] * n[@as(c_uint, @intCast(@as(c_int, 0)))]) + (col1[@as(c_uint, @intCast(@as(c_int, 0)))] * n[@as(c_uint, @intCast(@as(c_int, 1)))])) + (col2[@as(c_uint, @intCast(@as(c_int, 0)))] * n[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &x_1; - var y_2: f32 = ((col0[@as(c_uint, @intCast(@as(c_int, 1)))] * n[@as(c_uint, @intCast(@as(c_int, 0)))]) + (col1[@as(c_uint, @intCast(@as(c_int, 1)))] * n[@as(c_uint, @intCast(@as(c_int, 1)))])) + (col2[@as(c_uint, @intCast(@as(c_int, 1)))] * n[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &y_2; - var z_3: f32 = ((col0[@as(c_uint, @intCast(@as(c_int, 2)))] * n[@as(c_uint, @intCast(@as(c_int, 0)))]) + (col1[@as(c_uint, @intCast(@as(c_int, 2)))] * n[@as(c_uint, @intCast(@as(c_int, 1)))])) + (col2[@as(c_uint, @intCast(@as(c_int, 2)))] * n[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &z_3; - n[@as(c_uint, @intCast(@as(c_int, 0)))] = x_1; - n[@as(c_uint, @intCast(@as(c_int, 1)))] = y_2; - n[@as(c_uint, @intCast(@as(c_int, 2)))] = z_3; - } - } - } -} -pub export fn par_shapes_scale(arg_m: [*c]par_shapes_mesh, arg_x: f32, arg_y: f32, arg_z: f32) void { - var m = arg_m; - _ = &m; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var points: [*c]f32 = m.*.points; - _ = &points; - { - var i: c_int = 0; - _ = &i; - while (i < m.*.npoints) : (i += 1) { - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* *= x; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* *= y; - (blk: { - const ref = &points; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* *= z; - } - } - var n: [*c]f32 = m.*.normals; - _ = &n; - if ((n != null) and !((x == y) and (y == z))) { - var x_zero: bool = x == @as(f32, @floatFromInt(@as(c_int, 0))); - _ = &x_zero; - var y_zero: bool = y == @as(f32, @floatFromInt(@as(c_int, 0))); - _ = &y_zero; - var z_zero: bool = z == @as(f32, @floatFromInt(@as(c_int, 0))); - _ = &z_zero; - if ((!x_zero and !y_zero) and !z_zero) { - x = 1.0 / x; - y = 1.0 / y; - z = 1.0 / z; - } else { - x = @as(f32, @floatFromInt(@intFromBool(((@as(c_int, @intFromBool(x_zero)) != 0) and !y_zero) and !z_zero))); - y = @as(f32, @floatFromInt(@intFromBool(((@as(c_int, @intFromBool(y_zero)) != 0) and !x_zero) and !z_zero))); - z = @as(f32, @floatFromInt(@intFromBool(((@as(c_int, @intFromBool(z_zero)) != 0) and !x_zero) and !y_zero))); - } - { - var i: c_int = 0; - _ = &i; - while (i < m.*.npoints) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &n; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - n[@as(c_uint, @intCast(@as(c_int, 0)))] *= x; - n[@as(c_uint, @intCast(@as(c_int, 1)))] *= y; - n[@as(c_uint, @intCast(@as(c_int, 2)))] *= z; - par_shapes__normalize3(n); - } - } - } -} -pub export fn par_shapes_merge_and_free(arg_dst: [*c]par_shapes_mesh, arg_src: [*c]par_shapes_mesh) void { - var dst = arg_dst; - _ = &dst; - var src = arg_src; - _ = &src; - par_shapes_merge(dst, src); - par_shapes_free_mesh(src); -} -pub export fn par_shapes_invert(arg_m: [*c]par_shapes_mesh, arg_face: c_int, arg_nfaces: c_int) void { - var m = arg_m; - _ = &m; - var face = arg_face; - _ = &face; - var nfaces = arg_nfaces; - _ = &nfaces; - nfaces = if (nfaces != 0) nfaces else m.*.ntriangles; - var tri: [*c]u16 = m.*.triangles + @as(usize, @bitCast(@as(isize, @intCast(face * @as(c_int, 3))))); - _ = &tri; - { - var i: c_int = 0; - _ = &i; - while (i < nfaces) : (i += 1) { - { - var tmp: u16 = tri[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &tmp; - tri[@as(c_uint, @intCast(@as(c_int, 2)))] = tri[@as(c_uint, @intCast(@as(c_int, 0)))]; - tri[@as(c_uint, @intCast(@as(c_int, 0)))] = tmp; - } - tri += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - } - } -} -pub export fn par_shapes_remove_degenerate(arg_mesh: [*c]par_shapes_mesh, arg_mintriarea: f32) void { - var mesh = arg_mesh; - _ = &mesh; - var mintriarea = arg_mintriarea; - _ = &mintriarea; - var ntriangles: c_int = 0; - _ = &ntriangles; - var triangles: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - _ = &triangles; - var dst: [*c]u16 = triangles; - _ = &dst; - var src: [*c]const u16 = mesh.*.triangles; - _ = &src; - var next: [3]f32 = undefined; - _ = &next; - var prev: [3]f32 = undefined; - _ = &prev; - var cp: [3]f32 = undefined; - _ = &cp; - var mincplen2: f32 = (mintriarea * @as(f32, @floatFromInt(@as(c_int, 2)))) * (mintriarea * @as(f32, @floatFromInt(@as(c_int, 2)))); - _ = &mincplen2; - { - var f: c_int = 0; - _ = &f; - while (f < mesh.*.ntriangles) : (_ = blk: { - f += 1; - break :blk blk_1: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var pa: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 0)))]))))))); - _ = &pa; - var pb: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 1)))]))))))); - _ = &pb; - var pc: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, src[@as(c_uint, @intCast(@as(c_int, 2)))]))))))); - _ = &pc; - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&next))), pb); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&next))), pa); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pc); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pa); - par_shapes__cross3(@as([*c]f32, @ptrCast(@alignCast(&cp))), @as([*c]f32, @ptrCast(@alignCast(&next))), @as([*c]f32, @ptrCast(@alignCast(&prev)))); - var cplen2: f32 = par_shapes__dot3(@as([*c]f32, @ptrCast(@alignCast(&cp))), @as([*c]f32, @ptrCast(@alignCast(&cp)))); - _ = &cplen2; - if (cplen2 >= mincplen2) { - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - ntriangles += 1; - } - } - } - mesh.*.ntriangles = ntriangles; - free(@as(?*anyopaque, @ptrCast(mesh.*.triangles))); - mesh.*.triangles = triangles; -} -pub export fn par_shapes_unweld(arg_mesh: [*c]par_shapes_mesh, arg_create_indices: bool) void { - var mesh = arg_mesh; - _ = &mesh; - var create_indices = arg_create_indices; - _ = &create_indices; - var npoints: c_int = mesh.*.ntriangles * @as(c_int, 3); - _ = &npoints; - var points: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * npoints))) *% @sizeOf(f32))))); - _ = &points; - var dst: [*c]f32 = points; - _ = &dst; - var index_1: [*c]const u16 = mesh.*.triangles; - _ = &index_1; - { - var i: c_int = 0; - _ = &i; - while (i < npoints) : (i += 1) { - var src: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, (blk: { - const ref = &index_1; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*))))))); - _ = &src; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - } - } - free(@as(?*anyopaque, @ptrCast(mesh.*.points))); - mesh.*.points = points; - mesh.*.npoints = npoints; - if (create_indices) { - var tris: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * mesh.*.ntriangles))) *% @sizeOf(u16))))); - _ = &tris; - var index_2: [*c]u16 = tris; - _ = &index_2; - { - var i: c_int = 0; - _ = &i; - while (i < (mesh.*.ntriangles * @as(c_int, 3))) : (i += 1) { - (blk: { - const ref = &index_2; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(i)))); - } - } - free(@as(?*anyopaque, @ptrCast(mesh.*.triangles))); - mesh.*.triangles = tris; - } -} -pub export fn par_shapes_weld(arg_mesh: [*c]const par_shapes_mesh, arg_epsilon: f32, arg_weldmap: [*c]u16) [*c]par_shapes_mesh { - var mesh = arg_mesh; - _ = &mesh; - var epsilon = arg_epsilon; - _ = ε - var weldmap = arg_weldmap; - _ = &weldmap; - var clone: [*c]par_shapes_mesh = par_shapes_clone(mesh, null); - _ = &clone; - var aabb: [6]f32 = undefined; - _ = &aabb; - var gridsize: c_int = 20; - _ = &gridsize; - var maxcell: f32 = @as(f32, @floatFromInt(gridsize - @as(c_int, 1))); - _ = &maxcell; - par_shapes_compute_aabb(clone, @as([*c]f32, @ptrCast(@alignCast(&aabb)))); - var scale: [3]f32 = [3]f32{ - if (aabb[@as(c_uint, @intCast(@as(c_int, 3)))] == aabb[@as(c_uint, @intCast(@as(c_int, 0)))]) 1.0 else maxcell / (aabb[@as(c_uint, @intCast(@as(c_int, 3)))] - aabb[@as(c_uint, @intCast(@as(c_int, 0)))]), - if (aabb[@as(c_uint, @intCast(@as(c_int, 4)))] == aabb[@as(c_uint, @intCast(@as(c_int, 1)))]) 1.0 else maxcell / (aabb[@as(c_uint, @intCast(@as(c_int, 4)))] - aabb[@as(c_uint, @intCast(@as(c_int, 1)))]), - if (aabb[@as(c_uint, @intCast(@as(c_int, 5)))] == aabb[@as(c_uint, @intCast(@as(c_int, 2)))]) 1.0 else maxcell / (aabb[@as(c_uint, @intCast(@as(c_int, 5)))] - aabb[@as(c_uint, @intCast(@as(c_int, 2)))]), - }; - _ = &scale; - par_shapes_translate(clone, -aabb[@as(c_uint, @intCast(@as(c_int, 0)))], -aabb[@as(c_uint, @intCast(@as(c_int, 1)))], -aabb[@as(c_uint, @intCast(@as(c_int, 2)))]); - par_shapes_scale(clone, scale[@as(c_uint, @intCast(@as(c_int, 0)))], scale[@as(c_uint, @intCast(@as(c_int, 1)))], scale[@as(c_uint, @intCast(@as(c_int, 2)))]); - var sortmap: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints))) *% @sizeOf(u16))))); - _ = &sortmap; - par_shapes__sort_points(clone, gridsize, sortmap); - var owner: bool = @as(c_int, 0) != 0; - _ = &owner; - if (!(weldmap != null)) { - owner = @as(c_int, 1) != 0; - weldmap = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints))) *% @sizeOf(u16))))); - } - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk weldmap + @as(usize, @intCast(tmp)) else break :blk weldmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u16, @bitCast(@as(c_short, @truncate(i)))); - } - } - par_shapes__weld_points(clone, gridsize, epsilon, weldmap); - if (owner) { - free(@as(?*anyopaque, @ptrCast(weldmap))); - } else { - var newmap: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints))) *% @sizeOf(u16))))); - _ = &newmap; - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk newmap + @as(usize, @intCast(tmp)) else break :blk newmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = weldmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk sortmap + @as(usize, @intCast(tmp)) else break :blk sortmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*]; - } - } - _ = memcpy(@as(?*anyopaque, @ptrCast(weldmap)), @as(?*const anyopaque, @ptrCast(newmap)), @sizeOf(u16) *% @as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints)))); - free(@as(?*anyopaque, @ptrCast(newmap))); - } - free(@as(?*anyopaque, @ptrCast(sortmap))); - par_shapes_scale(clone, @as(f32, @floatCast(1.0 / @as(f64, @floatCast(scale[@as(c_uint, @intCast(@as(c_int, 0)))])))), @as(f32, @floatCast(1.0 / @as(f64, @floatCast(scale[@as(c_uint, @intCast(@as(c_int, 1)))])))), @as(f32, @floatCast(1.0 / @as(f64, @floatCast(scale[@as(c_uint, @intCast(@as(c_int, 2)))]))))); - par_shapes_translate(clone, aabb[@as(c_uint, @intCast(@as(c_int, 0)))], aabb[@as(c_uint, @intCast(@as(c_int, 1)))], aabb[@as(c_uint, @intCast(@as(c_int, 2)))]); - return clone; -} -pub export fn par_shapes_compute_normals(arg_m: [*c]par_shapes_mesh) void { - var m = arg_m; - _ = &m; - free(@as(?*anyopaque, @ptrCast(m.*.normals))); - m.*.normals = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, m.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - var triangle: [*c]const u16 = m.*.triangles; - _ = ▵ - var next: [3]f32 = undefined; - _ = &next; - var prev: [3]f32 = undefined; - _ = &prev; - var cp: [3]f32 = undefined; - _ = &cp; - { - var f: c_int = 0; - _ = &f; - while (f < m.*.ntriangles) : (_ = blk: { - f += 1; - break :blk blk_1: { - const ref = ▵ - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var pa: [*c]const f32 = m.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, triangle[@as(c_uint, @intCast(@as(c_int, 0)))]))))))); - _ = &pa; - var pb: [*c]const f32 = m.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, triangle[@as(c_uint, @intCast(@as(c_int, 1)))]))))))); - _ = &pb; - var pc: [*c]const f32 = m.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, triangle[@as(c_uint, @intCast(@as(c_int, 2)))]))))))); - _ = &pc; - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&next))), pb); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&next))), pa); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pc); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pa); - par_shapes__cross3(@as([*c]f32, @ptrCast(@alignCast(&cp))), @as([*c]f32, @ptrCast(@alignCast(&next))), @as([*c]f32, @ptrCast(@alignCast(&prev)))); - par_shapes__add3(m.*.normals + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, triangle[@as(c_uint, @intCast(@as(c_int, 0)))]))))))), @as([*c]f32, @ptrCast(@alignCast(&cp)))); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&next))), pc); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&next))), pb); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pa); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pb); - par_shapes__cross3(@as([*c]f32, @ptrCast(@alignCast(&cp))), @as([*c]f32, @ptrCast(@alignCast(&next))), @as([*c]f32, @ptrCast(@alignCast(&prev)))); - par_shapes__add3(m.*.normals + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, triangle[@as(c_uint, @intCast(@as(c_int, 1)))]))))))), @as([*c]f32, @ptrCast(@alignCast(&cp)))); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&next))), pa); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&next))), pc); - par_shapes__copy3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pb); - par_shapes__subtract3(@as([*c]f32, @ptrCast(@alignCast(&prev))), pc); - par_shapes__cross3(@as([*c]f32, @ptrCast(@alignCast(&cp))), @as([*c]f32, @ptrCast(@alignCast(&next))), @as([*c]f32, @ptrCast(@alignCast(&prev)))); - par_shapes__add3(m.*.normals + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, triangle[@as(c_uint, @intCast(@as(c_int, 2)))]))))))), @as([*c]f32, @ptrCast(@alignCast(&cp)))); - } - } - var normal: [*c]f32 = m.*.normals; - _ = &normal; - { - var p: c_int = 0; - _ = &p; - while (p < m.*.npoints) : (_ = blk: { - p += 1; - break :blk blk_1: { - const ref = &normal; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - par_shapes__normalize3(normal); - } - } -} -pub export fn par_shapes_set_epsilon_welded_normals(arg_epsilon: f32) void { - var epsilon = arg_epsilon; - _ = ε - par_shapes__epsilon_welded_normals = epsilon; -} -pub export fn par_shapes_set_epsilon_degenerate_sphere(arg_epsilon: f32) void { - var epsilon = arg_epsilon; - _ = ε - par_shapes__epsilon_degenerate_sphere = epsilon; -} -pub export fn par_shapes__compute_welded_normals(arg_m: [*c]par_shapes_mesh) void { - var m = arg_m; - _ = &m; - const epsilon: f32 = par_shapes__epsilon_welded_normals; - _ = ε - m.*.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, m.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - var weldmap: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, m.*.npoints))) *% @sizeOf(u16))))); - _ = &weldmap; - var welded: [*c]par_shapes_mesh = par_shapes_weld(m, epsilon, weldmap); - _ = &welded; - par_shapes_compute_normals(welded); - var pdst: [*c]f32 = m.*.normals; - _ = &pdst; - { - var i: c_int = 0; - _ = &i; - while (i < m.*.npoints) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &pdst; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var d: c_int = @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk weldmap + @as(usize, @intCast(tmp)) else break :blk weldmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))); - _ = &d; - var pnormal: [*c]const f32 = welded.*.normals + @as(usize, @bitCast(@as(isize, @intCast(d * @as(c_int, 3))))); - _ = &pnormal; - pdst[@as(c_uint, @intCast(@as(c_int, 0)))] = pnormal[@as(c_uint, @intCast(@as(c_int, 0)))]; - pdst[@as(c_uint, @intCast(@as(c_int, 1)))] = pnormal[@as(c_uint, @intCast(@as(c_int, 1)))]; - pdst[@as(c_uint, @intCast(@as(c_int, 2)))] = pnormal[@as(c_uint, @intCast(@as(c_int, 2)))]; - } - } - free(@as(?*anyopaque, @ptrCast(weldmap))); - par_shapes_free_mesh(welded); -} -pub export fn par_shapes__connect(arg_scene: [*c]par_shapes_mesh, arg_cylinder: [*c]par_shapes_mesh, arg_slices: c_int) void { - var scene = arg_scene; - _ = &scene; - var cylinder = arg_cylinder; - _ = &cylinder; - var slices = arg_slices; - _ = &slices; - var stacks: c_int = 1; - _ = &stacks; - var npoints: c_int = (slices + @as(c_int, 1)) * (stacks + @as(c_int, 1)); - _ = &npoints; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((scene.*.npoints >= npoints) and (@intFromPtr("Cannot connect to empty scene.") != 0)) {} else { - __assert_fail("scene->npoints >= npoints && \"Cannot connect to empty scene.\"", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1184))), "void par_shapes__connect(par_shapes_mesh *, par_shapes_mesh *, int)"); - }; - }; - }; - npoints = scene.*.npoints + (slices + @as(c_int, 1)); - var points: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = &points; - _ = memcpy(@as(?*anyopaque, @ptrCast(points)), @as(?*const anyopaque, @ptrCast(scene.*.points)), (@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, scene.*.npoints)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3))))); - var newpts: [*c]f32 = points + @as(usize, @bitCast(@as(isize, @intCast(scene.*.npoints * @as(c_int, 3))))); - _ = &newpts; - _ = memcpy(@as(?*anyopaque, @ptrCast(newpts)), @as(?*const anyopaque, @ptrCast(cylinder.*.points + @as(usize, @bitCast(@as(isize, @intCast((slices + @as(c_int, 1)) * @as(c_int, 3))))))), (@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_long, slices + @as(c_int, 1))))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3))))); - free(@as(?*anyopaque, @ptrCast(scene.*.points))); - scene.*.points = points; - var ntriangles: c_int = scene.*.ntriangles + ((@as(c_int, 2) * slices) * stacks); - _ = &ntriangles; - var triangles: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - _ = &triangles; - _ = memcpy(@as(?*anyopaque, @ptrCast(triangles)), @as(?*const anyopaque, @ptrCast(scene.*.triangles)), (@sizeOf(u16) *% @as(c_ulong, @bitCast(@as(c_long, scene.*.ntriangles)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3))))); - var v: c_int = scene.*.npoints - (slices + @as(c_int, 1)); - _ = &v; - var face: [*c]u16 = triangles + @as(usize, @bitCast(@as(isize, @intCast(scene.*.ntriangles * @as(c_int, 3))))); - _ = &face; - { - var stack: c_int = 0; - _ = &stack; - while (stack < stacks) : (stack += 1) { - { - var slice: c_int = 0; - _ = &slice; - while (slice < slices) : (slice += 1) { - var next: c_int = slice + @as(c_int, 1); - _ = &next; - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(((v + slice) + slices) + @as(c_int, 1))))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(v + next)))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(v + slice)))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(((v + slice) + slices) + @as(c_int, 1))))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(((v + next) + slices) + @as(c_int, 1))))); - (blk: { - const ref = &face; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(v + next)))); - } - } - v += slices + @as(c_int, 1); - } - } - free(@as(?*anyopaque, @ptrCast(scene.*.triangles))); - scene.*.triangles = triangles; - scene.*.npoints = npoints; - scene.*.ntriangles = ntriangles; -} -pub var par_shapes__epsilon_welded_normals: f32 = @as(f32, @floatCast(0.001)); -pub var par_shapes__epsilon_degenerate_sphere: f32 = @as(f32, @floatCast(0.0001)); -pub fn par_shapes__sphere(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var phi: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 0)))])) * 3.14159265359)); - _ = φ - var theta: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = θ - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = cosf(theta) * sinf(phi); - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = sinf(theta) * sinf(phi); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = cosf(phi); -} -pub fn par_shapes__hemisphere(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var phi: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 0)))])) * 3.14159265359)); - _ = φ - var theta: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))])) * 3.14159265359)); - _ = θ - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = cosf(theta) * sinf(phi); - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = sinf(theta) * sinf(phi); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = cosf(phi); -} -pub fn par_shapes__plane(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = uv[@as(c_uint, @intCast(@as(c_int, 0)))]; - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = uv[@as(c_uint, @intCast(@as(c_int, 1)))]; - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = 0; -} -pub fn par_shapes__klein(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var u: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 0)))])) * 3.14159265359)); - _ = &u; - var v: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = &v; - u = u * @as(f32, @floatFromInt(@as(c_int, 2))); - if (@as(f64, @floatCast(u)) < 3.14159265359) { - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = ((@as(f32, @floatFromInt(@as(c_int, 3))) * cosf(u)) * (@as(f32, @floatFromInt(@as(c_int, 1))) + sinf(u))) + (((@as(f32, @floatFromInt(@as(c_int, 2))) * (@as(f32, @floatFromInt(@as(c_int, 1))) - (cosf(u) / @as(f32, @floatFromInt(@as(c_int, 2)))))) * cosf(u)) * cosf(v)); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = (@as(f32, @floatFromInt(-@as(c_int, 8))) * sinf(u)) - (((@as(f32, @floatFromInt(@as(c_int, 2))) * (@as(f32, @floatFromInt(@as(c_int, 1))) - (cosf(u) / @as(f32, @floatFromInt(@as(c_int, 2)))))) * sinf(u)) * cosf(v)); - } else { - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = ((@as(f32, @floatFromInt(@as(c_int, 3))) * cosf(u)) * (@as(f32, @floatFromInt(@as(c_int, 1))) + sinf(u))) + ((@as(f32, @floatFromInt(@as(c_int, 2))) * (@as(f32, @floatFromInt(@as(c_int, 1))) - (cosf(u) / @as(f32, @floatFromInt(@as(c_int, 2)))))) * cosf(@as(f32, @floatCast(@as(f64, @floatCast(v)) + 3.14159265359)))); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = @as(f32, @floatFromInt(-@as(c_int, 8))) * sinf(u); - } - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = (@as(f32, @floatFromInt(-@as(c_int, 2))) * (@as(f32, @floatFromInt(@as(c_int, 1))) - (cosf(u) / @as(f32, @floatFromInt(@as(c_int, 2)))))) * sinf(v); -} -pub fn par_shapes__cylinder(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var theta: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = θ - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = sinf(theta); - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = cosf(theta); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = uv[@as(c_uint, @intCast(@as(c_int, 0)))]; -} -pub fn par_shapes__cone(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var r: f32 = 1.0 - uv[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &r; - var theta: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = θ - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = r * sinf(theta); - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = r * cosf(theta); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = uv[@as(c_uint, @intCast(@as(c_int, 0)))]; -} -pub fn par_shapes__torus(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var major: f32 = 1; - _ = &major; - var minor: f32 = @as([*c]f32, @ptrCast(@alignCast(userdata))).*; - _ = &minor; - var theta: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 0)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = θ - var phi: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = φ - var beta: f32 = major + (minor * cosf(phi)); - _ = β - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = cosf(theta) * beta; - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = sinf(theta) * beta; - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = sinf(phi) * minor; -} -pub fn par_shapes__trefoil(arg_uv: [*c]const f32, arg_xyz: [*c]f32, arg_userdata: ?*anyopaque) callconv(.C) void { - var uv = arg_uv; - _ = &uv; - var xyz = arg_xyz; - _ = &xyz; - var userdata = arg_userdata; - _ = &userdata; - var minor: f32 = @as([*c]f32, @ptrCast(@alignCast(userdata))).*; - _ = &minor; - const a: f32 = 0.5; - _ = &a; - const b: f32 = 0.30000001192092896; - _ = &b; - const c: f32 = 0.5; - _ = &c; - const d: f32 = minor * 0.10000000149011612; - _ = &d; - const u: f32 = @as(f32, @floatCast(@as(f64, @floatCast((@as(f32, @floatFromInt(@as(c_int, 1))) - uv[@as(c_uint, @intCast(@as(c_int, 0)))]) * @as(f32, @floatFromInt(@as(c_int, 4))))) * 3.14159265359)); - _ = &u; - const v: f32 = @as(f32, @floatCast(@as(f64, @floatCast(uv[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(f32, @floatFromInt(@as(c_int, 2))))) * 3.14159265359)); - _ = &v; - const r: f32 = @as(f32, @floatCast(@as(f64, @floatCast(a)) + (@as(f64, @floatCast(b)) * cos(@as(f64, @floatCast(1.5 * u)))))); - _ = &r; - const x: f32 = @as(f32, @floatCast(@as(f64, @floatCast(r)) * cos(@as(f64, @floatCast(u))))); - _ = &x; - const y: f32 = @as(f32, @floatCast(@as(f64, @floatCast(r)) * sin(@as(f64, @floatCast(u))))); - _ = &y; - const z: f32 = @as(f32, @floatCast(@as(f64, @floatCast(c)) * sin(@as(f64, @floatCast(1.5 * u))))); - _ = &z; - var q: [3]f32 = undefined; - _ = &q; - q[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(f32, @floatCast(((@as(f64, @floatCast(-1.5 * b)) * sin(@as(f64, @floatCast(1.5 * u)))) * cos(@as(f64, @floatCast(u)))) - ((@as(f64, @floatCast(a)) + (@as(f64, @floatCast(b)) * cos(@as(f64, @floatCast(1.5 * u))))) * sin(@as(f64, @floatCast(u)))))); - q[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(f32, @floatCast(((@as(f64, @floatCast(-1.5 * b)) * sin(@as(f64, @floatCast(1.5 * u)))) * sin(@as(f64, @floatCast(u)))) + ((@as(f64, @floatCast(a)) + (@as(f64, @floatCast(b)) * cos(@as(f64, @floatCast(1.5 * u))))) * cos(@as(f64, @floatCast(u)))))); - q[@as(c_uint, @intCast(@as(c_int, 2)))] = @as(f32, @floatCast(@as(f64, @floatCast(1.5 * c)) * cos(@as(f64, @floatCast(1.5 * u))))); - par_shapes__normalize3(@as([*c]f32, @ptrCast(@alignCast(&q)))); - var qvn: [3]f32 = [3]f32{ - q[@as(c_uint, @intCast(@as(c_int, 1)))], - -q[@as(c_uint, @intCast(@as(c_int, 0)))], - 0, - }; - _ = &qvn; - par_shapes__normalize3(@as([*c]f32, @ptrCast(@alignCast(&qvn)))); - var ww: [3]f32 = undefined; - _ = &ww; - par_shapes__cross3(@as([*c]f32, @ptrCast(@alignCast(&ww))), @as([*c]f32, @ptrCast(@alignCast(&q))), @as([*c]f32, @ptrCast(@alignCast(&qvn)))); - xyz[@as(c_uint, @intCast(@as(c_int, 0)))] = @as(f32, @floatCast(@as(f64, @floatCast(x)) + (@as(f64, @floatCast(d)) * ((@as(f64, @floatCast(qvn[@as(c_uint, @intCast(@as(c_int, 0)))])) * cos(@as(f64, @floatCast(v)))) + (@as(f64, @floatCast(ww[@as(c_uint, @intCast(@as(c_int, 0)))])) * sin(@as(f64, @floatCast(v)))))))); - xyz[@as(c_uint, @intCast(@as(c_int, 1)))] = @as(f32, @floatCast(@as(f64, @floatCast(y)) + (@as(f64, @floatCast(d)) * ((@as(f64, @floatCast(qvn[@as(c_uint, @intCast(@as(c_int, 1)))])) * cos(@as(f64, @floatCast(v)))) + (@as(f64, @floatCast(ww[@as(c_uint, @intCast(@as(c_int, 1)))])) * sin(@as(f64, @floatCast(v)))))))); - xyz[@as(c_uint, @intCast(@as(c_int, 2)))] = @as(f32, @floatCast(@as(f64, @floatCast(z)) + (@as(f64, @floatCast(d * ww[@as(c_uint, @intCast(@as(c_int, 2)))])) * sin(@as(f64, @floatCast(v)))))); -} -pub fn par__simplex_noise(arg_seed: i64, arg_ctx: [*c][*c]struct_osn_context) callconv(.C) c_int { - var seed = arg_seed; - _ = &seed; - var ctx = arg_ctx; - _ = &ctx; - var rc: c_int = undefined; - _ = &rc; - var source: [256]i16 = undefined; - _ = &source; - var i: c_int = undefined; - _ = &i; - var perm: [*c]i16 = undefined; - _ = &perm; - var permGradIndex3D: [*c]i16 = undefined; - _ = &permGradIndex3D; - ctx.* = @as([*c]struct_osn_context, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(struct_osn_context))))); - if (!(ctx.* != null)) { - return -@as(c_int, 12); - } - ctx.*.*.perm = null; - ctx.*.*.permGradIndex3D = null; - rc = allocate_perm(ctx.*, @as(c_int, 256), @as(c_int, 256)); - if (rc != 0) { - free(@as(?*anyopaque, @ptrCast(ctx.*))); - return rc; - } - perm = ctx.*.*.perm; - permGradIndex3D = ctx.*.*.permGradIndex3D; - { - i = 0; - while (i < @as(c_int, 256)) : (i += 1) { - source[@as(c_uint, @intCast(i))] = @as(i16, @bitCast(@as(c_short, @truncate(i)))); - } - } - seed = @as(i64, @bitCast(@as(c_long, @truncate((@as(c_longlong, @bitCast(@as(c_longlong, seed))) * @as(c_longlong, 6364136223846793005)) + @as(c_longlong, 1442695040888963407))))); - seed = @as(i64, @bitCast(@as(c_long, @truncate((@as(c_longlong, @bitCast(@as(c_longlong, seed))) * @as(c_longlong, 6364136223846793005)) + @as(c_longlong, 1442695040888963407))))); - seed = @as(i64, @bitCast(@as(c_long, @truncate((@as(c_longlong, @bitCast(@as(c_longlong, seed))) * @as(c_longlong, 6364136223846793005)) + @as(c_longlong, 1442695040888963407))))); - { - i = 255; - while (i >= @as(c_int, 0)) : (i -= 1) { - seed = @as(i64, @bitCast(@as(c_long, @truncate((@as(c_longlong, @bitCast(@as(c_longlong, seed))) * @as(c_longlong, 6364136223846793005)) + @as(c_longlong, 1442695040888963407))))); - var r: c_int = @as(c_int, @bitCast(@as(c_int, @truncate(@import("std").zig.c_translation.signedRemainder(seed + @as(i64, @bitCast(@as(c_long, @as(c_int, 31)))), @as(i64, @bitCast(@as(c_long, i + @as(c_int, 1))))))))); - _ = &r; - if (r < @as(c_int, 0)) { - r += i + @as(c_int, 1); - } - (blk: { - const tmp = i; - if (tmp >= 0) break :blk perm + @as(usize, @intCast(tmp)) else break :blk perm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = source[@as(c_uint, @intCast(r))]; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk permGradIndex3D + @as(usize, @intCast(tmp)) else break :blk permGradIndex3D - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_short, @bitCast(@as(c_ushort, @truncate((@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk perm + @as(usize, @intCast(tmp)) else break :blk perm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) % ((@sizeOf([72]i8) / @sizeOf(i8)) / @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - source[@as(c_uint, @intCast(r))] = source[@as(c_uint, @intCast(i))]; - } - } - return 0; -} -pub fn par__simplex_noise_free(arg_ctx: [*c]struct_osn_context) callconv(.C) void { - var ctx = arg_ctx; - _ = &ctx; - if (!(ctx != null)) return; - if (ctx.*.perm != null) { - free(@as(?*anyopaque, @ptrCast(ctx.*.perm))); - ctx.*.perm = null; - } - if (ctx.*.permGradIndex3D != null) { - free(@as(?*anyopaque, @ptrCast(ctx.*.permGradIndex3D))); - ctx.*.permGradIndex3D = null; - } - free(@as(?*anyopaque, @ptrCast(ctx))); -} -pub fn par__simplex_noise2(arg_ctx: [*c]struct_osn_context, arg_x: f64, arg_y: f64) callconv(.C) f64 { - var ctx = arg_ctx; - _ = &ctx; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var stretchOffset: f64 = (x + y) * -0.211324865405187; - _ = &stretchOffset; - var xs: f64 = x + stretchOffset; - _ = &xs; - var ys: f64 = y + stretchOffset; - _ = &ys; - var xsb: c_int = fastFloor(xs); - _ = &xsb; - var ysb: c_int = fastFloor(ys); - _ = &ysb; - var squishOffset: f64 = @as(f64, @floatFromInt(xsb + ysb)) * 0.366025403784439; - _ = &squishOffset; - var xb: f64 = @as(f64, @floatFromInt(xsb)) + squishOffset; - _ = &xb; - var yb: f64 = @as(f64, @floatFromInt(ysb)) + squishOffset; - _ = &yb; - var xins: f64 = xs - @as(f64, @floatFromInt(xsb)); - _ = &xins; - var yins: f64 = ys - @as(f64, @floatFromInt(ysb)); - _ = &yins; - var inSum: f64 = xins + yins; - _ = &inSum; - var dx0: f64 = x - xb; - _ = &dx0; - var dy0: f64 = y - yb; - _ = &dy0; - var dx_ext: f64 = undefined; - _ = &dx_ext; - var dy_ext: f64 = undefined; - _ = &dy_ext; - var xsv_ext: c_int = undefined; - _ = &xsv_ext; - var ysv_ext: c_int = undefined; - _ = &ysv_ext; - var value: f64 = 0; - _ = &value; - var dx1: f64 = (dx0 - @as(f64, @floatFromInt(@as(c_int, 1)))) - 0.366025403784439; - _ = &dx1; - var dy1: f64 = (dy0 - @as(f64, @floatFromInt(@as(c_int, 0)))) - 0.366025403784439; - _ = &dy1; - var attn1: f64 = (@as(f64, @floatFromInt(@as(c_int, 2))) - (dx1 * dx1)) - (dy1 * dy1); - _ = &attn1; - if (attn1 > @as(f64, @floatFromInt(@as(c_int, 0)))) { - attn1 *= attn1; - value += (attn1 * attn1) * extrapolate2(ctx, xsb + @as(c_int, 1), ysb + @as(c_int, 0), dx1, dy1); - } - var dx2: f64 = (dx0 - @as(f64, @floatFromInt(@as(c_int, 0)))) - 0.366025403784439; - _ = &dx2; - var dy2: f64 = (dy0 - @as(f64, @floatFromInt(@as(c_int, 1)))) - 0.366025403784439; - _ = &dy2; - var attn2: f64 = (@as(f64, @floatFromInt(@as(c_int, 2))) - (dx2 * dx2)) - (dy2 * dy2); - _ = &attn2; - if (attn2 > @as(f64, @floatFromInt(@as(c_int, 0)))) { - attn2 *= attn2; - value += (attn2 * attn2) * extrapolate2(ctx, xsb + @as(c_int, 0), ysb + @as(c_int, 1), dx2, dy2); - } - if (inSum <= @as(f64, @floatFromInt(@as(c_int, 1)))) { - var zins: f64 = @as(f64, @floatFromInt(@as(c_int, 1))) - inSum; - _ = &zins; - if ((zins > xins) or (zins > yins)) { - if (xins > yins) { - xsv_ext = xsb + @as(c_int, 1); - ysv_ext = ysb - @as(c_int, 1); - dx_ext = dx0 - @as(f64, @floatFromInt(@as(c_int, 1))); - dy_ext = dy0 + @as(f64, @floatFromInt(@as(c_int, 1))); - } else { - xsv_ext = xsb - @as(c_int, 1); - ysv_ext = ysb + @as(c_int, 1); - dx_ext = dx0 + @as(f64, @floatFromInt(@as(c_int, 1))); - dy_ext = dy0 - @as(f64, @floatFromInt(@as(c_int, 1))); - } - } else { - xsv_ext = xsb + @as(c_int, 1); - ysv_ext = ysb + @as(c_int, 1); - dx_ext = (dx0 - @as(f64, @floatFromInt(@as(c_int, 1)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - dy_ext = (dy0 - @as(f64, @floatFromInt(@as(c_int, 1)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - } - } else { - var zins: f64 = @as(f64, @floatFromInt(@as(c_int, 2))) - inSum; - _ = &zins; - if ((zins < xins) or (zins < yins)) { - if (xins > yins) { - xsv_ext = xsb + @as(c_int, 2); - ysv_ext = ysb + @as(c_int, 0); - dx_ext = (dx0 - @as(f64, @floatFromInt(@as(c_int, 2)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - dy_ext = (dy0 + @as(f64, @floatFromInt(@as(c_int, 0)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - } else { - xsv_ext = xsb + @as(c_int, 0); - ysv_ext = ysb + @as(c_int, 2); - dx_ext = (dx0 + @as(f64, @floatFromInt(@as(c_int, 0)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - dy_ext = (dy0 - @as(f64, @floatFromInt(@as(c_int, 2)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - } - } else { - dx_ext = dx0; - dy_ext = dy0; - xsv_ext = xsb; - ysv_ext = ysb; - } - xsb += @as(c_int, 1); - ysb += @as(c_int, 1); - dx0 = (dx0 - @as(f64, @floatFromInt(@as(c_int, 1)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - dy0 = (dy0 - @as(f64, @floatFromInt(@as(c_int, 1)))) - (@as(f64, @floatFromInt(@as(c_int, 2))) * 0.366025403784439); - } - var attn0: f64 = (@as(f64, @floatFromInt(@as(c_int, 2))) - (dx0 * dx0)) - (dy0 * dy0); - _ = &attn0; - if (attn0 > @as(f64, @floatFromInt(@as(c_int, 0)))) { - attn0 *= attn0; - value += (attn0 * attn0) * extrapolate2(ctx, xsb, ysb, dx0, dy0); - } - var attn_ext: f64 = (@as(f64, @floatFromInt(@as(c_int, 2))) - (dx_ext * dx_ext)) - (dy_ext * dy_ext); - _ = &attn_ext; - if (attn_ext > @as(f64, @floatFromInt(@as(c_int, 0)))) { - attn_ext *= attn_ext; - value += (attn_ext * attn_ext) * extrapolate2(ctx, xsv_ext, ysv_ext, dx_ext, dy_ext); - } - return value / 47.0; -} -pub fn par_shapes__copy3(arg_result: [*c]f32, arg_a: [*c]const f32) callconv(.C) void { - var result = arg_result; - _ = &result; - var a = arg_a; - _ = &a; - result[@as(c_uint, @intCast(@as(c_int, 0)))] = a[@as(c_uint, @intCast(@as(c_int, 0)))]; - result[@as(c_uint, @intCast(@as(c_int, 1)))] = a[@as(c_uint, @intCast(@as(c_int, 1)))]; - result[@as(c_uint, @intCast(@as(c_int, 2)))] = a[@as(c_uint, @intCast(@as(c_int, 2)))]; -} -pub fn par_shapes__dot3(arg_a: [*c]const f32, arg_b: [*c]const f32) callconv(.C) f32 { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - return ((b[@as(c_uint, @intCast(@as(c_int, 0)))] * a[@as(c_uint, @intCast(@as(c_int, 0)))]) + (b[@as(c_uint, @intCast(@as(c_int, 1)))] * a[@as(c_uint, @intCast(@as(c_int, 1)))])) + (b[@as(c_uint, @intCast(@as(c_int, 2)))] * a[@as(c_uint, @intCast(@as(c_int, 2)))]); -} -pub fn par_shapes__transform3(arg_p: [*c]f32, arg_x: [*c]const f32, arg_y: [*c]const f32, arg_z: [*c]const f32) callconv(.C) void { - var p = arg_p; - _ = &p; - var x = arg_x; - _ = &x; - var y = arg_y; - _ = &y; - var z = arg_z; - _ = &z; - var px: f32 = par_shapes__dot3(p, x); - _ = &px; - var py: f32 = par_shapes__dot3(p, y); - _ = &py; - var pz: f32 = par_shapes__dot3(p, z); - _ = &pz; - p[@as(c_uint, @intCast(@as(c_int, 0)))] = px; - p[@as(c_uint, @intCast(@as(c_int, 1)))] = py; - p[@as(c_uint, @intCast(@as(c_int, 2)))] = pz; -} -pub fn par_shapes__cross3(arg_result: [*c]f32, arg_a: [*c]const f32, arg_b: [*c]const f32) callconv(.C) void { - var result = arg_result; - _ = &result; - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var x: f32 = (a[@as(c_uint, @intCast(@as(c_int, 1)))] * b[@as(c_uint, @intCast(@as(c_int, 2)))]) - (a[@as(c_uint, @intCast(@as(c_int, 2)))] * b[@as(c_uint, @intCast(@as(c_int, 1)))]); - _ = &x; - var y: f32 = (a[@as(c_uint, @intCast(@as(c_int, 2)))] * b[@as(c_uint, @intCast(@as(c_int, 0)))]) - (a[@as(c_uint, @intCast(@as(c_int, 0)))] * b[@as(c_uint, @intCast(@as(c_int, 2)))]); - _ = &y; - var z: f32 = (a[@as(c_uint, @intCast(@as(c_int, 0)))] * b[@as(c_uint, @intCast(@as(c_int, 1)))]) - (a[@as(c_uint, @intCast(@as(c_int, 1)))] * b[@as(c_uint, @intCast(@as(c_int, 0)))]); - _ = &z; - result[@as(c_uint, @intCast(@as(c_int, 0)))] = x; - result[@as(c_uint, @intCast(@as(c_int, 1)))] = y; - result[@as(c_uint, @intCast(@as(c_int, 2)))] = z; -} -pub fn par_shapes__mix3(arg_d: [*c]f32, arg_a: [*c]const f32, arg_b: [*c]const f32, arg_t: f32) callconv(.C) void { - var d = arg_d; - _ = &d; - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var t = arg_t; - _ = &t; - var x: f32 = (b[@as(c_uint, @intCast(@as(c_int, 0)))] * t) + (a[@as(c_uint, @intCast(@as(c_int, 0)))] * (@as(f32, @floatFromInt(@as(c_int, 1))) - t)); - _ = &x; - var y: f32 = (b[@as(c_uint, @intCast(@as(c_int, 1)))] * t) + (a[@as(c_uint, @intCast(@as(c_int, 1)))] * (@as(f32, @floatFromInt(@as(c_int, 1))) - t)); - _ = &y; - var z: f32 = (b[@as(c_uint, @intCast(@as(c_int, 2)))] * t) + (a[@as(c_uint, @intCast(@as(c_int, 2)))] * (@as(f32, @floatFromInt(@as(c_int, 1))) - t)); - _ = &z; - d[@as(c_uint, @intCast(@as(c_int, 0)))] = x; - d[@as(c_uint, @intCast(@as(c_int, 1)))] = y; - d[@as(c_uint, @intCast(@as(c_int, 2)))] = z; -} -pub fn par_shapes__scale3(arg_result: [*c]f32, arg_a: f32) callconv(.C) void { - var result = arg_result; - _ = &result; - var a = arg_a; - _ = &a; - result[@as(c_uint, @intCast(@as(c_int, 0)))] *= a; - result[@as(c_uint, @intCast(@as(c_int, 1)))] *= a; - result[@as(c_uint, @intCast(@as(c_int, 2)))] *= a; -} -pub fn par_shapes__normalize3(arg_v: [*c]f32) callconv(.C) void { - var v = arg_v; - _ = &v; - var lsqr: f32 = @as(f32, @floatCast(sqrt(@as(f64, @floatCast(((v[@as(c_uint, @intCast(@as(c_int, 0)))] * v[@as(c_uint, @intCast(@as(c_int, 0)))]) + (v[@as(c_uint, @intCast(@as(c_int, 1)))] * v[@as(c_uint, @intCast(@as(c_int, 1)))])) + (v[@as(c_uint, @intCast(@as(c_int, 2)))] * v[@as(c_uint, @intCast(@as(c_int, 2)))])))))); - _ = &lsqr; - if (lsqr > @as(f32, @floatFromInt(@as(c_int, 0)))) { - par_shapes__scale3(v, 1.0 / lsqr); - } -} -pub fn par_shapes__subtract3(arg_result: [*c]f32, arg_a: [*c]const f32) callconv(.C) void { - var result = arg_result; - _ = &result; - var a = arg_a; - _ = &a; - result[@as(c_uint, @intCast(@as(c_int, 0)))] -= a[@as(c_uint, @intCast(@as(c_int, 0)))]; - result[@as(c_uint, @intCast(@as(c_int, 1)))] -= a[@as(c_uint, @intCast(@as(c_int, 1)))]; - result[@as(c_uint, @intCast(@as(c_int, 2)))] -= a[@as(c_uint, @intCast(@as(c_int, 2)))]; -} -pub fn par_shapes__add3(arg_result: [*c]f32, arg_a: [*c]const f32) callconv(.C) void { - var result = arg_result; - _ = &result; - var a = arg_a; - _ = &a; - result[@as(c_uint, @intCast(@as(c_int, 0)))] += a[@as(c_uint, @intCast(@as(c_int, 0)))]; - result[@as(c_uint, @intCast(@as(c_int, 1)))] += a[@as(c_uint, @intCast(@as(c_int, 1)))]; - result[@as(c_uint, @intCast(@as(c_int, 2)))] += a[@as(c_uint, @intCast(@as(c_int, 2)))]; -} -pub fn par_shapes__sqrdist3(arg_a: [*c]const f32, arg_b: [*c]const f32) callconv(.C) f32 { - var a = arg_a; - _ = &a; - var b = arg_b; - _ = &b; - var dx: f32 = a[@as(c_uint, @intCast(@as(c_int, 0)))] - b[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &dx; - var dy: f32 = a[@as(c_uint, @intCast(@as(c_int, 1)))] - b[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &dy; - var dz: f32 = a[@as(c_uint, @intCast(@as(c_int, 2)))] - b[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &dz; - return ((dx * dx) + (dy * dy)) + (dz * dz); -} -pub const par_shapes__command = extern struct { - cmd: [*c]u8 = @import("std").mem.zeroes([*c]u8), - arg: [*c]u8 = @import("std").mem.zeroes([*c]u8), -}; -pub const par_shapes__rule = extern struct { - name: [*c]const u8 = @import("std").mem.zeroes([*c]const u8), - weight: c_int = @import("std").mem.zeroes(c_int), - ncommands: c_int = @import("std").mem.zeroes(c_int), - commands: [*c]par_shapes__command = @import("std").mem.zeroes([*c]par_shapes__command), -}; -pub const par_shapes__stackframe = extern struct { - pc: c_int = @import("std").mem.zeroes(c_int), - position: [3]f32 = @import("std").mem.zeroes([3]f32), - scale: [3]f32 = @import("std").mem.zeroes([3]f32), - orientation: [*c]par_shapes_mesh = @import("std").mem.zeroes([*c]par_shapes_mesh), - rule: [*c]par_shapes__rule = @import("std").mem.zeroes([*c]par_shapes__rule), -}; -pub fn par_shapes__pick_rule(arg_name: [*c]const u8, arg_rules: [*c]par_shapes__rule, arg_nrules: c_int) callconv(.C) [*c]par_shapes__rule { - var name = arg_name; - _ = &name; - var rules = arg_rules; - _ = &rules; - var nrules = arg_nrules; - _ = &nrules; - var rule: [*c]par_shapes__rule = null; - _ = &rule; - var total: c_int = 0; - _ = &total; - { - var i: c_int = 0; - _ = &i; - while (i < nrules) : (i += 1) { - rule = rules + @as(usize, @bitCast(@as(isize, @intCast(i)))); - if (!(strcmp(rule.*.name, name) != 0)) { - total += rule.*.weight; - } - } - } - var r: f32 = @as(f32, @floatFromInt(rand())) / @as(f32, @floatFromInt(@as(c_int, 2147483647))); - _ = &r; - var t: f32 = 0; - _ = &t; - { - var i: c_int = 0; - _ = &i; - while (i < nrules) : (i += 1) { - rule = rules + @as(usize, @bitCast(@as(isize, @intCast(i)))); - if (!(strcmp(rule.*.name, name) != 0)) { - t += @as(f32, @floatFromInt(rule.*.weight)) / @as(f32, @floatFromInt(total)); - if (t >= r) { - return rule; - } - } - } - } - return rule; -} -pub fn par_shapes__create_turtle() callconv(.C) [*c]par_shapes_mesh { - const xaxis: [3]f32 = [3]f32{ - 1, - 0, - 0, - }; - _ = &xaxis; - const yaxis: [3]f32 = [3]f32{ - 0, - 1, - 0, - }; - _ = &yaxis; - const zaxis: [3]f32 = [3]f32{ - 0, - 0, - 1, - }; - _ = &zaxis; - var turtle: [*c]par_shapes_mesh = @as([*c]par_shapes_mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))) *% @sizeOf(par_shapes_mesh), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &turtle; - turtle.*.npoints = 3; - turtle.*.points = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, turtle.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - par_shapes__copy3(turtle.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 0))))), @as([*c]const f32, @ptrCast(@alignCast(&xaxis)))); - par_shapes__copy3(turtle.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))), @as([*c]const f32, @ptrCast(@alignCast(&yaxis)))); - par_shapes__copy3(turtle.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))), @as([*c]const f32, @ptrCast(@alignCast(&zaxis)))); - return turtle; -} -pub fn par_shapes__apply_turtle(arg_mesh: [*c]par_shapes_mesh, arg_turtle: [*c]par_shapes_mesh, arg_pos: [*c]const f32, arg_scale: [*c]const f32) callconv(.C) [*c]par_shapes_mesh { - var mesh = arg_mesh; - _ = &mesh; - var turtle = arg_turtle; - _ = &turtle; - var pos = arg_pos; - _ = &pos; - var scale = arg_scale; - _ = &scale; - var m: [*c]par_shapes_mesh = par_shapes_clone(mesh, null); - _ = &m; - { - var p: c_int = 0; - _ = &p; - while (p < m.*.npoints) : (p += 1) { - var pt: [*c]f32 = m.*.points + @as(usize, @bitCast(@as(isize, @intCast(p * @as(c_int, 3))))); - _ = &pt; - pt[@as(c_uint, @intCast(@as(c_int, 0)))] *= scale[@as(c_uint, @intCast(@as(c_int, 0)))]; - pt[@as(c_uint, @intCast(@as(c_int, 1)))] *= scale[@as(c_uint, @intCast(@as(c_int, 1)))]; - pt[@as(c_uint, @intCast(@as(c_int, 2)))] *= scale[@as(c_uint, @intCast(@as(c_int, 2)))]; - par_shapes__transform3(pt, turtle.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 0))))), turtle.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))), turtle.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6)))))); - pt[@as(c_uint, @intCast(@as(c_int, 0)))] += pos[@as(c_uint, @intCast(@as(c_int, 0)))]; - pt[@as(c_uint, @intCast(@as(c_int, 1)))] += pos[@as(c_uint, @intCast(@as(c_int, 1)))]; - pt[@as(c_uint, @intCast(@as(c_int, 2)))] += pos[@as(c_uint, @intCast(@as(c_int, 2)))]; - } - } - return m; -} -pub fn par_shapes__subdivide(arg_mesh: [*c]par_shapes_mesh) callconv(.C) void { - var mesh = arg_mesh; - _ = &mesh; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if ((mesh.*.npoints == (mesh.*.ntriangles * @as(c_int, 3))) and (@intFromPtr("Must be unwelded.") != 0)) {} else { - __assert_fail("mesh->npoints == mesh->ntriangles * 3 && \"Must be unwelded.\"", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1476))), "void par_shapes__subdivide(par_shapes_mesh *)"); - }; - }; - }; - var ntriangles: c_int = mesh.*.ntriangles * @as(c_int, 4); - _ = &ntriangles; - var npoints: c_int = ntriangles * @as(c_int, 3); - _ = &npoints; - var points: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, npoints * @as(c_int, 3)))) *% @sizeOf(f32), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &points; - var dpoint: [*c]f32 = points; - _ = &dpoint; - var spoint: [*c]const f32 = mesh.*.points; - _ = &spoint; - { - var t: c_int = 0; - _ = &t; - while (t < mesh.*.ntriangles) : (_ = blk: { - _ = blk_1: { - t += 1; - break :blk_1 blk_2: { - const ref = &spoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 9))))); - break :blk_2 ref.*; - }; - }; - break :blk blk_1: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var a: [*c]const f32 = spoint; - _ = &a; - var b: [*c]const f32 = spoint + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - _ = &b; - var c: [*c]const f32 = spoint + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))); - _ = &c; - var p0: [*c]const f32 = dpoint; - _ = &p0; - var p1: [*c]const f32 = dpoint + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - _ = &p1; - var p2: [*c]const f32 = dpoint + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 6))))); - _ = &p2; - par_shapes__mix3(dpoint, a, b, @as(f32, @floatCast(0.5))); - par_shapes__mix3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, b, c, @as(f32, @floatCast(0.5))); - par_shapes__mix3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, a, c, @as(f32, @floatCast(0.5))); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, a); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, p0); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, p2); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, p0); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, b); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, p1); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, p2); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, p1); - par_shapes__add3(blk: { - const ref = &dpoint; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk ref.*; - }, c); - } - } - free(@as(?*anyopaque, @ptrCast(mesh.*.points))); - mesh.*.points = points; - mesh.*.npoints = npoints; - mesh.*.ntriangles = ntriangles; -} -const struct_unnamed_16 = extern struct { - points: [*c]const f32 = @import("std").mem.zeroes([*c]const f32), - gridsize: c_int = @import("std").mem.zeroes(c_int), -}; -pub var par_shapes__sort_context: struct_unnamed_16 = @import("std").mem.zeroes(struct_unnamed_16); -pub fn par_shapes__cmp1(arg_arg0: ?*const anyopaque, arg_arg1: ?*const anyopaque) callconv(.C) c_int { - var arg0 = arg_arg0; - _ = &arg0; - var arg1 = arg_arg1; - _ = &arg1; - const g: c_int = par_shapes__sort_context.gridsize; - _ = &g; - var d0: u16 = @as([*c]const u16, @ptrCast(@alignCast(arg0))).*; - _ = &d0; - var p0: [*c]const f32 = par_shapes__sort_context.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, @bitCast(@as(c_uint, d0))) * @as(c_int, 3))))); - _ = &p0; - var @"i0": c_int = @as(c_int, @intFromFloat(p0[@as(c_uint, @intCast(@as(c_int, 0)))])); - _ = &@"i0"; - var j0_1: c_int = @as(c_int, @intFromFloat(p0[@as(c_uint, @intCast(@as(c_int, 1)))])); - _ = &j0_1; - var k0: c_int = @as(c_int, @intFromFloat(p0[@as(c_uint, @intCast(@as(c_int, 2)))])); - _ = &k0; - var index0: c_int = (@"i0" + (g * j0_1)) + ((g * g) * k0); - _ = &index0; - var d1: u16 = @as([*c]const u16, @ptrCast(@alignCast(arg1))).*; - _ = &d1; - var p1: [*c]const f32 = par_shapes__sort_context.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, @bitCast(@as(c_uint, d1))) * @as(c_int, 3))))); - _ = &p1; - var @"i1": c_int = @as(c_int, @intFromFloat(p1[@as(c_uint, @intCast(@as(c_int, 0)))])); - _ = &@"i1"; - var j1_2: c_int = @as(c_int, @intFromFloat(p1[@as(c_uint, @intCast(@as(c_int, 1)))])); - _ = &j1_2; - var k1: c_int = @as(c_int, @intFromFloat(p1[@as(c_uint, @intCast(@as(c_int, 2)))])); - _ = &k1; - var index1: c_int = (@"i1" + (g * j1_2)) + ((g * g) * k1); - _ = &index1; - if (index0 < index1) return -@as(c_int, 1); - if (index0 > index1) return 1; - return 0; -} -pub fn par_shapes__sort_points(arg_mesh: [*c]par_shapes_mesh, arg_gridsize: c_int, arg_sortmap: [*c]u16) callconv(.C) void { - var mesh = arg_mesh; - _ = &mesh; - var gridsize = arg_gridsize; - _ = &gridsize; - var sortmap = arg_sortmap; - _ = &sortmap; - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk sortmap + @as(usize, @intCast(tmp)) else break :blk sortmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u16, @bitCast(@as(c_short, @truncate(i)))); - } - } - par_shapes__sort_context.gridsize = gridsize; - par_shapes__sort_context.points = mesh.*.points; - qsort(@as(?*anyopaque, @ptrCast(sortmap)), @as(usize, @bitCast(@as(c_long, mesh.*.npoints))), @sizeOf(u16), &par_shapes__cmp1); - var newpts: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints * @as(c_int, 3)))) *% @sizeOf(f32))))); - _ = &newpts; - var invmap: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints))) *% @sizeOf(u16))))); - _ = &invmap; - var dstpt: [*c]f32 = newpts; - _ = &dstpt; - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.npoints) : (i += 1) { - invmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk sortmap + @as(usize, @intCast(tmp)) else break :blk sortmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*] = @as(u16, @bitCast(@as(c_short, @truncate(i)))); - var srcpt: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3) * @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk sortmap + @as(usize, @intCast(tmp)) else break :blk sortmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))))); - _ = &srcpt; - (blk: { - const ref = &dstpt; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = &srcpt; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - (blk: { - const ref = &dstpt; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = &srcpt; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - (blk: { - const ref = &dstpt; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = (blk: { - const ref = &srcpt; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*; - } - } - free(@as(?*anyopaque, @ptrCast(mesh.*.points))); - mesh.*.points = newpts; - var newinds: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.ntriangles * @as(c_int, 3)))) *% @sizeOf(u16))))); - _ = &newinds; - var dstind: [*c]u16 = newinds; - _ = &dstind; - var srcind: [*c]const u16 = mesh.*.triangles; - _ = &srcind; - { - var i: c_int = 0; - _ = &i; - while (i < (mesh.*.ntriangles * @as(c_int, 3))) : (i += 1) { - (blk: { - const ref = &dstind; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = invmap[(blk: { - const ref = &srcind; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).*]; - } - } - free(@as(?*anyopaque, @ptrCast(mesh.*.triangles))); - mesh.*.triangles = newinds; - _ = memcpy(@as(?*anyopaque, @ptrCast(sortmap)), @as(?*const anyopaque, @ptrCast(invmap)), @sizeOf(u16) *% @as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints)))); - free(@as(?*anyopaque, @ptrCast(invmap))); -} -pub fn par_shapes__weld_points(arg_mesh: [*c]par_shapes_mesh, arg_gridsize: c_int, arg_epsilon: f32, arg_weldmap: [*c]u16) callconv(.C) void { - var mesh = arg_mesh; - _ = &mesh; - var gridsize = arg_gridsize; - _ = &gridsize; - var epsilon = arg_epsilon; - _ = ε - var weldmap = arg_weldmap; - _ = &weldmap; - var bins: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (gridsize * gridsize) * gridsize))) *% @sizeOf(u16), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))); - _ = &bins; - var prev_binindex: c_int = -@as(c_int, 1); - _ = &prev_binindex; - { - var p: c_int = 0; - _ = &p; - while (p < mesh.*.npoints) : (p += 1) { - var pt: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(p * @as(c_int, 3))))); - _ = &pt; - var i: c_int = @as(c_int, @intFromFloat(pt[@as(c_uint, @intCast(@as(c_int, 0)))])); - _ = &i; - var j: c_int = @as(c_int, @intFromFloat(pt[@as(c_uint, @intCast(@as(c_int, 1)))])); - _ = &j; - var k: c_int = @as(c_int, @intFromFloat(pt[@as(c_uint, @intCast(@as(c_int, 2)))])); - _ = &k; - var this_binindex: c_int = (i + (gridsize * j)) + ((gridsize * gridsize) * k); - _ = &this_binindex; - if (this_binindex != prev_binindex) { - (blk: { - const tmp = this_binindex; - if (tmp >= 0) break :blk bins + @as(usize, @intCast(tmp)) else break :blk bins - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, 1) + p)))); - } - prev_binindex = this_binindex; - } - } - var pt: [*c]const f32 = mesh.*.points; - _ = &pt; - var nremoved: c_int = 0; - _ = &nremoved; - { - var p: c_int = 0; - _ = &p; - while (p < mesh.*.npoints) : (_ = blk: { - p += 1; - break :blk blk_1: { - const ref = &pt; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - if (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = p; - if (tmp >= 0) break :blk weldmap + @as(usize, @intCast(tmp)) else break :blk weldmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) != p) { - continue; - } - var nearby: [8]c_int = undefined; - _ = &nearby; - var nbins: c_int = 0; - _ = &nbins; - var minp: [3]c_int = undefined; - _ = &minp; - var maxp: [3]c_int = undefined; - _ = &maxp; - { - var c: c_int = 0; - _ = &c; - while (c < @as(c_int, 3)) : (c += 1) { - minp[@as(c_uint, @intCast(c))] = @as(c_int, @intFromFloat((blk: { - const tmp = c; - if (tmp >= 0) break :blk pt + @as(usize, @intCast(tmp)) else break :blk pt - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* - epsilon)); - maxp[@as(c_uint, @intCast(c))] = @as(c_int, @intFromFloat((blk: { - const tmp = c; - if (tmp >= 0) break :blk pt + @as(usize, @intCast(tmp)) else break :blk pt - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* + epsilon)); - } - } - { - var i: c_int = minp[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &i; - while (i <= maxp[@as(c_uint, @intCast(@as(c_int, 0)))]) : (i += 1) { - { - var j: c_int = minp[@as(c_uint, @intCast(@as(c_int, 1)))]; - _ = &j; - while (j <= maxp[@as(c_uint, @intCast(@as(c_int, 1)))]) : (j += 1) { - { - var k: c_int = minp[@as(c_uint, @intCast(@as(c_int, 2)))]; - _ = &k; - while (k <= maxp[@as(c_uint, @intCast(@as(c_int, 2)))]) : (k += 1) { - var binindex: c_int = (i + (gridsize * j)) + ((gridsize * gridsize) * k); - _ = &binindex; - var binvalue: u16 = (bins + @as(usize, @bitCast(@as(isize, @intCast(binindex))))).*; - _ = &binvalue; - if (@as(c_int, @bitCast(@as(c_uint, binvalue))) > @as(c_int, 0)) { - if (nbins == @as(c_int, 8)) { - _ = printf("Epsilon value is too large.\n"); - break; - } - nearby[@as(c_uint, @intCast(blk: { - const ref = &nbins; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }))] = binindex; - } - } - } - } - } - } - } - { - var b: c_int = 0; - _ = &b; - while (b < nbins) : (b += 1) { - var binindex: c_int = nearby[@as(c_uint, @intCast(b))]; - _ = &binindex; - var binvalue: u16 = (blk: { - const tmp = binindex; - if (tmp >= 0) break :blk bins + @as(usize, @intCast(tmp)) else break :blk bins - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &binvalue; - var nindex: u16 = @as(u16, @bitCast(@as(c_short, @truncate(@as(c_int, @bitCast(@as(c_uint, binvalue))) - @as(c_int, 1))))); - _ = &nindex; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (@as(c_int, @bitCast(@as(c_uint, nindex))) < mesh.*.npoints) {} else { - __assert_fail("nindex < mesh->npoints", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1715))), "void par_shapes__weld_points(par_shapes_mesh *, int, float, uint16_t *)"); - }; - }; - }; - while (true) { - if ((@as(c_int, @bitCast(@as(c_uint, nindex))) != p) and (@as(c_int, @bitCast(@as(c_uint, weldmap[nindex]))) == @as(c_int, @bitCast(@as(c_uint, nindex))))) { - var thatpt: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, @bitCast(@as(c_uint, nindex))) * @as(c_int, 3))))); - _ = &thatpt; - var dist2: f32 = par_shapes__sqrdist3(thatpt, pt); - _ = &dist2; - if (dist2 < epsilon) { - weldmap[nindex] = @as(u16, @bitCast(@as(c_short, @truncate(p)))); - nremoved += 1; - } - } - if (@as(c_int, @bitCast(@as(c_uint, blk: { - const ref = &nindex; - ref.* +%= 1; - break :blk ref.*; - }))) >= mesh.*.npoints) { - break; - } - var nextpt: [*c]const f32 = mesh.*.points + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, @bitCast(@as(c_uint, nindex))) * @as(c_int, 3))))); - _ = &nextpt; - var i: c_int = @as(c_int, @intFromFloat(nextpt[@as(c_uint, @intCast(@as(c_int, 0)))])); - _ = &i; - var j: c_int = @as(c_int, @intFromFloat(nextpt[@as(c_uint, @intCast(@as(c_int, 1)))])); - _ = &j; - var k: c_int = @as(c_int, @intFromFloat(nextpt[@as(c_uint, @intCast(@as(c_int, 2)))])); - _ = &k; - var nextbinindex: c_int = (i + (gridsize * j)) + ((gridsize * gridsize) * k); - _ = &nextbinindex; - if (nextbinindex != binindex) { - break; - } - } - } - } - } - } - free(@as(?*anyopaque, @ptrCast(bins))); - var npoints: c_int = mesh.*.npoints - nremoved; - _ = &npoints; - var newpts: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3) * npoints))) *% @sizeOf(f32))))); - _ = &newpts; - var dst: [*c]f32 = newpts; - _ = &dst; - var condensed_map: [*c]u16 = @as([*c]u16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints))) *% @sizeOf(u16))))); - _ = &condensed_map; - var cmap: [*c]u16 = condensed_map; - _ = &cmap; - var src: [*c]const f32 = mesh.*.points; - _ = &src; - var ci: c_int = 0; - _ = &ci; - { - var p: c_int = 0; - _ = &p; - while (p < mesh.*.npoints) : (_ = blk: { - p += 1; - break :blk blk_1: { - const ref = &src; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - if (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = p; - if (tmp >= 0) break :blk weldmap + @as(usize, @intCast(tmp)) else break :blk weldmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) == p) { - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 0)))]; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 1)))]; - (blk: { - const ref = &dst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = src[@as(c_uint, @intCast(@as(c_int, 2)))]; - (blk: { - const ref = &cmap; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = @as(u16, @bitCast(@as(c_short, @truncate(blk: { - const ref = &ci; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - })))); - } else { - (blk: { - const ref = &cmap; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = condensed_map[(blk: { - const tmp = p; - if (tmp >= 0) break :blk weldmap + @as(usize, @intCast(tmp)) else break :blk weldmap - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*]; - } - } - } - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (ci == npoints) {} else { - __assert_fail("ci == npoints", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1765))), "void par_shapes__weld_points(par_shapes_mesh *, int, float, uint16_t *)"); - }; - }; - }; - free(@as(?*anyopaque, @ptrCast(mesh.*.points))); - _ = memcpy(@as(?*anyopaque, @ptrCast(weldmap)), @as(?*const anyopaque, @ptrCast(condensed_map)), @as(c_ulong, @bitCast(@as(c_long, mesh.*.npoints))) *% @sizeOf(u16)); - free(@as(?*anyopaque, @ptrCast(condensed_map))); - mesh.*.points = newpts; - mesh.*.npoints = npoints; - var tsrc: [*c]const u16 = mesh.*.triangles; - _ = &tsrc; - var tdst: [*c]u16 = mesh.*.triangles; - _ = &tdst; - var ntriangles: c_int = 0; - _ = &ntriangles; - { - var i: c_int = 0; - _ = &i; - while (i < mesh.*.ntriangles) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &tsrc; - ref.* += @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 3))))); - break :blk_1 ref.*; - }; - }) { - var a: u16 = weldmap[tsrc[@as(c_uint, @intCast(@as(c_int, 0)))]]; - _ = &a; - var b: u16 = weldmap[tsrc[@as(c_uint, @intCast(@as(c_int, 1)))]]; - _ = &b; - var c: u16 = weldmap[tsrc[@as(c_uint, @intCast(@as(c_int, 2)))]]; - _ = &c; - if (((@as(c_int, @bitCast(@as(c_uint, a))) != @as(c_int, @bitCast(@as(c_uint, b)))) and (@as(c_int, @bitCast(@as(c_uint, a))) != @as(c_int, @bitCast(@as(c_uint, c))))) and (@as(c_int, @bitCast(@as(c_uint, b))) != @as(c_int, @bitCast(@as(c_uint, c))))) { - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (@as(c_int, @bitCast(@as(c_uint, a))) < mesh.*.npoints) {} else { - __assert_fail("a < mesh->npoints", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1781))), "void par_shapes__weld_points(par_shapes_mesh *, int, float, uint16_t *)"); - }; - }; - }; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (@as(c_int, @bitCast(@as(c_uint, b))) < mesh.*.npoints) {} else { - __assert_fail("b < mesh->npoints", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1782))), "void par_shapes__weld_points(par_shapes_mesh *, int, float, uint16_t *)"); - }; - }; - }; - _ = blk: { - _ = @sizeOf(c_int); - break :blk blk_1: { - break :blk_1 if (@as(c_int, @bitCast(@as(c_uint, c))) < mesh.*.npoints) {} else { - __assert_fail("c < mesh->npoints", "./external/par_shapes.h", @as(c_uint, @bitCast(@as(c_int, 1783))), "void par_shapes__weld_points(par_shapes_mesh *, int, float, uint16_t *)"); - }; - }; - }; - (blk: { - const ref = &tdst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = a; - (blk: { - const ref = &tdst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = b; - (blk: { - const ref = &tdst; - const tmp = ref.*; - ref.* += 1; - break :blk tmp; - }).* = c; - ntriangles += 1; - } - } - } - mesh.*.ntriangles = ntriangles; -} -pub const gradients2D: [16]i8 = [16]i8{ - 5, - 2, - 2, - 5, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 5))))), - 2, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 2))))), - 5, - 5, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 2))))), - 2, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 5))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 5))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 2))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 2))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 5))))), -}; -pub const gradients3D: [72]i8 = [72]i8{ - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - 4, - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 11, - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - 11, - 11, - 4, - 4, - 4, - 11, - 4, - 4, - 4, - 11, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 11, - 11, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - 4, - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 11, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 11, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - 11, - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - 11, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - 11, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - 4, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 4))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 11))))), -}; -pub const gradients4D: [256]i8 = [256]i8{ - 3, - 1, - 1, - 1, - 1, - 3, - 1, - 1, - 1, - 1, - 3, - 1, - 1, - 1, - 1, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 3, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - 3, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 3, - 3, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - 3, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 3, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 3, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - 3, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - 1, - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 1))))), - @as(i8, @bitCast(@as(i8, @truncate(-@as(c_int, 3))))), -}; -pub fn extrapolate2(arg_ctx: [*c]struct_osn_context, arg_xsb: c_int, arg_ysb: c_int, arg_dx: f64, arg_dy: f64) callconv(.C) f64 { - var ctx = arg_ctx; - _ = &ctx; - var xsb = arg_xsb; - _ = &xsb; - var ysb = arg_ysb; - _ = &ysb; - var dx = arg_dx; - _ = &dx; - var dy = arg_dy; - _ = &dy; - var perm: [*c]i16 = ctx.*.perm; - _ = &perm; - var index_1: c_int = @as(c_int, @bitCast(@as(c_int, (blk: { - const tmp = (@as(c_int, @bitCast(@as(c_int, (blk_1: { - const tmp_2 = xsb & @as(c_int, 255); - if (tmp_2 >= 0) break :blk_1 perm + @as(usize, @intCast(tmp_2)) else break :blk_1 perm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*))) + ysb) & @as(c_int, 255); - if (tmp >= 0) break :blk perm + @as(usize, @intCast(tmp)) else break :blk perm - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) & @as(c_int, 14); - _ = &index_1; - return (@as(f64, @floatFromInt(@as(c_int, @bitCast(@as(c_int, gradients2D[@as(c_uint, @intCast(index_1))]))))) * dx) + (@as(f64, @floatFromInt(@as(c_int, @bitCast(@as(c_int, gradients2D[@as(c_uint, @intCast(index_1 + @as(c_int, 1)))]))))) * dy); -} -pub fn fastFloor(arg_x: f64) callconv(.C) c_int { - var x = arg_x; - _ = &x; - var xi: c_int = @as(c_int, @intFromFloat(x)); - _ = ξ - return if (x < @as(f64, @floatFromInt(xi))) xi - @as(c_int, 1) else xi; -} -pub fn allocate_perm(arg_ctx: [*c]struct_osn_context, arg_nperm: c_int, arg_ngrad: c_int) callconv(.C) c_int { - var ctx = arg_ctx; - _ = &ctx; - var nperm = arg_nperm; - _ = &nperm; - var ngrad = arg_ngrad; - _ = &ngrad; - free(@as(?*anyopaque, @ptrCast(ctx.*.perm))); - free(@as(?*anyopaque, @ptrCast(ctx.*.permGradIndex3D))); - ctx.*.perm = @as([*c]i16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, nperm))) *% @sizeOf(i16))))); - if (!(ctx.*.perm != null)) { - return -@as(c_int, 12); - } - ctx.*.permGradIndex3D = @as([*c]i16, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, ngrad))) *% @sizeOf(i16))))); - if (!(ctx.*.permGradIndex3D != null)) { - free(@as(?*anyopaque, @ptrCast(ctx.*.perm))); - return -@as(c_int, 12); - } - return 0; -} -pub const useconds_t = __useconds_t; -pub const socklen_t = __socklen_t; -pub extern fn access(__name: [*c]const u8, __type: c_int) c_int; -pub extern fn faccessat(__fd: c_int, __file: [*c]const u8, __type: c_int, __flag: c_int) c_int; -pub extern fn lseek(__fd: c_int, __offset: __off_t, __whence: c_int) __off_t; -pub extern fn close(__fd: c_int) c_int; -pub extern fn closefrom(__lowfd: c_int) void; -pub extern fn read(__fd: c_int, __buf: ?*anyopaque, __nbytes: usize) isize; -pub extern fn write(__fd: c_int, __buf: ?*const anyopaque, __n: usize) isize; -pub extern fn pread(__fd: c_int, __buf: ?*anyopaque, __nbytes: usize, __offset: __off_t) isize; -pub extern fn pwrite(__fd: c_int, __buf: ?*const anyopaque, __n: usize, __offset: __off_t) isize; -pub extern fn pipe(__pipedes: [*c]c_int) c_int; -pub extern fn alarm(__seconds: c_uint) c_uint; -pub extern fn sleep(__seconds: c_uint) c_uint; -pub extern fn ualarm(__value: __useconds_t, __interval: __useconds_t) __useconds_t; -pub extern fn usleep(__useconds: __useconds_t) c_int; -pub extern fn pause() c_int; -pub extern fn chown(__file: [*c]const u8, __owner: __uid_t, __group: __gid_t) c_int; -pub extern fn fchown(__fd: c_int, __owner: __uid_t, __group: __gid_t) c_int; -pub extern fn lchown(__file: [*c]const u8, __owner: __uid_t, __group: __gid_t) c_int; -pub extern fn fchownat(__fd: c_int, __file: [*c]const u8, __owner: __uid_t, __group: __gid_t, __flag: c_int) c_int; -pub extern fn chdir(__path: [*c]const u8) c_int; -pub extern fn fchdir(__fd: c_int) c_int; -pub extern fn getcwd(__buf: [*c]u8, __size: usize) [*c]u8; -pub extern fn getwd(__buf: [*c]u8) [*c]u8; -pub extern fn dup(__fd: c_int) c_int; -pub extern fn dup2(__fd: c_int, __fd2: c_int) c_int; -pub extern var __environ: [*c][*c]u8; -pub extern fn execve(__path: [*c]const u8, __argv: [*c]const [*c]u8, __envp: [*c]const [*c]u8) c_int; -pub extern fn fexecve(__fd: c_int, __argv: [*c]const [*c]u8, __envp: [*c]const [*c]u8) c_int; -pub extern fn execv(__path: [*c]const u8, __argv: [*c]const [*c]u8) c_int; -pub extern fn execle(__path: [*c]const u8, __arg: [*c]const u8, ...) c_int; -pub extern fn execl(__path: [*c]const u8, __arg: [*c]const u8, ...) c_int; -pub extern fn execvp(__file: [*c]const u8, __argv: [*c]const [*c]u8) c_int; -pub extern fn execlp(__file: [*c]const u8, __arg: [*c]const u8, ...) c_int; -pub extern fn nice(__inc: c_int) c_int; -pub extern fn _exit(__status: c_int) noreturn; -pub const _PC_LINK_MAX: c_int = 0; -pub const _PC_MAX_CANON: c_int = 1; -pub const _PC_MAX_INPUT: c_int = 2; -pub const _PC_NAME_MAX: c_int = 3; -pub const _PC_PATH_MAX: c_int = 4; -pub const _PC_PIPE_BUF: c_int = 5; -pub const _PC_CHOWN_RESTRICTED: c_int = 6; -pub const _PC_NO_TRUNC: c_int = 7; -pub const _PC_VDISABLE: c_int = 8; -pub const _PC_SYNC_IO: c_int = 9; -pub const _PC_ASYNC_IO: c_int = 10; -pub const _PC_PRIO_IO: c_int = 11; -pub const _PC_SOCK_MAXBUF: c_int = 12; -pub const _PC_FILESIZEBITS: c_int = 13; -pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; -pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; -pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; -pub const _PC_REC_XFER_ALIGN: c_int = 17; -pub const _PC_ALLOC_SIZE_MIN: c_int = 18; -pub const _PC_SYMLINK_MAX: c_int = 19; -pub const _PC_2_SYMLINKS: c_int = 20; -const enum_unnamed_17 = c_uint; -pub const _SC_ARG_MAX: c_int = 0; -pub const _SC_CHILD_MAX: c_int = 1; -pub const _SC_CLK_TCK: c_int = 2; -pub const _SC_NGROUPS_MAX: c_int = 3; -pub const _SC_OPEN_MAX: c_int = 4; -pub const _SC_STREAM_MAX: c_int = 5; -pub const _SC_TZNAME_MAX: c_int = 6; -pub const _SC_JOB_CONTROL: c_int = 7; -pub const _SC_SAVED_IDS: c_int = 8; -pub const _SC_REALTIME_SIGNALS: c_int = 9; -pub const _SC_PRIORITY_SCHEDULING: c_int = 10; -pub const _SC_TIMERS: c_int = 11; -pub const _SC_ASYNCHRONOUS_IO: c_int = 12; -pub const _SC_PRIORITIZED_IO: c_int = 13; -pub const _SC_SYNCHRONIZED_IO: c_int = 14; -pub const _SC_FSYNC: c_int = 15; -pub const _SC_MAPPED_FILES: c_int = 16; -pub const _SC_MEMLOCK: c_int = 17; -pub const _SC_MEMLOCK_RANGE: c_int = 18; -pub const _SC_MEMORY_PROTECTION: c_int = 19; -pub const _SC_MESSAGE_PASSING: c_int = 20; -pub const _SC_SEMAPHORES: c_int = 21; -pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; -pub const _SC_AIO_LISTIO_MAX: c_int = 23; -pub const _SC_AIO_MAX: c_int = 24; -pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; -pub const _SC_DELAYTIMER_MAX: c_int = 26; -pub const _SC_MQ_OPEN_MAX: c_int = 27; -pub const _SC_MQ_PRIO_MAX: c_int = 28; -pub const _SC_VERSION: c_int = 29; -pub const _SC_PAGESIZE: c_int = 30; -pub const _SC_RTSIG_MAX: c_int = 31; -pub const _SC_SEM_NSEMS_MAX: c_int = 32; -pub const _SC_SEM_VALUE_MAX: c_int = 33; -pub const _SC_SIGQUEUE_MAX: c_int = 34; -pub const _SC_TIMER_MAX: c_int = 35; -pub const _SC_BC_BASE_MAX: c_int = 36; -pub const _SC_BC_DIM_MAX: c_int = 37; -pub const _SC_BC_SCALE_MAX: c_int = 38; -pub const _SC_BC_STRING_MAX: c_int = 39; -pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; -pub const _SC_EQUIV_CLASS_MAX: c_int = 41; -pub const _SC_EXPR_NEST_MAX: c_int = 42; -pub const _SC_LINE_MAX: c_int = 43; -pub const _SC_RE_DUP_MAX: c_int = 44; -pub const _SC_CHARCLASS_NAME_MAX: c_int = 45; -pub const _SC_2_VERSION: c_int = 46; -pub const _SC_2_C_BIND: c_int = 47; -pub const _SC_2_C_DEV: c_int = 48; -pub const _SC_2_FORT_DEV: c_int = 49; -pub const _SC_2_FORT_RUN: c_int = 50; -pub const _SC_2_SW_DEV: c_int = 51; -pub const _SC_2_LOCALEDEF: c_int = 52; -pub const _SC_PII: c_int = 53; -pub const _SC_PII_XTI: c_int = 54; -pub const _SC_PII_SOCKET: c_int = 55; -pub const _SC_PII_INTERNET: c_int = 56; -pub const _SC_PII_OSI: c_int = 57; -pub const _SC_POLL: c_int = 58; -pub const _SC_SELECT: c_int = 59; -pub const _SC_UIO_MAXIOV: c_int = 60; -pub const _SC_IOV_MAX: c_int = 60; -pub const _SC_PII_INTERNET_STREAM: c_int = 61; -pub const _SC_PII_INTERNET_DGRAM: c_int = 62; -pub const _SC_PII_OSI_COTS: c_int = 63; -pub const _SC_PII_OSI_CLTS: c_int = 64; -pub const _SC_PII_OSI_M: c_int = 65; -pub const _SC_T_IOV_MAX: c_int = 66; -pub const _SC_THREADS: c_int = 67; -pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; -pub const _SC_THREAD_KEYS_MAX: c_int = 74; -pub const _SC_THREAD_STACK_MIN: c_int = 75; -pub const _SC_THREAD_THREADS_MAX: c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; -pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; -pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; -pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; -pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; -pub const _SC_NPROCESSORS_CONF: c_int = 83; -pub const _SC_NPROCESSORS_ONLN: c_int = 84; -pub const _SC_PHYS_PAGES: c_int = 85; -pub const _SC_AVPHYS_PAGES: c_int = 86; -pub const _SC_ATEXIT_MAX: c_int = 87; -pub const _SC_PASS_MAX: c_int = 88; -pub const _SC_XOPEN_VERSION: c_int = 89; -pub const _SC_XOPEN_XCU_VERSION: c_int = 90; -pub const _SC_XOPEN_UNIX: c_int = 91; -pub const _SC_XOPEN_CRYPT: c_int = 92; -pub const _SC_XOPEN_ENH_I18N: c_int = 93; -pub const _SC_XOPEN_SHM: c_int = 94; -pub const _SC_2_CHAR_TERM: c_int = 95; -pub const _SC_2_C_VERSION: c_int = 96; -pub const _SC_2_UPE: c_int = 97; -pub const _SC_XOPEN_XPG2: c_int = 98; -pub const _SC_XOPEN_XPG3: c_int = 99; -pub const _SC_XOPEN_XPG4: c_int = 100; -pub const _SC_CHAR_BIT: c_int = 101; -pub const _SC_CHAR_MAX: c_int = 102; -pub const _SC_CHAR_MIN: c_int = 103; -pub const _SC_INT_MAX: c_int = 104; -pub const _SC_INT_MIN: c_int = 105; -pub const _SC_LONG_BIT: c_int = 106; -pub const _SC_WORD_BIT: c_int = 107; -pub const _SC_MB_LEN_MAX: c_int = 108; -pub const _SC_NZERO: c_int = 109; -pub const _SC_SSIZE_MAX: c_int = 110; -pub const _SC_SCHAR_MAX: c_int = 111; -pub const _SC_SCHAR_MIN: c_int = 112; -pub const _SC_SHRT_MAX: c_int = 113; -pub const _SC_SHRT_MIN: c_int = 114; -pub const _SC_UCHAR_MAX: c_int = 115; -pub const _SC_UINT_MAX: c_int = 116; -pub const _SC_ULONG_MAX: c_int = 117; -pub const _SC_USHRT_MAX: c_int = 118; -pub const _SC_NL_ARGMAX: c_int = 119; -pub const _SC_NL_LANGMAX: c_int = 120; -pub const _SC_NL_MSGMAX: c_int = 121; -pub const _SC_NL_NMAX: c_int = 122; -pub const _SC_NL_SETMAX: c_int = 123; -pub const _SC_NL_TEXTMAX: c_int = 124; -pub const _SC_XBS5_ILP32_OFF32: c_int = 125; -pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; -pub const _SC_XBS5_LP64_OFF64: c_int = 127; -pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; -pub const _SC_XOPEN_LEGACY: c_int = 129; -pub const _SC_XOPEN_REALTIME: c_int = 130; -pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; -pub const _SC_ADVISORY_INFO: c_int = 132; -pub const _SC_BARRIERS: c_int = 133; -pub const _SC_BASE: c_int = 134; -pub const _SC_C_LANG_SUPPORT: c_int = 135; -pub const _SC_C_LANG_SUPPORT_R: c_int = 136; -pub const _SC_CLOCK_SELECTION: c_int = 137; -pub const _SC_CPUTIME: c_int = 138; -pub const _SC_THREAD_CPUTIME: c_int = 139; -pub const _SC_DEVICE_IO: c_int = 140; -pub const _SC_DEVICE_SPECIFIC: c_int = 141; -pub const _SC_DEVICE_SPECIFIC_R: c_int = 142; -pub const _SC_FD_MGMT: c_int = 143; -pub const _SC_FIFO: c_int = 144; -pub const _SC_PIPE: c_int = 145; -pub const _SC_FILE_ATTRIBUTES: c_int = 146; -pub const _SC_FILE_LOCKING: c_int = 147; -pub const _SC_FILE_SYSTEM: c_int = 148; -pub const _SC_MONOTONIC_CLOCK: c_int = 149; -pub const _SC_MULTI_PROCESS: c_int = 150; -pub const _SC_SINGLE_PROCESS: c_int = 151; -pub const _SC_NETWORKING: c_int = 152; -pub const _SC_READER_WRITER_LOCKS: c_int = 153; -pub const _SC_SPIN_LOCKS: c_int = 154; -pub const _SC_REGEXP: c_int = 155; -pub const _SC_REGEX_VERSION: c_int = 156; -pub const _SC_SHELL: c_int = 157; -pub const _SC_SIGNALS: c_int = 158; -pub const _SC_SPAWN: c_int = 159; -pub const _SC_SPORADIC_SERVER: c_int = 160; -pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; -pub const _SC_SYSTEM_DATABASE: c_int = 162; -pub const _SC_SYSTEM_DATABASE_R: c_int = 163; -pub const _SC_TIMEOUTS: c_int = 164; -pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; -pub const _SC_USER_GROUPS: c_int = 166; -pub const _SC_USER_GROUPS_R: c_int = 167; -pub const _SC_2_PBS: c_int = 168; -pub const _SC_2_PBS_ACCOUNTING: c_int = 169; -pub const _SC_2_PBS_LOCATE: c_int = 170; -pub const _SC_2_PBS_MESSAGE: c_int = 171; -pub const _SC_2_PBS_TRACK: c_int = 172; -pub const _SC_SYMLOOP_MAX: c_int = 173; -pub const _SC_STREAMS: c_int = 174; -pub const _SC_2_PBS_CHECKPOINT: c_int = 175; -pub const _SC_V6_ILP32_OFF32: c_int = 176; -pub const _SC_V6_ILP32_OFFBIG: c_int = 177; -pub const _SC_V6_LP64_OFF64: c_int = 178; -pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; -pub const _SC_HOST_NAME_MAX: c_int = 180; -pub const _SC_TRACE: c_int = 181; -pub const _SC_TRACE_EVENT_FILTER: c_int = 182; -pub const _SC_TRACE_INHERIT: c_int = 183; -pub const _SC_TRACE_LOG: c_int = 184; -pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 185; -pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 186; -pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 187; -pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 188; -pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 189; -pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 190; -pub const _SC_LEVEL2_CACHE_SIZE: c_int = 191; -pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 192; -pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 193; -pub const _SC_LEVEL3_CACHE_SIZE: c_int = 194; -pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 195; -pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 196; -pub const _SC_LEVEL4_CACHE_SIZE: c_int = 197; -pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 198; -pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 199; -pub const _SC_IPV6: c_int = 235; -pub const _SC_RAW_SOCKETS: c_int = 236; -pub const _SC_V7_ILP32_OFF32: c_int = 237; -pub const _SC_V7_ILP32_OFFBIG: c_int = 238; -pub const _SC_V7_LP64_OFF64: c_int = 239; -pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; -pub const _SC_SS_REPL_MAX: c_int = 241; -pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; -pub const _SC_TRACE_NAME_MAX: c_int = 243; -pub const _SC_TRACE_SYS_MAX: c_int = 244; -pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; -pub const _SC_XOPEN_STREAMS: c_int = 246; -pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; -pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; -pub const _SC_MINSIGSTKSZ: c_int = 249; -pub const _SC_SIGSTKSZ: c_int = 250; -const enum_unnamed_18 = c_uint; -pub const _CS_PATH: c_int = 0; -pub const _CS_V6_WIDTH_RESTRICTED_ENVS: c_int = 1; -pub const _CS_GNU_LIBC_VERSION: c_int = 2; -pub const _CS_GNU_LIBPTHREAD_VERSION: c_int = 3; -pub const _CS_V5_WIDTH_RESTRICTED_ENVS: c_int = 4; -pub const _CS_V7_WIDTH_RESTRICTED_ENVS: c_int = 5; -pub const _CS_LFS_CFLAGS: c_int = 1000; -pub const _CS_LFS_LDFLAGS: c_int = 1001; -pub const _CS_LFS_LIBS: c_int = 1002; -pub const _CS_LFS_LINTFLAGS: c_int = 1003; -pub const _CS_LFS64_CFLAGS: c_int = 1004; -pub const _CS_LFS64_LDFLAGS: c_int = 1005; -pub const _CS_LFS64_LIBS: c_int = 1006; -pub const _CS_LFS64_LINTFLAGS: c_int = 1007; -pub const _CS_XBS5_ILP32_OFF32_CFLAGS: c_int = 1100; -pub const _CS_XBS5_ILP32_OFF32_LDFLAGS: c_int = 1101; -pub const _CS_XBS5_ILP32_OFF32_LIBS: c_int = 1102; -pub const _CS_XBS5_ILP32_OFF32_LINTFLAGS: c_int = 1103; -pub const _CS_XBS5_ILP32_OFFBIG_CFLAGS: c_int = 1104; -pub const _CS_XBS5_ILP32_OFFBIG_LDFLAGS: c_int = 1105; -pub const _CS_XBS5_ILP32_OFFBIG_LIBS: c_int = 1106; -pub const _CS_XBS5_ILP32_OFFBIG_LINTFLAGS: c_int = 1107; -pub const _CS_XBS5_LP64_OFF64_CFLAGS: c_int = 1108; -pub const _CS_XBS5_LP64_OFF64_LDFLAGS: c_int = 1109; -pub const _CS_XBS5_LP64_OFF64_LIBS: c_int = 1110; -pub const _CS_XBS5_LP64_OFF64_LINTFLAGS: c_int = 1111; -pub const _CS_XBS5_LPBIG_OFFBIG_CFLAGS: c_int = 1112; -pub const _CS_XBS5_LPBIG_OFFBIG_LDFLAGS: c_int = 1113; -pub const _CS_XBS5_LPBIG_OFFBIG_LIBS: c_int = 1114; -pub const _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS: c_int = 1115; -pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116; -pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117; -pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118; -pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119; -pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120; -pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121; -pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122; -pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123; -pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124; -pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125; -pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126; -pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127; -pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128; -pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129; -pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130; -pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131; -pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132; -pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133; -pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134; -pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135; -pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136; -pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137; -pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138; -pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139; -pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140; -pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141; -pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142; -pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143; -pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144; -pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; -pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; -pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; -pub const _CS_V6_ENV: c_int = 1148; -pub const _CS_V7_ENV: c_int = 1149; -const enum_unnamed_19 = c_uint; -pub extern fn pathconf(__path: [*c]const u8, __name: c_int) c_long; -pub extern fn fpathconf(__fd: c_int, __name: c_int) c_long; -pub extern fn sysconf(__name: c_int) c_long; -pub extern fn confstr(__name: c_int, __buf: [*c]u8, __len: usize) usize; -pub extern fn getpid() __pid_t; -pub extern fn getppid() __pid_t; -pub extern fn getpgrp() __pid_t; -pub extern fn __getpgid(__pid: __pid_t) __pid_t; -pub extern fn getpgid(__pid: __pid_t) __pid_t; -pub extern fn setpgid(__pid: __pid_t, __pgid: __pid_t) c_int; -pub extern fn setpgrp() c_int; -pub extern fn setsid() __pid_t; -pub extern fn getsid(__pid: __pid_t) __pid_t; -pub extern fn getuid() __uid_t; -pub extern fn geteuid() __uid_t; -pub extern fn getgid() __gid_t; -pub extern fn getegid() __gid_t; -pub extern fn getgroups(__size: c_int, __list: [*c]__gid_t) c_int; -pub extern fn setuid(__uid: __uid_t) c_int; -pub extern fn setreuid(__ruid: __uid_t, __euid: __uid_t) c_int; -pub extern fn seteuid(__uid: __uid_t) c_int; -pub extern fn setgid(__gid: __gid_t) c_int; -pub extern fn setregid(__rgid: __gid_t, __egid: __gid_t) c_int; -pub extern fn setegid(__gid: __gid_t) c_int; -pub extern fn fork() __pid_t; -pub extern fn vfork() c_int; -pub extern fn ttyname(__fd: c_int) [*c]u8; -pub extern fn ttyname_r(__fd: c_int, __buf: [*c]u8, __buflen: usize) c_int; -pub extern fn isatty(__fd: c_int) c_int; -pub extern fn ttyslot() c_int; -pub extern fn link(__from: [*c]const u8, __to: [*c]const u8) c_int; -pub extern fn linkat(__fromfd: c_int, __from: [*c]const u8, __tofd: c_int, __to: [*c]const u8, __flags: c_int) c_int; -pub extern fn symlink(__from: [*c]const u8, __to: [*c]const u8) c_int; -pub extern fn readlink(noalias __path: [*c]const u8, noalias __buf: [*c]u8, __len: usize) isize; -pub extern fn symlinkat(__from: [*c]const u8, __tofd: c_int, __to: [*c]const u8) c_int; -pub extern fn readlinkat(__fd: c_int, noalias __path: [*c]const u8, noalias __buf: [*c]u8, __len: usize) isize; -pub extern fn unlink(__name: [*c]const u8) c_int; -pub extern fn unlinkat(__fd: c_int, __name: [*c]const u8, __flag: c_int) c_int; -pub extern fn rmdir(__path: [*c]const u8) c_int; -pub extern fn tcgetpgrp(__fd: c_int) __pid_t; -pub extern fn tcsetpgrp(__fd: c_int, __pgrp_id: __pid_t) c_int; -pub extern fn getlogin() [*c]u8; -pub extern fn getlogin_r(__name: [*c]u8, __name_len: usize) c_int; -pub extern fn setlogin(__name: [*c]const u8) c_int; -pub extern var optarg: [*c]u8; -pub extern var optind: c_int; -pub extern var opterr: c_int; -pub extern var optopt: c_int; -pub extern fn getopt(___argc: c_int, ___argv: [*c]const [*c]u8, __shortopts: [*c]const u8) c_int; -pub extern fn gethostname(__name: [*c]u8, __len: usize) c_int; -pub extern fn sethostname(__name: [*c]const u8, __len: usize) c_int; -pub extern fn sethostid(__id: c_long) c_int; -pub extern fn getdomainname(__name: [*c]u8, __len: usize) c_int; -pub extern fn setdomainname(__name: [*c]const u8, __len: usize) c_int; -pub extern fn vhangup() c_int; -pub extern fn revoke(__file: [*c]const u8) c_int; -pub extern fn profil(__sample_buffer: [*c]c_ushort, __size: usize, __offset: usize, __scale: c_uint) c_int; -pub extern fn acct(__name: [*c]const u8) c_int; -pub extern fn getusershell() [*c]u8; -pub extern fn endusershell() void; -pub extern fn setusershell() void; -pub extern fn daemon(__nochdir: c_int, __noclose: c_int) c_int; -pub extern fn chroot(__path: [*c]const u8) c_int; -pub extern fn getpass(__prompt: [*c]const u8) [*c]u8; -pub extern fn fsync(__fd: c_int) c_int; -pub extern fn gethostid() c_long; -pub extern fn sync() void; -pub extern fn getpagesize() c_int; -pub extern fn getdtablesize() c_int; -pub extern fn truncate(__file: [*c]const u8, __length: __off_t) c_int; -pub extern fn ftruncate(__fd: c_int, __length: __off_t) c_int; -pub extern fn brk(__addr: ?*anyopaque) c_int; -pub extern fn sbrk(__delta: isize) ?*anyopaque; -pub extern fn syscall(__sysno: c_long, ...) c_long; -pub extern fn lockf(__fd: c_int, __cmd: c_int, __len: __off_t) c_int; -pub extern fn fdatasync(__fildes: c_int) c_int; -pub extern fn crypt(__key: [*c]const u8, __salt: [*c]const u8) [*c]u8; -pub extern fn getentropy(__buffer: ?*anyopaque, __length: usize) c_int; -pub fn LoadOBJ(arg_fileName: [*c]const u8) callconv(.C) Model { - var fileName = arg_fileName; - _ = &fileName; - var objAttributes: tinyobj_attrib_t = tinyobj_attrib_t{ - .num_vertices = @as(c_uint, @bitCast(@as(c_int, 0))), - .num_normals = 0, - .num_texcoords = 0, - .num_faces = 0, - .num_face_num_verts = 0, - .pad0 = 0, - .vertices = null, - .normals = null, - .texcoords = null, - .faces = null, - .face_num_verts = null, - .material_ids = null, - }; - _ = &objAttributes; - var objShapes: [*c]tinyobj_shape_t = null; - _ = &objShapes; - var objShapeCount: c_uint = 0; - _ = &objShapeCount; - var objMaterials: [*c]tinyobj_material_t = null; - _ = &objMaterials; - var objMaterialCount: c_uint = 0; - _ = &objMaterialCount; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - model.transform = MatrixIdentity(); - var fileText: [*c]u8 = LoadFileText(fileName); - _ = &fileText; - if (fileText == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - TraceLog(LOG_ERROR, "MODEL Unable to read obj file %s", fileName); - return model; - } - var currentDir: [1024]u8 = [1]u8{ - 0, - } ++ [1]u8{0} ** 1023; - _ = ¤tDir; - _ = strcpy(@as([*c]u8, @ptrCast(@alignCast(¤tDir))), GetWorkingDirectory()); - var workingDir: [*c]const u8 = GetDirectoryPath(fileName); - _ = &workingDir; - if (chdir(workingDir) != @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to change working directory", workingDir); - } - var dataSize: c_uint = @as(c_uint, @bitCast(@as(c_uint, @truncate(strlen(fileText))))); - _ = &dataSize; - var flags: c_uint = @as(c_uint, @bitCast(@as(c_int, 1) << @intCast(0))); - _ = &flags; - var ret: c_int = tinyobj_parse_obj(&objAttributes, &objShapes, &objShapeCount, &objMaterials, &objMaterialCount, fileText, dataSize, flags); - _ = &ret; - if (ret != @as(c_int, 0)) { - TraceLog(LOG_ERROR, "MODEL Unable to read obj data %s", fileName); - return model; - } - UnloadFileText(fileText); - var faceVertIndex: c_uint = 0; - _ = &faceVertIndex; - var nextShape: c_uint = 1; - _ = &nextShape; - var lastMaterial: c_int = -@as(c_int, 1); - _ = &lastMaterial; - var meshIndex: c_uint = 0; - _ = &meshIndex; - var nextShapeEnd: c_uint = objAttributes.num_face_num_verts; - _ = &nextShapeEnd; - if (objShapeCount > @as(c_uint, @bitCast(@as(c_int, 1)))) { - nextShapeEnd = objShapes[nextShape].face_offset; - } - { - var faceId: c_uint = 0; - _ = &faceId; - while (faceId < objAttributes.num_faces) : (faceId +%= 1) { - if (faceVertIndex >= nextShapeEnd) { - nextShape +%= 1; - if (nextShape < objShapeCount) { - nextShapeEnd = objShapes[nextShape].face_offset; - } else { - nextShapeEnd = objAttributes.num_face_num_verts; - } - meshIndex +%= 1; - } else if ((lastMaterial != -@as(c_int, 1)) and (objAttributes.material_ids[faceId] != lastMaterial)) { - meshIndex +%= 1; - } - lastMaterial = objAttributes.material_ids[faceId]; - faceVertIndex +%= @as(c_uint, @bitCast(objAttributes.face_num_verts[faceId])); - } - } - model.meshCount = @as(c_int, @bitCast(meshIndex +% @as(c_uint, @bitCast(@as(c_int, 1))))); - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate(@sizeOf(Mesh) *% @as(c_ulong, @bitCast(@as(c_long, model.meshCount))))))))))); - if (objMaterialCount > @as(c_uint, @bitCast(@as(c_int, 0)))) { - model.materialCount = @as(c_int, @bitCast(objMaterialCount)); - model.materials = @as([*c]Material, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate(@sizeOf(Material) *% @as(c_ulong, @bitCast(@as(c_ulong, objMaterialCount))))))))))); - } else { - model.materialCount = 1; - model.materials = @as([*c]Material, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate(@sizeOf(Material) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1)))))))))))); - } - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate(@sizeOf(c_int) *% @as(c_ulong, @bitCast(@as(c_long, model.meshCount))))))))))); - var localMeshVertexCounts: [*c]c_uint = @as([*c]c_uint, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate(@sizeOf(c_uint) *% @as(c_ulong, @bitCast(@as(c_long, model.meshCount))))))))))); - _ = &localMeshVertexCounts; - faceVertIndex = 0; - nextShapeEnd = objAttributes.num_face_num_verts; - lastMaterial = -@as(c_int, 1); - meshIndex = 0; - var localMeshVertexCount: c_uint = 0; - _ = &localMeshVertexCount; - nextShape = 1; - if (objShapeCount > @as(c_uint, @bitCast(@as(c_int, 1)))) { - nextShapeEnd = objShapes[nextShape].face_offset; - } - { - var faceId: c_uint = 0; - _ = &faceId; - while (faceId < objAttributes.num_faces) : (faceId +%= 1) { - var newMesh: bool = @as(c_int, 0) != 0; - _ = &newMesh; - if (faceVertIndex >= nextShapeEnd) { - nextShape +%= 1; - if (nextShape < objShapeCount) { - nextShapeEnd = objShapes[nextShape].face_offset; - } else { - nextShapeEnd = objAttributes.num_face_num_verts; - } - newMesh = @as(c_int, 1) != 0; - } else if ((lastMaterial != -@as(c_int, 1)) and (objAttributes.material_ids[faceId] != lastMaterial)) { - newMesh = @as(c_int, 1) != 0; - } - lastMaterial = objAttributes.material_ids[faceId]; - if (newMesh) { - localMeshVertexCounts[meshIndex] = localMeshVertexCount; - localMeshVertexCount = 0; - meshIndex +%= 1; - } - faceVertIndex +%= @as(c_uint, @bitCast(objAttributes.face_num_verts[faceId])); - localMeshVertexCount +%= @as(c_uint, @bitCast(objAttributes.face_num_verts[faceId])); - } - } - localMeshVertexCounts[meshIndex] = localMeshVertexCount; - { - var i: c_int = 0; - _ = &i; - while (i < model.meshCount) : (i += 1) { - var vertexCount: c_uint = (blk: { - const tmp = i; - if (tmp >= 0) break :blk localMeshVertexCounts + @as(usize, @intCast(tmp)) else break :blk localMeshVertexCounts - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &vertexCount; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount = @as(c_int, @bitCast(vertexCount)); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.triangleCount = @as(c_int, @bitCast(vertexCount / @as(c_uint, @bitCast(@as(c_int, 3))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices = @as([*c]f32, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate((@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_ulong, vertexCount)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals = @as([*c]f32, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate((@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_ulong, vertexCount)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoords = @as([*c]f32, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate((@sizeOf(f32) *% @as(c_ulong, @bitCast(@as(c_ulong, vertexCount)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 2)))))))))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(MemAlloc(@as(c_uint, @bitCast(@as(c_uint, @truncate((@sizeOf(u8) *% @as(c_ulong, @bitCast(@as(c_ulong, vertexCount)))) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4)))))))))))); - } - } - MemFree(@as(?*anyopaque, @ptrCast(localMeshVertexCounts))); - localMeshVertexCounts = null; - faceVertIndex = 0; - nextShapeEnd = objAttributes.num_face_num_verts; - nextShape = 1; - if (objShapeCount > @as(c_uint, @bitCast(@as(c_int, 1)))) { - nextShapeEnd = objShapes[nextShape].face_offset; - } - lastMaterial = -@as(c_int, 1); - meshIndex = 0; - localMeshVertexCount = 0; - { - var faceId: c_uint = 0; - _ = &faceId; - while (faceId < objAttributes.num_faces) : (faceId +%= 1) { - var newMesh: bool = @as(c_int, 0) != 0; - _ = &newMesh; - if (faceVertIndex >= nextShapeEnd) { - nextShape +%= 1; - if (nextShape < objShapeCount) { - nextShapeEnd = objShapes[nextShape].face_offset; - } else { - nextShapeEnd = objAttributes.num_face_num_verts; - } - newMesh = @as(c_int, 1) != 0; - } - if ((lastMaterial != -@as(c_int, 1)) and (objAttributes.material_ids[faceId] != lastMaterial)) { - newMesh = @as(c_int, 1) != 0; - } - lastMaterial = objAttributes.material_ids[faceId]; - if (newMesh) { - localMeshVertexCount = 0; - meshIndex +%= 1; - } - var matId: c_int = 0; - _ = &matId; - if ((lastMaterial >= @as(c_int, 0)) and (lastMaterial < @as(c_int, @bitCast(objMaterialCount)))) { - matId = lastMaterial; - } - model.meshMaterial[meshIndex] = matId; - { - var f: c_int = 0; - _ = &f; - while (f < objAttributes.face_num_verts[faceId]) : (f += 1) { - var vertIndex: c_int = objAttributes.faces[faceVertIndex].v_idx; - _ = &vertIndex; - var normalIndex: c_int = objAttributes.faces[faceVertIndex].vn_idx; - _ = &normalIndex; - var texcordIndex: c_int = objAttributes.faces[faceVertIndex].vt_idx; - _ = &texcordIndex; - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 3)) : (i += 1) { - model.meshes[meshIndex].vertices[(localMeshVertexCount *% @as(c_uint, @bitCast(@as(c_int, 3)))) +% @as(c_uint, @bitCast(i))] = (blk: { - const tmp = (vertIndex * @as(c_int, 3)) + i; - if (tmp >= 0) break :blk objAttributes.vertices + @as(usize, @intCast(tmp)) else break :blk objAttributes.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 3)) : (i += 1) { - model.meshes[meshIndex].normals[(localMeshVertexCount *% @as(c_uint, @bitCast(@as(c_int, 3)))) +% @as(c_uint, @bitCast(i))] = (blk: { - const tmp = (normalIndex * @as(c_int, 3)) + i; - if (tmp >= 0) break :blk objAttributes.normals + @as(usize, @intCast(tmp)) else break :blk objAttributes.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 2)) : (i += 1) { - model.meshes[meshIndex].texcoords[(localMeshVertexCount *% @as(c_uint, @bitCast(@as(c_int, 2)))) +% @as(c_uint, @bitCast(i))] = (blk: { - const tmp = (texcordIndex * @as(c_int, 2)) + i; - if (tmp >= 0) break :blk objAttributes.texcoords + @as(usize, @intCast(tmp)) else break :blk objAttributes.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - model.meshes[meshIndex].texcoords[(localMeshVertexCount *% @as(c_uint, @bitCast(@as(c_int, 2)))) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = 1.0 - model.meshes[meshIndex].texcoords[(localMeshVertexCount *% @as(c_uint, @bitCast(@as(c_int, 2)))) +% @as(c_uint, @bitCast(@as(c_int, 1)))]; - { - var i: c_int = 0; - _ = &i; - while (i < @as(c_int, 4)) : (i += 1) { - model.meshes[meshIndex].colors[(localMeshVertexCount *% @as(c_uint, @bitCast(@as(c_int, 4)))) +% @as(c_uint, @bitCast(i))] = 255; - } - } - faceVertIndex +%= 1; - localMeshVertexCount +%= 1; - } - } - } - } - if (objMaterialCount > @as(c_uint, @bitCast(@as(c_int, 0)))) { - ProcessMaterialsOBJ(model.materials, objMaterials, @as(c_int, @bitCast(objMaterialCount))); - } else { - model.materials[@as(c_uint, @intCast(@as(c_int, 0)))] = LoadMaterialDefault(); - } - tinyobj_attrib_free(&objAttributes); - tinyobj_shapes_free(objShapes, objShapeCount); - tinyobj_materials_free(objMaterials, objMaterialCount); - { - var i: c_int = 0; - _ = &i; - while (i < model.meshCount) : (i += 1) { - UploadMesh(model.meshes + @as(usize, @bitCast(@as(isize, @intCast(i)))), @as(c_int, 1) != 0); - } - } - if (chdir(@as([*c]u8, @ptrCast(@alignCast(¤tDir)))) != @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to change working directory", @as([*c]u8, @ptrCast(@alignCast(¤tDir)))); - } - return model; -} -pub fn LoadIQM(arg_fileName: [*c]const u8) callconv(.C) Model { - var fileName = arg_fileName; - _ = &fileName; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - var fileDataPtr: [*c]u8 = fileData; - _ = &fileDataPtr; - const struct_IQMHeader = extern struct { - magic: [16]u8 = @import("std").mem.zeroes([16]u8), - version: c_uint = @import("std").mem.zeroes(c_uint), - dataSize: c_uint = @import("std").mem.zeroes(c_uint), - flags: c_uint = @import("std").mem.zeroes(c_uint), - num_text: c_uint = @import("std").mem.zeroes(c_uint), - ofs_text: c_uint = @import("std").mem.zeroes(c_uint), - num_meshes: c_uint = @import("std").mem.zeroes(c_uint), - ofs_meshes: c_uint = @import("std").mem.zeroes(c_uint), - num_vertexarrays: c_uint = @import("std").mem.zeroes(c_uint), - num_vertexes: c_uint = @import("std").mem.zeroes(c_uint), - ofs_vertexarrays: c_uint = @import("std").mem.zeroes(c_uint), - num_triangles: c_uint = @import("std").mem.zeroes(c_uint), - ofs_triangles: c_uint = @import("std").mem.zeroes(c_uint), - ofs_adjacency: c_uint = @import("std").mem.zeroes(c_uint), - num_joints: c_uint = @import("std").mem.zeroes(c_uint), - ofs_joints: c_uint = @import("std").mem.zeroes(c_uint), - num_poses: c_uint = @import("std").mem.zeroes(c_uint), - ofs_poses: c_uint = @import("std").mem.zeroes(c_uint), - num_anims: c_uint = @import("std").mem.zeroes(c_uint), - ofs_anims: c_uint = @import("std").mem.zeroes(c_uint), - num_frames: c_uint = @import("std").mem.zeroes(c_uint), - num_framechannels: c_uint = @import("std").mem.zeroes(c_uint), - ofs_frames: c_uint = @import("std").mem.zeroes(c_uint), - ofs_bounds: c_uint = @import("std").mem.zeroes(c_uint), - num_comment: c_uint = @import("std").mem.zeroes(c_uint), - ofs_comment: c_uint = @import("std").mem.zeroes(c_uint), - num_extensions: c_uint = @import("std").mem.zeroes(c_uint), - ofs_extensions: c_uint = @import("std").mem.zeroes(c_uint), - }; - _ = &struct_IQMHeader; - const IQMHeader = struct_IQMHeader; - _ = &IQMHeader; - const struct_IQMMesh = extern struct { - name: c_uint = @import("std").mem.zeroes(c_uint), - material: c_uint = @import("std").mem.zeroes(c_uint), - first_vertex: c_uint = @import("std").mem.zeroes(c_uint), - num_vertexes: c_uint = @import("std").mem.zeroes(c_uint), - first_triangle: c_uint = @import("std").mem.zeroes(c_uint), - num_triangles: c_uint = @import("std").mem.zeroes(c_uint), - }; - _ = &struct_IQMMesh; - const IQMMesh = struct_IQMMesh; - _ = &IQMMesh; - const struct_IQMTriangle = extern struct { - vertex: [3]c_uint = @import("std").mem.zeroes([3]c_uint), - }; - _ = &struct_IQMTriangle; - const IQMTriangle = struct_IQMTriangle; - _ = &IQMTriangle; - const struct_IQMJoint = extern struct { - name: c_uint = @import("std").mem.zeroes(c_uint), - parent: c_int = @import("std").mem.zeroes(c_int), - translate: [3]f32 = @import("std").mem.zeroes([3]f32), - rotate: [4]f32 = @import("std").mem.zeroes([4]f32), - scale: [3]f32 = @import("std").mem.zeroes([3]f32), - }; - _ = &struct_IQMJoint; - const IQMJoint = struct_IQMJoint; - _ = &IQMJoint; - const struct_IQMVertexArray = extern struct { - type: c_uint = @import("std").mem.zeroes(c_uint), - flags: c_uint = @import("std").mem.zeroes(c_uint), - format: c_uint = @import("std").mem.zeroes(c_uint), - size: c_uint = @import("std").mem.zeroes(c_uint), - offset: c_uint = @import("std").mem.zeroes(c_uint), - }; - _ = &struct_IQMVertexArray; - const IQMVertexArray = struct_IQMVertexArray; - _ = &IQMVertexArray; - const IQM_POSITION: c_int = 0; - _ = &IQM_POSITION; - const IQM_TEXCOORD: c_int = 1; - _ = &IQM_TEXCOORD; - const IQM_NORMAL: c_int = 2; - _ = &IQM_NORMAL; - const IQM_TANGENT: c_int = 3; - _ = &IQM_TANGENT; - const IQM_BLENDINDEXES: c_int = 4; - _ = &IQM_BLENDINDEXES; - const IQM_BLENDWEIGHTS: c_int = 5; - _ = &IQM_BLENDWEIGHTS; - const IQM_COLOR: c_int = 6; - _ = &IQM_COLOR; - const IQM_CUSTOM: c_int = 16; - _ = &IQM_CUSTOM; - const enum_unnamed_20 = c_uint; - _ = &enum_unnamed_20; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - var imesh: [*c]IQMMesh = null; - _ = &imesh; - var tri: [*c]IQMTriangle = null; - _ = &tri; - var va: [*c]IQMVertexArray = null; - _ = &va; - var ijoint: [*c]IQMJoint = null; - _ = &ijoint; - var vertex: [*c]f32 = null; - _ = &vertex; - var normal: [*c]f32 = null; - _ = &normal; - var text: [*c]f32 = null; - _ = &text; - var blendi: [*c]u8 = null; - _ = &blendi; - var blendw: [*c]u8 = null; - _ = &blendw; - var color: [*c]u8 = null; - _ = &color; - if (fileDataPtr == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return model; - var basePath: [*c]const u8 = GetDirectoryPath(fileName); - _ = &basePath; - var iqmHeader: [*c]IQMHeader = @as([*c]IQMHeader, @ptrCast(@alignCast(fileDataPtr))); - _ = &iqmHeader; - if (memcmp(@as(?*const anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&iqmHeader.*.magic))))), @as(?*const anyopaque, @ptrCast("INTERQUAKEMODEL")), @sizeOf([16]u8)) != @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName); - return model; - } - if (iqmHeader.*.version != @as(c_uint, @bitCast(@as(c_int, 2)))) { - TraceLog(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader.*.version); - return model; - } - imesh = @as([*c]IQMMesh, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_meshes))) *% @sizeOf(IQMMesh))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(imesh)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_meshes)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_meshes))) *% @sizeOf(IQMMesh)); - model.meshCount = @as(c_int, @bitCast(iqmHeader.*.num_meshes)); - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(Mesh))))); - model.materialCount = model.meshCount; - model.materials = @as([*c]Material, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.materialCount))), @sizeOf(Material))))); - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(c_int))))); - var name: [32]u8 = [1]u8{ - 0, - } ++ [1]u8{0} ** 31; - _ = &name; - var material: [32]u8 = [1]u8{ - 0, - } ++ [1]u8{0} ** 31; - _ = &material; - { - var i: c_int = 0; - _ = &i; - while (i < model.meshCount) : (i += 1) { - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&name))))), @as(?*const anyopaque, @ptrCast((fileDataPtr + iqmHeader.*.ofs_text) + (blk: { - const tmp = i; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 32)))) *% @sizeOf(u8)); - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&material))))), @as(?*const anyopaque, @ptrCast((fileDataPtr + iqmHeader.*.ofs_text) + (blk: { - const tmp = i; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.material)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 32)))) *% @sizeOf(u8)); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.materials + @as(usize, @intCast(tmp)) else break :blk model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = LoadMaterialDefault(); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTexture(TextFormat("%s/%s", basePath, @as([*c]u8, @ptrCast(@alignCast(&material))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshMaterial + @as(usize, @intCast(tmp)) else break :blk model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = i; - TraceLog(LOG_DEBUG, "MODEL: [%s] mesh name (%s), material (%s)", fileName, @as([*c]u8, @ptrCast(@alignCast(&name))), @as([*c]u8, @ptrCast(@alignCast(&material)))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount = @as(c_int, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.num_vertexes)); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoords = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 2)))), @sizeOf(f32))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneIds = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(u8))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(f32))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.triangleCount = @as(c_int, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.num_triangles)); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.indices = @as([*c]c_ushort, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.triangleCount * @as(c_int, 3)))), @sizeOf(c_ushort))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animVertices = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animNormals = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - } - } - tri = @as([*c]IQMTriangle, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_triangles))) *% @sizeOf(IQMTriangle))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(tri)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_triangles)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_triangles))) *% @sizeOf(IQMTriangle)); - { - var m: c_int = 0; - _ = &m; - while (m < model.meshCount) : (m += 1) { - var tcounter: c_int = 0; - _ = &tcounter; - { - var i: c_uint = (blk: { - const tmp = m; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.first_triangle; - _ = &i; - while (i < ((blk: { - const tmp = m; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.first_triangle +% (blk: { - const tmp = m; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.num_triangles)) : (i +%= 1) { - (blk: { - const tmp = tcounter + @as(c_int, 2); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.indices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_ushort, @truncate(tri[i].vertex[@as(c_uint, @intCast(@as(c_int, 0)))] -% (blk: { - const tmp = m; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.first_vertex)))); - (blk: { - const tmp = tcounter + @as(c_int, 1); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.indices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_ushort, @truncate(tri[i].vertex[@as(c_uint, @intCast(@as(c_int, 1)))] -% (blk: { - const tmp = m; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.first_vertex)))); - (blk: { - const tmp = tcounter; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.indices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.indices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_ushort, @bitCast(@as(c_ushort, @truncate(tri[i].vertex[@as(c_uint, @intCast(@as(c_int, 2)))] -% (blk: { - const tmp = m; - if (tmp >= 0) break :blk imesh + @as(usize, @intCast(tmp)) else break :blk imesh - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.first_vertex)))); - tcounter += @as(c_int, 3); - } - } - } - } - va = @as([*c]IQMVertexArray, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexarrays))) *% @sizeOf(IQMVertexArray))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(va)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_vertexarrays)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexarrays))) *% @sizeOf(IQMVertexArray)); - { - var i: c_uint = 0; - _ = &i; - while (i < iqmHeader.*.num_vertexarrays) : (i +%= 1) { - while (true) { - switch (va[i].type) { - @as(c_uint, @bitCast(@as(c_int, 0))) => { - { - vertex = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 3)))))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(vertex)), @as(?*const anyopaque, @ptrCast(fileDataPtr + va[i].offset)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 3)))))) *% @sizeOf(f32)); - { - var m: c_uint = 0; - _ = &m; - while (m < iqmHeader.*.num_meshes) : (m +%= 1) { - var vCounter: c_int = 0; - _ = &vCounter; - { - var i_1: c_uint = imesh[m].first_vertex *% @as(c_uint, @bitCast(@as(c_int, 3))); - _ = &i_1; - while (i_1 < ((imesh[m].first_vertex +% imesh[m].num_vertexes) *% @as(c_uint, @bitCast(@as(c_int, 3))))) : (i_1 +%= 1) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk model.meshes[m].vertices + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vertex[i_1]; - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk model.meshes[m].animVertices + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].animVertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = vertex[i_1]; - vCounter += 1; - } - } - } - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 2))) => { - { - normal = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 3)))))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(normal)), @as(?*const anyopaque, @ptrCast(fileDataPtr + va[i].offset)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 3)))))) *% @sizeOf(f32)); - { - var m: c_uint = 0; - _ = &m; - while (m < iqmHeader.*.num_meshes) : (m +%= 1) { - var vCounter: c_int = 0; - _ = &vCounter; - { - var i_1: c_uint = imesh[m].first_vertex *% @as(c_uint, @bitCast(@as(c_int, 3))); - _ = &i_1; - while (i_1 < ((imesh[m].first_vertex +% imesh[m].num_vertexes) *% @as(c_uint, @bitCast(@as(c_int, 3))))) : (i_1 +%= 1) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk model.meshes[m].normals + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = normal[i_1]; - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk model.meshes[m].animNormals + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].animNormals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = normal[i_1]; - vCounter += 1; - } - } - } - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 1))) => { - { - text = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 2)))))) *% @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(text)), @as(?*const anyopaque, @ptrCast(fileDataPtr + va[i].offset)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 2)))))) *% @sizeOf(f32)); - { - var m: c_uint = 0; - _ = &m; - while (m < iqmHeader.*.num_meshes) : (m +%= 1) { - var vCounter: c_int = 0; - _ = &vCounter; - { - var i_1: c_uint = imesh[m].first_vertex *% @as(c_uint, @bitCast(@as(c_int, 2))); - _ = &i_1; - while (i_1 < ((imesh[m].first_vertex +% imesh[m].num_vertexes) *% @as(c_uint, @bitCast(@as(c_int, 2))))) : (i_1 +%= 1) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk model.meshes[m].texcoords + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = text[i_1]; - vCounter += 1; - } - } - } - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 4))) => { - { - blendi = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 4)))))) *% @sizeOf(u8))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(blendi)), @as(?*const anyopaque, @ptrCast(fileDataPtr + va[i].offset)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 4)))))) *% @sizeOf(u8)); - { - var m: c_uint = 0; - _ = &m; - while (m < iqmHeader.*.num_meshes) : (m +%= 1) { - var boneCounter: c_int = 0; - _ = &boneCounter; - { - var i_1: c_uint = imesh[m].first_vertex *% @as(c_uint, @bitCast(@as(c_int, 4))); - _ = &i_1; - while (i_1 < ((imesh[m].first_vertex +% imesh[m].num_vertexes) *% @as(c_uint, @bitCast(@as(c_int, 4))))) : (i_1 +%= 1) { - (blk: { - const tmp = boneCounter; - if (tmp >= 0) break :blk model.meshes[m].boneIds + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].boneIds - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(blendi[i_1])); - boneCounter += 1; - } - } - } - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 5))) => { - { - blendw = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 4)))))) *% @sizeOf(u8))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(blendw)), @as(?*const anyopaque, @ptrCast(fileDataPtr + va[i].offset)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 4)))))) *% @sizeOf(u8)); - { - var m: c_uint = 0; - _ = &m; - while (m < iqmHeader.*.num_meshes) : (m +%= 1) { - var boneCounter: c_int = 0; - _ = &boneCounter; - { - var i_1: c_uint = imesh[m].first_vertex *% @as(c_uint, @bitCast(@as(c_int, 4))); - _ = &i_1; - while (i_1 < ((imesh[m].first_vertex +% imesh[m].num_vertexes) *% @as(c_uint, @bitCast(@as(c_int, 4))))) : (i_1 +%= 1) { - (blk: { - const tmp = boneCounter; - if (tmp >= 0) break :blk model.meshes[m].boneWeights + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].boneWeights - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, blendw[i_1]))))) / 255.0; - boneCounter += 1; - } - } - } - } - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 6))) => { - { - color = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 4)))))) *% @sizeOf(u8))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(color)), @as(?*const anyopaque, @ptrCast(fileDataPtr + va[i].offset)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_vertexes *% @as(c_uint, @bitCast(@as(c_int, 4)))))) *% @sizeOf(u8)); - { - var m: c_uint = 0; - _ = &m; - while (m < iqmHeader.*.num_meshes) : (m +%= 1) { - model.meshes[m].colors = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshes[m].vertexCount * @as(c_int, 4)))), @sizeOf(u8))))); - var vCounter: c_int = 0; - _ = &vCounter; - { - var i_1: c_uint = imesh[m].first_vertex *% @as(c_uint, @bitCast(@as(c_int, 4))); - _ = &i_1; - while (i_1 < ((imesh[m].first_vertex +% imesh[m].num_vertexes) *% @as(c_uint, @bitCast(@as(c_int, 4))))) : (i_1 +%= 1) { - (blk: { - const tmp = vCounter; - if (tmp >= 0) break :blk model.meshes[m].colors + @as(usize, @intCast(tmp)) else break :blk model.meshes[m].colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = color[i_1]; - vCounter += 1; - } - } - } - } - } - break; - }, - else => {}, - } - break; - } - } - } - ijoint = @as([*c]IQMJoint, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_joints))) *% @sizeOf(IQMJoint))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(ijoint)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_joints)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_joints))) *% @sizeOf(IQMJoint)); - model.boneCount = @as(c_int, @bitCast(iqmHeader.*.num_joints)); - model.bones = @as([*c]BoneInfo, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_joints))) *% @sizeOf(BoneInfo))))); - model.bindPose = @as([*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_joints))) *% @sizeOf(Transform))))); - { - var i: c_uint = 0; - _ = &i; - while (i < iqmHeader.*.num_joints) : (i +%= 1) { - model.bones[i].parent = ijoint[i].parent; - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&model.bones[i].name))))), @as(?*const anyopaque, @ptrCast((fileDataPtr + iqmHeader.*.ofs_text) + ijoint[i].name)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 32)))) *% @sizeOf(u8)); - model.bindPose[i].translation.x = ijoint[i].translate[@as(c_uint, @intCast(@as(c_int, 0)))]; - model.bindPose[i].translation.y = ijoint[i].translate[@as(c_uint, @intCast(@as(c_int, 1)))]; - model.bindPose[i].translation.z = ijoint[i].translate[@as(c_uint, @intCast(@as(c_int, 2)))]; - model.bindPose[i].rotation.x = ijoint[i].rotate[@as(c_uint, @intCast(@as(c_int, 0)))]; - model.bindPose[i].rotation.y = ijoint[i].rotate[@as(c_uint, @intCast(@as(c_int, 1)))]; - model.bindPose[i].rotation.z = ijoint[i].rotate[@as(c_uint, @intCast(@as(c_int, 2)))]; - model.bindPose[i].rotation.w = ijoint[i].rotate[@as(c_uint, @intCast(@as(c_int, 3)))]; - model.bindPose[i].scale.x = ijoint[i].scale[@as(c_uint, @intCast(@as(c_int, 0)))]; - model.bindPose[i].scale.y = ijoint[i].scale[@as(c_uint, @intCast(@as(c_int, 1)))]; - model.bindPose[i].scale.z = ijoint[i].scale[@as(c_uint, @intCast(@as(c_int, 2)))]; - } - } - BuildPoseFromParentJoints(model.bones, model.boneCount, model.bindPose); - UnloadFileData(fileData); - free(@as(?*anyopaque, @ptrCast(imesh))); - free(@as(?*anyopaque, @ptrCast(tri))); - free(@as(?*anyopaque, @ptrCast(va))); - free(@as(?*anyopaque, @ptrCast(vertex))); - free(@as(?*anyopaque, @ptrCast(normal))); - free(@as(?*anyopaque, @ptrCast(text))); - free(@as(?*anyopaque, @ptrCast(blendi))); - free(@as(?*anyopaque, @ptrCast(blendw))); - free(@as(?*anyopaque, @ptrCast(ijoint))); - free(@as(?*anyopaque, @ptrCast(color))); - return model; -} -pub fn LoadModelAnimationsIQM(arg_fileName: [*c]const u8, arg_animCount: [*c]c_int) callconv(.C) [*c]ModelAnimation { - var fileName = arg_fileName; - _ = &fileName; - var animCount = arg_animCount; - _ = &animCount; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - var fileDataPtr: [*c]u8 = fileData; - _ = &fileDataPtr; - const struct_IQMHeader = extern struct { - magic: [16]u8 = @import("std").mem.zeroes([16]u8), - version: c_uint = @import("std").mem.zeroes(c_uint), - dataSize: c_uint = @import("std").mem.zeroes(c_uint), - flags: c_uint = @import("std").mem.zeroes(c_uint), - num_text: c_uint = @import("std").mem.zeroes(c_uint), - ofs_text: c_uint = @import("std").mem.zeroes(c_uint), - num_meshes: c_uint = @import("std").mem.zeroes(c_uint), - ofs_meshes: c_uint = @import("std").mem.zeroes(c_uint), - num_vertexarrays: c_uint = @import("std").mem.zeroes(c_uint), - num_vertexes: c_uint = @import("std").mem.zeroes(c_uint), - ofs_vertexarrays: c_uint = @import("std").mem.zeroes(c_uint), - num_triangles: c_uint = @import("std").mem.zeroes(c_uint), - ofs_triangles: c_uint = @import("std").mem.zeroes(c_uint), - ofs_adjacency: c_uint = @import("std").mem.zeroes(c_uint), - num_joints: c_uint = @import("std").mem.zeroes(c_uint), - ofs_joints: c_uint = @import("std").mem.zeroes(c_uint), - num_poses: c_uint = @import("std").mem.zeroes(c_uint), - ofs_poses: c_uint = @import("std").mem.zeroes(c_uint), - num_anims: c_uint = @import("std").mem.zeroes(c_uint), - ofs_anims: c_uint = @import("std").mem.zeroes(c_uint), - num_frames: c_uint = @import("std").mem.zeroes(c_uint), - num_framechannels: c_uint = @import("std").mem.zeroes(c_uint), - ofs_frames: c_uint = @import("std").mem.zeroes(c_uint), - ofs_bounds: c_uint = @import("std").mem.zeroes(c_uint), - num_comment: c_uint = @import("std").mem.zeroes(c_uint), - ofs_comment: c_uint = @import("std").mem.zeroes(c_uint), - num_extensions: c_uint = @import("std").mem.zeroes(c_uint), - ofs_extensions: c_uint = @import("std").mem.zeroes(c_uint), - }; - _ = &struct_IQMHeader; - const IQMHeader = struct_IQMHeader; - _ = &IQMHeader; - const struct_IQMJoint = extern struct { - name: c_uint = @import("std").mem.zeroes(c_uint), - parent: c_int = @import("std").mem.zeroes(c_int), - translate: [3]f32 = @import("std").mem.zeroes([3]f32), - rotate: [4]f32 = @import("std").mem.zeroes([4]f32), - scale: [3]f32 = @import("std").mem.zeroes([3]f32), - }; - _ = &struct_IQMJoint; - const IQMJoint = struct_IQMJoint; - _ = &IQMJoint; - const struct_IQMPose = extern struct { - parent: c_int = @import("std").mem.zeroes(c_int), - mask: c_uint = @import("std").mem.zeroes(c_uint), - channeloffset: [10]f32 = @import("std").mem.zeroes([10]f32), - channelscale: [10]f32 = @import("std").mem.zeroes([10]f32), - }; - _ = &struct_IQMPose; - const IQMPose = struct_IQMPose; - _ = &IQMPose; - const struct_IQMAnim = extern struct { - name: c_uint = @import("std").mem.zeroes(c_uint), - first_frame: c_uint = @import("std").mem.zeroes(c_uint), - num_frames: c_uint = @import("std").mem.zeroes(c_uint), - framerate: f32 = @import("std").mem.zeroes(f32), - flags: c_uint = @import("std").mem.zeroes(c_uint), - }; - _ = &struct_IQMAnim; - const IQMAnim = struct_IQMAnim; - _ = &IQMAnim; - if (fileDataPtr == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return null; - var iqmHeader: [*c]IQMHeader = @as([*c]IQMHeader, @ptrCast(@alignCast(fileDataPtr))); - _ = &iqmHeader; - if (memcmp(@as(?*const anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&iqmHeader.*.magic))))), @as(?*const anyopaque, @ptrCast("INTERQUAKEMODEL")), @sizeOf([16]u8)) != @as(c_int, 0)) { - TraceLog(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName); - return null; - } - if (iqmHeader.*.version != @as(c_uint, @bitCast(@as(c_int, 2)))) { - TraceLog(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader.*.version); - return null; - } - var poses: [*c]IQMPose = @as([*c]IQMPose, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_poses))) *% @sizeOf(IQMPose))))); - _ = &poses; - _ = memcpy(@as(?*anyopaque, @ptrCast(poses)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_poses)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_poses))) *% @sizeOf(IQMPose)); - animCount.* = @as(c_int, @bitCast(iqmHeader.*.num_anims)); - var anim: [*c]IQMAnim = @as([*c]IQMAnim, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_anims))) *% @sizeOf(IQMAnim))))); - _ = &anim; - _ = memcpy(@as(?*anyopaque, @ptrCast(anim)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_anims)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_anims))) *% @sizeOf(IQMAnim)); - var animations: [*c]ModelAnimation = @as([*c]ModelAnimation, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_anims))) *% @sizeOf(ModelAnimation))))); - _ = &animations; - var framedata: [*c]c_ushort = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_frames *% iqmHeader.*.num_framechannels))) *% @sizeOf(c_ushort))))); - _ = &framedata; - _ = memcpy(@as(?*anyopaque, @ptrCast(framedata)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_frames)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_frames *% iqmHeader.*.num_framechannels))) *% @sizeOf(c_ushort)); - var joints: [*c]IQMJoint = @as([*c]IQMJoint, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_joints))) *% @sizeOf(IQMJoint))))); - _ = &joints; - _ = memcpy(@as(?*anyopaque, @ptrCast(joints)), @as(?*const anyopaque, @ptrCast(fileDataPtr + iqmHeader.*.ofs_joints)), @as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_joints))) *% @sizeOf(IQMJoint)); - { - var a: c_uint = 0; - _ = &a; - while (a < iqmHeader.*.num_anims) : (a +%= 1) { - animations[a].frameCount = @as(c_int, @bitCast(anim[a].num_frames)); - animations[a].boneCount = @as(c_int, @bitCast(iqmHeader.*.num_poses)); - animations[a].bones = @as([*c]BoneInfo, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_poses))) *% @sizeOf(BoneInfo))))); - animations[a].framePoses = @as([*c][*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, anim[a].num_frames))) *% @sizeOf([*c]Transform))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&animations[a].name))))), @as(?*const anyopaque, @ptrCast((fileDataPtr + iqmHeader.*.ofs_text) + anim[a].name)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 32))))); - TraceLog(LOG_INFO, "IQM Anim %s", @as([*c]u8, @ptrCast(@alignCast(&animations[a].name)))); - { - var j: c_uint = 0; - _ = &j; - while (j < iqmHeader.*.num_poses) : (j +%= 1) { - if (iqmHeader.*.num_joints > @as(c_uint, @bitCast(@as(c_int, 0)))) { - _ = memcpy(@as(?*anyopaque, @ptrCast(@as([*c]u8, @ptrCast(@alignCast(&animations[a].bones[j].name))))), @as(?*const anyopaque, @ptrCast((fileDataPtr + iqmHeader.*.ofs_text) + joints[j].name)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 32)))) *% @sizeOf(u8)); - } else { - _ = strcpy(@as([*c]u8, @ptrCast(@alignCast(&animations[a].bones[j].name))), "ANIMJOINTNAME"); - } - animations[a].bones[j].parent = poses[j].parent; - } - } - { - var j: c_uint = 0; - _ = &j; - while (j < anim[a].num_frames) : (j +%= 1) { - animations[a].framePoses[j] = @as([*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, iqmHeader.*.num_poses))) *% @sizeOf(Transform))))); - } - } - var dcounter: c_int = @as(c_int, @bitCast(anim[a].first_frame *% iqmHeader.*.num_framechannels)); - _ = &dcounter; - { - var frame: c_uint = 0; - _ = &frame; - while (frame < anim[a].num_frames) : (frame +%= 1) { - { - var i: c_uint = 0; - _ = &i; - while (i < iqmHeader.*.num_poses) : (i +%= 1) { - animations[a].framePoses[frame][i].translation.x = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 0)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 1)))) != 0) { - animations[a].framePoses[frame][i].translation.x += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 0)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].translation.y = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 1)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 2)))) != 0) { - animations[a].framePoses[frame][i].translation.y += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 1)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].translation.z = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 2)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 4)))) != 0) { - animations[a].framePoses[frame][i].translation.z += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 2)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].rotation.x = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 3)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 8)))) != 0) { - animations[a].framePoses[frame][i].rotation.x += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 3)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].rotation.y = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 4)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 16)))) != 0) { - animations[a].framePoses[frame][i].rotation.y += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 4)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].rotation.z = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 5)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 32)))) != 0) { - animations[a].framePoses[frame][i].rotation.z += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 5)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].rotation.w = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 6)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 64)))) != 0) { - animations[a].framePoses[frame][i].rotation.w += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 6)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].scale.x = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 7)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 128)))) != 0) { - animations[a].framePoses[frame][i].scale.x += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 7)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].scale.y = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 8)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 256)))) != 0) { - animations[a].framePoses[frame][i].scale.y += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 8)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].scale.z = poses[i].channeloffset[@as(c_uint, @intCast(@as(c_int, 9)))]; - if ((poses[i].mask & @as(c_uint, @bitCast(@as(c_int, 512)))) != 0) { - animations[a].framePoses[frame][i].scale.z += @as(f32, @floatFromInt(@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = dcounter; - if (tmp >= 0) break :blk framedata + @as(usize, @intCast(tmp)) else break :blk framedata - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))))) * poses[i].channelscale[@as(c_uint, @intCast(@as(c_int, 9)))]; - dcounter += 1; - } - animations[a].framePoses[frame][i].rotation = QuaternionNormalize(animations[a].framePoses[frame][i].rotation); - } - } - } - } - { - var frame: c_uint = 0; - _ = &frame; - while (frame < anim[a].num_frames) : (frame +%= 1) { - { - var i: c_int = 0; - _ = &i; - while (i < animations[a].boneCount) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].bones + @as(usize, @intCast(tmp)) else break :blk animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent >= @as(c_int, 0)) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation = QuaternionMultiply((blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation, (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3RotateByQuaternion((blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3Add((blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale = Vector3Multiply((blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk animations[a].framePoses[frame] + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses[frame] - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale); - } - } - } - } - } - } - } - UnloadFileData(fileData); - free(@as(?*anyopaque, @ptrCast(joints))); - free(@as(?*anyopaque, @ptrCast(framedata))); - free(@as(?*anyopaque, @ptrCast(poses))); - free(@as(?*anyopaque, @ptrCast(anim))); - return animations; -} -pub fn LoadGLTF(arg_fileName: [*c]const u8) callconv(.C) Model { - var fileName = arg_fileName; - _ = &fileName; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - if (fileData == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return model; - var options: cgltf_options = cgltf_options{ - .type = @as(c_uint, @bitCast(@as(c_int, 0))), - .json_token_count = @import("std").mem.zeroes(cgltf_size), - .memory = @import("std").mem.zeroes(cgltf_memory_options), - .file = @import("std").mem.zeroes(cgltf_file_options), - }; - _ = &options; - options.file.read = &LoadFileGLTFCallback; - options.file.release = &ReleaseFileGLTFCallback; - var data: [*c]cgltf_data = null; - _ = &data; - var result: cgltf_result = cgltf_parse(&options, @as(?*const anyopaque, @ptrCast(fileData)), @as(cgltf_size, @bitCast(@as(c_long, dataSize))), &data); - _ = &result; - if (result == @as(c_uint, @bitCast(cgltf_result_success))) { - if (data.*.file_type == @as(c_uint, @bitCast(cgltf_file_type_glb))) { - TraceLog(LOG_INFO, "MODEL: [%s] Model basic data (glb) loaded successfully", fileName); - } else if (data.*.file_type == @as(c_uint, @bitCast(cgltf_file_type_gltf))) { - TraceLog(LOG_INFO, "MODEL: [%s] Model basic data (glTF) loaded successfully", fileName); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Model format not recognized", fileName); - } - TraceLog(LOG_INFO, " > Meshes count: %i", data.*.meshes_count); - TraceLog(LOG_INFO, " > Materials count: %i (+1 default)", data.*.materials_count); - TraceLog(LOG_DEBUG, " > Buffers count: %i", data.*.buffers_count); - TraceLog(LOG_DEBUG, " > Images count: %i", data.*.images_count); - TraceLog(LOG_DEBUG, " > Textures count: %i", data.*.textures_count); - result = cgltf_load_buffers(&options, data, fileName); - if (result != @as(c_uint, @bitCast(cgltf_result_success))) { - TraceLog(LOG_INFO, "MODEL: [%s] Failed to load mesh/material buffers", fileName); - } - var primitivesCount: c_int = 0; - _ = &primitivesCount; - { - var i: c_uint = 0; - _ = &i; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < data.*.nodes_count) : (i +%= 1) { - var node: [*c]cgltf_node = &data.*.nodes[i]; - _ = &node; - var mesh: [*c]cgltf_mesh = node.*.mesh; - _ = &mesh; - if (!(mesh != null)) continue; - { - var p: c_uint = 0; - _ = &p; - while (@as(cgltf_size, @bitCast(@as(c_ulong, p))) < mesh.*.primitives_count) : (p +%= 1) { - if (mesh.*.primitives[p].type == @as(c_uint, @bitCast(cgltf_primitive_type_triangles))) { - primitivesCount += 1; - } - } - } - } - } - TraceLog(LOG_DEBUG, " > Primitives (triangles only) count based on hierarchy : %i", primitivesCount); - model.meshCount = primitivesCount; - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(Mesh))))); - model.materialCount = @as(c_int, @bitCast(@as(c_uint, @truncate(data.*.materials_count)))) + @as(c_int, 1); - model.materials = @as([*c]Material, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.materialCount))), @sizeOf(Material))))); - model.materials[@as(c_uint, @intCast(@as(c_int, 0)))] = LoadMaterialDefault(); - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(c_int))))); - { - var i: c_uint = 0; - _ = &i; - var j: c_uint = 1; - _ = &j; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < data.*.materials_count) : (_ = blk: { - i +%= 1; - break :blk blk_1: { - const ref = &j; - const tmp = ref.*; - ref.* +%= 1; - break :blk_1 tmp; - }; - }) { - model.materials[j] = LoadMaterialDefault(); - var texPath: [*c]const u8 = GetDirectoryPath(fileName); - _ = &texPath; - if (data.*.materials[i].has_pbr_metallic_roughness != 0) { - if (data.*.materials[i].pbr_metallic_roughness.base_color_texture.texture != null) { - var imAlbedo: Image = LoadImageFromCgltfImage(data.*.materials[i].pbr_metallic_roughness.base_color_texture.texture.*.image, texPath); - _ = &imAlbedo; - if (imAlbedo.data != @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(imAlbedo); - UnloadImage(imAlbedo); - } - } - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.r = @as(u8, @intFromFloat(data.*.materials[i].pbr_metallic_roughness.base_color_factor[@as(c_uint, @intCast(@as(c_int, 0)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.g = @as(u8, @intFromFloat(data.*.materials[i].pbr_metallic_roughness.base_color_factor[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.b = @as(u8, @intFromFloat(data.*.materials[i].pbr_metallic_roughness.base_color_factor[@as(c_uint, @intCast(@as(c_int, 2)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.a = @as(u8, @intFromFloat(data.*.materials[i].pbr_metallic_roughness.base_color_factor[@as(c_uint, @intCast(@as(c_int, 3)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - if (data.*.materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture != null) { - var imMetallicRoughness: Image = LoadImageFromCgltfImage(data.*.materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture.*.image, texPath); - _ = &imMetallicRoughness; - if (imMetallicRoughness.data != @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - (blk: { - const tmp = MATERIAL_MAP_ROUGHNESS; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(imMetallicRoughness); - UnloadImage(imMetallicRoughness); - } - var roughness: f32 = data.*.materials[i].pbr_metallic_roughness.roughness_factor; - _ = &roughness; - (blk: { - const tmp = MATERIAL_MAP_ROUGHNESS; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = roughness; - var metallic: f32 = data.*.materials[i].pbr_metallic_roughness.metallic_factor; - _ = &metallic; - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = metallic; - } - if (data.*.materials[i].normal_texture.texture != null) { - var imNormal: Image = LoadImageFromCgltfImage(data.*.materials[i].normal_texture.texture.*.image, texPath); - _ = &imNormal; - if (imNormal.data != @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(imNormal); - UnloadImage(imNormal); - } - } - if (data.*.materials[i].occlusion_texture.texture != null) { - var imOcclusion: Image = LoadImageFromCgltfImage(data.*.materials[i].occlusion_texture.texture.*.image, texPath); - _ = &imOcclusion; - if (imOcclusion.data != @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - (blk: { - const tmp = MATERIAL_MAP_OCCLUSION; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(imOcclusion); - UnloadImage(imOcclusion); - } - } - if (data.*.materials[i].emissive_texture.texture != null) { - var imEmissive: Image = LoadImageFromCgltfImage(data.*.materials[i].emissive_texture.texture.*.image, texPath); - _ = &imEmissive; - if (imEmissive.data != @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(imEmissive); - UnloadImage(imEmissive); - } - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.r = @as(u8, @intFromFloat(data.*.materials[i].emissive_factor[@as(c_uint, @intCast(@as(c_int, 0)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.g = @as(u8, @intFromFloat(data.*.materials[i].emissive_factor[@as(c_uint, @intCast(@as(c_int, 1)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.b = @as(u8, @intFromFloat(data.*.materials[i].emissive_factor[@as(c_uint, @intCast(@as(c_int, 2)))] * @as(cgltf_float, @floatFromInt(@as(c_int, 255))))); - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk model.materials[j].maps + @as(usize, @intCast(tmp)) else break :blk model.materials[j].maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color.a = 255; - } - } - } - } - var meshIndex: c_int = 0; - _ = &meshIndex; - { - var i: c_uint = 0; - _ = &i; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < data.*.nodes_count) : (i +%= 1) { - var node: [*c]cgltf_node = &data.*.nodes[i]; - _ = &node; - var mesh: [*c]cgltf_mesh = node.*.mesh; - _ = &mesh; - if (!(mesh != null)) continue; - var worldTransform: [16]cgltf_float = undefined; - _ = &worldTransform; - cgltf_node_transform_world(node, @as([*c]cgltf_float, @ptrCast(@alignCast(&worldTransform)))); - var worldMatrix: Matrix = Matrix{ - .m0 = worldTransform[@as(c_uint, @intCast(@as(c_int, 0)))], - .m4 = worldTransform[@as(c_uint, @intCast(@as(c_int, 4)))], - .m8 = worldTransform[@as(c_uint, @intCast(@as(c_int, 8)))], - .m12 = worldTransform[@as(c_uint, @intCast(@as(c_int, 12)))], - .m1 = worldTransform[@as(c_uint, @intCast(@as(c_int, 1)))], - .m5 = worldTransform[@as(c_uint, @intCast(@as(c_int, 5)))], - .m9 = worldTransform[@as(c_uint, @intCast(@as(c_int, 9)))], - .m13 = worldTransform[@as(c_uint, @intCast(@as(c_int, 13)))], - .m2 = worldTransform[@as(c_uint, @intCast(@as(c_int, 2)))], - .m6 = worldTransform[@as(c_uint, @intCast(@as(c_int, 6)))], - .m10 = worldTransform[@as(c_uint, @intCast(@as(c_int, 10)))], - .m14 = worldTransform[@as(c_uint, @intCast(@as(c_int, 14)))], - .m3 = worldTransform[@as(c_uint, @intCast(@as(c_int, 3)))], - .m7 = worldTransform[@as(c_uint, @intCast(@as(c_int, 7)))], - .m11 = worldTransform[@as(c_uint, @intCast(@as(c_int, 11)))], - .m15 = worldTransform[@as(c_uint, @intCast(@as(c_int, 15)))], - }; - _ = &worldMatrix; - var worldMatrixNormals: Matrix = MatrixTranspose(MatrixInvert(worldMatrix)); - _ = &worldMatrixNormals; - { - var p: c_uint = 0; - _ = &p; - while (@as(cgltf_size, @bitCast(@as(c_ulong, p))) < mesh.*.primitives_count) : (p +%= 1) { - if (mesh.*.primitives[p].type != @as(c_uint, @bitCast(cgltf_primitive_type_triangles))) continue; - { - var j: c_uint = 0; - _ = &j; - while (@as(cgltf_size, @bitCast(@as(c_ulong, j))) < mesh.*.primitives[p].attributes_count) : (j +%= 1) { - if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_position))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if ((attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec3))) and (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f)))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount = @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.count)))); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))) *% @sizeOf(f32))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 3)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - var vertices: [*c]f32 = (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices; - _ = &vertices; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - var vt: Vector3 = Vector3Transform(Vector3{ - .x = vertices[@as(c_uint, @bitCast(@as(c_int, 3))) *% k], - .y = vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 1)))], - .z = vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 2)))], - }, worldMatrix); - _ = &vt; - vertices[@as(c_uint, @bitCast(@as(c_int, 3))) *% k] = vt.x; - vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = vt.y; - vertices[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 2)))] = vt.z; - } - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Vertices attribute data format not supported, use vec3 float", fileName); - } - } else if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_normal))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if ((attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec3))) and (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f)))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))) *% @sizeOf(f32))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 3)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - var normals: [*c]f32 = (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals; - _ = &normals; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - var nt: Vector3 = Vector3Transform(Vector3{ - .x = normals[@as(c_uint, @bitCast(@as(c_int, 3))) *% k], - .y = normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 1)))], - .z = normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 2)))], - }, worldMatrixNormals); - _ = &nt; - normals[@as(c_uint, @bitCast(@as(c_int, 3))) *% k] = nt.x; - normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = nt.y; - normals[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 2)))] = nt.z; - } - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Normal attribute data format not supported, use vec3 float", fileName); - } - } else if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_tangent))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if ((attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec4))) and (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f)))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.tangents = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(f32))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.tangents[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - var tangents: [*c]f32 = (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.tangents; - _ = &tangents; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - var tt: Vector3 = Vector3Transform(Vector3{ - .x = tangents[@as(c_uint, @bitCast(@as(c_int, 3))) *% k], - .y = tangents[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 1)))], - .z = tangents[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 2)))], - }, worldMatrix); - _ = &tt; - tangents[@as(c_uint, @bitCast(@as(c_int, 3))) *% k] = tt.x; - tangents[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 1)))] = tt.y; - tangents[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(@as(c_int, 2)))] = tt.z; - } - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Tangent attribute data format not supported, use vec4 float", fileName); - } - } else if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_texcoord))) { - var texcoordPtr: [*c]f32 = null; - _ = &texcoordPtr; - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if (attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec2))) { - if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f))) { - texcoordPtr = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2))))) *% @sizeOf(f32))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 2)) : (l += 1) { - texcoordPtr[(@as(c_uint, @bitCast(@as(c_int, 2))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_8u))) { - texcoordPtr = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2))))) *% @sizeOf(f32))))); - var temp: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2))))) *% @sizeOf(u8))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]u8 = (@as([*c]u8, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(u8))) + (attribute.*.offset / @sizeOf(u8)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 2)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 2))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(u8))))); - } - } - } - { - var t: c_uint = 0; - _ = &t; - while (@as(cgltf_size, @bitCast(@as(c_ulong, t))) < (attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2)))))) : (t +%= 1) { - texcoordPtr[t] = @as(f32, @floatFromInt(temp[t])) / 255.0; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_16u))) { - texcoordPtr = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2))))) *% @sizeOf(f32))))); - var temp: [*c]c_ushort = @as([*c]c_ushort, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2))))) *% @sizeOf(c_ushort))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_ushort = (@as([*c]c_ushort, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_ushort))) + (attribute.*.offset / @sizeOf(c_ushort)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 2)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 2))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_ushort))))); - } - } - } - { - var t: c_uint = 0; - _ = &t; - while (@as(cgltf_size, @bitCast(@as(c_ulong, t))) < (attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 2)))))) : (t +%= 1) { - texcoordPtr[t] = @as(f32, @floatFromInt(temp[t])) / 65535.0; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Texcoords attribute data format not supported", fileName); - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Texcoords attribute data format not supported, use vec2 float", fileName); - } - var index_1: c_int = mesh.*.primitives[p].attributes[j].index; - _ = &index_1; - if (index_1 == @as(c_int, 0)) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoords = texcoordPtr; - } else if (index_1 == @as(c_int, 1)) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoords2 = texcoordPtr; - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] No more than 2 texture coordinates attributes supported", fileName); - if (texcoordPtr != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - free(@as(?*anyopaque, @ptrCast(texcoordPtr))); - } - } - } else if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_color))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if (attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec3))) { - if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_8u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - var temp: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))) *% @sizeOf(u8))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]u8 = (@as([*c]u8, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(u8))) + (attribute.*.offset / @sizeOf(u8)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 3)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(u8))))); - } - } - } - { - var c: c_uint = 0; - _ = &c; - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, c))) < ((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3)))))) : (_ = blk: { - c +%= @as(c_uint, @bitCast(@as(c_int, 4))); - break :blk blk_1: { - const ref = &k; - ref.* +%= @as(c_uint, @bitCast(@as(c_int, 3))); - break :blk_1 ref.*; - }; - }) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c] = temp[k]; - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 1)))] = temp[k +% @as(c_uint, @bitCast(@as(c_int, 1)))]; - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 2)))] = temp[k +% @as(c_uint, @bitCast(@as(c_int, 2)))]; - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 3)))] = 255; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_16u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - var temp: [*c]c_ushort = @as([*c]c_ushort, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))) *% @sizeOf(c_ushort))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_ushort = (@as([*c]c_ushort, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_ushort))) + (attribute.*.offset / @sizeOf(c_ushort)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 3)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_ushort))))); - } - } - } - { - var c: c_uint = 0; - _ = &c; - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, c))) < ((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3)))))) : (_ = blk: { - c +%= @as(c_uint, @bitCast(@as(c_int, 4))); - break :blk blk_1: { - const ref = &k; - ref.* +%= @as(c_uint, @bitCast(@as(c_int, 3))); - break :blk_1 ref.*; - }; - }) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c] = @as(u8, @intFromFloat((@as(f32, @floatFromInt(temp[k])) / 65535.0) * 255.0)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 1)))] = @as(u8, @intFromFloat((@as(f32, @floatFromInt(temp[k +% @as(c_uint, @bitCast(@as(c_int, 1)))])) / 65535.0) * 255.0)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 2)))] = @as(u8, @intFromFloat((@as(f32, @floatFromInt(temp[k +% @as(c_uint, @bitCast(@as(c_int, 2)))])) / 65535.0) * 255.0)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 3)))] = 255; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - var temp: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))) *% @sizeOf(f32))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 3)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 3))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - { - var c: c_uint = 0; - _ = &c; - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, c))) < ((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3)))))) : (_ = blk: { - c +%= @as(c_uint, @bitCast(@as(c_int, 4))); - break :blk blk_1: { - const ref = &k; - ref.* +%= @as(c_uint, @bitCast(@as(c_int, 3))); - break :blk_1 ref.*; - }; - }) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c] = @as(u8, @intFromFloat(temp[k] * 255.0)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 1)))] = @as(u8, @intFromFloat(temp[k +% @as(c_uint, @bitCast(@as(c_int, 1)))] * 255.0)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 2)))] = @as(u8, @intFromFloat(temp[k +% @as(c_uint, @bitCast(@as(c_int, 2)))] * 255.0)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c +% @as(c_uint, @bitCast(@as(c_int, 3)))] = 255; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Color attribute data format not supported", fileName); - } - } else if (attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec4))) { - if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_8u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]u8 = (@as([*c]u8, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(u8))) + (attribute.*.offset / @sizeOf(u8)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(u8))))); - } - } - } - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_16u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - var temp: [*c]c_ushort = @as([*c]c_ushort, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(c_ushort))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_ushort = (@as([*c]c_ushort, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_ushort))) + (attribute.*.offset / @sizeOf(c_ushort)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_ushort))))); - } - } - } - { - var c: c_uint = 0; - _ = &c; - while (@as(cgltf_size, @bitCast(@as(c_ulong, c))) < (attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))))) : (c +%= 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c] = @as(u8, @intFromFloat((@as(f32, @floatFromInt(temp[c])) / 65535.0) * 255.0)); - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - var temp: [*c]f32 = @as([*c]f32, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(f32))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - { - var c: c_uint = 0; - _ = &c; - while (@as(cgltf_size, @bitCast(@as(c_ulong, c))) < (attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))))) : (c +%= 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors[c] = @as(u8, @intFromFloat(temp[c] * 255.0)); - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Color attribute data format not supported", fileName); - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Color attribute data format not supported", fileName); - } - } - } - } - if (mesh.*.primitives[p].indices != @as([*c]cgltf_accessor, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].indices; - _ = &attribute; - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.triangleCount = @divTrunc(@as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.count)))), @as(c_int, 3)); - if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_16u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.indices = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(attribute.*.count *% @sizeOf(c_ushort))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_ushort = (@as([*c]c_ushort, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_ushort))) + (attribute.*.offset / @sizeOf(c_ushort)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 1)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.indices[(@as(c_uint, @bitCast(@as(c_int, 1))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_ushort))))); - } - } - } - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.indices = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(attribute.*.count *% @sizeOf(c_ushort))))); - var temp: [*c]c_uint = @as([*c]c_uint, @ptrCast(@alignCast(malloc(attribute.*.count *% @sizeOf(c_uint))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_uint = (@as([*c]c_uint, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_uint))) + (attribute.*.offset / @sizeOf(c_uint)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 1)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 1))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_uint))))); - } - } - } - { - var d: c_uint = 0; - _ = &d; - while (@as(cgltf_size, @bitCast(@as(c_ulong, d))) < attribute.*.count) : (d +%= 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.indices[d] = @as(c_ushort, @bitCast(@as(c_ushort, @truncate(temp[d])))); - } - } - TraceLog(LOG_WARNING, "MODEL: [%s] Indices data converted from u32 to u16, possible loss of data", fileName); - free(@as(?*anyopaque, @ptrCast(temp))); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Indices data format not supported, use u16", fileName); - } - } else { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.triangleCount = @divTrunc((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount, @as(c_int, 3)); - } - { - var m: c_uint = 0; - _ = &m; - while (@as(cgltf_size, @bitCast(@as(c_ulong, m))) < data.*.materials_count) : (m +%= 1) { - if ((&data.*.materials[m]) == mesh.*.primitives[p].material) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshMaterial + @as(usize, @intCast(tmp)) else break :blk model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(c_int, @bitCast(m +% @as(c_uint, @bitCast(@as(c_int, 1))))); - break; - } - } - } - meshIndex += 1; - } - } - } - } - if (data.*.skins_count == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))) { - var skin: cgltf_skin = data.*.skins[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &skin; - model.bones = LoadBoneInfoGLTF(skin, &model.boneCount); - model.bindPose = @as([*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, model.boneCount))) *% @sizeOf(Transform))))); - { - var i: c_int = 0; - _ = &i; - while (i < model.boneCount) : (i += 1) { - var node: [*c]cgltf_node = (blk: { - const tmp = i; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &node; - var worldTransform: [16]cgltf_float = undefined; - _ = &worldTransform; - cgltf_node_transform_world(node, @as([*c]cgltf_float, @ptrCast(@alignCast(&worldTransform)))); - var worldMatrix: Matrix = Matrix{ - .m0 = worldTransform[@as(c_uint, @intCast(@as(c_int, 0)))], - .m4 = worldTransform[@as(c_uint, @intCast(@as(c_int, 4)))], - .m8 = worldTransform[@as(c_uint, @intCast(@as(c_int, 8)))], - .m12 = worldTransform[@as(c_uint, @intCast(@as(c_int, 12)))], - .m1 = worldTransform[@as(c_uint, @intCast(@as(c_int, 1)))], - .m5 = worldTransform[@as(c_uint, @intCast(@as(c_int, 5)))], - .m9 = worldTransform[@as(c_uint, @intCast(@as(c_int, 9)))], - .m13 = worldTransform[@as(c_uint, @intCast(@as(c_int, 13)))], - .m2 = worldTransform[@as(c_uint, @intCast(@as(c_int, 2)))], - .m6 = worldTransform[@as(c_uint, @intCast(@as(c_int, 6)))], - .m10 = worldTransform[@as(c_uint, @intCast(@as(c_int, 10)))], - .m14 = worldTransform[@as(c_uint, @intCast(@as(c_int, 14)))], - .m3 = worldTransform[@as(c_uint, @intCast(@as(c_int, 3)))], - .m7 = worldTransform[@as(c_uint, @intCast(@as(c_int, 7)))], - .m11 = worldTransform[@as(c_uint, @intCast(@as(c_int, 11)))], - .m15 = worldTransform[@as(c_uint, @intCast(@as(c_int, 15)))], - }; - _ = &worldMatrix; - MatrixDecompose(worldMatrix, &(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, &(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation, &(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale); - } - } - } else if (data.*.skins_count > @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))) { - TraceLog(LOG_ERROR, "MODEL: [%s] can only load one skin (armature) per model, but gltf skins_count == %i", fileName, data.*.skins_count); - } - meshIndex = 0; - { - var i: c_uint = 0; - _ = &i; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < data.*.nodes_count) : (i +%= 1) { - var node: [*c]cgltf_node = &data.*.nodes[i]; - _ = &node; - var mesh: [*c]cgltf_mesh = node.*.mesh; - _ = &mesh; - if (!(mesh != null)) continue; - { - var p: c_uint = 0; - _ = &p; - while (@as(cgltf_size, @bitCast(@as(c_ulong, p))) < mesh.*.primitives_count) : (p +%= 1) { - if (mesh.*.primitives[p].type != @as(c_uint, @bitCast(cgltf_primitive_type_triangles))) continue; - { - var j: c_uint = 0; - _ = &j; - while (@as(cgltf_size, @bitCast(@as(c_ulong, j))) < mesh.*.primitives[p].attributes_count) : (j +%= 1) { - if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_joints))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if (attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec4))) { - if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_8u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneIds = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(u8))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]u8 = (@as([*c]u8, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(u8))) + (attribute.*.offset / @sizeOf(u8)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneIds[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(u8))))); - } - } - } - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_16u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneIds = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(u8))))); - var temp: [*c]c_ushort = @as([*c]c_ushort, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(c_ushort))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_ushort = (@as([*c]c_ushort, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_ushort))) + (attribute.*.offset / @sizeOf(c_ushort)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_ushort))))); - } - } - } - var boneIdOverflowWarning: bool = @as(c_int, 0) != 0; - _ = &boneIdOverflowWarning; - { - var b: c_int = 0; - _ = &b; - while (b < ((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4))) : (b += 1) { - if ((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = b; - if (tmp >= 0) break :blk temp + @as(usize, @intCast(tmp)) else break :blk temp - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) > @as(c_int, 255)) and !boneIdOverflowWarning) { - TraceLog(LOG_WARNING, "MODEL: [%s] Joint attribute data format (u16) overflow", fileName); - boneIdOverflowWarning = @as(c_int, 1) != 0; - } - (blk: { - const tmp = b; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = meshIndex; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneIds + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = meshIndex; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneIds - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(u8, @truncate((blk: { - const tmp = b; - if (tmp >= 0) break :blk temp + @as(usize, @intCast(tmp)) else break :blk temp - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)))); - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported", fileName); - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported", fileName); - } - } else if (mesh.*.primitives[p].attributes[j].type == @as(c_uint, @bitCast(cgltf_attribute_type_weights))) { - var attribute: [*c]cgltf_accessor = mesh.*.primitives[p].attributes[j].data; - _ = &attribute; - if (attribute.*.type == @as(c_uint, @bitCast(cgltf_type_vec4))) { - if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_8u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(f32))))); - var temp: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(u8))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]u8 = (@as([*c]u8, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(u8))) + (attribute.*.offset / @sizeOf(u8)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(u8))))); - } - } - } - { - var b: c_uint = 0; - _ = &b; - while (@as(cgltf_size, @bitCast(@as(c_ulong, b))) < (attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))))) : (b +%= 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights[b] = @as(f32, @floatFromInt(temp[b])) / 255.0; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_16u))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(f32))))); - var temp: [*c]c_ushort = @as([*c]c_ushort, @ptrCast(@alignCast(malloc((attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))) *% @sizeOf(c_ushort))))); - _ = &temp; - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]c_ushort = (@as([*c]c_ushort, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(c_ushort))) + (attribute.*.offset / @sizeOf(c_ushort)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - temp[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(c_ushort))))); - } - } - } - { - var b: c_uint = 0; - _ = &b; - while (@as(cgltf_size, @bitCast(@as(c_ulong, b))) < (attribute.*.count *% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4)))))) : (b +%= 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights[b] = @as(f32, @floatFromInt(temp[b])) / 65535.0; - } - } - free(@as(?*anyopaque, @ptrCast(temp))); - } else if (attribute.*.component_type == @as(c_uint, @bitCast(cgltf_component_type_r_32f))) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(f32))))); - { - var n: c_int = 0; - _ = &n; - var buffer: [*c]f32 = (@as([*c]f32, @ptrCast(@alignCast(attribute.*.buffer_view.*.buffer.*.data))) + (attribute.*.buffer_view.*.offset / @sizeOf(f32))) + (attribute.*.offset / @sizeOf(f32)); - _ = &buffer; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < attribute.*.count) : (k +%= 1) { - { - var l: c_int = 0; - _ = &l; - while (l < @as(c_int, 4)) : (l += 1) { - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights[(@as(c_uint, @bitCast(@as(c_int, 4))) *% k) +% @as(c_uint, @bitCast(l))] = (blk: { - const tmp = n + l; - if (tmp >= 0) break :blk buffer + @as(usize, @intCast(tmp)) else break :blk buffer - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - } - } - n += @as(c_int, @bitCast(@as(c_uint, @truncate(attribute.*.stride / @sizeOf(f32))))); - } - } - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Joint weight attribute data format not supported, use vec4 float", fileName); - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Joint weight attribute data format not supported, use vec4 float", fileName); - } - } - } - } - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animVertices = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - _ = memcpy(@as(?*anyopaque, @ptrCast((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animVertices)), @as(?*const anyopaque, @ptrCast((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices)), @as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32)); - (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animNormals = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - if ((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals != @as([*c]f32, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - _ = memcpy(@as(?*anyopaque, @ptrCast((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animNormals)), @as(?*const anyopaque, @ptrCast((blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals)), @as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = meshIndex; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32)); - } - meshIndex += 1; - } - } - } - } - cgltf_free(data); - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName); - } - UnloadFileData(fileData); - return model; -} -pub fn LoadModelAnimationsGLTF(arg_fileName: [*c]const u8, arg_animCount: [*c]c_int) callconv(.C) [*c]ModelAnimation { - var fileName = arg_fileName; - _ = &fileName; - var animCount = arg_animCount; - _ = &animCount; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - var animations: [*c]ModelAnimation = null; - _ = &animations; - var options: cgltf_options = cgltf_options{ - .type = @as(c_uint, @bitCast(@as(c_int, 0))), - .json_token_count = @import("std").mem.zeroes(cgltf_size), - .memory = @import("std").mem.zeroes(cgltf_memory_options), - .file = @import("std").mem.zeroes(cgltf_file_options), - }; - _ = &options; - options.file.read = &LoadFileGLTFCallback; - options.file.release = &ReleaseFileGLTFCallback; - var data: [*c]cgltf_data = null; - _ = &data; - var result: cgltf_result = cgltf_parse(&options, @as(?*const anyopaque, @ptrCast(fileData)), @as(cgltf_size, @bitCast(@as(c_long, dataSize))), &data); - _ = &result; - if (result != @as(c_uint, @bitCast(cgltf_result_success))) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName); - animCount.* = 0; - return null; - } - result = cgltf_load_buffers(&options, data, fileName); - if (result != @as(c_uint, @bitCast(cgltf_result_success))) { - TraceLog(LOG_INFO, "MODEL: [%s] Failed to load animation buffers", fileName); - } - if (result == @as(c_uint, @bitCast(cgltf_result_success))) { - if (data.*.skins_count == @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))) { - var skin: cgltf_skin = data.*.skins[@as(c_uint, @intCast(@as(c_int, 0)))]; - _ = &skin; - animCount.* = @as(c_int, @bitCast(@as(c_uint, @truncate(data.*.animations_count)))); - animations = @as([*c]ModelAnimation, @ptrCast(@alignCast(malloc(data.*.animations_count *% @sizeOf(ModelAnimation))))); - { - var i: c_uint = 0; - _ = &i; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < data.*.animations_count) : (i +%= 1) { - animations[i].bones = LoadBoneInfoGLTF(skin, &animations[i].boneCount); - var animData: cgltf_animation = data.*.animations[i]; - _ = &animData; - const struct_Channels = extern struct { - translate: [*c]cgltf_animation_channel = @import("std").mem.zeroes([*c]cgltf_animation_channel), - rotate: [*c]cgltf_animation_channel = @import("std").mem.zeroes([*c]cgltf_animation_channel), - scale: [*c]cgltf_animation_channel = @import("std").mem.zeroes([*c]cgltf_animation_channel), - interpolationType: cgltf_interpolation_type = @import("std").mem.zeroes(cgltf_interpolation_type), - }; - _ = &struct_Channels; - var boneChannels: [*c]struct_Channels = @as([*c]struct_Channels, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, animations[i].boneCount))), @sizeOf(struct_Channels))))); - _ = &boneChannels; - var animDuration: f32 = 0.0; - _ = &animDuration; - { - var j: c_uint = 0; - _ = &j; - while (@as(cgltf_size, @bitCast(@as(c_ulong, j))) < animData.channels_count) : (j +%= 1) { - var channel: cgltf_animation_channel = animData.channels[j]; - _ = &channel; - var boneIndex: c_int = -@as(c_int, 1); - _ = &boneIndex; - { - var k: c_uint = 0; - _ = &k; - while (@as(cgltf_size, @bitCast(@as(c_ulong, k))) < skin.joints_count) : (k +%= 1) { - if (animData.channels[j].target_node == skin.joints[k]) { - boneIndex = @as(c_int, @bitCast(k)); - break; - } - } - } - if (boneIndex == -@as(c_int, 1)) { - continue; - } - (blk: { - const tmp = boneIndex; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.interpolationType = animData.channels[j].sampler.*.interpolation; - if (animData.channels[j].sampler.*.interpolation != @as(c_uint, @bitCast(cgltf_interpolation_type_max_enum))) { - if (channel.target_path == @as(c_uint, @bitCast(cgltf_animation_path_type_translation))) { - (blk: { - const tmp = boneIndex; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translate = &animData.channels[j]; - } else if (channel.target_path == @as(c_uint, @bitCast(cgltf_animation_path_type_rotation))) { - (blk: { - const tmp = boneIndex; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotate = &animData.channels[j]; - } else if (channel.target_path == @as(c_uint, @bitCast(cgltf_animation_path_type_scale))) { - (blk: { - const tmp = boneIndex; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale = &animData.channels[j]; - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Unsupported target_path on channel %d's sampler for animation %d. Skipping.", fileName, j, i); - } - } else { - TraceLog(LOG_WARNING, "MODEL: [%s] Invalid interpolation curve encountered for GLTF animation.", fileName); - } - var t: f32 = 0.0; - _ = &t; - var r: cgltf_bool = cgltf_accessor_read_float(channel.sampler.*.input, channel.sampler.*.input.*.count -% @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1)))), &t, @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))); - _ = &r; - if (!(r != 0)) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load input time", fileName); - continue; - } - animDuration = if (t > animDuration) t else animDuration; - } - } - if (animData.name != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&animations[i].name))), animData.name, @sizeOf([32]u8)); - animations[i].name[@sizeOf([32]u8) -% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1))))] = '\x00'; - } - animations[i].frameCount = @as(c_int, @intFromFloat((animDuration * 1000.0) / @as(f32, @floatFromInt(@as(c_int, 17))))) + @as(c_int, 1); - animations[i].framePoses = @as([*c][*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, animations[i].frameCount))) *% @sizeOf([*c]Transform))))); - { - var j: c_int = 0; - _ = &j; - while (j < animations[i].frameCount) : (j += 1) { - (blk: { - const tmp = j; - if (tmp >= 0) break :blk animations[i].framePoses + @as(usize, @intCast(tmp)) else break :blk animations[i].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as([*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, animations[i].boneCount))) *% @sizeOf(Transform))))); - var time: f32 = (@as(f32, @floatFromInt(j)) * @as(f32, @floatFromInt(@as(c_int, 17)))) / 1000.0; - _ = &time; - { - var k: c_int = 0; - _ = &k; - while (k < animations[i].boneCount) : (k += 1) { - var translation: Vector3 = Vector3{ - .x = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.translation[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.translation[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.translation[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &translation; - var rotation: Quaternion = Quaternion{ - .x = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.rotation[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.rotation[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.rotation[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.rotation[@as(c_uint, @intCast(@as(c_int, 3)))], - }; - _ = &rotation; - var scale: Vector3 = Vector3{ - .x = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.scale[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.scale[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = (blk: { - const tmp = k; - if (tmp >= 0) break :blk skin.joints + @as(usize, @intCast(tmp)) else break :blk skin.joints - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.*.scale[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &scale; - if ((blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translate != null) { - if (!GetPoseAtTimeGLTF((blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.interpolationType, (blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translate.*.sampler.*.input, (blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translate.*.sampler.*.output, time, @as(?*anyopaque, @ptrCast(&translation)))) { - TraceLog(LOG_INFO, "MODEL: [%s] Failed to load translate pose data for bone %s", fileName, @as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = k; - if (tmp >= 0) break :blk animations[i].bones + @as(usize, @intCast(tmp)) else break :blk animations[i].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name)))); - } - } - if ((blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotate != null) { - if (!GetPoseAtTimeGLTF((blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.interpolationType, (blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotate.*.sampler.*.input, (blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotate.*.sampler.*.output, time, @as(?*anyopaque, @ptrCast(&rotation)))) { - TraceLog(LOG_INFO, "MODEL: [%s] Failed to load rotate pose data for bone %s", fileName, @as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = k; - if (tmp >= 0) break :blk animations[i].bones + @as(usize, @intCast(tmp)) else break :blk animations[i].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name)))); - } - } - if ((blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale != null) { - if (!GetPoseAtTimeGLTF((blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.interpolationType, (blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale.*.sampler.*.input, (blk: { - const tmp = k; - if (tmp >= 0) break :blk boneChannels + @as(usize, @intCast(tmp)) else break :blk boneChannels - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale.*.sampler.*.output, time, @as(?*anyopaque, @ptrCast(&scale)))) { - TraceLog(LOG_INFO, "MODEL: [%s] Failed to load scale pose data for bone %s", fileName, @as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = k; - if (tmp >= 0) break :blk animations[i].bones + @as(usize, @intCast(tmp)) else break :blk animations[i].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name)))); - } - } - (blk: { - const tmp = k; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 animations[i].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[i].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 animations[i].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[i].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = Transform{ - .translation = translation, - .rotation = rotation, - .scale = scale, - }; - } - } - BuildPoseFromParentJoints(animations[i].bones, animations[i].boneCount, (blk: { - const tmp = j; - if (tmp >= 0) break :blk animations[i].framePoses + @as(usize, @intCast(tmp)) else break :blk animations[i].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*); - } - } - TraceLog(LOG_INFO, "MODEL: [%s] Loaded animation: %s (%d frames, %fs)", fileName, if (animData.name != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) animData.name else "NULL", animations[i].frameCount, @as(f64, @floatCast(animDuration))); - free(@as(?*anyopaque, @ptrCast(boneChannels))); - } - } - } else { - TraceLog(LOG_ERROR, "MODEL: [%s] expected exactly one skin to load animation data from, but found %i", fileName, data.*.skins_count); - } - cgltf_free(data); - } - UnloadFileData(fileData); - return animations; -} -pub fn LoadVOX(arg_fileName: [*c]const u8) callconv(.C) Model { - var fileName = arg_fileName; - _ = &fileName; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - var nbvertices: c_int = 0; - _ = &nbvertices; - var meshescount: c_int = 0; - _ = &meshescount; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - if (fileData == null) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load VOX file", fileName); - return model; - } - var voxarray: VoxArray3D = VoxArray3D{ - .sizeX = @as(c_int, 0), - .sizeY = 0, - .sizeZ = 0, - .chunksSizeX = 0, - .chunksSizeY = 0, - .chunksSizeZ = 0, - .m_arrayChunks = null, - .arrayChunksSize = 0, - .ChunkFlattenOffset = 0, - .chunksAllocated = 0, - .chunksTotal = 0, - .vertices = @import("std").mem.zeroes(ArrayVector3), - .normals = @import("std").mem.zeroes(ArrayVector3), - .indices = @import("std").mem.zeroes(ArrayUShort), - .colors = @import("std").mem.zeroes(ArrayColor), - .palette = @import("std").mem.zeroes([256]VoxColor), - }; - _ = &voxarray; - var ret: c_int = Vox_LoadFromMemory(fileData, @as(c_uint, @bitCast(dataSize)), &voxarray); - _ = &ret; - if (ret != @as(c_int, 0)) { - UnloadFileData(fileData); - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load VOX data", fileName); - return model; - } else { - nbvertices = voxarray.vertices.used; - meshescount = @as(c_int, 1) + @divTrunc(nbvertices, @as(c_int, 65536)); - TraceLog(LOG_INFO, "MODEL: [%s] VOX data loaded successfully : %i vertices/%i meshes", fileName, nbvertices, meshescount); - } - model.transform = MatrixIdentity(); - model.meshCount = meshescount; - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(Mesh))))); - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(c_int))))); - model.materialCount = 1; - model.materials = @as([*c]Material, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.materialCount))), @sizeOf(Material))))); - model.materials[@as(c_uint, @intCast(@as(c_int, 0)))] = LoadMaterialDefault(); - var verticesRemain: c_int = voxarray.vertices.used; - _ = &verticesRemain; - var verticesMax: c_int = 65532; - _ = &verticesMax; - var pvertices: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(voxarray.vertices.array))); - _ = &pvertices; - var pnormals: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(voxarray.normals.array))); - _ = &pnormals; - var pcolors: [*c]Color = @as([*c]Color, @ptrCast(@alignCast(voxarray.colors.array))); - _ = &pcolors; - var pindices: [*c]c_ushort = voxarray.indices.array; - _ = &pindices; - var size: c_int = 0; - _ = &size; - { - var i: c_int = 0; - _ = &i; - while (i < meshescount) : (i += 1) { - var pmesh: [*c]Mesh = &(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - _ = &pmesh; - _ = memset(@as(?*anyopaque, @ptrCast(pmesh)), @as(c_int, 0), @sizeOf(Mesh)); - pmesh.*.vertexCount = @as(c_int, @intFromFloat(fmin(@as(f64, @floatFromInt(verticesMax)), @as(f64, @floatFromInt(verticesRemain))))); - size = @as(c_int, @bitCast(@as(c_uint, @truncate((@as(c_ulong, @bitCast(@as(c_long, pmesh.*.vertexCount))) *% @sizeOf(f32)) *% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 3)))))))); - pmesh.*.vertices = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, size))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(pmesh.*.vertices)), @as(?*const anyopaque, @ptrCast(pvertices)), @as(c_ulong, @bitCast(@as(c_long, size)))); - pmesh.*.normals = @as([*c]f32, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, size))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(pmesh.*.normals)), @as(?*const anyopaque, @ptrCast(pnormals)), @as(c_ulong, @bitCast(@as(c_long, size)))); - size = @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, voxarray.indices.used))) *% @sizeOf(c_ushort))))); - pmesh.*.indices = @as([*c]c_ushort, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, size))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(pmesh.*.indices)), @as(?*const anyopaque, @ptrCast(pindices)), @as(c_ulong, @bitCast(@as(c_long, size)))); - pmesh.*.triangleCount = @divTrunc(pmesh.*.vertexCount, @as(c_int, 4)) * @as(c_int, 2); - size = @as(c_int, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_long, pmesh.*.vertexCount))) *% @sizeOf(Color))))); - pmesh.*.colors = @as([*c]u8, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, size))))))); - _ = memcpy(@as(?*anyopaque, @ptrCast(pmesh.*.colors)), @as(?*const anyopaque, @ptrCast(pcolors)), @as(c_ulong, @bitCast(@as(c_long, size)))); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshMaterial + @as(usize, @intCast(tmp)) else break :blk model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 0; - verticesRemain -= verticesMax; - pvertices += @as(usize, @bitCast(@as(isize, @intCast(verticesMax)))); - pnormals += @as(usize, @bitCast(@as(isize, @intCast(verticesMax)))); - pcolors += @as(usize, @bitCast(@as(isize, @intCast(verticesMax)))); - } - } - Vox_FreeArrays(&voxarray); - UnloadFileData(fileData); - return model; -} -pub fn LoadM3D(arg_fileName: [*c]const u8) callconv(.C) Model { - var fileName = arg_fileName; - _ = &fileName; - var model: Model = Model{ - .transform = Matrix{ - .m0 = @as(f32, @floatFromInt(@as(c_int, 0))), - .m4 = 0, - .m8 = 0, - .m12 = 0, - .m1 = 0, - .m5 = 0, - .m9 = 0, - .m13 = 0, - .m2 = 0, - .m6 = 0, - .m10 = 0, - .m14 = 0, - .m3 = 0, - .m7 = 0, - .m11 = 0, - .m15 = 0, - }, - .meshCount = 0, - .materialCount = 0, - .meshes = null, - .materials = null, - .meshMaterial = null, - .boneCount = 0, - .bones = null, - .bindPose = null, - }; - _ = &model; - var m3d: [*c]m3d_t = null; - _ = &m3d; - var prop: [*c]m3dp_t = null; - _ = ∝ - var i: c_int = undefined; - _ = &i; - var j: c_int = undefined; - _ = &j; - var k: c_int = undefined; - _ = &k; - var l: c_int = undefined; - _ = &l; - var n: c_int = undefined; - _ = &n; - var mi: c_int = -@as(c_int, 2); - _ = &mi; - var vcolor: c_int = 0; - _ = &vcolor; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - if (fileData != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - m3d = m3d_load(fileData, &m3d_loaderhook, &m3d_freehook, null); - if (!(m3d != null) or ((@as(c_int, @bitCast(@as(c_int, m3d.*.errcode))) < @as(c_int, 0)) and (@as(c_int, @bitCast(@as(c_int, m3d.*.errcode))) > -@as(c_int, 65)))) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load M3D data, error code %d", fileName, if (m3d != null) @as(c_int, @bitCast(@as(c_int, m3d.*.errcode))) else -@as(c_int, 2)); - if (m3d != null) { - m3d_free(m3d); - } - UnloadFileData(fileData); - return model; - } else { - TraceLog(LOG_INFO, "MODEL: [%s] M3D data loaded successfully: %i faces/%i materials", fileName, m3d.*.numface, m3d.*.nummaterial); - } - if (!(m3d.*.numface != 0)) { - m3d_free(m3d); - UnloadFileData(fileData); - return model; - } - if (m3d.*.nummaterial > @as(M3D_INDEX, @bitCast(@as(c_int, 0)))) { - model.meshCount = blk: { - const tmp = @as(c_int, @bitCast(m3d.*.nummaterial)); - model.materialCount = tmp; - break :blk tmp; - }; - TraceLog(LOG_INFO, "MODEL: model has %i material meshes", model.materialCount); - } else { - model.meshCount = 1; - model.materialCount = 0; - TraceLog(LOG_INFO, "MODEL: No materials, putting all meshes in a default material"); - } - model.materialCount += 1; - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(Mesh))))); - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.meshCount))), @sizeOf(c_int))))); - model.materials = @as([*c]Material, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.materialCount + @as(c_int, 1)))), @sizeOf(Material))))); - model.materials[@as(c_uint, @intCast(@as(c_int, 0)))] = LoadMaterialDefault(); - { - _ = blk: { - i = blk_1: { - const tmp = @as(c_int, 0); - l = tmp; - break :blk_1 tmp; - }; - break :blk blk_1: { - const tmp = -@as(c_int, 1); - k = tmp; - break :blk_1 tmp; - }; - }; - while (i < @as(c_int, @bitCast(m3d.*.numface))) : (_ = blk: { - i += 1; - break :blk blk_1: { - const ref = &l; - const tmp = ref.*; - ref.* += 1; - break :blk_1 tmp; - }; - }) { - if (@as(M3D_INDEX, @bitCast(mi)) != (blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.materialid) { - if ((k + @as(c_int, 1)) >= model.meshCount) { - model.meshCount += 1; - model.meshes = @as([*c]Mesh, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(model.meshes)), @as(c_ulong, @bitCast(@as(c_long, model.meshCount))) *% @sizeOf(Mesh))))); - _ = memset(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = model.meshCount - @as(c_int, 1); - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(c_int, 0), @sizeOf(Mesh)); - model.meshMaterial = @as([*c]c_int, @ptrCast(@alignCast(realloc(@as(?*anyopaque, @ptrCast(model.meshMaterial)), @as(c_ulong, @bitCast(@as(c_long, model.meshCount))) *% @sizeOf(c_int))))); - } - k += 1; - mi = @as(c_int, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.materialid)); - { - _ = blk: { - j = i; - break :blk blk_1: { - const tmp = blk_2: { - const tmp_3 = @as(c_int, 0); - vcolor = tmp_3; - break :blk_2 tmp_3; - }; - l = tmp; - break :blk_1 tmp; - }; - }; - while ((j < @as(c_int, @bitCast(m3d.*.numface))) and (@as(M3D_INDEX, @bitCast(mi)) == (blk: { - const tmp = j; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.materialid)) : (_ = blk: { - j += 1; - break :blk blk_1: { - const ref = &l; - const tmp = ref.*; - ref.* += 1; - break :blk_1 tmp; - }; - }) { - if ((!(m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 0)))]].color != 0) or !(m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 1)))]].color != 0)) or !(m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 2)))]].color != 0)) - { - vcolor = 1; - } - } - } - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount = l * @as(c_int, 3); - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.triangleCount = l; - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoords = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 2)))), @sizeOf(f32))))); - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - if ((@as(c_uint, @bitCast(mi)) == @as(c_uint, 4294967295)) or (vcolor != 0)) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(u8))))); - } - if ((@as(c_uint, @bitCast(mi)) == @as(c_uint, 4294967295)) and ((blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))))))) { - { - var c: c_int = 0; - _ = &c; - while (c < ((blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4))) : (c += 1) { - (blk: { - const tmp = c; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 255; - } - } - } - if ((m3d.*.numbone != 0) and (m3d.*.numskin != 0)) { - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneIds = @as([*c]u8, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(u8))))); - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneWeights = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 4)))), @sizeOf(f32))))); - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animVertices = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animNormals = @as([*c]f32, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))), @sizeOf(f32))))); - } - (blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshMaterial + @as(usize, @intCast(tmp)) else break :blk model.meshMaterial - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = mi + @as(c_int, 1); - l = 0; - } - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 0); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 0)))]].x * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 1); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 0)))]].y * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 2); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 0)))]].z * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 3); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 1)))]].x * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 4); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 1)))]].y * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 5); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 1)))]].z * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 6); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 2)))]].x * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 7); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 2)))]].y * m3d.*.scale; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 8); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.vertices - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 2)))]].z * m3d.*.scale; - if ((blk: { - const tmp = k; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.colors != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - if ((m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 0)))]].color & @as(c_uint, 4278190080)) != 0) - { - _ = memcpy(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = (l * @as(c_int, 12)) + @as(c_int, 0); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(?*const anyopaque, @ptrCast(&m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 0)))]].color)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - } - if ((m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 1)))]].color & @as(c_uint, 4278190080)) != 0) - { - _ = memcpy(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = (l * @as(c_int, 12)) + @as(c_int, 4); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(?*const anyopaque, @ptrCast(&m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 1)))]].color)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - } - if ((m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 2)))]].color & @as(c_uint, 4278190080)) != 0) - { - _ = memcpy(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = (l * @as(c_int, 12)) + @as(c_int, 8); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.colors - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*)), @as(?*const anyopaque, @ptrCast(&m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(@as(c_int, 2)))]].color)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - } - } - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 0)))] != @as(c_uint, 4294967295)) { - (blk: { - const tmp = (l * @as(c_int, 6)) + @as(c_int, 0); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.tmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 0)))]].u; - (blk: { - const tmp = (l * @as(c_int, 6)) + @as(c_int, 1); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 1.0 - m3d.*.tmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 0)))]].v; - (blk: { - const tmp = (l * @as(c_int, 6)) + @as(c_int, 2); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.tmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 1)))]].u; - (blk: { - const tmp = (l * @as(c_int, 6)) + @as(c_int, 3); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 1.0 - m3d.*.tmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 1)))]].v; - (blk: { - const tmp = (l * @as(c_int, 6)) + @as(c_int, 4); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.tmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 2)))]].u; - (blk: { - const tmp = (l * @as(c_int, 6)) + @as(c_int, 5); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.texcoords - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 1.0 - m3d.*.tmap[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texcoord[@as(c_uint, @intCast(@as(c_int, 2)))]].v; - } - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 0)))] != @as(c_uint, 4294967295)) { - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 0); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 0)))]].x; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 1); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 0)))]].y; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 2); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 0)))]].z; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 3); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 1)))]].x; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 4); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 1)))]].y; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 5); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 1)))]].z; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 6); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 2)))]].x; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 7); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 2)))]].y; - (blk: { - const tmp = (l * @as(c_int, 9)) + @as(c_int, 8); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.normals - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normal[@as(c_uint, @intCast(@as(c_int, 2)))]].z; - } - if ((m3d.*.numbone != 0) and (m3d.*.numskin != 0)) { - { - n = 0; - while (n < @as(c_int, 3)) : (n += 1) { - var skinid: c_int = @as(c_int, @bitCast(m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.face + @as(usize, @intCast(tmp)) else break :blk m3d.*.face - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertex[@as(c_uint, @intCast(n))]].skinid)); - _ = &skinid; - if ((@as(c_uint, @bitCast(skinid)) != @as(c_uint, 4294967295)) and (skinid < @as(c_int, @bitCast(m3d.*.numskin)))) { - { - j = 0; - while (j < @as(c_int, 4)) : (j += 1) { - (blk: { - const tmp = ((l * @as(c_int, 12)) + (n * @as(c_int, 4))) + j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneIds + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneIds - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(u8, @truncate((blk: { - const tmp = skinid; - if (tmp >= 0) break :blk m3d.*.skin + @as(usize, @intCast(tmp)) else break :blk m3d.*.skin - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.boneid[@as(c_uint, @intCast(j))])))); - (blk: { - const tmp = ((l * @as(c_int, 12)) + (n * @as(c_int, 4))) + j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneWeights + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneWeights - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = (blk: { - const tmp = skinid; - if (tmp >= 0) break :blk m3d.*.skin + @as(usize, @intCast(tmp)) else break :blk m3d.*.skin - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.weight[@as(c_uint, @intCast(j))]; - } - } - } else { - (blk: { - const tmp = (l * @as(c_int, 12)) + (n * @as(c_int, 4)); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneIds + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneIds - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as(u8, @bitCast(@as(u8, @truncate(m3d.*.numbone)))); - (blk: { - const tmp = (l * @as(c_int, 12)) + (n * @as(c_int, 4)); - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneWeights + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = k; - if (tmp_2 >= 0) break :blk_1 model.meshes + @as(usize, @intCast(tmp_2)) else break :blk_1 model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.boneWeights - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = 1.0; - } - } - } - } - } - } - { - i = 0; - while (i < @as(c_int, @bitCast(m3d.*.nummaterial))) : (i += 1) { - (blk: { - const tmp = i + @as(c_int, 1); - if (tmp >= 0) break :blk model.materials + @as(usize, @intCast(tmp)) else break :blk model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = LoadMaterialDefault(); - { - j = 0; - while (j < @as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.material + @as(usize, @intCast(tmp)) else break :blk m3d.*.material - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.numprop)))) : (j += 1) { - prop = &(blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 m3d.*.material + @as(usize, @intCast(tmp_2)) else break :blk_1 m3d.*.material - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.prop + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 m3d.*.material + @as(usize, @intCast(tmp_2)) else break :blk_1 m3d.*.material - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.prop - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - while (true) { - switch (@as(c_int, @bitCast(@as(c_uint, prop.*.type)))) { - @as(c_int, 0) => { - { - _ = memcpy(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color)), @as(?*const anyopaque, @ptrCast(&prop.*.value.color)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = 0.0; - } - break; - }, - @as(c_int, 2) => { - { - _ = memcpy(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color)), @as(?*const anyopaque, @ptrCast(&prop.*.value.color)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - } - break; - }, - @as(c_int, 3) => { - { - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = prop.*.value.fnum; - } - break; - }, - @as(c_int, 4) => { - { - _ = memcpy(@as(?*anyopaque, @ptrCast(&(blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color)), @as(?*const anyopaque, @ptrCast(&prop.*.value.color)), @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 4))))); - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = 0.0; - } - break; - }, - @as(c_int, 65) => { - { - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = prop.*.value.fnum; - } - break; - }, - @as(c_int, 64) => { - { - (blk: { - const tmp = MATERIAL_MAP_ROUGHNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = prop.*.value.fnum; - } - break; - }, - @as(c_int, 66) => { - { - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = prop.*.value.fnum; - } - break; - }, - else => { - { - if (@as(c_int, @bitCast(@as(c_uint, prop.*.type))) >= @as(c_int, 128)) { - var image: Image = Image{ - .data = null, - .width = 0, - .height = 0, - .mipmaps = 0, - .format = 0, - }; - _ = ℑ - image.data = @as(?*anyopaque, @ptrCast(m3d.*.texture[prop.*.value.textureid].d)); - image.width = @as(c_int, @bitCast(@as(c_uint, m3d.*.texture[prop.*.value.textureid].w))); - image.height = @as(c_int, @bitCast(@as(c_uint, m3d.*.texture[prop.*.value.textureid].h))); - image.mipmaps = 1; - image.format = if (@as(c_int, @bitCast(@as(c_uint, m3d.*.texture[prop.*.value.textureid].f))) == @as(c_int, 4)) PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 else if (@as(c_int, @bitCast(@as(c_uint, m3d.*.texture[prop.*.value.textureid].f))) == @as(c_int, 3)) PIXELFORMAT_UNCOMPRESSED_R8G8B8 else if (@as(c_int, @bitCast(@as(c_uint, m3d.*.texture[prop.*.value.textureid].f))) == @as(c_int, 2)) PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA else PIXELFORMAT_UNCOMPRESSED_GRAYSCALE; - while (true) { - switch (@as(c_int, @bitCast(@as(c_uint, prop.*.type)))) { - @as(c_int, 128) => { - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(image); - break; - }, - @as(c_int, 130) => { - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(image); - break; - }, - @as(c_int, 132) => { - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(image); - break; - }, - @as(c_int, 134) => { - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(image); - break; - }, - @as(c_int, 129) => { - (blk: { - const tmp = MATERIAL_MAP_OCCLUSION; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(image); - break; - }, - @as(c_int, 193) => { - (blk: { - const tmp = MATERIAL_MAP_ROUGHNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i + @as(c_int, 1); - if (tmp_2 >= 0) break :blk_1 model.materials + @as(usize, @intCast(tmp_2)) else break :blk_1 model.materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTextureFromImage(image); - break; - }, - else => break, - } - break; - } - } - } - break; - }, - } - break; - } - } - } - } - } - if (m3d.*.numbone != 0) { - model.boneCount = @as(c_int, @bitCast(m3d.*.numbone +% @as(M3D_INDEX, @bitCast(@as(c_int, 1))))); - model.bones = @as([*c]BoneInfo, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.boneCount))), @sizeOf(BoneInfo))))); - model.bindPose = @as([*c]Transform, @ptrCast(@alignCast(calloc(@as(c_ulong, @bitCast(@as(c_long, model.boneCount))), @sizeOf(Transform))))); - { - i = 0; - while (i < @as(c_int, @bitCast(m3d.*.numbone))) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bones + @as(usize, @intCast(tmp)) else break :blk model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent = @as(c_int, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent)); - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bones + @as(usize, @intCast(tmp)) else break :blk model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name))), (blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name, @sizeOf([32]u8)); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.x = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.pos].x * m3d.*.scale; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.y = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.pos].y * m3d.*.scale; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.z = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.pos].z * m3d.*.scale; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.x = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].x; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.y = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].y; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.z = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].z; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.w = m3d.*.vertex[(blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].w; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation = QuaternionNormalize((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale.x = blk: { - const tmp = blk_1: { - const tmp_2 = 1.0; - (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.bindPose + @as(usize, @intCast(tmp_3)) else break :blk_2 model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*.scale.z = tmp_2; - break :blk_1 tmp_2; - }; - (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.bindPose + @as(usize, @intCast(tmp_2)) else break :blk_1 model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.scale.y = tmp; - break :blk tmp; - }; - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bones + @as(usize, @intCast(tmp)) else break :blk model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent >= @as(c_int, 0)) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation = QuaternionMultiply((blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.bones + @as(usize, @intCast(tmp_2)) else break :blk_1 model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3RotateByQuaternion((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.bones + @as(usize, @intCast(tmp_2)) else break :blk_1 model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3Add((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.bones + @as(usize, @intCast(tmp_2)) else break :blk_1 model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale = Vector3Multiply((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.bones + @as(usize, @intCast(tmp_2)) else break :blk_1 model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale); - } - } - } - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bones + @as(usize, @intCast(tmp)) else break :blk model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent = -@as(c_int, 1); - _ = strcpy(@as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bones + @as(usize, @intCast(tmp)) else break :blk model.bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name))), "NO BONE"); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.x = 0.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.y = 0.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.z = 0.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.x = 0.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.y = 0.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.z = 0.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.w = 1.0; - (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.bindPose + @as(usize, @intCast(tmp)) else break :blk model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale.x = blk: { - const tmp = blk_1: { - const tmp_2 = 1.0; - (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 model.bindPose + @as(usize, @intCast(tmp_3)) else break :blk_2 model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*.scale.z = tmp_2; - break :blk_1 tmp_2; - }; - (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 model.bindPose + @as(usize, @intCast(tmp_2)) else break :blk_1 model.bindPose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.scale.y = tmp; - break :blk tmp; - }; - } - if ((m3d.*.numbone != 0) and (m3d.*.numskin != 0)) { - { - i = 0; - while (i < model.meshCount) : (i += 1) { - _ = memcpy(@as(?*anyopaque, @ptrCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animVertices)), @as(?*const anyopaque, @ptrCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertices)), @as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32)); - _ = memcpy(@as(?*anyopaque, @ptrCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.animNormals)), @as(?*const anyopaque, @ptrCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.normals)), @as(c_ulong, @bitCast(@as(c_long, (blk: { - const tmp = i; - if (tmp >= 0) break :blk model.meshes + @as(usize, @intCast(tmp)) else break :blk model.meshes - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.vertexCount * @as(c_int, 3)))) *% @sizeOf(f32)); - } - } - } - m3d_free(m3d); - UnloadFileData(fileData); - } - return model; -} -pub fn LoadModelAnimationsM3D(arg_fileName: [*c]const u8, arg_animCount: [*c]c_int) callconv(.C) [*c]ModelAnimation { - var fileName = arg_fileName; - _ = &fileName; - var animCount = arg_animCount; - _ = &animCount; - var animations: [*c]ModelAnimation = null; - _ = &animations; - var m3d: [*c]m3d_t = null; - _ = &m3d; - var i: c_int = 0; - _ = &i; - var j: c_int = 0; - _ = &j; - animCount.* = 0; - var dataSize: c_int = 0; - _ = &dataSize; - var fileData: [*c]u8 = LoadFileData(fileName, &dataSize); - _ = &fileData; - if (fileData != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - m3d = m3d_load(fileData, &m3d_loaderhook, &m3d_freehook, null); - if (!(m3d != null) or ((@as(c_int, @bitCast(@as(c_int, m3d.*.errcode))) < @as(c_int, 0)) and (@as(c_int, @bitCast(@as(c_int, m3d.*.errcode))) > -@as(c_int, 65)))) { - TraceLog(LOG_WARNING, "MODEL: [%s] Failed to load M3D data, error code %d", fileName, if (m3d != null) @as(c_int, @bitCast(@as(c_int, m3d.*.errcode))) else -@as(c_int, 2)); - UnloadFileData(fileData); - return null; - } else { - TraceLog(LOG_INFO, "MODEL: [%s] M3D data loaded successfully: %i animations, %i bones, %i skins", fileName, m3d.*.numaction, m3d.*.numbone, m3d.*.numskin); - } - if ((!(m3d.*.numaction != 0) or !(m3d.*.numbone != 0)) or !(m3d.*.numskin != 0)) { - m3d_free(m3d); - UnloadFileData(fileData); - return null; - } - animations = @as([*c]ModelAnimation, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, m3d.*.numaction))) *% @sizeOf(ModelAnimation))))); - animCount.* = @as(c_int, @bitCast(m3d.*.numaction)); - { - var a: c_uint = 0; - _ = &a; - while (a < m3d.*.numaction) : (a +%= 1) { - animations[a].frameCount = @as(c_int, @bitCast(m3d.*.action[a].durationmsec / @as(u32, @bitCast(@as(c_int, 17))))); - animations[a].boneCount = @as(c_int, @bitCast(m3d.*.numbone +% @as(M3D_INDEX, @bitCast(@as(c_int, 1))))); - animations[a].bones = @as([*c]BoneInfo, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, m3d.*.numbone +% @as(M3D_INDEX, @bitCast(@as(c_int, 1)))))) *% @sizeOf(BoneInfo))))); - animations[a].framePoses = @as([*c][*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_long, animations[a].frameCount))) *% @sizeOf([*c]Transform))))); - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&animations[a].name))), m3d.*.action[a].name, @sizeOf([32]u8)); - animations[a].name[@sizeOf([32]u8) -% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1))))] = '\x00'; - TraceLog(LOG_INFO, "MODEL: [%s] animation #%i: %i msec, %i frames", fileName, a, m3d.*.action[a].durationmsec, animations[a].frameCount); - { - i = 0; - while (i < @as(c_int, @bitCast(m3d.*.numbone))) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].bones + @as(usize, @intCast(tmp)) else break :blk animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent = @as(c_int, @bitCast((blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent)); - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].bones + @as(usize, @intCast(tmp)) else break :blk animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name))), (blk: { - const tmp = i; - if (tmp >= 0) break :blk m3d.*.bone + @as(usize, @intCast(tmp)) else break :blk m3d.*.bone - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name, @sizeOf([32]u8)); - } - } - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].bones + @as(usize, @intCast(tmp)) else break :blk animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent = -@as(c_int, 1); - _ = strcpy(@as([*c]u8, @ptrCast(@alignCast(&(blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].bones + @as(usize, @intCast(tmp)) else break :blk animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.name))), "NO BONE"); - { - i = 0; - while (i < animations[a].frameCount) : (i += 1) { - (blk: { - const tmp = i; - if (tmp >= 0) break :blk animations[a].framePoses + @as(usize, @intCast(tmp)) else break :blk animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = @as([*c]Transform, @ptrCast(@alignCast(malloc(@as(c_ulong, @bitCast(@as(c_ulong, m3d.*.numbone +% @as(M3D_INDEX, @bitCast(@as(c_int, 1)))))) *% @sizeOf(Transform))))); - var pose: [*c]m3db_t = m3d_pose(m3d, a, @as(u32, @bitCast(i * @as(c_int, 17)))); - _ = &pose; - if (pose != @as([*c]m3db_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - { - j = 0; - while (j < @as(c_int, @bitCast(m3d.*.numbone))) : (j += 1) { - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.x = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.pos].x * m3d.*.scale; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.y = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.pos].y * m3d.*.scale; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.z = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.pos].z * m3d.*.scale; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.x = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].x; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.y = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].y; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.z = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].z; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.w = m3d.*.vertex[(blk: { - const tmp = j; - if (tmp >= 0) break :blk pose + @as(usize, @intCast(tmp)) else break :blk pose - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.ori].w; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation = QuaternionNormalize((blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale.x = blk: { - const tmp = blk_1: { - const tmp_2 = 1.0; - (blk_2: { - const tmp_3 = j; - if (tmp_3 >= 0) break :blk_2 (blk_3: { - const tmp_4 = i; - if (tmp_4 >= 0) break :blk_3 animations[a].framePoses + @as(usize, @intCast(tmp_4)) else break :blk_3 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_4)) +% -1)); - }).* + @as(usize, @intCast(tmp_3)) else break :blk_2 (blk_3: { - const tmp_4 = i; - if (tmp_4 >= 0) break :blk_3 animations[a].framePoses + @as(usize, @intCast(tmp_4)) else break :blk_3 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_4)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*.scale.z = tmp_2; - break :blk_1 tmp_2; - }; - (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 animations[a].framePoses + @as(usize, @intCast(tmp_3)) else break :blk_2 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).* + @as(usize, @intCast(tmp_2)) else break :blk_1 (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 animations[a].framePoses + @as(usize, @intCast(tmp_3)) else break :blk_2 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.scale.y = tmp; - break :blk tmp; - }; - if ((blk: { - const tmp = j; - if (tmp >= 0) break :blk animations[a].bones + @as(usize, @intCast(tmp)) else break :blk animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent >= @as(c_int, 0)) { - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation = QuaternionMultiply((blk: { - const tmp = (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation, (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3RotateByQuaternion((blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3Add((blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation); - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale = Vector3Multiply((blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale, (blk: { - const tmp = (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 animations[a].bones + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale); - } - } - } - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.x = 0.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.y = 0.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation.z = 0.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.x = 0.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.y = 0.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.z = 0.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation.w = 1.0; - (blk: { - const tmp = j; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 animations[a].framePoses + @as(usize, @intCast(tmp_2)) else break :blk_1 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale.x = blk: { - const tmp = blk_1: { - const tmp_2 = 1.0; - (blk_2: { - const tmp_3 = j; - if (tmp_3 >= 0) break :blk_2 (blk_3: { - const tmp_4 = i; - if (tmp_4 >= 0) break :blk_3 animations[a].framePoses + @as(usize, @intCast(tmp_4)) else break :blk_3 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_4)) +% -1)); - }).* + @as(usize, @intCast(tmp_3)) else break :blk_2 (blk_3: { - const tmp_4 = i; - if (tmp_4 >= 0) break :blk_3 animations[a].framePoses + @as(usize, @intCast(tmp_4)) else break :blk_3 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_4)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).*.scale.z = tmp_2; - break :blk_1 tmp_2; - }; - (blk_1: { - const tmp_2 = j; - if (tmp_2 >= 0) break :blk_1 (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 animations[a].framePoses + @as(usize, @intCast(tmp_3)) else break :blk_2 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).* + @as(usize, @intCast(tmp_2)) else break :blk_1 (blk_2: { - const tmp_3 = i; - if (tmp_3 >= 0) break :blk_2 animations[a].framePoses + @as(usize, @intCast(tmp_3)) else break :blk_2 animations[a].framePoses - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_3)) +% -1)); - }).* - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.scale.y = tmp; - break :blk tmp; - }; - free(@as(?*anyopaque, @ptrCast(pose))); - } - } - } - } - } - m3d_free(m3d); - UnloadFileData(fileData); - } - return animations; -} -pub fn ProcessMaterialsOBJ(arg_materials: [*c]Material, arg_mats: [*c]tinyobj_material_t, arg_materialCount: c_int) callconv(.C) void { - var materials = arg_materials; - _ = &materials; - var mats = arg_mats; - _ = &mats; - var materialCount = arg_materialCount; - _ = &materialCount; - { - var m: c_int = 0; - _ = &m; - while (m < materialCount) : (m += 1) { - (blk: { - const tmp = m; - if (tmp >= 0) break :blk materials + @as(usize, @intCast(tmp)) else break :blk materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).* = LoadMaterialDefault(); - if (mats == @as([*c]tinyobj_material_t, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) continue; - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = Texture2D{ - .id = rlGetTextureIdDefault(), - .width = @as(c_int, 1), - .height = @as(c_int, 1), - .mipmaps = @as(c_int, 1), - .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, - }; - if ((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.diffuse_texname != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTexture((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.diffuse_texname); - } else { - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.diffuse[@as(c_uint, @intCast(@as(c_int, 0)))] * 255.0)), - .g = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.diffuse[@as(c_uint, @intCast(@as(c_int, 1)))] * 255.0)), - .b = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.diffuse[@as(c_uint, @intCast(@as(c_int, 2)))] * 255.0)), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - } - (blk: { - const tmp = MATERIAL_MAP_ALBEDO; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = 0.0; - if ((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.specular_texname != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTexture((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.specular_texname); - } - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.specular[@as(c_uint, @intCast(@as(c_int, 0)))] * 255.0)), - .g = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.specular[@as(c_uint, @intCast(@as(c_int, 1)))] * 255.0)), - .b = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.specular[@as(c_uint, @intCast(@as(c_int, 2)))] * 255.0)), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - (blk: { - const tmp = MATERIAL_MAP_METALNESS; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = 0.0; - if ((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.bump_texname != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTexture((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.bump_texname); - } - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .g = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .b = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - (blk: { - const tmp = MATERIAL_MAP_NORMAL; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.value = (blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.shininess; - (blk: { - const tmp = MATERIAL_MAP_EMISSION; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.color = Color{ - .r = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.emission[@as(c_uint, @intCast(@as(c_int, 0)))] * 255.0)), - .g = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.emission[@as(c_uint, @intCast(@as(c_int, 1)))] * 255.0)), - .b = @as(u8, @intFromFloat((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.emission[@as(c_uint, @intCast(@as(c_int, 2)))] * 255.0)), - .a = @as(u8, @bitCast(@as(i8, @truncate(@as(c_int, 255))))), - }; - if ((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.displacement_texname != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - (blk: { - const tmp = MATERIAL_MAP_HEIGHT; - if (tmp >= 0) break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps + @as(usize, @intCast(tmp)) else break :blk (blk_1: { - const tmp_2 = m; - if (tmp_2 >= 0) break :blk_1 materials + @as(usize, @intCast(tmp_2)) else break :blk_1 materials - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.maps - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.texture = LoadTexture((blk: { - const tmp = m; - if (tmp >= 0) break :blk mats + @as(usize, @intCast(tmp)) else break :blk mats - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.displacement_texname); - } - } - } -} -pub fn BuildPoseFromParentJoints(arg_bones: [*c]BoneInfo, arg_boneCount: c_int, arg_transforms: [*c]Transform) callconv(.C) void { - var bones = arg_bones; - _ = &bones; - var boneCount = arg_boneCount; - _ = &boneCount; - var transforms = arg_transforms; - _ = &transforms; - { - var i: c_int = 0; - _ = &i; - while (i < boneCount) : (i += 1) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk bones + @as(usize, @intCast(tmp)) else break :blk bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent >= @as(c_int, 0)) { - if ((blk: { - const tmp = i; - if (tmp >= 0) break :blk bones + @as(usize, @intCast(tmp)) else break :blk bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent > i) { - TraceLog(LOG_WARNING, "Assumes bones are toplogically sorted, but bone %d has parent %d. Skipping.", i, (blk: { - const tmp = i; - if (tmp >= 0) break :blk bones + @as(usize, @intCast(tmp)) else break :blk bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.parent); - continue; - } - (blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation = QuaternionMultiply((blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 bones + @as(usize, @intCast(tmp_2)) else break :blk_1 bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation, (blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3RotateByQuaternion((blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 bones + @as(usize, @intCast(tmp_2)) else break :blk_1 bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.rotation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation = Vector3Add((blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 bones + @as(usize, @intCast(tmp_2)) else break :blk_1 bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.translation); - (blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale = Vector3Multiply((blk: { - const tmp = i; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale, (blk: { - const tmp = (blk_1: { - const tmp_2 = i; - if (tmp_2 >= 0) break :blk_1 bones + @as(usize, @intCast(tmp_2)) else break :blk_1 bones - ~@as(usize, @bitCast(@as(isize, @intCast(tmp_2)) +% -1)); - }).*.parent; - if (tmp >= 0) break :blk transforms + @as(usize, @intCast(tmp)) else break :blk transforms - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*.scale); - } - } - } -} -pub fn LoadFileGLTFCallback(arg_memoryOptions: [*c]const struct_cgltf_memory_options, arg_fileOptions: [*c]const struct_cgltf_file_options, arg_path: [*c]const u8, arg_size: [*c]cgltf_size, arg_data: [*c]?*anyopaque) callconv(.C) cgltf_result { - var memoryOptions = arg_memoryOptions; - _ = &memoryOptions; - var fileOptions = arg_fileOptions; - _ = &fileOptions; - var path = arg_path; - _ = &path; - var size = arg_size; - _ = &size; - var data = arg_data; - _ = &data; - var filesize: c_int = undefined; - _ = &filesize; - var filedata: [*c]u8 = LoadFileData(path, &filesize); - _ = &filedata; - if (filedata == @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) return @as(c_uint, @bitCast(cgltf_result_io_error)); - size.* = @as(cgltf_size, @bitCast(@as(c_long, filesize))); - data.* = @as(?*anyopaque, @ptrCast(filedata)); - return @as(c_uint, @bitCast(cgltf_result_success)); -} -pub fn ReleaseFileGLTFCallback(arg_memoryOptions: [*c]const struct_cgltf_memory_options, arg_fileOptions: [*c]const struct_cgltf_file_options, arg_data: ?*anyopaque) callconv(.C) void { - var memoryOptions = arg_memoryOptions; - _ = &memoryOptions; - var fileOptions = arg_fileOptions; - _ = &fileOptions; - var data = arg_data; - _ = &data; - UnloadFileData(@as([*c]u8, @ptrCast(@alignCast(data)))); -} -pub fn LoadImageFromCgltfImage(arg_cgltfImage: [*c]cgltf_image, arg_texPath: [*c]const u8) callconv(.C) Image { - var cgltfImage = arg_cgltfImage; - _ = &cgltfImage; - var texPath = arg_texPath; - _ = &texPath; - var image: Image = Image{ - .data = null, - .width = 0, - .height = 0, - .mipmaps = 0, - .format = 0, - }; - _ = ℑ - if (cgltfImage.*.uri != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - if ((((((strlen(cgltfImage.*.uri) > @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 5))))) and (@as(c_int, @bitCast(@as(c_uint, cgltfImage.*.uri[@as(c_uint, @intCast(@as(c_int, 0)))]))) == @as(c_int, 'd'))) and (@as(c_int, @bitCast(@as(c_uint, cgltfImage.*.uri[@as(c_uint, @intCast(@as(c_int, 1)))]))) == @as(c_int, 'a'))) and (@as(c_int, @bitCast(@as(c_uint, cgltfImage.*.uri[@as(c_uint, @intCast(@as(c_int, 2)))]))) == @as(c_int, 't'))) and (@as(c_int, @bitCast(@as(c_uint, cgltfImage.*.uri[@as(c_uint, @intCast(@as(c_int, 3)))]))) == @as(c_int, 'a'))) and (@as(c_int, @bitCast(@as(c_uint, cgltfImage.*.uri[@as(c_uint, @intCast(@as(c_int, 4)))]))) == @as(c_int, ':'))) { - var i: c_int = 0; - _ = &i; - while ((@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk cgltfImage.*.uri + @as(usize, @intCast(tmp)) else break :blk cgltfImage.*.uri - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) != @as(c_int, ',')) and (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk cgltfImage.*.uri + @as(usize, @intCast(tmp)) else break :blk cgltfImage.*.uri - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) != @as(c_int, 0))) { - i += 1; - } - if (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i; - if (tmp >= 0) break :blk cgltfImage.*.uri + @as(usize, @intCast(tmp)) else break :blk cgltfImage.*.uri - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) == @as(c_int, 0)) { - TraceLog(LOG_WARNING, "IMAGE: glTF data URI is not a valid image"); - } else { - var base64Size: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate(strlen((cgltfImage.*.uri + @as(usize, @bitCast(@as(isize, @intCast(i))))) + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1)))))))))); - _ = &base64Size; - while (@as(c_int, @bitCast(@as(c_uint, (blk: { - const tmp = i + base64Size; - if (tmp >= 0) break :blk cgltfImage.*.uri + @as(usize, @intCast(tmp)) else break :blk cgltfImage.*.uri - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*))) == @as(c_int, '=')) { - base64Size -= 1; - } - var numberOfEncodedBits: c_int = (base64Size * @as(c_int, 6)) - @import("std").zig.c_translation.signedRemainder(base64Size * @as(c_int, 6), @as(c_int, 8)); - _ = &numberOfEncodedBits; - var outSize: c_int = @divTrunc(numberOfEncodedBits, @as(c_int, 8)); - _ = &outSize; - var data: ?*anyopaque = @as(?*anyopaque, @ptrFromInt(@as(c_int, 0))); - _ = &data; - var options: cgltf_options = cgltf_options{ - .type = @as(c_uint, @bitCast(@as(c_int, 0))), - .json_token_count = @import("std").mem.zeroes(cgltf_size), - .memory = @import("std").mem.zeroes(cgltf_memory_options), - .file = @import("std").mem.zeroes(cgltf_file_options), - }; - _ = &options; - options.file.read = &LoadFileGLTFCallback; - options.file.release = &ReleaseFileGLTFCallback; - var result: cgltf_result = cgltf_load_buffer_base64(&options, @as(cgltf_size, @bitCast(@as(c_long, outSize))), (cgltfImage.*.uri + @as(usize, @bitCast(@as(isize, @intCast(i))))) + @as(usize, @bitCast(@as(isize, @intCast(@as(c_int, 1))))), &data); - _ = &result; - if (result == @as(c_uint, @bitCast(cgltf_result_success))) { - image = LoadImageFromMemory(".png", @as([*c]u8, @ptrCast(@alignCast(data))), outSize); - free(data); - } - } - } else { - image = LoadImage(TextFormat("%s/%s", texPath, cgltfImage.*.uri)); - } - } else if (cgltfImage.*.buffer_view.*.buffer.*.data != @as(?*anyopaque, @ptrFromInt(@as(c_int, 0)))) { - var data: [*c]u8 = @as([*c]u8, @ptrCast(@alignCast(malloc(cgltfImage.*.buffer_view.*.size)))); - _ = &data; - var offset: c_int = @as(c_int, @bitCast(@as(c_uint, @truncate(cgltfImage.*.buffer_view.*.offset)))); - _ = &offset; - var stride: c_int = if (@as(c_int, @bitCast(@as(c_uint, @truncate(cgltfImage.*.buffer_view.*.stride)))) != 0) @as(c_int, @bitCast(@as(c_uint, @truncate(cgltfImage.*.buffer_view.*.stride)))) else @as(c_int, 1); - _ = &stride; - { - var i: c_uint = 0; - _ = &i; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < cgltfImage.*.buffer_view.*.size) : (i +%= 1) { - data[i] = (blk: { - const tmp = offset; - if (tmp >= 0) break :blk @as([*c]u8, @ptrCast(@alignCast(cgltfImage.*.buffer_view.*.buffer.*.data))) + @as(usize, @intCast(tmp)) else break :blk @as([*c]u8, @ptrCast(@alignCast(cgltfImage.*.buffer_view.*.buffer.*.data))) - ~@as(usize, @bitCast(@as(isize, @intCast(tmp)) +% -1)); - }).*; - offset += stride; - } - } - if ((strcmp(cgltfImage.*.mime_type, "image\\/png") == @as(c_int, 0)) or (strcmp(cgltfImage.*.mime_type, "image/png") == @as(c_int, 0))) { - image = LoadImageFromMemory(".png", data, @as(c_int, @bitCast(@as(c_uint, @truncate(cgltfImage.*.buffer_view.*.size))))); - } else if ((strcmp(cgltfImage.*.mime_type, "image\\/jpeg") == @as(c_int, 0)) or (strcmp(cgltfImage.*.mime_type, "image/jpeg") == @as(c_int, 0))) { - image = LoadImageFromMemory(".jpg", data, @as(c_int, @bitCast(@as(c_uint, @truncate(cgltfImage.*.buffer_view.*.size))))); - } else { - TraceLog(LOG_WARNING, "MODEL: glTF image data MIME type not recognized", TextFormat("%s/%s", texPath, cgltfImage.*.uri)); - } - free(@as(?*anyopaque, @ptrCast(data))); - } - return image; -} -pub fn LoadBoneInfoGLTF(arg_skin: cgltf_skin, arg_boneCount: [*c]c_int) callconv(.C) [*c]BoneInfo { - var skin = arg_skin; - _ = &skin; - var boneCount = arg_boneCount; - _ = &boneCount; - boneCount.* = @as(c_int, @bitCast(@as(c_uint, @truncate(skin.joints_count)))); - var bones: [*c]BoneInfo = @as([*c]BoneInfo, @ptrCast(@alignCast(malloc(skin.joints_count *% @sizeOf(BoneInfo))))); - _ = &bones; - { - var i: c_uint = 0; - _ = &i; - while (@as(cgltf_size, @bitCast(@as(c_ulong, i))) < skin.joints_count) : (i +%= 1) { - var node: cgltf_node = skin.joints[i].*; - _ = &node; - if (node.name != @as([*c]u8, @ptrCast(@alignCast(@as(?*anyopaque, @ptrFromInt(@as(c_int, 0))))))) { - _ = strncpy(@as([*c]u8, @ptrCast(@alignCast(&bones[i].name))), node.name, @sizeOf([32]u8)); - bones[i].name[@sizeOf([32]u8) -% @as(c_ulong, @bitCast(@as(c_long, @as(c_int, 1))))] = '\x00'; - } - var parentIndex: c_int = -@as(c_int, 1); - _ = &parentIndex; - { - var j: c_uint = 0; - _ = &j; - while (@as(cgltf_size, @bitCast(@as(c_ulong, j))) < skin.joints_count) : (j +%= 1) { - if (skin.joints[j] == node.parent) { - parentIndex = @as(c_int, @bitCast(j)); - break; - } - } - } - bones[i].parent = parentIndex; - } - } - return bones; -} -pub fn GetPoseAtTimeGLTF(arg_interpolationType: cgltf_interpolation_type, arg_input: [*c]cgltf_accessor, arg_output: [*c]cgltf_accessor, arg_time: f32, arg_data: ?*anyopaque) callconv(.C) bool { - var interpolationType = arg_interpolationType; - _ = &interpolationType; - var input = arg_input; - _ = &input; - var output = arg_output; - _ = &output; - var time = arg_time; - _ = &time; - var data = arg_data; - _ = &data; - if (interpolationType >= @as(c_uint, @bitCast(cgltf_interpolation_type_max_enum))) return @as(c_int, 0) != 0; - var tstart: f32 = 0.0; - _ = &tstart; - var tend: f32 = 0.0; - _ = &tend; - var keyframe: c_int = 0; - _ = &keyframe; - { - var i: c_int = 0; - _ = &i; - while (i < (@as(c_int, @bitCast(@as(c_uint, @truncate(input.*.count)))) - @as(c_int, 1))) : (i += 1) { - var r1: cgltf_bool = cgltf_accessor_read_float(input, @as(cgltf_size, @bitCast(@as(c_long, i))), &tstart, @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))); - _ = &r1; - if (!(r1 != 0)) return @as(c_int, 0) != 0; - var r2: cgltf_bool = cgltf_accessor_read_float(input, @as(cgltf_size, @bitCast(@as(c_long, i + @as(c_int, 1)))), &tend, @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 1))))); - _ = &r2; - if (!(r2 != 0)) return @as(c_int, 0) != 0; - if ((tstart <= time) and (time < tend)) { - keyframe = i; - break; - } - } - } - if (FloatEquals(tend, tstart) != 0) return @as(c_int, 1) != 0; - var duration: f32 = fmaxf(tend - tstart, 0.0000009999999974752427); - _ = &duration; - var t: f32 = (time - tstart) / duration; - _ = &t; - t = if (t < 0.0) 0.0 else t; - t = if (t > 1.0) 1.0 else t; - if (output.*.component_type != @as(c_uint, @bitCast(cgltf_component_type_r_32f))) return @as(c_int, 0) != 0; - if (output.*.type == @as(c_uint, @bitCast(cgltf_type_vec3))) { - while (true) { - switch (interpolationType) { - @as(c_uint, @bitCast(@as(c_int, 1))) => { - { - var tmp: [3]f32 = [1]f32{ - 0.0, - } ++ [1]f32{0} ** 2; - _ = &tmp; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, keyframe))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var v1: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &v1; - var r: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(data))); - _ = &r; - r.* = v1; - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 0))) => { - { - var tmp: [3]f32 = [1]f32{ - 0.0, - } ++ [1]f32{0} ** 2; - _ = &tmp; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, keyframe))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var v1: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &v1; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, keyframe + @as(c_int, 1)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var v2: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &v2; - var r: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(data))); - _ = &r; - r.* = Vector3Lerp(v1, v2, t); - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 2))) => { - { - var tmp: [3]f32 = [1]f32{ - 0.0, - } ++ [1]f32{0} ** 2; - _ = &tmp; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, (@as(c_int, 3) * keyframe) + @as(c_int, 1)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var v1: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &v1; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, (@as(c_int, 3) * keyframe) + @as(c_int, 2)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var tangent1: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &tangent1; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, (@as(c_int, 3) * (keyframe + @as(c_int, 1))) + @as(c_int, 1)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var v2: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &v2; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3) * (keyframe + @as(c_int, 1))))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3))))); - var tangent2: Vector3 = Vector3{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - }; - _ = &tangent2; - var r: [*c]Vector3 = @as([*c]Vector3, @ptrCast(@alignCast(data))); - _ = &r; - r.* = Vector3CubicHermite(v1, tangent1, v2, tangent2, t); - } - break; - }, - else => break, - } - break; - } - } else if (output.*.type == @as(c_uint, @bitCast(cgltf_type_vec4))) { - while (true) { - switch (interpolationType) { - @as(c_uint, @bitCast(@as(c_int, 1))) => { - { - var tmp: [4]f32 = [1]f32{ - 0.0, - } ++ [1]f32{0} ** 3; - _ = &tmp; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, keyframe))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var v1: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = tmp[@as(c_uint, @intCast(@as(c_int, 3)))], - }; - _ = &v1; - var r: [*c]Vector4 = @as([*c]Vector4, @ptrCast(@alignCast(data))); - _ = &r; - r.* = v1; - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 0))) => { - { - var tmp: [4]f32 = [1]f32{ - 0.0, - } ++ [1]f32{0} ** 3; - _ = &tmp; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, keyframe))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var v1: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = tmp[@as(c_uint, @intCast(@as(c_int, 3)))], - }; - _ = &v1; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, keyframe + @as(c_int, 1)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var v2: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = tmp[@as(c_uint, @intCast(@as(c_int, 3)))], - }; - _ = &v2; - var r: [*c]Vector4 = @as([*c]Vector4, @ptrCast(@alignCast(data))); - _ = &r; - r.* = QuaternionSlerp(v1, v2, t); - } - break; - }, - @as(c_uint, @bitCast(@as(c_int, 2))) => { - { - var tmp: [4]f32 = [1]f32{ - 0.0, - } ++ [1]f32{0} ** 3; - _ = &tmp; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, (@as(c_int, 3) * keyframe) + @as(c_int, 1)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var v1: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = tmp[@as(c_uint, @intCast(@as(c_int, 3)))], - }; - _ = &v1; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, (@as(c_int, 3) * keyframe) + @as(c_int, 2)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var outTangent1: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = 0.0, - }; - _ = &outTangent1; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, (@as(c_int, 3) * (keyframe + @as(c_int, 1))) + @as(c_int, 1)))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var v2: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = tmp[@as(c_uint, @intCast(@as(c_int, 3)))], - }; - _ = &v2; - _ = cgltf_accessor_read_float(output, @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 3) * (keyframe + @as(c_int, 1))))), @as([*c]f32, @ptrCast(@alignCast(&tmp))), @as(cgltf_size, @bitCast(@as(c_long, @as(c_int, 4))))); - var inTangent2: Vector4 = Vector4{ - .x = tmp[@as(c_uint, @intCast(@as(c_int, 0)))], - .y = tmp[@as(c_uint, @intCast(@as(c_int, 1)))], - .z = tmp[@as(c_uint, @intCast(@as(c_int, 2)))], - .w = 0.0, - }; - _ = &inTangent2; - var r: [*c]Vector4 = @as([*c]Vector4, @ptrCast(@alignCast(data))); - _ = &r; - v1 = QuaternionNormalize(v1); - v2 = QuaternionNormalize(v2); - if (Vector4DotProduct(v1, v2) < 0.0) { - v2 = Vector4Negate(v2); - } - outTangent1 = Vector4Scale(outTangent1, duration); - inTangent2 = Vector4Scale(inTangent2, duration); - r.* = QuaternionCubicHermiteSpline(v1, outTangent1, v2, inTangent2, t); - } - break; - }, - else => break, - } - break; - } - } - return @as(c_int, 1) != 0; -} -pub export fn m3d_loaderhook(arg_fn: [*c]u8, arg_len: [*c]c_uint) [*c]u8 { - var @"fn" = arg_fn; - _ = &@"fn"; - var len = arg_len; - _ = &len; - return LoadFileData(@as([*c]const u8, @ptrCast(@alignCast(@"fn"))), @as([*c]c_int, @ptrCast(@alignCast(len)))); -} -pub export fn m3d_freehook(arg_data: ?*anyopaque) void { - var data = arg_data; - _ = &data; - UnloadFileData(@as([*c]u8, @ptrCast(@alignCast(data)))); -} -pub const __llvm__ = @as(c_int, 1); -pub const __clang__ = @as(c_int, 1); -pub const __clang_major__ = @as(c_int, 18); -pub const __clang_minor__ = @as(c_int, 1); -pub const __clang_patchlevel__ = @as(c_int, 6); -pub const __clang_version__ = "18.1.6 (https://github.com/ziglang/zig-bootstrap 98bc6bf4fc4009888d33941daf6b600d20a42a56)"; -pub const __GNUC__ = @as(c_int, 4); -pub const __GNUC_MINOR__ = @as(c_int, 2); -pub const __GNUC_PATCHLEVEL__ = @as(c_int, 1); -pub const __GXX_ABI_VERSION = @as(c_int, 1002); -pub const __ATOMIC_RELAXED = @as(c_int, 0); -pub const __ATOMIC_CONSUME = @as(c_int, 1); -pub const __ATOMIC_ACQUIRE = @as(c_int, 2); -pub const __ATOMIC_RELEASE = @as(c_int, 3); -pub const __ATOMIC_ACQ_REL = @as(c_int, 4); -pub const __ATOMIC_SEQ_CST = @as(c_int, 5); -pub const __MEMORY_SCOPE_SYSTEM = @as(c_int, 0); -pub const __MEMORY_SCOPE_DEVICE = @as(c_int, 1); -pub const __MEMORY_SCOPE_WRKGRP = @as(c_int, 2); -pub const __MEMORY_SCOPE_WVFRNT = @as(c_int, 3); -pub const __MEMORY_SCOPE_SINGLE = @as(c_int, 4); -pub const __OPENCL_MEMORY_SCOPE_WORK_ITEM = @as(c_int, 0); -pub const __OPENCL_MEMORY_SCOPE_WORK_GROUP = @as(c_int, 1); -pub const __OPENCL_MEMORY_SCOPE_DEVICE = @as(c_int, 2); -pub const __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES = @as(c_int, 3); -pub const __OPENCL_MEMORY_SCOPE_SUB_GROUP = @as(c_int, 4); -pub const __FPCLASS_SNAN = @as(c_int, 0x0001); -pub const __FPCLASS_QNAN = @as(c_int, 0x0002); -pub const __FPCLASS_NEGINF = @as(c_int, 0x0004); -pub const __FPCLASS_NEGNORMAL = @as(c_int, 0x0008); -pub const __FPCLASS_NEGSUBNORMAL = @as(c_int, 0x0010); -pub const __FPCLASS_NEGZERO = @as(c_int, 0x0020); -pub const __FPCLASS_POSZERO = @as(c_int, 0x0040); -pub const __FPCLASS_POSSUBNORMAL = @as(c_int, 0x0080); -pub const __FPCLASS_POSNORMAL = @as(c_int, 0x0100); -pub const __FPCLASS_POSINF = @as(c_int, 0x0200); -pub const __PRAGMA_REDEFINE_EXTNAME = @as(c_int, 1); -pub const __VERSION__ = "Clang 18.1.6 (https://github.com/ziglang/zig-bootstrap 98bc6bf4fc4009888d33941daf6b600d20a42a56)"; -pub const __OBJC_BOOL_IS_BOOL = @as(c_int, 0); -pub const __CONSTANT_CFSTRINGS__ = @as(c_int, 1); -pub const __clang_literal_encoding__ = "UTF-8"; -pub const __clang_wide_literal_encoding__ = "UTF-32"; -pub const __ORDER_LITTLE_ENDIAN__ = @as(c_int, 1234); -pub const __ORDER_BIG_ENDIAN__ = @as(c_int, 4321); -pub const __ORDER_PDP_ENDIAN__ = @as(c_int, 3412); -pub const __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__; -pub const __LITTLE_ENDIAN__ = @as(c_int, 1); -pub const _LP64 = @as(c_int, 1); -pub const __LP64__ = @as(c_int, 1); -pub const __CHAR_BIT__ = @as(c_int, 8); -pub const __BOOL_WIDTH__ = @as(c_int, 8); -pub const __SHRT_WIDTH__ = @as(c_int, 16); -pub const __INT_WIDTH__ = @as(c_int, 32); -pub const __LONG_WIDTH__ = @as(c_int, 64); -pub const __LLONG_WIDTH__ = @as(c_int, 64); -pub const __BITINT_MAXWIDTH__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 8388608, .decimal); -pub const __SCHAR_MAX__ = @as(c_int, 127); -pub const __SHRT_MAX__ = @as(c_int, 32767); -pub const __INT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const __LONG_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __LONG_LONG_MAX__ = @as(c_longlong, 9223372036854775807); -pub const __WCHAR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const __WCHAR_WIDTH__ = @as(c_int, 32); -pub const __WINT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub const __WINT_WIDTH__ = @as(c_int, 32); -pub const __INTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __INTMAX_WIDTH__ = @as(c_int, 64); -pub const __SIZE_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const __SIZE_WIDTH__ = @as(c_int, 64); -pub const __UINTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const __UINTMAX_WIDTH__ = @as(c_int, 64); -pub const __PTRDIFF_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __PTRDIFF_WIDTH__ = @as(c_int, 64); -pub const __INTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __INTPTR_WIDTH__ = @as(c_int, 64); -pub const __UINTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const __UINTPTR_WIDTH__ = @as(c_int, 64); -pub const __SIZEOF_DOUBLE__ = @as(c_int, 8); -pub const __SIZEOF_FLOAT__ = @as(c_int, 4); -pub const __SIZEOF_INT__ = @as(c_int, 4); -pub const __SIZEOF_LONG__ = @as(c_int, 8); -pub const __SIZEOF_LONG_DOUBLE__ = @as(c_int, 16); -pub const __SIZEOF_LONG_LONG__ = @as(c_int, 8); -pub const __SIZEOF_POINTER__ = @as(c_int, 8); -pub const __SIZEOF_SHORT__ = @as(c_int, 2); -pub const __SIZEOF_PTRDIFF_T__ = @as(c_int, 8); -pub const __SIZEOF_SIZE_T__ = @as(c_int, 8); -pub const __SIZEOF_WCHAR_T__ = @as(c_int, 4); -pub const __SIZEOF_WINT_T__ = @as(c_int, 4); -pub const __SIZEOF_INT128__ = @as(c_int, 16); -pub const __INTMAX_TYPE__ = c_long; -pub const __INTMAX_FMTd__ = "ld"; -pub const __INTMAX_FMTi__ = "li"; -pub const __INTMAX_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `L`"); -// (no file):95:9 -pub const __UINTMAX_TYPE__ = c_ulong; -pub const __UINTMAX_FMTo__ = "lo"; -pub const __UINTMAX_FMTu__ = "lu"; -pub const __UINTMAX_FMTx__ = "lx"; -pub const __UINTMAX_FMTX__ = "lX"; -pub const __UINTMAX_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `UL`"); -// (no file):101:9 -pub const __PTRDIFF_TYPE__ = c_long; -pub const __PTRDIFF_FMTd__ = "ld"; -pub const __PTRDIFF_FMTi__ = "li"; -pub const __INTPTR_TYPE__ = c_long; -pub const __INTPTR_FMTd__ = "ld"; -pub const __INTPTR_FMTi__ = "li"; -pub const __SIZE_TYPE__ = c_ulong; -pub const __SIZE_FMTo__ = "lo"; -pub const __SIZE_FMTu__ = "lu"; -pub const __SIZE_FMTx__ = "lx"; -pub const __SIZE_FMTX__ = "lX"; -pub const __WCHAR_TYPE__ = c_int; -pub const __WINT_TYPE__ = c_uint; -pub const __SIG_ATOMIC_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const __SIG_ATOMIC_WIDTH__ = @as(c_int, 32); -pub const __CHAR16_TYPE__ = c_ushort; -pub const __CHAR32_TYPE__ = c_uint; -pub const __UINTPTR_TYPE__ = c_ulong; -pub const __UINTPTR_FMTo__ = "lo"; -pub const __UINTPTR_FMTu__ = "lu"; -pub const __UINTPTR_FMTx__ = "lx"; -pub const __UINTPTR_FMTX__ = "lX"; -pub const __FLT16_DENORM_MIN__ = @as(f16, 5.9604644775390625e-8); -pub const __FLT16_HAS_DENORM__ = @as(c_int, 1); -pub const __FLT16_DIG__ = @as(c_int, 3); -pub const __FLT16_DECIMAL_DIG__ = @as(c_int, 5); -pub const __FLT16_EPSILON__ = @as(f16, 9.765625e-4); -pub const __FLT16_HAS_INFINITY__ = @as(c_int, 1); -pub const __FLT16_HAS_QUIET_NAN__ = @as(c_int, 1); -pub const __FLT16_MANT_DIG__ = @as(c_int, 11); -pub const __FLT16_MAX_10_EXP__ = @as(c_int, 4); -pub const __FLT16_MAX_EXP__ = @as(c_int, 16); -pub const __FLT16_MAX__ = @as(f16, 6.5504e+4); -pub const __FLT16_MIN_10_EXP__ = -@as(c_int, 4); -pub const __FLT16_MIN_EXP__ = -@as(c_int, 13); -pub const __FLT16_MIN__ = @as(f16, 6.103515625e-5); -pub const __FLT_DENORM_MIN__ = @as(f32, 1.40129846e-45); -pub const __FLT_HAS_DENORM__ = @as(c_int, 1); -pub const __FLT_DIG__ = @as(c_int, 6); -pub const __FLT_DECIMAL_DIG__ = @as(c_int, 9); -pub const __FLT_EPSILON__ = @as(f32, 1.19209290e-7); -pub const __FLT_HAS_INFINITY__ = @as(c_int, 1); -pub const __FLT_HAS_QUIET_NAN__ = @as(c_int, 1); -pub const __FLT_MANT_DIG__ = @as(c_int, 24); -pub const __FLT_MAX_10_EXP__ = @as(c_int, 38); -pub const __FLT_MAX_EXP__ = @as(c_int, 128); -pub const __FLT_MAX__ = @as(f32, 3.40282347e+38); -pub const __FLT_MIN_10_EXP__ = -@as(c_int, 37); -pub const __FLT_MIN_EXP__ = -@as(c_int, 125); -pub const __FLT_MIN__ = @as(f32, 1.17549435e-38); -pub const __DBL_DENORM_MIN__ = @as(f64, 4.9406564584124654e-324); -pub const __DBL_HAS_DENORM__ = @as(c_int, 1); -pub const __DBL_DIG__ = @as(c_int, 15); -pub const __DBL_DECIMAL_DIG__ = @as(c_int, 17); -pub const __DBL_EPSILON__ = @as(f64, 2.2204460492503131e-16); -pub const __DBL_HAS_INFINITY__ = @as(c_int, 1); -pub const __DBL_HAS_QUIET_NAN__ = @as(c_int, 1); -pub const __DBL_MANT_DIG__ = @as(c_int, 53); -pub const __DBL_MAX_10_EXP__ = @as(c_int, 308); -pub const __DBL_MAX_EXP__ = @as(c_int, 1024); -pub const __DBL_MAX__ = @as(f64, 1.7976931348623157e+308); -pub const __DBL_MIN_10_EXP__ = -@as(c_int, 307); -pub const __DBL_MIN_EXP__ = -@as(c_int, 1021); -pub const __DBL_MIN__ = @as(f64, 2.2250738585072014e-308); -pub const __LDBL_DENORM_MIN__ = @as(c_longdouble, 3.64519953188247460253e-4951); -pub const __LDBL_HAS_DENORM__ = @as(c_int, 1); -pub const __LDBL_DIG__ = @as(c_int, 18); -pub const __LDBL_DECIMAL_DIG__ = @as(c_int, 21); -pub const __LDBL_EPSILON__ = @as(c_longdouble, 1.08420217248550443401e-19); -pub const __LDBL_HAS_INFINITY__ = @as(c_int, 1); -pub const __LDBL_HAS_QUIET_NAN__ = @as(c_int, 1); -pub const __LDBL_MANT_DIG__ = @as(c_int, 64); -pub const __LDBL_MAX_10_EXP__ = @as(c_int, 4932); -pub const __LDBL_MAX_EXP__ = @as(c_int, 16384); -pub const __LDBL_MAX__ = @as(c_longdouble, 1.18973149535723176502e+4932); -pub const __LDBL_MIN_10_EXP__ = -@as(c_int, 4931); -pub const __LDBL_MIN_EXP__ = -@as(c_int, 16381); -pub const __LDBL_MIN__ = @as(c_longdouble, 3.36210314311209350626e-4932); -pub const __POINTER_WIDTH__ = @as(c_int, 64); -pub const __BIGGEST_ALIGNMENT__ = @as(c_int, 16); -pub const __WINT_UNSIGNED__ = @as(c_int, 1); -pub const __INT8_TYPE__ = i8; -pub const __INT8_FMTd__ = "hhd"; -pub const __INT8_FMTi__ = "hhi"; -pub const __INT8_C_SUFFIX__ = ""; -pub const __INT16_TYPE__ = c_short; -pub const __INT16_FMTd__ = "hd"; -pub const __INT16_FMTi__ = "hi"; -pub const __INT16_C_SUFFIX__ = ""; -pub const __INT32_TYPE__ = c_int; -pub const __INT32_FMTd__ = "d"; -pub const __INT32_FMTi__ = "i"; -pub const __INT32_C_SUFFIX__ = ""; -pub const __INT64_TYPE__ = c_long; -pub const __INT64_FMTd__ = "ld"; -pub const __INT64_FMTi__ = "li"; -pub const __INT64_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `L`"); -// (no file):198:9 -pub const __UINT8_TYPE__ = u8; -pub const __UINT8_FMTo__ = "hho"; -pub const __UINT8_FMTu__ = "hhu"; -pub const __UINT8_FMTx__ = "hhx"; -pub const __UINT8_FMTX__ = "hhX"; -pub const __UINT8_C_SUFFIX__ = ""; -pub const __UINT8_MAX__ = @as(c_int, 255); -pub const __INT8_MAX__ = @as(c_int, 127); -pub const __UINT16_TYPE__ = c_ushort; -pub const __UINT16_FMTo__ = "ho"; -pub const __UINT16_FMTu__ = "hu"; -pub const __UINT16_FMTx__ = "hx"; -pub const __UINT16_FMTX__ = "hX"; -pub const __UINT16_C_SUFFIX__ = ""; -pub const __UINT16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); -pub const __INT16_MAX__ = @as(c_int, 32767); -pub const __UINT32_TYPE__ = c_uint; -pub const __UINT32_FMTo__ = "o"; -pub const __UINT32_FMTu__ = "u"; -pub const __UINT32_FMTx__ = "x"; -pub const __UINT32_FMTX__ = "X"; -pub const __UINT32_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `U`"); -// (no file):220:9 -pub const __UINT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub const __INT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const __UINT64_TYPE__ = c_ulong; -pub const __UINT64_FMTo__ = "lo"; -pub const __UINT64_FMTu__ = "lu"; -pub const __UINT64_FMTx__ = "lx"; -pub const __UINT64_FMTX__ = "lX"; -pub const __UINT64_C_SUFFIX__ = @compileError("unable to translate macro: undefined identifier `UL`"); -// (no file):228:9 -pub const __UINT64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const __INT64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __INT_LEAST8_TYPE__ = i8; -pub const __INT_LEAST8_MAX__ = @as(c_int, 127); -pub const __INT_LEAST8_WIDTH__ = @as(c_int, 8); -pub const __INT_LEAST8_FMTd__ = "hhd"; -pub const __INT_LEAST8_FMTi__ = "hhi"; -pub const __UINT_LEAST8_TYPE__ = u8; -pub const __UINT_LEAST8_MAX__ = @as(c_int, 255); -pub const __UINT_LEAST8_FMTo__ = "hho"; -pub const __UINT_LEAST8_FMTu__ = "hhu"; -pub const __UINT_LEAST8_FMTx__ = "hhx"; -pub const __UINT_LEAST8_FMTX__ = "hhX"; -pub const __INT_LEAST16_TYPE__ = c_short; -pub const __INT_LEAST16_MAX__ = @as(c_int, 32767); -pub const __INT_LEAST16_WIDTH__ = @as(c_int, 16); -pub const __INT_LEAST16_FMTd__ = "hd"; -pub const __INT_LEAST16_FMTi__ = "hi"; -pub const __UINT_LEAST16_TYPE__ = c_ushort; -pub const __UINT_LEAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); -pub const __UINT_LEAST16_FMTo__ = "ho"; -pub const __UINT_LEAST16_FMTu__ = "hu"; -pub const __UINT_LEAST16_FMTx__ = "hx"; -pub const __UINT_LEAST16_FMTX__ = "hX"; -pub const __INT_LEAST32_TYPE__ = c_int; -pub const __INT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const __INT_LEAST32_WIDTH__ = @as(c_int, 32); -pub const __INT_LEAST32_FMTd__ = "d"; -pub const __INT_LEAST32_FMTi__ = "i"; -pub const __UINT_LEAST32_TYPE__ = c_uint; -pub const __UINT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub const __UINT_LEAST32_FMTo__ = "o"; -pub const __UINT_LEAST32_FMTu__ = "u"; -pub const __UINT_LEAST32_FMTx__ = "x"; -pub const __UINT_LEAST32_FMTX__ = "X"; -pub const __INT_LEAST64_TYPE__ = c_long; -pub const __INT_LEAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __INT_LEAST64_WIDTH__ = @as(c_int, 64); -pub const __INT_LEAST64_FMTd__ = "ld"; -pub const __INT_LEAST64_FMTi__ = "li"; -pub const __UINT_LEAST64_TYPE__ = c_ulong; -pub const __UINT_LEAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const __UINT_LEAST64_FMTo__ = "lo"; -pub const __UINT_LEAST64_FMTu__ = "lu"; -pub const __UINT_LEAST64_FMTx__ = "lx"; -pub const __UINT_LEAST64_FMTX__ = "lX"; -pub const __INT_FAST8_TYPE__ = i8; -pub const __INT_FAST8_MAX__ = @as(c_int, 127); -pub const __INT_FAST8_WIDTH__ = @as(c_int, 8); -pub const __INT_FAST8_FMTd__ = "hhd"; -pub const __INT_FAST8_FMTi__ = "hhi"; -pub const __UINT_FAST8_TYPE__ = u8; -pub const __UINT_FAST8_MAX__ = @as(c_int, 255); -pub const __UINT_FAST8_FMTo__ = "hho"; -pub const __UINT_FAST8_FMTu__ = "hhu"; -pub const __UINT_FAST8_FMTx__ = "hhx"; -pub const __UINT_FAST8_FMTX__ = "hhX"; -pub const __INT_FAST16_TYPE__ = c_short; -pub const __INT_FAST16_MAX__ = @as(c_int, 32767); -pub const __INT_FAST16_WIDTH__ = @as(c_int, 16); -pub const __INT_FAST16_FMTd__ = "hd"; -pub const __INT_FAST16_FMTi__ = "hi"; -pub const __UINT_FAST16_TYPE__ = c_ushort; -pub const __UINT_FAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); -pub const __UINT_FAST16_FMTo__ = "ho"; -pub const __UINT_FAST16_FMTu__ = "hu"; -pub const __UINT_FAST16_FMTx__ = "hx"; -pub const __UINT_FAST16_FMTX__ = "hX"; -pub const __INT_FAST32_TYPE__ = c_int; -pub const __INT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const __INT_FAST32_WIDTH__ = @as(c_int, 32); -pub const __INT_FAST32_FMTd__ = "d"; -pub const __INT_FAST32_FMTi__ = "i"; -pub const __UINT_FAST32_TYPE__ = c_uint; -pub const __UINT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub const __UINT_FAST32_FMTo__ = "o"; -pub const __UINT_FAST32_FMTu__ = "u"; -pub const __UINT_FAST32_FMTx__ = "x"; -pub const __UINT_FAST32_FMTX__ = "X"; -pub const __INT_FAST64_TYPE__ = c_long; -pub const __INT_FAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const __INT_FAST64_WIDTH__ = @as(c_int, 64); -pub const __INT_FAST64_FMTd__ = "ld"; -pub const __INT_FAST64_FMTi__ = "li"; -pub const __UINT_FAST64_TYPE__ = c_ulong; -pub const __UINT_FAST64_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const __UINT_FAST64_FMTo__ = "lo"; -pub const __UINT_FAST64_FMTu__ = "lu"; -pub const __UINT_FAST64_FMTx__ = "lx"; -pub const __UINT_FAST64_FMTX__ = "lX"; -pub const __USER_LABEL_PREFIX__ = ""; -pub const __FINITE_MATH_ONLY__ = @as(c_int, 0); -pub const __GNUC_STDC_INLINE__ = @as(c_int, 1); -pub const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = @as(c_int, 1); -pub const __CLANG_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_INT_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2); -pub const __CLANG_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_INT_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2); -pub const __GCC_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2); -pub const __NO_INLINE__ = @as(c_int, 1); -pub const __PIC__ = @as(c_int, 2); -pub const __pic__ = @as(c_int, 2); -pub const __FLT_RADIX__ = @as(c_int, 2); -pub const __DECIMAL_DIG__ = __LDBL_DECIMAL_DIG__; -pub const __SSP_STRONG__ = @as(c_int, 2); -pub const __ELF__ = @as(c_int, 1); -pub const __GCC_ASM_FLAG_OUTPUTS__ = @as(c_int, 1); -pub const __code_model_small__ = @as(c_int, 1); -pub const __amd64__ = @as(c_int, 1); -pub const __amd64 = @as(c_int, 1); -pub const __x86_64 = @as(c_int, 1); -pub const __x86_64__ = @as(c_int, 1); -pub const __SEG_GS = @as(c_int, 1); -pub const __SEG_FS = @as(c_int, 1); -pub const __seg_gs = @compileError("unable to translate macro: undefined identifier `address_space`"); -// (no file):358:9 -pub const __seg_fs = @compileError("unable to translate macro: undefined identifier `address_space`"); -// (no file):359:9 -pub const __znver3 = @as(c_int, 1); -pub const __znver3__ = @as(c_int, 1); -pub const __tune_znver3__ = @as(c_int, 1); -pub const __REGISTER_PREFIX__ = ""; -pub const __NO_MATH_INLINES = @as(c_int, 1); -pub const __AES__ = @as(c_int, 1); -pub const __VAES__ = @as(c_int, 1); -pub const __PCLMUL__ = @as(c_int, 1); -pub const __VPCLMULQDQ__ = @as(c_int, 1); -pub const __LAHF_SAHF__ = @as(c_int, 1); -pub const __LZCNT__ = @as(c_int, 1); -pub const __RDRND__ = @as(c_int, 1); -pub const __FSGSBASE__ = @as(c_int, 1); -pub const __BMI__ = @as(c_int, 1); -pub const __BMI2__ = @as(c_int, 1); -pub const __POPCNT__ = @as(c_int, 1); -pub const __PRFCHW__ = @as(c_int, 1); -pub const __RDSEED__ = @as(c_int, 1); -pub const __ADX__ = @as(c_int, 1); -pub const __MWAITX__ = @as(c_int, 1); -pub const __MOVBE__ = @as(c_int, 1); -pub const __SSE4A__ = @as(c_int, 1); -pub const __FMA__ = @as(c_int, 1); -pub const __F16C__ = @as(c_int, 1); -pub const __SHA__ = @as(c_int, 1); -pub const __FXSR__ = @as(c_int, 1); -pub const __XSAVE__ = @as(c_int, 1); -pub const __XSAVEOPT__ = @as(c_int, 1); -pub const __XSAVEC__ = @as(c_int, 1); -pub const __XSAVES__ = @as(c_int, 1); -pub const __PKU__ = @as(c_int, 1); -pub const __CLFLUSHOPT__ = @as(c_int, 1); -pub const __CLWB__ = @as(c_int, 1); -pub const __WBNOINVD__ = @as(c_int, 1); -pub const __SHSTK__ = @as(c_int, 1); -pub const __CLZERO__ = @as(c_int, 1); -pub const __RDPID__ = @as(c_int, 1); -pub const __RDPRU__ = @as(c_int, 1); -pub const __INVPCID__ = @as(c_int, 1); -pub const __CRC32__ = @as(c_int, 1); -pub const __AVX2__ = @as(c_int, 1); -pub const __AVX__ = @as(c_int, 1); -pub const __SSE4_2__ = @as(c_int, 1); -pub const __SSE4_1__ = @as(c_int, 1); -pub const __SSSE3__ = @as(c_int, 1); -pub const __SSE3__ = @as(c_int, 1); -pub const __SSE2__ = @as(c_int, 1); -pub const __SSE2_MATH__ = @as(c_int, 1); -pub const __SSE__ = @as(c_int, 1); -pub const __SSE_MATH__ = @as(c_int, 1); -pub const __MMX__ = @as(c_int, 1); -pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = @as(c_int, 1); -pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = @as(c_int, 1); -pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = @as(c_int, 1); -pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = @as(c_int, 1); -pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = @as(c_int, 1); -pub const __SIZEOF_FLOAT128__ = @as(c_int, 16); -pub const unix = @as(c_int, 1); -pub const __unix = @as(c_int, 1); -pub const __unix__ = @as(c_int, 1); -pub const linux = @as(c_int, 1); -pub const __linux = @as(c_int, 1); -pub const __linux__ = @as(c_int, 1); -pub const __gnu_linux__ = @as(c_int, 1); -pub const __FLOAT128__ = @as(c_int, 1); -pub const __STDC__ = @as(c_int, 1); -pub const __STDC_HOSTED__ = @as(c_int, 1); -pub const __STDC_VERSION__ = @as(c_long, 201710); -pub const __STDC_UTF_16__ = @as(c_int, 1); -pub const __STDC_UTF_32__ = @as(c_int, 1); -pub const __GLIBC_MINOR__ = @as(c_int, 39); -pub const _DEBUG = @as(c_int, 1); -pub const __GCC_HAVE_DWARF2_CFI_ASM = @as(c_int, 1); -pub const RAYLIB_H = ""; -pub const __STDARG_H = ""; -pub const __need___va_list = ""; -pub const __need_va_list = ""; -pub const __need_va_arg = ""; -pub const __need___va_copy = ""; -pub const __need_va_copy = ""; -pub const __GNUC_VA_LIST = ""; -pub const _VA_LIST = ""; -pub const va_start = @compileError("unable to translate macro: undefined identifier `__builtin_va_start`"); -// /opt/zig-bin-0.13.0/lib/include/__stdarg_va_arg.h:17:9 -pub const va_end = @compileError("unable to translate macro: undefined identifier `__builtin_va_end`"); -// /opt/zig-bin-0.13.0/lib/include/__stdarg_va_arg.h:19:9 -pub const va_arg = @compileError("unable to translate C expr: unexpected token 'an identifier'"); -// /opt/zig-bin-0.13.0/lib/include/__stdarg_va_arg.h:20:9 -pub const __va_copy = @compileError("unable to translate macro: undefined identifier `__builtin_va_copy`"); -// /opt/zig-bin-0.13.0/lib/include/__stdarg___va_copy.h:11:9 -pub const va_copy = @compileError("unable to translate macro: undefined identifier `__builtin_va_copy`"); -// /opt/zig-bin-0.13.0/lib/include/__stdarg_va_copy.h:11:9 -pub const RAYLIB_VERSION_MAJOR = @as(c_int, 5); -pub const RAYLIB_VERSION_MINOR = @as(c_int, 5); -pub const RAYLIB_VERSION_PATCH = @as(c_int, 0); -pub const RAYLIB_VERSION = "5.5-dev"; -pub const RLAPI = ""; -pub const PI = @as(f32, 3.14159265358979323846); -pub const DEG2RAD = @import("std").zig.c_translation.MacroArithmetic.div(PI, @as(f32, 180.0)); -pub const RAD2DEG = @import("std").zig.c_translation.MacroArithmetic.div(@as(f32, 180.0), PI); -pub inline fn RL_MALLOC(sz: anytype) @TypeOf(malloc(sz)) { - _ = &sz; - return malloc(sz); -} -pub inline fn RL_CALLOC(n: anytype, sz: anytype) @TypeOf(calloc(n, sz)) { - _ = &n; - _ = &sz; - return calloc(n, sz); -} -pub inline fn RL_REALLOC(ptr: anytype, sz: anytype) @TypeOf(realloc(ptr, sz)) { - _ = &ptr; - _ = &sz; - return realloc(ptr, sz); -} -pub inline fn RL_FREE(ptr: anytype) @TypeOf(free(ptr)) { - _ = &ptr; - return free(ptr); -} -pub inline fn CLITERAL(@"type": anytype) @TypeOf(@"type") { - _ = &@"type"; - return @"type"; -} -pub const RL_COLOR_TYPE = ""; -pub const RL_RECTANGLE_TYPE = ""; -pub const RL_VECTOR2_TYPE = ""; -pub const RL_VECTOR3_TYPE = ""; -pub const RL_VECTOR4_TYPE = ""; -pub const RL_QUATERNION_TYPE = ""; -pub const RL_MATRIX_TYPE = ""; -pub const LIGHTGRAY = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 200), @as(c_int, 200), @as(c_int, 200), @as(c_int, 255) }); -pub const GRAY = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 130), @as(c_int, 130), @as(c_int, 130), @as(c_int, 255) }); -pub const DARKGRAY = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 80), @as(c_int, 80), @as(c_int, 80), @as(c_int, 255) }); -pub const YELLOW = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 253), @as(c_int, 249), @as(c_int, 0), @as(c_int, 255) }); -pub const GOLD = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 255), @as(c_int, 203), @as(c_int, 0), @as(c_int, 255) }); -pub const ORANGE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 255), @as(c_int, 161), @as(c_int, 0), @as(c_int, 255) }); -pub const PINK = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 255), @as(c_int, 109), @as(c_int, 194), @as(c_int, 255) }); -pub const RED = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 230), @as(c_int, 41), @as(c_int, 55), @as(c_int, 255) }); -pub const MAROON = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 190), @as(c_int, 33), @as(c_int, 55), @as(c_int, 255) }); -pub const GREEN = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 228), @as(c_int, 48), @as(c_int, 255) }); -pub const LIME = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 158), @as(c_int, 47), @as(c_int, 255) }); -pub const DARKGREEN = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 117), @as(c_int, 44), @as(c_int, 255) }); -pub const SKYBLUE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 102), @as(c_int, 191), @as(c_int, 255), @as(c_int, 255) }); -pub const BLUE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 121), @as(c_int, 241), @as(c_int, 255) }); -pub const DARKBLUE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 82), @as(c_int, 172), @as(c_int, 255) }); -pub const PURPLE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 200), @as(c_int, 122), @as(c_int, 255), @as(c_int, 255) }); -pub const VIOLET = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 135), @as(c_int, 60), @as(c_int, 190), @as(c_int, 255) }); -pub const DARKPURPLE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 112), @as(c_int, 31), @as(c_int, 126), @as(c_int, 255) }); -pub const BEIGE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 211), @as(c_int, 176), @as(c_int, 131), @as(c_int, 255) }); -pub const BROWN = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 127), @as(c_int, 106), @as(c_int, 79), @as(c_int, 255) }); -pub const DARKBROWN = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 76), @as(c_int, 63), @as(c_int, 47), @as(c_int, 255) }); -pub const WHITE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 255), @as(c_int, 255), @as(c_int, 255), @as(c_int, 255) }); -pub const BLACK = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 0), @as(c_int, 0), @as(c_int, 255) }); -pub const BLANK = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 0), @as(c_int, 0), @as(c_int, 0), @as(c_int, 0) }); -pub const MAGENTA = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 255), @as(c_int, 0), @as(c_int, 255), @as(c_int, 255) }); -pub const RAYWHITE = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 245), @as(c_int, 245), @as(c_int, 245), @as(c_int, 255) }); -pub const __STDBOOL_H = ""; -pub const __bool_true_false_are_defined = @as(c_int, 1); -pub const @"bool" = bool; -pub const @"true" = @as(c_int, 1); -pub const @"false" = @as(c_int, 0); -pub const MOUSE_LEFT_BUTTON = MOUSE_BUTTON_LEFT; -pub const MOUSE_RIGHT_BUTTON = MOUSE_BUTTON_RIGHT; -pub const MOUSE_MIDDLE_BUTTON = MOUSE_BUTTON_MIDDLE; -pub const MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO; -pub const MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS; -pub const SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO; -pub const SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS; -pub const GetMouseRay = GetScreenToWorldRay; -pub const CONFIG_H = ""; -pub const SUPPORT_MODULE_RSHAPES = @as(c_int, 1); -pub const SUPPORT_MODULE_RTEXTURES = @as(c_int, 1); -pub const SUPPORT_MODULE_RTEXT = @as(c_int, 1); -pub const SUPPORT_MODULE_RMODELS = @as(c_int, 1); -pub const SUPPORT_MODULE_RAUDIO = @as(c_int, 1); -pub const SUPPORT_CAMERA_SYSTEM = @as(c_int, 1); -pub const SUPPORT_GESTURES_SYSTEM = @as(c_int, 1); -pub const SUPPORT_RPRAND_GENERATOR = @as(c_int, 1); -pub const SUPPORT_MOUSE_GESTURES = @as(c_int, 1); -pub const SUPPORT_SSH_KEYBOARD_RPI = @as(c_int, 1); -pub const SUPPORT_WINMM_HIGHRES_TIMER = @as(c_int, 1); -pub const SUPPORT_PARTIALBUSY_WAIT_LOOP = @as(c_int, 1); -pub const SUPPORT_SCREEN_CAPTURE = @as(c_int, 1); -pub const SUPPORT_GIF_RECORDING = @as(c_int, 1); -pub const SUPPORT_COMPRESSION_API = @as(c_int, 1); -pub const SUPPORT_AUTOMATION_EVENTS = @as(c_int, 1); -pub const MAX_FILEPATH_CAPACITY = @as(c_int, 8192); -pub const MAX_FILEPATH_LENGTH = @as(c_int, 4096); -pub const MAX_KEYBOARD_KEYS = @as(c_int, 512); -pub const MAX_MOUSE_BUTTONS = @as(c_int, 8); -pub const MAX_GAMEPADS = @as(c_int, 4); -pub const MAX_GAMEPAD_AXIS = @as(c_int, 8); -pub const MAX_GAMEPAD_BUTTONS = @as(c_int, 32); -pub const MAX_GAMEPAD_VIBRATION_TIME = @as(f32, 2.0); -pub const MAX_TOUCH_POINTS = @as(c_int, 8); -pub const MAX_KEY_PRESSED_QUEUE = @as(c_int, 16); -pub const MAX_CHAR_PRESSED_QUEUE = @as(c_int, 16); -pub const MAX_DECOMPRESSION_SIZE = @as(c_int, 64); -pub const MAX_AUTOMATION_EVENTS = @as(c_int, 16384); -pub const RL_DEFAULT_BATCH_BUFFERS = @as(c_int, 1); -pub const RL_DEFAULT_BATCH_DRAWCALLS = @as(c_int, 256); -pub const RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS = @as(c_int, 4); -pub const RL_MAX_MATRIX_STACK_SIZE = @as(c_int, 32); -pub const RL_MAX_SHADER_LOCATIONS = @as(c_int, 32); -pub const RL_CULL_DISTANCE_NEAR = @as(f64, 0.01); -pub const RL_CULL_DISTANCE_FAR = @as(f64, 1000.0); -pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION = @as(c_int, 0); -pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD = @as(c_int, 1); -pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL = @as(c_int, 2); -pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR = @as(c_int, 3); -pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT = @as(c_int, 4); -pub const RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 = @as(c_int, 5); -pub const RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION = "vertexPosition"; -pub const RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD = "vertexTexCoord"; -pub const RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL = "vertexNormal"; -pub const RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR = "vertexColor"; -pub const RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT = "vertexTangent"; -pub const RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 = "vertexTexCoord2"; -pub const RL_DEFAULT_SHADER_UNIFORM_NAME_MVP = "mvp"; -pub const RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW = "matView"; -pub const RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION = "matProjection"; -pub const RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL = "matModel"; -pub const RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL = "matNormal"; -pub const RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR = "colDiffuse"; -pub const RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 = "texture0"; -pub const RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 = "texture1"; -pub const RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 = "texture2"; -pub const SUPPORT_QUADS_DRAW_MODE = @as(c_int, 1); -pub const SPLINE_SEGMENT_DIVISIONS = @as(c_int, 24); -pub const SUPPORT_FILEFORMAT_PNG = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_GIF = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_QOI = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_DDS = @as(c_int, 1); -pub const SUPPORT_IMAGE_EXPORT = @as(c_int, 1); -pub const SUPPORT_IMAGE_GENERATION = @as(c_int, 1); -pub const SUPPORT_IMAGE_MANIPULATION = @as(c_int, 1); -pub const SUPPORT_DEFAULT_FONT = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_TTF = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_FNT = @as(c_int, 1); -pub const SUPPORT_TEXT_MANIPULATION = @as(c_int, 1); -pub const SUPPORT_FONT_ATLAS_WHITE_REC = @as(c_int, 1); -pub const MAX_TEXT_BUFFER_LENGTH = @as(c_int, 1024); -pub const MAX_TEXTSPLIT_COUNT = @as(c_int, 128); -pub const SUPPORT_FILEFORMAT_OBJ = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_MTL = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_IQM = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_GLTF = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_VOX = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_M3D = @as(c_int, 1); -pub const SUPPORT_MESH_GENERATION = @as(c_int, 1); -pub const MAX_MATERIAL_MAPS = @as(c_int, 12); -pub const MAX_MESH_VERTEX_BUFFERS = @as(c_int, 7); -pub const SUPPORT_FILEFORMAT_WAV = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_OGG = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_MP3 = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_QOA = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_XM = @as(c_int, 1); -pub const SUPPORT_FILEFORMAT_MOD = @as(c_int, 1); -pub const AUDIO_DEVICE_FORMAT = @compileError("unable to translate macro: undefined identifier `ma_format_f32`"); -// ./config.h:244:9 -pub const AUDIO_DEVICE_CHANNELS = @as(c_int, 2); -pub const AUDIO_DEVICE_SAMPLE_RATE = @as(c_int, 0); -pub const MAX_AUDIO_BUFFER_POOL_CHANNELS = @as(c_int, 16); -pub const SUPPORT_STANDARD_FILEIO = @as(c_int, 1); -pub const SUPPORT_TRACELOG = @as(c_int, 1); -pub const MAX_TRACELOG_MSG_LENGTH = @as(c_int, 256); -pub const UTILS_H = ""; -pub const TRACELOG = @compileError("unable to translate C expr: expected ')' instead got '...'"); -// ./utils.h:36:13 -pub const TRACELOGD = @compileError("unable to translate C expr: expected ')' instead got '...'"); -// ./utils.h:41:17 -pub const RLGL_H = ""; -pub const RLGL_VERSION = "5.0"; -pub const GRAPHICS_API_OPENGL_33 = ""; -pub const RLGL_RENDER_TEXTURES_HINT = ""; -pub const RL_DEFAULT_BATCH_BUFFER_ELEMENTS = @as(c_int, 8192); -pub const RL_TEXTURE_WRAP_S = @as(c_int, 0x2802); -pub const RL_TEXTURE_WRAP_T = @as(c_int, 0x2803); -pub const RL_TEXTURE_MAG_FILTER = @as(c_int, 0x2800); -pub const RL_TEXTURE_MIN_FILTER = @as(c_int, 0x2801); -pub const RL_TEXTURE_FILTER_NEAREST = @as(c_int, 0x2600); -pub const RL_TEXTURE_FILTER_LINEAR = @as(c_int, 0x2601); -pub const RL_TEXTURE_FILTER_MIP_NEAREST = @as(c_int, 0x2700); -pub const RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR = @as(c_int, 0x2702); -pub const RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST = @as(c_int, 0x2701); -pub const RL_TEXTURE_FILTER_MIP_LINEAR = @as(c_int, 0x2703); -pub const RL_TEXTURE_FILTER_ANISOTROPIC = @as(c_int, 0x3000); -pub const RL_TEXTURE_MIPMAP_BIAS_RATIO = @as(c_int, 0x4000); -pub const RL_TEXTURE_WRAP_REPEAT = @as(c_int, 0x2901); -pub const RL_TEXTURE_WRAP_CLAMP = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x812F, .hex); -pub const RL_TEXTURE_WRAP_MIRROR_REPEAT = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8370, .hex); -pub const RL_TEXTURE_WRAP_MIRROR_CLAMP = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8742, .hex); -pub const RL_MODELVIEW = @as(c_int, 0x1700); -pub const RL_PROJECTION = @as(c_int, 0x1701); -pub const RL_TEXTURE = @as(c_int, 0x1702); -pub const RL_LINES = @as(c_int, 0x0001); -pub const RL_TRIANGLES = @as(c_int, 0x0004); -pub const RL_QUADS = @as(c_int, 0x0007); -pub const RL_UNSIGNED_BYTE = @as(c_int, 0x1401); -pub const RL_FLOAT = @as(c_int, 0x1406); -pub const RL_STREAM_DRAW = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E0, .hex); -pub const RL_STREAM_READ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E1, .hex); -pub const RL_STREAM_COPY = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E2, .hex); -pub const RL_STATIC_DRAW = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E4, .hex); -pub const RL_STATIC_READ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E5, .hex); -pub const RL_STATIC_COPY = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E6, .hex); -pub const RL_DYNAMIC_DRAW = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E8, .hex); -pub const RL_DYNAMIC_READ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88E9, .hex); -pub const RL_DYNAMIC_COPY = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x88EA, .hex); -pub const RL_FRAGMENT_SHADER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8B30, .hex); -pub const RL_VERTEX_SHADER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8B31, .hex); -pub const RL_COMPUTE_SHADER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x91B9, .hex); -pub const RL_ZERO = @as(c_int, 0); -pub const RL_ONE = @as(c_int, 1); -pub const RL_SRC_COLOR = @as(c_int, 0x0300); -pub const RL_ONE_MINUS_SRC_COLOR = @as(c_int, 0x0301); -pub const RL_SRC_ALPHA = @as(c_int, 0x0302); -pub const RL_ONE_MINUS_SRC_ALPHA = @as(c_int, 0x0303); -pub const RL_DST_ALPHA = @as(c_int, 0x0304); -pub const RL_ONE_MINUS_DST_ALPHA = @as(c_int, 0x0305); -pub const RL_DST_COLOR = @as(c_int, 0x0306); -pub const RL_ONE_MINUS_DST_COLOR = @as(c_int, 0x0307); -pub const RL_SRC_ALPHA_SATURATE = @as(c_int, 0x0308); -pub const RL_CONSTANT_COLOR = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8001, .hex); -pub const RL_ONE_MINUS_CONSTANT_COLOR = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8002, .hex); -pub const RL_CONSTANT_ALPHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8003, .hex); -pub const RL_ONE_MINUS_CONSTANT_ALPHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8004, .hex); -pub const RL_FUNC_ADD = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8006, .hex); -pub const RL_MIN = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8007, .hex); -pub const RL_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8008, .hex); -pub const RL_FUNC_SUBTRACT = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x800A, .hex); -pub const RL_FUNC_REVERSE_SUBTRACT = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x800B, .hex); -pub const RL_BLEND_EQUATION = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8009, .hex); -pub const RL_BLEND_EQUATION_RGB = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8009, .hex); -pub const RL_BLEND_EQUATION_ALPHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x883D, .hex); -pub const RL_BLEND_DST_RGB = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80C8, .hex); -pub const RL_BLEND_SRC_RGB = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80C9, .hex); -pub const RL_BLEND_DST_ALPHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80CA, .hex); -pub const RL_BLEND_SRC_ALPHA = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80CB, .hex); -pub const RL_BLEND_COLOR = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8005, .hex); -pub const RL_READ_FRAMEBUFFER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8CA8, .hex); -pub const RL_DRAW_FRAMEBUFFER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8CA9, .hex); -pub const RL_SHADER_LOC_MAP_DIFFUSE = RL_SHADER_LOC_MAP_ALBEDO; -pub const RL_SHADER_LOC_MAP_SPECULAR = RL_SHADER_LOC_MAP_METALNESS; -pub const RAYMATH_H = ""; -pub const RMAPI = @compileError("unable to translate C expr: unexpected token 'inline'"); -// ./raymath.h:76:17 -pub const EPSILON = @as(f32, 0.000001); -pub inline fn MatrixToFloat(mat: anytype) @TypeOf(MatrixToFloatV(mat).v) { - _ = &mat; - return MatrixToFloatV(mat).v; -} -pub inline fn Vector3ToFloat(vec: anytype) @TypeOf(Vector3ToFloatV(vec).v) { - _ = &vec; - return Vector3ToFloatV(vec).v; -} -pub const _MATH_H = @as(c_int, 1); -pub const __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION = ""; -pub const _FEATURES_H = @as(c_int, 1); -pub const __KERNEL_STRICT_NAMES = ""; -pub inline fn __GNUC_PREREQ(maj: anytype, min: anytype) @TypeOf(((__GNUC__ << @as(c_int, 16)) + __GNUC_MINOR__) >= ((maj << @as(c_int, 16)) + min)) { - _ = &maj; - _ = &min; - return ((__GNUC__ << @as(c_int, 16)) + __GNUC_MINOR__) >= ((maj << @as(c_int, 16)) + min); -} -pub inline fn __glibc_clang_prereq(maj: anytype, min: anytype) @TypeOf(((__clang_major__ << @as(c_int, 16)) + __clang_minor__) >= ((maj << @as(c_int, 16)) + min)) { - _ = &maj; - _ = &min; - return ((__clang_major__ << @as(c_int, 16)) + __clang_minor__) >= ((maj << @as(c_int, 16)) + min); -} -pub const __GLIBC_USE = @compileError("unable to translate macro: undefined identifier `__GLIBC_USE_`"); -// /usr/include/features.h:189:9 -pub const _DEFAULT_SOURCE = @as(c_int, 1); -pub const __GLIBC_USE_ISOC23 = @as(c_int, 0); -pub const __USE_ISOC11 = @as(c_int, 1); -pub const __USE_ISOC99 = @as(c_int, 1); -pub const __USE_ISOC95 = @as(c_int, 1); -pub const __USE_POSIX_IMPLICITLY = @as(c_int, 1); -pub const _POSIX_SOURCE = @as(c_int, 1); -pub const _POSIX_C_SOURCE = @as(c_long, 200809); -pub const __USE_POSIX = @as(c_int, 1); -pub const __USE_POSIX2 = @as(c_int, 1); -pub const __USE_POSIX199309 = @as(c_int, 1); -pub const __USE_POSIX199506 = @as(c_int, 1); -pub const __USE_XOPEN2K = @as(c_int, 1); -pub const __USE_XOPEN2K8 = @as(c_int, 1); -pub const _ATFILE_SOURCE = @as(c_int, 1); -pub const __WORDSIZE = @as(c_int, 64); -pub const __WORDSIZE_TIME64_COMPAT32 = @as(c_int, 1); -pub const __SYSCALL_WORDSIZE = @as(c_int, 64); -pub const __TIMESIZE = __WORDSIZE; -pub const __USE_TIME_BITS64 = @as(c_int, 1); -pub const __USE_MISC = @as(c_int, 1); -pub const __USE_ATFILE = @as(c_int, 1); -pub const __USE_FORTIFY_LEVEL = @as(c_int, 0); -pub const __GLIBC_USE_DEPRECATED_GETS = @as(c_int, 0); -pub const __GLIBC_USE_DEPRECATED_SCANF = @as(c_int, 0); -pub const __GLIBC_USE_C23_STRTOL = @as(c_int, 0); -pub const _STDC_PREDEF_H = @as(c_int, 1); -pub const __STDC_IEC_559__ = @as(c_int, 1); -pub const __STDC_IEC_60559_BFP__ = @as(c_long, 201404); -pub const __STDC_IEC_559_COMPLEX__ = @as(c_int, 1); -pub const __STDC_IEC_60559_COMPLEX__ = @as(c_long, 201404); -pub const __STDC_ISO_10646__ = @as(c_long, 201706); -pub const __GNU_LIBRARY__ = @as(c_int, 6); -pub const __GLIBC__ = @as(c_int, 2); -pub inline fn __GLIBC_PREREQ(maj: anytype, min: anytype) @TypeOf(((__GLIBC__ << @as(c_int, 16)) + __GLIBC_MINOR__) >= ((maj << @as(c_int, 16)) + min)) { - _ = &maj; - _ = &min; - return ((__GLIBC__ << @as(c_int, 16)) + __GLIBC_MINOR__) >= ((maj << @as(c_int, 16)) + min); -} -pub const _SYS_CDEFS_H = @as(c_int, 1); -pub const __glibc_has_attribute = @compileError("unable to translate macro: undefined identifier `__has_attribute`"); -// /usr/include/sys/cdefs.h:45:10 -pub inline fn __glibc_has_builtin(name: anytype) @TypeOf(__has_builtin(name)) { - _ = &name; - return __has_builtin(name); -} -pub const __glibc_has_extension = @compileError("unable to translate macro: undefined identifier `__has_extension`"); -// /usr/include/sys/cdefs.h:55:10 -pub const __LEAF = ""; -pub const __LEAF_ATTR = ""; -pub const __THROW = @compileError("unable to translate macro: undefined identifier `__nothrow__`"); -// /usr/include/sys/cdefs.h:79:11 -pub const __THROWNL = @compileError("unable to translate macro: undefined identifier `__nothrow__`"); -// /usr/include/sys/cdefs.h:80:11 -pub const __NTH = @compileError("unable to translate macro: undefined identifier `__nothrow__`"); -// /usr/include/sys/cdefs.h:81:11 -pub const __NTHNL = @compileError("unable to translate macro: undefined identifier `__nothrow__`"); -// /usr/include/sys/cdefs.h:82:11 -pub const __COLD = @compileError("unable to translate macro: undefined identifier `__cold__`"); -// /usr/include/sys/cdefs.h:102:11 -pub inline fn __P(args: anytype) @TypeOf(args) { - _ = &args; - return args; -} -pub inline fn __PMT(args: anytype) @TypeOf(args) { - _ = &args; - return args; -} -pub const __CONCAT = @compileError("unable to translate C expr: unexpected token '##'"); -// /usr/include/sys/cdefs.h:131:9 -pub const __STRING = @compileError("unable to translate C expr: unexpected token '#'"); -// /usr/include/sys/cdefs.h:132:9 -pub const __ptr_t = ?*anyopaque; -pub const __BEGIN_DECLS = ""; -pub const __END_DECLS = ""; -pub const __attribute_overloadable__ = @compileError("unable to translate macro: undefined identifier `__overloadable__`"); -// /usr/include/sys/cdefs.h:151:10 -pub inline fn __bos(ptr: anytype) @TypeOf(__builtin_object_size(ptr, __USE_FORTIFY_LEVEL > @as(c_int, 1))) { - _ = &ptr; - return __builtin_object_size(ptr, __USE_FORTIFY_LEVEL > @as(c_int, 1)); -} -pub inline fn __bos0(ptr: anytype) @TypeOf(__builtin_object_size(ptr, @as(c_int, 0))) { - _ = &ptr; - return __builtin_object_size(ptr, @as(c_int, 0)); -} -pub inline fn __glibc_objsize0(__o: anytype) @TypeOf(__bos0(__o)) { - _ = &__o; - return __bos0(__o); -} -pub inline fn __glibc_objsize(__o: anytype) @TypeOf(__bos(__o)) { - _ = &__o; - return __bos(__o); -} -pub const __warnattr = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:370:10 -pub const __errordecl = @compileError("unable to translate C expr: unexpected token 'extern'"); -// /usr/include/sys/cdefs.h:371:10 -pub const __flexarr = @compileError("unable to translate C expr: unexpected token '['"); -// /usr/include/sys/cdefs.h:379:10 -pub const __glibc_c99_flexarr_available = @as(c_int, 1); -pub const __REDIRECT = @compileError("unable to translate C expr: unexpected token '__asm__'"); -// /usr/include/sys/cdefs.h:410:10 -pub const __REDIRECT_NTH = @compileError("unable to translate C expr: unexpected token '__asm__'"); -// /usr/include/sys/cdefs.h:417:11 -pub const __REDIRECT_NTHNL = @compileError("unable to translate C expr: unexpected token '__asm__'"); -// /usr/include/sys/cdefs.h:419:11 -pub const __ASMNAME = @compileError("unable to translate C expr: unexpected token ','"); -// /usr/include/sys/cdefs.h:422:10 -pub inline fn __ASMNAME2(prefix: anytype, cname: anytype) @TypeOf(__STRING(prefix) ++ cname) { - _ = &prefix; - _ = &cname; - return __STRING(prefix) ++ cname; -} -pub const __REDIRECT_FORTIFY = __REDIRECT; -pub const __REDIRECT_FORTIFY_NTH = __REDIRECT_NTH; -pub const __attribute_malloc__ = @compileError("unable to translate macro: undefined identifier `__malloc__`"); -// /usr/include/sys/cdefs.h:452:10 -pub const __attribute_alloc_size__ = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:463:10 -pub const __attribute_alloc_align__ = @compileError("unable to translate macro: undefined identifier `__alloc_align__`"); -// /usr/include/sys/cdefs.h:469:10 -pub const __attribute_pure__ = @compileError("unable to translate macro: undefined identifier `__pure__`"); -// /usr/include/sys/cdefs.h:479:10 -pub const __attribute_const__ = @compileError("unable to translate C expr: unexpected token '__attribute__'"); -// /usr/include/sys/cdefs.h:486:10 -pub const __attribute_maybe_unused__ = @compileError("unable to translate macro: undefined identifier `__unused__`"); -// /usr/include/sys/cdefs.h:492:10 -pub const __attribute_used__ = @compileError("unable to translate macro: undefined identifier `__used__`"); -// /usr/include/sys/cdefs.h:501:10 -pub const __attribute_noinline__ = @compileError("unable to translate macro: undefined identifier `__noinline__`"); -// /usr/include/sys/cdefs.h:502:10 -pub const __attribute_deprecated__ = @compileError("unable to translate macro: undefined identifier `__deprecated__`"); -// /usr/include/sys/cdefs.h:510:10 -pub const __attribute_deprecated_msg__ = @compileError("unable to translate macro: undefined identifier `__deprecated__`"); -// /usr/include/sys/cdefs.h:520:10 -pub const __attribute_format_arg__ = @compileError("unable to translate macro: undefined identifier `__format_arg__`"); -// /usr/include/sys/cdefs.h:533:10 -pub const __attribute_format_strfmon__ = @compileError("unable to translate macro: undefined identifier `__format__`"); -// /usr/include/sys/cdefs.h:543:10 -pub const __attribute_nonnull__ = @compileError("unable to translate macro: undefined identifier `__nonnull__`"); -// /usr/include/sys/cdefs.h:555:11 -pub inline fn __nonnull(params: anytype) @TypeOf(__attribute_nonnull__(params)) { - _ = ¶ms; - return __attribute_nonnull__(params); -} -pub const __returns_nonnull = @compileError("unable to translate macro: undefined identifier `__returns_nonnull__`"); -// /usr/include/sys/cdefs.h:568:10 -pub const __attribute_warn_unused_result__ = @compileError("unable to translate macro: undefined identifier `__warn_unused_result__`"); -// /usr/include/sys/cdefs.h:577:10 -pub const __wur = ""; -pub const __always_inline = @compileError("unable to translate macro: undefined identifier `__always_inline__`"); -// /usr/include/sys/cdefs.h:595:10 -pub const __attribute_artificial__ = @compileError("unable to translate macro: undefined identifier `__artificial__`"); -// /usr/include/sys/cdefs.h:604:10 -pub const __extern_inline = @compileError("unable to translate macro: undefined identifier `__gnu_inline__`"); -// /usr/include/sys/cdefs.h:622:11 -pub const __extern_always_inline = @compileError("unable to translate macro: undefined identifier `__gnu_inline__`"); -// /usr/include/sys/cdefs.h:623:11 -pub const __fortify_function = __extern_always_inline ++ __attribute_artificial__; -pub const __restrict_arr = @compileError("unable to translate C expr: unexpected token '__restrict'"); -// /usr/include/sys/cdefs.h:666:10 -pub inline fn __glibc_unlikely(cond: anytype) @TypeOf(__builtin_expect(cond, @as(c_int, 0))) { - _ = &cond; - return __builtin_expect(cond, @as(c_int, 0)); -} -pub inline fn __glibc_likely(cond: anytype) @TypeOf(__builtin_expect(cond, @as(c_int, 1))) { - _ = &cond; - return __builtin_expect(cond, @as(c_int, 1)); -} -pub const __attribute_nonstring__ = ""; -pub const __attribute_copy__ = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:715:10 -pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI = @as(c_int, 0); -pub inline fn __LDBL_REDIR1(name: anytype, proto: anytype, alias: anytype) @TypeOf(name ++ proto) { - _ = &name; - _ = &proto; - _ = &alias; - return name ++ proto; -} -pub inline fn __LDBL_REDIR(name: anytype, proto: anytype) @TypeOf(name ++ proto) { - _ = &name; - _ = &proto; - return name ++ proto; -} -pub inline fn __LDBL_REDIR1_NTH(name: anytype, proto: anytype, alias: anytype) @TypeOf(name ++ proto ++ __THROW) { - _ = &name; - _ = &proto; - _ = &alias; - return name ++ proto ++ __THROW; -} -pub inline fn __LDBL_REDIR_NTH(name: anytype, proto: anytype) @TypeOf(name ++ proto ++ __THROW) { - _ = &name; - _ = &proto; - return name ++ proto ++ __THROW; -} -pub const __LDBL_REDIR2_DECL = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:792:10 -pub const __LDBL_REDIR_DECL = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:793:10 -pub inline fn __REDIRECT_LDBL(name: anytype, proto: anytype, alias: anytype) @TypeOf(__REDIRECT(name, proto, alias)) { - _ = &name; - _ = &proto; - _ = &alias; - return __REDIRECT(name, proto, alias); -} -pub inline fn __REDIRECT_NTH_LDBL(name: anytype, proto: anytype, alias: anytype) @TypeOf(__REDIRECT_NTH(name, proto, alias)) { - _ = &name; - _ = &proto; - _ = &alias; - return __REDIRECT_NTH(name, proto, alias); -} -pub const __glibc_macro_warning1 = @compileError("unable to translate macro: undefined identifier `_Pragma`"); -// /usr/include/sys/cdefs.h:807:10 -pub const __glibc_macro_warning = @compileError("unable to translate macro: undefined identifier `GCC`"); -// /usr/include/sys/cdefs.h:808:10 -pub const __HAVE_GENERIC_SELECTION = @as(c_int, 1); -pub const __fortified_attr_access = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:853:11 -pub const __attr_access = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:854:11 -pub const __attr_access_none = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:855:11 -pub const __attr_dealloc = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/sys/cdefs.h:865:10 -pub const __attr_dealloc_free = ""; -pub const __attribute_returns_twice__ = @compileError("unable to translate macro: undefined identifier `__returns_twice__`"); -// /usr/include/sys/cdefs.h:872:10 -pub const __attribute_struct_may_alias__ = @compileError("unable to translate macro: undefined identifier `__may_alias__`"); -// /usr/include/sys/cdefs.h:881:10 -pub const __stub___compat_bdflush = ""; -pub const __stub_chflags = ""; -pub const __stub_fchflags = ""; -pub const __stub_gtty = ""; -pub const __stub_revoke = ""; -pub const __stub_setlogin = ""; -pub const __stub_sigreturn = ""; -pub const __stub_stty = ""; -pub const __GLIBC_USE_LIB_EXT2 = @as(c_int, 0); -pub const __GLIBC_USE_IEC_60559_BFP_EXT = @as(c_int, 0); -pub const __GLIBC_USE_IEC_60559_BFP_EXT_C23 = @as(c_int, 0); -pub const __GLIBC_USE_IEC_60559_EXT = @as(c_int, 0); -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT = @as(c_int, 0); -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C23 = @as(c_int, 0); -pub const __GLIBC_USE_IEC_60559_TYPES_EXT = @as(c_int, 0); -pub const _BITS_TYPES_H = @as(c_int, 1); -pub const __S16_TYPE = c_short; -pub const __U16_TYPE = c_ushort; -pub const __S32_TYPE = c_int; -pub const __U32_TYPE = c_uint; -pub const __SLONGWORD_TYPE = c_long; -pub const __ULONGWORD_TYPE = c_ulong; -pub const __SQUAD_TYPE = c_long; -pub const __UQUAD_TYPE = c_ulong; -pub const __SWORD_TYPE = c_long; -pub const __UWORD_TYPE = c_ulong; -pub const __SLONG32_TYPE = c_int; -pub const __ULONG32_TYPE = c_uint; -pub const __S64_TYPE = c_long; -pub const __U64_TYPE = c_ulong; -pub const __STD_TYPE = @compileError("unable to translate C expr: unexpected token 'typedef'"); -// /usr/include/bits/types.h:137:10 -pub const _BITS_TYPESIZES_H = @as(c_int, 1); -pub const __SYSCALL_SLONG_TYPE = __SLONGWORD_TYPE; -pub const __SYSCALL_ULONG_TYPE = __ULONGWORD_TYPE; -pub const __DEV_T_TYPE = __UQUAD_TYPE; -pub const __UID_T_TYPE = __U32_TYPE; -pub const __GID_T_TYPE = __U32_TYPE; -pub const __INO_T_TYPE = __SYSCALL_ULONG_TYPE; -pub const __INO64_T_TYPE = __UQUAD_TYPE; -pub const __MODE_T_TYPE = __U32_TYPE; -pub const __NLINK_T_TYPE = __SYSCALL_ULONG_TYPE; -pub const __FSWORD_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __OFF_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __OFF64_T_TYPE = __SQUAD_TYPE; -pub const __PID_T_TYPE = __S32_TYPE; -pub const __RLIM_T_TYPE = __SYSCALL_ULONG_TYPE; -pub const __RLIM64_T_TYPE = __UQUAD_TYPE; -pub const __BLKCNT_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __BLKCNT64_T_TYPE = __SQUAD_TYPE; -pub const __FSBLKCNT_T_TYPE = __SYSCALL_ULONG_TYPE; -pub const __FSBLKCNT64_T_TYPE = __UQUAD_TYPE; -pub const __FSFILCNT_T_TYPE = __SYSCALL_ULONG_TYPE; -pub const __FSFILCNT64_T_TYPE = __UQUAD_TYPE; -pub const __ID_T_TYPE = __U32_TYPE; -pub const __CLOCK_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __TIME_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __USECONDS_T_TYPE = __U32_TYPE; -pub const __SUSECONDS_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __SUSECONDS64_T_TYPE = __SQUAD_TYPE; -pub const __DADDR_T_TYPE = __S32_TYPE; -pub const __KEY_T_TYPE = __S32_TYPE; -pub const __CLOCKID_T_TYPE = __S32_TYPE; -pub const __TIMER_T_TYPE = ?*anyopaque; -pub const __BLKSIZE_T_TYPE = __SYSCALL_SLONG_TYPE; -pub const __FSID_T_TYPE = @compileError("unable to translate macro: undefined identifier `__val`"); -// /usr/include/bits/typesizes.h:73:9 -pub const __SSIZE_T_TYPE = __SWORD_TYPE; -pub const __CPU_MASK_TYPE = __SYSCALL_ULONG_TYPE; -pub const __OFF_T_MATCHES_OFF64_T = @as(c_int, 1); -pub const __INO_T_MATCHES_INO64_T = @as(c_int, 1); -pub const __RLIM_T_MATCHES_RLIM64_T = @as(c_int, 1); -pub const __STATFS_MATCHES_STATFS64 = @as(c_int, 1); -pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 = @as(c_int, 1); -pub const __FD_SETSIZE = @as(c_int, 1024); -pub const _BITS_TIME64_H = @as(c_int, 1); -pub const __TIME64_T_TYPE = __TIME_T_TYPE; -pub const _BITS_LIBM_SIMD_DECL_STUBS_H = @as(c_int, 1); -pub const __DECL_SIMD_cos = ""; -pub const __DECL_SIMD_cosf = ""; -pub const __DECL_SIMD_cosl = ""; -pub const __DECL_SIMD_cosf16 = ""; -pub const __DECL_SIMD_cosf32 = ""; -pub const __DECL_SIMD_cosf64 = ""; -pub const __DECL_SIMD_cosf128 = ""; -pub const __DECL_SIMD_cosf32x = ""; -pub const __DECL_SIMD_cosf64x = ""; -pub const __DECL_SIMD_cosf128x = ""; -pub const __DECL_SIMD_sin = ""; -pub const __DECL_SIMD_sinf = ""; -pub const __DECL_SIMD_sinl = ""; -pub const __DECL_SIMD_sinf16 = ""; -pub const __DECL_SIMD_sinf32 = ""; -pub const __DECL_SIMD_sinf64 = ""; -pub const __DECL_SIMD_sinf128 = ""; -pub const __DECL_SIMD_sinf32x = ""; -pub const __DECL_SIMD_sinf64x = ""; -pub const __DECL_SIMD_sinf128x = ""; -pub const __DECL_SIMD_sincos = ""; -pub const __DECL_SIMD_sincosf = ""; -pub const __DECL_SIMD_sincosl = ""; -pub const __DECL_SIMD_sincosf16 = ""; -pub const __DECL_SIMD_sincosf32 = ""; -pub const __DECL_SIMD_sincosf64 = ""; -pub const __DECL_SIMD_sincosf128 = ""; -pub const __DECL_SIMD_sincosf32x = ""; -pub const __DECL_SIMD_sincosf64x = ""; -pub const __DECL_SIMD_sincosf128x = ""; -pub const __DECL_SIMD_log = ""; -pub const __DECL_SIMD_logf = ""; -pub const __DECL_SIMD_logl = ""; -pub const __DECL_SIMD_logf16 = ""; -pub const __DECL_SIMD_logf32 = ""; -pub const __DECL_SIMD_logf64 = ""; -pub const __DECL_SIMD_logf128 = ""; -pub const __DECL_SIMD_logf32x = ""; -pub const __DECL_SIMD_logf64x = ""; -pub const __DECL_SIMD_logf128x = ""; -pub const __DECL_SIMD_exp = ""; -pub const __DECL_SIMD_expf = ""; -pub const __DECL_SIMD_expl = ""; -pub const __DECL_SIMD_expf16 = ""; -pub const __DECL_SIMD_expf32 = ""; -pub const __DECL_SIMD_expf64 = ""; -pub const __DECL_SIMD_expf128 = ""; -pub const __DECL_SIMD_expf32x = ""; -pub const __DECL_SIMD_expf64x = ""; -pub const __DECL_SIMD_expf128x = ""; -pub const __DECL_SIMD_pow = ""; -pub const __DECL_SIMD_powf = ""; -pub const __DECL_SIMD_powl = ""; -pub const __DECL_SIMD_powf16 = ""; -pub const __DECL_SIMD_powf32 = ""; -pub const __DECL_SIMD_powf64 = ""; -pub const __DECL_SIMD_powf128 = ""; -pub const __DECL_SIMD_powf32x = ""; -pub const __DECL_SIMD_powf64x = ""; -pub const __DECL_SIMD_powf128x = ""; -pub const __DECL_SIMD_acos = ""; -pub const __DECL_SIMD_acosf = ""; -pub const __DECL_SIMD_acosl = ""; -pub const __DECL_SIMD_acosf16 = ""; -pub const __DECL_SIMD_acosf32 = ""; -pub const __DECL_SIMD_acosf64 = ""; -pub const __DECL_SIMD_acosf128 = ""; -pub const __DECL_SIMD_acosf32x = ""; -pub const __DECL_SIMD_acosf64x = ""; -pub const __DECL_SIMD_acosf128x = ""; -pub const __DECL_SIMD_atan = ""; -pub const __DECL_SIMD_atanf = ""; -pub const __DECL_SIMD_atanl = ""; -pub const __DECL_SIMD_atanf16 = ""; -pub const __DECL_SIMD_atanf32 = ""; -pub const __DECL_SIMD_atanf64 = ""; -pub const __DECL_SIMD_atanf128 = ""; -pub const __DECL_SIMD_atanf32x = ""; -pub const __DECL_SIMD_atanf64x = ""; -pub const __DECL_SIMD_atanf128x = ""; -pub const __DECL_SIMD_asin = ""; -pub const __DECL_SIMD_asinf = ""; -pub const __DECL_SIMD_asinl = ""; -pub const __DECL_SIMD_asinf16 = ""; -pub const __DECL_SIMD_asinf32 = ""; -pub const __DECL_SIMD_asinf64 = ""; -pub const __DECL_SIMD_asinf128 = ""; -pub const __DECL_SIMD_asinf32x = ""; -pub const __DECL_SIMD_asinf64x = ""; -pub const __DECL_SIMD_asinf128x = ""; -pub const __DECL_SIMD_hypot = ""; -pub const __DECL_SIMD_hypotf = ""; -pub const __DECL_SIMD_hypotl = ""; -pub const __DECL_SIMD_hypotf16 = ""; -pub const __DECL_SIMD_hypotf32 = ""; -pub const __DECL_SIMD_hypotf64 = ""; -pub const __DECL_SIMD_hypotf128 = ""; -pub const __DECL_SIMD_hypotf32x = ""; -pub const __DECL_SIMD_hypotf64x = ""; -pub const __DECL_SIMD_hypotf128x = ""; -pub const __DECL_SIMD_exp2 = ""; -pub const __DECL_SIMD_exp2f = ""; -pub const __DECL_SIMD_exp2l = ""; -pub const __DECL_SIMD_exp2f16 = ""; -pub const __DECL_SIMD_exp2f32 = ""; -pub const __DECL_SIMD_exp2f64 = ""; -pub const __DECL_SIMD_exp2f128 = ""; -pub const __DECL_SIMD_exp2f32x = ""; -pub const __DECL_SIMD_exp2f64x = ""; -pub const __DECL_SIMD_exp2f128x = ""; -pub const __DECL_SIMD_exp10 = ""; -pub const __DECL_SIMD_exp10f = ""; -pub const __DECL_SIMD_exp10l = ""; -pub const __DECL_SIMD_exp10f16 = ""; -pub const __DECL_SIMD_exp10f32 = ""; -pub const __DECL_SIMD_exp10f64 = ""; -pub const __DECL_SIMD_exp10f128 = ""; -pub const __DECL_SIMD_exp10f32x = ""; -pub const __DECL_SIMD_exp10f64x = ""; -pub const __DECL_SIMD_exp10f128x = ""; -pub const __DECL_SIMD_cosh = ""; -pub const __DECL_SIMD_coshf = ""; -pub const __DECL_SIMD_coshl = ""; -pub const __DECL_SIMD_coshf16 = ""; -pub const __DECL_SIMD_coshf32 = ""; -pub const __DECL_SIMD_coshf64 = ""; -pub const __DECL_SIMD_coshf128 = ""; -pub const __DECL_SIMD_coshf32x = ""; -pub const __DECL_SIMD_coshf64x = ""; -pub const __DECL_SIMD_coshf128x = ""; -pub const __DECL_SIMD_expm1 = ""; -pub const __DECL_SIMD_expm1f = ""; -pub const __DECL_SIMD_expm1l = ""; -pub const __DECL_SIMD_expm1f16 = ""; -pub const __DECL_SIMD_expm1f32 = ""; -pub const __DECL_SIMD_expm1f64 = ""; -pub const __DECL_SIMD_expm1f128 = ""; -pub const __DECL_SIMD_expm1f32x = ""; -pub const __DECL_SIMD_expm1f64x = ""; -pub const __DECL_SIMD_expm1f128x = ""; -pub const __DECL_SIMD_sinh = ""; -pub const __DECL_SIMD_sinhf = ""; -pub const __DECL_SIMD_sinhl = ""; -pub const __DECL_SIMD_sinhf16 = ""; -pub const __DECL_SIMD_sinhf32 = ""; -pub const __DECL_SIMD_sinhf64 = ""; -pub const __DECL_SIMD_sinhf128 = ""; -pub const __DECL_SIMD_sinhf32x = ""; -pub const __DECL_SIMD_sinhf64x = ""; -pub const __DECL_SIMD_sinhf128x = ""; -pub const __DECL_SIMD_cbrt = ""; -pub const __DECL_SIMD_cbrtf = ""; -pub const __DECL_SIMD_cbrtl = ""; -pub const __DECL_SIMD_cbrtf16 = ""; -pub const __DECL_SIMD_cbrtf32 = ""; -pub const __DECL_SIMD_cbrtf64 = ""; -pub const __DECL_SIMD_cbrtf128 = ""; -pub const __DECL_SIMD_cbrtf32x = ""; -pub const __DECL_SIMD_cbrtf64x = ""; -pub const __DECL_SIMD_cbrtf128x = ""; -pub const __DECL_SIMD_atan2 = ""; -pub const __DECL_SIMD_atan2f = ""; -pub const __DECL_SIMD_atan2l = ""; -pub const __DECL_SIMD_atan2f16 = ""; -pub const __DECL_SIMD_atan2f32 = ""; -pub const __DECL_SIMD_atan2f64 = ""; -pub const __DECL_SIMD_atan2f128 = ""; -pub const __DECL_SIMD_atan2f32x = ""; -pub const __DECL_SIMD_atan2f64x = ""; -pub const __DECL_SIMD_atan2f128x = ""; -pub const __DECL_SIMD_log10 = ""; -pub const __DECL_SIMD_log10f = ""; -pub const __DECL_SIMD_log10l = ""; -pub const __DECL_SIMD_log10f16 = ""; -pub const __DECL_SIMD_log10f32 = ""; -pub const __DECL_SIMD_log10f64 = ""; -pub const __DECL_SIMD_log10f128 = ""; -pub const __DECL_SIMD_log10f32x = ""; -pub const __DECL_SIMD_log10f64x = ""; -pub const __DECL_SIMD_log10f128x = ""; -pub const __DECL_SIMD_log2 = ""; -pub const __DECL_SIMD_log2f = ""; -pub const __DECL_SIMD_log2l = ""; -pub const __DECL_SIMD_log2f16 = ""; -pub const __DECL_SIMD_log2f32 = ""; -pub const __DECL_SIMD_log2f64 = ""; -pub const __DECL_SIMD_log2f128 = ""; -pub const __DECL_SIMD_log2f32x = ""; -pub const __DECL_SIMD_log2f64x = ""; -pub const __DECL_SIMD_log2f128x = ""; -pub const __DECL_SIMD_log1p = ""; -pub const __DECL_SIMD_log1pf = ""; -pub const __DECL_SIMD_log1pl = ""; -pub const __DECL_SIMD_log1pf16 = ""; -pub const __DECL_SIMD_log1pf32 = ""; -pub const __DECL_SIMD_log1pf64 = ""; -pub const __DECL_SIMD_log1pf128 = ""; -pub const __DECL_SIMD_log1pf32x = ""; -pub const __DECL_SIMD_log1pf64x = ""; -pub const __DECL_SIMD_log1pf128x = ""; -pub const __DECL_SIMD_atanh = ""; -pub const __DECL_SIMD_atanhf = ""; -pub const __DECL_SIMD_atanhl = ""; -pub const __DECL_SIMD_atanhf16 = ""; -pub const __DECL_SIMD_atanhf32 = ""; -pub const __DECL_SIMD_atanhf64 = ""; -pub const __DECL_SIMD_atanhf128 = ""; -pub const __DECL_SIMD_atanhf32x = ""; -pub const __DECL_SIMD_atanhf64x = ""; -pub const __DECL_SIMD_atanhf128x = ""; -pub const __DECL_SIMD_acosh = ""; -pub const __DECL_SIMD_acoshf = ""; -pub const __DECL_SIMD_acoshl = ""; -pub const __DECL_SIMD_acoshf16 = ""; -pub const __DECL_SIMD_acoshf32 = ""; -pub const __DECL_SIMD_acoshf64 = ""; -pub const __DECL_SIMD_acoshf128 = ""; -pub const __DECL_SIMD_acoshf32x = ""; -pub const __DECL_SIMD_acoshf64x = ""; -pub const __DECL_SIMD_acoshf128x = ""; -pub const __DECL_SIMD_erf = ""; -pub const __DECL_SIMD_erff = ""; -pub const __DECL_SIMD_erfl = ""; -pub const __DECL_SIMD_erff16 = ""; -pub const __DECL_SIMD_erff32 = ""; -pub const __DECL_SIMD_erff64 = ""; -pub const __DECL_SIMD_erff128 = ""; -pub const __DECL_SIMD_erff32x = ""; -pub const __DECL_SIMD_erff64x = ""; -pub const __DECL_SIMD_erff128x = ""; -pub const __DECL_SIMD_tanh = ""; -pub const __DECL_SIMD_tanhf = ""; -pub const __DECL_SIMD_tanhl = ""; -pub const __DECL_SIMD_tanhf16 = ""; -pub const __DECL_SIMD_tanhf32 = ""; -pub const __DECL_SIMD_tanhf64 = ""; -pub const __DECL_SIMD_tanhf128 = ""; -pub const __DECL_SIMD_tanhf32x = ""; -pub const __DECL_SIMD_tanhf64x = ""; -pub const __DECL_SIMD_tanhf128x = ""; -pub const __DECL_SIMD_asinh = ""; -pub const __DECL_SIMD_asinhf = ""; -pub const __DECL_SIMD_asinhl = ""; -pub const __DECL_SIMD_asinhf16 = ""; -pub const __DECL_SIMD_asinhf32 = ""; -pub const __DECL_SIMD_asinhf64 = ""; -pub const __DECL_SIMD_asinhf128 = ""; -pub const __DECL_SIMD_asinhf32x = ""; -pub const __DECL_SIMD_asinhf64x = ""; -pub const __DECL_SIMD_asinhf128x = ""; -pub const __DECL_SIMD_erfc = ""; -pub const __DECL_SIMD_erfcf = ""; -pub const __DECL_SIMD_erfcl = ""; -pub const __DECL_SIMD_erfcf16 = ""; -pub const __DECL_SIMD_erfcf32 = ""; -pub const __DECL_SIMD_erfcf64 = ""; -pub const __DECL_SIMD_erfcf128 = ""; -pub const __DECL_SIMD_erfcf32x = ""; -pub const __DECL_SIMD_erfcf64x = ""; -pub const __DECL_SIMD_erfcf128x = ""; -pub const __DECL_SIMD_tan = ""; -pub const __DECL_SIMD_tanf = ""; -pub const __DECL_SIMD_tanl = ""; -pub const __DECL_SIMD_tanf16 = ""; -pub const __DECL_SIMD_tanf32 = ""; -pub const __DECL_SIMD_tanf64 = ""; -pub const __DECL_SIMD_tanf128 = ""; -pub const __DECL_SIMD_tanf32x = ""; -pub const __DECL_SIMD_tanf64x = ""; -pub const __DECL_SIMD_tanf128x = ""; -pub const _BITS_FLOATN_H = ""; -pub const __HAVE_FLOAT128 = @as(c_int, 0); -pub const __HAVE_DISTINCT_FLOAT128 = @as(c_int, 0); -pub const __HAVE_FLOAT64X = @as(c_int, 1); -pub const __HAVE_FLOAT64X_LONG_DOUBLE = @as(c_int, 1); -pub const _BITS_FLOATN_COMMON_H = ""; -pub const __HAVE_FLOAT16 = @as(c_int, 0); -pub const __HAVE_FLOAT32 = @as(c_int, 1); -pub const __HAVE_FLOAT64 = @as(c_int, 1); -pub const __HAVE_FLOAT32X = @as(c_int, 1); -pub const __HAVE_FLOAT128X = @as(c_int, 0); -pub const __HAVE_DISTINCT_FLOAT16 = __HAVE_FLOAT16; -pub const __HAVE_DISTINCT_FLOAT32 = @as(c_int, 0); -pub const __HAVE_DISTINCT_FLOAT64 = @as(c_int, 0); -pub const __HAVE_DISTINCT_FLOAT32X = @as(c_int, 0); -pub const __HAVE_DISTINCT_FLOAT64X = @as(c_int, 0); -pub const __HAVE_DISTINCT_FLOAT128X = __HAVE_FLOAT128X; -pub const __HAVE_FLOAT128_UNLIKE_LDBL = (__HAVE_DISTINCT_FLOAT128 != 0) and (__LDBL_MANT_DIG__ != @as(c_int, 113)); -pub const __HAVE_FLOATN_NOT_TYPEDEF = @as(c_int, 0); -pub const __f32 = @import("std").zig.c_translation.Macros.F_SUFFIX; -pub inline fn __f64(x: anytype) @TypeOf(x) { - _ = &x; - return x; -} -pub inline fn __f32x(x: anytype) @TypeOf(x) { - _ = &x; - return x; -} -pub const __f64x = @import("std").zig.c_translation.Macros.L_SUFFIX; -pub const __CFLOAT32 = @compileError("unable to translate: TODO _Complex"); -// /usr/include/bits/floatn-common.h:149:12 -pub const __CFLOAT64 = @compileError("unable to translate: TODO _Complex"); -// /usr/include/bits/floatn-common.h:160:13 -pub const __CFLOAT32X = @compileError("unable to translate: TODO _Complex"); -// /usr/include/bits/floatn-common.h:169:12 -pub const __CFLOAT64X = @compileError("unable to translate: TODO _Complex"); -// /usr/include/bits/floatn-common.h:178:13 -pub inline fn __builtin_huge_valf32() @TypeOf(__builtin_huge_valf()) { - return __builtin_huge_valf(); -} -pub inline fn __builtin_inff32() @TypeOf(__builtin_inff()) { - return __builtin_inff(); -} -pub inline fn __builtin_nanf32(x: anytype) @TypeOf(__builtin_nanf(x)) { - _ = &x; - return __builtin_nanf(x); -} -pub const __builtin_nansf32 = @compileError("unable to translate macro: undefined identifier `__builtin_nansf`"); -// /usr/include/bits/floatn-common.h:221:12 -pub const __builtin_huge_valf64 = @compileError("unable to translate macro: undefined identifier `__builtin_huge_val`"); -// /usr/include/bits/floatn-common.h:255:13 -pub const __builtin_inff64 = @compileError("unable to translate macro: undefined identifier `__builtin_inf`"); -// /usr/include/bits/floatn-common.h:256:13 -pub const __builtin_nanf64 = @compileError("unable to translate macro: undefined identifier `__builtin_nan`"); -// /usr/include/bits/floatn-common.h:257:13 -pub const __builtin_nansf64 = @compileError("unable to translate macro: undefined identifier `__builtin_nans`"); -// /usr/include/bits/floatn-common.h:258:13 -pub const __builtin_huge_valf32x = @compileError("unable to translate macro: undefined identifier `__builtin_huge_val`"); -// /usr/include/bits/floatn-common.h:272:12 -pub const __builtin_inff32x = @compileError("unable to translate macro: undefined identifier `__builtin_inf`"); -// /usr/include/bits/floatn-common.h:273:12 -pub const __builtin_nanf32x = @compileError("unable to translate macro: undefined identifier `__builtin_nan`"); -// /usr/include/bits/floatn-common.h:274:12 -pub const __builtin_nansf32x = @compileError("unable to translate macro: undefined identifier `__builtin_nans`"); -// /usr/include/bits/floatn-common.h:275:12 -pub const __builtin_huge_valf64x = @compileError("unable to translate macro: undefined identifier `__builtin_huge_vall`"); -// /usr/include/bits/floatn-common.h:289:13 -pub const __builtin_inff64x = @compileError("unable to translate macro: undefined identifier `__builtin_infl`"); -// /usr/include/bits/floatn-common.h:290:13 -pub const __builtin_nanf64x = @compileError("unable to translate macro: undefined identifier `__builtin_nanl`"); -// /usr/include/bits/floatn-common.h:291:13 -pub const __builtin_nansf64x = @compileError("unable to translate macro: undefined identifier `__builtin_nansl`"); -// /usr/include/bits/floatn-common.h:292:13 -pub const HUGE_VAL = @compileError("unable to translate macro: undefined identifier `__builtin_huge_val`"); -// /usr/include/math.h:48:10 -pub const HUGE_VALF = __builtin_huge_valf(); -pub const HUGE_VALL = @compileError("unable to translate macro: undefined identifier `__builtin_huge_vall`"); -// /usr/include/math.h:60:11 -pub const INFINITY = __builtin_inff(); -pub const NAN = __builtin_nanf(""); -pub const __GLIBC_FLT_EVAL_METHOD = @compileError("unable to translate macro: undefined identifier `__FLT_EVAL_METHOD__`"); -// /usr/include/bits/flt-eval-method.h:27:11 -pub const __FP_LOGB0_IS_MIN = @as(c_int, 1); -pub const __FP_LOGBNAN_IS_MIN = @as(c_int, 1); -pub const FP_ILOGB0 = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1); -pub const FP_ILOGBNAN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1); -pub const __SIMD_DECL = @compileError("unable to translate macro: undefined identifier `__DECL_SIMD_`"); -// /usr/include/math.h:276:9 -pub inline fn __MATHCALL_VEC(function: anytype, suffix: anytype, args: anytype) @TypeOf(__SIMD_DECL(__MATH_PRECNAME(function, suffix)) ++ __MATHCALL(function, suffix, args)) { - _ = &function; - _ = &suffix; - _ = &args; - return __SIMD_DECL(__MATH_PRECNAME(function, suffix)) ++ __MATHCALL(function, suffix, args); -} -pub inline fn __MATHDECL_VEC(@"type": anytype, function: anytype, suffix: anytype, args: anytype) @TypeOf(__SIMD_DECL(__MATH_PRECNAME(function, suffix)) ++ __MATHDECL(@"type", function, suffix, args)) { - _ = &@"type"; - _ = &function; - _ = &suffix; - _ = &args; - return __SIMD_DECL(__MATH_PRECNAME(function, suffix)) ++ __MATHDECL(@"type", function, suffix, args); -} -pub inline fn __MATHCALL(function: anytype, suffix: anytype, args: anytype) @TypeOf(__MATHDECL(_Mdouble_, function, suffix, args)) { - _ = &function; - _ = &suffix; - _ = &args; - return __MATHDECL(_Mdouble_, function, suffix, args); -} -pub const __MATHDECL = @compileError("unable to translate macro: undefined identifier `__`"); -// /usr/include/math.h:288:9 -pub inline fn __MATHCALLX(function: anytype, suffix: anytype, args: anytype, attrib: anytype) @TypeOf(__MATHDECLX(_Mdouble_, function, suffix, args, attrib)) { - _ = &function; - _ = &suffix; - _ = &args; - _ = &attrib; - return __MATHDECLX(_Mdouble_, function, suffix, args, attrib); -} -pub const __MATHDECLX = @compileError("unable to translate macro: undefined identifier `__`"); -// /usr/include/math.h:293:9 -pub const __MATHDECL_1_IMPL = @compileError("unable to translate C expr: unexpected token 'extern'"); -// /usr/include/math.h:296:9 -pub inline fn __MATHDECL_1(@"type": anytype, function: anytype, suffix: anytype, args: anytype) @TypeOf(__MATHDECL_1_IMPL(@"type", function, suffix, args)) { - _ = &@"type"; - _ = &function; - _ = &suffix; - _ = &args; - return __MATHDECL_1_IMPL(@"type", function, suffix, args); -} -pub inline fn __MATHDECL_ALIAS(@"type": anytype, function: anytype, suffix: anytype, args: anytype, alias: anytype) @TypeOf(__MATHDECL_1(@"type", function, suffix, args)) { - _ = &@"type"; - _ = &function; - _ = &suffix; - _ = &args; - _ = &alias; - return __MATHDECL_1(@"type", function, suffix, args); -} -pub const __MATHREDIR = @compileError("unable to translate C expr: unexpected token 'extern'"); -// /usr/include/math.h:305:9 -pub const _Mdouble_ = f64; -pub inline fn __MATH_PRECNAME(name: anytype, r: anytype) @TypeOf(__CONCAT(name, r)) { - _ = &name; - _ = &r; - return __CONCAT(name, r); -} -pub const __MATH_DECLARING_DOUBLE = @as(c_int, 1); -pub const __MATH_DECLARING_FLOATN = @as(c_int, 0); -pub const __MATH_DECLARE_LDOUBLE = @as(c_int, 1); -pub const __MATHCALL_NARROW_ARGS_1 = @compileError("unable to translate macro: undefined identifier `_Marg_`"); -// /usr/include/math.h:550:9 -pub const __MATHCALL_NARROW_ARGS_2 = @compileError("unable to translate macro: undefined identifier `_Marg_`"); -// /usr/include/math.h:551:9 -pub const __MATHCALL_NARROW_ARGS_3 = @compileError("unable to translate macro: undefined identifier `_Marg_`"); -// /usr/include/math.h:552:9 -pub const __MATHCALL_NARROW_NORMAL = @compileError("unable to translate macro: undefined identifier `_Mret_`"); -// /usr/include/math.h:553:9 -pub const __MATHCALL_NARROW_REDIR = @compileError("unable to translate macro: undefined identifier `_Mret_`"); -// /usr/include/math.h:555:9 -pub inline fn __MATHCALL_NARROW(func: anytype, redir: anytype, nargs: anytype) @TypeOf(__MATHCALL_NARROW_NORMAL(func, nargs)) { - _ = &func; - _ = &redir; - _ = &nargs; - return __MATHCALL_NARROW_NORMAL(func, nargs); -} -pub const __MATH_TG = @compileError("unable to translate macro: undefined identifier `f`"); -// /usr/include/math.h:922:10 -pub const fpclassify = @compileError("unable to translate macro: undefined identifier `__builtin_fpclassify`"); -// /usr/include/math.h:967:11 -pub inline fn signbit(x: anytype) @TypeOf(__builtin_signbit(x)) { - _ = &x; - return __builtin_signbit(x); -} -pub const isfinite = @compileError("unable to translate macro: undefined identifier `__builtin_isfinite`"); -// /usr/include/math.h:994:11 -pub const isnormal = @compileError("unable to translate macro: undefined identifier `__builtin_isnormal`"); -// /usr/include/math.h:1002:11 -pub const MATH_ERRNO = @as(c_int, 1); -pub const MATH_ERREXCEPT = @as(c_int, 2); -pub const math_errhandling = MATH_ERRNO | MATH_ERREXCEPT; -pub const M_E = @as(f64, 2.7182818284590452354); -pub const M_LOG2E = @as(f64, 1.4426950408889634074); -pub const M_LOG10E = @as(f64, 0.43429448190325182765); -pub const M_LN2 = @as(f64, 0.69314718055994530942); -pub const M_LN10 = @as(f64, 2.30258509299404568402); -pub const M_PI = @as(f64, 3.14159265358979323846); -pub const M_PI_2 = @as(f64, 1.57079632679489661923); -pub const M_PI_4 = @as(f64, 0.78539816339744830962); -pub const M_1_PI = @as(f64, 0.31830988618379067154); -pub const M_2_PI = @as(f64, 0.63661977236758134308); -pub const M_2_SQRTPI = @as(f64, 1.12837916709551257390); -pub const M_SQRT2 = @as(f64, 1.41421356237309504880); -pub const M_SQRT1_2 = @as(f64, 0.70710678118654752440); -pub const isgreater = @compileError("unable to translate macro: undefined identifier `__builtin_isgreater`"); -// /usr/include/math.h:1306:11 -pub const isgreaterequal = @compileError("unable to translate macro: undefined identifier `__builtin_isgreaterequal`"); -// /usr/include/math.h:1307:11 -pub const isless = @compileError("unable to translate macro: undefined identifier `__builtin_isless`"); -// /usr/include/math.h:1308:11 -pub const islessequal = @compileError("unable to translate macro: undefined identifier `__builtin_islessequal`"); -// /usr/include/math.h:1309:11 -pub const islessgreater = @compileError("unable to translate macro: undefined identifier `__builtin_islessgreater`"); -// /usr/include/math.h:1310:11 -pub const isunordered = @compileError("unable to translate macro: undefined identifier `__builtin_isunordered`"); -// /usr/include/math.h:1311:11 -pub const _STDIO_H = @as(c_int, 1); -pub const __need_size_t = ""; -pub const __need_NULL = ""; -pub const _SIZE_T = ""; -pub const NULL = @import("std").zig.c_translation.cast(?*anyopaque, @as(c_int, 0)); -pub const _____fpos_t_defined = @as(c_int, 1); -pub const ____mbstate_t_defined = @as(c_int, 1); -pub const _____fpos64_t_defined = @as(c_int, 1); -pub const ____FILE_defined = @as(c_int, 1); -pub const __FILE_defined = @as(c_int, 1); -pub const __struct_FILE_defined = @as(c_int, 1); -pub const __getc_unlocked_body = @compileError("TODO postfix inc/dec expr"); -// /usr/include/bits/types/struct_FILE.h:102:9 -pub const __putc_unlocked_body = @compileError("TODO postfix inc/dec expr"); -// /usr/include/bits/types/struct_FILE.h:106:9 -pub const _IO_EOF_SEEN = @as(c_int, 0x0010); -pub inline fn __feof_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_EOF_SEEN) != @as(c_int, 0)) { - _ = &_fp; - return (_fp.*._flags & _IO_EOF_SEEN) != @as(c_int, 0); -} -pub const _IO_ERR_SEEN = @as(c_int, 0x0020); -pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { - _ = &_fp; - return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); -} -pub const _IO_USER_LOCK = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hex); -pub const __cookie_io_functions_t_defined = @as(c_int, 1); -pub const _VA_LIST_DEFINED = ""; -pub const __off_t_defined = ""; -pub const __ssize_t_defined = ""; -pub const _IOFBF = @as(c_int, 0); -pub const _IOLBF = @as(c_int, 1); -pub const _IONBF = @as(c_int, 2); -pub const BUFSIZ = @as(c_int, 8192); -pub const EOF = -@as(c_int, 1); -pub const SEEK_SET = @as(c_int, 0); -pub const SEEK_CUR = @as(c_int, 1); -pub const SEEK_END = @as(c_int, 2); -pub const P_tmpdir = "/tmp"; -pub const L_tmpnam = @as(c_int, 20); -pub const TMP_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 238328, .decimal); -pub const _BITS_STDIO_LIM_H = @as(c_int, 1); -pub const FILENAME_MAX = @as(c_int, 4096); -pub const L_ctermid = @as(c_int, 9); -pub const FOPEN_MAX = @as(c_int, 16); -pub const __attr_dealloc_fclose = __attr_dealloc(fclose, @as(c_int, 1)); -pub const __need_wchar_t = ""; -pub const _WCHAR_T = ""; -pub const _STDLIB_H = @as(c_int, 1); -pub const WNOHANG = @as(c_int, 1); -pub const WUNTRACED = @as(c_int, 2); -pub const WSTOPPED = @as(c_int, 2); -pub const WEXITED = @as(c_int, 4); -pub const WCONTINUED = @as(c_int, 8); -pub const WNOWAIT = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x01000000, .hex); -pub const __WNOTHREAD = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x20000000, .hex); -pub const __WALL = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x40000000, .hex); -pub const __WCLONE = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80000000, .hex); -pub inline fn __WEXITSTATUS(status: anytype) @TypeOf((status & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xff00, .hex)) >> @as(c_int, 8)) { - _ = &status; - return (status & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xff00, .hex)) >> @as(c_int, 8); -} -pub inline fn __WTERMSIG(status: anytype) @TypeOf(status & @as(c_int, 0x7f)) { - _ = &status; - return status & @as(c_int, 0x7f); -} -pub inline fn __WSTOPSIG(status: anytype) @TypeOf(__WEXITSTATUS(status)) { - _ = &status; - return __WEXITSTATUS(status); -} -pub inline fn __WIFEXITED(status: anytype) @TypeOf(__WTERMSIG(status) == @as(c_int, 0)) { - _ = &status; - return __WTERMSIG(status) == @as(c_int, 0); -} -pub inline fn __WIFSIGNALED(status: anytype) @TypeOf((@import("std").zig.c_translation.cast(i8, (status & @as(c_int, 0x7f)) + @as(c_int, 1)) >> @as(c_int, 1)) > @as(c_int, 0)) { - _ = &status; - return (@import("std").zig.c_translation.cast(i8, (status & @as(c_int, 0x7f)) + @as(c_int, 1)) >> @as(c_int, 1)) > @as(c_int, 0); -} -pub inline fn __WIFSTOPPED(status: anytype) @TypeOf((status & @as(c_int, 0xff)) == @as(c_int, 0x7f)) { - _ = &status; - return (status & @as(c_int, 0xff)) == @as(c_int, 0x7f); -} -pub inline fn __WIFCONTINUED(status: anytype) @TypeOf(status == __W_CONTINUED) { - _ = &status; - return status == __W_CONTINUED; -} -pub inline fn __WCOREDUMP(status: anytype) @TypeOf(status & __WCOREFLAG) { - _ = &status; - return status & __WCOREFLAG; -} -pub inline fn __W_EXITCODE(ret: anytype, sig: anytype) @TypeOf((ret << @as(c_int, 8)) | sig) { - _ = &ret; - _ = &sig; - return (ret << @as(c_int, 8)) | sig; -} -pub inline fn __W_STOPCODE(sig: anytype) @TypeOf((sig << @as(c_int, 8)) | @as(c_int, 0x7f)) { - _ = &sig; - return (sig << @as(c_int, 8)) | @as(c_int, 0x7f); -} -pub const __W_CONTINUED = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffff, .hex); -pub const __WCOREFLAG = @as(c_int, 0x80); -pub inline fn WEXITSTATUS(status: anytype) @TypeOf(__WEXITSTATUS(status)) { - _ = &status; - return __WEXITSTATUS(status); -} -pub inline fn WTERMSIG(status: anytype) @TypeOf(__WTERMSIG(status)) { - _ = &status; - return __WTERMSIG(status); -} -pub inline fn WSTOPSIG(status: anytype) @TypeOf(__WSTOPSIG(status)) { - _ = &status; - return __WSTOPSIG(status); -} -pub inline fn WIFEXITED(status: anytype) @TypeOf(__WIFEXITED(status)) { - _ = &status; - return __WIFEXITED(status); -} -pub inline fn WIFSIGNALED(status: anytype) @TypeOf(__WIFSIGNALED(status)) { - _ = &status; - return __WIFSIGNALED(status); -} -pub inline fn WIFSTOPPED(status: anytype) @TypeOf(__WIFSTOPPED(status)) { - _ = &status; - return __WIFSTOPPED(status); -} -pub inline fn WIFCONTINUED(status: anytype) @TypeOf(__WIFCONTINUED(status)) { - _ = &status; - return __WIFCONTINUED(status); -} -pub const __ldiv_t_defined = @as(c_int, 1); -pub const __lldiv_t_defined = @as(c_int, 1); -pub const RAND_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const EXIT_FAILURE = @as(c_int, 1); -pub const EXIT_SUCCESS = @as(c_int, 0); -pub const MB_CUR_MAX = __ctype_get_mb_cur_max(); -pub const _SYS_TYPES_H = @as(c_int, 1); -pub const __u_char_defined = ""; -pub const __ino_t_defined = ""; -pub const __dev_t_defined = ""; -pub const __gid_t_defined = ""; -pub const __mode_t_defined = ""; -pub const __nlink_t_defined = ""; -pub const __uid_t_defined = ""; -pub const __pid_t_defined = ""; -pub const __id_t_defined = ""; -pub const __daddr_t_defined = ""; -pub const __key_t_defined = ""; -pub const __clock_t_defined = @as(c_int, 1); -pub const __clockid_t_defined = @as(c_int, 1); -pub const __time_t_defined = @as(c_int, 1); -pub const __timer_t_defined = @as(c_int, 1); -pub const _BITS_STDINT_INTN_H = @as(c_int, 1); -pub const __BIT_TYPES_DEFINED__ = @as(c_int, 1); -pub const _ENDIAN_H = @as(c_int, 1); -pub const _BITS_ENDIAN_H = @as(c_int, 1); -pub const __LITTLE_ENDIAN = @as(c_int, 1234); -pub const __BIG_ENDIAN = @as(c_int, 4321); -pub const __PDP_ENDIAN = @as(c_int, 3412); -pub const _BITS_ENDIANNESS_H = @as(c_int, 1); -pub const __BYTE_ORDER = __LITTLE_ENDIAN; -pub const __FLOAT_WORD_ORDER = __BYTE_ORDER; -pub inline fn __LONG_LONG_PAIR(HI: anytype, LO: anytype) @TypeOf(HI) { - _ = &HI; - _ = &LO; - return blk: { - _ = &LO; - break :blk HI; - }; -} -pub const LITTLE_ENDIAN = __LITTLE_ENDIAN; -pub const BIG_ENDIAN = __BIG_ENDIAN; -pub const PDP_ENDIAN = __PDP_ENDIAN; -pub const BYTE_ORDER = __BYTE_ORDER; -pub const _BITS_BYTESWAP_H = @as(c_int, 1); -pub inline fn __bswap_constant_16(x: anytype) __uint16_t { - _ = &x; - return @import("std").zig.c_translation.cast(__uint16_t, ((x >> @as(c_int, 8)) & @as(c_int, 0xff)) | ((x & @as(c_int, 0xff)) << @as(c_int, 8))); -} -pub inline fn __bswap_constant_32(x: anytype) @TypeOf(((((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0xff000000, .hex)) >> @as(c_int, 24)) | ((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0x00ff0000, .hex)) >> @as(c_int, 8))) | ((x & @as(c_uint, 0x0000ff00)) << @as(c_int, 8))) | ((x & @as(c_uint, 0x000000ff)) << @as(c_int, 24))) { - _ = &x; - return ((((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0xff000000, .hex)) >> @as(c_int, 24)) | ((x & @import("std").zig.c_translation.promoteIntLiteral(c_uint, 0x00ff0000, .hex)) >> @as(c_int, 8))) | ((x & @as(c_uint, 0x0000ff00)) << @as(c_int, 8))) | ((x & @as(c_uint, 0x000000ff)) << @as(c_int, 24)); -} -pub inline fn __bswap_constant_64(x: anytype) @TypeOf(((((((((x & @as(c_ulonglong, 0xff00000000000000)) >> @as(c_int, 56)) | ((x & @as(c_ulonglong, 0x00ff000000000000)) >> @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x0000ff0000000000)) >> @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000ff00000000)) >> @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x00000000ff000000)) << @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x0000000000ff0000)) << @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000000000ff00)) << @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x00000000000000ff)) << @as(c_int, 56))) { - _ = &x; - return ((((((((x & @as(c_ulonglong, 0xff00000000000000)) >> @as(c_int, 56)) | ((x & @as(c_ulonglong, 0x00ff000000000000)) >> @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x0000ff0000000000)) >> @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000ff00000000)) >> @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x00000000ff000000)) << @as(c_int, 8))) | ((x & @as(c_ulonglong, 0x0000000000ff0000)) << @as(c_int, 24))) | ((x & @as(c_ulonglong, 0x000000000000ff00)) << @as(c_int, 40))) | ((x & @as(c_ulonglong, 0x00000000000000ff)) << @as(c_int, 56)); -} -pub const _BITS_UINTN_IDENTITY_H = @as(c_int, 1); -pub inline fn htobe16(x: anytype) @TypeOf(__bswap_16(x)) { - _ = &x; - return __bswap_16(x); -} -pub inline fn htole16(x: anytype) @TypeOf(__uint16_identity(x)) { - _ = &x; - return __uint16_identity(x); -} -pub inline fn be16toh(x: anytype) @TypeOf(__bswap_16(x)) { - _ = &x; - return __bswap_16(x); -} -pub inline fn le16toh(x: anytype) @TypeOf(__uint16_identity(x)) { - _ = &x; - return __uint16_identity(x); -} -pub inline fn htobe32(x: anytype) @TypeOf(__bswap_32(x)) { - _ = &x; - return __bswap_32(x); -} -pub inline fn htole32(x: anytype) @TypeOf(__uint32_identity(x)) { - _ = &x; - return __uint32_identity(x); -} -pub inline fn be32toh(x: anytype) @TypeOf(__bswap_32(x)) { - _ = &x; - return __bswap_32(x); -} -pub inline fn le32toh(x: anytype) @TypeOf(__uint32_identity(x)) { - _ = &x; - return __uint32_identity(x); -} -pub inline fn htobe64(x: anytype) @TypeOf(__bswap_64(x)) { - _ = &x; - return __bswap_64(x); -} -pub inline fn htole64(x: anytype) @TypeOf(__uint64_identity(x)) { - _ = &x; - return __uint64_identity(x); -} -pub inline fn be64toh(x: anytype) @TypeOf(__bswap_64(x)) { - _ = &x; - return __bswap_64(x); -} -pub inline fn le64toh(x: anytype) @TypeOf(__uint64_identity(x)) { - _ = &x; - return __uint64_identity(x); -} -pub const _SYS_SELECT_H = @as(c_int, 1); -pub const __FD_ZERO = @compileError("unable to translate macro: undefined identifier `__i`"); -// /usr/include/bits/select.h:25:9 -pub const __FD_SET = @compileError("unable to translate C expr: expected ')' instead got '|='"); -// /usr/include/bits/select.h:32:9 -pub const __FD_CLR = @compileError("unable to translate C expr: expected ')' instead got '&='"); -// /usr/include/bits/select.h:34:9 -pub inline fn __FD_ISSET(d: anytype, s: anytype) @TypeOf((__FDS_BITS(s)[@as(usize, @intCast(__FD_ELT(d)))] & __FD_MASK(d)) != @as(c_int, 0)) { - _ = &d; - _ = &s; - return (__FDS_BITS(s)[@as(usize, @intCast(__FD_ELT(d)))] & __FD_MASK(d)) != @as(c_int, 0); -} -pub const __sigset_t_defined = @as(c_int, 1); -pub const ____sigset_t_defined = ""; -pub const _SIGSET_NWORDS = @import("std").zig.c_translation.MacroArithmetic.div(@as(c_int, 1024), @as(c_int, 8) * @import("std").zig.c_translation.sizeof(c_ulong)); -pub const __timeval_defined = @as(c_int, 1); -pub const _STRUCT_TIMESPEC = @as(c_int, 1); -pub const __suseconds_t_defined = ""; -pub const __NFDBITS = @as(c_int, 8) * @import("std").zig.c_translation.cast(c_int, @import("std").zig.c_translation.sizeof(__fd_mask)); -pub inline fn __FD_ELT(d: anytype) @TypeOf(@import("std").zig.c_translation.MacroArithmetic.div(d, __NFDBITS)) { - _ = &d; - return @import("std").zig.c_translation.MacroArithmetic.div(d, __NFDBITS); -} -pub inline fn __FD_MASK(d: anytype) __fd_mask { - _ = &d; - return @import("std").zig.c_translation.cast(__fd_mask, @as(c_ulong, 1) << @import("std").zig.c_translation.MacroArithmetic.rem(d, __NFDBITS)); -} -pub inline fn __FDS_BITS(set: anytype) @TypeOf(set.*.__fds_bits) { - _ = &set; - return set.*.__fds_bits; -} -pub const FD_SETSIZE = __FD_SETSIZE; -pub const NFDBITS = __NFDBITS; -pub inline fn FD_SET(fd: anytype, fdsetp: anytype) @TypeOf(__FD_SET(fd, fdsetp)) { - _ = &fd; - _ = &fdsetp; - return __FD_SET(fd, fdsetp); -} -pub inline fn FD_CLR(fd: anytype, fdsetp: anytype) @TypeOf(__FD_CLR(fd, fdsetp)) { - _ = &fd; - _ = &fdsetp; - return __FD_CLR(fd, fdsetp); -} -pub inline fn FD_ISSET(fd: anytype, fdsetp: anytype) @TypeOf(__FD_ISSET(fd, fdsetp)) { - _ = &fd; - _ = &fdsetp; - return __FD_ISSET(fd, fdsetp); -} -pub inline fn FD_ZERO(fdsetp: anytype) @TypeOf(__FD_ZERO(fdsetp)) { - _ = &fdsetp; - return __FD_ZERO(fdsetp); -} -pub const __blksize_t_defined = ""; -pub const __blkcnt_t_defined = ""; -pub const __fsblkcnt_t_defined = ""; -pub const __fsfilcnt_t_defined = ""; -pub const _BITS_PTHREADTYPES_COMMON_H = @as(c_int, 1); -pub const _THREAD_SHARED_TYPES_H = @as(c_int, 1); -pub const _BITS_PTHREADTYPES_ARCH_H = @as(c_int, 1); -pub const __SIZEOF_PTHREAD_MUTEX_T = @as(c_int, 40); -pub const __SIZEOF_PTHREAD_ATTR_T = @as(c_int, 56); -pub const __SIZEOF_PTHREAD_RWLOCK_T = @as(c_int, 56); -pub const __SIZEOF_PTHREAD_BARRIER_T = @as(c_int, 32); -pub const __SIZEOF_PTHREAD_MUTEXATTR_T = @as(c_int, 4); -pub const __SIZEOF_PTHREAD_COND_T = @as(c_int, 48); -pub const __SIZEOF_PTHREAD_CONDATTR_T = @as(c_int, 4); -pub const __SIZEOF_PTHREAD_RWLOCKATTR_T = @as(c_int, 8); -pub const __SIZEOF_PTHREAD_BARRIERATTR_T = @as(c_int, 4); -pub const __LOCK_ALIGNMENT = ""; -pub const __ONCE_ALIGNMENT = ""; -pub const _BITS_ATOMIC_WIDE_COUNTER_H = ""; -pub const _THREAD_MUTEX_INTERNAL_H = @as(c_int, 1); -pub const __PTHREAD_MUTEX_HAVE_PREV = @as(c_int, 1); -pub const __PTHREAD_MUTEX_INITIALIZER = @compileError("unable to translate C expr: unexpected token '{'"); -// /usr/include/bits/struct_mutex.h:56:10 -pub const _RWLOCK_INTERNAL_H = ""; -pub const __PTHREAD_RWLOCK_ELISION_EXTRA = @compileError("unable to translate C expr: unexpected token '{'"); -// /usr/include/bits/struct_rwlock.h:40:11 -pub inline fn __PTHREAD_RWLOCK_INITIALIZER(__flags: anytype) @TypeOf(__flags) { - _ = &__flags; - return blk: { - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = @as(c_int, 0); - _ = &__PTHREAD_RWLOCK_ELISION_EXTRA; - _ = @as(c_int, 0); - break :blk __flags; - }; -} -pub const __ONCE_FLAG_INIT = @compileError("unable to translate C expr: unexpected token '{'"); -// /usr/include/bits/thread-shared-types.h:113:9 -pub const __have_pthread_attr_t = @as(c_int, 1); -pub const _ALLOCA_H = @as(c_int, 1); -pub const __COMPAR_FN_T = ""; -pub const _STRING_H = @as(c_int, 1); -pub const _BITS_TYPES_LOCALE_T_H = @as(c_int, 1); -pub const _BITS_TYPES___LOCALE_T_H = @as(c_int, 1); -pub const _STRINGS_H = @as(c_int, 1); -pub const TINYOBJ_MALLOC = RL_MALLOC; -pub const TINYOBJ_CALLOC = RL_CALLOC; -pub const TINYOBJ_REALLOC = RL_REALLOC; -pub const TINYOBJ_FREE = RL_FREE; -pub const TINYOBJ_LOADER_C_IMPLEMENTATION = ""; -pub const TINOBJ_LOADER_C_H_ = ""; -pub const TINYOBJ_FLAG_TRIANGULATE = @as(c_int, 1) << @as(c_int, 0); -pub const TINYOBJ_INVALID_INDEX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x80000000, .hex); -pub const TINYOBJ_SUCCESS = @as(c_int, 0); -pub const TINYOBJ_ERROR_EMPTY = -@as(c_int, 1); -pub const TINYOBJ_ERROR_INVALID_PARAMETER = -@as(c_int, 2); -pub const TINYOBJ_ERROR_FILE_OPERATION = -@as(c_int, 3); -pub const _ASSERT_H = @as(c_int, 1); -pub const __ASSERT_VOID_CAST = @compileError("unable to translate C expr: unexpected token ''"); -// /usr/include/assert.h:40:10 -pub const assert = @compileError("unable to translate macro: undefined identifier `__FILE__`"); -// /usr/include/assert.h:115:11 -pub const __ASSERT_FUNCTION = @compileError("unable to translate C expr: unexpected token '__extension__'"); -// /usr/include/assert.h:137:12 -pub const static_assert = @compileError("unable to translate C expr: unexpected token '_Static_assert'"); -// /usr/include/assert.h:155:10 -pub const _ERRNO_H = @as(c_int, 1); -pub const _BITS_ERRNO_H = @as(c_int, 1); -pub const _ASM_GENERIC_ERRNO_H = ""; -pub const _ASM_GENERIC_ERRNO_BASE_H = ""; -pub const EPERM = @as(c_int, 1); -pub const ENOENT = @as(c_int, 2); -pub const ESRCH = @as(c_int, 3); -pub const EINTR = @as(c_int, 4); -pub const EIO = @as(c_int, 5); -pub const ENXIO = @as(c_int, 6); -pub const E2BIG = @as(c_int, 7); -pub const ENOEXEC = @as(c_int, 8); -pub const EBADF = @as(c_int, 9); -pub const ECHILD = @as(c_int, 10); -pub const EAGAIN = @as(c_int, 11); -pub const ENOMEM = @as(c_int, 12); -pub const EACCES = @as(c_int, 13); -pub const EFAULT = @as(c_int, 14); -pub const ENOTBLK = @as(c_int, 15); -pub const EBUSY = @as(c_int, 16); -pub const EEXIST = @as(c_int, 17); -pub const EXDEV = @as(c_int, 18); -pub const ENODEV = @as(c_int, 19); -pub const ENOTDIR = @as(c_int, 20); -pub const EISDIR = @as(c_int, 21); -pub const EINVAL = @as(c_int, 22); -pub const ENFILE = @as(c_int, 23); -pub const EMFILE = @as(c_int, 24); -pub const ENOTTY = @as(c_int, 25); -pub const ETXTBSY = @as(c_int, 26); -pub const EFBIG = @as(c_int, 27); -pub const ENOSPC = @as(c_int, 28); -pub const ESPIPE = @as(c_int, 29); -pub const EROFS = @as(c_int, 30); -pub const EMLINK = @as(c_int, 31); -pub const EPIPE = @as(c_int, 32); -pub const EDOM = @as(c_int, 33); -pub const ERANGE = @as(c_int, 34); -pub const EDEADLK = @as(c_int, 35); -pub const ENAMETOOLONG = @as(c_int, 36); -pub const ENOLCK = @as(c_int, 37); -pub const ENOSYS = @as(c_int, 38); -pub const ENOTEMPTY = @as(c_int, 39); -pub const ELOOP = @as(c_int, 40); -pub const EWOULDBLOCK = EAGAIN; -pub const ENOMSG = @as(c_int, 42); -pub const EIDRM = @as(c_int, 43); -pub const ECHRNG = @as(c_int, 44); -pub const EL2NSYNC = @as(c_int, 45); -pub const EL3HLT = @as(c_int, 46); -pub const EL3RST = @as(c_int, 47); -pub const ELNRNG = @as(c_int, 48); -pub const EUNATCH = @as(c_int, 49); -pub const ENOCSI = @as(c_int, 50); -pub const EL2HLT = @as(c_int, 51); -pub const EBADE = @as(c_int, 52); -pub const EBADR = @as(c_int, 53); -pub const EXFULL = @as(c_int, 54); -pub const ENOANO = @as(c_int, 55); -pub const EBADRQC = @as(c_int, 56); -pub const EBADSLT = @as(c_int, 57); -pub const EDEADLOCK = EDEADLK; -pub const EBFONT = @as(c_int, 59); -pub const ENOSTR = @as(c_int, 60); -pub const ENODATA = @as(c_int, 61); -pub const ETIME = @as(c_int, 62); -pub const ENOSR = @as(c_int, 63); -pub const ENONET = @as(c_int, 64); -pub const ENOPKG = @as(c_int, 65); -pub const EREMOTE = @as(c_int, 66); -pub const ENOLINK = @as(c_int, 67); -pub const EADV = @as(c_int, 68); -pub const ESRMNT = @as(c_int, 69); -pub const ECOMM = @as(c_int, 70); -pub const EPROTO = @as(c_int, 71); -pub const EMULTIHOP = @as(c_int, 72); -pub const EDOTDOT = @as(c_int, 73); -pub const EBADMSG = @as(c_int, 74); -pub const EOVERFLOW = @as(c_int, 75); -pub const ENOTUNIQ = @as(c_int, 76); -pub const EBADFD = @as(c_int, 77); -pub const EREMCHG = @as(c_int, 78); -pub const ELIBACC = @as(c_int, 79); -pub const ELIBBAD = @as(c_int, 80); -pub const ELIBSCN = @as(c_int, 81); -pub const ELIBMAX = @as(c_int, 82); -pub const ELIBEXEC = @as(c_int, 83); -pub const EILSEQ = @as(c_int, 84); -pub const ERESTART = @as(c_int, 85); -pub const ESTRPIPE = @as(c_int, 86); -pub const EUSERS = @as(c_int, 87); -pub const ENOTSOCK = @as(c_int, 88); -pub const EDESTADDRREQ = @as(c_int, 89); -pub const EMSGSIZE = @as(c_int, 90); -pub const EPROTOTYPE = @as(c_int, 91); -pub const ENOPROTOOPT = @as(c_int, 92); -pub const EPROTONOSUPPORT = @as(c_int, 93); -pub const ESOCKTNOSUPPORT = @as(c_int, 94); -pub const EOPNOTSUPP = @as(c_int, 95); -pub const EPFNOSUPPORT = @as(c_int, 96); -pub const EAFNOSUPPORT = @as(c_int, 97); -pub const EADDRINUSE = @as(c_int, 98); -pub const EADDRNOTAVAIL = @as(c_int, 99); -pub const ENETDOWN = @as(c_int, 100); -pub const ENETUNREACH = @as(c_int, 101); -pub const ENETRESET = @as(c_int, 102); -pub const ECONNABORTED = @as(c_int, 103); -pub const ECONNRESET = @as(c_int, 104); -pub const ENOBUFS = @as(c_int, 105); -pub const EISCONN = @as(c_int, 106); -pub const ENOTCONN = @as(c_int, 107); -pub const ESHUTDOWN = @as(c_int, 108); -pub const ETOOMANYREFS = @as(c_int, 109); -pub const ETIMEDOUT = @as(c_int, 110); -pub const ECONNREFUSED = @as(c_int, 111); -pub const EHOSTDOWN = @as(c_int, 112); -pub const EHOSTUNREACH = @as(c_int, 113); -pub const EALREADY = @as(c_int, 114); -pub const EINPROGRESS = @as(c_int, 115); -pub const ESTALE = @as(c_int, 116); -pub const EUCLEAN = @as(c_int, 117); -pub const ENOTNAM = @as(c_int, 118); -pub const ENAVAIL = @as(c_int, 119); -pub const EISNAM = @as(c_int, 120); -pub const EREMOTEIO = @as(c_int, 121); -pub const EDQUOT = @as(c_int, 122); -pub const ENOMEDIUM = @as(c_int, 123); -pub const EMEDIUMTYPE = @as(c_int, 124); -pub const ECANCELED = @as(c_int, 125); -pub const ENOKEY = @as(c_int, 126); -pub const EKEYEXPIRED = @as(c_int, 127); -pub const EKEYREVOKED = @as(c_int, 128); -pub const EKEYREJECTED = @as(c_int, 129); -pub const EOWNERDEAD = @as(c_int, 130); -pub const ENOTRECOVERABLE = @as(c_int, 131); -pub const ERFKILL = @as(c_int, 132); -pub const EHWPOISON = @as(c_int, 133); -pub const ENOTSUP = EOPNOTSUPP; -pub const errno = __errno_location().*; -pub const TINYOBJ_MAX_FACES_PER_F_LINE = @as(c_int, 16); -pub inline fn IS_SPACE(x: anytype) @TypeOf((x == ' ') or (x == '\t')) { - _ = &x; - return (x == ' ') or (x == '\t'); -} -pub inline fn IS_DIGIT(x: anytype) @TypeOf(@import("std").zig.c_translation.cast(c_uint, x - '0') < @import("std").zig.c_translation.cast(c_uint, @as(c_int, 10))) { - _ = &x; - return @import("std").zig.c_translation.cast(c_uint, x - '0') < @import("std").zig.c_translation.cast(c_uint, @as(c_int, 10)); -} -pub inline fn IS_NEW_LINE(x: anytype) @TypeOf(((x == '\r') or (x == '\n')) or (x == '\x00')) { - _ = &x; - return ((x == '\r') or (x == '\n')) or (x == '\x00'); -} -pub const HASH_TABLE_ERROR = @as(c_int, 1); -pub const HASH_TABLE_SUCCESS = @as(c_int, 0); -pub const HASH_TABLE_DEFAULT_SIZE = @as(c_int, 10); -pub const CGLTF_MALLOC = RL_MALLOC; -pub const CGLTF_FREE = RL_FREE; -pub const CGLTF_IMPLEMENTATION = ""; -pub const CGLTF_H_INCLUDED__ = ""; -pub const __STDDEF_H = ""; -pub const __need_ptrdiff_t = ""; -pub const __need_max_align_t = ""; -pub const __need_offsetof = ""; -pub const _PTRDIFF_T = ""; -pub const __CLANG_MAX_ALIGN_T_DEFINED = ""; -pub const offsetof = @compileError("unable to translate C expr: unexpected token 'an identifier'"); -// /opt/zig-bin-0.13.0/lib/include/__stddef_offsetof.h:16:9 -pub const __CLANG_STDINT_H = ""; -pub const _STDINT_H = @as(c_int, 1); -pub const _BITS_WCHAR_H = @as(c_int, 1); -pub const __WCHAR_MAX = __WCHAR_MAX__; -pub const __WCHAR_MIN = -__WCHAR_MAX - @as(c_int, 1); -pub const _BITS_STDINT_UINTN_H = @as(c_int, 1); -pub const _BITS_STDINT_LEAST_H = @as(c_int, 1); -pub const __intptr_t_defined = ""; -pub const __INT64_C = @import("std").zig.c_translation.Macros.L_SUFFIX; -pub const __UINT64_C = @import("std").zig.c_translation.Macros.UL_SUFFIX; -pub const INT8_MIN = -@as(c_int, 128); -pub const INT16_MIN = -@as(c_int, 32767) - @as(c_int, 1); -pub const INT32_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1); -pub const INT64_MIN = -__INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)) - @as(c_int, 1); -pub const INT8_MAX = @as(c_int, 127); -pub const INT16_MAX = @as(c_int, 32767); -pub const INT32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const INT64_MAX = __INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)); -pub const UINT8_MAX = @as(c_int, 255); -pub const UINT16_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); -pub const UINT32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub const UINT64_MAX = __UINT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 18446744073709551615, .decimal)); -pub const INT_LEAST8_MIN = -@as(c_int, 128); -pub const INT_LEAST16_MIN = -@as(c_int, 32767) - @as(c_int, 1); -pub const INT_LEAST32_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1); -pub const INT_LEAST64_MIN = -__INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)) - @as(c_int, 1); -pub const INT_LEAST8_MAX = @as(c_int, 127); -pub const INT_LEAST16_MAX = @as(c_int, 32767); -pub const INT_LEAST32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const INT_LEAST64_MAX = __INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)); -pub const UINT_LEAST8_MAX = @as(c_int, 255); -pub const UINT_LEAST16_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal); -pub const UINT_LEAST32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub const UINT_LEAST64_MAX = __UINT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 18446744073709551615, .decimal)); -pub const INT_FAST8_MIN = -@as(c_int, 128); -pub const INT_FAST16_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal) - @as(c_int, 1); -pub const INT_FAST32_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal) - @as(c_int, 1); -pub const INT_FAST64_MIN = -__INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)) - @as(c_int, 1); -pub const INT_FAST8_MAX = @as(c_int, 127); -pub const INT_FAST16_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const INT_FAST32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const INT_FAST64_MAX = __INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)); -pub const UINT_FAST8_MAX = @as(c_int, 255); -pub const UINT_FAST16_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const UINT_FAST32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const UINT_FAST64_MAX = __UINT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 18446744073709551615, .decimal)); -pub const INTPTR_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal) - @as(c_int, 1); -pub const INTPTR_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const UINTPTR_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const INTMAX_MIN = -__INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)) - @as(c_int, 1); -pub const INTMAX_MAX = __INT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal)); -pub const UINTMAX_MAX = __UINT64_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 18446744073709551615, .decimal)); -pub const PTRDIFF_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal) - @as(c_int, 1); -pub const PTRDIFF_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal); -pub const SIG_ATOMIC_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1); -pub const SIG_ATOMIC_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const SIZE_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal); -pub const WCHAR_MIN = __WCHAR_MIN; -pub const WCHAR_MAX = __WCHAR_MAX; -pub const WINT_MIN = @as(c_uint, 0); -pub const WINT_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal); -pub inline fn INT8_C(c: anytype) @TypeOf(c) { - _ = &c; - return c; -} -pub inline fn INT16_C(c: anytype) @TypeOf(c) { - _ = &c; - return c; -} -pub inline fn INT32_C(c: anytype) @TypeOf(c) { - _ = &c; - return c; -} -pub const INT64_C = @import("std").zig.c_translation.Macros.L_SUFFIX; -pub inline fn UINT8_C(c: anytype) @TypeOf(c) { - _ = &c; - return c; -} -pub inline fn UINT16_C(c: anytype) @TypeOf(c) { - _ = &c; - return c; -} -pub const UINT32_C = @import("std").zig.c_translation.Macros.U_SUFFIX; -pub const UINT64_C = @import("std").zig.c_translation.Macros.UL_SUFFIX; -pub const INTMAX_C = @import("std").zig.c_translation.Macros.L_SUFFIX; -pub const UINTMAX_C = @import("std").zig.c_translation.Macros.UL_SUFFIX; -pub const __CLANG_LIMITS_H = ""; -pub const _GCC_LIMITS_H_ = ""; -pub const _LIBC_LIMITS_H_ = @as(c_int, 1); -pub const MB_LEN_MAX = @as(c_int, 16); -pub const LLONG_MIN = -LLONG_MAX - @as(c_int, 1); -pub const LLONG_MAX = __LONG_LONG_MAX__; -pub const ULLONG_MAX = (LLONG_MAX * @as(c_ulonglong, 2)) + @as(c_int, 1); -pub const _BITS_POSIX1_LIM_H = @as(c_int, 1); -pub const _POSIX_AIO_LISTIO_MAX = @as(c_int, 2); -pub const _POSIX_AIO_MAX = @as(c_int, 1); -pub const _POSIX_ARG_MAX = @as(c_int, 4096); -pub const _POSIX_CHILD_MAX = @as(c_int, 25); -pub const _POSIX_DELAYTIMER_MAX = @as(c_int, 32); -pub const _POSIX_HOST_NAME_MAX = @as(c_int, 255); -pub const _POSIX_LINK_MAX = @as(c_int, 8); -pub const _POSIX_LOGIN_NAME_MAX = @as(c_int, 9); -pub const _POSIX_MAX_CANON = @as(c_int, 255); -pub const _POSIX_MAX_INPUT = @as(c_int, 255); -pub const _POSIX_MQ_OPEN_MAX = @as(c_int, 8); -pub const _POSIX_MQ_PRIO_MAX = @as(c_int, 32); -pub const _POSIX_NAME_MAX = @as(c_int, 14); -pub const _POSIX_NGROUPS_MAX = @as(c_int, 8); -pub const _POSIX_OPEN_MAX = @as(c_int, 20); -pub const _POSIX_PATH_MAX = @as(c_int, 256); -pub const _POSIX_PIPE_BUF = @as(c_int, 512); -pub const _POSIX_RE_DUP_MAX = @as(c_int, 255); -pub const _POSIX_RTSIG_MAX = @as(c_int, 8); -pub const _POSIX_SEM_NSEMS_MAX = @as(c_int, 256); -pub const _POSIX_SEM_VALUE_MAX = @as(c_int, 32767); -pub const _POSIX_SIGQUEUE_MAX = @as(c_int, 32); -pub const _POSIX_SSIZE_MAX = @as(c_int, 32767); -pub const _POSIX_STREAM_MAX = @as(c_int, 8); -pub const _POSIX_SYMLINK_MAX = @as(c_int, 255); -pub const _POSIX_SYMLOOP_MAX = @as(c_int, 8); -pub const _POSIX_TIMER_MAX = @as(c_int, 32); -pub const _POSIX_TTY_NAME_MAX = @as(c_int, 9); -pub const _POSIX_TZNAME_MAX = @as(c_int, 6); -pub const _POSIX_CLOCKRES_MIN = @import("std").zig.c_translation.promoteIntLiteral(c_int, 20000000, .decimal); -pub const __undef_NR_OPEN = ""; -pub const __undef_LINK_MAX = ""; -pub const __undef_OPEN_MAX = ""; -pub const __undef_ARG_MAX = ""; -pub const _LINUX_LIMITS_H = ""; -pub const NR_OPEN = @as(c_int, 1024); -pub const NGROUPS_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65536, .decimal); -pub const ARG_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 131072, .decimal); -pub const LINK_MAX = @as(c_int, 127); -pub const MAX_CANON = @as(c_int, 255); -pub const MAX_INPUT = @as(c_int, 255); -pub const NAME_MAX = @as(c_int, 255); -pub const PATH_MAX = @as(c_int, 4096); -pub const PIPE_BUF = @as(c_int, 4096); -pub const XATTR_NAME_MAX = @as(c_int, 255); -pub const XATTR_SIZE_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65536, .decimal); -pub const XATTR_LIST_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65536, .decimal); -pub const RTSIG_MAX = @as(c_int, 32); -pub const _POSIX_THREAD_KEYS_MAX = @as(c_int, 128); -pub const PTHREAD_KEYS_MAX = @as(c_int, 1024); -pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = @as(c_int, 4); -pub const PTHREAD_DESTRUCTOR_ITERATIONS = _POSIX_THREAD_DESTRUCTOR_ITERATIONS; -pub const _POSIX_THREAD_THREADS_MAX = @as(c_int, 64); -pub const AIO_PRIO_DELTA_MAX = @as(c_int, 20); -pub const PTHREAD_STACK_MIN = @as(c_int, 16384); -pub const DELAYTIMER_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const TTY_NAME_MAX = @as(c_int, 32); -pub const LOGIN_NAME_MAX = @as(c_int, 256); -pub const HOST_NAME_MAX = @as(c_int, 64); -pub const MQ_PRIO_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 32768, .decimal); -pub const SEM_VALUE_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal); -pub const SSIZE_MAX = LONG_MAX; -pub const _BITS_POSIX2_LIM_H = @as(c_int, 1); -pub const _POSIX2_BC_BASE_MAX = @as(c_int, 99); -pub const _POSIX2_BC_DIM_MAX = @as(c_int, 2048); -pub const _POSIX2_BC_SCALE_MAX = @as(c_int, 99); -pub const _POSIX2_BC_STRING_MAX = @as(c_int, 1000); -pub const _POSIX2_COLL_WEIGHTS_MAX = @as(c_int, 2); -pub const _POSIX2_EXPR_NEST_MAX = @as(c_int, 32); -pub const _POSIX2_LINE_MAX = @as(c_int, 2048); -pub const _POSIX2_RE_DUP_MAX = @as(c_int, 255); -pub const _POSIX2_CHARCLASS_NAME_MAX = @as(c_int, 14); -pub const BC_BASE_MAX = _POSIX2_BC_BASE_MAX; -pub const BC_DIM_MAX = _POSIX2_BC_DIM_MAX; -pub const BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX; -pub const BC_STRING_MAX = _POSIX2_BC_STRING_MAX; -pub const COLL_WEIGHTS_MAX = @as(c_int, 255); -pub const EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX; -pub const LINE_MAX = _POSIX2_LINE_MAX; -pub const CHARCLASS_NAME_MAX = @as(c_int, 2048); -pub const RE_DUP_MAX = @as(c_int, 0x7fff); -pub const SCHAR_MAX = __SCHAR_MAX__; -pub const SHRT_MAX = __SHRT_MAX__; -pub const INT_MAX = __INT_MAX__; -pub const LONG_MAX = __LONG_MAX__; -pub const SCHAR_MIN = -__SCHAR_MAX__ - @as(c_int, 1); -pub const SHRT_MIN = -__SHRT_MAX__ - @as(c_int, 1); -pub const INT_MIN = -__INT_MAX__ - @as(c_int, 1); -pub const LONG_MIN = -__LONG_MAX__ - @as(c_long, 1); -pub const UCHAR_MAX = (__SCHAR_MAX__ * @as(c_int, 2)) + @as(c_int, 1); -pub const USHRT_MAX = (__SHRT_MAX__ * @as(c_int, 2)) + @as(c_int, 1); -pub const UINT_MAX = (__INT_MAX__ * @as(c_uint, 2)) + @as(c_uint, 1); -pub const ULONG_MAX = (__LONG_MAX__ * @as(c_ulong, 2)) + @as(c_ulong, 1); -pub const CHAR_BIT = __CHAR_BIT__; -pub const CHAR_MIN = SCHAR_MIN; -pub const CHAR_MAX = __SCHAR_MAX__; -pub const __CLANG_FLOAT_H = ""; -pub const FLT_EVAL_METHOD = @compileError("unable to translate macro: undefined identifier `__FLT_EVAL_METHOD__`"); -// /opt/zig-bin-0.13.0/lib/include/float.h:91:9 -pub const FLT_ROUNDS = @compileError("unable to translate macro: undefined identifier `__builtin_flt_rounds`"); -// /opt/zig-bin-0.13.0/lib/include/float.h:93:9 -pub const FLT_RADIX = __FLT_RADIX__; -pub const FLT_MANT_DIG = __FLT_MANT_DIG__; -pub const DBL_MANT_DIG = __DBL_MANT_DIG__; -pub const LDBL_MANT_DIG = __LDBL_MANT_DIG__; -pub const DECIMAL_DIG = __DECIMAL_DIG__; -pub const FLT_DIG = __FLT_DIG__; -pub const DBL_DIG = __DBL_DIG__; -pub const LDBL_DIG = __LDBL_DIG__; -pub const FLT_MIN_EXP = __FLT_MIN_EXP__; -pub const DBL_MIN_EXP = __DBL_MIN_EXP__; -pub const LDBL_MIN_EXP = __LDBL_MIN_EXP__; -pub const FLT_MIN_10_EXP = __FLT_MIN_10_EXP__; -pub const DBL_MIN_10_EXP = __DBL_MIN_10_EXP__; -pub const LDBL_MIN_10_EXP = __LDBL_MIN_10_EXP__; -pub const FLT_MAX_EXP = __FLT_MAX_EXP__; -pub const DBL_MAX_EXP = __DBL_MAX_EXP__; -pub const LDBL_MAX_EXP = __LDBL_MAX_EXP__; -pub const FLT_MAX_10_EXP = __FLT_MAX_10_EXP__; -pub const DBL_MAX_10_EXP = __DBL_MAX_10_EXP__; -pub const LDBL_MAX_10_EXP = __LDBL_MAX_10_EXP__; -pub const FLT_MAX = __FLT_MAX__; -pub const DBL_MAX = __DBL_MAX__; -pub const LDBL_MAX = __LDBL_MAX__; -pub const FLT_EPSILON = __FLT_EPSILON__; -pub const DBL_EPSILON = __DBL_EPSILON__; -pub const LDBL_EPSILON = __LDBL_EPSILON__; -pub const FLT_MIN = __FLT_MIN__; -pub const DBL_MIN = __DBL_MIN__; -pub const LDBL_MIN = __LDBL_MIN__; -pub const FLT_TRUE_MIN = __FLT_DENORM_MIN__; -pub const DBL_TRUE_MIN = __DBL_DENORM_MIN__; -pub const LDBL_TRUE_MIN = __LDBL_DENORM_MIN__; -pub const FLT_DECIMAL_DIG = __FLT_DECIMAL_DIG__; -pub const DBL_DECIMAL_DIG = __DBL_DECIMAL_DIG__; -pub const LDBL_DECIMAL_DIG = __LDBL_DECIMAL_DIG__; -pub const FLT_HAS_SUBNORM = __FLT_HAS_DENORM__; -pub const DBL_HAS_SUBNORM = __DBL_HAS_DENORM__; -pub const LDBL_HAS_SUBNORM = __LDBL_HAS_DENORM__; -pub const JSMN_PARENT_LINKS = ""; -pub const JSMN_STRICT = ""; -pub const GlbHeaderSize = @as(c_int, 12); -pub const GlbChunkHeaderSize = @as(c_int, 8); -pub const CGLTF_CONSTS = ""; -pub inline fn CGLTF_ATOI(str: anytype) @TypeOf(atoi(str)) { - _ = &str; - return atoi(str); -} -pub inline fn CGLTF_ATOF(str: anytype) @TypeOf(atof(str)) { - _ = &str; - return atof(str); -} -pub inline fn CGLTF_ATOLL(str: anytype) @TypeOf(atoll(str)) { - _ = &str; - return atoll(str); -} -pub const CGLTF_VALIDATE_ENABLE_ASSERTS = @as(c_int, 0); -pub const CGLTF_ASSERT_IF = @compileError("unable to translate C expr: unexpected token 'if'"); -// ./external/cgltf.h:1559:9 -pub const CGLTF_ERROR_JSON = -@as(c_int, 1); -pub const CGLTF_ERROR_NOMEM = -@as(c_int, 2); -pub const CGLTF_ERROR_LEGACY = -@as(c_int, 3); -pub const CGLTF_CHECK_TOKTYPE = @compileError("unable to translate C expr: unexpected token 'if'"); -// ./external/cgltf.h:2640:9 -pub const CGLTF_CHECK_TOKTYPE_RET = @compileError("unable to translate C expr: unexpected token 'if'"); -// ./external/cgltf.h:2641:9 -pub const CGLTF_CHECK_KEY = @compileError("unable to translate C expr: unexpected token 'if'"); -// ./external/cgltf.h:2642:9 -pub const CGLTF_PTRINDEX = @compileError("unable to translate C expr: unexpected token ')'"); -// ./external/cgltf.h:2644:9 -pub const CGLTF_PTRFIXUP = @compileError("unable to translate C expr: unexpected token 'if'"); -// ./external/cgltf.h:2645:9 -pub const CGLTF_PTRFIXUP_REQ = @compileError("unable to translate C expr: unexpected token 'if'"); -// ./external/cgltf.h:2646:9 -pub const VOX_MALLOC = RL_MALLOC; -pub const VOX_CALLOC = RL_CALLOC; -pub const VOX_REALLOC = RL_REALLOC; -pub const VOX_FREE = RL_FREE; -pub const VOX_LOADER_IMPLEMENTATION = ""; -pub const VOX_LOADER_H = ""; -pub const VOX_SUCCESS = @as(c_int, 0); -pub const VOX_ERROR_FILE_NOT_FOUND = -@as(c_int, 1); -pub const VOX_ERROR_INVALID_FORMAT = -@as(c_int, 2); -pub const VOX_ERROR_FILE_VERSION_NOT_MATCH = -@as(c_int, 3); -pub const CHUNKSIZE = @as(c_int, 16); -pub const CHUNKSIZE_OPSHIFT = @as(c_int, 4); -pub const CHUNK_FLATTENOFFSET_OPSHIFT = @as(c_int, 8); -pub const M3D_MALLOC = RL_MALLOC; -pub const M3D_REALLOC = RL_REALLOC; -pub const M3D_FREE = RL_FREE; -pub const M3D_IMPLEMENTATION = ""; -pub const _M3D_H_ = ""; -pub const M3D_LOG = @compileError("unable to translate C expr: unexpected token ''"); -// ./external/m3d.h:56:10 -pub const M3D_APIVERSION = @as(c_int, 0x0100); -pub const M3D_EPSILON = @import("std").zig.c_translation.cast(M3D_FLOAT, @as(f64, 1e-7)); -pub const M3D_UNDEF = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffffffff, .hex); -pub const M3D_INDEXMAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfffffffe, .hex); -pub const M3D_VOXUNDEF = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffff, .hex); -pub const M3D_VOXCLEAR = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xfffe, .hex); -pub const M3D_NOTDEFINED = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffffffff, .hex); -pub const M3D_NUMBONE = @as(c_int, 4); -pub const M3D_BONEMAXLEVEL = @as(c_int, 64); -pub const _inline = @compileError("unable to translate C expr: unexpected token '__inline__'"); -// ./external/m3d.h:96:9 -pub const _pack = @compileError("unable to translate macro: undefined identifier `packed`"); -// ./external/m3d.h:98:9 -pub const _unused = @compileError("unable to translate macro: undefined identifier `unused`"); -// ./external/m3d.h:99:9 -pub const _register = @compileError("unable to translate C expr: unexpected token 'register'"); -// ./external/m3d.h:106:9 -pub const m3d_textureindex_t = m3dti_t; -pub const m3d_texturedata_t = m3dtx_t; -pub const m3d_weight_t = m3dw_t; -pub const m3d_bone_t = m3db_t; -pub const m3d_skin_t = m3ds_t; -pub const m3d_vertex_t = m3dv_t; -pub const M3D_PROPERTYDEF = @compileError("unable to translate C expr: unexpected token '{'"); -// ./external/m3d.h:240:9 -pub const m3d_property_t = m3dp_t; -pub const m3d_material_t = m3dm_t; -pub const m3d_face_t = m3df_t; -pub const m3d_voxelitem_t = m3dvi_t; -pub const m3d_parameter_t = m3dvi_t; -pub const m3d_voxeltype_t = m3dvt_t; -pub const m3d_voxel_t = m3dvx_t; -pub const M3D_CMDMAXARG = @as(c_int, 8); -pub const M3D_CMDDEF = @compileError("unable to translate C expr: unexpected token '{'"); -// ./external/m3d.h:418:9 -pub const m3d_shapecommand_t = m3dc_t; -pub const m3d_shape_t = m3dh_t; -pub const m3d_label_t = m3dl_t; -pub const m3d_transform_t = m3dtr_t; -pub const m3d_frame_t = m3dfr_t; -pub const m3d_action_t = m3da_t; -pub const m3d_inlinedasset_t = m3di_t; -pub const M3D_FLG_FREERAW = @as(c_int, 1) << @as(c_int, 0); -pub const M3D_FLG_FREESTR = @as(c_int, 1) << @as(c_int, 1); -pub const M3D_FLG_MTLLIB = @as(c_int, 1) << @as(c_int, 2); -pub const M3D_FLG_GENNORM = @as(c_int, 1) << @as(c_int, 3); -pub const M3D_EXP_INT8 = @as(c_int, 0); -pub const M3D_EXP_INT16 = @as(c_int, 1); -pub const M3D_EXP_FLOAT = @as(c_int, 2); -pub const M3D_EXP_DOUBLE = @as(c_int, 3); -pub const M3D_EXP_NOCMAP = @as(c_int, 1) << @as(c_int, 0); -pub const M3D_EXP_NOMATERIAL = @as(c_int, 1) << @as(c_int, 1); -pub const M3D_EXP_NOFACE = @as(c_int, 1) << @as(c_int, 2); -pub const M3D_EXP_NONORMAL = @as(c_int, 1) << @as(c_int, 3); -pub const M3D_EXP_NOTXTCRD = @as(c_int, 1) << @as(c_int, 4); -pub const M3D_EXP_FLIPTXTCRD = @as(c_int, 1) << @as(c_int, 5); -pub const M3D_EXP_NORECALC = @as(c_int, 1) << @as(c_int, 6); -pub const M3D_EXP_IDOSUCK = @as(c_int, 1) << @as(c_int, 7); -pub const M3D_EXP_NOBONE = @as(c_int, 1) << @as(c_int, 8); -pub const M3D_EXP_NOACTION = @as(c_int, 1) << @as(c_int, 9); -pub const M3D_EXP_INLINE = @as(c_int, 1) << @as(c_int, 10); -pub const M3D_EXP_EXTRA = @as(c_int, 1) << @as(c_int, 11); -pub const M3D_EXP_NOZLIB = @as(c_int, 1) << @as(c_int, 14); -pub const M3D_EXP_ASCII = @as(c_int, 1) << @as(c_int, 15); -pub const M3D_EXP_NOVRTMAX = @as(c_int, 1) << @as(c_int, 16); -pub const M3D_SUCCESS = @as(c_int, 0); -pub const M3D_ERR_ALLOC = -@as(c_int, 1); -pub const M3D_ERR_BADFILE = -@as(c_int, 2); -pub const M3D_ERR_UNIMPL = -@as(c_int, 65); -pub const M3D_ERR_UNKPROP = -@as(c_int, 66); -pub const M3D_ERR_UNKMESH = -@as(c_int, 67); -pub const M3D_ERR_UNKIMG = -@as(c_int, 68); -pub const M3D_ERR_UNKFRAME = -@as(c_int, 69); -pub const M3D_ERR_UNKCMD = -@as(c_int, 70); -pub const M3D_ERR_UNKVOX = -@as(c_int, 71); -pub const M3D_ERR_TRUNC = -@as(c_int, 72); -pub const M3D_ERR_CMAP = -@as(c_int, 73); -pub const M3D_ERR_TMAP = -@as(c_int, 74); -pub const M3D_ERR_VRTS = -@as(c_int, 75); -pub const M3D_ERR_BONE = -@as(c_int, 76); -pub const M3D_ERR_MTRL = -@as(c_int, 77); -pub const M3D_ERR_SHPE = -@as(c_int, 78); -pub const M3D_ERR_VOXT = -@as(c_int, 79); -pub inline fn M3D_ERR_ISFATAL(x: anytype) @TypeOf((x < @as(c_int, 0)) and (x > -@as(c_int, 65))) { - _ = &x; - return (x < @as(c_int, 0)) and (x > -@as(c_int, 65)); -} -pub const STBI_ASSERT = @compileError("unable to translate C expr: unexpected token ''"); -// ./external/m3d.h:730:9 -pub inline fn STBI_NOTUSED(v: anytype) anyopaque { - _ = &v; - return @import("std").zig.c_translation.cast(anyopaque, @import("std").zig.c_translation.sizeof(v)); -} -pub inline fn STBI__BYTECAST(x: anytype) u8 { - _ = &x; - return @import("std").zig.c_translation.cast(u8, x & @as(c_int, 255)); -} -pub inline fn STBI_MALLOC(sz: anytype) @TypeOf(M3D_MALLOC(sz)) { - _ = &sz; - return M3D_MALLOC(sz); -} -pub inline fn STBI_REALLOC(p: anytype, newsz: anytype) @TypeOf(M3D_REALLOC(p, newsz)) { - _ = &p; - _ = &newsz; - return M3D_REALLOC(p, newsz); -} -pub inline fn STBI_FREE(p: anytype) @TypeOf(M3D_FREE(p)) { - _ = &p; - return M3D_FREE(p); -} -pub inline fn STBI_REALLOC_SIZED(p: anytype, oldsz: anytype, newsz: anytype) @TypeOf(STBI_REALLOC(p, newsz)) { - _ = &p; - _ = &oldsz; - _ = &newsz; - return STBI_REALLOC(p, newsz); -} -pub inline fn _m3dstbi__err(x: anytype, y: anytype) @TypeOf(_m3dstbi__errstr(y)) { - _ = &x; - _ = &y; - return _m3dstbi__errstr(y); -} -pub inline fn STBI__COMBO(a: anytype, b: anytype) @TypeOf((a * @as(c_int, 8)) + b) { - _ = &a; - _ = &b; - return (a * @as(c_int, 8)) + b; -} -pub const STBI__CASE = @compileError("unable to translate macro: undefined identifier `i`"); -// ./external/m3d.h:854:15 -pub const STBI__ZFAST_BITS = @as(c_int, 9); -pub const STBI__ZFAST_MASK = (@as(c_int, 1) << STBI__ZFAST_BITS) - @as(c_int, 1); -pub inline fn STBI__PNG_TYPE(a: anytype, b: anytype, c: anytype, d: anytype) @TypeOf((((@import("std").zig.c_translation.cast(c_uint, a) << @as(c_int, 24)) + (@import("std").zig.c_translation.cast(c_uint, b) << @as(c_int, 16))) + (@import("std").zig.c_translation.cast(c_uint, c) << @as(c_int, 8))) + @import("std").zig.c_translation.cast(c_uint, d)) { - _ = &a; - _ = &b; - _ = &c; - _ = &d; - return (((@import("std").zig.c_translation.cast(c_uint, a) << @as(c_int, 24)) + (@import("std").zig.c_translation.cast(c_uint, b) << @as(c_int, 16))) + (@import("std").zig.c_translation.cast(c_uint, c) << @as(c_int, 8))) + @import("std").zig.c_translation.cast(c_uint, d); -} -pub const stbi__context = _m3dstbi__context; -pub const stbi__result_info = _m3dstbi__result_info; -pub const stbi__png_load = _m3dstbi__png_load; -pub const stbi_zlib_decode_malloc_guesssize_headerflag = _m3dstbi_zlib_decode_malloc_guesssize_headerflag; -pub inline fn M3D_CHUNKMAGIC(m: anytype, a: anytype, b: anytype, c: anytype, d: anytype) @TypeOf((((m[@as(usize, @intCast(@as(c_int, 0)))] == a) and (m[@as(usize, @intCast(@as(c_int, 1)))] == b)) and (m[@as(usize, @intCast(@as(c_int, 2)))] == c)) and (m[@as(usize, @intCast(@as(c_int, 3)))] == d)) { - _ = &m; - _ = &a; - _ = &b; - _ = &c; - _ = &d; - return (((m[@as(usize, @intCast(@as(c_int, 0)))] == a) and (m[@as(usize, @intCast(@as(c_int, 1)))] == b)) and (m[@as(usize, @intCast(@as(c_int, 2)))] == c)) and (m[@as(usize, @intCast(@as(c_int, 3)))] == d); -} -pub const M3D_GETSTR = @compileError("unable to translate macro: undefined identifier `offs`"); -// ./external/m3d.h:2278:9 -pub const PAR_MALLOC = @compileError("unable to translate C expr: unexpected token ')'"); -// rmodels.c:99:13 -pub const PAR_CALLOC = @compileError("unable to translate C expr: unexpected token ')'"); -// rmodels.c:100:13 -pub const PAR_REALLOC = @compileError("unable to translate C expr: unexpected token ')'"); -// rmodels.c:101:13 -pub const PAR_FREE = RL_FREE; -pub const PAR_SHAPES_IMPLEMENTATION = ""; -pub const PAR_SHAPES_H = ""; -pub const PAR_SHAPES_T = u16; -pub const PAR_PI = @as(f64, 3.14159265359); -pub inline fn PAR_MIN(a: anytype, b: anytype) @TypeOf(if (a > b) b else a) { - _ = &a; - _ = &b; - return if (a > b) b else a; -} -pub inline fn PAR_MAX(a: anytype, b: anytype) @TypeOf(if (a > b) a else b) { - _ = &a; - _ = &b; - return if (a > b) a else b; -} -pub inline fn PAR_CLAMP(v: anytype, lo: anytype, hi: anytype) @TypeOf(PAR_MAX(lo, PAR_MIN(hi, v))) { - _ = &v; - _ = &lo; - _ = &hi; - return PAR_MAX(lo, PAR_MIN(hi, v)); -} -pub const PAR_SWAP = @compileError("unable to translate macro: undefined identifier `tmp`"); -// ./external/par_shapes.h:197:9 -pub inline fn PAR_SQR(a: anytype) @TypeOf(a * a) { - _ = &a; - return a * a; -} -pub const STRETCH_CONSTANT_2D = -@as(f64, 0.211324865405187); -pub const SQUISH_CONSTANT_2D = @as(f64, 0.366025403784439); -pub const STRETCH_CONSTANT_3D = @import("std").zig.c_translation.MacroArithmetic.div(-@as(f64, 1.0), @as(f64, 6.0)); -pub const SQUISH_CONSTANT_3D = @import("std").zig.c_translation.MacroArithmetic.div(@as(f64, 1.0), @as(f64, 3.0)); -pub const STRETCH_CONSTANT_4D = -@as(f64, 0.138196601125011); -pub const SQUISH_CONSTANT_4D = @as(f64, 0.309016994374947); -pub const NORM_CONSTANT_2D = @as(f64, 47.0); -pub const NORM_CONSTANT_3D = @as(f64, 103.0); -pub const NORM_CONSTANT_4D = @as(f64, 30.0); -pub const DEFAULT_SEED = @as(c_longlong, 0); -pub const ARRAYSIZE = @compileError("unable to translate C expr: unexpected token '('"); -// ./external/par_shapes.h:1857:9 -pub const _UNISTD_H = @as(c_int, 1); -pub const _POSIX_VERSION = @as(c_long, 200809); -pub const __POSIX2_THIS_VERSION = @as(c_long, 200809); -pub const _POSIX2_VERSION = __POSIX2_THIS_VERSION; -pub const _POSIX2_C_VERSION = __POSIX2_THIS_VERSION; -pub const _POSIX2_C_BIND = __POSIX2_THIS_VERSION; -pub const _POSIX2_C_DEV = __POSIX2_THIS_VERSION; -pub const _POSIX2_SW_DEV = __POSIX2_THIS_VERSION; -pub const _POSIX2_LOCALEDEF = __POSIX2_THIS_VERSION; -pub const _XOPEN_VERSION = @as(c_int, 700); -pub const _XOPEN_XCU_VERSION = @as(c_int, 4); -pub const _XOPEN_XPG2 = @as(c_int, 1); -pub const _XOPEN_XPG3 = @as(c_int, 1); -pub const _XOPEN_XPG4 = @as(c_int, 1); -pub const _XOPEN_UNIX = @as(c_int, 1); -pub const _XOPEN_ENH_I18N = @as(c_int, 1); -pub const _XOPEN_LEGACY = @as(c_int, 1); -pub const _BITS_POSIX_OPT_H = @as(c_int, 1); -pub const _POSIX_JOB_CONTROL = @as(c_int, 1); -pub const _POSIX_SAVED_IDS = @as(c_int, 1); -pub const _POSIX_PRIORITY_SCHEDULING = @as(c_long, 200809); -pub const _POSIX_SYNCHRONIZED_IO = @as(c_long, 200809); -pub const _POSIX_FSYNC = @as(c_long, 200809); -pub const _POSIX_MAPPED_FILES = @as(c_long, 200809); -pub const _POSIX_MEMLOCK = @as(c_long, 200809); -pub const _POSIX_MEMLOCK_RANGE = @as(c_long, 200809); -pub const _POSIX_MEMORY_PROTECTION = @as(c_long, 200809); -pub const _POSIX_CHOWN_RESTRICTED = @as(c_int, 0); -pub const _POSIX_VDISABLE = '\x00'; -pub const _POSIX_NO_TRUNC = @as(c_int, 1); -pub const _XOPEN_REALTIME = @as(c_int, 1); -pub const _XOPEN_REALTIME_THREADS = @as(c_int, 1); -pub const _XOPEN_SHM = @as(c_int, 1); -pub const _POSIX_THREADS = @as(c_long, 200809); -pub const _POSIX_REENTRANT_FUNCTIONS = @as(c_int, 1); -pub const _POSIX_THREAD_SAFE_FUNCTIONS = @as(c_long, 200809); -pub const _POSIX_THREAD_PRIORITY_SCHEDULING = @as(c_long, 200809); -pub const _POSIX_THREAD_ATTR_STACKSIZE = @as(c_long, 200809); -pub const _POSIX_THREAD_ATTR_STACKADDR = @as(c_long, 200809); -pub const _POSIX_THREAD_PRIO_INHERIT = @as(c_long, 200809); -pub const _POSIX_THREAD_PRIO_PROTECT = @as(c_long, 200809); -pub const _POSIX_THREAD_ROBUST_PRIO_INHERIT = @as(c_long, 200809); -pub const _POSIX_THREAD_ROBUST_PRIO_PROTECT = -@as(c_int, 1); -pub const _POSIX_SEMAPHORES = @as(c_long, 200809); -pub const _POSIX_REALTIME_SIGNALS = @as(c_long, 200809); -pub const _POSIX_ASYNCHRONOUS_IO = @as(c_long, 200809); -pub const _POSIX_ASYNC_IO = @as(c_int, 1); -pub const _LFS_ASYNCHRONOUS_IO = @as(c_int, 1); -pub const _POSIX_PRIORITIZED_IO = @as(c_long, 200809); -pub const _LFS64_ASYNCHRONOUS_IO = @as(c_int, 1); -pub const _LFS_LARGEFILE = @as(c_int, 1); -pub const _LFS64_LARGEFILE = @as(c_int, 1); -pub const _LFS64_STDIO = @as(c_int, 1); -pub const _POSIX_SHARED_MEMORY_OBJECTS = @as(c_long, 200809); -pub const _POSIX_CPUTIME = @as(c_int, 0); -pub const _POSIX_THREAD_CPUTIME = @as(c_int, 0); -pub const _POSIX_REGEXP = @as(c_int, 1); -pub const _POSIX_READER_WRITER_LOCKS = @as(c_long, 200809); -pub const _POSIX_SHELL = @as(c_int, 1); -pub const _POSIX_TIMEOUTS = @as(c_long, 200809); -pub const _POSIX_SPIN_LOCKS = @as(c_long, 200809); -pub const _POSIX_SPAWN = @as(c_long, 200809); -pub const _POSIX_TIMERS = @as(c_long, 200809); -pub const _POSIX_BARRIERS = @as(c_long, 200809); -pub const _POSIX_MESSAGE_PASSING = @as(c_long, 200809); -pub const _POSIX_THREAD_PROCESS_SHARED = @as(c_long, 200809); -pub const _POSIX_MONOTONIC_CLOCK = @as(c_int, 0); -pub const _POSIX_CLOCK_SELECTION = @as(c_long, 200809); -pub const _POSIX_ADVISORY_INFO = @as(c_long, 200809); -pub const _POSIX_IPV6 = @as(c_long, 200809); -pub const _POSIX_RAW_SOCKETS = @as(c_long, 200809); -pub const _POSIX2_CHAR_TERM = @as(c_long, 200809); -pub const _POSIX_SPORADIC_SERVER = -@as(c_int, 1); -pub const _POSIX_THREAD_SPORADIC_SERVER = -@as(c_int, 1); -pub const _POSIX_TRACE = -@as(c_int, 1); -pub const _POSIX_TRACE_EVENT_FILTER = -@as(c_int, 1); -pub const _POSIX_TRACE_INHERIT = -@as(c_int, 1); -pub const _POSIX_TRACE_LOG = -@as(c_int, 1); -pub const _POSIX_TYPED_MEMORY_OBJECTS = -@as(c_int, 1); -pub const _POSIX_V7_LPBIG_OFFBIG = -@as(c_int, 1); -pub const _POSIX_V6_LPBIG_OFFBIG = -@as(c_int, 1); -pub const _XBS5_LPBIG_OFFBIG = -@as(c_int, 1); -pub const _POSIX_V7_LP64_OFF64 = @as(c_int, 1); -pub const _POSIX_V6_LP64_OFF64 = @as(c_int, 1); -pub const _XBS5_LP64_OFF64 = @as(c_int, 1); -pub const __ILP32_OFF32_CFLAGS = "-m32"; -pub const __ILP32_OFF32_LDFLAGS = "-m32"; -pub const __ILP32_OFFBIG_CFLAGS = "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"; -pub const __ILP32_OFFBIG_LDFLAGS = "-m32"; -pub const __LP64_OFF64_CFLAGS = "-m64"; -pub const __LP64_OFF64_LDFLAGS = "-m64"; -pub const STDIN_FILENO = @as(c_int, 0); -pub const STDOUT_FILENO = @as(c_int, 1); -pub const STDERR_FILENO = @as(c_int, 2); -pub const __useconds_t_defined = ""; -pub const __socklen_t_defined = ""; -pub const R_OK = @as(c_int, 4); -pub const W_OK = @as(c_int, 2); -pub const X_OK = @as(c_int, 1); -pub const F_OK = @as(c_int, 0); -pub const L_SET = SEEK_SET; -pub const L_INCR = SEEK_CUR; -pub const L_XTND = SEEK_END; -pub const _SC_PAGE_SIZE = _SC_PAGESIZE; -pub const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = _CS_V6_WIDTH_RESTRICTED_ENVS; -pub const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS = _CS_V5_WIDTH_RESTRICTED_ENVS; -pub const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS = _CS_V7_WIDTH_RESTRICTED_ENVS; -pub const _GETOPT_POSIX_H = @as(c_int, 1); -pub const _GETOPT_CORE_H = @as(c_int, 1); -pub const F_ULOCK = @as(c_int, 0); -pub const F_LOCK = @as(c_int, 1); -pub const F_TLOCK = @as(c_int, 2); -pub const F_TEST = @as(c_int, 3); -pub const CHDIR = chdir; -pub const TEXT_BYTES_PER_LINE = @as(c_int, 20); -pub const CUSTOM_MESH_GEN_PLANE = ""; -pub const CUSTOM_MESH_GEN_CUBE = ""; -pub inline fn GRAY_VALUE(c: anytype) @TypeOf(@import("std").zig.c_translation.MacroArithmetic.div(@import("std").zig.c_translation.cast(f32, (c.r + c.g) + c.b), @as(f32, 3.0))) { - _ = &c; - return @import("std").zig.c_translation.MacroArithmetic.div(@import("std").zig.c_translation.cast(f32, (c.r + c.g) + c.b), @as(f32, 3.0)); -} -pub inline fn COLOR_EQUAL(col1: anytype, col2: anytype) @TypeOf((((col1.r == col2.r) and (col1.g == col2.g)) and (col1.b == col2.b)) and (col1.a == col2.a)) { - _ = &col1; - _ = &col2; - return (((col1.r == col2.r) and (col1.g == col2.g)) and (col1.b == col2.b)) and (col1.a == col2.a); -} -pub const IQM_MAGIC = "INTERQUAKEMODEL"; -pub const IQM_VERSION = @as(c_int, 2); -pub const BONE_NAME_LENGTH = @as(c_int, 32); -pub const MESH_NAME_LENGTH = @as(c_int, 32); -pub const MATERIAL_NAME_LENGTH = @as(c_int, 32); -pub const LOAD_ATTRIBUTE = @compileError("unable to translate macro: undefined identifier `n`"); -// rmodels.c:5083:13 -pub const GLTF_ANIMDELAY = @as(c_int, 17); -pub const M3D_ANIMDELAY = @as(c_int, 17); -pub const par_shapes_mesh_s = struct_par_shapes_mesh_s; -pub const _G_fpos_t = struct__G_fpos_t; -pub const _G_fpos64_t = struct__G_fpos64_t; -pub const _IO_marker = struct__IO_marker; -pub const _IO_codecvt = struct__IO_codecvt; -pub const _IO_wide_data = struct__IO_wide_data; -pub const _IO_FILE = struct__IO_FILE; -pub const _IO_cookie_io_functions_t = struct__IO_cookie_io_functions_t; -pub const timeval = struct_timeval; -pub const timespec = struct_timespec; -pub const __pthread_internal_list = struct___pthread_internal_list; -pub const __pthread_internal_slist = struct___pthread_internal_slist; -pub const __pthread_mutex_s = struct___pthread_mutex_s; -pub const __pthread_rwlock_arch_t = struct___pthread_rwlock_arch_t; -pub const __pthread_cond_s = struct___pthread_cond_s; -pub const random_data = struct_random_data; -pub const drand48_data = struct_drand48_data; -pub const __locale_struct = struct___locale_struct; -pub const jsmnerr = enum_jsmnerr; -pub const osn_context = struct_osn_context; diff --git a/src/c/raylib_extension.h b/src/c/raylib_extension.h deleted file mode 100644 index 1cb8338..0000000 --- a/src/c/raylib_extension.h +++ /dev/null @@ -1,675 +0,0 @@ -/********************************************************************************************** -* This file contains modified pieces of code from the Raylib library. -* Original license follows below. -* -* LICENSE: zlib/libpng -* -* Copyright (c) 2014-2025 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -**********************************************************************************************/ - -#include "raylib.h" -#include "rlgl.h" -#include "raymath.h" - -#include -#include -#include - -#define CHUNK_MAX_MESH_VERTEX_BUFFERS 5 -#define CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0 -#define CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1 -#define CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2 -#define CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD 3 -#define CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1 4 - -#define CHUNK_MAX_MATERIAL_MAPS 12 -#define CHUNK_MAX_SHADER_LOCATIONS 32 - -typedef enum { - CHUNK_SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position - CHUNK_SHADER_LOC_VERTEX_TEXCOORD, // Shader location: vertex attribute: texcoord - CHUNK_SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal - CHUNK_SHADER_LOC_VERTEX_TILETEXCOORD, // Shader location: vertex attribute: tiletexcoord - CHUNK_SHADER_LOC_VERTEX_METADATA1, // Shader location: vertex attribute: metadata1 - CHUNK_SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection - CHUNK_SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) - CHUNK_SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection - CHUNK_SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform) - CHUNK_SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal - CHUNK_SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view - CHUNK_SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color - CHUNK_SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color - CHUNK_SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color - CHUNK_SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: CHUNK_SHADER_LOC_MAP_DIFFUSE) - CHUNK_SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: CHUNK_SHADER_LOC_MAP_SPECULAR) - CHUNK_SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal - CHUNK_SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness - CHUNK_SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion - CHUNK_SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission - CHUNK_SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height - CHUNK_SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap - CHUNK_SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance - CHUNK_SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter - CHUNK_SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf -} chunkShaderLocationIndex; - -#define CHUNK_SHADER_LOC_MAP_DIFFUSE CHUNK_SHADER_LOC_MAP_ALBEDO -#define CHUNK_SHADER_LOC_MAP_SPECULAR CHUNK_SHADER_LOC_MAP_METALNESS - -#define CHUNK_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION -#define CHUNK_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD -#define CHUNK_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL -#define CHUNK_DEFAULT_SHADER_ATTRIB_NAME_TILETEXCOORD "vertexTileTexCoord" // Bound by default to shader location: CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD -#define CHUNK_DEFAULT_SHADER_ATTRIB_NAME_METADATA1 "vertexMetadata1" // Bound by default to shader location: CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1 -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))) -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) -#define CHUNK_DEFAULT_SHADER_UNIFORM_NAME_BONE_MATRICES "boneMatrices" // bone matrices -#define CHUNK_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) -#define CHUNK_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) -#define CHUNK_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) - -typedef struct ChunkMesh { - int vertexCount; // Number of vertices stored in arrays - int triangleCount; // Number of triangles stored (indexed or not) - - // Vertex attributes data - float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) - float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) - float *tiletexcoords; // Vertex tile tex coordinates (UV - 2 components per vertex) (shader-location = 3) - float *metadata1; // Vertex metadata 1 (ABCD - 4 components per vertex) (shader-location = 4) - - // OpenGL identifiers - unsigned int vaoId; // OpenGL Vertex Array Object id - unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data) -} ChunkMesh; - -// Model, meshes, materials and animation data -typedef struct ChunkModel { - Matrix transform; // Local transform matrix - - int meshCount; // Number of meshes - int materialCount; // Number of materials - ChunkMesh *meshes; // Meshes array - Material *materials; // Materials array - int *meshMaterial; // Mesh material number - - // Animation data - int boneCount; // Number of bones - BoneInfo *bones; // Bones information (skeleton) - Transform *bindPose; // Bones base transformation (pose) -} ChunkModel; - -RLAPI void UploadChunkMesh(ChunkMesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids -RLAPI ChunkModel LoadChunkModelFromMesh(ChunkMesh mesh); // Load model from generated mesh (default material) -RLAPI void UnloadChunkModel(ChunkModel model); // Unload model (including meshes) from memory (RAM and/or VRAM) -RLAPI void UnloadChunkMesh(ChunkMesh mesh); // Unload mesh data from CPU and GPU -RLAPI void DrawChunkModel(ChunkModel model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) -RLAPI void DrawChunkModelEx(ChunkModel model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters -RLAPI void DrawChunkMesh(ChunkMesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform -RLAPI Shader LoadChunkShader(const char *vsFileName, const char *fsFileName); // Load shader from files and bind default locations -RLAPI Shader LoadChunkShaderFromMemory(const char *vsCode, const char *fsCode); // Load shader from code strings and bind default locations - -RLAPI unsigned int chunkLoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings -RLAPI unsigned int chunkLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId); // Load custom shader program - -// Upload vertex data into a VAO (if supported) and VBO -void UploadChunkMesh(ChunkMesh *mesh, bool dynamic) { - if (mesh->vaoId > 0) - { - // Check if mesh has already been loaded in GPU - printf("CHUNK VAO: [ID %i] Trying to re-load an already loaded mesh\n", mesh->vaoId); - return; - } - - mesh->vboId = (unsigned int *)RL_CALLOC(CHUNK_MAX_MESH_VERTEX_BUFFERS, sizeof(unsigned int)); - - mesh->vaoId = 0; // Vertex Array Object - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION] = 0; - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD] = 0; - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL] = 0; - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD] = 0; - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1] = 0; - -#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - mesh->vaoId = rlLoadVertexArray(); - rlEnableVertexArray(mesh->vaoId); - - // NOTE: Vertex attributes must be uploaded considering default locations points and available vertex data - - // Enable vertex attributes: position (shader-location = 0) - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION] = rlLoadVertexBuffer(mesh->vertices, mesh->vertexCount*3*sizeof(float), dynamic); - rlSetVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, 3, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION); - - // Enable vertex attributes: texcoords (shader-location = 1) - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD] = rlLoadVertexBuffer(mesh->texcoords, mesh->vertexCount*2*sizeof(float), dynamic); - rlSetVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, 2, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD); - - // Enable vertex attributes: normals (shader-location = 2) - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL] = rlLoadVertexBuffer(mesh->normals, mesh->vertexCount*3*sizeof(float), dynamic); - rlSetVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, 3, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL); - - // Enable vertex attribute: tiletexcoord (shader-location = 3) - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD] = rlLoadVertexBuffer(mesh->tiletexcoords, mesh->vertexCount*2*sizeof(float), dynamic); - rlSetVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD, 2, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD); - - // Enable vertex attribute: metadata1 (shader-location = 4) - mesh->vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1] = rlLoadVertexBuffer(mesh->metadata1, mesh->vertexCount*4*sizeof(float), dynamic); - rlSetVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1, 4, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1); - - if (mesh->vaoId > 0) printf("CHUNK VAO: [ID %i] Mesh uploaded successfully to VRAM (GPU)\n", mesh->vaoId); - else printf("CHUNK VBO: Mesh uploaded successfully to VRAM (GPU)"); - - rlDisableVertexArray(); -#endif -} - - -// Load model from generated mesh -// WARNING: A shallow copy of mesh is generated, passed by value, -// as long as struct contains pointers to data and some values, we get a copy -// of mesh pointing to same data as original version... be careful! -ChunkModel LoadChunkModelFromMesh(ChunkMesh mesh) -{ - ChunkModel model = { 0 }; - - model.transform = MatrixIdentity(); - - model.meshCount = 1; - model.meshes = (ChunkMesh *)RL_CALLOC(model.meshCount, sizeof(ChunkMesh)); - model.meshes[0] = mesh; - - model.materialCount = 1; - model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material)); - model.materials[0] = LoadMaterialDefault(); - - model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int)); - model.meshMaterial[0] = 0; // First material index - - return model; -} - - -// Unload model (meshes/materials) from memory (RAM and/or VRAM) -// NOTE: This function takes care of all model elements, for a detailed control -// over them, use UnloadMesh() and UnloadMaterial() -void UnloadChunkModel(ChunkModel model) -{ - // Unload meshes - for (int i = 0; i < model.meshCount; i++) UnloadChunkMesh(model.meshes[i]); - - // Unload materials maps - // NOTE: As the user could be sharing shaders and textures between models, - // we don't unload the material but just free its maps, - // the user is responsible for freeing models shaders and textures - for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps); - - // Unload arrays - RL_FREE(model.meshes); - RL_FREE(model.materials); - RL_FREE(model.meshMaterial); - - TRACELOG(LOG_INFO, "CHUNK MODEL: Unloaded model (and meshes) from RAM and VRAM"); -} - -// Unload mesh from memory (RAM and VRAM) -void UnloadChunkMesh(ChunkMesh mesh) -{ - // Unload rlgl mesh vboId data - rlUnloadVertexArray(mesh.vaoId); - - if (mesh.vboId != NULL) for (int i = 0; i < CHUNK_MAX_MESH_VERTEX_BUFFERS; i++) rlUnloadVertexBuffer(mesh.vboId[i]); - RL_FREE(mesh.vboId); - - RL_FREE(mesh.vertices); - RL_FREE(mesh.texcoords); - RL_FREE(mesh.normals); - RL_FREE(mesh.tiletexcoords); -} - -// Draw a model (with texture if set) -void DrawChunkModel(ChunkModel model, Vector3 position, float scale, Color tint) -{ - Vector3 vScale = { scale, scale, scale }; - Vector3 rotationAxis = { 0.0f, 1.0f, 0.0f }; - - DrawChunkModelEx(model, position, rotationAxis, 0.0f, vScale, tint); -} - -// Draw a model with extended parameters -void DrawChunkModelEx(ChunkModel model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint) -{ - // Calculate transformation matrix from function parameters - // Get transform matrix (rotation -> scale -> translation) - Matrix matScale = MatrixScale(scale.x, scale.y, scale.z); - Matrix matRotation = MatrixRotate(rotationAxis, rotationAngle*DEG2RAD); - Matrix matTranslation = MatrixTranslate(position.x, position.y, position.z); - - Matrix matTransform = MatrixMultiply(MatrixMultiply(matScale, matRotation), matTranslation); - - // Combine model transformation matrix (model.transform) with matrix generated by function parameters (matTransform) - model.transform = MatrixMultiply(model.transform, matTransform); - - for (int i = 0; i < model.meshCount; i++) - { - Color color = model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color; - - Color colorTint = WHITE; - colorTint.r = (unsigned char)(((int)color.r*(int)tint.r)/255); - colorTint.g = (unsigned char)(((int)color.g*(int)tint.g)/255); - colorTint.b = (unsigned char)(((int)color.b*(int)tint.b)/255); - colorTint.a = (unsigned char)(((int)color.a*(int)tint.a)/255); - - model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = colorTint; - DrawChunkMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform); - model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = color; - } -} - -// Draw a 3d mesh with material and transform -void DrawChunkMesh(ChunkMesh mesh, Material material, Matrix transform) -{ -#if defined(GRAPHICS_API_OPENGL_11) - #define GL_VERTEX_ARRAY 0x8074 - #define GL_NORMAL_ARRAY 0x8075 - #define GL_COLOR_ARRAY 0x8076 - #define GL_TEXTURE_COORD_ARRAY 0x8078 - - rlEnableTexture(material.maps[MATERIAL_MAP_DIFFUSE].texture.id); - - rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.vertices); - rlEnableStatePointer(GL_TEXTURE_COORD_ARRAY, mesh.texcoords); - rlEnableStatePointer(GL_NORMAL_ARRAY, mesh.normals); - rlEnableStatePointer(GL_COLOR_ARRAY, mesh.colors); - - rlPushMatrix(); - rlMultMatrixf(MatrixToFloat(transform)); - rlColor4ub(material.maps[MATERIAL_MAP_DIFFUSE].color.r, - material.maps[MATERIAL_MAP_DIFFUSE].color.g, - material.maps[MATERIAL_MAP_DIFFUSE].color.b, - material.maps[MATERIAL_MAP_DIFFUSE].color.a); - - if (mesh.indices != NULL) rlDrawVertexArrayElements(0, mesh.triangleCount*3, mesh.indices); - else rlDrawVertexArray(0, mesh.vertexCount); - rlPopMatrix(); - - rlDisableStatePointer(GL_VERTEX_ARRAY); - rlDisableStatePointer(GL_TEXTURE_COORD_ARRAY); - rlDisableStatePointer(GL_NORMAL_ARRAY); - rlDisableStatePointer(GL_COLOR_ARRAY); - - rlDisableTexture(); -#endif - -#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - // Bind shader program - rlEnableShader(material.shader.id); - - // Send required data to shader (matrices, values) - //----------------------------------------------------- - // Upload to shader material.colDiffuse - if (material.shader.locs[CHUNK_SHADER_LOC_COLOR_DIFFUSE] != -1) - { - float values[4] = { - (float)material.maps[MATERIAL_MAP_DIFFUSE].color.r/255.0f, - (float)material.maps[MATERIAL_MAP_DIFFUSE].color.g/255.0f, - (float)material.maps[MATERIAL_MAP_DIFFUSE].color.b/255.0f, - (float)material.maps[MATERIAL_MAP_DIFFUSE].color.a/255.0f - }; - - rlSetUniform(material.shader.locs[CHUNK_SHADER_LOC_COLOR_DIFFUSE], values, SHADER_UNIFORM_VEC4, 1); - } - - // Upload to shader material.colSpecular (if location available) - if (material.shader.locs[CHUNK_SHADER_LOC_COLOR_SPECULAR] != -1) - { - float values[4] = { - (float)material.maps[MATERIAL_MAP_SPECULAR].color.r/255.0f, - (float)material.maps[MATERIAL_MAP_SPECULAR].color.g/255.0f, - (float)material.maps[MATERIAL_MAP_SPECULAR].color.b/255.0f, - (float)material.maps[MATERIAL_MAP_SPECULAR].color.a/255.0f - }; - - rlSetUniform(material.shader.locs[CHUNK_SHADER_LOC_COLOR_SPECULAR], values, SHADER_UNIFORM_VEC4, 1); - } - - // Get a copy of current matrices to work with, - // just in case stereo render is required, and we need to modify them - // NOTE: At this point the modelview matrix just contains the view matrix (camera) - // That's because BeginMode3D() sets it and there is no model-drawing function - // that modifies it, all use rlPushMatrix() and rlPopMatrix() - Matrix matModel = MatrixIdentity(); - Matrix matView = rlGetMatrixModelview(); - Matrix matModelView = MatrixIdentity(); - Matrix matProjection = rlGetMatrixProjection(); - - // Upload view and projection matrices (if locations available) - if (material.shader.locs[CHUNK_SHADER_LOC_MATRIX_VIEW] != -1) rlSetUniformMatrix(material.shader.locs[CHUNK_SHADER_LOC_MATRIX_VIEW], matView); - if (material.shader.locs[CHUNK_SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[CHUNK_SHADER_LOC_MATRIX_PROJECTION], matProjection); - - // Accumulate several model transformations: - // transform: model transformation provided (includes DrawModel() params combined with model.transform) - // rlGetMatrixTransform(): rlgl internal transform matrix due to push/pop matrix stack - matModel = MatrixMultiply(transform, rlGetMatrixTransform()); - - // Model transformation matrix is sent to shader uniform location: SHADER_LOC_MATRIX_MODEL - if (material.shader.locs[CHUNK_SHADER_LOC_MATRIX_MODEL] != -1) rlSetUniformMatrix(material.shader.locs[CHUNK_SHADER_LOC_MATRIX_MODEL], matModel); - - // Get model-view matrix - matModelView = MatrixMultiply(matModel, matView); - - // Upload model normal matrix (if locations available) - if (material.shader.locs[CHUNK_SHADER_LOC_MATRIX_NORMAL] != -1) rlSetUniformMatrix(material.shader.locs[CHUNK_SHADER_LOC_MATRIX_NORMAL], MatrixTranspose(MatrixInvert(matModel))); - //----------------------------------------------------- - - // Bind active texture maps (if available) - for (int i = 0; i < CHUNK_MAX_MATERIAL_MAPS; i++) - { - if (material.maps[i].texture.id > 0) - { - // Select current shader texture slot - rlActiveTextureSlot(i); - - // Enable texture for active slot - if ((i == MATERIAL_MAP_IRRADIANCE) || - (i == MATERIAL_MAP_PREFILTER) || - (i == MATERIAL_MAP_CUBEMAP)) rlEnableTextureCubemap(material.maps[i].texture.id); - else rlEnableTexture(material.maps[i].texture.id); - - rlSetUniform(material.shader.locs[CHUNK_SHADER_LOC_MAP_DIFFUSE + i], &i, SHADER_UNIFORM_INT, 1); - } - } - - // Try binding vertex array objects (VAO) or use VBOs if not possible - // WARNING: UploadMesh() enables all vertex attributes available in mesh and sets default attribute values - // for shader expected vertex attributes that are not provided by the mesh (i.e. colors) - // This could be a dangerous approach because different meshes with different shaders can enable/disable some attributes - if (!rlEnableVertexArray(mesh.vaoId)) - { - // Bind mesh VBO data: vertex position (shader-location = 0) - rlEnableVertexBuffer(mesh.vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION]); - rlSetVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_POSITION], 3, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_POSITION]); - - // Bind mesh VBO data: vertex texcoords (shader-location = 1) - rlEnableVertexBuffer(mesh.vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD]); - rlSetVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_TEXCOORD], 2, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_TEXCOORD]); - - // Bind mesh VBO data: vertex normal (shader-location = 2) - rlEnableVertexBuffer(mesh.vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL]); - rlSetVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_NORMAL], 3, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_NORMAL]); - - // Bind mesh VBO data: vertex tiletexcoords (shader-location = 3) - rlEnableVertexBuffer(mesh.vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD]); - rlSetVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_TILETEXCOORD], 2, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_TILETEXCOORD]); - - // Bind mesh VBO data: vertex metadata1 (shader-location = 4) - rlEnableVertexBuffer(mesh.vboId[CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1]); - rlSetVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_METADATA1], 4, RL_FLOAT, 0, 0, 0); - rlEnableVertexAttribute(material.shader.locs[CHUNK_SHADER_LOC_VERTEX_METADATA1]); - } - - int eyeCount = 1; - if (rlIsStereoRenderEnabled()) eyeCount = 2; - - for (int eye = 0; eye < eyeCount; eye++) - { - // Calculate model-view-projection matrix (MVP) - Matrix matModelViewProjection = MatrixIdentity(); - if (eyeCount == 1) matModelViewProjection = MatrixMultiply(matModelView, matProjection); - else - { - // Setup current eye viewport (half screen width) - rlViewport(eye*rlGetFramebufferWidth()/2, 0, rlGetFramebufferWidth()/2, rlGetFramebufferHeight()); - matModelViewProjection = MatrixMultiply(MatrixMultiply(matModelView, rlGetMatrixViewOffsetStereo(eye)), rlGetMatrixProjectionStereo(eye)); - } - - // Send combined model-view-projection matrix to shader - rlSetUniformMatrix(material.shader.locs[CHUNK_SHADER_LOC_MATRIX_MVP], matModelViewProjection); - - // Draw mesh - rlDrawVertexArray(0, mesh.vertexCount); - } - - // Unbind all bound texture maps - for (int i = 0; i < CHUNK_MAX_MATERIAL_MAPS; i++) - { - if (material.maps[i].texture.id > 0) - { - // Select current shader texture slot - rlActiveTextureSlot(i); - - // Disable texture for active slot - if ((i == MATERIAL_MAP_IRRADIANCE) || - (i == MATERIAL_MAP_PREFILTER) || - (i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap(); - else rlDisableTexture(); - } - } - - // Disable all possible vertex array objects (or VBOs) - rlDisableVertexArray(); - rlDisableVertexBuffer(); - rlDisableVertexBufferElement(); - - // Disable shader program - rlDisableShader(); - - // Restore rlgl internal modelview and projection matrices - rlSetMatrixModelview(matView); - rlSetMatrixProjection(matProjection); -#endif -} - -// Load shader from files and bind default locations -// NOTE: If shader string is NULL, using default vertex/fragment shaders -Shader LoadChunkShader(const char *vsFileName, const char *fsFileName) -{ - Shader shader = { 0 }; - - char *vShaderStr = NULL; - char *fShaderStr = NULL; - - if (vsFileName != NULL) vShaderStr = LoadFileText(vsFileName); - if (fsFileName != NULL) fShaderStr = LoadFileText(fsFileName); - - if ((vShaderStr == NULL) && (fShaderStr == NULL)) printf("CHUNK SHADER: Shader files provided are not valid, using default shader\n"); - - shader = LoadChunkShaderFromMemory(vShaderStr, fShaderStr); - - UnloadFileText(vShaderStr); - UnloadFileText(fShaderStr); - - printf("CHUNK SHADER: Shader loaded successfully from shader files\n"); - return shader; -} - -// Load shader from code strings and bind default locations -Shader LoadChunkShaderFromMemory(const char *vsCode, const char *fsCode) -{ - Shader shader = { 0 }; - - shader.id = rlLoadShaderCode(vsCode, fsCode); - - if (shader.id == rlGetShaderIdDefault()) shader.locs = rlGetShaderLocsDefault(); - else if (shader.id > 0) - { - // After custom shader loading, we TRY to set default location names - // Default shader attribute locations have been binded before linking: - // vertex position location = 0 - // vertex texcoord location = 1 - // vertex normal location = 2 - // vertex tiletexcoord location = 3 - // vertex metadata1 location = 4 - - // NOTE: If any location is not found, loc point becomes -1 - - shader.locs = (int *)RL_CALLOC(CHUNK_MAX_SHADER_LOCATIONS, sizeof(int)); - - // All locations reset to -1 (no location) - for (int i = 0; i < CHUNK_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1; - - // Get handles to GLSL input attribute locations - shader.locs[CHUNK_SHADER_LOC_VERTEX_POSITION] = rlGetLocationAttrib(shader.id, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_POSITION); - shader.locs[CHUNK_SHADER_LOC_VERTEX_TEXCOORD] = rlGetLocationAttrib(shader.id, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD); - shader.locs[CHUNK_SHADER_LOC_VERTEX_NORMAL] = rlGetLocationAttrib(shader.id, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_NORMAL); - shader.locs[CHUNK_SHADER_LOC_VERTEX_TILETEXCOORD] = rlGetLocationAttrib(shader.id, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_TILETEXCOORD); - shader.locs[CHUNK_SHADER_LOC_VERTEX_METADATA1] = rlGetLocationAttrib(shader.id, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_METADATA1); - - // Get handles to GLSL uniform locations (vertex shader) - shader.locs[CHUNK_SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_UNIFORM_NAME_MVP); - shader.locs[CHUNK_SHADER_LOC_MATRIX_VIEW] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_UNIFORM_NAME_VIEW); - shader.locs[CHUNK_SHADER_LOC_MATRIX_PROJECTION] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION); - shader.locs[CHUNK_SHADER_LOC_MATRIX_MODEL] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_UNIFORM_NAME_MODEL); - shader.locs[CHUNK_SHADER_LOC_MATRIX_NORMAL] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_UNIFORM_NAME_NORMAL); - - // Get handles to GLSL uniform locations (fragment shader) - shader.locs[CHUNK_SHADER_LOC_COLOR_DIFFUSE] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_UNIFORM_NAME_COLOR); - shader.locs[CHUNK_SHADER_LOC_MAP_DIFFUSE] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0); // SHADER_LOC_MAP_ALBEDO - shader.locs[CHUNK_SHADER_LOC_MAP_SPECULAR] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1); // SHADER_LOC_MAP_METALNESS - shader.locs[CHUNK_SHADER_LOC_MAP_NORMAL] = rlGetLocationUniform(shader.id, CHUNK_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2); - } - - return shader; -} - -#ifdef RLGL_IMPLEMENTATION - -// Load custom shader strings and return program id -unsigned int chunkLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId) -{ - unsigned int program = 0; - -#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - GLint success = 0; - program = glCreateProgram(); - - glAttachShader(program, vShaderId); - glAttachShader(program, fShaderId); - - // NOTE: Default attribute shader locations must be Bound before linking - glBindAttribLocation(program, CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_POSITION); - glBindAttribLocation(program, CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD); - glBindAttribLocation(program, CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_NORMAL); - glBindAttribLocation(program, CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_TILETEXCOORD, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_TILETEXCOORD); - glBindAttribLocation(program, CHUNK_DEFAULT_SHADER_ATTRIB_LOCATION_METADATA1, CHUNK_DEFAULT_SHADER_ATTRIB_NAME_METADATA1); - - // NOTE: If some attrib name is no found on the shader, it locations becomes -1 - - glLinkProgram(program); - - // NOTE: All uniform variables are intitialised to 0 when a program links - - glGetProgramiv(program, GL_LINK_STATUS, &success); - - if (success == GL_FALSE) - { - printf("SHADER: [ID %i] Failed to link shader program\n", program); - - int maxLength = 0; - glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); - - if (maxLength > 0) - { - int length = 0; - char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); - glGetProgramInfoLog(program, maxLength, &length, log); - printf("SHADER: [ID %i] Link error: %s\n", program, log); - RL_FREE(log); - } - - glDeleteProgram(program); - - program = 0; - } - else - { - // Get the size of compiled shader program (not available on OpenGL ES 2.0) - // NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero - //GLint binarySize = 0; - //glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize); - - printf(RL_LOG_INFO, "SHADER: [ID %i] Program shader loaded successfully\n", program); - } -#endif -} - - -// Load shader from code strings -// NOTE: If shader string is NULL, using default vertex/fragment shaders -unsigned int chunkLoadShaderCode(const char *vsCode, const char *fsCode) -{ - unsigned int id = 0; - -#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - unsigned int vertexShaderId = 0; - unsigned int fragmentShaderId = 0; - - // Compile vertex shader (if provided) - // NOTE: If not vertex shader is provided, use default one - if (vsCode != NULL) vertexShaderId = rlCompileShader(vsCode, GL_VERTEX_SHADER); - else { - printf("vertex shader is null!\n"); - exit(1); - } - - // Compile fragment shader (if provided) - // NOTE: If not vertex shader is provided, use default one - if (fsCode != NULL) fragmentShaderId = rlCompileShader(fsCode, GL_FRAGMENT_SHADER); - else { - printf("fragment shader is null!\n"); - exit(1); - } - - if ((vertexShaderId > 0) && (fragmentShaderId > 0)) - { - // One of or both shader are new, we need to compile a new shader program - id = chunkLoadShaderProgram(vertexShaderId, fragmentShaderId); - - // WARNING: Shader program linkage could fail and returned id is 0 - if (id > 0) glDetachShader(id, vertexShaderId); - glDeleteShader(vertexShaderId); - - // WARNING: Shader program linkage could fail and returned id is 0 - if (id > 0) glDetachShader(id, fragmentShaderId); - glDeleteShader(fragmentShaderId); - - // In case shader program loading failed - if (id == 0) - { - printf("failed to load custom shaders!\n"); - exit(1); - } - } -#endif - - return id; -} -#endif // RLGL_IMPLEMENTATION diff --git a/src/lib_helpers/raylib_helper.zig b/src/lib_helpers/raylib_helper.zig index 3e5b951..c30455f 100644 --- a/src/lib_helpers/raylib_helper.zig +++ b/src/lib_helpers/raylib_helper.zig @@ -1,5 +1,8 @@ pub const raylib = @cImport({ - @cInclude("raylib_extension.h"); + @cInclude("raylib.h"); + @cInclude("rlgl.h"); + @cInclude("raymath.h"); + @cInclude("rchunks_extension.h"); }); pub const v3 = struct { @@ -30,6 +33,9 @@ pub const v3 = struct { pub inline fn nor(a: raylib.Vector3) raylib.Vector3 { return raylib.Vector3Normalize(a); } + pub inline fn dot(a: raylib.Vector3, b: raylib.Vector3) f32 { + return raylib.Vector3DotProduct(a, b); + } pub inline fn cross(a: raylib.Vector3, b: raylib.Vector3) raylib.Vector3 { return raylib.Vector3CrossProduct(a, b); } diff --git a/src/main.zig b/src/main.zig index cf6ae68..a8c6a75 100644 --- a/src/main.zig +++ b/src/main.zig @@ -64,23 +64,19 @@ pub fn main() !void { defer raylib.UnloadTexture(texture); raylib.UnloadImage(tiles); + const ambient_occlusion_image = raylib.LoadImage("resources/images/ambient_occlusion.png"); + const ambient_occlusion_texture = raylib.LoadTextureFromImage(ambient_occlusion_image); + defer raylib.UnloadTexture(ambient_occlusion_texture); + raylib.UnloadImage(ambient_occlusion_image); + const shader = raylib.LoadChunkShader("resources/shaders/tiling.vs", "resources/shaders/tiling.fs"); defer raylib.UnloadShader(shader); - //std.debug.print("shader id: {}\n", .{shader.id}); - //std.debug.print("shader attrib position loc: {}\n", .{raylib.GetShaderLocationAttrib(shader, "vertexPosition")}); - //std.debug.print("shader attrib texcoord loc: {}\n", .{raylib.GetShaderLocationAttrib(shader, "vertexTexCoord")}); - //std.debug.print("shader attrib normal loc: {}\n", .{raylib.GetShaderLocationAttrib(shader, "vertexNormal")}); - //std.debug.print("shader attrib tiletexcoord loc: {}\n", .{raylib.GetShaderLocationAttrib(shader, "vertexTileTexCoord")}); - //std.debug.print("shader attrib metadata1 loc: {}\n", .{raylib.GetShaderLocationAttrib(shader, "vertexMetadata1")}); - //for (0..32) |i|{ - // std.debug.print("shader loc {}: {}\n", .{i, shader.locs[i]}); - //} raylib.SetShaderValue(shader, raylib.GetShaderLocation(shader, "textureTiling"), &.{ @as(f32, @floatFromInt(tile_columns)), @as(f32, @floatFromInt(tile_rows)) }, raylib.SHADER_UNIFORM_VEC2); var chunk = try chunks.Chunk.init(a7r); defer chunk.deinit(); - const height_generator = znoise.FnlGenerator{ .seed = 413445 }; + // const height_generator = znoise.FnlGenerator{ .seed = 413445 }; const tile_type_generator = znoise.FnlGenerator{ .seed = 4435, .frequency = 0.1 }; for (0..32) |raw_x| for (0..32) |raw_y| for (0..32) |raw_z| { const x: u5 = @intCast(raw_x); @@ -89,9 +85,10 @@ pub fn main() !void { const xf: f32 = @floatFromInt(raw_x); const yf: f32 = @floatFromInt(raw_y); const zf: f32 = @floatFromInt(raw_z); - const height: f32 = (height_generator.noise2(xf, zf) + 1) * 16 + @as(f32, if(x > 24) 4.0 else 0.0) + @as(f32, if(z < 8) 4.0 else 0.0); - const tile_type: u32 = if (tile_type_generator.noise3(xf, yf, zf) > 0) 1 else 2; - if (height >= yf) chunk.setTile(x, y, z, tile_type); + const tile_type: u32 = if (tile_type_generator.noise3(xf, yf, zf) > 0) 2 else 2; + // const height: f32 = (height_generator.noise2(xf, zf) + 1) * 16 + @as(f32, if(x > 24) 4.0 else 0.0) + @as(f32, if(z < 8) 4.0 else 0.0); + // if (height >= yf) chunk.setTile(x, y, z, tile_type); + if((xf-16)*(xf-16)+(yf-16)*(yf-16)+(zf-16)*(zf-16) < 16*16) chunk.setTile(x, y, z, tile_type); }; if (benchmark_chunk_meshing) { @@ -113,6 +110,13 @@ pub fn main() !void { model.materials[0].maps[raylib.MATERIAL_MAP_DIFFUSE].texture = texture; model.materials[0].shader = shader; + model.materials[0].shader.locs[raylib.SHADER_LOC_MAP_DIFFUSE+1] = raylib.GetShaderLocation(shader, "occlusionMap"); + raylib.SetShaderValueTexture(shader, model.materials[0].shader.locs[raylib.SHADER_LOC_MAP_DIFFUSE+1], ambient_occlusion_texture); model.materials[0].maps[raylib.MATERIAL_MAP_DIFFUSE+1].texture = ambient_occlusion_texture; + + // for (0..32) |i|{ + // std.debug.print("shader loc {}: {}\n", .{i, shader.locs[i]}); + // } + while (!raylib.WindowShouldClose()) { raylib.ClearBackground(raylib.BLACK); @@ -133,10 +137,17 @@ pub fn main() !void { moveCamera(&camera, v3.scl(v3.nor(movement), speed)); const delta = raylib.GetMouseDelta(); - // on the first mouse movement, for some reason mouse delta is completely insane, so we just ignore too large deltas + // on the first mouse movement, for some reason mouse delta is way too large, so we just ignore too large deltas if(delta.x < 1000 and delta.y < 1000 and delta.x > -1000 and delta.y > -1000){ - camera.target = v3.add(camera.position, v3.rotate(v3.sub(camera.target, camera.position), camera.up, -0.005 * delta.x)); - camera.target = v3.add(camera.position, v3.rotate(v3.sub(camera.target, camera.position), right, -0.005 * delta.y)); + var direction = v3.sub(camera.target, camera.position); + direction = v3.rotate(direction, camera.up, -0.005 * delta.x); + const tmp_direction = direction; + direction = v3.rotate(direction, right, -0.005 * delta.y); + if(tmp_direction.x*direction.x+tmp_direction.z*direction.z > 0){ + camera.target = v3.add(camera.position, direction); + } else { + camera.target = v3.add(camera.position, tmp_direction); + } } raylib.BeginDrawing(); @@ -150,6 +161,7 @@ pub fn main() !void { raylib.BeginShaderMode(shader); defer raylib.EndShaderMode(); + raylib.SetShaderValueTexture(shader, raylib.GetShaderLocation(shader, "ambientOcclusionTexture"), ambient_occlusion_texture); raylib.DrawChunkModel(model, model_position, 0.5, raylib.WHITE); } diff --git a/src/world/chunk.zig b/src/world/chunk.zig index 9ee5030..e57c88b 100644 --- a/src/world/chunk.zig +++ b/src/world/chunk.zig @@ -4,8 +4,10 @@ const raylib = raylib_helper.raylib; const v3 = raylib_helper.v3; const A7r = std.mem.Allocator; const comptimePrint = std.fmt.comptimePrint; + const VERTICES_BLOCK_SIZE = 2 * 3 * 3; const TEXCOORDS_BLOCK_SIZE = 2 * 2 * 3; + const X_DIRECTION = 0; const Y_DIRECTION = 1; const Z_DIRECTION = 2; @@ -19,6 +21,8 @@ const RawQuad = struct { normal: raylib.Vector3, width: f32, height: f32, + flip_x: bool, + flip_y: bool, top_obscuring_pattern: u32, left_obscuring_pattern: u32, @@ -32,15 +36,16 @@ const RawQuad = struct { // Quad shader metadata. Has to be 128 bytes in size. const Metadata1 = packed struct { - ambient_occlusion_1: u32, - ambient_occlusion_2: u32, - ambient_occlusion_corner1: bool, - ambient_occlusion_corner2: bool, - ambient_occlusion_corner3: bool, + top_left_obscured: bool, + top_right_obscured: bool, + bottom_right_obscured: bool, + bottom_left_obscured: bool, quad_height: u6, quad_width: u6, - unused: u17 = 0, + unused: u16 = 0, unused_2: u32 = 0, + unused_3: u32 = 0, + unused_4: u32 = 0, }; comptime { @@ -93,7 +98,7 @@ pub const Chunk = struct { } // Create a raw quad with specified parameters and surface, accounting for dimension and sign. Surface is the block ID. - fn pack_raw_quad( + fn packRawQuad( x: f32, y_start: usize, y_end: usize, z_start: usize, z_end: usize, @@ -104,6 +109,10 @@ pub const Chunk = struct { y_plus_obscuring_pattern: u32, z_minus_obscuring_pattern: u32, z_plus_obscuring_pattern: u32, + y_minus_z_minus_obscured: bool, + y_minus_z_plus_obscured: bool, + y_plus_z_plus_obscured: bool, + y_plus_z_minus_obscured: bool, ) RawQuad { const ymin: f32 = @as(f32, @floatFromInt(y_start)) - 0.5; const ymax: f32 = @as(f32, @floatFromInt(y_end)) - 0.5; @@ -113,6 +122,7 @@ pub const Chunk = struct { const yright: f32 = if (sign == 1) ymax else ymin; const zleft: f32 = if (sign == 1) zmin else zmax; const zright: f32 = if (sign == 1) zmax else zmin; + var raw_quad: RawQuad = undefined; switch (dimension) { X_DIRECTION => { @@ -125,15 +135,17 @@ pub const Chunk = struct { .normal = v3.new(sign, 0, 0), .width = zmax - zmin, .height = ymax - ymin, + .flip_x = sign == -1, + .flip_y = false, - .top_obscuring_pattern = z_plus_obscuring_pattern, + .top_obscuring_pattern = y_plus_obscuring_pattern, .left_obscuring_pattern = z_minus_obscuring_pattern, - .right_obscuring_pattern = y_plus_obscuring_pattern, + .right_obscuring_pattern = z_plus_obscuring_pattern, .bottom_obscuring_pattern = y_minus_obscuring_pattern, - .top_left_obscured = false, - .top_right_obscured = false, - .bottom_right_obscured = false, - .bottom_left_obscured = false, + .top_left_obscured = y_plus_z_minus_obscured, + .top_right_obscured = y_plus_z_plus_obscured, + .bottom_right_obscured = y_minus_z_plus_obscured, + .bottom_left_obscured = y_minus_z_minus_obscured, }; }, Y_DIRECTION => { @@ -146,15 +158,17 @@ pub const Chunk = struct { .normal = v3.new(0, 0, sign), .height = zmax - zmin, .width = ymax - ymin, + .flip_x = sign == 1, + .flip_y = false, - .top_obscuring_pattern = 0, - .left_obscuring_pattern = 0, - .right_obscuring_pattern = 0, - .bottom_obscuring_pattern = 0, - .top_left_obscured = false, - .top_right_obscured = false, - .bottom_right_obscured = false, - .bottom_left_obscured = false, + .top_obscuring_pattern = z_plus_obscuring_pattern, + .left_obscuring_pattern = y_minus_obscuring_pattern, + .right_obscuring_pattern = y_plus_obscuring_pattern, + .bottom_obscuring_pattern = z_minus_obscuring_pattern, + .top_left_obscured = y_minus_z_plus_obscured, + .top_right_obscured = y_plus_z_plus_obscured, + .bottom_right_obscured = y_plus_z_minus_obscured, + .bottom_left_obscured = y_minus_z_minus_obscured, }; }, Z_DIRECTION => { @@ -167,15 +181,17 @@ pub const Chunk = struct { .normal = v3.new(0, sign, 0), .width = zmax - zmin, .height = ymax - ymin, + .flip_x = sign == 1, + .flip_y = true, - .top_obscuring_pattern = 0, - .left_obscuring_pattern = 0, - .right_obscuring_pattern = 0, - .bottom_obscuring_pattern = 0, - .top_left_obscured = false, - .top_right_obscured = false, - .bottom_right_obscured = false, - .bottom_left_obscured = false, + .top_obscuring_pattern = y_plus_obscuring_pattern, + .left_obscuring_pattern = z_minus_obscuring_pattern, + .right_obscuring_pattern = z_plus_obscuring_pattern, + .bottom_obscuring_pattern = y_minus_obscuring_pattern, + .top_left_obscured = y_plus_z_minus_obscured, + .top_right_obscured = y_plus_z_plus_obscured, + .bottom_right_obscured = y_minus_z_plus_obscured, + .bottom_left_obscured = y_minus_z_minus_obscured, }; }, else => unreachable, @@ -256,8 +272,19 @@ pub const Chunk = struct { if (chunk.getTileRawShifted(if (sign == 1) x+1 else x-1, @intCast(y_end), z, dimension) != 0) y_plus_obscuring_pattern |= 1; } } - // std.debug.print("{}\n", .{z_minus_obscuring_pattern}); - const raw_quad = pack_raw_quad(@floatFromInt(raw_x), y_start, y_end, z_start, z_end, sign, dimension, surface, y_minus_obscuring_pattern, y_plus_obscuring_pattern, z_minus_obscuring_pattern, z_plus_obscuring_pattern); + var y_minus_z_minus_obscured = false; + var y_minus_z_plus_obscured = false; + var y_plus_z_plus_obscured = false; + var y_plus_z_minus_obscured = false; + if(x != (if (sign == 1) 31 else 0) and y_start != 0 and z_start != 0) + y_minus_z_minus_obscured = chunk.getTileRawShifted(if (sign == 1) x+1 else x-1, @intCast(y_start-1), @intCast(z_start-1), dimension) != 0; + if(x != (if (sign == 1) 31 else 0) and y_start != 0 and z_end != 32) + y_minus_z_plus_obscured = chunk.getTileRawShifted(if (sign == 1) x+1 else x-1, @intCast(y_start-1), @intCast(z_end), dimension) != 0; + if(x != (if (sign == 1) 31 else 0) and y_end != 32 and z_end != 32) + y_plus_z_plus_obscured = chunk.getTileRawShifted(if (sign == 1) x+1 else x-1, @intCast(y_end), @intCast(z_end), dimension) != 0; + if(x != (if (sign == 1) 31 else 0) and y_end != 32 and z_start != 0) + y_plus_z_minus_obscured = chunk.getTileRawShifted(if (sign == 1) x+1 else x-1, @intCast(y_end), @intCast(z_start-1), dimension) != 0; + const raw_quad = packRawQuad(@floatFromInt(raw_x), y_start, y_end, z_start, z_end, sign, dimension, surface, y_minus_obscuring_pattern, y_plus_obscuring_pattern, z_minus_obscuring_pattern, z_plus_obscuring_pattern, y_minus_z_minus_obscured, y_minus_z_plus_obscured, y_plus_z_plus_obscured, y_plus_z_minus_obscured); try raw_quads.append(raw_quad); }; } @@ -273,7 +300,8 @@ pub const Chunk = struct { const texcoords: [*]f32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 2))); const tiletexcoords: [*]f32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 2))); const normals: [*]f32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 3))); - const metadata1_packed: [*]f32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 4))); + const metadata1_packed: [*]u32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 4))); + const occlusion_sides: [*]u32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 4))); for (raw_quads.items, 0..) |raw_quad, i| { if (raw_quad.tile <= 0) continue; // air tile, no texture @@ -296,8 +324,10 @@ pub const Chunk = struct { const vertex_corners = .{ raw_quad.top_left, raw_quad.bottom_left, raw_quad.top_right, raw_quad.bottom_right, raw_quad.top_right, raw_quad.bottom_left }; const texcoords_x = .{ left_uv, left_uv, right_uv, right_uv, right_uv, left_uv }; const texcoords_y = .{ top_uv, bottom_uv } ** 3; - const tiletexcoords_x = .{ 0.0, 0.0, raw_quad.width, raw_quad.width, raw_quad.width, 0.0 }; - const tiletexcoords_y = .{ 0.0, raw_quad.height } ** 3; + const tiletexcoords_x = if(raw_quad.flip_x) + .{raw_quad.width, raw_quad.width, 0.0, 0.0, 0.0, raw_quad.width} else + .{ 0.0, 0.0, raw_quad.width, raw_quad.width, raw_quad.width, 0.0 }; + const tiletexcoords_y = if(raw_quad.flip_y) .{ raw_quad.height, 0.0 } ** 3 else .{ 0.0, raw_quad.height } ** 3; inline for (0..6) |corner_id| { vertices[VERTICES_BLOCK_SIZE * i + corner_id * 3 + 0] = vertex_corners[corner_id].x; @@ -310,35 +340,27 @@ pub const Chunk = struct { } // Store metadata into OpenGL buffers. - for (0..3) |j| { + for (0..6) |j| { const metadata1 = Metadata1{ - .ambient_occlusion_1 = raw_quad.left_obscuring_pattern, - .ambient_occlusion_2 = raw_quad.right_obscuring_pattern, - .ambient_occlusion_corner1 = raw_quad.top_left_obscured, - .ambient_occlusion_corner2 = raw_quad.bottom_left_obscured, - .ambient_occlusion_corner3 = raw_quad.top_right_obscured, + .top_left_obscured = raw_quad.top_left_obscured, + .top_right_obscured = raw_quad.top_right_obscured, + .bottom_left_obscured = raw_quad.bottom_left_obscured, + .bottom_right_obscured = raw_quad.bottom_right_obscured, .quad_height = @intFromFloat(raw_quad.height), .quad_width = @intFromFloat(raw_quad.width), }; - const metadata1_baked: [4]f32 = @bitCast(metadata1); + const metadata1_baked: [4]u32 = @bitCast(metadata1); for (0..4) |k| { - metadata1_packed[24 * i + 4 * j + k] = @bitCast(@as(f32, metadata1_baked[k])); + metadata1_packed[24 * i + 4 * j + k] = metadata1_baked[k]; } } - for (3..6) |j| { - const metadata1 = Metadata1{ - .ambient_occlusion_1 = raw_quad.right_obscuring_pattern, - .ambient_occlusion_2 = raw_quad.bottom_obscuring_pattern, - .ambient_occlusion_corner1 = raw_quad.bottom_right_obscured, - .ambient_occlusion_corner2 = raw_quad.top_right_obscured, - .ambient_occlusion_corner3 = raw_quad.bottom_left_obscured, - .quad_height = @intFromFloat(raw_quad.height), - .quad_width = @intFromFloat(raw_quad.width), - }; - const metadata1_baked: [4]f32 = @bitCast(metadata1); - for (0..4) |k| { - metadata1_packed[24 * i + 4 * j + k] = @bitCast(@as(f32, metadata1_baked[k])); - } + + // Store ambient occlusion sides into OpenGL buffers. + for (0..6) |j| { + occlusion_sides[24 * i + 4 * j + 0] = raw_quad.left_obscuring_pattern; + occlusion_sides[24 * i + 4 * j + 1] = raw_quad.right_obscuring_pattern; + occlusion_sides[24 * i + 4 * j + 2] = raw_quad.top_obscuring_pattern; + occlusion_sides[24 * i + 4 * j + 3] = raw_quad.bottom_obscuring_pattern; } } @@ -352,6 +374,7 @@ pub const Chunk = struct { .tiletexcoords = tiletexcoords, .normals = normals, .metadata1 = metadata1_packed, + .occlusion_sides = occlusion_sides, .vaoId = 0, .vboId = null,