Remove (almost) all references to pRenderer (#651)
Remove all references to pRenderer, except from the DebugDraw and LyShine Gems that are still being updated.
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "ComponentEntityEditorPlugin_precompiled.h"
|
||||
#include "ComponentEntityDebugPrinter.h"
|
||||
|
||||
#include <AzFramework/Entity/GameEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
|
||||
ComponentEntityDebugPrinter::ComponentEntityDebugPrinter()
|
||||
{
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void ComponentEntityDebugPrinter::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
|
||||
{
|
||||
if (!GetIEditor()->GetRenderer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ICVar* displayInfo = GetIEditor()->GetSystem()->GetIConsole()->GetCVar("r_DisplayInfo");
|
||||
if (!displayInfo || displayInfo->GetIVal() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float x = 2.f;
|
||||
float y = 2.f;
|
||||
|
||||
SDrawTextInfo textInfo;
|
||||
textInfo.xscale = 1.25f;
|
||||
textInfo.yscale = textInfo.xscale;
|
||||
textInfo.flags = eDrawText_2D | eDrawText_FixedSize | eDrawText_800x600 | eDrawText_Monospace;
|
||||
|
||||
// Figure out whether we're querying the Game or Editor entity context
|
||||
AzFramework::EntityContextId entityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
if (GetIEditor()->IsInGameMode())
|
||||
{
|
||||
AzFramework::GameEntityContextRequestBus::BroadcastResult(entityContextId, &AzFramework::GameEntityContextRequestBus::Events::GetGameEntityContextId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(entityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId);
|
||||
}
|
||||
if (entityContextId.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Print the number of entities in the level
|
||||
AZ::SliceComponent* rootSlice = nullptr;
|
||||
AzFramework::SliceEntityOwnershipServiceRequestBus::EventResult(rootSlice, entityContextId,
|
||||
&AzFramework::SliceEntityOwnershipServiceRequestBus::Events::GetRootSlice);
|
||||
if (rootSlice)
|
||||
{
|
||||
size_t numEntities = rootSlice->GetInstantiatedEntityCount();
|
||||
if (numEntities > 0)
|
||||
{
|
||||
GetIEditor()->GetRenderer()->DrawTextQueued(Vec3(x, y, 0), textInfo, AZStd::string::format("Entities: %zu", numEntities).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
|
||||
/**
|
||||
* Prints debug statistics about Component Entities to screen
|
||||
*/
|
||||
class ComponentEntityDebugPrinter
|
||||
: private AZ::TickBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ComponentEntityDebugPrinter, AZ::SystemAllocator, 0);
|
||||
|
||||
ComponentEntityDebugPrinter();
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// TickBus
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
@@ -915,14 +915,6 @@ void CComponentEntityObject::Display(DisplayContext& dc)
|
||||
m_entityId, &AzFramework::EntityDebugDisplayEvents::DisplayEntityViewport,
|
||||
AzFramework::ViewportInfo{ dc.GetView()->asCViewport()->GetViewportId() },
|
||||
*debugDisplay);
|
||||
|
||||
if (showIcons)
|
||||
{
|
||||
if (!displaySelectionHelper && !IsSelected())
|
||||
{
|
||||
m_entityIconVisible = DisplayEntityIcon(dc, *debugDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -984,38 +976,6 @@ void CComponentEntityObject::OnContextMenu(QMenu* /*pMenu*/)
|
||||
// Deliberately bypass the base class implementation (CEntityObject::OnContextMenu()).
|
||||
}
|
||||
|
||||
bool CComponentEntityObject::DisplayEntityIcon(
|
||||
DisplayContext& displayContext, AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
if (!m_hasIcon)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const QPoint entityScreenPos = displayContext.GetView()->WorldToView(GetWorldPos());
|
||||
|
||||
const Vec3 worldPos = GetWorldPos();
|
||||
const CCamera& camera = gEnv->pRenderer->GetCamera();
|
||||
const Vec3 cameraToEntity = (worldPos - camera.GetMatrix().GetTranslation());
|
||||
const float distSq = cameraToEntity.GetLengthSquared();
|
||||
if (distSq > square(s_kIconMaxWorldDist))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Draw component icons on top of meshes (no depth testing)
|
||||
int iconFlags = (int) DisplayContext::ETextureIconFlags::TEXICON_ON_TOP;
|
||||
SetDrawTextureIconProperties(displayContext, worldPos, 1.0f, iconFlags);
|
||||
|
||||
const float iconScale = s_kIconMinScale + (s_kIconMaxScale - s_kIconMinScale) * (1.0f - clamp_tpl(max(0.0f, sqrt_tpl(distSq) - s_kIconCloseDist) / s_kIconFarDist, 0.0f, 1.0f));
|
||||
const float worldDistToScreenScaleFraction = 0.045f;
|
||||
const float screenScale = displayContext.GetView()->GetScreenScaleFactor(GetWorldPos()) * worldDistToScreenScaleFraction;
|
||||
|
||||
debugDisplay.DrawTextureLabel(m_iconTexture, LYVec3ToAZVec3(worldPos), s_kIconSize * iconScale, s_kIconSize * iconScale, GetTextureIconFlags());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CComponentEntityObject::SetupEntityIcon()
|
||||
{
|
||||
bool hideIconInViewport = false;
|
||||
@@ -1031,8 +991,9 @@ void CComponentEntityObject::SetupEntityIcon()
|
||||
{
|
||||
m_hasIcon = true;
|
||||
|
||||
int textureId = GetIEditor()->GetIconManager()->GetIconTexture(m_icon.c_str());
|
||||
m_iconTexture = GetIEditor()->GetRenderer() ? GetIEditor()->GetRenderer()->EF_GetTextureByID(textureId) : nullptr;
|
||||
// ToDo: Get from Atom?
|
||||
// int textureId = GetIEditor()->GetIconManager()->GetIconTexture(m_icon.c_str());
|
||||
m_iconTexture = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
#include <MathConversion.h>
|
||||
|
||||
#include "Objects/ComponentEntityObject.h"
|
||||
#include "ComponentEntityDebugPrinter.h"
|
||||
#include "ISourceControl.h"
|
||||
#include "UI/QComponentEntityEditorMainWindow.h"
|
||||
|
||||
@@ -72,7 +71,6 @@
|
||||
#include <Editor/CryEditDoc.h>
|
||||
#include <Editor/GameEngine.h>
|
||||
#include <Editor/DisplaySettings.h>
|
||||
#include <Editor/Util/CubemapUtils.h>
|
||||
#include <Editor/IconManager.h>
|
||||
#include <Editor/Settings.h>
|
||||
#include <Editor/StringDlg.h>
|
||||
@@ -141,7 +139,6 @@ SandboxIntegrationManager::SandboxIntegrationManager()
|
||||
, m_startedUndoRecordingNestingLevel(0)
|
||||
, m_dc(nullptr)
|
||||
, m_notificationWindowManager(new AzToolsFramework::SliceOverridesNotificationWindowManager())
|
||||
, m_entityDebugPrinter(aznew ComponentEntityDebugPrinter())
|
||||
{
|
||||
// Required to receive events from the Cry Engine undo system
|
||||
GetIEditor()->GetUndoManager()->AddListener(this);
|
||||
@@ -1998,92 +1995,6 @@ void SandboxIntegrationManager::BrowseForAssets(AssetSelectionModel& selection)
|
||||
AssetBrowserComponentRequestBus::Broadcast(&AssetBrowserComponentRequests::PickAssets, selection, GetMainWindow());
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::GenerateCubemapForEntity(AZ::EntityId entityId, AZStd::string* cubemapOutputPath, bool hideEntity)
|
||||
{
|
||||
GenerateCubemapWithIDForEntity(entityId, AZ::Uuid::CreateNull(), cubemapOutputPath, hideEntity, false);
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::GenerateCubemapWithIDForEntity(AZ::EntityId entityId, AZ::Uuid cubemapId,
|
||||
AZStd::string* cubemapOutputPath, bool hideEntity, bool hasCubemapId)
|
||||
{
|
||||
AZ::u32 resolution = 0;
|
||||
EBUS_EVENT_ID_RESULT(resolution, entityId, LmbrCentral::EditorLightComponentRequestBus, GetCubemapResolution);
|
||||
|
||||
if (resolution > 0)
|
||||
{
|
||||
CComponentEntityObject* componentEntity = CComponentEntityObject::FindObjectForEntity(entityId);
|
||||
|
||||
if (componentEntity)
|
||||
{
|
||||
QString levelfolder = GetIEditor()->GetGameEngine()->GetLevelPath();
|
||||
QString levelname = Path::GetFile(levelfolder).toLower();
|
||||
QString fullGameFolder = QString(Path::GetEditingGameDataFolder().c_str());
|
||||
QString texturename;
|
||||
if (hasCubemapId)
|
||||
{
|
||||
texturename = QStringLiteral("%1_cm.tif").arg(cubemapId.ToString<QString>(false, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
texturename = QStringLiteral("%1_cm.tif").arg(static_cast<qulonglong>(componentEntity->GetAssociatedEntityId()));
|
||||
}
|
||||
texturename = texturename.toLower();
|
||||
|
||||
QString fullFolder = Path::SubDirectoryCaseInsensitive(fullGameFolder, {"textures", "cubemaps", levelname});
|
||||
QString fullFilename = QDir(fullFolder).absoluteFilePath(texturename);
|
||||
QString relFilename = QDir(fullGameFolder).relativeFilePath(fullFilename);
|
||||
|
||||
bool directlyExists = CFileUtil::CreateDirectory(fullFolder.toUtf8().data());
|
||||
if (!directlyExists)
|
||||
{
|
||||
QMessageBox::warning(GetMainWindow(), QObject::tr("Cubemap Generation Failed"), QString(QObject::tr("Failed to create destination path '%1'")).arg(fullFolder));
|
||||
return;
|
||||
}
|
||||
|
||||
if (CubemapUtils::GenCubemapWithObjectPathAndSize(fullFilename, componentEntity, static_cast<int>(resolution), hideEntity))
|
||||
{
|
||||
AZStd::string assetPath = relFilename.toUtf8().data();
|
||||
AzFramework::StringFunc::Path::ReplaceExtension(assetPath, ".dds");
|
||||
|
||||
EBUS_EVENT_ID(entityId, LmbrCentral::EditorLightComponentRequestBus, SetCubemap, assetPath);
|
||||
|
||||
if (cubemapOutputPath)
|
||||
{
|
||||
*cubemapOutputPath = AZStd::move(assetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(GetMainWindow(), QObject::tr("Cubemap Generation Failed"), QObject::tr("Unspecified error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::GenerateAllCubemaps()
|
||||
{
|
||||
AZStd::string cubemapOutputPath;
|
||||
|
||||
std::vector<CBaseObject*> results;
|
||||
results.reserve(128);
|
||||
GetIEditor()->GetObjectManager()->FindObjectsOfType(OBJTYPE_AZENTITY, results);
|
||||
for (std::vector<CBaseObject*>::iterator end = results.end(), item = results.begin(); item != end; ++item)
|
||||
{
|
||||
CComponentEntityObject* componentEntity = static_cast<CComponentEntityObject*>(*item);
|
||||
|
||||
//check if it's customized cubemap, only generate it if it's not.
|
||||
bool isCustomizedCubemap = true;
|
||||
EBUS_EVENT_ID_RESULT(isCustomizedCubemap, componentEntity->GetAssociatedEntityId(), LmbrCentral::EditorLightComponentRequestBus, UseCustomizedCubemap);
|
||||
|
||||
if (isCustomizedCubemap)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GenerateCubemapForEntity(componentEntity->GetAssociatedEntityId(), nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::SetColor(float r, float g, float b, float a)
|
||||
{
|
||||
if (m_dc)
|
||||
@@ -2575,19 +2486,6 @@ void SandboxIntegrationManager::Draw2dTextLabel(float x, float y, float size, co
|
||||
}
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::DrawTextOn2DBox(const AZ::Vector3& pos, const char* text, float textScale, const AZ::Vector4& textColor, const AZ::Vector4& textBackColor)
|
||||
{
|
||||
if (m_dc)
|
||||
{
|
||||
m_dc->DrawTextOn2DBox(
|
||||
AZVec3ToLYVec3(pos),
|
||||
text,
|
||||
textScale,
|
||||
ColorF(AZVec3ToLYVec3(textColor.GetAsVector3()), textColor.GetW()),
|
||||
ColorF(AZVec3ToLYVec3(textBackColor.GetAsVector3()), textBackColor.GetW()));
|
||||
}
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags)
|
||||
{
|
||||
if (m_dc)
|
||||
@@ -2614,8 +2512,12 @@ void SandboxIntegrationManager::DrawTextureLabel(ITexture* texture, const AZ::Ve
|
||||
|
||||
void SandboxIntegrationManager::DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags)
|
||||
{
|
||||
ITexture* texture = GetIEditor()->GetRenderer()->EF_GetTextureByID(textureId);
|
||||
DrawTextureLabel(texture, pos, sizeX, sizeY, texIconFlags);
|
||||
// ToDo: With Atom?
|
||||
AZ_UNUSED(textureId);
|
||||
AZ_UNUSED(pos);
|
||||
AZ_UNUSED(sizeX);
|
||||
AZ_UNUSED(sizeY);
|
||||
AZ_UNUSED(texIconFlags);
|
||||
}
|
||||
|
||||
void SandboxIntegrationManager::SetLineWidth(float width)
|
||||
|
||||
@@ -143,9 +143,6 @@ private:
|
||||
QDockWidget* InstanceViewPane(const char* paneName) override;
|
||||
void CloseViewPane(const char* paneName) override;
|
||||
void BrowseForAssets(AzToolsFramework::AssetBrowser::AssetSelectionModel& selection) override;
|
||||
void GenerateAllCubemaps() override;
|
||||
void GenerateCubemapForEntity(AZ::EntityId entityId, AZStd::string* cubemapOutputPath, bool hideEntity) override;
|
||||
void GenerateCubemapWithIDForEntity(AZ::EntityId entityId, AZ::Uuid cubemapId, AZStd::string* cubemapOutputPath, bool hideEntity, bool hasCubemapId) override;
|
||||
void HandleObjectModeSelection(const AZ::Vector2& point, int flags, bool& handled) override;
|
||||
void UpdateObjectModeCursor(AZ::u32& cursorId, AZStd::string& cursorStr) override;
|
||||
void CreateEditorRepresentation(AZ::Entity* entity) override;
|
||||
@@ -249,7 +246,6 @@ private:
|
||||
void DrawArrow(const AZ::Vector3& src, const AZ::Vector3& trg, float fHeadScale, bool b2SidedArrow) override;
|
||||
void DrawTextLabel(const AZ::Vector3& pos, float size, const char* text, const bool bCenter, int srcOffsetX, int scrOffsetY) override;
|
||||
void Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter) override;
|
||||
void DrawTextOn2DBox(const AZ::Vector3& pos, const char* text, float textScale, const AZ::Vector4& TextColor, const AZ::Vector4& TextBackColor) override;
|
||||
void DrawTextureLabel(ITexture* texture, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
|
||||
void DrawTextureLabel(int textureId, const AZ::Vector3& pos, float sizeX, float sizeY, int texIconFlags) override;
|
||||
void SetLineWidth(float width) override;
|
||||
@@ -365,8 +361,6 @@ private:
|
||||
|
||||
DisplayContext* m_dc;
|
||||
|
||||
AZStd::unique_ptr<class ComponentEntityDebugPrinter> m_entityDebugPrinter;
|
||||
|
||||
AZStd::vector<SliceAssetDeletionErrorInfo> m_sliceAssetDeletionErrorRestoreInfos;
|
||||
|
||||
// Tracks new entities that have not yet been saved.
|
||||
|
||||
-2
@@ -17,8 +17,6 @@ set(FILES
|
||||
SandboxIntegration.cpp
|
||||
ComponentEntityEditorPlugin_precompiled.cpp
|
||||
ComponentEntityEditorPlugin_precompiled.h
|
||||
ComponentEntityDebugPrinter.h
|
||||
ComponentEntityDebugPrinter.cpp
|
||||
UI/ComponentEntityEditorOutlinerWindow.qrc
|
||||
UI/QComponentEntityEditorMainWindow.h
|
||||
UI/QComponentEntityEditorMainWindow.cpp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,336 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_EDITORCOMMON_MANIPSCENE_H
|
||||
#define CRYINCLUDE_EDITORCOMMON_MANIPSCENE_H
|
||||
#pragma once
|
||||
|
||||
#include <platform.h>
|
||||
#include <Cry_Geo.h>
|
||||
#include <Cry_Color.h>
|
||||
#include "EditorCommonAPI.h"
|
||||
#include <QObject>
|
||||
#include "QViewportConsumer.h"
|
||||
|
||||
|
||||
namespace Serialization {
|
||||
class IArchive;
|
||||
}
|
||||
|
||||
class CAxisHelper;
|
||||
|
||||
// Manip is a set of reusable utilities for creating interactive 3d scene that
|
||||
// can be manipulated with gizmos.
|
||||
namespace Manip
|
||||
{
|
||||
using std::unique_ptr;
|
||||
using std::set;
|
||||
using std::vector;
|
||||
|
||||
enum EElementCaps
|
||||
{
|
||||
CAP_SELECT = 1 << 0,
|
||||
CAP_HIDE = 1 << 1,
|
||||
CAP_MOVE = 1 << 2,
|
||||
CAP_ROTATE = 1 << 3,
|
||||
CAP_SCALE = 1 << 4,
|
||||
CAP_DELETE = 1 << 5,
|
||||
};
|
||||
|
||||
enum EElementShape
|
||||
{
|
||||
SHAPE_AXES,
|
||||
SHAPE_BOX
|
||||
};
|
||||
|
||||
enum EElementAction
|
||||
{
|
||||
ACTION_NONE,
|
||||
ACTION_DELETE,
|
||||
ACTION_HIDE,
|
||||
ACTION_UNHIDE
|
||||
};
|
||||
|
||||
enum EElementColorGroup
|
||||
{
|
||||
ELEMENT_COLOR_PROXY,
|
||||
ELEMENT_COLOR_CLOTH
|
||||
};
|
||||
|
||||
struct SElementPlacement
|
||||
{
|
||||
QuatT transform;
|
||||
QuatT startTransform;
|
||||
Vec3 center;
|
||||
Vec3 size;
|
||||
|
||||
SElementPlacement()
|
||||
: transform(IDENTITY)
|
||||
, startTransform(IDENTITY)
|
||||
, size(1.0f, 1.0f, 1.0f)
|
||||
, center(0.0f, 0.0f, 0.0f)
|
||||
{}
|
||||
|
||||
void Serialize(Serialization::IArchive& ar);
|
||||
};
|
||||
|
||||
typedef uint64 ElementId;
|
||||
|
||||
struct SSpaceAndIndex
|
||||
{
|
||||
int m_space;
|
||||
int m_jointCRC32;
|
||||
int m_attachmentCRC32;
|
||||
SSpaceAndIndex()
|
||||
{
|
||||
m_space = -1;
|
||||
m_jointCRC32 = -1;
|
||||
m_attachmentCRC32 = -1;
|
||||
};
|
||||
};
|
||||
|
||||
struct SElement
|
||||
{
|
||||
int id;
|
||||
union
|
||||
{
|
||||
int originalId;
|
||||
const void* originalHandle;
|
||||
};
|
||||
int layer;
|
||||
SElementPlacement placement;
|
||||
int caps;
|
||||
EElementAction action;
|
||||
EElementShape shape;
|
||||
EElementColorGroup colorGroup;
|
||||
SSpaceAndIndex parentSpaceIndex;
|
||||
SSpaceAndIndex parentOrientationSpaceIndex;
|
||||
QuatT parentSpaceConcatenation;
|
||||
int mousePickPriority;
|
||||
bool hidden;
|
||||
bool changed;
|
||||
bool alwaysXRay;
|
||||
|
||||
SElement()
|
||||
: id()
|
||||
, layer(0)
|
||||
, originalHandle(0)
|
||||
, action(ACTION_NONE)
|
||||
, shape(SHAPE_AXES)
|
||||
, hidden(false)
|
||||
, changed(false)
|
||||
, colorGroup(ELEMENT_COLOR_PROXY)
|
||||
, mousePickPriority(0)
|
||||
, alwaysXRay(false)
|
||||
, parentSpaceIndex()
|
||||
, parentOrientationSpaceIndex()
|
||||
, parentSpaceConcatenation(IDENTITY)
|
||||
{
|
||||
}
|
||||
};
|
||||
typedef std::vector<SElement> SElements;
|
||||
|
||||
struct SElementData {};
|
||||
|
||||
struct IMouseDragHandler
|
||||
{
|
||||
virtual ~IMouseDragHandler() = default;
|
||||
virtual bool Begin(const SMouseEvent& ev, Vec3 hitPoint) = 0;
|
||||
virtual void Update(const SMouseEvent& ev) = 0;
|
||||
virtual void Render([[maybe_unused]] const SRenderContext& rc) {}
|
||||
virtual void End(const SMouseEvent& ev) = 0;
|
||||
};
|
||||
|
||||
struct SSelectionSet
|
||||
{
|
||||
SSelectionSet() {}
|
||||
SSelectionSet(ElementId id) { items.push_back(id); }
|
||||
void Clear();
|
||||
void Add(ElementId elementId)
|
||||
{
|
||||
items.erase(std::remove(items.begin(), items.end(), elementId), items.end());
|
||||
items.push_back(elementId);
|
||||
std::sort(items.begin(), items.end());
|
||||
}
|
||||
void Remove(int elementId);
|
||||
bool IsEmpty() const{ return items.empty(); }
|
||||
bool Contains(int id) const{ return std::find(items.begin(), items.end(), id) != items.end(); }
|
||||
size_t Size() const{ return items.size(); }
|
||||
|
||||
bool operator==(const SSelectionSet& rhs) const
|
||||
{
|
||||
return items == rhs.items;
|
||||
}
|
||||
|
||||
bool operator!=(const SSelectionSet& rhs) const{ return !operator==(rhs); }
|
||||
|
||||
std::vector<ElementId> items;
|
||||
};
|
||||
|
||||
struct ICommand {};
|
||||
|
||||
struct IElementTracer
|
||||
{
|
||||
virtual bool HitRay(Vec3* intersectionPoint, const Ray& ray, const SElement& element) const = 0;
|
||||
};
|
||||
|
||||
struct IElementDrawer
|
||||
{
|
||||
virtual bool Draw(const SElement& element);
|
||||
};
|
||||
|
||||
enum ETransformationSpace
|
||||
{
|
||||
SPACE_WORLD,
|
||||
SPACE_LOCAL
|
||||
};
|
||||
|
||||
enum ETransformationMode
|
||||
{
|
||||
MODE_TRANSLATE,
|
||||
MODE_ROTATE,
|
||||
MODE_SCALE
|
||||
};
|
||||
|
||||
struct SLookSettings
|
||||
{
|
||||
ColorB proxyColor;
|
||||
ColorB proxySelectionColor;
|
||||
ColorB proxyHighlightColor;
|
||||
ColorB clothProxyColor;
|
||||
|
||||
ColorB jointColor;
|
||||
ColorB jointHighlightColor;
|
||||
ColorB jointSelectionColor;
|
||||
|
||||
SLookSettings()
|
||||
: proxyColor(126, 159, 243, 128)
|
||||
, proxySelectionColor(255, 255, 255, 128)
|
||||
, proxyHighlightColor(233, 255, 122, 128)
|
||||
, clothProxyColor(243, 159, 126, 128)
|
||||
, jointColor(0, 249, 48, 255)
|
||||
, jointHighlightColor(255, 248, 0, 128)
|
||||
, jointSelectionColor(255, 255, 255, 128)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct ISpaceProvider
|
||||
{
|
||||
virtual ~ISpaceProvider() = default;
|
||||
virtual SSpaceAndIndex FindSpaceIndexByName(int spaceType, const char* name, int parentsUp) const = 0;
|
||||
virtual QuatT GetTransform(const SSpaceAndIndex& index) const = 0;
|
||||
};
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
class EDITOR_COMMON_API CScene
|
||||
: public QObject
|
||||
, public QViewportConsumer
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
Q_OBJECT
|
||||
public:
|
||||
CScene();
|
||||
~CScene();
|
||||
|
||||
void OnViewportKey(const SKeyEvent& ev) override;
|
||||
bool ProcessesViewportKey(const QKeySequence& key) override;
|
||||
void OnViewportMouse(const SMouseEvent& ev) override;
|
||||
void OnViewportRender(const SRenderContext& rc) override;
|
||||
|
||||
void SetTransformationMode(ETransformationMode mode);
|
||||
ETransformationMode TransformationMode() const;
|
||||
void SetTransformationSpace(ETransformationSpace space);
|
||||
ETransformationSpace TransformationSpace() const { return m_transformationSpace; }
|
||||
void SetVisibleLayerMask(unsigned int layerMask);
|
||||
unsigned int VisibleLayerMask() const { return m_visibleLayerMask; }
|
||||
bool IsLayerVisible(int layer) const;
|
||||
|
||||
void Clear();
|
||||
void ClearLayer(int layer);
|
||||
void AddElement(const SElement& element);
|
||||
void AddElement(const SElement& element, ElementId id);
|
||||
void ApplyToAll(EElementAction);
|
||||
void ApplyToSelection(EElementAction);
|
||||
|
||||
void SetSpaceProvider(ISpaceProvider* spaceProvider);
|
||||
ISpaceProvider* SpaceProvider() const{ return m_spaceProvider; }
|
||||
QuatT GetParentSpace(const SElement& e) const;
|
||||
QuatT ElementToWorldSpace(const SElement& e) const;
|
||||
void WorldSpaceToElement(SElement* e, const QuatT& worldSpaceTransform);
|
||||
|
||||
void SetCustomTracer(IElementTracer* tracer);
|
||||
|
||||
const SElements& Elements() const{ return m_elements; }
|
||||
SElements& Elements() { return m_elements; }
|
||||
void GetSelectedElements(SElements* elements) const;
|
||||
const SSelectionSet& Selection() const{ return m_selection; }
|
||||
void SetSelection(const SSelectionSet& selection);
|
||||
void AddToSelection(const SSelectionSet& selection);
|
||||
void AddToSelection(ElementId elementId);
|
||||
|
||||
bool SelectionCanBeMoved() const;
|
||||
bool SelectionCanBeRotated() const;
|
||||
QuatT GetSelectionTransform(ETransformationSpace space) const;
|
||||
bool SetSelectionTransform(ETransformationSpace space, const QuatT& newTransform);
|
||||
|
||||
void Serialize(Serialization::IArchive& ar);
|
||||
signals:
|
||||
void SignalUndo();
|
||||
void SignalRedo();
|
||||
void SignalPushUndo(const char* description, ICommand* cause);
|
||||
void SignalElementsChanged(unsigned int layerBits);
|
||||
void SignalElementContinousChange(unsigned int layerBits);
|
||||
void SignalPropertiesChanged();
|
||||
void SignalRenderElements(const SElements& elements, const SRenderContext& rc);
|
||||
void SignalSelectionChanged();
|
||||
void SignalManipulationModeChanged();
|
||||
|
||||
private:
|
||||
void UpdateElements(const SElements& elements);
|
||||
bool SetSelectionTransform(const Matrix34& newMatrix);
|
||||
Matrix34 GetSelectionTransform() const;
|
||||
int GetSelectionCaps() const;
|
||||
Vec3 GetSelectionSize() const;
|
||||
bool SetSelectionSize(const Vec3& size);
|
||||
void OnMouseMove(const SMouseEvent& ev);
|
||||
|
||||
struct SBlockSelectHandler;
|
||||
struct SMoveHandler;
|
||||
struct SRotationHandler;
|
||||
struct SScalingHandler;
|
||||
struct STransformBox;
|
||||
|
||||
IElementTracer* m_customTracer;
|
||||
IElementDrawer* m_customDrawer;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
SSelectionSet m_selection;
|
||||
unique_ptr<IMouseDragHandler> m_mouseDragHandler;
|
||||
ISpaceProvider* m_spaceProvider;
|
||||
unique_ptr<CAxisHelper> m_axisHelper;
|
||||
SElements m_elements;
|
||||
std::vector<ElementId> m_lastIdByLayer;
|
||||
ETransformationMode m_transformationMode;
|
||||
ETransformationSpace m_transformationSpace;
|
||||
int m_highlightItem;
|
||||
unsigned int m_visibleLayerMask;
|
||||
bool m_showGizmo;
|
||||
SLookSettings m_lookSettings;
|
||||
int m_highlightedItem;
|
||||
QuatT m_temporaryLocalDelta;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CRYINCLUDE_EDITORCOMMON_MANIPSCENE_H
|
||||
@@ -145,7 +145,6 @@ QViewport::QViewport(QWidget* parent, StartupMode startupMode)
|
||||
void QViewport::Startup()
|
||||
{
|
||||
m_frameTimer = new QElapsedTimer();
|
||||
CreateRenderContext();
|
||||
|
||||
m_camera.reset(new CCamera());
|
||||
ResetCamera();
|
||||
@@ -162,8 +161,6 @@ void QViewport::Startup()
|
||||
|
||||
QViewport::~QViewport()
|
||||
{
|
||||
DestroyRenderContext();
|
||||
|
||||
m_viewportRequests.reset();
|
||||
}
|
||||
|
||||
@@ -180,51 +177,14 @@ void QViewport::UpdateBackgroundColor()
|
||||
|
||||
bool QViewport::ScreenToWorldRay(Ray* ray, int x, int y)
|
||||
{
|
||||
if (!GetIEditor()->GetEnv()->pRenderer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetCurrentContext();
|
||||
|
||||
Vec3 pos0, pos1;
|
||||
float wx, wy, wz;
|
||||
if (!GetIEditor()->GetEnv()->pRenderer->UnProjectFromScreen(float(x), float(m_height - y), 0, &wx, &wy, &wz))
|
||||
{
|
||||
RestorePreviousContext();
|
||||
return false;
|
||||
}
|
||||
pos0(wx, wy, wz);
|
||||
if (!GetIEditor()->GetEnv()->pRenderer->UnProjectFromScreen(float(x), float(m_height - y), 1, &wx, &wy, &wz))
|
||||
{
|
||||
RestorePreviousContext();
|
||||
return false;
|
||||
}
|
||||
pos1(wx, wy, wz);
|
||||
|
||||
RestorePreviousContext();
|
||||
|
||||
Vec3 v = (pos1 - pos0);
|
||||
v = v.GetNormalized();
|
||||
|
||||
ray->origin = pos0;
|
||||
ray->direction = v;
|
||||
return true;
|
||||
AZ_UNUSED(ray);
|
||||
AZ_UNUSED(x);
|
||||
AZ_UNUSED(y);
|
||||
return false;
|
||||
}
|
||||
|
||||
QPoint QViewport::ProjectToScreen(const Vec3& wp)
|
||||
QPoint QViewport::ProjectToScreen(const Vec3&)
|
||||
{
|
||||
float x, y, z;
|
||||
|
||||
SetCurrentContext();
|
||||
GetIEditor()->GetEnv()->pRenderer->ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z);
|
||||
if (_finite(x) || _finite(y))
|
||||
{
|
||||
RestorePreviousContext();
|
||||
return QPoint(int((x / 100.0) * Width()), int((y / 100.0) * Height()));
|
||||
}
|
||||
RestorePreviousContext();
|
||||
|
||||
return QPoint(0, 0);
|
||||
}
|
||||
|
||||
@@ -245,105 +205,6 @@ int QViewport::Height() const
|
||||
return rect().height();
|
||||
}
|
||||
|
||||
bool QViewport::CreateRenderContext()
|
||||
{
|
||||
if (m_creatingRenderContext || !isVisible())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
HWND windowHandle = reinterpret_cast<HWND>(QWidget::winId());
|
||||
|
||||
if( m_renderContextCreated && windowHandle == m_lastHwnd)
|
||||
{
|
||||
// the hwnd has not changed, no need to destroy and recreate context (and swap chain etc)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_creatingRenderContext = true;
|
||||
DestroyRenderContext();
|
||||
if (windowHandle && GetIEditor()->GetEnv()->pRenderer && !m_renderContextCreated)
|
||||
{
|
||||
m_renderContextCreated = true;
|
||||
|
||||
m_viewportRequests.get()->BusConnect(windowHandle);
|
||||
AzFramework::WindowSystemNotificationBus::Broadcast(&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated, windowHandle);
|
||||
|
||||
m_lastHwnd = windowHandle;
|
||||
|
||||
StorePreviousContext();
|
||||
GetIEditor()->GetEnv()->pRenderer->CreateContext(windowHandle);
|
||||
RestorePreviousContext();
|
||||
|
||||
m_creatingRenderContext = false;
|
||||
return true;
|
||||
}
|
||||
m_creatingRenderContext = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void QViewport::DestroyRenderContext()
|
||||
{
|
||||
if (GetIEditor()->GetEnv()->pRenderer && m_renderContextCreated)
|
||||
{
|
||||
HWND windowHandle = reinterpret_cast<HWND>(QWidget::winId());
|
||||
|
||||
if (windowHandle != GetIEditor()->GetEnv()->pRenderer->GetHWND())
|
||||
{
|
||||
GetIEditor()->GetEnv()->pRenderer->DeleteContext(windowHandle);
|
||||
}
|
||||
m_renderContextCreated = false;
|
||||
|
||||
AzFramework::WindowNotificationBus::Event(windowHandle, &AzFramework::WindowNotificationBus::Handler::OnWindowClosed);
|
||||
m_viewportRequests.get()->BusDisconnect();
|
||||
m_lastHwnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QViewport::StorePreviousContext()
|
||||
{
|
||||
SPreviousContext previous;
|
||||
previous.width = GetIEditor()->GetEnv()->pRenderer->GetWidth();
|
||||
previous.height = GetIEditor()->GetEnv()->pRenderer->GetHeight();
|
||||
previous.window = reinterpret_cast<HWND>(GetIEditor()->GetEnv()->pRenderer->GetCurrentContextHWND());
|
||||
previous.renderCamera = GetIEditor()->GetEnv()->pRenderer->GetCamera();
|
||||
previous.systemCamera = GetISystem()->GetViewCamera();
|
||||
previous.isMainViewport = GetIEditor()->GetEnv()->pRenderer->IsCurrentContextMainVP();
|
||||
m_previousContexts.push_back(previous);
|
||||
}
|
||||
|
||||
void QViewport::SetCurrentContext()
|
||||
{
|
||||
StorePreviousContext();
|
||||
|
||||
if (m_camera.get() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HWND windowHandle = reinterpret_cast<HWND>(QWidget::winId());
|
||||
GetIEditor()->GetEnv()->pRenderer->SetCurrentContext(windowHandle);
|
||||
GetIEditor()->GetEnv()->pRenderer->ChangeViewport(0, 0, m_width, m_height);
|
||||
GetIEditor()->GetEnv()->pRenderer->SetCamera(*m_camera);
|
||||
GetIEditor()->GetEnv()->pSystem->SetViewCamera(*m_camera);
|
||||
}
|
||||
|
||||
void QViewport::RestorePreviousContext()
|
||||
{
|
||||
if (m_previousContexts.empty())
|
||||
{
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
SPreviousContext x = m_previousContexts.back();
|
||||
m_previousContexts.pop_back();
|
||||
GetIEditor()->GetEnv()->pRenderer->SetCurrentContext(x.window);
|
||||
GetIEditor()->GetEnv()->pRenderer->ChangeViewport(0, 0, x.width, x.height, x.isMainViewport);
|
||||
GetIEditor()->GetEnv()->pRenderer->SetCamera(x.renderCamera);
|
||||
GetIEditor()->GetEnv()->pSystem->SetViewCamera(x.systemCamera);
|
||||
}
|
||||
|
||||
void QViewport::Serialize(IArchive& ar)
|
||||
{
|
||||
if (!ar.IsEdit())
|
||||
@@ -720,45 +581,6 @@ void QViewport::RenderInternal()
|
||||
{
|
||||
}
|
||||
|
||||
void QViewport::GetImageOffscreen(CImageEx& image, const QSize& customSize)
|
||||
{
|
||||
if ((m_width == 0) || (m_height == 0))
|
||||
{
|
||||
// This can occur, for example, if the material editor window is sized to zero OR
|
||||
// if it is docked as a tab in another view pane window and is not the active tab when the editor starts.
|
||||
image.Allocate(1, 1);
|
||||
image.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer* renderer = GetIEditor()->GetRenderer();
|
||||
|
||||
renderer->EnableSwapBuffers(false);
|
||||
RenderInternal();
|
||||
renderer->EnableSwapBuffers(true);
|
||||
|
||||
int w;
|
||||
int h;
|
||||
|
||||
if (customSize.isValid())
|
||||
{
|
||||
w = customSize.width();
|
||||
h = customSize.height();
|
||||
}
|
||||
else
|
||||
{
|
||||
w = width();
|
||||
h = height();
|
||||
}
|
||||
|
||||
image.Allocate(w, h);
|
||||
|
||||
// the renderer will read the frame buffer of the current render context, so we need to set ours as the current before we execute this command.
|
||||
SetCurrentContext();
|
||||
renderer->ReadFrameBufferFast(image.GetData(), w, h);
|
||||
RestorePreviousContext();
|
||||
}
|
||||
|
||||
void QViewport::SetWindowTitle(const AZStd::string& title)
|
||||
{
|
||||
// Do not support the WindowRequestBus changing the editor window title
|
||||
@@ -1022,12 +844,6 @@ void QViewport::resizeEvent(QResizeEvent* ev)
|
||||
m_width = cx;
|
||||
m_height = cy;
|
||||
|
||||
// We queue the window resize event in case the windows is hidden.
|
||||
// If the QWidget is hidden, the native windows does not resize and the
|
||||
// swapchain may have the incorrect size. We need to wait
|
||||
// until it's visible to trigger the resize event.
|
||||
m_resizeWindowEvent = true;
|
||||
|
||||
GetIEditor()->GetEnv()->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, cx, cy);
|
||||
SignalUpdate();
|
||||
Update();
|
||||
@@ -1035,18 +851,9 @@ void QViewport::resizeEvent(QResizeEvent* ev)
|
||||
|
||||
void QViewport::showEvent(QShowEvent* ev)
|
||||
{
|
||||
// force a context create once we're shown
|
||||
// This must be queued, as the showEvent is sent before the widget is actually shown, not after
|
||||
QMetaObject::invokeMethod(this, "ForceRebuildRenderContext", Qt::QueuedConnection);
|
||||
|
||||
QWidget::showEvent(ev);
|
||||
}
|
||||
|
||||
void QViewport::ForceRebuildRenderContext()
|
||||
{
|
||||
CreateRenderContext();
|
||||
}
|
||||
|
||||
void QViewport::moveEvent(QMoveEvent* ev)
|
||||
{
|
||||
QWidget::moveEvent(ev);
|
||||
@@ -1058,11 +865,6 @@ bool QViewport::event(QEvent* ev)
|
||||
{
|
||||
bool result = QWidget::event(ev);
|
||||
|
||||
if (ev->type() == QEvent::WinIdChange)
|
||||
{
|
||||
CreateRenderContext();
|
||||
}
|
||||
|
||||
if (ev->type() == QEvent::ShortcutOverride)
|
||||
{
|
||||
// When a shortcut is matched, Qt's event processing sends out a shortcut override event
|
||||
|
||||
@@ -104,7 +104,6 @@ public:
|
||||
int Width() const;
|
||||
int Height() const;
|
||||
void SetSize(const QSize& size);
|
||||
void GetImageOffscreen(CImageEx& image, const QSize& customSize);
|
||||
|
||||
// WindowRequestBus::Handler... (handler moved to cpp to resolve link issues in unity builds)
|
||||
void SetWindowTitle(const AZStd::string& title);
|
||||
@@ -119,7 +118,6 @@ public slots:
|
||||
void Update();
|
||||
protected slots:
|
||||
void RenderInternal();
|
||||
void ForceRebuildRenderContext();
|
||||
signals:
|
||||
void SignalPreRender(const SRenderContext&);
|
||||
void SignalRender(const SRenderContext&);
|
||||
@@ -146,12 +144,6 @@ protected:
|
||||
private:
|
||||
struct SPrivate;
|
||||
|
||||
bool CreateRenderContext();
|
||||
void DestroyRenderContext();
|
||||
void StorePreviousContext();
|
||||
protected:
|
||||
void SetCurrentContext();
|
||||
void RestorePreviousContext();
|
||||
private:
|
||||
void UpdateBackgroundColor();
|
||||
|
||||
@@ -198,6 +190,4 @@ private:
|
||||
std::vector<QViewportConsumer*> m_consumers;
|
||||
AZStd::unique_ptr<QViewportRequests> m_viewportRequests;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
HWND m_lastHwnd = 0;
|
||||
bool m_resizeWindowEvent = false;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,6 @@ set(FILES
|
||||
EditorCommon.rc
|
||||
EditorCommon.qrc
|
||||
EditorCommonAPI.h
|
||||
ManipScene.cpp
|
||||
ManipScene.h
|
||||
moc.cpp
|
||||
QViewportConsumer.h
|
||||
TimelineContent.h
|
||||
|
||||
@@ -13,11 +13,9 @@
|
||||
|
||||
#include "EditorCommon_precompiled.h"
|
||||
#include <QViewport.h>
|
||||
#include <ManipScene.h>
|
||||
#include <Timeline.h>
|
||||
#include <CurveEditor.h>
|
||||
|
||||
#include <moc_QViewport.cpp>
|
||||
#include <moc_ManipScene.cpp>
|
||||
#include <moc_Timeline.cpp>
|
||||
#include <moc_CurveEditor.cpp>
|
||||
|
||||
Reference in New Issue
Block a user