| 1405 | } |
| 1406 | |
| 1407 | void Renderer::AddDebugCone(const Vector3& center, const Quaternion& orient, float radius, float length, const Vector4& color, RendererDebugPage page, bool isWireframe) |
| 1408 | { |
| 1409 | constexpr auto SUBDIVISION_COUNT = 32; |
| 1410 | |
| 1411 | if (_isLocked) |
| 1412 | return; |
| 1413 | |
| 1414 | if (!DebugMode || (_debugPage != page && page != RendererDebugPage::None)) |
| 1415 | return; |
| 1416 | |
| 1417 | auto rotMatrix = Matrix::CreateFromQuaternion(orient); |
| 1418 | |
| 1419 | auto baseVertices = std::vector<Vector3>{}; |
| 1420 | baseVertices.reserve(SUBDIVISION_COUNT); |
| 1421 | float angle = 0.0f; |
| 1422 | |
| 1423 | // Calculate base circle vertices. |
| 1424 | for (int i = 0; i <= SUBDIVISION_COUNT; i++) |
| 1425 | { |
| 1426 | float sinAngle = sin(angle); |
| 1427 | float cosAngle = cos(angle); |
| 1428 | |
| 1429 | auto vertex = center + Vector3::Transform(Vector3(radius * sinAngle, radius * cosAngle, 0.0f), rotMatrix); |
| 1430 | baseVertices.push_back(vertex); |
| 1431 | |
| 1432 | angle += PI_MUL_2 / SUBDIVISION_COUNT; |
| 1433 | } |
| 1434 | |
| 1435 | auto dir = Geometry::ConvertQuatToDirection(orient); |
| 1436 | auto topCenter = Geometry::TranslatePoint(center, dir, length); |
| 1437 | |
| 1438 | // Construct cone. |
| 1439 | for (int i = 0; i < baseVertices.size(); i++) |
| 1440 | { |
| 1441 | const auto& vertex0 = baseVertices[i]; |
| 1442 | const auto& vertex1 = baseVertices[(i == (baseVertices.size() - 1)) ? 0 : (i + 1)]; |
| 1443 | |
| 1444 | if (isWireframe) |
| 1445 | { |
| 1446 | AddDebugLine(vertex0, vertex1, color); |
| 1447 | |
| 1448 | if ((i % (SUBDIVISION_COUNT / 8)) == 0) |
| 1449 | AddDebugLine(vertex0, topCenter, color); |
| 1450 | } |
| 1451 | else |
| 1452 | { |
| 1453 | AddDebugTriangle(vertex0, vertex1, center, color); |
| 1454 | AddDebugTriangle(vertex0, vertex1, topCenter, color); |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | void Renderer::AddDebugCylinder(const Vector3& center, const Quaternion& orient, float radius, float length, const Color& color, RendererDebugPage page, bool isWireframe) |
| 1460 | { |
no test coverage detected