Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pfeodrippe committed Jan 29, 2025
1 parent cf5bce4 commit 5b37ad9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
24 changes: 19 additions & 5 deletions src/vybe/c.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1003,20 +1003,34 @@ signal(SIGSEGV, sighandler);

:if
(let [{:keys [then else] t :test} v
void-form? (or (:void (meta (:form v)))
(:void (meta v)))
void-str (if void-form? "NULL;" "")
;; For supporting the `:else` from a `cond` macro.
t (if (= (:form t) :else)
(analyze true)
t)]
t)
then (if void-form?
(vary-meta then merge {:void true})
then)
else (if (and else void-form?)
(vary-meta else merge {:void true})
else)]
(if (:form else)
(format "( %s ? \n ({%s;}) : \n ({%s;}) )"
(format "( %s ? \n ({%s;%s}) : \n ({%s;%s}) )"
(emit t)
(emit then)
(emit else))
(format "(typeof(({%s;})))( %s ? \n ({%s;}) : \n (typeof(({%s;}))){0} )"
void-str
(emit else)
void-str)
(format "(typeof(({%s;%s})))( %s ? \n ({%s;%s}) : \n (typeof(({%s;%s}))){0} )"
(emit then)
void-str
(emit t)
(emit then)
void-str
(emit then)
void-str
#_(emit else))))

;; Loops have special handling as we want to output a normal
Expand Down Expand Up @@ -1449,7 +1463,7 @@ long long int: \"long long int\", unsigned long long int: \"unsigned long long i
([code-form {:keys [sym-meta sym sym-name] :as opts}]
(let [{:keys [c-code ::c-data form-hash final-form init-struct-val]}
(-> code-form
(transpile (assoc opts ::version 51)))
(transpile (assoc opts ::version 52)))

obj-name (str "vybe_" sym-name "_"
(when (or (:no-cache sym-meta)
Expand Down
40 changes: 13 additions & 27 deletions src/vybe/game/system.clj
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@

;; We modify the component from the ref and then we have to notify flecs
;; that it was modified.
(merge @node-ref (if t
#_(merge @node-ref (if t
(lerp-p (nth values idx)
(nth values (inc idx))
t)
Expand All @@ -264,12 +264,11 @@
c)))
nil))

(vf/defsystem-c ^:debug animation-node-player-2 w
(vf/defsystem-c animation-node-player-2 w
[_ [:vg.anim/target-node '?node]
translation [:src '?node vt/Translation]
scale [:src '?node vt/Scale]
rotation [:src '?node vt/Rotation]
;; TODO Maybe [:vg.anim/target-component [:vf/component'?c]] ?
_ [:vg.anim/target-component '?c]
{:keys [id]} [:src '?c vf/VybeComponentId]
{:keys [kind timeline_count values timeline]} vt/AnimationChannel
Expand All @@ -294,41 +293,28 @@
-1

:else
(dec idx*))

#_ #_my-ref (-> (vf.c/ecs-ref-get-id (:w @node-ref)
(vp/& (:flecs_ref @node-ref))
(:id (:flecs_ref @node-ref)))
#_(vp/p->map c))]
#_(tap> (long (vp/& (:flecs_ref @node-ref))))

#_(when tttt
(tap> @tttt))
(dec idx*))]

;; TODO We could use some `:void` metadata to indicate that
;; a form does not return anything.
(if (>= idx 0)
(let [v (/ (- (:current_time @player)
(nth timeline* idx))
(- (nth timeline* (inc idx))
(nth timeline* idx)))]
;; You can use `^:void` to signal that an `if` or a `cond` don't
;; care about the returned expression.
^:void
(cond
(= kind 0)
(do (merge @translation
(nth (vp/arr values timeline_count vt/Translation) idx))
nil)
(merge @translation
(nth (vp/arr values timeline_count vt/Translation) idx))

(= kind 2)
(do (merge @rotation
(nth (vp/arr values timeline_count vt/Rotation) idx))
nil)

#_(= kind 1)
#_(nth (vp/arr values timeline_count vt/Scale) idx)
(= kind 1)
(merge @scale
(nth (vp/arr values timeline_count vt/Scale) idx))

#_(= kind 2)
#_(nth (vp/arr values timeline_count vt/Rotation) idx))
(= kind 2)
(merge @rotation
(nth (vp/arr values timeline_count vt/Rotation) idx)))

#_(merge @node-ref (nth values idx)
#_(if t
Expand Down

0 comments on commit 5b37ad9

Please sign in to comment.