Skip to content

Commit

Permalink
Merge branch 'development' into BeforeAndAfterInputtingValueInNumberB…
Browse files Browse the repository at this point in the history
…arInconsistent-o3de#5234

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
  • Loading branch information
jjjoness committed Jan 13, 2022
2 parents d0f66e9 + ff0df4b commit 3e9fd6f
Show file tree
Hide file tree
Showing 61 changed files with 2,280 additions and 736 deletions.
10 changes: 0 additions & 10 deletions Code/Editor/EditorPreferencesPageViewportGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ void CEditorPreferencesPage_ViewportGeneral::Reflect(AZ::SerializeContext& seria
->Field("ShowBBoxes", &Display::m_showBBoxes)
->Field("DrawEntityLabels", &Display::m_drawEntityLabels)
->Field("ShowTriggerBounds", &Display::m_showTriggerBounds)
->Field("ShowIcons", &Display::m_showIcons)
->Field("DistanceScaleIcons", &Display::m_distanceScaleIcons)
->Field("ShowFrozenHelpers", &Display::m_showFrozenHelpers)
->Field("FillSelectedShapes", &Display::m_fillSelectedShapes)
->Field("ShowGridGuide", &Display::m_showGridGuide)
Expand Down Expand Up @@ -118,10 +116,6 @@ void CEditorPreferencesPage_ViewportGeneral::Reflect(AZ::SerializeContext& seria
AZ::Edit::UIHandlers::CheckBox, &Display::m_drawEntityLabels, "Always Draw Entity Labels", "Always Draw Entity Labels")
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &Display::m_showTriggerBounds, "Always Show Trigger Bounds", "Always Show Trigger Bounds")
->DataElement(AZ::Edit::UIHandlers::CheckBox, &Display::m_showIcons, "Show Object Icons", "Show Object Icons")
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &Display::m_distanceScaleIcons, "Scale Object Icons with Distance",
"Scale Object Icons with Distance")
->DataElement(
AZ::Edit::UIHandlers::CheckBox, &Display::m_showFrozenHelpers, "Show Helpers of Frozen Objects",
"Show Helpers of Frozen Objects")
Expand Down Expand Up @@ -244,8 +238,6 @@ void CEditorPreferencesPage_ViewportGeneral::OnApply()
}
gSettings.viewports.bDrawEntityLabels = m_display.m_drawEntityLabels;
gSettings.viewports.bShowTriggerBounds = m_display.m_showTriggerBounds;
gSettings.viewports.bShowIcons = m_display.m_showIcons;
gSettings.viewports.bDistanceScaleIcons = m_display.m_distanceScaleIcons;
gSettings.viewports.nShowFrozenHelpers = m_display.m_showFrozenHelpers;
gSettings.viewports.bFillSelectedShapes = m_display.m_fillSelectedShapes;
gSettings.viewports.bShowGridGuide = m_display.m_showGridGuide;
Expand Down Expand Up @@ -300,8 +292,6 @@ void CEditorPreferencesPage_ViewportGeneral::InitializeSettings()
m_display.m_showBBoxes = (ds->GetRenderFlags() & RENDER_FLAG_BBOX) == RENDER_FLAG_BBOX;
m_display.m_drawEntityLabels = gSettings.viewports.bDrawEntityLabels;
m_display.m_showTriggerBounds = gSettings.viewports.bShowTriggerBounds;
m_display.m_showIcons = gSettings.viewports.bShowIcons;
m_display.m_distanceScaleIcons = gSettings.viewports.bDistanceScaleIcons;
m_display.m_showFrozenHelpers = gSettings.viewports.nShowFrozenHelpers;
m_display.m_fillSelectedShapes = gSettings.viewports.bFillSelectedShapes;
m_display.m_showGridGuide = gSettings.viewports.bShowGridGuide;
Expand Down
2 changes: 0 additions & 2 deletions Code/Editor/EditorPreferencesPageViewportGeneral.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ class CEditorPreferencesPage_ViewportGeneral : public IPreferencesPage
bool m_showBBoxes;
bool m_drawEntityLabels;
bool m_showTriggerBounds;
bool m_showIcons;
bool m_distanceScaleIcons;
bool m_showFrozenHelpers;
bool m_fillSelectedShapes;
bool m_showGridGuide;
Expand Down
2 changes: 0 additions & 2 deletions Code/Editor/EditorViewportWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,6 @@ void EditorViewportWidget::OnTitleMenu(QMenu* menu)
AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Safe Frame"), &gSettings.viewports.bShowSafeFrame);
AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Construction Plane"), &gSettings.snap.constructPlaneDisplay);
AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Trigger Bounds"), &gSettings.viewports.bShowTriggerBounds);
AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Icons"), &gSettings.viewports.bShowIcons, &gSettings.viewports.bShowSizeBasedIcons);
AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Size-based Icons"), &gSettings.viewports.bShowSizeBasedIcons, &gSettings.viewports.bShowIcons);
AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Helpers of Frozen Objects"), &gSettings.viewports.nShowFrozenHelpers);

