| 1415 | } |
| 1416 | |
| 1417 | void DebugDraw::DrawWireSphere(const BoundingSphere& sphere, const Color& color, float duration, bool depthTest) |
| 1418 | { |
| 1419 | // Select LOD |
| 1420 | int32 index; |
| 1421 | const Float3 centerF = sphere.Center - Context->Origin; |
| 1422 | const float radiusF = (float)sphere.Radius; |
| 1423 | const float screenRadiusSquared = RenderTools::ComputeBoundsScreenRadiusSquared(centerF, radiusF, Context->LastViewPos, Context->LastViewProjection); |
| 1424 | if (screenRadiusSquared > DEBUG_DRAW_SPHERE_LOD0_SCREEN_SIZE * DEBUG_DRAW_SPHERE_LOD0_SCREEN_SIZE * 0.25f) |
| 1425 | index = 0; |
| 1426 | else if (screenRadiusSquared > DEBUG_DRAW_SPHERE_LOD1_SCREEN_SIZE * DEBUG_DRAW_SPHERE_LOD1_SCREEN_SIZE * 0.25f) |
| 1427 | index = 1; |
| 1428 | else |
| 1429 | index = 2; |
| 1430 | auto& cache = SphereCache[index]; |
| 1431 | |
| 1432 | // Draw lines of the unit sphere after linear transform |
| 1433 | PROFILE_MEM(EngineDebug); |
| 1434 | auto& debugDrawData = depthTest ? Context->DebugDrawDepthTest : Context->DebugDrawDefault; |
| 1435 | if (duration > 0) |
| 1436 | { |
| 1437 | DebugLine l = { Float3::Zero, Float3::Zero, Color32(color), duration }; |
| 1438 | for (int32 i = 0; i < cache.Vertices.Count();) |
| 1439 | { |
| 1440 | l.Start = centerF + cache.Vertices.Get()[i++] * radiusF; |
| 1441 | l.End = centerF + cache.Vertices.Get()[i++] * radiusF; |
| 1442 | debugDrawData.DefaultLines.Add(l); |
| 1443 | } |
| 1444 | } |
| 1445 | else |
| 1446 | { |
| 1447 | Vertex l = { Float3::Zero, Color32(color) }; |
| 1448 | for (int32 i = 0; i < cache.Vertices.Count();) |
| 1449 | { |
| 1450 | l.Position = centerF + cache.Vertices.Get()[i++] * radiusF; |
| 1451 | debugDrawData.OneFrameLines.Add(l); |
| 1452 | l.Position = centerF + cache.Vertices.Get()[i++] * radiusF; |
| 1453 | debugDrawData.OneFrameLines.Add(l); |
| 1454 | } |
| 1455 | } |
| 1456 | } |
| 1457 | |
| 1458 | void DebugDraw::DrawSphere(const BoundingSphere& sphere, const Color& color, float duration, bool depthTest) |
| 1459 | { |
no test coverage detected