Beispiel #1
0
        public JsonNode Pred2parent(ref DebugVisual dv)
        { // 3 Parent / Pred, -, -
            JsonNode retVal = pred;

            retVal.next = null; // Link Pred -> Next(=null)
            pred        = null;
            dv?.update(this, -2);
            parent = null;
            dv?.update(this, -1);
            return(retVal); // next @pred (last node in a row)
        }
Beispiel #2
0
        public JsonNode Next2next(ref DebugVisual dv)
        { // 9 Parent / - , - , Next
            JsonNode retVal = next;

            parent.node = next;
            next.parent = parent; // null not set by parser
            dv?.update(this);
            next.pred = null;
            dv?.update(this);
            next = null;
            dv?.update(this, -8);
            parent = null;
            dv?.update(this, -1);
            return(retVal);
        }
Beispiel #3
0
        public JsonNode DeleteNode2next(ref DebugVisual dv)
        { // 13 Parent / - , Node, Next
            JsonNode retVal = next, retVal2 = parent;

            retVal.pred = null;
            parent.node = next;
            next.parent = parent; // null not set by parser
            parent      = null;
            dv?.update(this, -1);
            next = null;
            dv?.update(this, -8);
            node = null;
            dv?.update(this, -4);
            return(retVal ?? retVal2);
        }
Beispiel #4
0
    public void GetCollisionPoints(Mesh mesh)
    {
        var triangles = mesh.triangles;

        for (int i = 0; i < triangles.Length - 1; i++)
        {
            var vert1 = mesh.vertices[triangles[i]];
            var vert2 = mesh.vertices[triangles[i + 1]];
            var ray   = new Ray(vert1, vert2);

            RaycastHit hit;
            if (!Physics.Raycast(ray, out hit))
            {
                continue;
            }

            DebugVisual.Position(hit.point);
        }
    }
Beispiel #5
0
        public JsonNode RemoveEmpties(JsonNode removed, Byte[] src)
        {
            if (Tag != JsonTag.JSON_ARRAY && Tag != JsonTag.JSON_OBJECT
                /*&& !(keyIdxes.data == 0 && doubleOrString.data == 0 && node == null)*/)
            {
                return(this);                                                                       // only 2 types could be useless
            }
            int arround = 0;

            if (parent != null)
            {
                arround = 1;                        // ↑
            }
            if (pred != null)
            {
                arround |= 2;                       // ←
            }
            if (node != null)                       // ↓
            {
                arround |= 4;
                if (doubleOrString.data != 0)
                {
                    return(this);                          // if has no value
                }
            }
            if (next != null)
            {
                arround |= 8;                       // →
            }
            JsonNode    retVal = null, retVal2 = null;
            DebugVisual dv = null; // new DebugVisual(this, arround, src);

            switch (arround)
            {
            case 1:     //                              | Parent / -, -, -
                retVal  = parent;
                parent  = null;
                retVal2 = retVal.parent;
                if (retVal2 != null && retVal2?.parent != null)       // not 4 root
                {
                    retVal      = retVal2.RemoveEmpties(retVal, src);
                    retVal.node = null;
                    dv?.update(retVal);
                    return(retVal);
                }
                retVal.node = null;
                return(retVal);

            case 3:     //                              | Parent / Pred, -, -
                retVal    = parent;
                pred.next = null;
                parent    = null;
                pred      = null;
                dv?.update(retVal, -3);
                return(retVal); // next @pred (last node in a row)

            case 5:             // Orphan, nested obj or array  | Parent / -, Node, -
                if (node != removed)
                {
                    return(this);
                }
                retVal      = Parent;
                retVal2     = retVal.RemoveEmpties(this, src); // remove parent 2
                retVal.node = null;
                parent      = null;
                node.parent = null;
                node        = null; // clear me
                if (retVal2 != null)
                {
                    dv?.update(retVal2);
                    return(retVal2);
                }
                return(retVal?.parent ?? retVal);

            case 7:     // <-> a -> me => <-> a -> null | Parent / Pred, Node, -
                if (this != removed.parent)
                {
                    return(this);
                }
                retVal    = Pred;
                pred.next = null;
                pred      = null;
                node      = null; // clear me
                parent    = null;
                dv?.update(retVal2);
                return(retVal2);

            case 9:     // Parent / - , - , Next
                retVal      = next;
                parent.node = next;
                next.pred   = null;
                next.parent = parent;     // null not set by parser
                parent      = null;
                next        = null;
                dv?.update(retVal, -9);
                return(retVal);

            case 11:     // Parent / Pred , - , Next
                retVal      = next;
                next.parent = parent;
                pred.next   = next;
                next.pred   = pred;
                next.parent = parent;     // null not set by parser
                dv?.update(this);
                next    = null;
                pred    = null;
                retVal2 = parent;
                parent  = null;
                dv?.update(retVal, -11);
                return(retVal);

            case 13:     // me -> a                     | Parent / - , Node, Next
                if (node != removed)
                {
                    return(this);
                }
                retVal = DeleteNode2next(ref dv);
                dv?.update(retVal);
                return(retVal);

            case 15:     // a -> me -> b => a -> b      | Parent, Pred, Node, Next
                if (node != removed)
                {
                    return(this);
                }
                retVal      = next;
                pred.next   = next;
                next.pred   = pred;
                next.parent = parent; // null not set by parser
                pred        = null;
                node        = null;   // clear me
                next        = null;
                parent      = null;
                dv?.update(retVal);
                return(retVal);

            default:
                Console.WriteLine($"RemoveEmpties buggy node ({arround}) ?!");
                break;
            }
            return(null);
        }
