| 342 | #if USE_EDITOR |
| 343 | |
| 344 | void Cloth::DrawPhysicsDebug(RenderView& view) |
| 345 | { |
| 346 | #if WITH_CLOTH && COMPILE_WITH_DEBUG_DRAW |
| 347 | if (_cloth) |
| 348 | { |
| 349 | PROFILE_CPU(); |
| 350 | const ModelInstanceActor::MeshReference meshRef = GetMesh(); |
| 351 | if (meshRef.Actor == nullptr) |
| 352 | return; |
| 353 | MeshAccessor accessor; |
| 354 | MeshBufferType bufferTypes[1] = { MeshBufferType::Index }; |
| 355 | if (accessor.LoadMesh(meshRef.Get(), false, ToSpan(bufferTypes, 1))) |
| 356 | return; |
| 357 | auto indices = accessor.Index(); |
| 358 | auto indicesData = indices.GetData(); |
| 359 | PhysicsBackend::LockClothParticles(_cloth); |
| 360 | const Span<const Float4> particles = PhysicsBackend::GetClothParticles(_cloth); |
| 361 | const Transform transform = GetTransform(); |
| 362 | const bool indices16bit = indices.GetFormat() == PixelFormat::R16_UInt; |
| 363 | const int32 trianglesCount = indices.GetCount() / 3; |
| 364 | for (int32 triangleIndex = 0; triangleIndex < trianglesCount; triangleIndex++) |
| 365 | { |
| 366 | const int32 index = triangleIndex * 3; |
| 367 | int32 i0, i1, i2; |
| 368 | if (indices16bit) |
| 369 | { |
| 370 | i0 = indicesData.Get<uint16>()[index]; |
| 371 | i1 = indicesData.Get<uint16>()[index + 1]; |
| 372 | i2 = indicesData.Get<uint16>()[index + 2]; |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | i0 = indicesData.Get<uint32>()[index]; |
| 377 | i1 = indicesData.Get<uint32>()[index + 1]; |
| 378 | i2 = indicesData.Get<uint32>()[index + 2]; |
| 379 | } |
| 380 | if (_paint.Count() == particles.Length()) |
| 381 | { |
| 382 | if (Math::Max(_paint[i0], _paint[i1], _paint[i2]) < ZeroTolerance) |
| 383 | continue; |
| 384 | } |
| 385 | const Vector3 v0 = transform.LocalToWorld(Vector3(particles[i0])); |
| 386 | const Vector3 v1 = transform.LocalToWorld(Vector3(particles[i1])); |
| 387 | const Vector3 v2 = transform.LocalToWorld(Vector3(particles[i2])); |
| 388 | DEBUG_DRAW_TRIANGLE(v0, v1, v2, Color::Pink, 0, true); |
| 389 | } |
| 390 | PhysicsBackend::UnlockClothParticles(_cloth); |
| 391 | } |
| 392 | #endif |
| 393 | } |
| 394 | |
| 395 | void Cloth::OnDebugDrawSelected() |
| 396 | { |
nothing calls this directly
no test coverage detected