Minor stuff
This commit is contained in:
parent
f289d13101
commit
8582b94c44
|
|
@ -76,8 +76,7 @@ namespace Nz
|
||||||
|
|
||||||
RigidBody3D::~RigidBody3D()
|
RigidBody3D::~RigidBody3D()
|
||||||
{
|
{
|
||||||
if (m_body)
|
Destroy();
|
||||||
NewtonDestroyBody(m_body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody3D::AddForce(const Vector3f& force, CoordSys coordSys)
|
void RigidBody3D::AddForce(const Vector3f& force, CoordSys coordSys)
|
||||||
|
|
@ -93,7 +92,7 @@ namespace Nz
|
||||||
break;
|
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);
|
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);
|
NewtonBodySetSleepState(m_body, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +130,7 @@ namespace Nz
|
||||||
break;
|
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);
|
NewtonBodySetSleepState(m_body, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,7 +216,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
case CoordSys::Local:
|
case CoordSys::Local:
|
||||||
break; // Aucune opération à effectuer sur le centre de rotation
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return center;
|
return center;
|
||||||
|
|
@ -246,7 +245,7 @@ namespace Nz
|
||||||
|
|
||||||
Quaternionf RigidBody3D::GetRotation() const
|
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;
|
std::array<float, 4> rot;
|
||||||
NewtonBodyGetRotation(m_body, rot.data());
|
NewtonBodyGetRotation(m_body, rot.data());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Nz
|
||||||
m_physWorld.Step(elapsedTime);
|
m_physWorld.Step(elapsedTime);
|
||||||
|
|
||||||
// Replicate rigid body position to their node components
|
// 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())
|
for (auto [entity, nodeComponent, rigidBodyComponent] : view.each())
|
||||||
{
|
{
|
||||||
if (rigidBodyComponent.IsSleeping())
|
if (rigidBodyComponent.IsSleeping())
|
||||||
|
|
@ -42,8 +42,8 @@ namespace Nz
|
||||||
|
|
||||||
void Physics3DSystem::OnConstruct(entt::registry& registry, entt::entity entity)
|
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
|
// If our entity already has a node component when adding a rigid body, initialize it with its position/rotation
|
||||||
Nz::NodeComponent* node = registry.try_get<NodeComponent>(entity);
|
NodeComponent* node = registry.try_get<NodeComponent>(entity);
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
RigidBody3DComponent& rigidBody = registry.get<RigidBody3DComponent>(entity);
|
RigidBody3DComponent& rigidBody = registry.get<RigidBody3DComponent>(entity);
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,7 @@ namespace Nz
|
||||||
m_hoveredWidget = bestEntry;
|
m_hoveredWidget = bestEntry;
|
||||||
m_widgetEntries[m_hoveredWidget].widget->OnMouseEnter();
|
m_widgetEntries[m_hoveredWidget].widget->OnMouseEnter();
|
||||||
|
|
||||||
|
// Only allow cursor update when not owning mouse
|
||||||
if (m_cursorController && m_mouseOwner == InvalidCanvasIndex)
|
if (m_cursorController && m_mouseOwner == InvalidCanvasIndex)
|
||||||
m_cursorController->UpdateCursor(Cursor::Get(m_widgetEntries[m_hoveredWidget].cursor));
|
m_cursorController->UpdateCursor(Cursor::Get(m_widgetEntries[m_hoveredWidget].cursor));
|
||||||
}
|
}
|
||||||
|
|
@ -318,6 +319,7 @@ namespace Nz
|
||||||
m_widgetEntries[m_hoveredWidget].widget->OnMouseExit();
|
m_widgetEntries[m_hoveredWidget].widget->OnMouseExit();
|
||||||
m_hoveredWidget = InvalidCanvasIndex;
|
m_hoveredWidget = InvalidCanvasIndex;
|
||||||
|
|
||||||
|
// Only allow cursor update when not owning mouse
|
||||||
if (m_cursorController && m_mouseOwner == InvalidCanvasIndex)
|
if (m_cursorController && m_mouseOwner == InvalidCanvasIndex)
|
||||||
m_cursorController->UpdateCursor(Cursor::Get(SystemCursor::Default));
|
m_cursorController->UpdateCursor(Cursor::Get(SystemCursor::Default));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue