Beispiel #1
0
        public void Execute(int index1)
        {
            //for (int index1 = 0; index1 < brushesThatNeedIndirectUpdate.Length; index1++)
            {
                var brush1IndexOrder = brushesThatNeedIndirectUpdate[index1];
                int brush1NodeOrder  = brush1IndexOrder.nodeOrder;

                NativeListArray <BrushIntersectWith> .NativeList brush1Intersections;
                if (!brushBrushIntersections.IsAllocated(brush1NodeOrder))
                {
                    brush1Intersections = brushBrushIntersections.AllocateWithCapacityForIndex(brush1NodeOrder, 16);
                }
                else
                {
                    brush1Intersections = brushBrushIntersections[brush1NodeOrder];
                }
                for (int index0 = 0; index0 < allTreeBrushIndexOrders.Length; index0++)
                {
                    var brush0IndexOrder = allTreeBrushIndexOrders[index0];
                    int brush0NodeOrder  = brush0IndexOrder.nodeOrder;
                    if (brush0NodeOrder == brush1NodeOrder
                        // TODO: figure out why this optimization causes iterative updates to fail
                        //|| foundBrushes.IsSet(brush0IndexOrder.nodeOrder)
                        )
                    {
                        continue;
                    }
                    if (brush0NodeOrder > brush1NodeOrder)
                    {
                        var result = IntersectionUtility.FindIntersection(brush0NodeOrder, brush1NodeOrder,
                                                                          ref brushMeshLookup, ref brushTreeSpaceBounds, ref transformationCache,
                                                                          ref transformedPlanes0, ref transformedPlanes1);
                        if (result == IntersectionType.NoIntersection)
                        {
                            continue;
                        }
                        result = IntersectionUtility.Flip(result);
                        IntersectionUtility.StoreIntersection(brush1Intersections, brush0IndexOrder, result);
                    }
                    else
                    {
                        var result = IntersectionUtility.FindIntersection(brush1NodeOrder, brush0NodeOrder,
                                                                          ref brushMeshLookup, ref brushTreeSpaceBounds, ref transformationCache,
                                                                          ref transformedPlanes0, ref transformedPlanes1);
                        if (result == IntersectionType.NoIntersection)
                        {
                            continue;
                        }
                        IntersectionUtility.StoreIntersection(brush1Intersections, brush0IndexOrder, result);
                    }
                }
            }
            //*/
        }
Beispiel #2
0
        public void Execute()
        {
            var minCount = brushBrushIntersections.Count * 16;

            NativeCollectionHelpers.EnsureCapacityAndClear(ref intersections, minCount);

            for (int i = 0; i < brushBrushIntersections.Count; i++)
            {
                if (!brushBrushIntersections.IsAllocated(i))
                {
                    continue;
                }
                var subArray = brushBrushIntersections[i];
                for (int j = 0; j < subArray.Count; j++)
                {
                    var intersectWith = subArray[j];
                    var pair          = new BrushPair
                    {
                        brushNodeOrder0 = i,
                        brushNodeOrder1 = intersectWith.brushNodeOrder1,
                        type            = intersectWith.type
                    };
                    intersections.Add(pair);
                    pair.Flip();
                    intersections.Add(pair);
                }
            }
            brushIntersectionsWith->Clear();
            if (intersections.Length == 0)
            {
                return;
            }

            intersections.Sort(new ListComparer());

            var currentPair   = intersections[0];
            int previousOrder = currentPair.brushNodeOrder0;

            brushIntersectionsWith->Add(new BrushIntersectWith
            {
                brushNodeOrder1 = currentPair.brushNodeOrder1,
                type            = currentPair.type,
            });
            int2 range = new int2(0, 1);

            for (int i = 1; i < intersections.Length; i++)
            {
                currentPair = intersections[i];
                int currentOrder = currentPair.brushNodeOrder0;
                brushIntersectionsWith->Add(new BrushIntersectWith
                {
                    brushNodeOrder1 = currentPair.brushNodeOrder1,
                    type            = currentPair.type,
                });
                if (currentOrder != previousOrder)
                {
                    //Debug.Log($"{previousOrder} {range}");
                    brushIntersectionsWithRange[previousOrder] = range;
                    previousOrder = currentOrder;
                    range.x       = i;
                    range.y       = 1;
                }
                else
                {
                    range.y++;
                }
            }
            brushIntersectionsWithRange[previousOrder] = range;
        }
