![]() If (tempVoxelCoord.Y > maxChanged.Y) maxChanged.Y = tempVoxelCoord.Y If (newVal maxChanged.X) maxChanged.X = tempVoxelCoord.X We are tracking which voxels were changed, so we can invalidate only needed cells in the cacheĮlse if (diff MyVoxelConstants.VOXEL_CONTENT_EMPTY & contentToRemove > MyVoxelConstants.VOXEL_CONTENT_EMPTY) Public static void CutOutSphereInvalidateCache(MyVoxelMap voxelMap, BoundingSphere sphere, ref bool changed) This is same as normal cut-out sphere, but cache is invalidated like in cut-out sphere fast(so that voxel cut-out will be immediately visible) VoxelMap.SetVoxelContent((byte)newVal, ref tempVoxelCoord) If (newVal < MyVoxelConstants.VOXEL_CONTENT_EMPTY) newVal = MyVoxelConstants.VOXEL_CONTENT_EMPTY Int newVal = originalContent - contentToRemove + sphere.Radius + MyVoxelConstants.VOXEL_SIZE_IN_METRES)) įor (tempVoxelCoord.X = minCorner.X tempVoxelCoord.X MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF)ĬontentToRemove = MyVoxelConstants.VOXEL_CONTENT_EMPTY Įlse if (diff MyVoxelConstants.VOXEL_CONTENT_EMPTY) + sphere.Radius + MyVoxelConstants.VOXEL_SIZE_IN_METRES, MyMwcVector3Int maxCorner = voxelMap.GetVoxelCoordinateFromMeters(new Vector3( sphere.Radius - MyVoxelConstants.VOXEL_SIZE_IN_METRES)) sphere.Radius - MyVoxelConstants.VOXEL_SIZE_IN_METRES, MyMwcVector3Int minCorner = voxelMap.GetVoxelCoordinateFromMeters(new Vector3( Public static void CutOutSphere(MyVoxelMap voxelMap, BoundingSphere sphere) This is non-optimized version (faster one is CutOutSphereFast). Center is relative to voxel map (not world coordinates). We modify only voxels inside the sphere - set them to full or partialy full. Generates inverse sphere in a voxel map (extract matters, create hole, etc - it's like explosion). VoxelMap.SetVoxelMaterialAndIndestructibleContent(voxelMaterial.Value, indestructibleContent, ref voxelCoord) if original material is same as new material then do nothingīyte indestructibleContent = MyVoxelConstants.VOXEL_CONTENT_EMPTY If (originalMaterial = voxelMaterial.Value) ![]() VoxelMap.GetMaterialAndIndestructibleContent(ref voxelCoord, out originalMaterial, MyMwcVoxelMaterialsEnum originalMaterial MyRender.GetRenderProfiler().EndProfilingBlock() if there are no voxel content then do nothing If (originalContent = MyVoxelConstants.VOXEL_CONTENT_EMPTY) MyRender.GetRenderProfiler().StartProfilingBlock("PerformChangeMaterialVoxels") īyte originalContent = voxelMap.GetVoxelContent(ref voxelCoord) Bool PerformChangeMaterialVoxels(MyVoxelMap voxelMap, MyMwcVector3Int voxelCoord, MyMwcVoxelMaterialsEnum? voxelMaterial, ref bool changed)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |