public bool GenerateNodes(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, NativeList <GeneratedNode> nodes, Allocator allocator)
        {
            var generatedBrushMeshes = new NativeList <ChiselBlobAssetReference <BrushMeshBlob> >(nodes.Length, Allocator.Temp);

            try
            {
                generatedBrushMeshes.Resize(nodes.Length, NativeArrayOptions.ClearMemory);
                if (!BrushMeshFactory.GenerateSpiralStairs(generatedBrushMeshes,
                                                           ref this,
                                                           in surfaceDefinitionBlob,
                                                           allocator))
                {
                    for (int i = 0; i < generatedBrushMeshes.Length; i++)
                    {
                        if (generatedBrushMeshes[i].IsCreated)
                        {
                            generatedBrushMeshes[i].Dispose();
                        }
                        generatedBrushMeshes[i] = default;
                    }
                    return(false);
                }
                for (int i = 0; i < generatedBrushMeshes.Length; i++)
                {
                    nodes[i] = GeneratedNode.GenerateBrush(generatedBrushMeshes[i]);
                }

                // TODO: clean this up
                {
                    var subMeshIndex = TreadStart - CylinderSubMeshCount;
                    var node         = nodes[subMeshIndex];
                    node.operation      = CSGOperationType.Intersecting;
                    nodes[subMeshIndex] = node;

                    subMeshIndex        = RequiredSubMeshCount - CylinderSubMeshCount;
                    node                = nodes[subMeshIndex];
                    node.operation      = CSGOperationType.Intersecting;
                    nodes[subMeshIndex] = node;
                }

                if (HaveInnerCylinder)
                {
                    var subMeshIndex = TreadStart - 1;
                    var node         = nodes[subMeshIndex];
                    node.operation      = CSGOperationType.Subtractive;
                    nodes[subMeshIndex] = node;

                    subMeshIndex        = RequiredSubMeshCount - 1;
                    node                = nodes[subMeshIndex];
                    node.operation      = CSGOperationType.Subtractive;
                    nodes[subMeshIndex] = node;
                }

                return(true);
            }
            finally
            {
                generatedBrushMeshes.Dispose();
            }
        }
