public void Test_SetGetVoxelData_Index([Random(0, 1f, 5)] float newVoxelData, [Random(0, 5 * 5 * 5 - 1, 5)] int index)
 {
     TestSetGetVoxelData(() =>
     {
         voxelDataVolume.SetVoxelData(newVoxelData, index);
         return(voxelDataVolume.GetVoxelData(index));
     }, newVoxelData);
 }
示例#2
0
        public void Test_SetGetVoxelData_Index([Random(0, 1f, 5)] float newVoxelData, [Random(0, 5 * 5 * 5 - 1, 5)] int index)
        {
            voxelDataVolume = new VoxelDataVolume(5, Allocator.Temp);

            voxelDataVolume.SetVoxelData(newVoxelData, index);
            float actualVoxelData = voxelDataVolume.GetVoxelData(index);

            Assert.IsTrue(AreVoxelDatasSame(newVoxelData, actualVoxelData), $"Expected {newVoxelData}, actual was {actualVoxelData}");
        }
示例#3
0
        public void Test_SetGetVoxelData_Int3([Random(0, 1f, 5)] float newVoxelData, [Random(0, 4, 3)] int x, [Random(0, 4, 3)] int y, [Random(0, 4, 3)] int z)
        {
            voxelDataVolume = new VoxelDataVolume(5, Allocator.Temp);

            voxelDataVolume.SetVoxelData(newVoxelData, new int3(x, y, z));
            float actualVoxelData = voxelDataVolume.GetVoxelData(new int3(x, y, z));

            Assert.IsTrue(AreVoxelDatasSame(newVoxelData, actualVoxelData), $"Expected {newVoxelData}, actual was {actualVoxelData}");
        }
示例#4
0
        public void Test_IncreaseVoxelData_Index(float increaseAmount, float originalVoxelData, float expectedVoxelData)
        {
            voxelDataVolume = new VoxelDataVolume(5, Allocator.Temp);
            int index = 36; // Just some arbitrary index to set the voxel data at

            voxelDataVolume.SetVoxelData(originalVoxelData, index);
            voxelDataVolume.IncreaseVoxelData(increaseAmount, index);

            float actualVoxelData = voxelDataVolume.GetVoxelData(index);

            Assert.IsTrue(AreVoxelDatasSame(expectedVoxelData, actualVoxelData), $"Expected {expectedVoxelData}, actual was {actualVoxelData}");
        }
示例#5
0
        /// <summary>
        /// Gets the voxel data of a custom volume in the world
        /// </summary>
        /// <param name="worldSpaceQuery">The world-space volume to get the voxel data for</param>
        /// <param name="allocator">How the new voxel data array should be allocated</param>
        /// <returns>The voxel data array inside the bounds</returns>
        public VoxelDataVolume <T> GetVoxelDataCustom(BoundsInt worldSpaceQuery, Allocator allocator)
        {
            VoxelDataVolume <T> voxelDataArray = new VoxelDataVolume <T>(worldSpaceQuery.CalculateVolume(), allocator);

            ForEachVoxelDataArrayInQuery(worldSpaceQuery, (chunkCoordinate, voxelDataChunk) =>
            {
                ForEachVoxelDataInQueryInChunk(worldSpaceQuery, chunkCoordinate, voxelDataChunk, (voxelDataWorldPosition, voxelDataLocalPosition, voxelDataIndex, voxelData) =>
                {
                    voxelDataArray.SetVoxelData(voxelData, voxelDataWorldPosition - worldSpaceQuery.min.ToInt3());
                });
            });

            return(voxelDataArray);
        }