Ejemplo n.º 1
0
        ///     2 ------------- 3
        ///   /               /
        ///  1 ------------ 4
        public static GravityOverrideQuad DrawQuadWithBorders(ExtQuad quad, GravityOverrideQuad quadGravity, Color color, out bool hasChanged)
        {
            hasChanged = false;
            bool changed = hasChanged;

            float sizeLine  = quad.LocalScale.magnitude / 35;
            float sizePoint = quad.LocalScale.magnitude / 30;

            Color colorFace = new Color(color.r, color.g, color.b, color.a * 0.5f);
            Color colorLine = new Color(color.r, color.g, color.b, color.a * 0.8f);

            quadGravity.Face1 = DrawQuadFace(quad, quadGravity.Face1, quad.AllowBottom, colorFace, out changed);     hasChanged = (changed) ? true : hasChanged;

            quadGravity.Line1 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line1, quad.P1, quad.P2, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;
            quadGravity.Line2 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line2, quad.P2, quad.P3, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;
            quadGravity.Line3 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line3, quad.P3, quad.P4, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;
            quadGravity.Line4 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line4, quad.P4, quad.P1, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;

            quadGravity.Point1 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point1, quad.P1, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;
            quadGravity.Point2 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point2, quad.P2, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;
            quadGravity.Point3 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point3, quad.P3, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;
            quadGravity.Point4 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point4, quad.P4, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;

            return(quadGravity);
        }
Ejemplo n.º 2
0
 public static void ApplyModificationToQuad(SerializedProperty quad, GravityOverrideQuad datas)
 {
     quad.GetPropertie(nameof(datas.Face1)).boolValue  = datas.Face1;
     quad.GetPropertie(nameof(datas.Line1)).boolValue  = datas.Line1;
     quad.GetPropertie(nameof(datas.Line2)).boolValue  = datas.Line2;
     quad.GetPropertie(nameof(datas.Line3)).boolValue  = datas.Line3;
     quad.GetPropertie(nameof(datas.Line4)).boolValue  = datas.Line4;
     quad.GetPropertie(nameof(datas.Point1)).boolValue = datas.Point1;
     quad.GetPropertie(nameof(datas.Point2)).boolValue = datas.Point2;
     quad.GetPropertie(nameof(datas.Point3)).boolValue = datas.Point3;
     quad.GetPropertie(nameof(datas.Point4)).boolValue = datas.Point4;
     quad.GetPropertie("_canApplyGravity").boolValue   = datas.CanApplyGravity;
 }
Ejemplo n.º 3
0
        public bool GetClosestPointIfWeCan(Vector3 K, GravityOverrideQuad quad, out Vector3 closestPoint)
        {
            closestPoint = Vector3.zero;
            if (!_plane.AllowBottom && !_plane.IsAbove(K))
            {
                return(false);
            }
            if (!CanApplyFaces(K, quad))
            {
                return(false);
            }

            closestPoint = GetClosestPoint(K);
            return(true);
        }
Ejemplo n.º 4
0
        private bool CanApplyFaces(Vector3 K, GravityOverrideQuad quad)
        {
            bool isAboveFaceAdjecent1 = _planeAdjacent1.IsAbove(K);
            bool isAboveFaceAdjecent2 = _planeAdjacent2.IsAbove(K);
            bool isAboveFaceAdjecent3 = _planeAdjacent3.IsAbove(K);
            bool isAboveFaceAdjecent4 = _planeAdjacent4.IsAbove(K);

            if (!quad.Face1 && !isAboveFaceAdjecent1 && !isAboveFaceAdjecent2 && !isAboveFaceAdjecent3 && !isAboveFaceAdjecent4)
            {
                return(false);
            }
            if (!quad.Line1 && isAboveFaceAdjecent4 && !isAboveFaceAdjecent3 && !isAboveFaceAdjecent1)
            {
                return(false);
            }
            if (!quad.Line2 && isAboveFaceAdjecent3 && !isAboveFaceAdjecent4 && !isAboveFaceAdjecent2)
            {
                return(false);
            }
            if (!quad.Line3 && isAboveFaceAdjecent2 && !isAboveFaceAdjecent3 && !isAboveFaceAdjecent1)
            {
                return(false);
            }
            if (!quad.Line4 && isAboveFaceAdjecent1 && !isAboveFaceAdjecent4 && !isAboveFaceAdjecent2)
            {
                return(false);
            }
            if (!quad.Point1 && isAboveFaceAdjecent1 && isAboveFaceAdjecent4)
            {
                return(false);
            }
            if (!quad.Point2 && isAboveFaceAdjecent3 && isAboveFaceAdjecent4)
            {
                return(false);
            }
            if (!quad.Point3 && isAboveFaceAdjecent3 && isAboveFaceAdjecent2)
            {
                return(false);
            }
            if (!quad.Point4 && isAboveFaceAdjecent1 && isAboveFaceAdjecent2)
            {
                return(false);
            }
            return(true);
        }