예제 #2
0
        public ChiselBlobAssetReference <BrushMeshBlob> GenerateMesh(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, Allocator allocator)
        {
            var topDiameter    = new float2(topDiameterX, topDiameterZ);
            var bottomDiameter = new float2(bottomDiameterX, bottomDiameterZ);

            var topHeight    = height + bottomOffset;
            var bottomHeight = bottomOffset;

            switch (type)
            {
            case CylinderShapeType.ConicalFrustum:  break;

            case CylinderShapeType.Cylinder:        topDiameter = bottomDiameter; break;

            case CylinderShapeType.Cone:            topDiameter = float2.zero; break;

            default: throw new NotImplementedException();
            }

            if (!isEllipsoid)
            {
                topDiameter.y    = topDiameter.x;
                bottomDiameter.y = bottomDiameter.x;
            }

            if (!BrushMeshFactory.GenerateConicalFrustumSubMesh(topDiameter, topHeight,
                                                                bottomDiameter, bottomHeight,
                                                                rotation, sides, fitToBounds,
                                                                in surfaceDefinitionBlob,
                                                                out var newBrushMesh,
                                                                allocator))
            {
                return(default);
예제 #3
0
 public ChiselBlobAssetReference <BrushMeshBlob> GenerateMesh(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, Allocator allocator)
 {
     if (!BrushMeshFactory.CreateBox(bounds.Min, bounds.Max,
                                     in surfaceDefinitionBlob,
                                     out var newBrushMesh,
                                     allocator))
     {
         return(default);
 public ChiselBlobAssetReference <BrushMeshBlob> GenerateMesh(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, Allocator allocator)
 {
     if (!BrushMeshFactory.GenerateCapsule(in this,
                                           in surfaceDefinitionBlob,
                                           out var newBrushMesh,
                                           allocator))
     {
         return(default);
예제 #5
0
 public ChiselBlobAssetReference <BrushMeshBlob> GenerateMesh(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, Allocator allocator)
 {
     if (!BrushMeshFactory.GenerateStadium(width, height, length,
                                           topLength, topSides,
                                           bottomLength, bottomSides,
                                           in surfaceDefinitionBlob,
                                           out var newBrushMesh,
                                           allocator))
     {
         return(default);
 public static GeneratedNode GenerateBrush(ChiselBlobAssetReference <BrushMeshBlob> brushMesh, float4x4 transformation, CSGOperationType operation = CSGOperationType.Additive, int parentIndex = -1)
 {
     return(new GeneratedNode
     {
         parentIndex = parentIndex,
         transformation = transformation,
         operation = operation,
         brushMesh = brushMesh
     });
 }
예제 #7
0
 public ChiselBlobAssetReference <BrushMeshBlob> GenerateMesh(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, Allocator allocator)
 {
     if (!BrushMeshFactory.GenerateHemisphere(diameterXYZ,
                                              rotation, // TODO: useless?
                                              horizontalSegments,
                                              verticalSegments,
                                              in surfaceDefinitionBlob,
                                              out var newBrushMesh,
                                              allocator))
     {
         return(default);
예제 #8
0
        public bool GenerateNodes(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, NativeList <GeneratedNode> nodes, Allocator allocator)
        {
            var generatedBrushMeshes = new NativeList <ChiselBlobAssetReference <BrushMeshBlob> >(nodes.Length, Allocator.Temp);

            try
            {
                generatedBrushMeshes.Resize(nodes.Length, NativeArrayOptions.ClearMemory);
                using var vertices = BrushMeshFactory.GenerateTorusVertices(outerDiameter,
                                                                            tubeWidth,
                                                                            tubeHeight,
                                                                            tubeRotation,
                                                                            startAngle,
                                                                            totalAngle,
                                                                            verticalSegments,
                                                                            horizontalSegments,
                                                                            fitCircle,
                                                                            Allocator.Temp);

                if (!BrushMeshFactory.GenerateTorus(generatedBrushMeshes,
                                                    in vertices,
                                                    verticalSegments,
                                                    horizontalSegments,
                                                    in surfaceDefinitionBlob,
                                                    allocator))
                {
                    for (int i = 0; i < generatedBrushMeshes.Length; i++)
                    {
                        if (generatedBrushMeshes[i].IsCreated)
                        {
                            generatedBrushMeshes[i].Dispose();
                        }
                        generatedBrushMeshes[i] = default;
                    }
                    return(false);
                }

                for (int i = 0; i < generatedBrushMeshes.Length; i++)
                {
                    nodes[i] = GeneratedNode.GenerateBrush(generatedBrushMeshes[i]);
                }
                return(true);
            }
            finally
            {
                generatedBrushMeshes.Dispose();
            }
        }
        public bool GenerateNodes(ChiselBlobAssetReference <NativeChiselSurfaceDefinition> surfaceDefinitionBlob, NativeList <GeneratedNode> nodes, Allocator allocator)
        {
            var generatedBrushMeshes = new NativeList <ChiselBlobAssetReference <BrushMeshBlob> >(nodes.Length, Allocator.Temp);

            try
            {
                generatedBrushMeshes.Resize(nodes.Length, NativeArrayOptions.ClearMemory);
                var description = new BrushMeshFactory.LineairStairsData(bounds,
                                                                         stepHeight, stepDepth,
                                                                         treadHeight,
                                                                         nosingDepth, nosingWidth,
                                                                         plateauHeight,
                                                                         riserType, riserDepth,
                                                                         leftSide, rightSide,
                                                                         sideWidth, sideHeight, sideDepth);
                const int subMeshOffset = 0;
                if (!BrushMeshFactory.GenerateLinearStairsSubMeshes(generatedBrushMeshes,
                                                                    subMeshOffset,
                                                                    in description,
                                                                    in surfaceDefinitionBlob,
                                                                    allocator))
                {
                    for (int i = 0; i < generatedBrushMeshes.Length; i++)
                    {
                        if (generatedBrushMeshes[i].IsCreated)
                        {
                            generatedBrushMeshes[i].Dispose();
                        }
                        generatedBrushMeshes[i] = default;
                    }
                    return(false);
                }
                for (int i = 0; i < generatedBrushMeshes.Length; i++)
                {
                    nodes[i] = GeneratedNode.GenerateBrush(generatedBrushMeshes[i]);
                }
            }
            finally
            {
                generatedBrushMeshes.Dispose();
            }
            return(true);
        }
예제 #10
0
 bool CopyPolygonToIndices(ChiselBlobAssetReference <BrushMeshBlob> mesh, ref ChiselBlobArray <float3> treeSpaceVertices, int polygonIndex, HashedVertices hashedTreeSpaceVertices, NativeArray <Edge> edges, ref int edgeCount)
 {
     ref var halfEdges = ref mesh.Value.halfEdges;
        public ChiselBlobAssetReference <BrushMeshBlob> brushMesh;        // Note: ignored if type is not Brush


        public static GeneratedNode GenerateBrush(ChiselBlobAssetReference <BrushMeshBlob> brushMesh, CSGOperationType operation = CSGOperationType.Additive, int parentIndex = -1)
        {
            return(GenerateBrush(brushMesh, float4x4.identity, operation, parentIndex));
        }