Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions Editor/NRepl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,38 @@ public override object invoke ()
// Split the path, and try to infer the ns from the filename. If the ns exists, then change the current ns before evaluating
List<String> nsList = new List<String>();
Namespace fileNs = null;
Namespace priorNs = null;
try
{
var path = _request["file"].ToString();
string current = null;
while (path != null && current != "Assets")
{
current = Path.GetFileNameWithoutExtension(path);
nsList.Add(current);
path = Directory.GetParent(path).FullName;
// Debug.Log(string.Join(", ", _request.Value));
if (_request.ContainsKey("ns")) {
// Debug.Log("Trying to find: " + _request["ns"].ToString());
fileNs = Namespace.find(Symbol.create(_request["ns"].ToString()));
// Debug.Log("Found: " + _request["ns"].ToString());
} else {
fileNs = Namespace.find(Symbol.create(RT.CurrentNSVar.deref().ToString()));
Debug.Log("CurrentNSVar: " + RT.CurrentNSVar.deref().ToString());
}
nsList.Reverse();
nsList.RemoveAt(0);
// Debug.Log("Trying to find: " + string.Join(".", nsList.ToArray()));
fileNs = Namespace.find(Symbol.create(string.Join(".", nsList.ToArray())));
// Debug.Log("Found: " + string.Join(".", nsList.ToArray()));
}

// I don't know how the file functionality is exactly supposed to work,
// so I'll leave this here to override if the key is set.
// I expect in PR review we'll fix this =)...
if (_request.ContainsKey("file")) {
var path = _request["file"].ToString();
string current = null;
while (path != null && current != "Assets")
{
current = Path.GetFileNameWithoutExtension(path);
nsList.Add(current);
path = Directory.GetParent(path).FullName;
}
nsList.Reverse();
nsList.RemoveAt(0);
// Debug.Log("Trying to find: " + string.Join(".", nsList.ToArray()));
fileNs = Namespace.find(Symbol.create(string.Join(".", nsList.ToArray())));
// Debug.Log("Found: " + string.Join(".", nsList.ToArray()));
}
}
catch (Exception e)
{
/* Whatever sent in :file was not a path. Ignore it */
Expand Down
7 changes: 7 additions & 0 deletions Helpers/LinearHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public static IPersistentVector toAngleAxis(Quaternion q)
return PersistentVector.create(ang, axis);
}

public static IPersistentVector smoothDamp(Vector3 current, Vector3 target, Vector3 currentVelocity, float smoothTime)
{
Vector3 newCurrentVelocity = currentVelocity;
Vector3 result = Vector3.SmoothDamp(current, target, ref newCurrentVelocity, smoothTime);
return PersistentVector.create(result, newCurrentVelocity);
}

public static Matrix4x4 matrix (
float a, float b, float c, float d,
float e, float f, float g, float h,
Expand Down
11 changes: 11 additions & 0 deletions Source/arcadia/linear.clj
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ Calls to this function will be inlined if possible."})
;; ------------------------------------------------------------
;; dist

;; ------------------------------------------------------------
;; smooth damp

(definline smooth-damp
"Given a `Vector3` `current`, a `Vector3` `target` a `Vector3` `current-velocity` and a `float` `smooth-time`, returns a collection containing the result (`Vector3`) of smoothly changing from the current to the target over the time smooth-time and current-velocity (`Vector3`), as set by the `Vector3/SmoothDamp`.

Calls to this function will be inlined if possible."
[^UnityEngine.Vector3 current ^UnityEngine.Vector3 target ^UnityEngine.Vector3 current-velocity smooth-time]
`(Arcadia.LinearHelper/smoothDamp ~current ~target ~current-velocity ~smooth-time))


;; ------------------------------------------------------------
;; Quaternions
;; and then there's this
Expand Down