Minor stuff

This commit is contained in:
Jérôme Leclercq 2021-11-30 18:18:11 +01:00
parent f289d13101
commit 8582b94c44
3 changed files with 11 additions and 10 deletions

View File

@ -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<float, 4> rot;
NewtonBodyGetRotation(m_body, rot.data());

View File

@ -29,7 +29,7 @@ namespace Nz
m_physWorld.Step(elapsedTime);
// Replicate rigid body position to their node components
auto view = registry.view<Nz::NodeComponent, const RigidBody3DComponent>();
auto view = registry.view<NodeComponent, const RigidBody3DComponent>();
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<NodeComponent>(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<NodeComponent>(entity);
if (node)
{
RigidBody3DComponent& rigidBody = registry.get<RigidBody3DComponent>(entity);

View File

@ -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));
}