if (!m_predefinedAspectRatios.IsEmpty())
Expand Down
157 changes: 0 additions & 157 deletions Code/Editor/Objects/BaseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
// To use the Andrew's algorithm in order to make convex hull from the points, this header is needed.
#include "Util/GeometryUtil.h"

namespace {
QColor kLinkColorParent = QColor(0, 255, 255);
QColor kLinkColorChild = QColor(0, 0, 255);
QColor kLinkColorGray = QColor(128, 128, 128);
}

extern CObjectManager* g_pObjectManager;

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -761,72 +755,6 @@ void CBaseObject::SetModified(bool)
{
}

void CBaseObject::DrawDefault(DisplayContext& dc, const QColor& labelColor)
{
Vec3 wp = GetWorldPos();

bool bDisplaySelectionHelper = false;
if (!CanBeDrawn(dc, bDisplaySelectionHelper))
{
return;
}

// Draw link between parent and child.
if (dc.flags & DISPLAY_LINKS)
{
if (GetParent())
{
dc.DrawLine(GetParentAttachPointWorldTM().GetTranslation(), wp, IsFrozen() ? kLinkColorGray : kLinkColorParent, IsFrozen() ? kLinkColorGray : kLinkColorChild);
}
size_t nChildCount = GetChildCount();
for (size_t i = 0; i < nChildCount; ++i)
{
const CBaseObject* pChild = GetChild(i);
dc.DrawLine(pChild->GetParentAttachPointWorldTM().GetTranslation(), pChild->GetWorldPos(), pChild->IsFrozen() ? kLinkColorGray : kLinkColorParent, pChild->IsFrozen() ? kLinkColorGray : kLinkColorChild);
}
}

// Draw Bounding box
if (dc.flags & DISPLAY_BBOX)
{
AABB box;
GetBoundBox(box);
dc.SetColor(Vec3(1, 1, 1));
dc.DrawWireBox(box.min, box.max);
}

if (IsHighlighted())
{
DrawHighlight(dc);
}

if (IsSelected())
{
DrawArea(dc);

CSelectionGroup* pSelection = GetObjectManager()->GetSelection();

// If the number of selected object is over 2, the merged boundbox should be used to render the measurement axis.
if (!pSelection || (pSelection && pSelection->GetCount() == 1))
{
DrawDimensions(dc);
}
}

if (bDisplaySelectionHelper)
{
DrawSelectionHelper(dc, wp, labelColor, 1.0f);
}
else if (!(dc.flags & DISPLAY_HIDENAMES))
{
DrawLabel(dc, wp, labelColor);
}

SetDrawTextureIconProperties(dc, wp);
DrawTextureIcon(dc, wp);
DrawWarningIcons(dc, wp);
}

