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
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
* - Functions are always self-contained, no function use another raymath function inside,
|
|
19
19
|
* required code is directly re-implemented inside
|
|
20
20
|
* - Functions input parameters are always received by value (2 unavoidable exceptions)
|
|
21
|
-
* - Functions use always a "result"
|
|
21
|
+
* - Functions use always a "result" variable for return
|
|
22
22
|
* - Functions are always defined inline
|
|
23
23
|
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
|
|
24
24
|
*
|
|
25
25
|
*
|
|
26
26
|
* LICENSE: zlib/libpng
|
|
27
27
|
*
|
|
28
|
-
* Copyright (c) 2015-
|
|
28
|
+
* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
|
|
29
29
|
*
|
|
30
30
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
|
31
31
|
* will the authors be held liable for any damages arising from the use of this software.
|
|
@@ -77,6 +77,10 @@
|
|
|
77
77
|
#define PI 3.14159265358979323846f
|
|
78
78
|
#endif
|
|
79
79
|
|
|
80
|
+
#ifndef EPSILON
|
|
81
|
+
#define EPSILON 0.000001f
|
|
82
|
+
#endif
|
|
83
|
+
|
|
80
84
|
#ifndef DEG2RAD
|
|
81
85
|
#define DEG2RAD (PI/180.0f)
|
|
82
86
|
#endif
|
|
@@ -154,7 +158,7 @@ typedef struct float16 {
|
|
|
154
158
|
float v[16];
|
|
155
159
|
} float16;
|
|
156
160
|
|
|
157
|
-
#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), fminf(), fmaxf(), fabs()
|
|
161
|
+
#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabs()
|
|
158
162
|
|
|
159
163
|
//----------------------------------------------------------------------------------
|
|
160
164
|
// Module Functions Definition - Utils math
|
|
@@ -189,7 +193,23 @@ RMAPI float Normalize(float value, float start, float end)
|
|
|
189
193
|
// Remap input value within input range to output range
|
|
190
194
|
RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)
|
|
191
195
|
{
|
|
192
|
-
float result =(value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart;
|
|
196
|
+
float result = (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart;
|
|
197
|
+
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Wrap input value from min to max
|
|
202
|
+
RMAPI float Wrap(float value, float min, float max)
|
|
203
|
+
{
|
|
204
|
+
float result = value - (max - min)*floorf((value - min)/(max - min));
|
|
205
|
+
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Check whether two given floats are almost equal
|
|
210
|
+
RMAPI int FloatEquals(float x, float y)
|
|
211
|
+
{
|
|
212
|
+
int result = (fabsf(x - y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(x), fabsf(y))));
|
|
193
213
|
|
|
194
214
|
return result;
|
|
195
215
|
}
|
|
@@ -278,12 +298,18 @@ RMAPI float Vector2Distance(Vector2 v1, Vector2 v2)
|
|
|
278
298
|
return result;
|
|
279
299
|
}
|
|
280
300
|
|
|
281
|
-
// Calculate
|
|
282
|
-
RMAPI float
|
|
301
|
+
// Calculate square distance between two vectors
|
|
302
|
+
RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)
|
|
283
303
|
{
|
|
284
|
-
float result =
|
|
304
|
+
float result = ((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));
|
|
285
305
|
|
|
286
|
-
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Calculate angle from two vectors
|
|
310
|
+
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
|
|
311
|
+
{
|
|
312
|
+
float result = atan2f(v2.y, v2.x) - atan2f(v1.y, v1.x);
|
|
287
313
|
|
|
288
314
|
return result;
|
|
289
315
|
}
|
|
@@ -328,13 +354,29 @@ RMAPI Vector2 Vector2Normalize(Vector2 v)
|
|
|
328
354
|
|
|
329
355
|
if (length > 0)
|
|
330
356
|
{
|
|
331
|
-
|
|
332
|
-
result.
|
|
357
|
+
float ilength = 1.0f/length;
|
|
358
|
+
result.x = v.x*ilength;
|
|
359
|
+
result.y = v.y*ilength;
|
|
333
360
|
}
|
|
334
361
|
|
|
335
362
|
return result;
|
|
336
363
|
}
|
|
337
364
|
|
|
365
|
+
// Transforms a Vector2 by a given Matrix
|
|
366
|
+
RMAPI Vector2 Vector2Transform(Vector2 v, Matrix mat)
|
|
367
|
+
{
|
|
368
|
+
Vector2 result = { 0 };
|
|
369
|
+
|
|
370
|
+
float x = v.x;
|
|
371
|
+
float y = v.y;
|
|
372
|
+
float z = 0;
|
|
373
|
+
|
|
374
|
+
result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;
|
|
375
|
+
result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;
|
|
376
|
+
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
|
|
338
380
|
// Calculate linear interpolation between two vectors
|
|
339
381
|
RMAPI Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
|
|
340
382
|
{
|
|
@@ -364,8 +406,11 @@ RMAPI Vector2 Vector2Rotate(Vector2 v, float angle)
|
|
|
364
406
|
{
|
|
365
407
|
Vector2 result = { 0 };
|
|
366
408
|
|
|
367
|
-
|
|
368
|
-
|
|
409
|
+
float cosres = cosf(angle);
|
|
410
|
+
float sinres = sinf(angle);
|
|
411
|
+
|
|
412
|
+
result.x = v.x*cosres - v.y*sinres;
|
|
413
|
+
result.y = v.x*sinres + v.y*cosres;
|
|
369
414
|
|
|
370
415
|
return result;
|
|
371
416
|
}
|
|
@@ -389,6 +434,62 @@ RMAPI Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)
|
|
|
389
434
|
return result;
|
|
390
435
|
}
|
|
391
436
|
|
|
437
|
+
// Invert the given vector
|
|
438
|
+
RMAPI Vector2 Vector2Invert(Vector2 v)
|
|
439
|
+
{
|
|
440
|
+
Vector2 result = { 1.0f/v.x, 1.0f/v.y };
|
|
441
|
+
|
|
442
|
+
return result;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Clamp the components of the vector between
|
|
446
|
+
// min and max values specified by the given vectors
|
|
447
|
+
RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max)
|
|
448
|
+
{
|
|
449
|
+
Vector2 result = { 0 };
|
|
450
|
+
|
|
451
|
+
result.x = fminf(max.x, fmaxf(min.x, v.x));
|
|
452
|
+
result.y = fminf(max.y, fmaxf(min.y, v.y));
|
|
453
|
+
|
|
454
|
+
return result;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Clamp the magnitude of the vector between two min and max values
|
|
458
|
+
RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max)
|
|
459
|
+
{
|
|
460
|
+
Vector2 result = v;
|
|
461
|
+
|
|
462
|
+
float length = (v.x*v.x) + (v.y*v.y);
|
|
463
|
+
if (length > 0.0f)
|
|
464
|
+
{
|
|
465
|
+
length = sqrtf(length);
|
|
466
|
+
|
|
467
|
+
if (length < min)
|
|
468
|
+
{
|
|
469
|
+
float scale = min/length;
|
|
470
|
+
result.x = v.x*scale;
|
|
471
|
+
result.y = v.y*scale;
|
|
472
|
+
}
|
|
473
|
+
else if (length > max)
|
|
474
|
+
{
|
|
475
|
+
float scale = max/length;
|
|
476
|
+
result.x = v.x*scale;
|
|
477
|
+
result.y = v.y*scale;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return result;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Check whether two given vectors are almost equal
|
|
485
|
+
RMAPI int Vector2Equals(Vector2 p, Vector2 q)
|
|
486
|
+
{
|
|
487
|
+
int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
|
488
|
+
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y)))));
|
|
489
|
+
|
|
490
|
+
return result;
|
|
491
|
+
}
|
|
492
|
+
|
|
392
493
|
//----------------------------------------------------------------------------------
|
|
393
494
|
// Module Functions Definition - Vector3 math
|
|
394
495
|
//----------------------------------------------------------------------------------
|
|
@@ -473,14 +574,14 @@ RMAPI Vector3 Vector3Perpendicular(Vector3 v)
|
|
|
473
574
|
float min = (float) fabs(v.x);
|
|
474
575
|
Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
|
|
475
576
|
|
|
476
|
-
if (
|
|
577
|
+
if (fabsf(v.y) < min)
|
|
477
578
|
{
|
|
478
579
|
min = (float) fabs(v.y);
|
|
479
580
|
Vector3 tmp = {0.0f, 1.0f, 0.0f};
|
|
480
581
|
cardinalAxis = tmp;
|
|
481
582
|
}
|
|
482
583
|
|
|
483
|
-
if (
|
|
584
|
+
if (fabsf(v.z) < min)
|
|
484
585
|
{
|
|
485
586
|
Vector3 tmp = {0.0f, 0.0f, 1.0f};
|
|
486
587
|
cardinalAxis = tmp;
|
|
@@ -531,17 +632,28 @@ RMAPI float Vector3Distance(Vector3 v1, Vector3 v2)
|
|
|
531
632
|
return result;
|
|
532
633
|
}
|
|
533
634
|
|
|
534
|
-
// Calculate
|
|
535
|
-
RMAPI
|
|
635
|
+
// Calculate square distance between two vectors
|
|
636
|
+
RMAPI float Vector3DistanceSqr(Vector3 v1, Vector3 v2)
|
|
536
637
|
{
|
|
537
|
-
|
|
638
|
+
float result = 0.0f;
|
|
538
639
|
|
|
539
640
|
float dx = v2.x - v1.x;
|
|
540
641
|
float dy = v2.y - v1.y;
|
|
541
642
|
float dz = v2.z - v1.z;
|
|
643
|
+
result = dx*dx + dy*dy + dz*dz;
|
|
542
644
|
|
|
543
|
-
result
|
|
544
|
-
|
|
645
|
+
return result;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// Calculate angle between two vectors
|
|
649
|
+
RMAPI float Vector3Angle(Vector3 v1, Vector3 v2)
|
|
650
|
+
{
|
|
651
|
+
float result = 0.0f;
|
|
652
|
+
|
|
653
|
+
Vector3 cross = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x };
|
|
654
|
+
float len = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z);
|
|
655
|
+
float dot = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
|
|
656
|
+
result = atan2f(len, dot);
|
|
545
657
|
|
|
546
658
|
return result;
|
|
547
659
|
}
|
|
@@ -641,6 +753,58 @@ RMAPI Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q)
|
|
|
641
753
|
return result;
|
|
642
754
|
}
|
|
643
755
|
|
|
756
|
+
// Rotates a vector around an axis
|
|
757
|
+
RMAPI Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle)
|
|
758
|
+
{
|
|
759
|
+
// Using Euler-Rodrigues Formula
|
|
760
|
+
// Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula
|
|
761
|
+
|
|
762
|
+
Vector3 result = v;
|
|
763
|
+
|
|
764
|
+
// Vector3Normalize(axis);
|
|
765
|
+
float length = sqrtf(axis.x * axis.x + axis.y * axis.y + axis.z * axis.z);
|
|
766
|
+
if (length == 0.0f) length = 1.0f;
|
|
767
|
+
float ilength = 1.0f / length;
|
|
768
|
+
axis.x *= ilength;
|
|
769
|
+
axis.y *= ilength;
|
|
770
|
+
axis.z *= ilength;
|
|
771
|
+
|
|
772
|
+
angle /= 2.0f;
|
|
773
|
+
float a = sinf(angle);
|
|
774
|
+
float b = axis.x * a;
|
|
775
|
+
float c = axis.y * a;
|
|
776
|
+
float d = axis.z * a;
|
|
777
|
+
a = cosf(angle);
|
|
778
|
+
Vector3 w = { b, c, d };
|
|
779
|
+
|
|
780
|
+
// Vector3CrossProduct(w, v)
|
|
781
|
+
Vector3 wv = { w.y * v.z - w.z * v.y, w.z * v.x - w.x * v.z, w.x * v.y - w.y * v.x };
|
|
782
|
+
|
|
783
|
+
// Vector3CrossProduct(w, wv)
|
|
784
|
+
Vector3 wwv = { w.y * wv.z - w.z * wv.y, w.z * wv.x - w.x * wv.z, w.x * wv.y - w.y * wv.x };
|
|
785
|
+
|
|
786
|
+
// Vector3Scale(wv, 2 * a)
|
|
787
|
+
a *= 2;
|
|
788
|
+
wv.x *= a;
|
|
789
|
+
wv.y *= a;
|
|
790
|
+
wv.z *= a;
|
|
791
|
+
|
|
792
|
+
// Vector3Scale(wwv, 2)
|
|
793
|
+
wwv.x *= 2;
|
|
794
|
+
wwv.y *= 2;
|
|
795
|
+
wwv.z *= 2;
|
|
796
|
+
|
|
797
|
+
result.x += wv.x;
|
|
798
|
+
result.y += wv.y;
|
|
799
|
+
result.z += wv.z;
|
|
800
|
+
|
|
801
|
+
result.x += wwv.x;
|
|
802
|
+
result.y += wwv.y;
|
|
803
|
+
result.z += wwv.z;
|
|
804
|
+
|
|
805
|
+
return result;
|
|
806
|
+
}
|
|
807
|
+
|
|
644
808
|
// Calculate linear interpolation between two vectors
|
|
645
809
|
RMAPI Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount)
|
|
646
810
|
{
|
|
@@ -815,6 +979,92 @@ RMAPI float3 Vector3ToFloatV(Vector3 v)
|
|
|
815
979
|
return buffer;
|
|
816
980
|
}
|
|
817
981
|
|
|
982
|
+
// Invert the given vector
|
|
983
|
+
RMAPI Vector3 Vector3Invert(Vector3 v)
|
|
984
|
+
{
|
|
985
|
+
Vector3 result = { 1.0f/v.x, 1.0f/v.y, 1.0f/v.z };
|
|
986
|
+
|
|
987
|
+
return result;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Clamp the components of the vector between
|
|
991
|
+
// min and max values specified by the given vectors
|
|
992
|
+
RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max)
|
|
993
|
+
{
|
|
994
|
+
Vector3 result = { 0 };
|
|
995
|
+
|
|
996
|
+
result.x = fminf(max.x, fmaxf(min.x, v.x));
|
|
997
|
+
result.y = fminf(max.y, fmaxf(min.y, v.y));
|
|
998
|
+
result.z = fminf(max.z, fmaxf(min.z, v.z));
|
|
999
|
+
|
|
1000
|
+
return result;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// Clamp the magnitude of the vector between two values
|
|
1004
|
+
RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max)
|
|
1005
|
+
{
|
|
1006
|
+
Vector3 result = v;
|
|
1007
|
+
|
|
1008
|
+
float length = (v.x*v.x) + (v.y*v.y) + (v.z*v.z);
|
|
1009
|
+
if (length > 0.0f)
|
|
1010
|
+
{
|
|
1011
|
+
length = sqrtf(length);
|
|
1012
|
+
|
|
1013
|
+
if (length < min)
|
|
1014
|
+
{
|
|
1015
|
+
float scale = min/length;
|
|
1016
|
+
result.x = v.x*scale;
|
|
1017
|
+
result.y = v.y*scale;
|
|
1018
|
+
result.z = v.z*scale;
|
|
1019
|
+
}
|
|
1020
|
+
else if (length > max)
|
|
1021
|
+
{
|
|
1022
|
+
float scale = max/length;
|
|
1023
|
+
result.x = v.x*scale;
|
|
1024
|
+
result.y = v.y*scale;
|
|
1025
|
+
result.z = v.z*scale;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
// Check whether two given vectors are almost equal
|
|
1033
|
+
RMAPI int Vector3Equals(Vector3 p, Vector3 q)
|
|
1034
|
+
{
|
|
1035
|
+
int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
|
1036
|
+
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
|
|
1037
|
+
((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z)))));
|
|
1038
|
+
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// Compute the direction of a refracted ray where v specifies the
|
|
1043
|
+
// normalized direction of the incoming ray, n specifies the
|
|
1044
|
+
// normalized normal vector of the interface of two optical media,
|
|
1045
|
+
// and r specifies the ratio of the refractive index of the medium
|
|
1046
|
+
// from where the ray comes to the refractive index of the medium
|
|
1047
|
+
// on the other side of the surface
|
|
1048
|
+
RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r)
|
|
1049
|
+
{
|
|
1050
|
+
Vector3 result = { 0 };
|
|
1051
|
+
|
|
1052
|
+
float dot = v.x*n.x + v.y*n.y + v.z*n.z;
|
|
1053
|
+
float d = 1.0f - r*r*(1.0f - dot*dot);
|
|
1054
|
+
|
|
1055
|
+
if (d >= 0.0f)
|
|
1056
|
+
{
|
|
1057
|
+
d = sqrtf(d);
|
|
1058
|
+
v.x = r*v.x - (r*dot + d)*n.x;
|
|
1059
|
+
v.y = r*v.y - (r*dot + d)*n.y;
|
|
1060
|
+
v.z = r*v.z - (r*dot + d)*n.z;
|
|
1061
|
+
|
|
1062
|
+
result = v;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
return result;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
818
1068
|
//----------------------------------------------------------------------------------
|
|
819
1069
|
// Module Functions Definition - Matrix math
|
|
820
1070
|
//----------------------------------------------------------------------------------
|
|
@@ -920,45 +1170,6 @@ RMAPI Matrix MatrixInvert(Matrix mat)
|
|
|
920
1170
|
return result;
|
|
921
1171
|
}
|
|
922
1172
|
|
|
923
|
-
// Normalize provided matrix
|
|
924
|
-
RMAPI Matrix MatrixNormalize(Matrix mat)
|
|
925
|
-
{
|
|
926
|
-
Matrix result = { 0 };
|
|
927
|
-
|
|
928
|
-
// Cache the matrix values (speed optimization)
|
|
929
|
-
float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3;
|
|
930
|
-
float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7;
|
|
931
|
-
float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11;
|
|
932
|
-
float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15;
|
|
933
|
-
|
|
934
|
-
// MatrixDeterminant(mat)
|
|
935
|
-
float det = a30*a21*a12*a03 - a20*a31*a12*a03 - a30*a11*a22*a03 + a10*a31*a22*a03 +
|
|
936
|
-
a20*a11*a32*a03 - a10*a21*a32*a03 - a30*a21*a02*a13 + a20*a31*a02*a13 +
|
|
937
|
-
a30*a01*a22*a13 - a00*a31*a22*a13 - a20*a01*a32*a13 + a00*a21*a32*a13 +
|
|
938
|
-
a30*a11*a02*a23 - a10*a31*a02*a23 - a30*a01*a12*a23 + a00*a31*a12*a23 +
|
|
939
|
-
a10*a01*a32*a23 - a00*a11*a32*a23 - a20*a11*a02*a33 + a10*a21*a02*a33 +
|
|
940
|
-
a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33;
|
|
941
|
-
|
|
942
|
-
result.m0 = mat.m0/det;
|
|
943
|
-
result.m1 = mat.m1/det;
|
|
944
|
-
result.m2 = mat.m2/det;
|
|
945
|
-
result.m3 = mat.m3/det;
|
|
946
|
-
result.m4 = mat.m4/det;
|
|
947
|
-
result.m5 = mat.m5/det;
|
|
948
|
-
result.m6 = mat.m6/det;
|
|
949
|
-
result.m7 = mat.m7/det;
|
|
950
|
-
result.m8 = mat.m8/det;
|
|
951
|
-
result.m9 = mat.m9/det;
|
|
952
|
-
result.m10 = mat.m10/det;
|
|
953
|
-
result.m11 = mat.m11/det;
|
|
954
|
-
result.m12 = mat.m12/det;
|
|
955
|
-
result.m13 = mat.m13/det;
|
|
956
|
-
result.m14 = mat.m14/det;
|
|
957
|
-
result.m15 = mat.m15/det;
|
|
958
|
-
|
|
959
|
-
return result;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
1173
|
// Get identity matrix
|
|
963
1174
|
RMAPI Matrix MatrixIdentity(void)
|
|
964
1175
|
{
|
|
@@ -1102,7 +1313,8 @@ RMAPI Matrix MatrixRotate(Vector3 axis, float angle)
|
|
|
1102
1313
|
return result;
|
|
1103
1314
|
}
|
|
1104
1315
|
|
|
1105
|
-
// Get x-rotation matrix
|
|
1316
|
+
// Get x-rotation matrix
|
|
1317
|
+
// NOTE: Angle must be provided in radians
|
|
1106
1318
|
RMAPI Matrix MatrixRotateX(float angle)
|
|
1107
1319
|
{
|
|
1108
1320
|
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
|
@@ -1114,14 +1326,15 @@ RMAPI Matrix MatrixRotateX(float angle)
|
|
|
1114
1326
|
float sinres = sinf(angle);
|
|
1115
1327
|
|
|
1116
1328
|
result.m5 = cosres;
|
|
1117
|
-
result.m6 =
|
|
1118
|
-
result.m9 = sinres;
|
|
1329
|
+
result.m6 = sinres;
|
|
1330
|
+
result.m9 = -sinres;
|
|
1119
1331
|
result.m10 = cosres;
|
|
1120
1332
|
|
|
1121
1333
|
return result;
|
|
1122
1334
|
}
|
|
1123
1335
|
|
|
1124
|
-
// Get y-rotation matrix
|
|
1336
|
+
// Get y-rotation matrix
|
|
1337
|
+
// NOTE: Angle must be provided in radians
|
|
1125
1338
|
RMAPI Matrix MatrixRotateY(float angle)
|
|
1126
1339
|
{
|
|
1127
1340
|
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
|
@@ -1133,14 +1346,15 @@ RMAPI Matrix MatrixRotateY(float angle)
|
|
|
1133
1346
|
float sinres = sinf(angle);
|
|
1134
1347
|
|
|
1135
1348
|
result.m0 = cosres;
|
|
1136
|
-
result.m2 = sinres;
|
|
1137
|
-
result.m8 =
|
|
1349
|
+
result.m2 = -sinres;
|
|
1350
|
+
result.m8 = sinres;
|
|
1138
1351
|
result.m10 = cosres;
|
|
1139
1352
|
|
|
1140
1353
|
return result;
|
|
1141
1354
|
}
|
|
1142
1355
|
|
|
1143
|
-
// Get z-rotation matrix
|
|
1356
|
+
// Get z-rotation matrix
|
|
1357
|
+
// NOTE: Angle must be provided in radians
|
|
1144
1358
|
RMAPI Matrix MatrixRotateZ(float angle)
|
|
1145
1359
|
{
|
|
1146
1360
|
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
|
@@ -1152,74 +1366,76 @@ RMAPI Matrix MatrixRotateZ(float angle)
|
|
|
1152
1366
|
float sinres = sinf(angle);
|
|
1153
1367
|
|
|
1154
1368
|
result.m0 = cosres;
|
|
1155
|
-
result.m1 =
|
|
1156
|
-
result.m4 = sinres;
|
|
1369
|
+
result.m1 = sinres;
|
|
1370
|
+
result.m4 = -sinres;
|
|
1157
1371
|
result.m5 = cosres;
|
|
1158
1372
|
|
|
1159
1373
|
return result;
|
|
1160
1374
|
}
|
|
1161
1375
|
|
|
1162
1376
|
|
|
1163
|
-
// Get xyz-rotation matrix
|
|
1164
|
-
|
|
1377
|
+
// Get xyz-rotation matrix
|
|
1378
|
+
// NOTE: Angle must be provided in radians
|
|
1379
|
+
RMAPI Matrix MatrixRotateXYZ(Vector3 angle)
|
|
1165
1380
|
{
|
|
1166
1381
|
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
|
1167
1382
|
0.0f, 1.0f, 0.0f, 0.0f,
|
|
1168
1383
|
0.0f, 0.0f, 1.0f, 0.0f,
|
|
1169
1384
|
0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity()
|
|
1170
1385
|
|
|
1171
|
-
float cosz = cosf(-
|
|
1172
|
-
float sinz = sinf(-
|
|
1173
|
-
float cosy = cosf(-
|
|
1174
|
-
float siny = sinf(-
|
|
1175
|
-
float cosx = cosf(-
|
|
1176
|
-
float sinx = sinf(-
|
|
1386
|
+
float cosz = cosf(-angle.z);
|
|
1387
|
+
float sinz = sinf(-angle.z);
|
|
1388
|
+
float cosy = cosf(-angle.y);
|
|
1389
|
+
float siny = sinf(-angle.y);
|
|
1390
|
+
float cosx = cosf(-angle.x);
|
|
1391
|
+
float sinx = sinf(-angle.x);
|
|
1177
1392
|
|
|
1178
1393
|
result.m0 = cosz*cosy;
|
|
1179
|
-
result.
|
|
1180
|
-
result.
|
|
1394
|
+
result.m1 = (cosz*siny*sinx) - (sinz*cosx);
|
|
1395
|
+
result.m2 = (cosz*siny*cosx) + (sinz*sinx);
|
|
1181
1396
|
|
|
1182
|
-
result.
|
|
1397
|
+
result.m4 = sinz*cosy;
|
|
1183
1398
|
result.m5 = (sinz*siny*sinx) + (cosz*cosx);
|
|
1184
|
-
result.
|
|
1399
|
+
result.m6 = (sinz*siny*cosx) - (cosz*sinx);
|
|
1185
1400
|
|
|
1186
|
-
result.
|
|
1187
|
-
result.
|
|
1401
|
+
result.m8 = -siny;
|
|
1402
|
+
result.m9 = cosy*sinx;
|
|
1188
1403
|
result.m10= cosy*cosx;
|
|
1189
1404
|
|
|
1190
1405
|
return result;
|
|
1191
1406
|
}
|
|
1192
1407
|
|
|
1193
|
-
// Get zyx-rotation matrix
|
|
1194
|
-
|
|
1408
|
+
// Get zyx-rotation matrix
|
|
1409
|
+
// NOTE: Angle must be provided in radians
|
|
1410
|
+
RMAPI Matrix MatrixRotateZYX(Vector3 angle)
|
|
1195
1411
|
{
|
|
1196
1412
|
Matrix result = { 0 };
|
|
1197
1413
|
|
|
1198
|
-
float cz = cosf(
|
|
1199
|
-
float sz = sinf(
|
|
1200
|
-
float cy = cosf(
|
|
1201
|
-
float sy = sinf(
|
|
1202
|
-
float cx = cosf(
|
|
1203
|
-
float sx = sinf(
|
|
1414
|
+
float cz = cosf(angle.z);
|
|
1415
|
+
float sz = sinf(angle.z);
|
|
1416
|
+
float cy = cosf(angle.y);
|
|
1417
|
+
float sy = sinf(angle.y);
|
|
1418
|
+
float cx = cosf(angle.x);
|
|
1419
|
+
float sx = sinf(angle.x);
|
|
1204
1420
|
|
|
1205
1421
|
result.m0 = cz*cy;
|
|
1206
|
-
result.
|
|
1207
|
-
result.
|
|
1208
|
-
result.
|
|
1422
|
+
result.m4 = cz*sy*sx - cx*sz;
|
|
1423
|
+
result.m8 = sz*sx + cz*cx*sy;
|
|
1424
|
+
result.m12 = 0;
|
|
1209
1425
|
|
|
1210
|
-
result.
|
|
1426
|
+
result.m1 = cy*sz;
|
|
1211
1427
|
result.m5 = cz*cx + sz*sy*sx;
|
|
1212
|
-
result.
|
|
1213
|
-
result.
|
|
1428
|
+
result.m9 = cx*sz*sy - cz*sx;
|
|
1429
|
+
result.m13 = 0;
|
|
1214
1430
|
|
|
1215
|
-
result.
|
|
1216
|
-
result.
|
|
1431
|
+
result.m2 = -sy;
|
|
1432
|
+
result.m6 = cy*sx;
|
|
1217
1433
|
result.m10 = cy*cx;
|
|
1218
|
-
result.m11 = 0;
|
|
1219
|
-
|
|
1220
|
-
result.m12 = 0;
|
|
1221
|
-
result.m13 = 0;
|
|
1222
1434
|
result.m14 = 0;
|
|
1435
|
+
|
|
1436
|
+
result.m3 = 0;
|
|
1437
|
+
result.m7 = 0;
|
|
1438
|
+
result.m11 = 0;
|
|
1223
1439
|
result.m15 = 1;
|
|
1224
1440
|
|
|
1225
1441
|
return result;
|
|
@@ -1269,7 +1485,7 @@ RMAPI Matrix MatrixFrustum(double left, double right, double bottom, double top,
|
|
|
1269
1485
|
}
|
|
1270
1486
|
|
|
1271
1487
|
// Get perspective projection matrix
|
|
1272
|
-
// NOTE:
|
|
1488
|
+
// NOTE: Fovy angle must be provided in radians
|
|
1273
1489
|
RMAPI Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
|
|
1274
1490
|
{
|
|
1275
1491
|
Matrix result = { 0 };
|
|
@@ -1478,10 +1694,9 @@ RMAPI Quaternion QuaternionInvert(Quaternion q)
|
|
|
1478
1694
|
{
|
|
1479
1695
|
Quaternion result = q;
|
|
1480
1696
|
|
|
1481
|
-
float
|
|
1482
|
-
float lengthSq = length*length;
|
|
1697
|
+
float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;
|
|
1483
1698
|
|
|
1484
|
-
if (lengthSq != 0.
|
|
1699
|
+
if (lengthSq != 0.0f)
|
|
1485
1700
|
{
|
|
1486
1701
|
float invLength = 1.0f/lengthSq;
|
|
1487
1702
|
|
|
@@ -1515,12 +1730,10 @@ RMAPI Quaternion QuaternionScale(Quaternion q, float mul)
|
|
|
1515
1730
|
{
|
|
1516
1731
|
Quaternion result = { 0 };
|
|
1517
1732
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
result.
|
|
1521
|
-
result.
|
|
1522
|
-
result.z = qaz*mul + qaw*mul + qax*mul - qay*mul;
|
|
1523
|
-
result.w = qaw*mul - qax*mul - qay*mul - qaz*mul;
|
|
1733
|
+
result.x = q.x*mul;
|
|
1734
|
+
result.y = q.y*mul;
|
|
1735
|
+
result.z = q.z*mul;
|
|
1736
|
+
result.w = q.w*mul;
|
|
1524
1737
|
|
|
1525
1738
|
return result;
|
|
1526
1739
|
}
|
|
@@ -1584,14 +1797,14 @@ RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
|
|
1584
1797
|
cosHalfTheta = -cosHalfTheta;
|
|
1585
1798
|
}
|
|
1586
1799
|
|
|
1587
|
-
if (
|
|
1800
|
+
if (fabsf(cosHalfTheta) >= 1.0f) result = q1;
|
|
1588
1801
|
else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);
|
|
1589
1802
|
else
|
|
1590
1803
|
{
|
|
1591
1804
|
float halfTheta = acosf(cosHalfTheta);
|
|
1592
1805
|
float sinHalfTheta = sqrtf(1.0f - cosHalfTheta*cosHalfTheta);
|
|
1593
1806
|
|
|
1594
|
-
if (
|
|
1807
|
+
if (fabsf(sinHalfTheta) < 0.001f)
|
|
1595
1808
|
{
|
|
1596
1809
|
result.x = (q1.x*0.5f + q2.x*0.5f);
|
|
1597
1810
|
result.y = (q1.y*0.5f + q2.y*0.5f);
|
|
@@ -1646,30 +1859,60 @@ RMAPI Quaternion QuaternionFromMatrix(Matrix mat)
|
|
|
1646
1859
|
{
|
|
1647
1860
|
Quaternion result = { 0 };
|
|
1648
1861
|
|
|
1649
|
-
|
|
1862
|
+
float fourWSquaredMinus1 = mat.m0 + mat.m5 + mat.m10;
|
|
1863
|
+
float fourXSquaredMinus1 = mat.m0 - mat.m5 - mat.m10;
|
|
1864
|
+
float fourYSquaredMinus1 = mat.m5 - mat.m0 - mat.m10;
|
|
1865
|
+
float fourZSquaredMinus1 = mat.m10 - mat.m0 - mat.m5;
|
|
1866
|
+
|
|
1867
|
+
int biggestIndex = 0;
|
|
1868
|
+
float fourBiggestSquaredMinus1 = fourWSquaredMinus1;
|
|
1869
|
+
if (fourXSquaredMinus1 > fourBiggestSquaredMinus1)
|
|
1650
1870
|
{
|
|
1651
|
-
|
|
1871
|
+
fourBiggestSquaredMinus1 = fourXSquaredMinus1;
|
|
1872
|
+
biggestIndex = 1;
|
|
1873
|
+
}
|
|
1652
1874
|
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1875
|
+
if (fourYSquaredMinus1 > fourBiggestSquaredMinus1)
|
|
1876
|
+
{
|
|
1877
|
+
fourBiggestSquaredMinus1 = fourYSquaredMinus1;
|
|
1878
|
+
biggestIndex = 2;
|
|
1657
1879
|
}
|
|
1658
|
-
|
|
1880
|
+
|
|
1881
|
+
if (fourZSquaredMinus1 > fourBiggestSquaredMinus1)
|
|
1659
1882
|
{
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
result.y = 0.25f*s;
|
|
1663
|
-
result.z = (mat.m9 + mat.m6)/s;
|
|
1664
|
-
result.w = (mat.m2 - mat.m8)/s;
|
|
1883
|
+
fourBiggestSquaredMinus1 = fourZSquaredMinus1;
|
|
1884
|
+
biggestIndex = 3;
|
|
1665
1885
|
}
|
|
1666
|
-
|
|
1886
|
+
|
|
1887
|
+
float biggestVal = sqrtf(fourBiggestSquaredMinus1 + 1.0f) * 0.5f;
|
|
1888
|
+
float mult = 0.25f / biggestVal;
|
|
1889
|
+
|
|
1890
|
+
switch (biggestIndex)
|
|
1667
1891
|
{
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1892
|
+
case 0:
|
|
1893
|
+
result.w = biggestVal;
|
|
1894
|
+
result.x = (mat.m6 - mat.m9) * mult;
|
|
1895
|
+
result.y = (mat.m8 - mat.m2) * mult;
|
|
1896
|
+
result.z = (mat.m1 - mat.m4) * mult;
|
|
1897
|
+
break;
|
|
1898
|
+
case 1:
|
|
1899
|
+
result.x = biggestVal;
|
|
1900
|
+
result.w = (mat.m6 - mat.m9) * mult;
|
|
1901
|
+
result.y = (mat.m1 + mat.m4) * mult;
|
|
1902
|
+
result.z = (mat.m8 + mat.m2) * mult;
|
|
1903
|
+
break;
|
|
1904
|
+
case 2:
|
|
1905
|
+
result.y = biggestVal;
|
|
1906
|
+
result.w = (mat.m8 - mat.m2) * mult;
|
|
1907
|
+
result.x = (mat.m1 + mat.m4) * mult;
|
|
1908
|
+
result.z = (mat.m6 + mat.m9) * mult;
|
|
1909
|
+
break;
|
|
1910
|
+
case 3:
|
|
1911
|
+
result.z = biggestVal;
|
|
1912
|
+
result.w = (mat.m1 - mat.m4) * mult;
|
|
1913
|
+
result.x = (mat.m8 + mat.m2) * mult;
|
|
1914
|
+
result.y = (mat.m6 + mat.m9) * mult;
|
|
1915
|
+
break;
|
|
1673
1916
|
}
|
|
1674
1917
|
|
|
1675
1918
|
return result;
|
|
@@ -1709,7 +1952,7 @@ RMAPI Matrix QuaternionToMatrix(Quaternion q)
|
|
|
1709
1952
|
}
|
|
1710
1953
|
|
|
1711
1954
|
// Get rotation quaternion for an angle and axis
|
|
1712
|
-
// NOTE:
|
|
1955
|
+
// NOTE: Angle must be provided in radians
|
|
1713
1956
|
RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
|
|
1714
1957
|
{
|
|
1715
1958
|
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
|
|
@@ -1757,7 +2000,7 @@ RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
|
|
|
1757
2000
|
// Get the rotation angle and axis for a given quaternion
|
|
1758
2001
|
RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
|
|
1759
2002
|
{
|
|
1760
|
-
if (
|
|
2003
|
+
if (fabsf(q.w) > 1.0f)
|
|
1761
2004
|
{
|
|
1762
2005
|
// QuaternionNormalize(q);
|
|
1763
2006
|
float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);
|
|
@@ -1850,4 +2093,19 @@ RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat)
|
|
|
1850
2093
|
return result;
|
|
1851
2094
|
}
|
|
1852
2095
|
|
|
2096
|
+
// Check whether two given quaternions are almost equal
|
|
2097
|
+
RMAPI int QuaternionEquals(Quaternion p, Quaternion q)
|
|
2098
|
+
{
|
|
2099
|
+
int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
|
2100
|
+
((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
|
|
2101
|
+
((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&
|
|
2102
|
+
((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))) ||
|
|
2103
|
+
(((fabsf(p.x + q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) &&
|
|
2104
|
+
((fabsf(p.y + q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) &&
|
|
2105
|
+
((fabsf(p.z + q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) &&
|
|
2106
|
+
((fabsf(p.w + q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w))))));
|
|
2107
|
+
|
|
2108
|
+
return result;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
1853
2111
|
#endif // RAYMATH_H
|