From fd5f5d7172977b590dddb0f7f447fe1dcdd5a2d8 Mon Sep 17 00:00:00 2001 From: Paulo Feodrippe Date: Tue, 21 Jan 2025 23:19:41 -0500 Subject: [PATCH] wip --- .github/workflows/ci.yml | 2 +- src/vybe/flecs.clj | 8 +++++--- src/vybe/game/system.clj | 44 ++++++++++++++++++++++++++++++++++++++++ todo.md | 26 +++++++++++++----------- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3b7b049..9184b121 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - develop + # - develop paths-ignore: - '**/README.md' - '**/CHANGELOG.md' diff --git a/src/vybe/flecs.clj b/src/vybe/flecs.clj index 18c0486a..12c8227d 100644 --- a/src/vybe/flecs.clj +++ b/src/vybe/flecs.clj @@ -824,6 +824,7 @@ _id (vf.c/ecs-component-init wptr desc)] (-add-meta wptr e e-id :vybe.flecs.type/component) (-cache-entity wptr e e-id) + (vf.c/ecs-doc-set-name wptr e-id (vp/comp-name e)) #_(-set-c wptr e-id [on-instantiate-inherit-id]) e-id) @@ -851,10 +852,11 @@ (if (not= e-id 0) e-id (let [id (vf.c/ecs-set-name wptr 0 sym)] + (vf.c/ecs-doc-set-name wptr id (str e)) (when (zero? id) - (throw (ex-info "`eid` would return `0` (from keyword ecs-set-name)" - {:e e - :opts opts}))) + (throw (ex-info "`eid` would return `0` (from keyword ecs-set-name)" + {:e e + :opts opts}))) #_(vf.c/ecs-set-symbol wptr id sym) (vp/cache-comp e) (-add-meta wptr e id :vybe.flecs.type/keyword) diff --git a/src/vybe/game/system.clj b/src/vybe/game/system.clj index 656de936..418d3466 100644 --- a/src/vybe/game/system.clj +++ b/src/vybe/game/system.clj @@ -245,6 +245,50 @@ (vf/modified! w node c))) +#_(vf/defsystem-c animation-node-player-2 w + [abc1 [:vg.anim/target-node :*] + abc2 [:vg.anim/target-component :*] + #_ #_ #_ #_ #_ #_ #_ #_ #_ #_ node-ref vf/Ref + {:keys [timeline_count values timeline]} vt/AnimationChannel + player [:meta {:flags #{:up :cascade} + :inout :mut} + vt/AnimationPlayer] + parent-e [:vf/entity {:flags #{:up}} :vg.anim/active] + _ [:not {:flags #{:up}} :vg.anim/stop]] + #_[[_ node] [:vg.anim/target-node :*] + [_ c] [:vg.anim/target-component :*] + node-ref vf/Ref + {:keys [timeline_count values timeline]} vt/AnimationChannel + player [:meta {:flags #{:up :cascade} + :inout :mut} + vt/AnimationPlayer] + parent-e [:vf/entity {:flags #{:up}} :vg.anim/active] + _ [:not {:flags #{:up}} :vg.anim/stop]] + #_(let [values (vp/arr values timeline_count c) + timeline (vp/arr timeline timeline_count :float) + idx* (first (indices #(>= % (:current_time player)) timeline)) + idx (max (dec (or idx* (count timeline))) 0) + t (when idx* + (/ (- (:current_time player) + (nth timeline idx)) + (- (nth timeline (inc idx)) + (nth timeline idx))))] + + (when-not idx* + (conj parent-e :vg.anim/stop) + ;; Just for triggering the `animation-loop` system. + (conj (vf/ent w node) :vg.anim.entity/stop)) + + ;; We modify the component from the ref and then we have to notify flecs + ;; that it was modified. + (merge @node-ref (if t + (lerp-p (nth values idx) + (nth values (inc idx)) + t) + (nth values idx))) + + (vf/modified! w node c))) + (vf/defsystem animation-loop w [[_ action] [:vg.anim/loop :*] _ [:maybe :vg.anim.entity/stop] diff --git a/todo.md b/todo.md index 48dab8d4..8bab1ce3 100644 --- a/todo.md +++ b/todo.md @@ -251,7 +251,7 @@ - [x] animate blob - [x] gltf loading test - [x] remove need for raylib for testing -- [ ] VybeC +- [x] VybeC - [x] move existing system into VybeC from C - [x] direct translation - [x] compile @@ -271,17 +271,7 @@ - [x] eval - [x] macro to quickly evaluate stuff - [-] REPL plugin like portal does for cljs? - - [ ] better way to jump to definition - - [ ] allocator setting - - [ ] comptime - - [ ] exe mode - - [ ] check that we don't have unitialized resources in the init function if - in this mode - - [ ] use generics for a `vp/mem` equivalent in VybeC - - [ ] share `matrix-transform` code - - [ ] make `@, vp/&` etc better - - [ ] create a merge or reset! "protocol" leveraging C generics - - [ ] make recompilation work with an indirection? +- [ ] try to VybeC animation-node-player - [ ] provide models - [ ] minimal - [ ] more complex @@ -408,6 +398,18 @@ - [ ] flecs entity - [ ] flecs system - [ ] tap from C into portal +- [ ] VybeC + - [ ] better way to jump to definition + - [ ] allocator setting + - [ ] comptime + - [ ] exe mode + - [ ] check that we don't have unitialized resources in the init function if + in this mode + - [ ] use generics for a `vp/mem` equivalent in VybeC + - [ ] share `matrix-transform` code + - [ ] make `@, vp/&` etc better + - [ ] create a merge or reset! "protocol" leveraging C generics + - [ ] make recompilation work with an indirection? - [ ] make it easy to DSP in the frequency domain - [ ] create filters in realtime from clerk - [ ] wasm