private void AddCameraToSort(Camera camera) { float3 min = camera.ViewportToWorldPoint(new Vector3(0F, 1F)); float3 max = camera.ViewportToWorldPoint(new Vector3(1F, 0F, camera.farClipPlane)); var b = new Bounds(); b.SetMinMax(math.min(min, max), math.max(min, max)); _cameraDataList.Add(new QuerySpatialHashingJob.CameraData { Bounds = b }); }
/// <inheritdoc /> protected override void InitSpatialHashing() { var matrix = GetSingleton <IsometricMatrix>(); var size = new float3(600, 600, 50); var pivot = new float3(size.x, 0F, 0F); var bottomPosition = matrix.IsoToScreen(pivot); var topPosition = matrix.IsoToScreen(new float3(pivot.x - size.x, pivot.yz + size.yz)); var isoBottom = pivot; isoBottom.y += size.y; var rightPosition = matrix.IsoToScreen(isoBottom); var leftPosition = matrix.IsoToScreen(new float3(pivot.x - size.x, pivot.yz)); var screenMin = new float2(leftPosition.x, bottomPosition.y); var screenMax = new float2(rightPosition.x, topPosition.y); var bounds = new Bounds(); bounds.SetMinMax(new float3(screenMin, 0F), new float3(screenMax, 1F)); size = new float3(6, 6, 3); pivot = new float3(size.x, 0F, 0F); bottomPosition = matrix.IsoToScreen(pivot); topPosition = matrix.IsoToScreen(new float3(pivot.x - size.x, pivot.yz + size.yz)); isoBottom = pivot; isoBottom.y += size.y; rightPosition = matrix.IsoToScreen(isoBottom); leftPosition = matrix.IsoToScreen(new float3(pivot.x - size.x, pivot.yz)); screenMin = new float2(leftPosition.x, bottomPosition.y); screenMax = new float2(rightPosition.x, topPosition.y); Debug.Log($"SpatialHashing Bounds {bounds} CellSize {new float3(screenMax - screenMin, 1F)}"); _spatialHash = new SpatialHash <IsometricData>(bounds, new float3(screenMax - screenMin, 1F), Allocator.Persistent); }