Legacy Mesh component removal
* Removed legacy components * More legacy render component removal * Starting removal of legacy mesh component dependencies * Removed old light components that were allowing Atom test to succeed * Testing increasing the timeout to see if it lets it pass in Jenkins * put original timeout back * reordered components to test if it is component specific or not * Testing disabiling the test to see if we get a green * Fixed the removal of the test to sandbox * Removed Legacy Mesh Component and associated tendrils * Removed some missed references * Fixed some issues with unity builds and ambiguous naming * Addressed review feedback
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include <AzCore/std/sort.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <LmbrCentral/Rendering/MaterialOwnerBus.h>
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <LmbrCentral/Rendering/RenderNodeBus.h>
|
||||
#include <IRenderAuxGeom.h>
|
||||
#include <IViewSystem.h>
|
||||
@@ -518,18 +517,6 @@ namespace ImGui
|
||||
ImGui::EndChild(); // End the "Meshes in Scene" Child
|
||||
}
|
||||
}
|
||||
|
||||
// Check to make sure the Tick Bus Connection status matches the debug enabled flag
|
||||
if (m_meshDebugEnabled && !AZ::TickBus::Handler::BusIsConnected())
|
||||
{
|
||||
// Connect to the Tick Bus
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
else if (!m_meshDebugEnabled && AZ::TickBus::Handler::BusIsConnected())
|
||||
{
|
||||
// Disconnect from the Tick Bus
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// Mesh Mouse Over Helper function
|
||||
@@ -597,81 +584,6 @@ namespace ImGui
|
||||
instanceOptions.m_mousedOverForDraw |= ImGui::IsItemHovered();
|
||||
}
|
||||
|
||||
void ImGuiLYAssetExplorer::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
{
|
||||
// Search through all entities for Asset Components
|
||||
OnTick_FindAssets();
|
||||
|
||||
// Check for all relevant pointers here. ( Actually requires checking all of these for different edge cases! :(
|
||||
if (gEnv && gEnv->pRenderer && gEnv->pSystem &&
|
||||
gEnv->pSystem->GetIViewSystem() && gEnv->pSystem->GetIViewSystem()->GetActiveView() &&
|
||||
gEnv->pSystem->GetIViewSystem()->GetActiveView()->GetCurrentParams())
|
||||
{
|
||||
// Get the Camera View Position from the view system.
|
||||
const Vec3& cameraPosVec3 = gEnv->pSystem->GetIViewSystem()->GetActiveView()->GetCurrentParams()->position;
|
||||
const AZ::Vector3 cameraPos(cameraPosVec3.x, cameraPosVec3.y, cameraPosVec3.z);
|
||||
|
||||
// Loop through all Meshes to draw the appropriate ones!
|
||||
for (const MeshInstanceDisplayList& meshInstanceList : m_meshInstanceDisplayList)
|
||||
{
|
||||
// bunch of different ways to filter results. First check for Mesh and Instance Name Filters...
|
||||
bool displayMesh = true;
|
||||
if (m_meshNameFilter)
|
||||
{
|
||||
displayMesh &= meshInstanceList.m_passesFilter;
|
||||
}
|
||||
if (m_entityNameFilter)
|
||||
{
|
||||
displayMesh &= meshInstanceList.m_childrenPassFilter;
|
||||
}
|
||||
|
||||
// ..Mouse Overs and Selection Filters should override other filters, so do it after.. Mouse Over THEN Selection Filter for precedence.
|
||||
if (m_anyMousedOverForDraw)
|
||||
{
|
||||
displayMesh = meshInstanceList.m_mousedOverForDraw || meshInstanceList.m_childMousedOverForDraw;
|
||||
}
|
||||
else if (m_selectionFilter)
|
||||
{
|
||||
displayMesh = meshInstanceList.m_selectedForDraw;
|
||||
for (const auto& meshInstance : meshInstanceList.m_instanceOptionMap)
|
||||
{
|
||||
displayMesh |= meshInstance.second.m_selectedForDraw;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayMesh)
|
||||
{
|
||||
for (const auto& meshInstance : meshInstanceList.m_instanceOptionMap)
|
||||
{
|
||||
AZ::Data::Asset<AZ::Data::AssetData> meshAsset;
|
||||
LmbrCentral::MeshComponentRequestBus::EventResult(meshAsset, meshInstance.first, &LmbrCentral::MeshComponentRequests::GetMeshAsset);
|
||||
// See if we pass name filter first..
|
||||
bool displayEntity = true;
|
||||
if (m_entityNameFilter)
|
||||
{
|
||||
displayEntity = meshInstance.second.m_passesFilter;
|
||||
}
|
||||
|
||||
// ..Mouse Overs and Selection Filters should override other filters, so do it after.. Mouse Over THEN Selection Filter for precedence.
|
||||
if (m_anyMousedOverForDraw)
|
||||
{
|
||||
displayEntity = meshInstance.second.m_mousedOverForDraw || meshInstanceList.m_mousedOverForDraw;
|
||||
}
|
||||
else if (m_selectionFilter)
|
||||
{
|
||||
displayEntity = meshInstance.second.m_selectedForDraw | meshInstanceList.m_selectedForDraw;
|
||||
}
|
||||
|
||||
if (displayEntity)
|
||||
{
|
||||
OnTick_DrawEntity(meshInstance.first, meshAsset.GetId(), gEnv->pRenderer, cameraPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MeshInstanceDisplayList& ImGuiLYAssetExplorer::FindOrCreateMeshInstanceList(const char* meshName)
|
||||
{
|
||||
// Walk the list and see if an entry for this mesh exists already. If we find one, return it!
|
||||
@@ -696,250 +608,6 @@ namespace ImGui
|
||||
m_meshInstanceDisplayList.push_back(meshList);
|
||||
return m_meshInstanceDisplayList.back();
|
||||
}
|
||||
|
||||
// Scan the scene for Meshes!
|
||||
void ImGuiLYAssetExplorer::OnTick_FindAssets()
|
||||
{
|
||||
// Retrieve Id map from game entity context (editor->runtime).
|
||||
AzFramework::EntityContextId gameContextId = AzFramework::EntityContextId::CreateNull();
|
||||
AzFramework::GameEntityContextRequestBus::BroadcastResult(gameContextId, &AzFramework::GameEntityContextRequests::GetGameEntityContextId);
|
||||
|
||||
// Get the Root Slice Component
|
||||
AZ::SliceComponent* rootSliceComponent;
|
||||
AzFramework::SliceEntityOwnershipServiceRequestBus::EventResult(rootSliceComponent, gameContextId,
|
||||
&AzFramework::SliceEntityOwnershipServiceRequests::GetRootSlice);
|
||||
|
||||
if (rootSliceComponent)
|
||||
{
|
||||
// Get an unordered_set of all EntityIds in the slice
|
||||
AZ::SliceComponent::EntityIdSet entityIds;
|
||||
rootSliceComponent->GetEntityIds(entityIds);
|
||||
|
||||
// Loop through Mesh Map and "un-verify" them
|
||||
for (MeshInstanceDisplayList& meshInstanceList : m_meshInstanceDisplayList)
|
||||
{
|
||||
for (auto& meshInstance : meshInstanceList.m_instanceOptionMap)
|
||||
{
|
||||
meshInstance.second.m_verifiedThisFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = entityIds.begin(); it != entityIds.end(); it++)
|
||||
{
|
||||
AZ::Data::Asset<AZ::Data::AssetData> meshAsset;
|
||||
LmbrCentral::MeshComponentRequestBus::EventResult(meshAsset, *it, &LmbrCentral::MeshComponentRequests::GetMeshAsset);
|
||||
|
||||
if (meshAsset.IsReady())
|
||||
{
|
||||
// Get the Asset Info so we can get the mesh path
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, meshAsset.GetId());
|
||||
|
||||
AZStd::string meshPath = assetInfo.m_relativePath;
|
||||
AZStd::to_lower(meshPath.begin(), meshPath.end());
|
||||
// Save off this mesh instance into the instance map
|
||||
MeshInstanceDisplayList& displayList = FindOrCreateMeshInstanceList(meshPath.c_str());
|
||||
if (!displayList.m_instanceOptionMap.count(*it))
|
||||
{
|
||||
// Get the Entity Name, for easy searching later
|
||||
AZStd::string entityName;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(entityName, &AZ::ComponentApplicationBus::Events::GetEntityName, *it);
|
||||
|
||||
// Init the instance entry and options
|
||||
MeshInstanceOptions& meshOptions = displayList.m_instanceOptionMap[*it];
|
||||
meshOptions.m_verifiedThisFrame = true;
|
||||
meshOptions.m_passesFilter = true;
|
||||
meshOptions.m_selectedForDraw = false;
|
||||
meshOptions.m_mousedOverForDraw = false;
|
||||
meshOptions.m_instanceLabel = AZStd::string::format("%s%s", (*it).ToString().c_str(), entityName.c_str());
|
||||
AZStd::to_lower(meshOptions.m_instanceLabel.begin(), meshOptions.m_instanceLabel.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
displayList.m_instanceOptionMap[*it].m_verifiedThisFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through Mesh Map again and remove any "un-verify"-ed entries!
|
||||
for (auto meshInstanceListIter = m_meshInstanceDisplayList.begin(); meshInstanceListIter != m_meshInstanceDisplayList.end();)
|
||||
{
|
||||
for (auto meshInstanceIter = (*meshInstanceListIter).m_instanceOptionMap.begin(); meshInstanceIter != (*meshInstanceListIter).m_instanceOptionMap.end();)
|
||||
{
|
||||
if (!(*meshInstanceIter).second.m_verifiedThisFrame)
|
||||
{
|
||||
// erase this instance from the map and set the iterator correctly.
|
||||
meshInstanceIter = (*meshInstanceListIter).m_instanceOptionMap.erase(meshInstanceIter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// increment the iterator
|
||||
meshInstanceIter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the Mesh Entry if there are no instances remaining
|
||||
if ((*meshInstanceListIter).m_instanceOptionMap.empty())
|
||||
{
|
||||
meshInstanceListIter = m_meshInstanceDisplayList.erase(meshInstanceListIter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// increment the iterator
|
||||
meshInstanceListIter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We know we want to draw this Entity/Mesh ( depending on distance from Cam ).. so draw!
|
||||
void ImGuiLYAssetExplorer::OnTick_DrawEntity(const AZ::EntityId& entity, const AZ::Data::AssetId& assetId, IRenderer* renderer, const AZ::Vector3& cameraPos)
|
||||
{
|
||||
// Get the Entity Position so we can see how far from the camera we are.
|
||||
AZ::Vector3 worldPos = AZ::Vector3::CreateZero();
|
||||
AZ::TransformBus::EventResult(worldPos, entity, &AZ::TransformBus::Events::GetWorldTranslation);
|
||||
|
||||
// Get Our Distance From The Camera! ( Used just for draw alpha value )
|
||||
float distFromCamera = m_distanceFilter_far + 1.0f; // Default to just outside camera view ( i.e. Don't draw )
|
||||
if (m_anyMousedOverForDraw || m_selectionFilter || !m_distanceFilter)
|
||||
{
|
||||
// If we have either the Selection Filter or Mouse Over state on or the distance filter is off, and we made it this far, we are the lucky selected one! Draw ourselves by setting dist to 0.0f
|
||||
distFromCamera = 0.0;
|
||||
}
|
||||
else if (m_distanceFilter)
|
||||
{
|
||||
// Distance filter is on and we aren't selected, so actually find the distance from the camera
|
||||
distFromCamera = worldPos.GetDistance(cameraPos);
|
||||
}
|
||||
|
||||
// Only draw things within view distance ( cheese it to zero above to force drawing far things )
|
||||
if (distFromCamera <= m_distanceFilter_far)
|
||||
{
|
||||
// Find an interpolated Alpha.. 1.0f while inside near radius, interp 1.0 -> 0.0 while heading toward far radius
|
||||
float alpha = (distFromCamera <= m_distanceFilter_near) ? 1.0f : (1.0f - ((distFromCamera - m_distanceFilter_near) / (m_distanceFilter_far - m_distanceFilter_near)));
|
||||
|
||||
// The string to hold label text we will build.
|
||||
AZStd::string entityLabel;
|
||||
|
||||
// Grab the Asset Info to get the mesh path name.
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, assetId);
|
||||
|
||||
// Start the label with either the EntName and Mesh, or just Mesh
|
||||
if (m_inWorld_label_entityName)
|
||||
{
|
||||
AZ::ComponentApplicationBus::BroadcastResult(entityLabel, &AZ::ComponentApplicationBus::Events::GetEntityName, entity);
|
||||
entityLabel = AZStd::string::format("Entity: %s %s\nMesh: %s", entity.ToString().c_str(), entityLabel.c_str(), assetInfo.m_relativePath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
entityLabel = AZStd::string::format("Mesh: %s", assetInfo.m_relativePath.c_str());
|
||||
}
|
||||
|
||||
// See if we should add the Material!
|
||||
if (m_inWorld_label_materialName)
|
||||
{
|
||||
_smart_ptr<IMaterial> material;
|
||||
LmbrCentral::MaterialOwnerRequestBus::EventResult(material, entity, &LmbrCentral::MaterialOwnerRequests::GetMaterial);
|
||||
if (material)
|
||||
{
|
||||
entityLabel.append(AZStd::string::format("\nMaterial: %s", material->GetName()));
|
||||
}
|
||||
}
|
||||
|
||||
// Get The Render Node for mesh debug draw and Lod Info
|
||||
IRenderNode* renderNode = nullptr;
|
||||
LmbrCentral::RenderNodeRequestBus::EventResult(renderNode, entity, &LmbrCentral::RenderNodeRequests::GetRenderNode);
|
||||
|
||||
if (renderNode != nullptr && renderNode->GetEntityStatObj())
|
||||
{
|
||||
// Debug Draw Mesh
|
||||
if (m_inWorld_debugDrawMesh)
|
||||
{
|
||||
SGeometryDebugDrawInfo dd;
|
||||
dd.color.Set(0.0f, 0.0f, 255.0f, 0.5f * alpha);
|
||||
dd.lineColor.Set(255.0f, 0.0f, 0.0f, 0.75f * alpha);
|
||||
renderNode->GetEntityStatObj()->DebugDraw(dd, 0.2f);
|
||||
}
|
||||
// Draw Total Lods info
|
||||
if (m_inWorld_label_totalLods)
|
||||
{
|
||||
entityLabel.append(AZStd::string::format("\nTotal Lods: %d", renderNode->GetEntityStatObj()->GetLoadedLodsNum()));
|
||||
}
|
||||
// Draw Misc Lod Info
|
||||
if (m_inWorld_label_miscLod)
|
||||
{
|
||||
entityLabel.append(AZStd::string::format("\nFirst Lod Distance: %f", renderNode->GetFirstLodDistance()));
|
||||
float distances[SMeshLodInfo::s_nMaxLodCount];
|
||||
renderNode->GetLodDistances(gEnv->p3DEngine->GetFrameLodInfo(), distances);
|
||||
for (int i = 0; i < SMeshLodInfo::s_nMaxLodCount; i++)
|
||||
{
|
||||
entityLabel.append(AZStd::string::format("\n frameLod: %d - %f", i, distances[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the label in the world
|
||||
if (m_inWorld_drawLabel)
|
||||
{
|
||||
SDrawTextInfo ti;
|
||||
ti.xscale = ti.yscale = m_inWorld_labelTextSize * alpha;
|
||||
ti.flags = eDrawText_FixedSize | eDrawText_Center | eDrawText_800x600;
|
||||
if (m_inWorld_label_framed)
|
||||
{
|
||||
ti.flags |= eDrawText_Framed;
|
||||
}
|
||||
if (m_inWorld_label_monoSpace)
|
||||
{
|
||||
ti.flags |= eDrawText_Monospace;
|
||||
}
|
||||
|
||||
{
|
||||
ti.color[0] = m_inWorld_label_textColor.Value.x;
|
||||
ti.color[1] = m_inWorld_label_textColor.Value.y;
|
||||
ti.color[2] = m_inWorld_label_textColor.Value.z;
|
||||
ti.color[3] = alpha;
|
||||
}
|
||||
Vec3 labelPos(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ() - m_inWorld_originSphereRadius);
|
||||
renderer->DrawTextQueued(labelPos, ti, entityLabel.c_str());
|
||||
}
|
||||
|
||||
// Draw the sphere and/or AABB in the world
|
||||
if (m_inWorld_drawOriginSphere || m_inWorld_drawAABB)
|
||||
{
|
||||
IRenderAuxGeom* pAuxGeom = renderer->GetIRenderAuxGeom();
|
||||
if (pAuxGeom)
|
||||
{
|
||||
const ColorF sphereColor(m_inWorld_label_textColor.Value.x, m_inWorld_label_textColor.Value.y, m_inWorld_label_textColor.Value.z, alpha);
|
||||
Vec3 spherePos(worldPos.GetX(), worldPos.GetY(), worldPos.GetZ());
|
||||
|
||||
// draw a sample sphere
|
||||
SAuxGeomRenderFlags oldFlags = pAuxGeom->GetRenderFlags();
|
||||
SAuxGeomRenderFlags flags = oldFlags;
|
||||
flags.SetDepthWriteFlag(e_DepthWriteOff);
|
||||
flags.SetDepthTestFlag(e_DepthTestOff);
|
||||
flags.SetDrawInFrontMode(e_DrawInFrontOn);
|
||||
flags.SetFillMode(e_FillModeSolid);
|
||||
flags.SetCullMode(e_CullModeNone);
|
||||
pAuxGeom->SetRenderFlags(flags);
|
||||
|
||||
if ( m_inWorld_drawOriginSphere)
|
||||
{
|
||||
pAuxGeom->DrawSphere(spherePos, m_inWorld_originSphereRadius, sphereColor, false);
|
||||
}
|
||||
|
||||
if (m_inWorld_drawAABB && renderNode)
|
||||
{
|
||||
pAuxGeom->DrawAABB(renderNode->GetBBox(), false, sphereColor, EBoundingBoxDrawStyle::eBBD_Extremes_Color_Encoded);
|
||||
}
|
||||
|
||||
// Restore rendering state
|
||||
pAuxGeom->SetRenderFlags(oldFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
} // namespace ImGui
|
||||
|
||||
#endif // IMGUI_ENABLED
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace ImGui
|
||||
|
||||
class ImGuiLYAssetExplorer
|
||||
: public ImGuiAssetExplorerRequestBus::Handler
|
||||
, public AZ::TickBus::Handler
|
||||
|
||||
{
|
||||
public:
|
||||
@@ -61,10 +60,6 @@ namespace ImGui
|
||||
void SetEnabled(bool enabled) override { m_enabled = enabled; m_meshDebugEnabled = enabled; }
|
||||
// -- ImGuiAssetExplorerRequestBus::Handler Interface ----------------------
|
||||
|
||||
// -- AZ::TickBus::Handler Interface ---------------------------------------
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
// -- AZ::TickBus::Handler Interface ---------------------------------------
|
||||
|
||||
// Toggle the menu on and off
|
||||
void ToggleEnabled() { m_enabled = !m_enabled; }
|
||||
|
||||
@@ -117,9 +112,6 @@ namespace ImGui
|
||||
void ImGuiUpdate_DrawMeshMouseOver(MeshInstanceDisplayList& meshDisplayList);
|
||||
void ImGuiUpdate_DrawEntityInstanceMouseOver(MeshInstanceDisplayList& meshDisplayList, AZ::EntityId& entityInstance, AZStd::string& entityName, MeshInstanceOptions& instanceOptions);
|
||||
|
||||
// Helper functions for the OnTick callback
|
||||
void OnTick_DrawEntity(const AZ::EntityId& entity, const AZ::Data::AssetId& assetId, IRenderer* renderer, const AZ::Vector3& cameraPos);
|
||||
void OnTick_FindAssets();
|
||||
};
|
||||
}
|
||||
#endif // IMGUI_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user