symmetrical latch
This commit is contained in:
parent
29fd414be1
commit
a4e3285d77
1 changed files with 8 additions and 5 deletions
|
@ -16,15 +16,18 @@ public class Drawer {
|
||||||
Matrix matrix = pose.ToMatrix();
|
Matrix matrix = pose.ToMatrix();
|
||||||
Vec3 localCursor = matrix.Inverse.Transform(cursor.pos);
|
Vec3 localCursor = matrix.Inverse.Transform(cursor.pos);
|
||||||
|
|
||||||
bool inBounds = localCursor.x > width / -2f && localCursor.x < width / 2f &&
|
bool inBounds = MathF.Abs(localCursor.x) < width / 2f &&
|
||||||
localCursor.y > height / -2f && localCursor.y < height / 2f;
|
MathF.Abs(localCursor.y) < height / 2f;
|
||||||
|
|
||||||
if (!opening) {
|
if (!opening) {
|
||||||
if (open > 0) {
|
if (open > 0) {
|
||||||
float delta = localCursor.z - oldZ;
|
float delta = localCursor.z - oldZ;
|
||||||
|
|
||||||
if (inBounds && localCursor.z < open && delta < -0.5f * Time.Stepf)
|
// if (inBounds && localCursor.z < open && delta < -0.5f * Time.Stepf)
|
||||||
|
// open = 0;
|
||||||
|
if (inBounds && localCursor.z < open && oldZ >= open) {
|
||||||
open = 0;
|
open = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open == 0 && inBounds && localCursor.z > 0 && oldZ <= 0) {
|
if (open == 0 && inBounds && localCursor.z > 0 && oldZ <= 0) {
|
||||||
|
@ -35,7 +38,7 @@ public class Drawer {
|
||||||
if (opening) {
|
if (opening) {
|
||||||
open = MathF.Max(localCursor.z, 0);
|
open = MathF.Max(localCursor.z, 0);
|
||||||
|
|
||||||
if (pinch == 0 || open > 0.4f) { // !inBounds ||
|
if (pinch == 0 || open > 0.4f || open <= 0.0f) { // !inBounds ||
|
||||||
opening = false;
|
opening = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +48,7 @@ public class Drawer {
|
||||||
Matrix.T(V.XYZ(0, 0, 0.5f)) *
|
Matrix.T(V.XYZ(0, 0, 0.5f)) *
|
||||||
Matrix.S(V.XYZ(width, height, MathF.Max(openSmooth.value, 0.01f))) *
|
Matrix.S(V.XYZ(width, height, MathF.Max(openSmooth.value, 0.01f))) *
|
||||||
pose.ToMatrix(),
|
pose.ToMatrix(),
|
||||||
new Color(0.8f, 0.8f, 0.8f, 0.5f)
|
Color.Hex(0x7D8995FF)
|
||||||
);
|
);
|
||||||
|
|
||||||
oldZ = localCursor.z;
|
oldZ = localCursor.z;
|
||||||
|
|
Loading…
Add table
Reference in a new issue