5656736db4
-Re-purposed an unused boolean in RPI::Cullable for previous frame's visiblity to instead represent objects that are hidden in the simulation. -Updated MeshFeatureProcessor::SetVisible to set this value on the cullable. -Updated the MeshComponent to handle visiblity changes by not rendering the mesh instead of deactivating and/or reactivating the component. -Updated the AtomActorInstance to handle changes to the visibility from the ActorComponent. Tested by creating two entities with static mesh components, on entity hidden and the other visible. Plus three entities with actor components, one where the actor is visible, one where the entity is visible but the 'render character' setting on the actor component is disabled, and one where the 'render character' setting is enabled, but the entity is not visible. For each of these 5 entities, I added them as 5 loose entities, 5 entities that were children to a parent entity, and a slice with all 5 as children to a parent entity, and tested toggling visibility of the parent entities. For each of these 3 sets of 5 entities, I added them directly to the level, added them all to a layer where the layer was visible, and added them all to a layer where the layer was not visible, and tested toggling the visibility of the layers.
78 lines
3.2 KiB
C++
78 lines
3.2 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
|
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
|
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
|
#include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
|
|
#include <AtomLyIntegration/CommonFeatures/Mesh/MeshComponentConstants.h>
|
|
#include <Mesh/MeshComponent.h>
|
|
|
|
namespace AZ
|
|
{
|
|
namespace Render
|
|
{
|
|
/**
|
|
* In-editor mesh component.
|
|
* Conducts some additional listening and operations to ensure immediate
|
|
* effects when changing fields in the editor.
|
|
*/
|
|
class EditorMeshComponent final
|
|
: public EditorRenderComponentAdapter<MeshComponentController, MeshComponent, MeshComponentConfig>
|
|
, private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
|
|
, private AzFramework::EntityDebugDisplayEventBus::Handler
|
|
, private MeshComponentNotificationBus::Handler
|
|
{
|
|
public:
|
|
using BaseClass = EditorRenderComponentAdapter<MeshComponentController, MeshComponent, MeshComponentConfig>;
|
|
AZ_EDITOR_COMPONENT(AZ::Render::EditorMeshComponent, EditorMeshComponentTypeId, BaseClass);
|
|
|
|
static void Reflect(AZ::ReflectContext* context);
|
|
|
|
EditorMeshComponent() = default;
|
|
explicit EditorMeshComponent(const MeshComponentConfig& config);
|
|
|
|
// AZ::Component overrides ...
|
|
void Activate() override;
|
|
void Deactivate() override;
|
|
|
|
/// Called when you want to change the game asset through code (like when creating components based on assets).
|
|
void SetPrimaryAsset(const AZ::Data::AssetId& assetId) override;
|
|
|
|
private:
|
|
|
|
// EditorComponentSelectionRequestsBus overrides ...
|
|
AZ::Aabb GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo) override;
|
|
bool EditorSelectionIntersectRayViewport(const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src, const AZ::Vector3& dir, float& distance) override;
|
|
bool SupportsEditorRayIntersect() override;
|
|
|
|
// EntityDebugDisplayEventBus overrides ...
|
|
void DisplayEntityViewport(const AzFramework::ViewportInfo&, AzFramework::DebugDisplayRequests&) override;
|
|
|
|
// MeshComponentNotificationBus overrides ...
|
|
void OnModelReady(const Data::Asset<RPI::ModelAsset>& modelAsset, const Data::Instance<RPI::Model>& model) override;
|
|
|
|
// AzToolsFramework::EditorEntityVisibilityNotificationBus::Handler overrides
|
|
void OnEntityVisibilityChanged(bool visibility) override;
|
|
|
|
// AzToolsFramework::Components::EditorComponentAdapter overrides
|
|
bool ShouldActivateController() const override;
|
|
|
|
AZ::u32 OnConfigurationChanged() override;
|
|
|
|
AZ::Crc32 AddEditorMaterialComponent();
|
|
bool HasEditorMaterialComponent() const;
|
|
AZ::u32 GetEditorMaterialComponentVisibility() const;
|
|
|
|
// Flag used for button placement
|
|
bool m_addMaterialComponentFlag = false;
|
|
};
|
|
} // namespace Render
|
|
} // namespace AZ
|