koffi 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +6 -0
- package/build/qemu/2.1.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_x64.tar.gz +0 -0
- package/doc/templates/badges.html +3 -0
- package/package.json +2 -2
- package/src/abi_arm64.cc +35 -1
- package/src/abi_x64_win.cc +2 -8
- package/src/abi_x86.cc +1 -7
- package/src/ffi.hh +1 -1
- package/src/util.hh +6 -0
- package/test/raylib.js +37 -5
- package/vendor/libcc/libcc.cc +430 -196
- package/vendor/libcc/libcc.hh +1417 -1283
- package/vendor/raylib/BINDINGS.md +87 -70
- package/vendor/raylib/CHANGELOG +263 -50
- package/vendor/raylib/CMakeLists.txt +12 -0
- package/vendor/raylib/CMakeOptions.txt +8 -1
- package/vendor/raylib/CONVENTIONS.md +2 -3
- package/vendor/raylib/FAQ.md +137 -0
- package/vendor/raylib/HISTORY.md +62 -29
- package/vendor/raylib/LICENSE +1 -1
- package/vendor/raylib/README.md +22 -17
- package/vendor/raylib/ROADMAP.md +8 -7
- package/vendor/raylib/cmake/CompileDefinitions.cmake +19 -15
- package/vendor/raylib/cmake/GlfwImport.cmake +2 -0
- package/vendor/raylib/cmake/LibraryConfigurations.cmake +22 -16
- package/vendor/raylib/cmake/raylib-config.cmake +52 -49
- package/vendor/raylib/examples/CMakeLists.txt +14 -9
- package/vendor/raylib/examples/Makefile +112 -125
- package/vendor/raylib/examples/Makefile.Android +1 -1
- package/vendor/raylib/examples/Makefile.Web +145 -158
- package/vendor/raylib/examples/README.md +141 -141
- package/vendor/raylib/examples/audio/audio_module_playing.c +9 -4
- package/vendor/raylib/examples/audio/audio_multichannel_sound.c +8 -3
- package/vendor/raylib/examples/audio/audio_music_stream.c +16 -11
- package/vendor/raylib/examples/audio/audio_raw_stream.c +57 -9
- package/vendor/raylib/examples/audio/audio_sound_loading.c +8 -3
- package/vendor/raylib/examples/audio/audio_stream_effects.c +179 -0
- package/vendor/raylib/examples/audio/audio_stream_effects.png +0 -0
- package/vendor/raylib/examples/build.zig +17 -6
- package/vendor/raylib/examples/core/core_2d_camera.c +8 -4
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.c +105 -0
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.png +0 -0
- package/vendor/raylib/examples/core/core_2d_camera_platformer.c +11 -6
- package/vendor/raylib/examples/core/core_3d_camera_first_person.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_free.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_mode.c +8 -3
- package/vendor/raylib/examples/core/core_3d_picking.c +9 -4
- package/vendor/raylib/examples/core/core_basic_screen_manager.c +9 -7
- package/vendor/raylib/examples/core/core_basic_window.c +8 -3
- package/vendor/raylib/examples/core/core_basic_window_web.c +13 -11
- package/vendor/raylib/examples/core/core_custom_frame_control.c +9 -4
- package/vendor/raylib/examples/core/core_custom_logging.c +12 -8
- package/vendor/raylib/examples/core/core_drop_files.c +20 -12
- package/vendor/raylib/examples/core/core_input_gamepad.c +20 -15
- package/vendor/raylib/examples/core/core_input_gestures.c +19 -15
- package/vendor/raylib/examples/core/core_input_keys.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse_wheel.c +8 -3
- package/vendor/raylib/examples/core/core_input_multitouch.c +8 -3
- package/vendor/raylib/examples/core/core_loading_thread.c +10 -6
- package/vendor/raylib/examples/core/core_random_values.c +8 -3
- package/vendor/raylib/examples/core/core_scissor_test.c +8 -3
- package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +9 -4
- package/vendor/raylib/examples/core/core_split_screen.c +8 -3
- package/vendor/raylib/examples/core/core_storage_values.c +109 -3
- package/vendor/raylib/examples/core/core_vr_simulator.c +15 -7
- package/vendor/raylib/examples/core/core_window_flags.c +8 -3
- package/vendor/raylib/examples/core/core_window_letterbox.c +13 -18
- package/vendor/raylib/examples/core/core_window_should_close.c +77 -0
- package/vendor/raylib/examples/core/core_window_should_close.png +0 -0
- package/vendor/raylib/examples/core/core_world_screen.c +9 -4
- package/vendor/raylib/examples/examples_template.c +8 -3
- package/vendor/raylib/examples/models/models_animation.c +11 -7
- package/vendor/raylib/examples/models/models_billboard.c +9 -4
- package/vendor/raylib/examples/models/models_box_collisions.c +8 -3
- package/vendor/raylib/examples/models/models_cubicmap.c +9 -4
- package/vendor/raylib/examples/models/models_first_person_maze.c +9 -4
- package/vendor/raylib/examples/models/models_geometric_shapes.c +8 -3
- package/vendor/raylib/examples/models/models_heightmap.c +9 -4
- package/vendor/raylib/examples/models/models_loading.c +21 -17
- package/vendor/raylib/examples/models/models_loading_gltf.c +15 -41
- package/vendor/raylib/examples/models/models_loading_vox.c +9 -4
- package/vendor/raylib/examples/models/models_mesh_generation.c +71 -58
- package/vendor/raylib/examples/models/models_mesh_picking.c +25 -7
- package/vendor/raylib/examples/models/models_orthographic_projection.c +8 -5
- package/vendor/raylib/examples/models/models_rlgl_solar_system.c +6 -4
- package/vendor/raylib/examples/models/models_skybox.c +16 -12
- package/vendor/raylib/examples/models/models_waving_cubes.c +9 -4
- package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +12 -7
- package/vendor/raylib/examples/models/resources/LICENSE.md +9 -10
- package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +2 -23
- package/vendor/raylib/examples/models/resources/models/gltf/{raylib_32x32.glb → raylib_logo_3d.glb} +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.blend +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.glb +0 -0
- package/vendor/raylib/examples/others/easings_testbed.c +10 -8
- package/vendor/raylib/examples/others/easings_testbed.png +0 -0
- package/vendor/raylib/examples/others/embedded_files_loading.c +10 -5
- package/vendor/raylib/examples/others/embedded_files_loading.png +0 -0
- package/vendor/raylib/examples/others/raylib_opengl_interop.c +10 -6
- package/vendor/raylib/{src/extras/easings.h → examples/others/reasings.h} +38 -38
- package/vendor/raylib/examples/others/rlgl_compute_shader.c +21 -20
- package/vendor/raylib/examples/others/rlgl_compute_shader.png +0 -0
- package/vendor/raylib/examples/others/rlgl_standalone.c +4 -4
- package/vendor/raylib/examples/others/rlgl_standalone.png +0 -0
- package/vendor/raylib/examples/raylib_compile_execute.bat +2 -2
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +1 -1
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/{base_lighting_instanced.vs → lighting_instancing.vs} +2 -2
- package/vendor/raylib/examples/shaders/rlights.h +14 -27
- package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +24 -26
- package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +13 -8
- package/vendor/raylib/examples/shaders/shaders_fog.c +8 -12
- package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_julia_set.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +45 -119
- package/vendor/raylib/examples/shaders/shaders_model_shader.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_palette_switch.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_postprocessing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_raymarching.c +14 -11
- package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_simple_mask.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_spotlight.c +10 -6
- package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_texture_outline.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_texture_waves.c +8 -3
- package/vendor/raylib/{src/extras → examples/shapes}/raygui.h +1290 -1141
- package/vendor/raylib/examples/{others/easings.h → shapes/reasings.h} +40 -40
- package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_collision_area.c +10 -4
- package/vendor/raylib/examples/shapes/shapes_colors_palette.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_ring.c +10 -6
- package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_following_eyes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +14 -5
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.c +355 -0
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.png +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular.ttf +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular_OFL.txt +93 -0
- package/vendor/raylib/examples/text/resources/LICENSE.md +1 -1
- package/vendor/raylib/examples/text/text_codepoints_loading.c +138 -0
- package/vendor/raylib/examples/text/text_codepoints_loading.png +0 -0
- package/vendor/raylib/examples/text/text_draw_3d.c +42 -33
- package/vendor/raylib/examples/text/text_font_filters.c +14 -11
- package/vendor/raylib/examples/text/text_font_loading.c +9 -4
- package/vendor/raylib/examples/text/text_font_sdf.c +9 -4
- package/vendor/raylib/examples/text/text_font_spritefont.c +12 -6
- package/vendor/raylib/examples/text/text_format_text.c +8 -3
- package/vendor/raylib/examples/text/text_input_box.c +8 -3
- package/vendor/raylib/examples/text/text_raylib_fonts.c +9 -4
- package/vendor/raylib/examples/text/text_rectangle_bounds.c +9 -5
- package/vendor/raylib/examples/text/text_unicode.c +9 -7
- package/vendor/raylib/examples/text/text_writing_anim.c +8 -3
- package/vendor/raylib/examples/textures/resources/scarfy_run.gif +0 -0
- package/vendor/raylib/examples/textures/textures_background_scrolling.c +8 -3
- package/vendor/raylib/examples/textures/textures_blend_modes.c +8 -3
- package/vendor/raylib/examples/textures/textures_bunnymark.c +8 -3
- package/vendor/raylib/examples/textures/textures_draw_tiled.c +14 -10
- package/vendor/raylib/examples/textures/textures_fog_of_war.c +154 -0
- package/vendor/raylib/examples/textures/textures_fog_of_war.png +0 -0
- package/vendor/raylib/examples/textures/textures_gif_player.c +121 -0
- package/vendor/raylib/examples/textures/textures_gif_player.png +0 -0
- package/vendor/raylib/examples/textures/textures_image_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_generation.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_loading.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_processing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_text.c +8 -3
- package/vendor/raylib/examples/textures/textures_logo_raylib.c +8 -3
- package/vendor/raylib/examples/textures/textures_mouse_painting.c +9 -4
- package/vendor/raylib/examples/textures/textures_npatch_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_particles_blending.c +8 -3
- package/vendor/raylib/examples/textures/textures_polygon.c +9 -5
- package/vendor/raylib/examples/textures/textures_raw_data.c +8 -3
- package/vendor/raylib/examples/textures/{textures_rectangle.c → textures_sprite_anim.c} +11 -5
- package/vendor/raylib/examples/textures/{textures_rectangle.png → textures_sprite_anim.png} +0 -0
- package/vendor/raylib/examples/textures/textures_sprite_button.c +8 -3
- package/vendor/raylib/examples/textures/textures_sprite_explosion.c +8 -3
- package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +8 -3
- package/vendor/raylib/examples/textures/textures_to_image.c +8 -3
- package/vendor/raylib/parser/LICENSE +1 -1
- package/vendor/raylib/parser/Makefile +28 -0
- package/vendor/raylib/parser/README.md +49 -5
- package/vendor/raylib/parser/output/raylib_api.json +10717 -0
- package/vendor/raylib/parser/output/raylib_api.lua +7435 -0
- package/vendor/raylib/parser/{raylib_api.txt → output/raylib_api.txt} +1371 -824
- package/vendor/raylib/parser/{raylib_api.xml → output/raylib_api.xml} +827 -595
- package/vendor/raylib/parser/raylib_parser.c +1174 -196
- package/vendor/raylib/projects/4coder/Makefile +2 -4
- package/vendor/raylib/projects/4coder/main.c +0 -1
- package/vendor/raylib/projects/CMake/CMakeLists.txt +13 -16
- package/vendor/raylib/projects/CMake/README.md +27 -0
- package/vendor/raylib/projects/CMake/core_basic_window.c +52 -31
- package/vendor/raylib/projects/CodeBlocks/README.md +4 -4
- package/vendor/raylib/projects/Geany/core_basic_window.c +1 -1
- package/vendor/raylib/projects/Notepad++/c_raylib.xml +168 -128
- package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +168 -84
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +67 -51
- package/vendor/raylib/projects/README.md +1 -1
- package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +1 -1
- package/vendor/raylib/projects/VSCode/Makefile +8 -11
- package/vendor/raylib/projects/VSCode/main.c +53 -26
- package/vendor/raylib/projects/VSCode/resources/LICENSE +1 -0
- package/vendor/raylib/projects/scripts/build-linux.sh +6 -6
- package/vendor/raylib/projects/scripts/build-osx.sh +6 -6
- package/vendor/raylib/projects/scripts/build-rpi.sh +6 -6
- package/vendor/raylib/projects/scripts/build-windows.bat +2 -2
- package/vendor/raylib/src/CMakeLists.txt +6 -7
- package/vendor/raylib/src/Makefile +209 -103
- package/vendor/raylib/src/build.zig +56 -20
- package/vendor/raylib/src/config.h +32 -27
- package/vendor/raylib/src/external/cgltf.h +342 -104
- package/vendor/raylib/src/external/dr_wav.h +487 -225
- package/vendor/raylib/src/external/glfw/src/posix_time.c +1 -3
- package/vendor/raylib/src/external/glfw/src/wl_init.c +1 -3
- package/vendor/raylib/src/external/jar_xm.h +2 -1
- package/vendor/raylib/src/external/miniaudio.h +62251 -42061
- package/vendor/raylib/src/external/qoi.h +671 -0
- package/vendor/raylib/src/external/stb_vorbis.h +1 -1
- package/vendor/raylib/src/external/vox_loader.h +30 -25
- package/vendor/raylib/src/minshell.html +82 -0
- package/vendor/raylib/src/raudio.c +359 -201
- package/vendor/raylib/src/raylib.dll.rc +5 -5
- package/vendor/raylib/src/raylib.dll.rc.data +0 -0
- package/vendor/raylib/src/raylib.h +95 -63
- package/vendor/raylib/src/raylib.rc +5 -5
- package/vendor/raylib/src/raylib.rc.data +0 -0
- package/vendor/raylib/src/raymath.h +391 -133
- package/vendor/raylib/src/rcamera.h +32 -41
- package/vendor/raylib/src/rcore.c +775 -471
- package/vendor/raylib/src/rgestures.h +5 -5
- package/vendor/raylib/src/rglfw.c +3 -3
- package/vendor/raylib/src/rlgl.h +184 -144
- package/vendor/raylib/src/rmodels.c +207 -144
- package/vendor/raylib/src/rshapes.c +105 -47
- package/vendor/raylib/src/rtext.c +255 -38
- package/vendor/raylib/src/rtextures.c +167 -71
- package/vendor/raylib/src/shell.html +63 -63
- package/vendor/raylib/src/utils.c +49 -3
- package/vendor/raylib/src/utils.h +3 -3
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
- package/vendor/raylib/CONTRIBUTORS.md +0 -63
- package/vendor/raylib/SPONSORS.md +0 -68
- package/vendor/raylib/examples/core/core_quat_conversion.c +0 -132
- package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +0 -118
- package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
- package/vendor/raylib/examples/models/rlights.h +0 -183
- package/vendor/raylib/examples/others/raudio_standalone.c +0 -152
- package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
- package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
- package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
- package/vendor/raylib/examples/physics/physics_demo.c +0 -128
- package/vendor/raylib/examples/physics/physics_demo.png +0 -0
- package/vendor/raylib/examples/physics/physics_friction.c +0 -142
- package/vendor/raylib/examples/physics/physics_friction.png +0 -0
- package/vendor/raylib/examples/physics/physics_movement.c +0 -128
- package/vendor/raylib/examples/physics/physics_movement.png +0 -0
- package/vendor/raylib/examples/physics/physics_restitution.c +0 -129
- package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
- package/vendor/raylib/examples/physics/physics_shatter.c +0 -111
- package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
- package/vendor/raylib/parser/raylib_api.json +0 -6668
- package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
- package/vendor/raylib/projects/VS2019/raylib/resource.h +0 -14
- package/vendor/raylib/src/extras/physac.h +0 -1977
- package/vendor/raylib/src/extras/rmem.h +0 -751
- package/vendor/raylib/src/raudio.h +0 -198
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* cgltf - a single-file glTF 2.0 parser written in C99.
|
|
3
3
|
*
|
|
4
|
-
* Version: 1.
|
|
4
|
+
* Version: 1.12
|
|
5
5
|
*
|
|
6
6
|
* Website: https://github.com/jkuhlmann/cgltf
|
|
7
7
|
*
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
* By passing null for the output pointer, users can find out how many floats are required in the
|
|
64
64
|
* output buffer.
|
|
65
65
|
*
|
|
66
|
-
* `
|
|
66
|
+
* `cgltf_num_components` is a tiny utility that tells you the dimensionality of
|
|
67
67
|
* a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
|
|
68
68
|
* the necessary amount of memory.
|
|
69
69
|
*
|
|
@@ -99,6 +99,7 @@ extern "C" {
|
|
|
99
99
|
#endif
|
|
100
100
|
|
|
101
101
|
typedef size_t cgltf_size;
|
|
102
|
+
typedef long long int cgltf_ssize;
|
|
102
103
|
typedef float cgltf_float;
|
|
103
104
|
typedef int cgltf_int;
|
|
104
105
|
typedef unsigned int cgltf_uint;
|
|
@@ -109,6 +110,7 @@ typedef enum cgltf_file_type
|
|
|
109
110
|
cgltf_file_type_invalid,
|
|
110
111
|
cgltf_file_type_gltf,
|
|
111
112
|
cgltf_file_type_glb,
|
|
113
|
+
cgltf_file_type_max_enum
|
|
112
114
|
} cgltf_file_type;
|
|
113
115
|
|
|
114
116
|
typedef enum cgltf_result
|
|
@@ -123,12 +125,13 @@ typedef enum cgltf_result
|
|
|
123
125
|
cgltf_result_io_error,
|
|
124
126
|
cgltf_result_out_of_memory,
|
|
125
127
|
cgltf_result_legacy_gltf,
|
|
128
|
+
cgltf_result_max_enum
|
|
126
129
|
} cgltf_result;
|
|
127
130
|
|
|
128
131
|
typedef struct cgltf_memory_options
|
|
129
132
|
{
|
|
130
|
-
void* (*
|
|
131
|
-
void (*
|
|
133
|
+
void* (*alloc_func)(void* user, cgltf_size size);
|
|
134
|
+
void (*free_func) (void* user, void* ptr);
|
|
132
135
|
void* user_data;
|
|
133
136
|
} cgltf_memory_options;
|
|
134
137
|
|
|
@@ -152,6 +155,7 @@ typedef enum cgltf_buffer_view_type
|
|
|
152
155
|
cgltf_buffer_view_type_invalid,
|
|
153
156
|
cgltf_buffer_view_type_indices,
|
|
154
157
|
cgltf_buffer_view_type_vertices,
|
|
158
|
+
cgltf_buffer_view_type_max_enum
|
|
155
159
|
} cgltf_buffer_view_type;
|
|
156
160
|
|
|
157
161
|
typedef enum cgltf_attribute_type
|
|
@@ -164,6 +168,8 @@ typedef enum cgltf_attribute_type
|
|
|
164
168
|
cgltf_attribute_type_color,
|
|
165
169
|
cgltf_attribute_type_joints,
|
|
166
170
|
cgltf_attribute_type_weights,
|
|
171
|
+
cgltf_attribute_type_custom,
|
|
172
|
+
cgltf_attribute_type_max_enum
|
|
167
173
|
} cgltf_attribute_type;
|
|
168
174
|
|
|
169
175
|
typedef enum cgltf_component_type
|
|
@@ -175,6 +181,7 @@ typedef enum cgltf_component_type
|
|
|
175
181
|
cgltf_component_type_r_16u, /* UNSIGNED_SHORT */
|
|
176
182
|
cgltf_component_type_r_32u, /* UNSIGNED_INT */
|
|
177
183
|
cgltf_component_type_r_32f, /* FLOAT */
|
|
184
|
+
cgltf_component_type_max_enum
|
|
178
185
|
} cgltf_component_type;
|
|
179
186
|
|
|
180
187
|
typedef enum cgltf_type
|
|
@@ -187,6 +194,7 @@ typedef enum cgltf_type
|
|
|
187
194
|
cgltf_type_mat2,
|
|
188
195
|
cgltf_type_mat3,
|
|
189
196
|
cgltf_type_mat4,
|
|
197
|
+
cgltf_type_max_enum
|
|
190
198
|
} cgltf_type;
|
|
191
199
|
|
|
192
200
|
typedef enum cgltf_primitive_type
|
|
@@ -198,6 +206,7 @@ typedef enum cgltf_primitive_type
|
|
|
198
206
|
cgltf_primitive_type_triangles,
|
|
199
207
|
cgltf_primitive_type_triangle_strip,
|
|
200
208
|
cgltf_primitive_type_triangle_fan,
|
|
209
|
+
cgltf_primitive_type_max_enum
|
|
201
210
|
} cgltf_primitive_type;
|
|
202
211
|
|
|
203
212
|
typedef enum cgltf_alpha_mode
|
|
@@ -205,6 +214,7 @@ typedef enum cgltf_alpha_mode
|
|
|
205
214
|
cgltf_alpha_mode_opaque,
|
|
206
215
|
cgltf_alpha_mode_mask,
|
|
207
216
|
cgltf_alpha_mode_blend,
|
|
217
|
+
cgltf_alpha_mode_max_enum
|
|
208
218
|
} cgltf_alpha_mode;
|
|
209
219
|
|
|
210
220
|
typedef enum cgltf_animation_path_type {
|
|
@@ -213,18 +223,21 @@ typedef enum cgltf_animation_path_type {
|
|
|
213
223
|
cgltf_animation_path_type_rotation,
|
|
214
224
|
cgltf_animation_path_type_scale,
|
|
215
225
|
cgltf_animation_path_type_weights,
|
|
226
|
+
cgltf_animation_path_type_max_enum
|
|
216
227
|
} cgltf_animation_path_type;
|
|
217
228
|
|
|
218
229
|
typedef enum cgltf_interpolation_type {
|
|
219
230
|
cgltf_interpolation_type_linear,
|
|
220
231
|
cgltf_interpolation_type_step,
|
|
221
232
|
cgltf_interpolation_type_cubic_spline,
|
|
233
|
+
cgltf_interpolation_type_max_enum
|
|
222
234
|
} cgltf_interpolation_type;
|
|
223
235
|
|
|
224
236
|
typedef enum cgltf_camera_type {
|
|
225
237
|
cgltf_camera_type_invalid,
|
|
226
238
|
cgltf_camera_type_perspective,
|
|
227
239
|
cgltf_camera_type_orthographic,
|
|
240
|
+
cgltf_camera_type_max_enum
|
|
228
241
|
} cgltf_camera_type;
|
|
229
242
|
|
|
230
243
|
typedef enum cgltf_light_type {
|
|
@@ -232,12 +245,14 @@ typedef enum cgltf_light_type {
|
|
|
232
245
|
cgltf_light_type_directional,
|
|
233
246
|
cgltf_light_type_point,
|
|
234
247
|
cgltf_light_type_spot,
|
|
248
|
+
cgltf_light_type_max_enum
|
|
235
249
|
} cgltf_light_type;
|
|
236
250
|
|
|
237
251
|
typedef enum cgltf_data_free_method {
|
|
238
252
|
cgltf_data_free_method_none,
|
|
239
253
|
cgltf_data_free_method_file_release,
|
|
240
254
|
cgltf_data_free_method_memory_free,
|
|
255
|
+
cgltf_data_free_method_max_enum
|
|
241
256
|
} cgltf_data_free_method;
|
|
242
257
|
|
|
243
258
|
typedef struct cgltf_extras {
|
|
@@ -267,6 +282,7 @@ typedef enum cgltf_meshopt_compression_mode {
|
|
|
267
282
|
cgltf_meshopt_compression_mode_attributes,
|
|
268
283
|
cgltf_meshopt_compression_mode_triangles,
|
|
269
284
|
cgltf_meshopt_compression_mode_indices,
|
|
285
|
+
cgltf_meshopt_compression_mode_max_enum
|
|
270
286
|
} cgltf_meshopt_compression_mode;
|
|
271
287
|
|
|
272
288
|
typedef enum cgltf_meshopt_compression_filter {
|
|
@@ -274,6 +290,7 @@ typedef enum cgltf_meshopt_compression_filter {
|
|
|
274
290
|
cgltf_meshopt_compression_filter_octahedral,
|
|
275
291
|
cgltf_meshopt_compression_filter_quaternion,
|
|
276
292
|
cgltf_meshopt_compression_filter_exponential,
|
|
293
|
+
cgltf_meshopt_compression_filter_max_enum
|
|
277
294
|
} cgltf_meshopt_compression_filter;
|
|
278
295
|
|
|
279
296
|
typedef struct cgltf_meshopt_compression
|
|
@@ -474,6 +491,21 @@ typedef struct cgltf_sheen
|
|
|
474
491
|
cgltf_float sheen_roughness_factor;
|
|
475
492
|
} cgltf_sheen;
|
|
476
493
|
|
|
494
|
+
typedef struct cgltf_emissive_strength
|
|
495
|
+
{
|
|
496
|
+
cgltf_float emissive_strength;
|
|
497
|
+
} cgltf_emissive_strength;
|
|
498
|
+
|
|
499
|
+
typedef struct cgltf_iridescence
|
|
500
|
+
{
|
|
501
|
+
cgltf_float iridescence_factor;
|
|
502
|
+
cgltf_texture_view iridescence_texture;
|
|
503
|
+
cgltf_float iridescence_ior;
|
|
504
|
+
cgltf_float iridescence_thickness_min;
|
|
505
|
+
cgltf_float iridescence_thickness_max;
|
|
506
|
+
cgltf_texture_view iridescence_thickness_texture;
|
|
507
|
+
} cgltf_iridescence;
|
|
508
|
+
|
|
477
509
|
typedef struct cgltf_material
|
|
478
510
|
{
|
|
479
511
|
char* name;
|
|
@@ -485,6 +517,8 @@ typedef struct cgltf_material
|
|
|
485
517
|
cgltf_bool has_ior;
|
|
486
518
|
cgltf_bool has_specular;
|
|
487
519
|
cgltf_bool has_sheen;
|
|
520
|
+
cgltf_bool has_emissive_strength;
|
|
521
|
+
cgltf_bool has_iridescence;
|
|
488
522
|
cgltf_pbr_metallic_roughness pbr_metallic_roughness;
|
|
489
523
|
cgltf_pbr_specular_glossiness pbr_specular_glossiness;
|
|
490
524
|
cgltf_clearcoat clearcoat;
|
|
@@ -493,6 +527,8 @@ typedef struct cgltf_material
|
|
|
493
527
|
cgltf_sheen sheen;
|
|
494
528
|
cgltf_transmission transmission;
|
|
495
529
|
cgltf_volume volume;
|
|
530
|
+
cgltf_emissive_strength emissive_strength;
|
|
531
|
+
cgltf_iridescence iridescence;
|
|
496
532
|
cgltf_texture_view normal_texture;
|
|
497
533
|
cgltf_texture_view occlusion_texture;
|
|
498
534
|
cgltf_texture_view emissive_texture;
|
|
@@ -524,6 +560,12 @@ typedef struct cgltf_draco_mesh_compression {
|
|
|
524
560
|
cgltf_size attributes_count;
|
|
525
561
|
} cgltf_draco_mesh_compression;
|
|
526
562
|
|
|
563
|
+
typedef struct cgltf_mesh_gpu_instancing {
|
|
564
|
+
cgltf_buffer_view* buffer_view;
|
|
565
|
+
cgltf_attribute* attributes;
|
|
566
|
+
cgltf_size attributes_count;
|
|
567
|
+
} cgltf_mesh_gpu_instancing;
|
|
568
|
+
|
|
527
569
|
typedef struct cgltf_primitive {
|
|
528
570
|
cgltf_primitive_type type;
|
|
529
571
|
cgltf_accessor* indices;
|
|
@@ -628,6 +670,8 @@ struct cgltf_node {
|
|
|
628
670
|
cgltf_float scale[3];
|
|
629
671
|
cgltf_float matrix[16];
|
|
630
672
|
cgltf_extras extras;
|
|
673
|
+
cgltf_bool has_mesh_gpu_instancing;
|
|
674
|
+
cgltf_mesh_gpu_instancing mesh_gpu_instancing;
|
|
631
675
|
cgltf_size extensions_count;
|
|
632
676
|
cgltf_extension* extensions;
|
|
633
677
|
};
|
|
@@ -779,8 +823,8 @@ cgltf_result cgltf_load_buffers(
|
|
|
779
823
|
|
|
780
824
|
cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data);
|
|
781
825
|
|
|
782
|
-
|
|
783
|
-
|
|
826
|
+
cgltf_size cgltf_decode_string(char* string);
|
|
827
|
+
cgltf_size cgltf_decode_uri(char* uri);
|
|
784
828
|
|
|
785
829
|
cgltf_result cgltf_validate(cgltf_data* data);
|
|
786
830
|
|
|
@@ -829,6 +873,10 @@ cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras*
|
|
|
829
873
|
#include <stdlib.h> /* For malloc, free, atoi, atof */
|
|
830
874
|
#endif
|
|
831
875
|
|
|
876
|
+
#if CGLTF_VALIDATE_ENABLE_ASSERTS
|
|
877
|
+
#include <assert.h>
|
|
878
|
+
#endif
|
|
879
|
+
|
|
832
880
|
/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */
|
|
833
881
|
#define JSMN_PARENT_LINKS
|
|
834
882
|
|
|
@@ -920,7 +968,7 @@ static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_siz
|
|
|
920
968
|
{
|
|
921
969
|
return NULL;
|
|
922
970
|
}
|
|
923
|
-
void* result = options->memory.
|
|
971
|
+
void* result = options->memory.alloc_func(options->memory.user_data, element_size * count);
|
|
924
972
|
if (!result)
|
|
925
973
|
{
|
|
926
974
|
return NULL;
|
|
@@ -932,8 +980,8 @@ static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_siz
|
|
|
932
980
|
static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data)
|
|
933
981
|
{
|
|
934
982
|
(void)file_options;
|
|
935
|
-
void* (*memory_alloc)(void*, cgltf_size) = memory_options->
|
|
936
|
-
void (*memory_free)(void*, void*) = memory_options->
|
|
983
|
+
void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc_func ? memory_options->alloc_func : &cgltf_default_alloc;
|
|
984
|
+
void (*memory_free)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free;
|
|
937
985
|
|
|
938
986
|
FILE* file = fopen(path, "rb");
|
|
939
987
|
if (!file)
|
|
@@ -995,7 +1043,7 @@ static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* m
|
|
|
995
1043
|
static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data)
|
|
996
1044
|
{
|
|
997
1045
|
(void)file_options;
|
|
998
|
-
void (*memfree)(void*, void*) = memory_options->
|
|
1046
|
+
void (*memfree)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free;
|
|
999
1047
|
memfree(memory_options->user_data, data);
|
|
1000
1048
|
}
|
|
1001
1049
|
|
|
@@ -1014,13 +1062,13 @@ cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_s
|
|
|
1014
1062
|
}
|
|
1015
1063
|
|
|
1016
1064
|
cgltf_options fixed_options = *options;
|
|
1017
|
-
if (fixed_options.memory.
|
|
1065
|
+
if (fixed_options.memory.alloc_func == NULL)
|
|
1018
1066
|
{
|
|
1019
|
-
fixed_options.memory.
|
|
1067
|
+
fixed_options.memory.alloc_func = &cgltf_default_alloc;
|
|
1020
1068
|
}
|
|
1021
|
-
if (fixed_options.memory.
|
|
1069
|
+
if (fixed_options.memory.free_func == NULL)
|
|
1022
1070
|
{
|
|
1023
|
-
fixed_options.memory.
|
|
1071
|
+
fixed_options.memory.free_func = &cgltf_default_free;
|
|
1024
1072
|
}
|
|
1025
1073
|
|
|
1026
1074
|
uint32_t tmp;
|
|
@@ -1185,8 +1233,8 @@ static void cgltf_combine_paths(char* path, const char* base, const char* uri)
|
|
|
1185
1233
|
|
|
1186
1234
|
static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data)
|
|
1187
1235
|
{
|
|
1188
|
-
void* (*memory_alloc)(void*, cgltf_size) = options->memory.
|
|
1189
|
-
void (*memory_free)(void*, void*) = options->memory.
|
|
1236
|
+
void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc;
|
|
1237
|
+
void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free;
|
|
1190
1238
|
cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
|
|
1191
1239
|
|
|
1192
1240
|
char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1);
|
|
@@ -1212,8 +1260,8 @@ static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_s
|
|
|
1212
1260
|
|
|
1213
1261
|
cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data)
|
|
1214
1262
|
{
|
|
1215
|
-
void* (*memory_alloc)(void*, cgltf_size) = options->memory.
|
|
1216
|
-
void (*memory_free)(void*, void*) = options->memory.
|
|
1263
|
+
void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc;
|
|
1264
|
+
void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free;
|
|
1217
1265
|
|
|
1218
1266
|
unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size);
|
|
1219
1267
|
if (!data)
|
|
@@ -1266,25 +1314,29 @@ static int cgltf_unhex(char ch)
|
|
|
1266
1314
|
-1;
|
|
1267
1315
|
}
|
|
1268
1316
|
|
|
1269
|
-
|
|
1317
|
+
cgltf_size cgltf_decode_string(char* string)
|
|
1270
1318
|
{
|
|
1271
|
-
char* read =
|
|
1272
|
-
if (read ==
|
|
1319
|
+
char* read = string + strcspn(string, "\\");
|
|
1320
|
+
if (*read == 0)
|
|
1273
1321
|
{
|
|
1274
|
-
return;
|
|
1322
|
+
return read - string;
|
|
1275
1323
|
}
|
|
1276
1324
|
char* write = string;
|
|
1277
1325
|
char* last = string;
|
|
1278
1326
|
|
|
1279
|
-
|
|
1327
|
+
for (;;)
|
|
1280
1328
|
{
|
|
1281
1329
|
// Copy characters since last escaped sequence
|
|
1282
1330
|
cgltf_size written = read - last;
|
|
1283
|
-
|
|
1331
|
+
memmove(write, last, written);
|
|
1284
1332
|
write += written;
|
|
1285
1333
|
|
|
1334
|
+
if (*read++ == 0)
|
|
1335
|
+
{
|
|
1336
|
+
break;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1286
1339
|
// jsmn already checked that all escape sequences are valid
|
|
1287
|
-
++read;
|
|
1288
1340
|
switch (*read++)
|
|
1289
1341
|
{
|
|
1290
1342
|
case '\"': *write++ = '\"'; break;
|
|
@@ -1326,13 +1378,14 @@ void cgltf_decode_string(char* string)
|
|
|
1326
1378
|
}
|
|
1327
1379
|
|
|
1328
1380
|
last = read;
|
|
1329
|
-
read
|
|
1381
|
+
read += strcspn(read, "\\");
|
|
1330
1382
|
}
|
|
1331
1383
|
|
|
1332
|
-
|
|
1384
|
+
*write = 0;
|
|
1385
|
+
return write - string;
|
|
1333
1386
|
}
|
|
1334
1387
|
|
|
1335
|
-
|
|
1388
|
+
cgltf_size cgltf_decode_uri(char* uri)
|
|
1336
1389
|
{
|
|
1337
1390
|
char* write = uri;
|
|
1338
1391
|
char* i = uri;
|
|
@@ -1360,6 +1413,7 @@ void cgltf_decode_uri(char* uri)
|
|
|
1360
1413
|
}
|
|
1361
1414
|
|
|
1362
1415
|
*write = 0;
|
|
1416
|
+
return write - uri;
|
|
1363
1417
|
}
|
|
1364
1418
|
|
|
1365
1419
|
cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path)
|
|
@@ -1695,10 +1749,10 @@ void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_
|
|
|
1695
1749
|
{
|
|
1696
1750
|
for (cgltf_size i = 0; i < extensions_count; ++i)
|
|
1697
1751
|
{
|
|
1698
|
-
data->memory.
|
|
1699
|
-
data->memory.
|
|
1752
|
+
data->memory.free_func(data->memory.user_data, extensions[i].name);
|
|
1753
|
+
data->memory.free_func(data->memory.user_data, extensions[i].data);
|
|
1700
1754
|
}
|
|
1701
|
-
data->memory.
|
|
1755
|
+
data->memory.free_func(data->memory.user_data, extensions);
|
|
1702
1756
|
}
|
|
1703
1757
|
|
|
1704
1758
|
void cgltf_free(cgltf_data* data)
|
|
@@ -1710,16 +1764,16 @@ void cgltf_free(cgltf_data* data)
|
|
|
1710
1764
|
|
|
1711
1765
|
void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = data->file.release ? data->file.release : cgltf_default_file_release;
|
|
1712
1766
|
|
|
1713
|
-
data->memory.
|
|
1714
|
-
data->memory.
|
|
1715
|
-
data->memory.
|
|
1716
|
-
data->memory.
|
|
1767
|
+
data->memory.free_func(data->memory.user_data, data->asset.copyright);
|
|
1768
|
+
data->memory.free_func(data->memory.user_data, data->asset.generator);
|
|
1769
|
+
data->memory.free_func(data->memory.user_data, data->asset.version);
|
|
1770
|
+
data->memory.free_func(data->memory.user_data, data->asset.min_version);
|
|
1717
1771
|
|
|
1718
1772
|
cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
|
|
1719
1773
|
|
|
1720
1774
|
for (cgltf_size i = 0; i < data->accessors_count; ++i)
|
|
1721
1775
|
{
|
|
1722
|
-
data->memory.
|
|
1776
|
+
data->memory.free_func(data->memory.user_data, data->accessors[i].name);
|
|
1723
1777
|
|
|
1724
1778
|
if(data->accessors[i].is_sparse)
|
|
1725
1779
|
{
|
|
@@ -1729,20 +1783,20 @@ void cgltf_free(cgltf_data* data)
|
|
|
1729
1783
|
}
|
|
1730
1784
|
cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
|
|
1731
1785
|
}
|
|
1732
|
-
data->memory.
|
|
1786
|
+
data->memory.free_func(data->memory.user_data, data->accessors);
|
|
1733
1787
|
|
|
1734
1788
|
for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
|
|
1735
1789
|
{
|
|
1736
|
-
data->memory.
|
|
1737
|
-
data->memory.
|
|
1790
|
+
data->memory.free_func(data->memory.user_data, data->buffer_views[i].name);
|
|
1791
|
+
data->memory.free_func(data->memory.user_data, data->buffer_views[i].data);
|
|
1738
1792
|
|
|
1739
1793
|
cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
|
|
1740
1794
|
}
|
|
1741
|
-
data->memory.
|
|
1795
|
+
data->memory.free_func(data->memory.user_data, data->buffer_views);
|
|
1742
1796
|
|
|
1743
1797
|
for (cgltf_size i = 0; i < data->buffers_count; ++i)
|
|
1744
1798
|
{
|
|
1745
|
-
data->memory.
|
|
1799
|
+
data->memory.free_func(data->memory.user_data, data->buffers[i].name);
|
|
1746
1800
|
|
|
1747
1801
|
if (data->buffers[i].data_free_method == cgltf_data_free_method_file_release)
|
|
1748
1802
|
{
|
|
@@ -1750,74 +1804,74 @@ void cgltf_free(cgltf_data* data)
|
|
|
1750
1804
|
}
|
|
1751
1805
|
else if (data->buffers[i].data_free_method == cgltf_data_free_method_memory_free)
|
|
1752
1806
|
{
|
|
1753
|
-
data->memory.
|
|
1807
|
+
data->memory.free_func(data->memory.user_data, data->buffers[i].data);
|
|
1754
1808
|
}
|
|
1755
1809
|
|
|
1756
|
-
data->memory.
|
|
1810
|
+
data->memory.free_func(data->memory.user_data, data->buffers[i].uri);
|
|
1757
1811
|
|
|
1758
1812
|
cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
|
|
1759
1813
|
}
|
|
1760
1814
|
|
|
1761
|
-
data->memory.
|
|
1815
|
+
data->memory.free_func(data->memory.user_data, data->buffers);
|
|
1762
1816
|
|
|
1763
1817
|
for (cgltf_size i = 0; i < data->meshes_count; ++i)
|
|
1764
1818
|
{
|
|
1765
|
-
data->memory.
|
|
1819
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].name);
|
|
1766
1820
|
|
|
1767
1821
|
for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
|
|
1768
1822
|
{
|
|
1769
1823
|
for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
|
|
1770
1824
|
{
|
|
1771
|
-
data->memory.
|
|
1825
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name);
|
|
1772
1826
|
}
|
|
1773
1827
|
|
|
1774
|
-
data->memory.
|
|
1828
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes);
|
|
1775
1829
|
|
|
1776
1830
|
for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
|
|
1777
1831
|
{
|
|
1778
1832
|
for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
|
|
1779
1833
|
{
|
|
1780
|
-
data->memory.
|
|
1834
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name);
|
|
1781
1835
|
}
|
|
1782
1836
|
|
|
1783
|
-
data->memory.
|
|
1837
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes);
|
|
1784
1838
|
}
|
|
1785
1839
|
|
|
1786
|
-
data->memory.
|
|
1840
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets);
|
|
1787
1841
|
|
|
1788
1842
|
if (data->meshes[i].primitives[j].has_draco_mesh_compression)
|
|
1789
1843
|
{
|
|
1790
1844
|
for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k)
|
|
1791
1845
|
{
|
|
1792
|
-
data->memory.
|
|
1846
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name);
|
|
1793
1847
|
}
|
|
1794
1848
|
|
|
1795
|
-
data->memory.
|
|
1849
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
|
|
1796
1850
|
}
|
|
1797
1851
|
|
|
1798
|
-
data->memory.
|
|
1852
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].mappings);
|
|
1799
1853
|
|
|
1800
1854
|
cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
|
|
1801
1855
|
}
|
|
1802
1856
|
|
|
1803
|
-
data->memory.
|
|
1804
|
-
data->memory.
|
|
1857
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].primitives);
|
|
1858
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].weights);
|
|
1805
1859
|
|
|
1806
1860
|
for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j)
|
|
1807
1861
|
{
|
|
1808
|
-
data->memory.
|
|
1862
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].target_names[j]);
|
|
1809
1863
|
}
|
|
1810
1864
|
|
|
1811
1865
|
cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
|
|
1812
1866
|
|
|
1813
|
-
data->memory.
|
|
1867
|
+
data->memory.free_func(data->memory.user_data, data->meshes[i].target_names);
|
|
1814
1868
|
}
|
|
1815
1869
|
|
|
1816
|
-
data->memory.
|
|
1870
|
+
data->memory.free_func(data->memory.user_data, data->meshes);
|
|
1817
1871
|
|
|
1818
1872
|
for (cgltf_size i = 0; i < data->materials_count; ++i)
|
|
1819
1873
|
{
|
|
1820
|
-
data->memory.
|
|
1874
|
+
data->memory.free_func(data->memory.user_data, data->materials[i].name);
|
|
1821
1875
|
|
|
1822
1876
|
if(data->materials[i].has_pbr_metallic_roughness)
|
|
1823
1877
|
{
|
|
@@ -1853,6 +1907,11 @@ void cgltf_free(cgltf_data* data)
|
|
|
1853
1907
|
cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count);
|
|
1854
1908
|
cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count);
|
|
1855
1909
|
}
|
|
1910
|
+
if(data->materials[i].has_iridescence)
|
|
1911
|
+
{
|
|
1912
|
+
cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_texture.extensions, data->materials[i].iridescence.iridescence_texture.extensions_count);
|
|
1913
|
+
cgltf_free_extensions(data, data->materials[i].iridescence.iridescence_thickness_texture.extensions, data->materials[i].iridescence.iridescence_thickness_texture.extensions_count);
|
|
1914
|
+
}
|
|
1856
1915
|
|
|
1857
1916
|
cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count);
|
|
1858
1917
|
cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count);
|
|
@@ -1861,126 +1920,126 @@ void cgltf_free(cgltf_data* data)
|
|
|
1861
1920
|
cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
|
|
1862
1921
|
}
|
|
1863
1922
|
|
|
1864
|
-
data->memory.
|
|
1923
|
+
data->memory.free_func(data->memory.user_data, data->materials);
|
|
1865
1924
|
|
|
1866
1925
|
for (cgltf_size i = 0; i < data->images_count; ++i)
|
|
1867
1926
|
{
|
|
1868
|
-
data->memory.
|
|
1869
|
-
data->memory.
|
|
1870
|
-
data->memory.
|
|
1927
|
+
data->memory.free_func(data->memory.user_data, data->images[i].name);
|
|
1928
|
+
data->memory.free_func(data->memory.user_data, data->images[i].uri);
|
|
1929
|
+
data->memory.free_func(data->memory.user_data, data->images[i].mime_type);
|
|
1871
1930
|
|
|
1872
1931
|
cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
|
|
1873
1932
|
}
|
|
1874
1933
|
|
|
1875
|
-
data->memory.
|
|
1934
|
+
data->memory.free_func(data->memory.user_data, data->images);
|
|
1876
1935
|
|
|
1877
1936
|
for (cgltf_size i = 0; i < data->textures_count; ++i)
|
|
1878
1937
|
{
|
|
1879
|
-
data->memory.
|
|
1938
|
+
data->memory.free_func(data->memory.user_data, data->textures[i].name);
|
|
1880
1939
|
cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
|
|
1881
1940
|
}
|
|
1882
1941
|
|
|
1883
|
-
data->memory.
|
|
1942
|
+
data->memory.free_func(data->memory.user_data, data->textures);
|
|
1884
1943
|
|
|
1885
1944
|
for (cgltf_size i = 0; i < data->samplers_count; ++i)
|
|
1886
1945
|
{
|
|
1887
|
-
data->memory.
|
|
1946
|
+
data->memory.free_func(data->memory.user_data, data->samplers[i].name);
|
|
1888
1947
|
cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
|
|
1889
1948
|
}
|
|
1890
1949
|
|
|
1891
|
-
data->memory.
|
|
1950
|
+
data->memory.free_func(data->memory.user_data, data->samplers);
|
|
1892
1951
|
|
|
1893
1952
|
for (cgltf_size i = 0; i < data->skins_count; ++i)
|
|
1894
1953
|
{
|
|
1895
|
-
data->memory.
|
|
1896
|
-
data->memory.
|
|
1954
|
+
data->memory.free_func(data->memory.user_data, data->skins[i].name);
|
|
1955
|
+
data->memory.free_func(data->memory.user_data, data->skins[i].joints);
|
|
1897
1956
|
|
|
1898
1957
|
cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
|
|
1899
1958
|
}
|
|
1900
1959
|
|
|
1901
|
-
data->memory.
|
|
1960
|
+
data->memory.free_func(data->memory.user_data, data->skins);
|
|
1902
1961
|
|
|
1903
1962
|
for (cgltf_size i = 0; i < data->cameras_count; ++i)
|
|
1904
1963
|
{
|
|
1905
|
-
data->memory.
|
|
1964
|
+
data->memory.free_func(data->memory.user_data, data->cameras[i].name);
|
|
1906
1965
|
cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
|
|
1907
1966
|
}
|
|
1908
1967
|
|
|
1909
|
-
data->memory.
|
|
1968
|
+
data->memory.free_func(data->memory.user_data, data->cameras);
|
|
1910
1969
|
|
|
1911
1970
|
for (cgltf_size i = 0; i < data->lights_count; ++i)
|
|
1912
1971
|
{
|
|
1913
|
-
data->memory.
|
|
1972
|
+
data->memory.free_func(data->memory.user_data, data->lights[i].name);
|
|
1914
1973
|
}
|
|
1915
1974
|
|
|
1916
|
-
data->memory.
|
|
1975
|
+
data->memory.free_func(data->memory.user_data, data->lights);
|
|
1917
1976
|
|
|
1918
1977
|
for (cgltf_size i = 0; i < data->nodes_count; ++i)
|
|
1919
1978
|
{
|
|
1920
|
-
data->memory.
|
|
1921
|
-
data->memory.
|
|
1922
|
-
data->memory.
|
|
1979
|
+
data->memory.free_func(data->memory.user_data, data->nodes[i].name);
|
|
1980
|
+
data->memory.free_func(data->memory.user_data, data->nodes[i].children);
|
|
1981
|
+
data->memory.free_func(data->memory.user_data, data->nodes[i].weights);
|
|
1923
1982
|
cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
|
|
1924
1983
|
}
|
|
1925
1984
|
|
|
1926
|
-
data->memory.
|
|
1985
|
+
data->memory.free_func(data->memory.user_data, data->nodes);
|
|
1927
1986
|
|
|
1928
1987
|
for (cgltf_size i = 0; i < data->scenes_count; ++i)
|
|
1929
1988
|
{
|
|
1930
|
-
data->memory.
|
|
1931
|
-
data->memory.
|
|
1989
|
+
data->memory.free_func(data->memory.user_data, data->scenes[i].name);
|
|
1990
|
+
data->memory.free_func(data->memory.user_data, data->scenes[i].nodes);
|
|
1932
1991
|
|
|
1933
1992
|
cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
|
|
1934
1993
|
}
|
|
1935
1994
|
|
|
1936
|
-
data->memory.
|
|
1995
|
+
data->memory.free_func(data->memory.user_data, data->scenes);
|
|
1937
1996
|
|
|
1938
1997
|
for (cgltf_size i = 0; i < data->animations_count; ++i)
|
|
1939
1998
|
{
|
|
1940
|
-
data->memory.
|
|
1999
|
+
data->memory.free_func(data->memory.user_data, data->animations[i].name);
|
|
1941
2000
|
for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
|
|
1942
2001
|
{
|
|
1943
2002
|
cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
|
|
1944
2003
|
}
|
|
1945
|
-
data->memory.
|
|
2004
|
+
data->memory.free_func(data->memory.user_data, data->animations[i].samplers);
|
|
1946
2005
|
|
|
1947
2006
|
for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
|
|
1948
2007
|
{
|
|
1949
2008
|
cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
|
|
1950
2009
|
}
|
|
1951
|
-
data->memory.
|
|
2010
|
+
data->memory.free_func(data->memory.user_data, data->animations[i].channels);
|
|
1952
2011
|
|
|
1953
2012
|
cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
|
|
1954
2013
|
}
|
|
1955
2014
|
|
|
1956
|
-
data->memory.
|
|
2015
|
+
data->memory.free_func(data->memory.user_data, data->animations);
|
|
1957
2016
|
|
|
1958
2017
|
for (cgltf_size i = 0; i < data->variants_count; ++i)
|
|
1959
2018
|
{
|
|
1960
|
-
data->memory.
|
|
2019
|
+
data->memory.free_func(data->memory.user_data, data->variants[i].name);
|
|
1961
2020
|
}
|
|
1962
2021
|
|
|
1963
|
-
data->memory.
|
|
2022
|
+
data->memory.free_func(data->memory.user_data, data->variants);
|
|
1964
2023
|
|
|
1965
2024
|
cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
|
|
1966
2025
|
|
|
1967
2026
|
for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
|
|
1968
2027
|
{
|
|
1969
|
-
data->memory.
|
|
2028
|
+
data->memory.free_func(data->memory.user_data, data->extensions_used[i]);
|
|
1970
2029
|
}
|
|
1971
2030
|
|
|
1972
|
-
data->memory.
|
|
2031
|
+
data->memory.free_func(data->memory.user_data, data->extensions_used);
|
|
1973
2032
|
|
|
1974
2033
|
for (cgltf_size i = 0; i < data->extensions_required_count; ++i)
|
|
1975
2034
|
{
|
|
1976
|
-
data->memory.
|
|
2035
|
+
data->memory.free_func(data->memory.user_data, data->extensions_required[i]);
|
|
1977
2036
|
}
|
|
1978
2037
|
|
|
1979
|
-
data->memory.
|
|
2038
|
+
data->memory.free_func(data->memory.user_data, data->extensions_required);
|
|
1980
2039
|
|
|
1981
2040
|
file_release(&data->memory, &data->file, data->file_data);
|
|
1982
2041
|
|
|
1983
|
-
data->memory.
|
|
2042
|
+
data->memory.free_func(data->memory.user_data, data);
|
|
1984
2043
|
}
|
|
1985
2044
|
|
|
1986
2045
|
void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix)
|
|
@@ -2063,7 +2122,7 @@ void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
|
|
|
2063
2122
|
}
|
|
2064
2123
|
}
|
|
2065
2124
|
|
|
2066
|
-
static
|
|
2125
|
+
static cgltf_ssize cgltf_component_read_integer(const void* in, cgltf_component_type component_type)
|
|
2067
2126
|
{
|
|
2068
2127
|
switch (component_type)
|
|
2069
2128
|
{
|
|
@@ -2074,7 +2133,7 @@ static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_typ
|
|
|
2074
2133
|
case cgltf_component_type_r_32u:
|
|
2075
2134
|
return *((const uint32_t*) in);
|
|
2076
2135
|
case cgltf_component_type_r_32f:
|
|
2077
|
-
return (
|
|
2136
|
+
return (cgltf_ssize)*((const float*) in);
|
|
2078
2137
|
case cgltf_component_type_r_8:
|
|
2079
2138
|
return *((const int8_t*) in);
|
|
2080
2139
|
case cgltf_component_type_r_8u:
|
|
@@ -2084,6 +2143,23 @@ static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_typ
|
|
|
2084
2143
|
}
|
|
2085
2144
|
}
|
|
2086
2145
|
|
|
2146
|
+
static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type)
|
|
2147
|
+
{
|
|
2148
|
+
switch (component_type)
|
|
2149
|
+
{
|
|
2150
|
+
case cgltf_component_type_r_16u:
|
|
2151
|
+
return *((const uint16_t*) in);
|
|
2152
|
+
case cgltf_component_type_r_32u:
|
|
2153
|
+
return *((const uint32_t*) in);
|
|
2154
|
+
case cgltf_component_type_r_32f:
|
|
2155
|
+
return (cgltf_size)*((const float*) in);
|
|
2156
|
+
case cgltf_component_type_r_8u:
|
|
2157
|
+
return *((const uint8_t*) in);
|
|
2158
|
+
default:
|
|
2159
|
+
return 0;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2087
2163
|
static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized)
|
|
2088
2164
|
{
|
|
2089
2165
|
if (component_type == cgltf_component_type_r_32f)
|
|
@@ -2109,7 +2185,7 @@ static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_ty
|
|
|
2109
2185
|
}
|
|
2110
2186
|
}
|
|
2111
2187
|
|
|
2112
|
-
return (cgltf_float)
|
|
2188
|
+
return (cgltf_float)cgltf_component_read_integer(in, component_type);
|
|
2113
2189
|
}
|
|
2114
2190
|
|
|
2115
2191
|
static cgltf_size cgltf_component_size(cgltf_component_type component_type);
|
|
@@ -2467,7 +2543,7 @@ static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* toke
|
|
|
2467
2543
|
return CGLTF_ERROR_JSON;
|
|
2468
2544
|
}
|
|
2469
2545
|
int size = tokens[i].end - tokens[i].start;
|
|
2470
|
-
char* result = (char*)options->memory.
|
|
2546
|
+
char* result = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
|
|
2471
2547
|
if (!result)
|
|
2472
2548
|
{
|
|
2473
2549
|
return CGLTF_ERROR_NOMEM;
|
|
@@ -2522,6 +2598,12 @@ static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const
|
|
|
2522
2598
|
|
|
2523
2599
|
static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index)
|
|
2524
2600
|
{
|
|
2601
|
+
if (*name == '_')
|
|
2602
|
+
{
|
|
2603
|
+
*out_type = cgltf_attribute_type_custom;
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2525
2607
|
const char* us = strchr(name, '_');
|
|
2526
2608
|
size_t len = us ? (size_t)(us - name) : strlen(name);
|
|
2527
2609
|
|
|
@@ -2620,7 +2702,7 @@ static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmnto
|
|
|
2620
2702
|
}
|
|
2621
2703
|
|
|
2622
2704
|
cgltf_size name_length = tokens[i].end - tokens[i].start;
|
|
2623
|
-
out_extension->name = (char*)options->memory.
|
|
2705
|
+
out_extension->name = (char*)options->memory.alloc_func(options->memory.user_data, name_length + 1);
|
|
2624
2706
|
if (!out_extension->name)
|
|
2625
2707
|
{
|
|
2626
2708
|
return CGLTF_ERROR_NOMEM;
|
|
@@ -2631,7 +2713,7 @@ static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmnto
|
|
|
2631
2713
|
|
|
2632
2714
|
size_t start = tokens[i].start;
|
|
2633
2715
|
size_t size = tokens[i].end - start;
|
|
2634
|
-
out_extension->data = (char*)options->memory.
|
|
2716
|
+
out_extension->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
|
|
2635
2717
|
if (!out_extension->data)
|
|
2636
2718
|
{
|
|
2637
2719
|
return CGLTF_ERROR_NOMEM;
|
|
@@ -2712,6 +2794,37 @@ static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmnt
|
|
|
2712
2794
|
return i;
|
|
2713
2795
|
}
|
|
2714
2796
|
|
|
2797
|
+
static int cgltf_parse_json_mesh_gpu_instancing(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh_gpu_instancing* out_mesh_gpu_instancing)
|
|
2798
|
+
{
|
|
2799
|
+
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
|
2800
|
+
|
|
2801
|
+
int size = tokens[i].size;
|
|
2802
|
+
++i;
|
|
2803
|
+
|
|
2804
|
+
for (int j = 0; j < size; ++j)
|
|
2805
|
+
{
|
|
2806
|
+
CGLTF_CHECK_KEY(tokens[i]);
|
|
2807
|
+
|
|
2808
|
+
if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
|
|
2809
|
+
{
|
|
2810
|
+
i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_mesh_gpu_instancing->attributes, &out_mesh_gpu_instancing->attributes_count);
|
|
2811
|
+
}
|
|
2812
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0)
|
|
2813
|
+
{
|
|
2814
|
+
++i;
|
|
2815
|
+
out_mesh_gpu_instancing->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
|
|
2816
|
+
++i;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
if (i < 0)
|
|
2820
|
+
{
|
|
2821
|
+
return i;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
return i;
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2715
2828
|
static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_mapping* out_mappings, cgltf_size* offset)
|
|
2716
2829
|
{
|
|
2717
2830
|
(void)options;
|
|
@@ -3838,6 +3951,100 @@ static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* token
|
|
|
3838
3951
|
return i;
|
|
3839
3952
|
}
|
|
3840
3953
|
|
|
3954
|
+
static int cgltf_parse_json_emissive_strength(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_emissive_strength* out_emissive_strength)
|
|
3955
|
+
{
|
|
3956
|
+
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
|
3957
|
+
int size = tokens[i].size;
|
|
3958
|
+
++i;
|
|
3959
|
+
|
|
3960
|
+
// Default
|
|
3961
|
+
out_emissive_strength->emissive_strength = 1.f;
|
|
3962
|
+
|
|
3963
|
+
for (int j = 0; j < size; ++j)
|
|
3964
|
+
{
|
|
3965
|
+
CGLTF_CHECK_KEY(tokens[i]);
|
|
3966
|
+
|
|
3967
|
+
if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveStrength") == 0)
|
|
3968
|
+
{
|
|
3969
|
+
++i;
|
|
3970
|
+
out_emissive_strength->emissive_strength = cgltf_json_to_float(tokens + i, json_chunk);
|
|
3971
|
+
++i;
|
|
3972
|
+
}
|
|
3973
|
+
else
|
|
3974
|
+
{
|
|
3975
|
+
i = cgltf_skip_json(tokens, i + 1);
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3978
|
+
if (i < 0)
|
|
3979
|
+
{
|
|
3980
|
+
return i;
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
return i;
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3987
|
+
static int cgltf_parse_json_iridescence(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_iridescence* out_iridescence)
|
|
3988
|
+
{
|
|
3989
|
+
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
|
3990
|
+
int size = tokens[i].size;
|
|
3991
|
+
++i;
|
|
3992
|
+
|
|
3993
|
+
// Default
|
|
3994
|
+
out_iridescence->iridescence_ior = 1.3f;
|
|
3995
|
+
out_iridescence->iridescence_thickness_min = 100.f;
|
|
3996
|
+
out_iridescence->iridescence_thickness_max = 400.f;
|
|
3997
|
+
|
|
3998
|
+
for (int j = 0; j < size; ++j)
|
|
3999
|
+
{
|
|
4000
|
+
CGLTF_CHECK_KEY(tokens[i]);
|
|
4001
|
+
|
|
4002
|
+
if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceFactor") == 0)
|
|
4003
|
+
{
|
|
4004
|
+
++i;
|
|
4005
|
+
out_iridescence->iridescence_factor = cgltf_json_to_float(tokens + i, json_chunk);
|
|
4006
|
+
++i;
|
|
4007
|
+
}
|
|
4008
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceTexture") == 0)
|
|
4009
|
+
{
|
|
4010
|
+
i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_texture);
|
|
4011
|
+
}
|
|
4012
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceIor") == 0)
|
|
4013
|
+
{
|
|
4014
|
+
++i;
|
|
4015
|
+
out_iridescence->iridescence_ior = cgltf_json_to_float(tokens + i, json_chunk);
|
|
4016
|
+
++i;
|
|
4017
|
+
}
|
|
4018
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMinimum") == 0)
|
|
4019
|
+
{
|
|
4020
|
+
++i;
|
|
4021
|
+
out_iridescence->iridescence_thickness_min = cgltf_json_to_float(tokens + i, json_chunk);
|
|
4022
|
+
++i;
|
|
4023
|
+
}
|
|
4024
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMaximum") == 0)
|
|
4025
|
+
{
|
|
4026
|
+
++i;
|
|
4027
|
+
out_iridescence->iridescence_thickness_max = cgltf_json_to_float(tokens + i, json_chunk);
|
|
4028
|
+
++i;
|
|
4029
|
+
}
|
|
4030
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessTexture") == 0)
|
|
4031
|
+
{
|
|
4032
|
+
i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_thickness_texture);
|
|
4033
|
+
}
|
|
4034
|
+
else
|
|
4035
|
+
{
|
|
4036
|
+
i = cgltf_skip_json(tokens, i + 1);
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4039
|
+
if (i < 0)
|
|
4040
|
+
{
|
|
4041
|
+
return i;
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
return i;
|
|
4046
|
+
}
|
|
4047
|
+
|
|
3841
4048
|
static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image)
|
|
3842
4049
|
{
|
|
3843
4050
|
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
|
@@ -4035,6 +4242,10 @@ static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tok
|
|
|
4035
4242
|
{
|
|
4036
4243
|
i = cgltf_skip_json(tokens, i + 1);
|
|
4037
4244
|
}
|
|
4245
|
+
if (i < 0)
|
|
4246
|
+
{
|
|
4247
|
+
return i;
|
|
4248
|
+
}
|
|
4038
4249
|
}
|
|
4039
4250
|
}
|
|
4040
4251
|
else
|
|
@@ -4212,6 +4423,16 @@ static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* to
|
|
|
4212
4423
|
out_material->has_sheen = 1;
|
|
4213
4424
|
i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen);
|
|
4214
4425
|
}
|
|
4426
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_emissive_strength") == 0)
|
|
4427
|
+
{
|
|
4428
|
+
out_material->has_emissive_strength = 1;
|
|
4429
|
+
i = cgltf_parse_json_emissive_strength(tokens, i + 1, json_chunk, &out_material->emissive_strength);
|
|
4430
|
+
}
|
|
4431
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_iridescence") == 0)
|
|
4432
|
+
{
|
|
4433
|
+
out_material->has_iridescence = 1;
|
|
4434
|
+
i = cgltf_parse_json_iridescence(options, tokens, i + 1, json_chunk, &out_material->iridescence);
|
|
4435
|
+
}
|
|
4215
4436
|
else
|
|
4216
4437
|
{
|
|
4217
4438
|
i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++]));
|
|
@@ -5172,6 +5393,11 @@ static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens
|
|
|
5172
5393
|
}
|
|
5173
5394
|
}
|
|
5174
5395
|
}
|
|
5396
|
+
else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_mesh_gpu_instancing") == 0)
|
|
5397
|
+
{
|
|
5398
|
+
out_node->has_mesh_gpu_instancing = 1;
|
|
5399
|
+
i = cgltf_parse_json_mesh_gpu_instancing(options, tokens, i + 1, json_chunk, &out_node->mesh_gpu_instancing);
|
|
5400
|
+
}
|
|
5175
5401
|
else
|
|
5176
5402
|
{
|
|
5177
5403
|
i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++]));
|
|
@@ -5899,7 +6125,7 @@ cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk,
|
|
|
5899
6125
|
options->json_token_count = token_count;
|
|
5900
6126
|
}
|
|
5901
6127
|
|
|
5902
|
-
jsmntok_t* tokens = (jsmntok_t*)options->memory.
|
|
6128
|
+
jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc_func(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1));
|
|
5903
6129
|
|
|
5904
6130
|
if (!tokens)
|
|
5905
6131
|
{
|
|
@@ -5912,7 +6138,7 @@ cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk,
|
|
|
5912
6138
|
|
|
5913
6139
|
if (token_count <= 0)
|
|
5914
6140
|
{
|
|
5915
|
-
options->memory.
|
|
6141
|
+
options->memory.free_func(options->memory.user_data, tokens);
|
|
5916
6142
|
return cgltf_result_invalid_json;
|
|
5917
6143
|
}
|
|
5918
6144
|
|
|
@@ -5920,11 +6146,11 @@ cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk,
|
|
|
5920
6146
|
// for invalid JSON inputs this makes sure we don't perform out of bound reads of token data
|
|
5921
6147
|
tokens[token_count].type = JSMN_UNDEFINED;
|
|
5922
6148
|
|
|
5923
|
-
cgltf_data* data = (cgltf_data*)options->memory.
|
|
6149
|
+
cgltf_data* data = (cgltf_data*)options->memory.alloc_func(options->memory.user_data, sizeof(cgltf_data));
|
|
5924
6150
|
|
|
5925
6151
|
if (!data)
|
|
5926
6152
|
{
|
|
5927
|
-
options->memory.
|
|
6153
|
+
options->memory.free_func(options->memory.user_data, tokens);
|
|
5928
6154
|
return cgltf_result_out_of_memory;
|
|
5929
6155
|
}
|
|
5930
6156
|
|
|
@@ -5934,7 +6160,7 @@ cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk,
|
|
|
5934
6160
|
|
|
5935
6161
|
int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data);
|
|
5936
6162
|
|
|
5937
|
-
options->memory.
|
|
6163
|
+
options->memory.free_func(options->memory.user_data, tokens);
|
|
5938
6164
|
|
|
5939
6165
|
if (i < 0)
|
|
5940
6166
|
{
|
|
@@ -6058,6 +6284,9 @@ static int cgltf_fixup_pointers(cgltf_data* data)
|
|
|
6058
6284
|
|
|
6059
6285
|
CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count);
|
|
6060
6286
|
CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count);
|
|
6287
|
+
|
|
6288
|
+
CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_texture.texture, data->textures, data->textures_count);
|
|
6289
|
+
CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_thickness_texture.texture, data->textures, data->textures_count);
|
|
6061
6290
|
}
|
|
6062
6291
|
|
|
6063
6292
|
for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
|
|
@@ -6099,6 +6328,15 @@ static int cgltf_fixup_pointers(cgltf_data* data)
|
|
|
6099
6328
|
CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count);
|
|
6100
6329
|
CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count);
|
|
6101
6330
|
CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count);
|
|
6331
|
+
|
|
6332
|
+
if (data->nodes[i].has_mesh_gpu_instancing)
|
|
6333
|
+
{
|
|
6334
|
+
CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.buffer_view, data->buffer_views, data->buffer_views_count);
|
|
6335
|
+
for (cgltf_size m = 0; m < data->nodes[i].mesh_gpu_instancing.attributes_count; ++m)
|
|
6336
|
+
{
|
|
6337
|
+
CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.attributes[m].data, data->accessors, data->accessors_count);
|
|
6338
|
+
}
|
|
6339
|
+
}
|
|
6102
6340
|
}
|
|
6103
6341
|
|
|
6104
6342
|
for (cgltf_size i = 0; i < data->scenes_count; ++i)
|