Example #1
0
    public void DebugDrawVelocityGrid()
    {
        if (mVelGrid != null)
        {
            Vector3 cellExtent = mVelGrid.GetCellExtent();
            Vector3 gridExtent = mVelGrid.GetExtent();
            Vector3 numCells   = new Vector3(mVelGrid.GetNumCells(0), mVelGrid.GetNumCells(1), mVelGrid.GetNumCells(2));
            Vector3 gridOrigin = mVelGrid.GetMinCorner();

            for (int i = 0; i < numCells.x; ++i)
            {
                for (int j = 0; j < numCells.y; ++j)
                {
                    for (int k = 0; k < numCells.z; ++k)
                    {
                        uint[]  indices = { (uint)i, (uint)j, (uint)k };
                        uint    offset  = mVelGrid.OffsetFromIndices(indices);
                        Vector3 center  = mVelGrid.PositionFromIndices(indices) + cellExtent / 2;
                        if (mVelGrid[offset].v.magnitude == 0)
                        {
                            break;
                        }

                        Color color = new Vector4(0.8f, 0.8f, 1, 1);
                        DebugExtension.DrawArrow(center, mVelGrid[offset].v / 8, color);
                    }
                }
            }
        }
    }