//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawDimensions(DisplayContext&, AABB*)
{
Expand All @@ -850,91 +778,6 @@ void CBaseObject::DrawSelectionHelper(DisplayContext& dc, const Vec3& pos, const
dc.SetState(nPrevState);
}

//////////////////////////////////////////////////////////////////////////
void CBaseObject::SetDrawTextureIconProperties(DisplayContext& dc, const Vec3& pos, float alpha, int texIconFlags)
{
if (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons)
{
if (IsHighlighted())
{
dc.SetColor(QColor(255, 120, 0), 0.8f * alpha);
}
else if (IsSelected())
{
dc.SetSelectedColor(alpha);
}
else if (IsFrozen())
{
dc.SetFreezeColor();
}
else
{
dc.SetColor(QColor(255, 255, 255), alpha);
}

m_vDrawIconPos = pos;

int nIconFlags = texIconFlags;
if (CheckFlags(OBJFLAG_SHOW_ICONONTOP))
{
Vec3 objectPos = GetWorldPos();

AABB box;
GetBoundBox(box);
m_vDrawIconPos.z = (m_vDrawIconPos.z - objectPos.z) + box.max.z;
nIconFlags |= DisplayContext::TEXICON_ALIGN_BOTTOM;
}
m_nIconFlags = nIconFlags;
}
}

//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawTextureIcon(DisplayContext& dc, [[maybe_unused]] const Vec3& pos, [[maybe_unused]] float alpha)
{
if (m_nTextureIcon && (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons))
{
dc.DrawTextureLabel(GetTextureIconDrawPos(), OBJECT_TEXTURE_ICON_SIZEX, OBJECT_TEXTURE_ICON_SIZEY, GetTextureIcon(), GetTextureIconFlags());
}
}

//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawWarningIcons(DisplayContext& dc, const Vec3&)
{
if (gSettings.viewports.bShowIcons || gSettings.viewports.bShowSizeBasedIcons)
{
const int warningIconSizeX = OBJECT_TEXTURE_ICON_SIZEX / 2;
const int warningIconSizeY = OBJECT_TEXTURE_ICON_SIZEY / 2;

const int iconOffsetX = m_nTextureIcon ? (-OBJECT_TEXTURE_ICON_SIZEX / 2) : 0;
const int iconOffsetY = m_nTextureIcon ? (-OBJECT_TEXTURE_ICON_SIZEY / 2) : 0;

if (gSettings.viewports.bShowScaleWarnings)
{
const EScaleWarningLevel scaleWarningLevel = GetScaleWarningLevel();

if (scaleWarningLevel != eScaleWarningLevel_None)
{
dc.SetColor(QColor(255, scaleWarningLevel == eScaleWarningLevel_RescaledNonUniform ? 50 : 255, 50), 1.0f);
dc.DrawTextureLabel(GetTextureIconDrawPos(), warningIconSizeX, warningIconSizeY,
GetIEditor()->GetIconManager()->GetIconTexture(eIcon_ScaleWarning), GetTextureIconFlags(),
-warningIconSizeX / 2, iconOffsetX - (warningIconSizeY / 2));
}
}

if (gSettings.viewports.bShowRotationWarnings)
{
const ERotationWarningLevel rotationWarningLevel = GetRotationWarningLevel();
if (rotationWarningLevel != eRotationWarningLevel_None)
{
dc.SetColor(QColor(255, rotationWarningLevel == eRotationWarningLevel_RotatedNonRectangular ? 50 : 255, 50), 1.0f);
dc.DrawTextureLabel(GetTextureIconDrawPos(), warningIconSizeX, warningIconSizeY,
GetIEditor()->GetIconManager()->GetIconTexture(eIcon_RotationWarning), GetTextureIconFlags(),
warningIconSizeX / 2, iconOffsetY - (warningIconSizeY / 2));
}
}
}
}

//////////////////////////////////////////////////////////////////////////
void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& lC, float alpha, float size)
{
Expand Down
10 changes: 0 additions & 10 deletions Code/Editor/Objects/BaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,6 @@ class SANDBOX_API CBaseObject
// Interface to be implemented in plugins.
//////////////////////////////////////////////////////////////////////////

//! Draw object to specified viewport.
virtual void Display([[maybe_unused]] DisplayContext& disp) {}

//! Perform intersection testing of this object.
//! Return true if was hit.
virtual bool HitTest([[maybe_unused]] HitContext& hc) { return false; };
Expand Down Expand Up @@ -529,8 +526,6 @@ class SANDBOX_API CBaseObject
void ResolveParent(CBaseObject* object);
void SetColor(const QColor& color);

//! Draw default object items.
virtual void DrawDefault(DisplayContext& dc, const QColor& labelColor = QColor(255, 255, 255));
//! Draw object label.
void DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& labelColor = QColor(255, 255, 255), float alpha = 1.0f, float size = 1.f);
//! Draw 3D Axis at object position.
Expand All @@ -539,10 +534,6 @@ class SANDBOX_API CBaseObject
void DrawArea(DisplayContext& dc);
//! Draw selection helper.
void DrawSelectionHelper(DisplayContext& dc, const Vec3& pos, const QColor& labelColor = QColor(255, 255, 255), float alpha = 1.0f);
//! Draw helper icon.
virtual void DrawTextureIcon(DisplayContext& dc, const Vec3& pos, float alpha = 1.0f);
//! Draw warning icons
virtual void DrawWarningIcons(DisplayContext& dc, const Vec3& pos);
//! Check if dimension's figures can be displayed before draw them.
virtual void DrawDimensions(DisplayContext& dc, AABB* pMergedBoundBox = nullptr);

Expand Down Expand Up @@ -575,7 +566,6 @@ class SANDBOX_API CBaseObject
//! Only used by ObjectManager.
bool IsPotentiallyVisible() const;

