Additional cleanup

Cleaned up some additional stuff that I found
This commit is contained in:
W2.Wizard
2021-02-21 18:17:35 +01:00
parent 8b3fc9842d
commit 35b687bf3d
21 changed files with 142 additions and 151 deletions

View File

@@ -56,104 +56,107 @@ namespace FlaxEditor.Gizmo
_activeAxis = Axis.None;
switch (_activeMode)
{
case Mode.Translate:
{
// Axis boxes collision
if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
case Mode.Translate:
{
_activeAxis = Axis.X;
closestintersection = intersection;
}
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
closestintersection = intersection;
// Axis boxes collision
if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.X;
closestintersection = intersection;
}
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
closestintersection = intersection;
}
// Quad planes collision
if (closestintersection >= float.MaxValue)
closestintersection = float.MinValue;
if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
{
_activeAxis = Axis.XY;
closestintersection = intersection;
}
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
{
_activeAxis = Axis.ZX;
closestintersection = intersection;
}
if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
{
_activeAxis = Axis.YZ;
closestintersection = intersection;
}
break;
}
// Quad planes collision
if (closestintersection >= float.MaxValue)
closestintersection = float.MinValue;
if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
case Mode.Rotate:
{
_activeAxis = Axis.XY;
closestintersection = intersection;
}
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
{
_activeAxis = Axis.ZX;
closestintersection = intersection;
}
if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestintersection)
{
_activeAxis = Axis.YZ;
closestintersection = intersection;
// Circles
if (IntersectsRotateCircle(Vector3.UnitX, ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.X;
closestintersection = intersection;
}
if (IntersectsRotateCircle(Vector3.UnitY, ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (IntersectsRotateCircle(Vector3.UnitZ, ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
closestintersection = intersection;
}
// Center
/*if (CenterSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Center;
closestintersection = intersection;
}*/
break;
}
break;
}
case Mode.Scale:
{
// Spheres collision
if (ScaleXSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.X;
closestintersection = intersection;
}
if (ScaleYSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (ScaleZSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
closestintersection = intersection;
}
case Mode.Rotate:
{
// Circles
if (IntersectsRotateCircle(Vector3.UnitX, ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.X;
closestintersection = intersection;
}
if (IntersectsRotateCircle(Vector3.UnitY, ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (IntersectsRotateCircle(Vector3.UnitZ, ref localRay, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
closestintersection = intersection;
}
// Center
if (CenterBox.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Center;
closestintersection = intersection;
}
// Center
/*if (CenterSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Center;
closestintersection = intersection;
}*/
break;
}
case Mode.Scale:
{
// Spheres collision
if (ScaleXSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.X;
closestintersection = intersection;
break;
}
if (ScaleYSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Y;
closestintersection = intersection;
}
if (ScaleZSphere.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Z;
closestintersection = intersection;
}
// Center
if (CenterBox.Intersects(ref ray, out intersection) && intersection < closestintersection)
{
_activeAxis = Axis.Center;
closestintersection = intersection;
}
break;
}
}
}
}