MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnDebugDrawSelected

Method OnDebugDrawSelected

Source/Engine/Physics/Actors/WheeledVehicle.cpp:402–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402void WheeledVehicle::OnDebugDrawSelected()
403{
404 // Wheels shapes
405 int32 wheelIndex = 0;
406 for (const auto& wheel : _wheels)
407 {
408 if (wheel.Collider && wheel.Collider->GetParent() == this && !wheel.Collider->GetIsTrigger())
409 {
410 WheelData data = { wheel.Collider, wheel.Collider->GetLocalOrientation() };
411 for (auto& e : _wheelsData)
412 {
413 if (e.Collider == data.Collider)
414 {
415 data = e;
416 break;
417 }
418 }
419 const Vector3 currentPos = wheel.Collider->GetPosition();
420 const Vector3 basePos = currentPos - Vector3(0, data.State.SuspensionOffset, 0);
421 const Quaternion wheelDebugOrientation = GetOrientation() * Quaternion::Euler(-data.State.RotationAngle, data.State.SteerAngle, 0) * Quaternion::Euler(90, 0, 90);
422 Transform actorPose = GetTransform(), shapePose = wheel.Collider->GetLocalTransform();
423 actorPose.Scale = Float3::One;
424 if (_actor)
425 PhysicsBackend::GetRigidActorPose(_actor, actorPose.Translation, actorPose.Orientation);
426 if (wheel.Collider->GetPhysicsShape())
427 PhysicsBackend::GetShapeLocalPose(wheel.Collider->GetPhysicsShape(), shapePose.Translation, shapePose.Orientation);
428 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(basePos, wheel.Radius * 0.07f), Color::Blue * 0.3f, 0, false);
429 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(currentPos, wheel.Radius * 0.08f), Color::Blue * 0.8f, 0, false);
430 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(actorPose.LocalToWorld(shapePose.Translation), wheel.Radius * 0.11f), Color::OrangeRed * 0.8f, 0, false);
431 DEBUG_DRAW_LINE(basePos, currentPos, Color::Blue, 0, false);
432 DEBUG_DRAW_WIRE_CYLINDER(currentPos, wheelDebugOrientation, wheel.Radius, wheel.Width, Color::Red * 0.4f, 0, false);
433 if (!data.State.SuspensionTraceStart.IsZero())
434 {
435 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(data.State.SuspensionTraceStart, 5.0f), Color::AliceBlue, 0, false);
436 DEBUG_DRAW_LINE(data.State.SuspensionTraceStart, data.State.SuspensionTraceEnd, data.State.IsInAir ? Color::Red : Color::Green, 0, false);
437 }
438 if (!data.State.IsInAir)
439 {
440 DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(data.State.TireContactPoint, 5.0f), Color::Green, 0, false);
441 }
442 if (ShowDebugDrawWheelNames)
443 {
444 const String text = String::Format(TEXT("Index: {}\nCollider: {}"), wheelIndex, wheel.Collider->GetName());
445 DEBUG_DRAW_TEXT(text, currentPos, Color::Blue, 10, 0);
446 }
447 }
448 wheelIndex++;
449 }
450
451 // Anti roll bars axes
452 const int32 wheelsCount = _wheels.Count();
453 for (int32 i = 0; i < _antiRollBars.Count(); i++)
454 {
455 const int32 axleIndex = _antiRollBars[i].Axle;
456 const int32 leftWheelIndex = axleIndex * 2;
457 const int32 rightWheelIndex = leftWheelIndex + 1;
458 if (leftWheelIndex >= wheelsCount || rightWheelIndex >= wheelsCount)
459 continue;

Callers

nothing calls this directly

Calls 12

GetOrientationFunction · 0.85
OnDebugDrawSelectedFunction · 0.85
GetPhysicsShapeMethod · 0.80
Vector3Class · 0.50
BoundingSphereClass · 0.50
FormatFunction · 0.50
GetParentMethod · 0.45
GetPositionMethod · 0.45
LocalToWorldMethod · 0.45
IsZeroMethod · 0.45
GetNameMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected