This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'arcadia.core | |
'arcadia.linear | |
'[magic.api :as m]) | |
(defmacro fast-cmpt [obj bndgs & body] | |
(let [objsym (with-meta (gensym "obj_") {:tag 'UnityEngine.GameObject}) | |
dcls (->> bndgs | |
(partition 2) | |
(mapcat (fn [[sym t]] | |
(let [sym2 (with-meta sym {:tag t})] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn move-towards [obj1, obj2, speed] | |
(with-cmpt obj1 [tr1 Transform] | |
(with-cmpt obj2 [tr2 Transform] | |
(m/faster | |
(let [diff (v3- (.position tr2) (.position tr1))] | |
(set! (.position tr1) | |
(v3+ (.position tr1) | |
(v3* (.normalized diff) | |
(Mathf/Min speed (.magnitude diff)))))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void RunFunctions () | |
{ | |
if (!_fullyInitialized) { | |
FullInit(); | |
} | |
var _go = gameObject; | |
var _fns = fns; | |
for (int i = 0; i < _fns.Length; i++) { | |
_fns[i].invoke(_go); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yes this is bugtter after all my little rodent friend; little to do with me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require | |
'[arcadia.internal.benchmarking :as b] | |
'[magic.faster :as f]) | |
(defn better-merge [m1 m2] | |
(persistent! | |
(reduce-kv assoc! (transient {}) m2))) | |
(let [m {} | |
m2 (zipmap (range 1e4) (range))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
squ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(do (require '[arcadia.internal.benchmarking :as b]) | |
(use 'arcadia.core)) | |
(def objo (object-named "Main Camera")) | |
(b/n-timing 1e6 | |
(cmpt objo UnityEngine.Transform)) | |
;; ~ 0.00026 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bla |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn go-to [^UnityEngine.GameObject obj] | |
(when-let [^UnityEngine.GameObject target (state obj ::target)] | |
(let [max-accel (float (or (state obj ::max-accel) | |
(throw | |
(Exception. | |
"Expects :car-scene.movement/max-accel key in state"))))] | |
(with-cmpt target [targ-tr UnityEngine.Transform] | |
(with-cmpt obj [tr UnityEngine.Transform | |
rb UnityEngine.Rigidbody] | |
(let [^UnityEngine.Transform targ-tr (.GetComponent target UnityEngine.Transform) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(clojure.core/load-file "/Users/timothygardner/code/magic_testbed/Assets/car_scene/cars.clj") | |
clojure.lang.Compiler+CompilerException: System.ArgumentException: Elements of the parameterTypes array cannot be null | |
Parameter name: parameterTypes | |
at System.Reflection.Emit.MethodBuilder..ctor (System.Reflection.Emit.TypeBuilder,string,System.Reflection.MethodAttributes,System.Reflection.CallingConventions,System.Type,System.Type[],System.Type[],System.Type[],System.Type[][],System.Type[][]) [0x0007a] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs:103 | |
at System.Reflection.Emit.TypeBuilder.DefineMethod (string,System.Reflection.MethodAttributes,System.Reflection.CallingConventions,System.Type,System.Type[],System.Type[],System.Type[],System.Type[][],System.Type[][]) [0x0005f] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs:569 | |
at System.Reflection.Emit.TypeBuilder.DefineMethod (string,System.Reflection.MethodAttribu |