From 8582b94c4407e0e235de8b6fe57735cc6feb1b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 30 Nov 2021 18:18:11 +0100 Subject: [PATCH] Minor stuff --- src/Nazara/Physics3D/RigidBody3D.cpp | 13 ++++++------- src/Nazara/Physics3D/Systems/Physics3DSystem.cpp | 6 +++--- src/Nazara/Widgets/Canvas.cpp | 2 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index 671e195a7..e94b40171 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -76,8 +76,7 @@ namespace Nz RigidBody3D::~RigidBody3D() { - if (m_body) - NewtonDestroyBody(m_body); + Destroy(); } void RigidBody3D::AddForce(const Vector3f& force, CoordSys coordSys) @@ -93,7 +92,7 @@ namespace Nz break; } - // On réveille le corps pour que le callback soit appelé et que les forces soient appliquées + // In case the body was sleeping, wake it up (force callback won't be called otherwise) NewtonBodySetSleepState(m_body, 0); } @@ -113,7 +112,7 @@ namespace Nz } } - // On réveille le corps pour que le callback soit appelé et que les forces soient appliquées + // In case the body was sleeping, wake it up (force callback won't be called otherwise) NewtonBodySetSleepState(m_body, 0); } @@ -131,7 +130,7 @@ namespace Nz break; } - // On réveille le corps pour que le callback soit appelé et que les forces soient appliquées + // In case the body was sleeping, wake it up (force callback won't be called otherwise) NewtonBodySetSleepState(m_body, 0); } @@ -217,7 +216,7 @@ namespace Nz } case CoordSys::Local: - break; // Aucune opération à effectuer sur le centre de rotation + break; } return center; @@ -246,7 +245,7 @@ namespace Nz Quaternionf RigidBody3D::GetRotation() const { - // NewtonBodyGetRotation output X, Y, Z, W and Nz::Quaternion stores W, X, Y, Z so we use a temporary array + // NewtonBodyGetRotation output X, Y, Z, W and Nz::Quaternion stores W, X, Y, Z so we use a temporary array to fix the order std::array rot; NewtonBodyGetRotation(m_body, rot.data()); diff --git a/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp b/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp index 26fe23380..895820d3c 100644 --- a/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp +++ b/src/Nazara/Physics3D/Systems/Physics3DSystem.cpp @@ -29,7 +29,7 @@ namespace Nz m_physWorld.Step(elapsedTime); // Replicate rigid body position to their node components - auto view = registry.view(); + auto view = registry.view(); for (auto [entity, nodeComponent, rigidBodyComponent] : view.each()) { if (rigidBodyComponent.IsSleeping()) @@ -42,8 +42,8 @@ namespace Nz void Physics3DSystem::OnConstruct(entt::registry& registry, entt::entity entity) { - // If our entity already has a node component when adding a rigid body, initialize it with - Nz::NodeComponent* node = registry.try_get(entity); + // If our entity already has a node component when adding a rigid body, initialize it with its position/rotation + NodeComponent* node = registry.try_get(entity); if (node) { RigidBody3DComponent& rigidBody = registry.get(entity); diff --git a/src/Nazara/Widgets/Canvas.cpp b/src/Nazara/Widgets/Canvas.cpp index 39a38b78c..1458c74dc 100644 --- a/src/Nazara/Widgets/Canvas.cpp +++ b/src/Nazara/Widgets/Canvas.cpp @@ -309,6 +309,7 @@ namespace Nz m_hoveredWidget = bestEntry; m_widgetEntries[m_hoveredWidget].widget->OnMouseEnter(); + // Only allow cursor update when not owning mouse if (m_cursorController && m_mouseOwner == InvalidCanvasIndex) m_cursorController->UpdateCursor(Cursor::Get(m_widgetEntries[m_hoveredWidget].cursor)); } @@ -318,6 +319,7 @@ namespace Nz m_widgetEntries[m_hoveredWidget].widget->OnMouseExit(); m_hoveredWidget = InvalidCanvasIndex; + // Only allow cursor update when not owning mouse if (m_cursorController && m_mouseOwner == InvalidCanvasIndex) m_cursorController->UpdateCursor(Cursor::Get(SystemCursor::Default)); }