magnum opus stretch-cursor

This commit is contained in:
spatialfree 2022-10-03 17:48:38 -04:00
parent ec595d9e20
commit df2b8da7ab
2 changed files with 14 additions and 15 deletions

View file

@ -2,7 +2,7 @@ namespace Oriels;
class StretchCursor : dof { class StretchCursor : dof {
// input // input
public Pose to, from; public Vec3 vTo, vFrom;
// data // data
public Vec3 cursor; public Vec3 cursor;
@ -10,12 +10,11 @@ class StretchCursor : dof {
public void Init() {} public void Init() {}
public void Frame() { public void Frame() {
Vec3 vec = to.position - from.position; float mag = (vTo - vFrom).Magnitude;
float len = vec.Length; float stretch = Math.Max(mag - deadzone, 0f);
Vec3 dir = vec / len;
float stretch = Math.Max(len - deadzone, 0f); Vec3 dir = PullRequest.Direction(vTo, vFrom);
cursor = to.position + dir * stretch * strength; cursor = vTo + dir * stretch * strength;
Mesh.Cube.Draw(Material.Default, Matrix.TS(cursor, 0.01f)); Mesh.Cube.Draw(Material.Default, Matrix.TS(cursor, 0.01f));
} }

View file

@ -1,17 +1,17 @@
input input
tipTo = [pos, ori] vTo
tipFrom = [pos, ori] vFrom
data data
cursor = [0, 0, 0] stretch
cursor
frame frame
vector = tipTo.pos - tipFrom.pos mag = (vTo - vFrom).mag
length = vec.length stretch = max(mag - deadzone, 0)
dir = vector / length
stretch = max(length - deadzone, 0) dir = dir(vTo, vFrom)
cursor = to.pos + dir * stretch * strength cursor = vTo + dir * stretch * strength
design design
deadzone = 0.1 deadzone = 0.1