void SetDrawTextureIconProperties(DisplayContext& dc, const Vec3& pos, float alpha = 1.0f, int texIconFlags = 0);
const Vec3& GetTextureIconDrawPos(){ return m_vDrawIconPos; };
int GetTextureIconFlags(){ return m_nIconFlags; };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,97 +723,6 @@ CComponentEntityObject* CComponentEntityObject::FindObjectForEntity(AZ::EntityId
return nullptr;
}

void CComponentEntityObject::Display(DisplayContext& dc)
{
if (!(dc.flags & DISPLAY_2D))
{
m_entityIconVisible = false;
}

bool displaySelectionHelper = false;
if (!CanBeDrawn(dc, displaySelectionHelper))
{
return;
}

DrawDefault(dc);

bool showIcons = m_hasIcon;
if (showIcons)
{
SEditorSettings* editorSettings = GetIEditor()->GetEditorSettings();
if (!editorSettings->viewports.bShowIcons && !editorSettings->viewports.bShowSizeBasedIcons)
{
showIcons = false;
}
}

if (m_entityId.IsValid())
{
// Draw link to parent if this or the parent object are selected.
{
AZ::EntityId parentId;
EBUS_EVENT_ID_RESULT(parentId, m_entityId, AZ::TransformBus, GetParentId);
if (parentId.IsValid())
{
bool isParentVisible = false;
AzToolsFramework::EditorEntityInfoRequestBus::EventResult(isParentVisible, parentId, &AzToolsFramework::EditorEntityInfoRequestBus::Events::IsVisible);

CComponentEntityObject* parentObject = CComponentEntityObject::FindObjectForEntity(parentId);
if (isParentVisible && (IsSelected() || (parentObject && parentObject->IsSelected())))
{
const QColor kLinkColorParent(0, 255, 255);
const QColor kLinkColorChild(0, 0, 255);

AZ::Vector3 parentTranslation;
EBUS_EVENT_ID_RESULT(parentTranslation, parentId, AZ::TransformBus, GetWorldTranslation);
dc.DrawLine(AZVec3ToLYVec3(parentTranslation), GetWorldTM().GetTranslation(), kLinkColorParent, kLinkColorChild);
}
}
}

// Don't draw icons if we have an ancestor in the same location that has an icon - makes sure
// ancestor icons draw on top and are able to be selected over children. Also check if a descendant
// is selected at the same location. In cases of entity hierarchies where numerous ancestors have
// no position offset, we need this so the ancestors don't draw over us when we're selected
if (showIcons)
{
if ((dc.flags & DISPLAY_2D) ||
IsSelected() ||
IsAncestorIconDrawingAtSameLocation() ||
IsDescendantSelectedAtSameLocation())
{
showIcons = false;
}
}

// Allow components to override in-editor visualization.
{
const AzFramework::DisplayContextRequestGuard displayContextGuard(dc);

AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus;
AzFramework::DebugDisplayRequestBus::Bind(
debugDisplayBus, AzFramework::g_defaultSceneEntityDebugDisplayId);
AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus.");

AzFramework::DebugDisplayRequests* debugDisplay =
AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus);

AzFramework::EntityDebugDisplayEventBus::Event(
m_entityId, &AzFramework::EntityDebugDisplayEvents::DisplayEntityViewport,
AzFramework::ViewportInfo{ dc.GetView()->asCViewport()->GetViewportId() },
*debugDisplay);
}
}
}

void CComponentEntityObject::DrawDefault(DisplayContext& dc, const QColor& labelColor)
{
CEntityObject::DrawDefault(dc, labelColor);

DrawAccent(dc);
}

bool CComponentEntityObject::IsIsolated() const
{
return m_isIsolated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class CComponentEntityObject
bool SetRotation(const Quat& rotate, int flags) override;
bool SetScale(const Vec3& scale, int flags) override;
void InvalidateTM(int nWhyFlags) override;
void Display(DisplayContext& disp) override;
bool HitTest(HitContext& hc) override;
void GetLocalBounds(AABB& box) override;
void GetBoundBox(AABB& box) override;
Expand All @@ -69,7 +68,6 @@ class CComponentEntityObject
void DetachThis(bool bKeepPos = true) override;
XmlNodeRef Export(const QString& levelPath, XmlNodeRef& xmlNode) override;
void DeleteEntity() override;
void DrawDefault(DisplayContext& dc, const QColor& labelColor = QColor(255, 255, 255)) override;

bool IsIsolated() const override;
bool IsSelected() const override;
Expand Down
Loading

0 comments on commit 3e9fd6f

Please sign in to comment.