示例#1
0
        public static bool UpdateBrushMesh(Int32 brushMeshInstanceID,
                                           Vector3[]                    vertices,
                                           BrushMesh.HalfEdge[] halfEdges,
                                           BrushMesh.Polygon[]  polygons)
        {
            if (vertices == null || halfEdges == null || polygons == null)
            {
                return(false);
            }

            if (!AssertBrushMeshIDValid(brushMeshInstanceID))
            {
                return(false);
            }

            BrushMesh brushMesh = GetBrushMesh(brushMeshInstanceID);

            if (brushMesh == null)
            {
                Debug.LogWarning("Brush has no BrushMeshInstance set");
                return(false);
            }

            if (!brushMesh.Set(vertices, halfEdges, polygons))
            {
                Debug.LogWarning("GenerateMesh failed");
                return(false);
            }

            CSGManager.NotifyBrushMeshModified(brushMeshInstanceID);
            return(true);
        }
示例#2
0
        public static bool UpdateBrushMesh(Int32 brushMeshInstanceID,
                                           float3[]                         vertices,
                                           BrushMesh.HalfEdge[] halfEdges,
                                           BrushMesh.Polygon[]  polygons)
        {
            if (vertices == null || halfEdges == null || polygons == null)
            {
                return(false);
            }

            if (!AssertBrushMeshIDValid(brushMeshInstanceID))
            {
                return(false);
            }

            BrushMesh brushMesh = GetBrushMesh(brushMeshInstanceID);

            if (brushMesh == null)
            {
                Debug.LogWarning("Brush has no BrushMeshInstance set");
                return(false);
            }

            if (!brushMesh.Set(vertices, halfEdges, polygons))
            {
                Debug.LogWarning("GenerateMesh failed");
                return(false);
            }

            var brushMeshIndex = brushMeshInstanceID - 1;

            if (ChiselMeshLookup.Value.brushMeshBlobs.TryGetValue(brushMeshIndex, out BlobAssetReference <BrushMeshBlob> item))
            {
                ChiselMeshLookup.Value.brushMeshBlobs.Remove(brushMeshIndex);
                if (item.IsCreated)
                {
                    item.Dispose();
                }
            }
            ChiselMeshLookup.Value.brushMeshBlobs[brushMeshIndex] = BrushMeshBlob.Build(brushMesh);
            Profiler.BeginSample("BrushMeshBlob.Build");
            CSGManager.NotifyBrushMeshModified(brushMeshInstanceID);
            Profiler.EndSample();
            return(true);
        }
        public static Int32 CreateBrushMesh(Int32 userID,
                                            float3[]                     vertices,
                                            BrushMesh.HalfEdge[] halfEdges,
                                            BrushMesh.Polygon[]  polygons)
        {
            int       brushMeshID = CreateBrushMeshID(userID);
            BrushMesh brushMesh   = GetBrushMesh(brushMeshID);

            if (brushMesh == null)
            {
                Debug.LogWarning("brushMesh == nullptr");
                DestroyBrushMesh(brushMeshID);
                return(BrushMeshInstance.InvalidInstanceID);
            }

            if (!brushMesh.Set(vertices, halfEdges, polygons))
            {
                Debug.LogWarning("GenerateMesh failed");
                DestroyBrushMesh(brushMeshID);
                return(BrushMeshInstance.InvalidInstanceID);
            }

            var brushMeshIndex = brushMeshID - 1;

            if (ChiselMeshLookup.Value.brushMeshBlobs.TryGetValue(brushMeshIndex, out BlobAssetReference <BrushMeshBlob> item))
            {
                ChiselMeshLookup.Value.brushMeshBlobs.Remove(brushMeshIndex);
                if (item.IsCreated)
                {
                    item.Dispose();
                }
            }

            ChiselMeshLookup.Value.brushMeshUpdateList.Add(brushMeshIndex);

            /*
             * Profiler.BeginSample("BrushMeshBlob.Build");
             * ChiselMeshLookup.Value.brushMeshBlobs[brushMeshIndex] = BrushMeshBlob.Build(brushMesh);
             * Profiler.EndSample();*/
            return(brushMeshID);
        }
示例#4
0
        public static Int32 CreateBrushMesh(Int32 userID,
                                            Vector3[]                    vertices,
                                            BrushMesh.HalfEdge[] halfEdges,
                                            BrushMesh.Polygon[]  polygons)
        {
            int       brushMeshID = CreateBrushMeshID(userID);
            BrushMesh brushMesh   = GetBrushMesh(brushMeshID);

            if (brushMesh == null)
            {
                Debug.LogWarning("brushMesh == nullptr");
                DestroyBrushMesh(brushMeshID);
                return(BrushMeshInstance.InvalidInstanceID);
            }

            if (!brushMesh.Set(vertices, halfEdges, polygons))
            {
                Debug.LogWarning("GenerateMesh failed");
                DestroyBrushMesh(brushMeshID);
                return(BrushMeshInstance.InvalidInstanceID);
            }
            return(brushMeshID);
        }