Core/Node: Refactor interface
- Removed overloads taking multiple scalars - Removed CoordSys parameter (functions exists in two sets, local and global)
This commit is contained in:
committed by
Jérôme Leclercq
parent
194dba5002
commit
63c526cecc
@@ -97,9 +97,9 @@ namespace Nz
|
||||
const SequenceJoint& sequenceJointB = m_impl->sequenceJoints[frameB*m_impl->jointCount + i];
|
||||
|
||||
Joint& joint = joints[i];
|
||||
joint.SetPosition(Vector3f::Lerp(sequenceJointA.position, sequenceJointB.position, interpolation), CoordSys::Local, Node::Invalidation::DontInvalidate);
|
||||
joint.SetRotation(Quaternionf::Slerp(sequenceJointA.rotation, sequenceJointB.rotation, interpolation), CoordSys::Local, Node::Invalidation::DontInvalidate);
|
||||
joint.SetScale(Vector3f::Lerp(sequenceJointA.scale, sequenceJointB.scale, interpolation), CoordSys::Local, Node::Invalidation::DontInvalidate);
|
||||
joint.SetPosition(Vector3f::Lerp(sequenceJointA.position, sequenceJointB.position, interpolation), Node::Invalidation::DontInvalidate);
|
||||
joint.SetRotation(Quaternionf::Slerp(sequenceJointA.rotation, sequenceJointB.rotation, interpolation), Node::Invalidation::DontInvalidate);
|
||||
joint.SetScale(Vector3f::Lerp(sequenceJointA.scale, sequenceJointB.scale, interpolation), Node::Invalidation::DontInvalidate);
|
||||
}
|
||||
|
||||
targetSkeleton->GetRootJoint()->Invalidate();
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Nz
|
||||
Joint* attachedJoints = m_attachedSkeleton.GetJoints();
|
||||
|
||||
for (std::size_t i = 0; i < jointCount; ++i)
|
||||
attachedJoints[i].SetTransform(referenceJoints[i].GetPosition(), referenceJoints[i].GetRotation(), referenceJoints[i].GetScale(), CoordSys::Local, Node::Invalidation::DontInvalidate);
|
||||
attachedJoints[i].SetTransform(referenceJoints[i].GetPosition(), referenceJoints[i].GetRotation(), referenceJoints[i].GetScale(), Node::Invalidation::DontInvalidate);
|
||||
|
||||
m_attachedSkeleton.GetRootJoint()->Invalidate();
|
||||
|
||||
|
||||
@@ -23,83 +23,6 @@ namespace Nz
|
||||
m_parent->RemoveChild(this);
|
||||
}
|
||||
|
||||
Node& Node::Interpolate(const Node& nodeA, const Node& nodeB, float interpolation, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
nodeA.EnsureDerivedUpdate();
|
||||
nodeB.EnsureDerivedUpdate();
|
||||
|
||||
m_position = ToLocalPosition(Vector3f::Lerp(nodeA.m_derivedPosition, nodeB.m_derivedPosition, interpolation));
|
||||
m_rotation = ToLocalRotation(Quaternionf::Slerp(nodeA.m_derivedRotation, nodeB.m_derivedRotation, interpolation));
|
||||
m_scale = ToLocalScale(Vector3f::Lerp(nodeA.m_derivedScale, nodeB.m_derivedScale, interpolation));
|
||||
break;
|
||||
|
||||
case CoordSys::Local:
|
||||
m_position = Vector3f::Lerp(nodeA.m_position, nodeB.m_position, interpolation);
|
||||
m_rotation = Quaternionf::Slerp(nodeA.m_rotation, nodeB.m_rotation, interpolation);
|
||||
m_scale = Vector3f::Lerp(nodeA.m_scale, nodeB.m_scale, interpolation);
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Node& Node::Move(const Vector3f& movement, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
{
|
||||
if (m_parent)
|
||||
{
|
||||
m_parent->EnsureDerivedUpdate();
|
||||
|
||||
m_position += (m_parent->m_derivedRotation.GetConjugate()*(movement - m_parent->m_derivedPosition))/m_parent->m_derivedScale; // Compensation
|
||||
}
|
||||
else
|
||||
m_position += movement; // Rien n'affecte le node
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CoordSys::Local:
|
||||
m_position += m_rotation * movement;
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Node& Node::Rotate(const Quaternionf& rotation, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
{
|
||||
EnsureDerivedUpdate();
|
||||
|
||||
m_rotation *= m_derivedRotation.GetInverse() * rotation * m_derivedRotation; ///FIXME: Correct ?
|
||||
break;
|
||||
}
|
||||
|
||||
case CoordSys::Local:
|
||||
m_rotation *= rotation;
|
||||
break;
|
||||
}
|
||||
|
||||
m_rotation.Normalize();
|
||||
|
||||
Invalidate(invalidation);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Node::SetParent(const Node* node, bool keepDerived, Invalidation invalidation)
|
||||
{
|
||||
#if NAZARA_CORE_SAFE
|
||||
@@ -122,7 +45,7 @@ namespace Nz
|
||||
|
||||
if (keepDerived)
|
||||
{
|
||||
EnsureDerivedUpdate();
|
||||
EnsureGlobalsUpdate();
|
||||
|
||||
if (m_parent)
|
||||
m_parent->RemoveChild(this);
|
||||
@@ -131,9 +54,9 @@ namespace Nz
|
||||
if (m_parent)
|
||||
m_parent->AddChild(this);
|
||||
|
||||
SetRotation(m_derivedRotation, CoordSys::Global, Invalidation::DontInvalidate);
|
||||
SetScale(m_derivedScale, CoordSys::Global, Invalidation::DontInvalidate);
|
||||
SetPosition(m_derivedPosition, CoordSys::Global, Invalidation::DontInvalidate);
|
||||
SetGlobalPosition(m_globalPosition, Invalidation::DontInvalidate);
|
||||
SetGlobalRotation(m_globalRotation, Invalidation::DontInvalidate);
|
||||
SetGlobalScale(m_globalScale, Invalidation::DontInvalidate);
|
||||
|
||||
Invalidate(invalidation);
|
||||
}
|
||||
@@ -152,157 +75,6 @@ namespace Nz
|
||||
OnParenting(node);
|
||||
}
|
||||
|
||||
void Node::SetPosition(const Vector3f& position, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
{
|
||||
if (m_parent && m_inheritPosition)
|
||||
{
|
||||
m_parent->EnsureDerivedUpdate();
|
||||
|
||||
m_position = (m_parent->m_derivedRotation.GetConjugate() * (position - m_parent->m_derivedPosition)) / m_parent->m_derivedScale - m_initialPosition;
|
||||
}
|
||||
else
|
||||
m_position = position - m_initialPosition;
|
||||
break;
|
||||
}
|
||||
|
||||
case CoordSys::Local:
|
||||
m_position = position;
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
}
|
||||
|
||||
void Node::SetRotation(const Quaternionf& rotation, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
if (m_parent && m_inheritRotation)
|
||||
{
|
||||
Quaternionf rot(m_parent->GetRotation() * m_initialRotation);
|
||||
|
||||
m_rotation = rot.GetConjugate() * rotation;
|
||||
}
|
||||
else
|
||||
m_rotation = rotation;
|
||||
|
||||
break;
|
||||
|
||||
case CoordSys::Local:
|
||||
m_rotation = rotation;
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
}
|
||||
|
||||
void Node::SetScale(const Vector3f& scale, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
if (m_parent && m_inheritScale)
|
||||
m_scale = scale / (m_initialScale * m_parent->GetScale());
|
||||
else
|
||||
m_scale = scale / m_initialScale;
|
||||
break;
|
||||
|
||||
case CoordSys::Local:
|
||||
m_scale = scale;
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
}
|
||||
|
||||
void Node::SetTransform(const Vector3f& position, const Quaternionf& rotation, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
{
|
||||
// Position
|
||||
if (m_parent && m_inheritPosition)
|
||||
{
|
||||
m_parent->EnsureDerivedUpdate();
|
||||
|
||||
m_position = (m_parent->m_derivedRotation.GetConjugate() * (position - m_parent->m_derivedPosition)) / m_parent->m_derivedScale - m_initialPosition;
|
||||
}
|
||||
else
|
||||
m_position = position - m_initialPosition;
|
||||
|
||||
// Rotation
|
||||
if (m_parent && m_inheritRotation)
|
||||
{
|
||||
Quaternionf rot(m_parent->GetRotation() * m_initialRotation);
|
||||
|
||||
m_rotation = rot.GetConjugate() * rotation;
|
||||
}
|
||||
else
|
||||
m_rotation = rotation;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CoordSys::Local:
|
||||
m_position = position;
|
||||
m_rotation = rotation;
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
}
|
||||
|
||||
void Node::SetTransform(const Vector3f& position, const Quaternionf& rotation, const Vector3f& scale, CoordSys coordSys, Invalidation invalidation)
|
||||
{
|
||||
switch (coordSys)
|
||||
{
|
||||
case CoordSys::Global:
|
||||
{
|
||||
// Position
|
||||
if (m_parent && m_inheritPosition)
|
||||
{
|
||||
m_parent->EnsureDerivedUpdate();
|
||||
|
||||
m_position = (m_parent->m_derivedRotation.GetConjugate() * (position - m_parent->m_derivedPosition)) / m_parent->m_derivedScale - m_initialPosition;
|
||||
}
|
||||
else
|
||||
m_position = position - m_initialPosition;
|
||||
|
||||
// Rotation
|
||||
if (m_parent && m_inheritRotation)
|
||||
{
|
||||
Quaternionf rot(m_parent->GetRotation() * m_initialRotation);
|
||||
|
||||
m_rotation = rot.GetConjugate() * rotation;
|
||||
}
|
||||
else
|
||||
m_rotation = rotation;
|
||||
|
||||
// Scale
|
||||
if (m_parent && m_inheritScale)
|
||||
m_scale = scale / (m_initialScale * m_parent->GetScale());
|
||||
else
|
||||
m_scale = scale / m_initialScale;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CoordSys::Local:
|
||||
m_position = position;
|
||||
m_rotation = rotation;
|
||||
m_scale = scale;
|
||||
break;
|
||||
}
|
||||
|
||||
Invalidate(invalidation);
|
||||
}
|
||||
|
||||
void Node::InvalidateNode(Invalidation invalidation)
|
||||
{
|
||||
m_derivedUpdated = false;
|
||||
@@ -326,34 +98,34 @@ namespace Nz
|
||||
{
|
||||
if (m_parent)
|
||||
{
|
||||
m_parent->EnsureDerivedUpdate();
|
||||
m_parent->EnsureGlobalsUpdate();
|
||||
|
||||
if (m_inheritPosition)
|
||||
m_derivedPosition = m_parent->m_derivedRotation*(m_parent->m_derivedScale * (m_initialPosition + m_position)) + m_parent->m_derivedPosition;
|
||||
if (m_doesInheritPosition)
|
||||
m_globalPosition = m_parent->m_globalRotation*(m_parent->m_globalScale * (m_initialPosition + m_position)) + m_parent->m_globalPosition;
|
||||
else
|
||||
m_derivedPosition = m_initialPosition + m_position;
|
||||
m_globalPosition = m_initialPosition + m_position;
|
||||
|
||||
if (m_inheritRotation)
|
||||
if (m_doesInheritRotation)
|
||||
{
|
||||
Quaternionf rotation = m_initialRotation * m_rotation;
|
||||
if (m_inheritScale)
|
||||
rotation = Quaternionf::Mirror(rotation, m_parent->m_derivedScale);
|
||||
if (m_doesInheritScale)
|
||||
rotation = Quaternionf::Mirror(rotation, m_parent->m_globalScale);
|
||||
|
||||
m_derivedRotation = m_parent->m_derivedRotation * rotation;
|
||||
m_derivedRotation.Normalize();
|
||||
m_globalRotation = m_parent->m_globalRotation * rotation;
|
||||
m_globalRotation.Normalize();
|
||||
}
|
||||
else
|
||||
m_derivedRotation = m_initialRotation * m_rotation;
|
||||
m_globalRotation = m_initialRotation * m_rotation;
|
||||
|
||||
m_derivedScale = m_initialScale * m_scale;
|
||||
if (m_inheritScale)
|
||||
m_derivedScale *= m_parent->m_derivedScale;
|
||||
m_globalScale = m_initialScale * m_scale;
|
||||
if (m_doesInheritScale)
|
||||
m_globalScale *= m_parent->m_globalScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_derivedPosition = m_initialPosition + m_position;
|
||||
m_derivedRotation = m_initialRotation * m_rotation;
|
||||
m_derivedScale = m_initialScale * m_scale;
|
||||
m_globalPosition = m_initialPosition + m_position;
|
||||
m_globalRotation = m_initialRotation * m_rotation;
|
||||
m_globalScale = m_initialScale * m_scale;
|
||||
}
|
||||
|
||||
m_derivedUpdated = true;
|
||||
@@ -361,9 +133,9 @@ namespace Nz
|
||||
|
||||
void Node::UpdateTransformMatrix() const
|
||||
{
|
||||
EnsureDerivedUpdate();
|
||||
EnsureGlobalsUpdate();
|
||||
|
||||
m_transformMatrix = Matrix4f::Transform(m_derivedPosition, m_derivedRotation, m_derivedScale);
|
||||
m_transformMatrix = Matrix4f::Transform(m_globalPosition, m_globalRotation, m_globalScale);
|
||||
m_transformMatrixUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +173,9 @@ namespace Nz
|
||||
const Joint* jointsA = &skeletonA.m_impl->joints[0];
|
||||
const Joint* jointsB = &skeletonB.m_impl->joints[0];
|
||||
for (std::size_t i = 0; i < m_impl->joints.size(); ++i)
|
||||
m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation, CoordSys::Local);
|
||||
m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation, Node::Invalidation::DontInvalidate);
|
||||
|
||||
GetRootJoint()->Invalidate();
|
||||
InvalidateJoints();
|
||||
}
|
||||
|
||||
@@ -192,9 +193,10 @@ namespace Nz
|
||||
std::size_t index = indices[i];
|
||||
NazaraAssert(index < m_impl->joints.size(), "joint index out of range");
|
||||
|
||||
m_impl->joints[index].Interpolate(jointsA[index], jointsB[index], interpolation, CoordSys::Local);
|
||||
m_impl->joints[index].Interpolate(jointsA[index], jointsB[index], interpolation, Node::Invalidation::DontInvalidate);
|
||||
}
|
||||
|
||||
GetRootJoint()->Invalidate();
|
||||
InvalidateJoints();
|
||||
}
|
||||
|
||||
|
||||
@@ -291,11 +291,11 @@ namespace Nz
|
||||
const NodeComponent& entityNode = m_registry.get<const NodeComponent>(entity);
|
||||
CameraComponent& entityCamera = m_registry.get<CameraComponent>(entity);
|
||||
|
||||
Vector3f cameraPosition = entityNode.GetPosition(CoordSys::Global);
|
||||
Vector3f cameraPosition = entityNode.GetGlobalPosition();
|
||||
|
||||
ViewerInstance& viewerInstance = entityCamera.GetViewerInstance();
|
||||
viewerInstance.UpdateEyePosition(cameraPosition);
|
||||
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(cameraPosition, entityNode.GetRotation(CoordSys::Global)));
|
||||
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(cameraPosition, entityNode.GetGlobalRotation()));
|
||||
}
|
||||
m_invalidatedCameraNode.clear();
|
||||
|
||||
@@ -318,9 +318,9 @@ namespace Nz
|
||||
const NodeComponent& entityNode = m_registry.get<const NodeComponent>(entity);
|
||||
LightComponent& entityLight = m_registry.get<LightComponent>(entity);
|
||||
|
||||
const Vector3f& position = entityNode.GetPosition(CoordSys::Global);
|
||||
const Quaternionf& rotation = entityNode.GetRotation(CoordSys::Global);
|
||||
const Vector3f& scale = entityNode.GetScale(CoordSys::Global);
|
||||
const Vector3f& position = entityNode.GetGlobalPosition();
|
||||
const Quaternionf& rotation = entityNode.GetGlobalRotation();
|
||||
const Vector3f& scale = entityNode.GetGlobalScale();
|
||||
|
||||
for (const auto& lightEntry : entityLight.GetLights())
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Nz
|
||||
const Joint* joint = skeleton.GetJoint(i);
|
||||
const Node* parent = joint->GetParent();
|
||||
if (parent)
|
||||
DrawLine(joint->GetPosition(CoordSys::Global), parent->GetPosition(CoordSys::Global), color);
|
||||
DrawLine(joint->GetGlobalPosition(), parent->GetGlobalPosition(), color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Nz
|
||||
gfxComponent.AttachRenderable(m_textSprite, GetCanvas()->GetRenderMask());
|
||||
|
||||
auto& textNode = registry.get<NodeComponent>(m_textEntity);
|
||||
textNode.SetPosition(s_textAreaPaddingWidth, GetHeight() - s_textAreaPaddingHeight);
|
||||
textNode.SetPosition({ s_textAreaPaddingWidth, GetHeight() - s_textAreaPaddingHeight });
|
||||
|
||||
SetCursor(SystemCursor::Text);
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Nz
|
||||
const AbstractTextDrawer& textDrawer = GetTextDrawer();
|
||||
|
||||
auto& textNode = GetRegistry().get<NodeComponent>(m_textEntity);
|
||||
Vector2f textPosition = Vector2f(textNode.GetPosition(CoordSys::Local));
|
||||
Vector2f textPosition = Vector2f(textNode.GetPosition());
|
||||
x -= textPosition.x;
|
||||
y -= textPosition.y;
|
||||
|
||||
@@ -627,19 +627,19 @@ namespace Nz
|
||||
float glyphWidth = (lastGlyph) ? lastGlyph->bounds.width : 0.f;
|
||||
|
||||
auto& textNode = registry.get<NodeComponent>(m_textEntity);
|
||||
float textPosition = textNode.GetPosition(CoordSys::Local).x - s_textAreaPaddingWidth;
|
||||
float textPosition = textNode.GetPosition().x - s_textAreaPaddingWidth;
|
||||
float cursorPosition = glyphPos + textPosition + ((overshooting) ? glyphWidth : 0.f);
|
||||
float width = GetWidth();
|
||||
|
||||
if (width <= textDrawer.GetBounds().width)
|
||||
{
|
||||
if (cursorPosition + glyphWidth > width)
|
||||
textNode.Move(width - cursorPosition - glyphWidth - s_textAreaPaddingWidth, 0.f);
|
||||
textNode.Move({ width - cursorPosition - glyphWidth - s_textAreaPaddingWidth, 0.f });
|
||||
else if (cursorPosition - glyphWidth < 0.f)
|
||||
textNode.Move(-cursorPosition + glyphWidth - s_textAreaPaddingWidth, 0.f);
|
||||
textNode.Move({ -cursorPosition + glyphWidth - s_textAreaPaddingWidth, 0.f });
|
||||
}
|
||||
else
|
||||
textNode.Move(-textPosition, 0.f); //< Reset text position if we have enough room to show everything
|
||||
textNode.Move({ -textPosition, 0.f }); //< Reset text position if we have enough room to show everything
|
||||
|
||||
// Create/destroy cursor entities and sprites
|
||||
std::size_t selectionLineCount = m_cursorPositionEnd.y - m_cursorPositionBegin.y + 1;
|
||||
@@ -697,14 +697,14 @@ namespace Nz
|
||||
|
||||
cursor.sprite->SetSize(Vector2f(spriteSize, lineInfo.bounds.height));
|
||||
|
||||
registry.get<NodeComponent>(cursor.entity).SetPosition(beginX, textHeight - lineInfo.bounds.y - lineInfo.bounds.height);
|
||||
registry.get<NodeComponent>(cursor.entity).SetPosition({ beginX, textHeight - lineInfo.bounds.y - lineInfo.bounds.height });
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full line selection
|
||||
cursor.sprite->SetSize(Vector2f(lineInfo.bounds.width, lineInfo.bounds.height));
|
||||
|
||||
registry.get<NodeComponent>(cursor.entity).SetPosition(0.f, textHeight - lineInfo.bounds.y - lineInfo.bounds.height);
|
||||
registry.get<NodeComponent>(cursor.entity).SetPosition({ 0.f, textHeight - lineInfo.bounds.y - lineInfo.bounds.height });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -724,6 +724,6 @@ namespace Nz
|
||||
Vector2f textSize = Vector2f(m_textSprite->GetAABB().GetLengths());
|
||||
|
||||
auto& textNode = GetRegistry().get<NodeComponent>(m_textEntity);
|
||||
textNode.SetPosition(s_textAreaPaddingWidth, GetHeight() - s_textAreaPaddingHeight - textSize.y);
|
||||
textNode.SetPosition({ s_textAreaPaddingWidth, GetHeight() - s_textAreaPaddingHeight - textSize.y });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace Nz
|
||||
|
||||
Rectf BaseWidget::GetScissorRect() const
|
||||
{
|
||||
Vector2f widgetPos = Vector2f(GetPosition(CoordSys::Global));
|
||||
Vector2f widgetPos = Vector2f(GetGlobalPosition());
|
||||
Vector2f widgetSize = GetSize();
|
||||
|
||||
Rectf widgetRect(widgetPos.x, widgetPos.y, widgetSize.x, widgetSize.y);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Nz
|
||||
{
|
||||
float contentPosition = (GetHeight() - m_content->GetHeight()) * (1.f - newValue);
|
||||
|
||||
m_content->SetPosition(0.f, contentPosition);
|
||||
m_content->SetPosition({ 0.f, contentPosition });
|
||||
m_content->SetRenderingRect(Nz::Rectf(-std::numeric_limits<float>::infinity(), -contentPosition, std::numeric_limits<float>::infinity(), GetHeight()));
|
||||
});
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Nz
|
||||
if (m_isScrollbarEnabled)
|
||||
m_horizontalScrollbar->Show();
|
||||
|
||||
m_horizontalScrollbar->SetPosition(contentSize.x, 0.f);
|
||||
m_horizontalScrollbar->SetPosition({ contentSize.x, 0.f, 0.f });
|
||||
m_horizontalScrollbar->Resize({ scrollBarWidth, GetHeight() });
|
||||
|
||||
ScrollToRatio(m_horizontalScrollbar->GetValue());
|
||||
|
||||
@@ -108,19 +108,19 @@ namespace Nz
|
||||
{
|
||||
m_scrollBackButton->Resize({ size.y, size.y });
|
||||
m_scrollNextButton->Resize({ size.y, size.y });
|
||||
m_scrollNextButton->SetPosition({ GetWidth() - m_scrollNextButton->GetWidth(), 0.f, 0.f });
|
||||
m_scrollNextButton->SetPosition({ GetWidth() - m_scrollNextButton->GetWidth(), 0.f });
|
||||
|
||||
float start = m_scrollBackButton->GetWidth();
|
||||
float remaining = size.x - start - m_scrollNextButton->GetWidth();
|
||||
float centerPosition = start + invValuePct * (remaining - remaining * stepPct);
|
||||
|
||||
m_scrollCenterButton->Resize({ remaining * stepPct, size.y });
|
||||
m_scrollCenterButton->SetPosition(start + centerPosition, 0.f);
|
||||
m_scrollCenterButton->SetPosition({ start + centerPosition, 0.f });
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scrollBackButton->Resize({ size.x, size.x });
|
||||
m_scrollBackButton->SetPosition({ 0.f, GetHeight() - m_scrollBackButton->GetHeight(), 0.f });
|
||||
m_scrollBackButton->SetPosition({ 0.f, GetHeight() - m_scrollBackButton->GetHeight() });
|
||||
m_scrollNextButton->Resize({ size.x, size.x });
|
||||
|
||||
float start = m_scrollBackButton->GetHeight();
|
||||
@@ -128,7 +128,7 @@ namespace Nz
|
||||
float centerPosition = start + invValuePct * (remaining - remaining * stepPct);
|
||||
|
||||
m_scrollCenterButton->Resize({ size.x, remaining * stepPct });
|
||||
m_scrollCenterButton->SetPosition(0.f, centerPosition);
|
||||
m_scrollCenterButton->SetPosition({ 0.f, centerPosition });
|
||||
}
|
||||
|
||||
m_style->Layout(size);
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Nz
|
||||
entt::registry& registry = GetRegistry();
|
||||
|
||||
Boxf textBox = m_textSprite->GetAABB();
|
||||
registry.get<NodeComponent>(m_textEntity).SetPosition(size.x / 2.f - textBox.width / 2.f, size.y / 2.f - textBox.height / 2.f);
|
||||
registry.get<NodeComponent>(m_textEntity).SetPosition({ size.x / 2.f - textBox.width / 2.f, size.y / 2.f - textBox.height / 2.f });
|
||||
}
|
||||
|
||||
void SimpleButtonWidgetStyle::OnHoverBegin()
|
||||
@@ -150,7 +150,7 @@ namespace Nz
|
||||
Vector2f checkSize = size * 0.66f;
|
||||
m_checkSprite->SetSize(checkSize);
|
||||
|
||||
GetRegistry().get<NodeComponent>(m_checkEntity).SetPosition(size.x / 2.f - checkSize.x / 2.f, size.y / 2.f - checkSize.y / 2.f);
|
||||
GetRegistry().get<NodeComponent>(m_checkEntity).SetPosition({ size.x / 2.f - checkSize.x / 2.f, size.y / 2.f - checkSize.y / 2.f });
|
||||
}
|
||||
|
||||
void SimpleCheckboxWidgetStyle::OnHoverBegin()
|
||||
@@ -363,7 +363,7 @@ namespace Nz
|
||||
entt::registry& registry = GetRegistry();
|
||||
|
||||
Boxf textBox = m_textSprite->GetAABB();
|
||||
registry.get<NodeComponent>(m_entity).SetPosition(size.x / 2.f - textBox.width / 2.f, size.y / 2.f - textBox.height / 2.f);
|
||||
registry.get<NodeComponent>(m_entity).SetPosition({ size.x / 2.f - textBox.width / 2.f, size.y / 2.f - textBox.height / 2.f });
|
||||
}
|
||||
|
||||
void SimpleLabelWidgetStyle::OnHoverBegin()
|
||||
@@ -426,7 +426,7 @@ namespace Nz
|
||||
|
||||
m_barEntity = CreateGraphicsEntity();
|
||||
registry.get<GraphicsComponent>(m_barEntity).AttachRenderable(m_progressBarSprite, renderMask);
|
||||
registry.get<NodeComponent>(m_barEntity).SetPosition(m_barOffset, m_barOffset);
|
||||
registry.get<NodeComponent>(m_barEntity).SetPosition({ m_barOffset, m_barOffset });
|
||||
}
|
||||
|
||||
void SimpleProgressBarWidgetStyle::Layout(const Vector2f& size)
|
||||
|
||||
Reference in New Issue
Block a user