Beispiel #6
0
        public JsonNode RemoveCurrent(Byte[] src)
        {
            JsonNode retVal = null, retVal2 = null;
            int      arround = 0;

            if (parent != null)
            {
                arround = 1;                        // ↑
            }
            if (pred != null)
            {
                arround |= 2;                       // ←
            }
            if (node != null)
            {
                arround |= 4;                       // ↓
            }
            if (next != null)
            {
                arround |= 8;      // →
            }
            DebugVisual dv = null; // new DebugVisual(this, arround, src);

            switch (arround)
            {
            case 1:     //                              | Parent / -, -, -
                retVal      = parent;
                retVal2     = parent?.parent;
                parent.node = null;
                parent      = null;
                retVal      = retVal.RemoveEmpties(this, src);
                retVal      = retVal ?? retVal2;
                dv?.update(retVal, -1);
                return(retVal);

            case 3:     //                              | Parent / Pred, -, -
                return(Pred2parent(ref dv));

            //case 5: // Orphan, nested obj or array  | Parent / -, Node, -
            //    retVal = Parent;
            //    if (retVal?.node.node == this)
            //        if (retVal.Tag == JsonTag.JSON_ARRAY
            //        || retVal.Tag == JsonTag.JSON_OBJECT)
            //        {
            //            retVal2 = retVal.RemoveEmpties(node, src); // remove parent 2
            //        }
            //    if (retVal?.Parent.NodeBelow != null) retVal = retVal?.Parent;
            //    if (retVal2 == null || retVal2.NodeBelow == null) return retVal;
            //    return retVal2;
            //case 7: // <-> a -> me => <-> a -> null | Parent / Pred, Node, -
            //    retVal = Pred;
            //    if (!Pred.ReplaceNext(null)) return null; // Link Pred -> Next(=null)
            //    node = null;
            //    NodeBelow = null;
            //    return retVal;
            case 9:     // Parent / - , - , Next
                return(Next2next(ref dv));

            case 11:     // Parent / Pred , - , Next
                retVal      = next;
                pred.next   = next;
                next.pred   = pred;
                next.parent = parent;     // null not set by parser
                dv?.update(parent, -11);
                return(next);

            //case 13: // me -> a                     | Parent / - , Node, Next
            //    retVal = next;
            //    parent.node = next;
            //    next.parent = parent;
            //    node = null; // clear me
            //    return retVal; // next @next
            //case 15: // a -> me -> b => a -> b      | Parent, Pred, Node, Next
            //    pred.next = next;
            //    next.pred = pred;
            //    retVal = next;
            //    node = null; // clear me
            //    return retVal; // next @next
            default:
                Console.WriteLine($"RemoveCurrent buggy node ({arround}) ?!");
                break;
            }
            return(null); // unreachable
        }