Beispiel #3
0
        public void Execute(int index1)
        {
            if (allTreeBrushIndexOrders.Length == rebuildTreeBrushIndexOrders.Length)
            {
                //for (int index1 = 0; index1 < updateBrushIndicesArray.Length; index1++)
                {
                    var brush1IndexOrder = rebuildTreeBrushIndexOrders[index1];
                    int brush1NodeOrder  = brush1IndexOrder.nodeOrder;
                    NativeListArray <BrushIntersectWith> .NativeList brush1Intersections;
                    if (!brushBrushIntersections.IsAllocated(brush1NodeOrder))
                    {
                        brush1Intersections = brushBrushIntersections.AllocateWithCapacityForIndex(brush1NodeOrder, 16);
                    }
                    else
                    {
                        brush1Intersections = brushBrushIntersections[brush1NodeOrder];
                    }
                    for (int index0 = 0; index0 < rebuildTreeBrushIndexOrders.Length; index0++)
                    {
                        var brush0IndexOrder = rebuildTreeBrushIndexOrders[index0];
                        int brush0NodeOrder  = brush0IndexOrder.nodeOrder;
                        if (brush0NodeOrder <= brush1NodeOrder)
                        {
                            continue;
                        }
                        var result = IntersectionUtility.FindIntersection(brush0NodeOrder, brush1NodeOrder,
                                                                          ref brushMeshLookup, ref brushTreeSpaceBounds, ref transformationCache,
                                                                          ref transformedPlanes0, ref transformedPlanes1);
                        if (result == IntersectionType.NoIntersection)
                        {
                            continue;
                        }
                        result = IntersectionUtility.Flip(result);
                        IntersectionUtility.StoreIntersection(brush1Intersections, brush0IndexOrder, result);
                    }
                }
                return;
            }

            NativeCollectionHelpers.EnsureMinimumSizeAndClear(ref foundBrushes, allTreeBrushIndexOrders.Length);
            NativeCollectionHelpers.EnsureMinimumSizeAndClear(ref usedBrushes, allTreeBrushIndexOrders.Length);

            // TODO: figure out a way to avoid needing this
            for (int a = 0; a < rebuildTreeBrushIndexOrders.Length; a++)
            {
                foundBrushes.Set(rebuildTreeBrushIndexOrders[a].nodeOrder, true);
            }

            //for (int index1 = 0; index1 < updateBrushIndicesArray.Length; index1++)
            {
                var brush1IndexOrder = rebuildTreeBrushIndexOrders[index1];
                int brush1NodeOrder  = brush1IndexOrder.nodeOrder;

                NativeListArray <BrushIntersectWith> .NativeList brush1Intersections;
                if (!brushBrushIntersections.IsAllocated(brush1NodeOrder))
                {
                    brush1Intersections = brushBrushIntersections.AllocateWithCapacityForIndex(brush1NodeOrder, 16);
                }
                else
                {
                    brush1Intersections = brushBrushIntersections[brush1NodeOrder];
                }
                for (int index0 = 0; index0 < allTreeBrushIndexOrders.Length; index0++)
                {
                    var brush0IndexOrder = allTreeBrushIndexOrders[index0];
                    int brush0NodeOrder  = brush0IndexOrder.nodeOrder;
                    if (brush0NodeOrder == brush1NodeOrder)
                    {
                        continue;
                    }
                    var found = foundBrushes.IsSet(brush0NodeOrder);
                    if (brush0NodeOrder < brush1NodeOrder && found)
                    {
                        continue;
                    }
                    var result = IntersectionUtility.FindIntersection(brush0NodeOrder, brush1NodeOrder,
                                                                      ref brushMeshLookup, ref brushTreeSpaceBounds, ref transformationCache,
                                                                      ref transformedPlanes0, ref transformedPlanes1);
                    if (result == IntersectionType.NoIntersection)
                    {
                        continue;
                    }
                    if (!found)
                    {
                        if (!usedBrushes.IsSet(brush0IndexOrder.nodeOrder))
                        {
                            usedBrushes.Set(brush0IndexOrder.nodeOrder, true);
                            brushesThatNeedIndirectUpdateHashMap.Add(brush0IndexOrder);
                            result = IntersectionUtility.Flip(result);
                            IntersectionUtility.StoreIntersection(brush1Intersections, brush0IndexOrder, result);
                        }
                    }
                    else
                    {
                        if (brush0NodeOrder > brush1NodeOrder)
                        {
                            result = IntersectionUtility.Flip(result);
                            IntersectionUtility.StoreIntersection(brush1Intersections, brush0IndexOrder, result);
                        }
                    }
                }
            }
        }