public void DrawLeavesRecursive(NativeArray <BoundingVolumeHierarchy.Node> nodes, Color color, int nodeIndex) { if (nodes[nodeIndex].IsLeaf) { bool4 leavesValid = nodes[nodeIndex].AreLeavesValid; for (int l = 0; l < 4; l++) { if (leavesValid[l]) { Aabb aabb = nodes[nodeIndex].Bounds.GetAabb(l); float3 center = aabb.Center; OutputStream.Box(aabb.Extents, center, Quaternion.identity, color); } } return; } for (int i = 0; i < 4; i++) { if (nodes[nodeIndex].IsChildValid(i)) { DrawLeavesRecursive(nodes, color, nodes[nodeIndex].Data[i]); } } }
public void Execute() { OutputStream.Begin(0); for (int b = 0; b < Bodies.Length; b++) { if (Bodies[b].Collider.IsCreated) { Aabb aabb = Bodies[b].Collider.Value.CalculateAabb(Bodies[b].WorldFromBody); float3 center = aabb.Center; OutputStream.Box(aabb.Extents, center, Quaternion.identity, DebugDisplay.ColorIndex.BrightRed); } } OutputStream.End(); }
public void Execute() { OutputStream.Begin(0); for (int b = 0; b < Bodies.Length; b++) { if (Bodies[b].Collider != null) { Aabb aabb = Bodies[b].Collider->CalculateAabb(Bodies[b].WorldFromBody); float3 center = aabb.Center; OutputStream.Box(aabb.Extents, center, Quaternion.identity, new Color(0.7f, 0.125f, 0.125f)); } } OutputStream.End(); }
public void Execute() { OutputStream.Begin(0); for (int m = 0; m < MotionDatas.Length; m++) { float3 com = MotionDatas[m].WorldFromMotion.pos; quaternion o = MotionDatas[m].WorldFromMotion.rot; float3 invInertiaLocal = MotionVelocities[m].InverseInertiaAndMass.xyz; float3 il = new float3(1.0f / invInertiaLocal.x, 1.0f / invInertiaLocal.y, 1.0f / invInertiaLocal.z); float invMass = MotionVelocities[m].InverseInertiaAndMass.w; // Reverse the inertia tensor computation to build a box which has the inerta tensor 'il' // The diagonal inertia of a box with dimensions h,w,d and mass m is: // Ix = 1/12 m (ww + dd) // Iy = 1/12 m (dd + hh) // Iz = 1/12 m (ww + hh) // // For simplicity, set K = I * 12 / m // Then K = (ww + dd, dd + hh, ww + hh) // => ww = Kx - dd, dd = Ky - hh, hh = Kz - ww // By manipulation: // 2ww = Kx - Ky + Kz // => w = ((0.5)(Kx - Ky + Kz))^-1 // Then, substitution gives h and d. float3 k = new float3(il.x * 12 * invMass, il.y * 12 * invMass, il.z * 12 * invMass); float w = math.sqrt((k.x - k.y + k.z) * 0.5f); float h = math.sqrt(k.z - w * w); float d = math.sqrt(k.y - h * h); float3 boxSize = new float3(h, w, d); OutputStream.Box(boxSize, com, o, Color.magenta); } OutputStream.End(); }