// ReSharper disable once UnusedMember.Local void OnDrawGizmosSelected() { Gizmos.color = Color.blue; Gizmos.DrawWireCube( RaycastTerrainBounds.center + TerrainPosition + VegetationStudioManager.GetFloatingOriginOffset(), RaycastTerrainBounds.size); }
public JobHandle SampleTerrain(NativeList <VegetationSpawnLocationInstance> spawnLocationList, VegetationInstanceData instanceData, int sampleCount, Rect spawnRect, JobHandle dependsOn) { if (!_initDone) { return(dependsOn); } Vector3 floatingOriginOffset = VegetationStudioManager.GetFloatingOriginOffset(); Rect terrainRect = RectExtension.CreateRectFromBounds(TerrainBounds); if (!spawnRect.Overlaps(terrainRect)) { return(dependsOn); } MaxHits = 1; RaycastContainers raycastContainers = RaycastContainerPool.Get(); raycastContainers.RaycastCommands = new NativeArray <RaycastCommand>(sampleCount, Allocator.TempJob); raycastContainers.RaycastHits = new NativeArray <RaycastHit>(sampleCount * MaxHits, Allocator.TempJob); RaycastContainerList.Add(raycastContainers); CreateRaycastCommandsJob createRaycastCommandsJob = new CreateRaycastCommandsJob { SpawnLocationList = spawnLocationList.ToDeferredJobArray(), LayerMask = RaycastLayerMask, MaxHits = MaxHits, RaycastCommands = raycastContainers.RaycastCommands, FloatingOriginOffset = floatingOriginOffset }; dependsOn = createRaycastCommandsJob.Schedule(dependsOn); dependsOn = RaycastCommand.ScheduleBatch(raycastContainers.RaycastCommands, raycastContainers.RaycastHits, 32, dependsOn); UpdateInstanceListJob updateInstanceListJob = new UpdateInstanceListJob { Position = instanceData.Position, Rotation = instanceData.Rotation, Scale = instanceData.Scale, TerrainNormal = instanceData.TerrainNormal, BiomeDistance = instanceData.BiomeDistance, TerrainTextureData = instanceData.TerrainTextureData, RandomNumberIndex = instanceData.RandomNumberIndex, DistanceFalloff = instanceData.DistanceFalloff, VegetationMaskDensity = instanceData.VegetationMaskDensity, VegetationMaskScale = instanceData.VegetationMaskScale, TerrainSourceIDs = instanceData.TerrainSourceID, TextureMaskData = instanceData.TextureMaskData, Excluded = instanceData.Excluded, RaycastHits = raycastContainers.RaycastHits, HeightmapSampled = instanceData.HeightmapSampled, SpawnLocationList = spawnLocationList.ToDeferredJobArray(), TerrainRect = terrainRect, FloatingOriginOffset = floatingOriginOffset, TerrainSourceID = (byte)TerrainSourceID }; dependsOn = updateInstanceListJob.Schedule(dependsOn); return(dependsOn); }