| 393 | } |
| 394 | |
| 395 | void Cloth::OnDebugDrawSelected() |
| 396 | { |
| 397 | #if WITH_CLOTH && COMPILE_WITH_DEBUG_DRAW |
| 398 | if (_cloth) |
| 399 | { |
| 400 | DEBUG_DRAW_WIRE_BOX(_box, Color::Violet.RGBMultiplied(0.8f), 0, true); |
| 401 | const ModelInstanceActor::MeshReference meshRef = GetMesh(); |
| 402 | if (meshRef.Actor == nullptr) |
| 403 | return; |
| 404 | MeshAccessor accessor; |
| 405 | MeshBufferType bufferTypes[1] = { MeshBufferType::Index }; |
| 406 | if (accessor.LoadMesh(meshRef.Get(), false, ToSpan(bufferTypes, 1))) |
| 407 | return; |
| 408 | auto indices = accessor.Index(); |
| 409 | auto indicesData = indices.GetData(); |
| 410 | PhysicsBackend::LockClothParticles(_cloth); |
| 411 | const Span<const Float4> particles = PhysicsBackend::GetClothParticles(_cloth); |
| 412 | const Transform transform = GetTransform(); |
| 413 | const bool indices16bit = indices.GetFormat() == PixelFormat::R16_UInt; |
| 414 | const int32 trianglesCount = indices.GetCount() / 3; |
| 415 | for (int32 triangleIndex = 0; triangleIndex < trianglesCount; triangleIndex++) |
| 416 | { |
| 417 | const int32 index = triangleIndex * 3; |
| 418 | int32 i0, i1, i2; |
| 419 | if (indices16bit) |
| 420 | { |
| 421 | i0 = indicesData.Get<uint16>()[index]; |
| 422 | i1 = indicesData.Get<uint16>()[index + 1]; |
| 423 | i2 = indicesData.Get<uint16>()[index + 2]; |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | i0 = indicesData.Get<uint32>()[index]; |
| 428 | i1 = indicesData.Get<uint32>()[index + 1]; |
| 429 | i2 = indicesData.Get<uint32>()[index + 2]; |
| 430 | } |
| 431 | const Vector3 v0 = transform.LocalToWorld(Vector3(particles[i0])); |
| 432 | const Vector3 v1 = transform.LocalToWorld(Vector3(particles[i1])); |
| 433 | const Vector3 v2 = transform.LocalToWorld(Vector3(particles[i2])); |
| 434 | Color c0 = Color::White, c1 = Color::White, c2 = Color::White; |
| 435 | if (_paint.Count() == particles.Length()) |
| 436 | { |
| 437 | c0 = Color::Lerp(Color::Red, Color::White, _paint[i0]); |
| 438 | c1 = Color::Lerp(Color::Red, Color::White, _paint[i1]); |
| 439 | c2 = Color::Lerp(Color::Red, Color::White, _paint[i2]); |
| 440 | } |
| 441 | DebugDraw::DrawLine(v0, v1, c0, c1, 0, DebugDrawDepthTest); |
| 442 | DebugDraw::DrawLine(v1, v2, c1, c2, 0, DebugDrawDepthTest); |
| 443 | DebugDraw::DrawLine(v2, v0, c2, c0, 0, DebugDrawDepthTest); |
| 444 | } |
| 445 | PhysicsBackend::UnlockClothParticles(_cloth); |
| 446 | } |
| 447 | #endif |
| 448 | |
| 449 | Actor::OnDebugDrawSelected(); |
| 450 | } |
| 451 | |
| 452 | #endif |
nothing calls this directly
no test coverage detected