# HG changeset patch # User Sam # Date 1701530786 -25200 # Node ID e76822e943af532c9914391df51187ba8b934d11 # Parent bba0e9c881d1844ce1438d3dcdc78a6a3bdbe69f# Parent ade6e9324ae0cbc17092b2ab273db12d959b8e2b Merge branch 'main' of github.com:saemideluxe/semicongine diff -r bba0e9c881d1 -r e76822e943af generators/vulkan_api/config.nims diff -r bba0e9c881d1 -r e76822e943af generators/vulkan_api/vulkan_api_generator.nim diff -r bba0e9c881d1 -r e76822e943af semicongine.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/animation.nim --- a/semicongine/animation.nim Sat Dec 02 22:23:29 2023 +0700 +++ b/semicongine/animation.nim Sat Dec 02 22:26:26 2023 +0700 @@ -34,7 +34,7 @@ iterations: int AnimationPlayer*[T] = object animation*: Animation[T] - currentTime: float32 + currentTime*: float32 playing*: bool currentDirection: int currentIteration: int @@ -125,17 +125,18 @@ iterations: iterations ) -func resetPlayer*(player: var AnimationPlayer) = +proc reset*(player: var AnimationPlayer) = + player.currentValue = player.animation.animationFunction(0) player.currentTime = 0 player.currentDirection = if player.animation.direction == Backward: -1 else : 1 player.currentIteration = player.animation.iterations -func newAnimationPlayer*[T](animation: Animation[T]): AnimationPlayer[T] = +proc newAnimationPlayer*[T](animation: Animation[T]): AnimationPlayer[T] = result = AnimationPlayer[T](animation: animation, playing: false) - result.resetPlayer() + result.reset() -func newAnimationPlayer*[T](value: T = default(T)): AnimationPlayer[T] = +proc newAnimationPlayer*[T](value: T = default(T)): AnimationPlayer[T] = newAnimationPlayer[T](newAnimation[T]((t: AnimationTime) => value, 0)) func start*(player: var AnimationPlayer) = @@ -148,11 +149,12 @@ # TODO: check this function, not 100% correct I think if player.playing: player.currentTime += float32(player.currentDirection) * dt - if abs(player.currentTime) > player.animation.duration: + if not (0 <= player.currentTime and player.currentTime < player.animation.duration): dec player.currentIteration + # last iteration reached if player.currentIteration <= 0 and player.animation.iterations != 0: player.stop() - player.resetPlayer() + # more iterations else: case player.animation.direction: of Forward: @@ -163,5 +165,7 @@ player.currentDirection = -player.currentDirection player.currentTime += float32(player.currentDirection) * dt * 2'f32 - player.currentValue = player.animation.animationFunction((abs(player.currentTime) / player.animation.duration) mod high(AnimationTime)) + player.currentValue = player.animation.animationFunction( + max(low(AnimationTime), min(player.currentTime / player.animation.duration, high(AnimationTime))) + ) return player.currentValue diff -r bba0e9c881d1 -r e76822e943af semicongine/audio.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/collision.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/audiotypes.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/buildconfig.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/color.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/dynamic_arrays.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/fonttypes.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/gpu_types.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/imagetypes.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/matrix.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/utils.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/vector.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/core/vulkanapi.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/engine.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/events.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/material.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/mesh.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/noise.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/audio.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/linux/audio.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/linux/surface.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/linux/symkey_map.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/linux/vulkanExtensions.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/linux/window.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/surface.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/vulkanExtensions.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/window.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/windows/audio.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/windows/surface.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/windows/virtualkey_map.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/windows/vulkanExtensions.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/platform/windows/window.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/renderer.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/resources.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/audio.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/font.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/image.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/lodepng.c diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/lodepng.h diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/mesh.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/stb_truetype.h diff -r bba0e9c881d1 -r e76822e943af semicongine/resources/stb_vorbis.c diff -r bba0e9c881d1 -r e76822e943af semicongine/scene.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/settings.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/telemetry.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/text.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/buffer.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/commandbuffer.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/descriptor.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/device.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/drawable.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/framebuffer.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/image.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/instance.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/memory.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/physicaldevice.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/pipeline.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/android.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/directfb.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/fuchsia.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/ggp.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/ios.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/macos.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/metal.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/provisional.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/sci.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/screen.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/vi.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/wayland.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/win32.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/xcb.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/xlib.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/platform/xlib_xrandr.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/renderpass.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/shader.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/swapchain.nim diff -r bba0e9c881d1 -r e76822e943af semicongine/vulkan/syncing.nim