diff --git a/src/vybe/flecs.clj b/src/vybe/flecs.clj index 0bf9a543..454321de 100644 --- a/src/vybe/flecs.clj +++ b/src/vybe/flecs.clj @@ -250,7 +250,8 @@ (-set-c this k v) this) (dissoc [this k] - (vf.c/ecs-delete this (ent this k)) + (when (get this k) + (vf.c/ecs-delete this (ent this k))) this) (keys [this] (-world-entities this)) (keySet [this] (set (potemkin.collections/keys* this))) @@ -1458,16 +1459,20 @@ [k v]) (concat (partition 2 bindings) (list (list w :vf/world)))) + bindings-map (into {} bindings) + _ (when-not (:vf/name bindings-map) + (throw (ex-info "`with-system` requires a :vf/name" {:bindings bindings + :body body}))) code `(-system ~w ~(mapv (fn [[k v]] [`(quote ~k) v]) bindings) - (fn [~(vec (remove keyword? (mapv first bindings)))] + (fn ~(symbol (str (namespace (:vf/name bindings-map)) + "__" + (name (:vf/name bindings-map)))) + [~(vec (remove keyword? (mapv first bindings)))] (try ~@body (catch Throwable e# (println e#))))) hashed (hash code)] - (when-not (contains? (set (mapv first bindings)) :vf/name) - (throw (ex-info "`with-system` requires a :vf/name" {:bindings bindings - :body body}))) `(let [hashed# (hash ~(mapv last bindings))] (or (when-let [e# (get-in @*-each-cache [(vp/mem ~w) [~hashed hashed#]])] (when (vf.c/ecs-is-alive ~w (ent ~w e#)) @@ -1566,8 +1571,15 @@ [k v]) (concat (partition 2 bindings) (list (list w :vf/world)))) + bindings-map (into {} bindings) + _ (when-not (:vf/name bindings-map) + (throw (ex-info "`with-system` requires a :vf/name" {:bindings bindings + :body body}))) code `(-observer ~w ~(mapv (fn [[k v]] [`(quote ~k) v]) bindings) - (fn [~(vec (remove keyword? (mapv first bindings)))] + (fn ~(symbol (str (namespace (:vf/name bindings-map)) + "__" + (name (:vf/name bindings-map)))) + [~(vec (remove keyword? (mapv first bindings)))] (try ~@body (catch Throwable e# diff --git a/src/vybe/flecs/impl.clj b/src/vybe/flecs/impl.clj index be4cb89a..e61e8d97 100644 --- a/src/vybe/flecs/impl.clj +++ b/src/vybe/flecs/impl.clj @@ -120,6 +120,13 @@ :main-thread? (nil? ret)}))))))) #_ (def methods-to-intern (-methods)) +(defn -debug + [v] + (let [t (type v)] + (if (contains? #{Long String Boolean} t) + v + t))) + (defmacro -intern-methods [init size] `(do ~(->> (-methods) @@ -145,7 +152,7 @@ ~(mapv (comp symbol :name) args) ;; Fn body. `(do #_(println '~'~(csk/->kebab-case-symbol n) - (mapv type ~~(mapv (comp symbol :name) args))) + (mapv -debug ~~(mapv (comp symbol :name) args))) (vp/try-p->map ~~``(~(symbol "org.vybe.flecs.flecs" ~n) ~@~(vec @@ -175,7 +182,7 @@ #_(macroexpand-1 '(-intern-methods 300 10)) #_(meta #'draw-text!) -#_(macroexpand-1 '(load-model "OOOB")) +#_(macroexpand-1 '(ecs-add-id w e id)) #_(macroexpand-1 '(update-camera! 1 2)) #_(macroexpand-1 '(get-monitor-name 0)) diff --git a/src/vybe/jolt.clj b/src/vybe/jolt.clj index 1e35716b..fb838706 100644 --- a/src/vybe/jolt.clj +++ b/src/vybe/jolt.clj @@ -266,8 +266,10 @@ ;; -- Body (defn body-active? - [body] - (vj.c/jpc-body-is-active body)) + ([body] + (vj.c/jpc-body-is-active body)) + ([phys body-id] + (vj.c/jpc-body-interface-is-active (body-interface phys) body-id))) (defn body-move "Move kinematic body. @@ -288,6 +290,18 @@ [phys body-id] (vj.c/jpc-body-interface-is-added (body-interface phys) body-id)) +(defn body-position + [phys body-id] + (let [pos (Vector3)] + (vj.c/jpc-body-interface-get-position (body-interface phys) body-id pos) + pos)) + +(defn body-rotation + [phys body-id] + (let [rot (Vector4)] + (vj.c/jpc-body-interface-get-rotation (body-interface phys) body-id rot) + rot)) + ;; -- Misc (defonce *temp-allocator (delay (vj.c/jpc-temp-allocator-create (* 16 1024 1024))))