public static BurstBoxCollider CreateRandomBox() { var randomPosition = new Vector3(Random.value, Random.value, Random.value); var x = BurstColliderFactory.CreateBox(Random.insideUnitSphere * 4, randomPosition, Random.rotation); return(x); }
void OnDrawGizmos() { foreach (var item in _trackedObjects) { var box = BurstColliderFactory.CreateBox(item.Value.WrappedObject.transform); DrawingHelpers.DrawWireFrame(box); } }
void Update() { if (!ExecuteInEditMode && !Application.isPlaying) { return; } if (GridManager == null || !GridManager.IsValid) { return; } if (!isActiveAndEnabled || !transform.hasChanged) { return; } Box = BurstColliderFactory.CreateBox(transform); if (LogPerformance) { _stopwatch.Restart(); } var box = BurstColliderFactory.CreateBox(Collider as BoxCollider); _closestNodeToCenter = GridManager.Grid.FindClosestNode(Box.Center); _nodesInRange.Clear(); _touchedNodes.Clear(); if (GridManager.Grid.CollidesWithNode(Collider, _closestNodeToCenter, out float gapDistance, out Vector3 pointOnCollider)) { //var scanDistance = 1 + (int) Math.Round((Collider.bounds.size.x / 2f) - gapDistance, MidpointRounding.AwayFromZero); //var boxWorldMin = Box.Center - Box.Min; //var boxWorldMax = Box.Center - Box.Max; //var a = math.transform(Box.ToWorldMatrix, Box.Min); //var b = math.transform(Box.ToWorldMatrix, Box.Max); //DebugExtension.DebugWireSphere(a, Color.yellow, 0.1f); //DebugExtension.DebugWireSphere(b, Color.yellow, 0.1f); //var minNode = GridManager.Grid.FindClosestNode(Box.Bounds.min); //var maxNode = GridManager.Grid.FindClosestNode(Box.Bounds.max); //var debug1 = GridManager.Grid.ToWorldPosition(minNode.Center); //var debug2 = GridManager.Grid.ToWorldPosition(maxNode.Center); //DebugExtension.DebugWireSphere(debug1, Color.red, 0.1f); //DebugExtension.DebugWireSphere(debug2, Color.red, 0.1f); //var sw = Stopwatch.StartNew(); _trackedIndices = GridNodeJobs.AllNodes.IntersectionDiff.SetFlagsInBoxDiff.Run(GridManager.Grid, (ulong)AddFlags, box, _trackedIndices); //sw.Stop(); //Debug.Log($"Took: {sw.Elapsed.TotalMilliseconds:N8} ms"); } }