public virtual void CleanupInternalData(VolumetricWorldVoxelLayout layout) { foreach (var effect in effects) { effect.CleanupInternalData(layout); } }
public virtual void SetupInternalData(VolumetricWorldVoxelLayout layout, int myLayerId) { voxelLayerId = myLayerId; foreach (var effect in effects) { effect.SetupInternalData(layout); } }
public DoubleBufferModifierHandle(VolumetricWorldVoxelLayout voxels, int doubleBufferedLayerIndex) { valuesA = new NativeArray <float>(voxels.totalVoxels, Allocator.Persistent); valuesB = new NativeArray <float>(voxels.totalVoxels, Allocator.Persistent); mostRecentDataInA = true; this.voxelLayout = voxels; this.doubleBufferedLayerIndex = doubleBufferedLayerIndex; }
public CommandBufferNativeWritableHandle( NativeList <LayerModificationCommand> modificationCommandBuffer, VolumetricWorldVoxelLayout voxelDistribution, Matrix4x4 localToWorld) { this.modificationCommandBuffer = modificationCommandBuffer; this.voxelLayout = voxelDistribution; this.localToWorldTransformation = localToWorld; }
public DoubleBufferNativeWritableHandle( NativeArray <float> targetDurabilityData, VolumetricWorldVoxelLayout voxelDistribution, Matrix4x4 localToWorld) { this.targetData = targetDurabilityData; this.voxelLayout = voxelDistribution; this.localToWorldTransformation = localToWorld; }
/// <summary> /// takes in a by-voxel data array. returns another array of the same format with the diffused results. /// may modify the values in the input array. may return the input array. will handle disposing the input /// array if not returned. /// </summary> public static void ComputeDiffusion( VolumetricWorldVoxelLayout voxelLayout, DoubleBuffered <float> layerData, NativeArray <float> diffusionConstantMultipliers, float minimumDiffusionConstantMultiplier, float deltaTime, float diffusionConstant, ref JobHandleWrapper dependecy) { var combinedDiffusionFactor = deltaTime * diffusionConstant; if (combinedDiffusionFactor >= 1f / 6) { throw new System.ArgumentException("diffusion factor cannot exceed the connectivity of each node"); } var adjacencyVectors = new NativeArray <Vector3Int>(new[] { new Vector3Int(1, 0, 0), new Vector3Int(-1, 0, 0), new Vector3Int(0, 1, 0), new Vector3Int(0, -1, 0), new Vector3Int(0, 0, 1), new Vector3Int(0, 0, -1), }, Allocator.TempJob); var diffuseJob = new VoxelAdjacencyResourceConservingBoundaryComputeJob { sourceDiffusionValues = layerData.CurrentData, targetDiffusionValues = layerData.NextData, diffusionConstantAdjusters = diffusionConstantMultipliers, minimumDiffusionConstantMultiplier = minimumDiffusionConstantMultiplier, maximumDiffsuionConstant = 1 / 7f, adjacencyVectors = adjacencyVectors, voxelLayout = voxelLayout, diffusionConstant = combinedDiffusionFactor }; dependecy = diffuseJob.Schedule(layerData.CurrentData.Length, 1000, dependecy); layerData.Swap(); adjacencyVectors.Dispose(dependecy); }
/// <summary> /// takes in a by-voxel data array. returns another array of the same format with the diffused results. /// may modify the values in the input array. may return the input array. will handle disposing the input /// array if not returned. /// </summary> public static NativeArray <float> ComputeDiffusion( VolumetricWorldVoxelLayout voxelLayout, NativeArray <float> inputArrayWithData, float deltaTime, float diffusionConstant, ref JobHandle dependecy) { var kernel = new NativeArray <float>(3, Allocator.TempJob); var kernelJob = new VoxelKernelComputeJob { oneDimensionalKernel = kernel, deltaTime = deltaTime, diffusionConstant = diffusionConstant }; var kernelDep = kernelJob.Schedule(); dependecy = JobHandle.CombineDependencies(dependecy, kernelDep); var tmpSwapSpace = new NativeArray <float>(voxelLayout.totalVoxels, Allocator.TempJob); var diffuseXJob = new VoxelKernelDiffusionJob { sourceDiffusionValues = inputArrayWithData, targetDiffusionValues = tmpSwapSpace, oneDimensionalKernel = kernel, diffuseAxis = VoxelKernelDiffusionJob.DiffusionAxis.X, voxelLayout = voxelLayout, boundaryValue = 0 }; dependecy = diffuseXJob.Schedule(inputArrayWithData.Length, 1000, dependecy); var diffuseYJob = new VoxelKernelDiffusionJob { sourceDiffusionValues = tmpSwapSpace, targetDiffusionValues = inputArrayWithData, oneDimensionalKernel = kernel, diffuseAxis = VoxelKernelDiffusionJob.DiffusionAxis.Y, voxelLayout = voxelLayout, boundaryValue = 0 }; dependecy = diffuseYJob.Schedule(inputArrayWithData.Length, 1000, dependecy); var diffuseZJob = new VoxelKernelDiffusionJob { sourceDiffusionValues = inputArrayWithData, targetDiffusionValues = tmpSwapSpace, oneDimensionalKernel = kernel, diffuseAxis = VoxelKernelDiffusionJob.DiffusionAxis.Z, voxelLayout = voxelLayout, boundaryValue = 0 }; dependecy = diffuseZJob.Schedule(inputArrayWithData.Length, 1000, dependecy); inputArrayWithData.Dispose(dependecy); kernel.Dispose(dependecy); return(tmpSwapSpace); }
public CommandBufferModifierHandle(VolumetricWorldVoxelLayout voxels) { modificationCommands = new NativeList <LayerModificationCommand>(10, Allocator.Persistent); this.voxelLayout = voxels; }
public virtual void CleanupInternalData(VolumetricWorldVoxelLayout layout) { }
public override void CleanupInternalData(VolumetricWorldVoxelLayout layout) { base.CleanupInternalData(layout); damageDataUpdateDependency?.Complete(); volumetricDestructionTimestamps.Dispose(); }
public override void SetupInternalData(VolumetricWorldVoxelLayout layout) { base.SetupInternalData(layout); volumetricDestructionTimestamps = new NativeArray <float>(layout.totalVoxels, Allocator.Persistent); }