Пример #1
0
        public void VisualizeVoxels(Matrix4x4 vesselLocalToWorldMatrix)
        {
            ClearVisualVoxels();
            visualVoxels = new DebugVisualVoxel[8, 8, 8];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        DebugVisualVoxel vx;
                        //if(voxelPoints[i,j,k] != null)
                        PartSizePair pair = voxelPoints[i + 8 * j + 64 * k];
                        if ((object)pair.part != null)
                        {
                            double elementSize = pair.GetSize();
                            if (elementSize > 1)
                            {
                                elementSize = 1;
                            }

                            elementSize          *= _size * 0.5f;
                            vx                    = new DebugVisualVoxel(vesselLocalToWorldMatrix.MultiplyPoint3x4(lowerCorner + new Vector3d(i, j, k) * _size), elementSize);
                            visualVoxels[i, j, k] = vx;
                        }
                    }
                }
            }
        }
        public void VisualizeVoxels(Matrix4x4 vesselLocalToWorldMatrix, DebugVisualVoxelMeshController voxelMesh)
        {
            ClearVisualVoxels();
            visualVoxels = new DebugVisualVoxel[8, 8, 8];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        PartSizePair pair = voxelPoints[i + 8 * j + 64 * k];
                        if (pair.part is null)
                        {
                            continue;
                        }
                        double elementSize = pair.GetSize();
                        if (elementSize > 1)
                        {
                            elementSize = 1;
                        }

                        elementSize *= _size * 0.5f;
                        var vx =
                            new DebugVisualVoxel(vesselLocalToWorldMatrix.MultiplyPoint3x4(lowerCorner +
                                                                                           new Vector3d(i, j, k) *
                                                                                           _size),
                                                 elementSize);
                        voxelMesh.DebugVoxels.Add(vx);
                        visualVoxels[i, j, k] = vx;
                    }
                }
            }
        }
        public void VisualizeVoxels <T>(
            Matrix4x4 vesselLocalToWorldMatrix,
            PartTint tint,
            DebugVoxelMesh voxelMesh,
            T builder
            ) where T : IDebugVoxelMeshBuilder <DebugVoxel>
        {
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        PartSizePair pair = voxelPoints[i + 8 * j + 64 * k];
                        if (pair.part is null)
                        {
                            continue;
                        }
                        double elementSize = pair.GetSize();
                        if (elementSize > 1)
                        {
                            elementSize = 1;
                        }

                        elementSize *= _size * 0.5f;
                        var vx =
                            new DebugVoxel(vesselLocalToWorldMatrix.MultiplyPoint3x4(lowerCorner +
                                                                                     new Vector3d(i, j, k) * _size),
                                           (float)elementSize,
                                           tint.GetOrAdd(pair.part));
                        voxelMesh.Add(builder, vx);
                    }
                }
            }
        }
Пример #4
0
        unsafe void SetPart(Part p, int index, VoxelOrientationPlane plane, byte location)
        {
            PartSizePair pair = voxelPoints[index];

            Part currentPart = pair.part;
            //if we update the plane location with this, then we can consider replacing the part here.  Otherwise, we don't
            bool largerThanLast = pair.SetPlaneLocation(plane, location);

            if ((object)currentPart == null || overridingParts.Contains(p) || (largerThanLast && !overridingParts.Contains(currentPart)))
            {
                pair.part = p;
            }
        }
Пример #5
0
        public VoxelChunk(double size, Vector3d lowerCorner, int iOffset, int jOffset, int kOffset, HashSet <Part> overridingParts)
        {
            _size  = size;
            offset = iOffset + 8 * jOffset + 64 * kOffset;
            //voxelPoints = new Part[512];
            //voxelSize = new float[512];
            voxelPoints = new PartSizePair[512];
            for (int i = 0; i < voxelPoints.Length; i++)
            {
                voxelPoints[i] = new PartSizePair();
            }

            this.lowerCorner     = lowerCorner;
            this.overridingParts = overridingParts;
        }
        private void SetPart(Part p, int index, VoxelOrientationPlane plane, byte location)
        {
            PartSizePair pair = voxelPoints[index];

            Part currentPart = pair.part;
            //if we update the plane location with this, then we can consider replacing the part here.  Otherwise, we don't
            bool largerThanLast  = pair.SetPlaneLocation(plane, location);
            int  currentPriority = PartPriority(currentPart);
            int  newPriority     = PartPriority(p);

            if (newPriority > currentPriority ||
                largerThanLast && currentPriority <= 0)
            {
                pair.part = p;
            }
        }