Integrating github/staging through commit ab87ed9
This commit is contained in:
@@ -56,18 +56,23 @@ namespace NvCloth
|
||||
return;
|
||||
}
|
||||
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
AZ::Render::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
|
||||
void ClothComponent::Deactivate()
|
||||
{
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusDisconnect();
|
||||
AZ::Render::MeshComponentNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_clothComponentMesh.reset();
|
||||
}
|
||||
|
||||
void ClothComponent::OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
void ClothComponent::OnModelReady(
|
||||
const AZ::Data::Asset<AZ::RPI::ModelAsset>& asset,
|
||||
[[maybe_unused]] const AZ::Data::Instance<AZ::RPI::Model>& model)
|
||||
{
|
||||
// [TODO LYN-1886] Remove this call once OnModelDestroyed is part of MeshComponentNotificationBus
|
||||
OnModelDestroyed();
|
||||
|
||||
if (!asset.IsReady())
|
||||
{
|
||||
return;
|
||||
@@ -76,7 +81,7 @@ namespace NvCloth
|
||||
m_clothComponentMesh = AZStd::make_unique<ClothComponentMesh>(GetEntityId(), m_config);
|
||||
}
|
||||
|
||||
void ClothComponent::OnMeshDestroyed()
|
||||
void ClothComponent::OnModelDestroyed()
|
||||
{
|
||||
m_clothComponentMesh.reset();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h>
|
||||
|
||||
#include <Components/ClothConfiguration.h>
|
||||
#include <Components/ClothComponentMesh/ClothComponentMesh.h>
|
||||
@@ -24,7 +24,7 @@ namespace NvCloth
|
||||
//! Class for runtime Cloth Component.
|
||||
class ClothComponent
|
||||
: public AZ::Component
|
||||
, public LmbrCentral::MeshComponentNotificationBus::Handler
|
||||
, public AZ::Render::MeshComponentNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(ClothComponent, "{AC9B8FA0-A6DA-4377-8219-25BA7E4A22E9}");
|
||||
@@ -46,9 +46,9 @@ namespace NvCloth
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// LmbrCentral::MeshComponentNotificationBus::Handler overrides ...
|
||||
void OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset) override;
|
||||
void OnMeshDestroyed() override;
|
||||
// AZ::Render::MeshComponentNotificationBus::Handler overrides ...
|
||||
void OnModelReady(const AZ::Data::Asset<AZ::RPI::ModelAsset>& modelAsset, const AZ::Data::Instance<AZ::RPI::Model>& model) override;
|
||||
void OnModelDestroyed(); // [TODO LYN-1886] Add override once it's part of MeshComponentNotificationBus
|
||||
|
||||
private:
|
||||
ClothConfiguration m_config;
|
||||
|
||||
@@ -387,9 +387,14 @@ namespace NvCloth
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Cloth);
|
||||
|
||||
if (!m_cloth)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate normals of the cloth particles (simplified mesh).
|
||||
AZStd::vector<AZ::Vector3> normals;
|
||||
bool normalsCalculated =
|
||||
[[maybe_unused]] bool normalsCalculated =
|
||||
AZ::Interface<ITangentSpaceHelper>::Get()->CalculateNormals(particles, m_cloth->GetInitialIndices(), normals);
|
||||
AZ_Assert(normalsCalculated, "Cloth component mesh failed to calculate normals.");
|
||||
|
||||
@@ -416,7 +421,7 @@ namespace NvCloth
|
||||
}
|
||||
|
||||
// Calculate tangents and bitangents for the full mesh.
|
||||
bool tangentsAndBitangentsCalculated =
|
||||
[[maybe_unused]] bool tangentsAndBitangentsCalculated =
|
||||
AZ::Interface<ITangentSpaceHelper>::Get()->CalculateTangentsAndBitagents(
|
||||
renderData.m_particles, m_meshClothInfo.m_indices,
|
||||
m_meshClothInfo.m_uvs, renderData.m_normals,
|
||||
@@ -444,9 +449,9 @@ namespace NvCloth
|
||||
const auto& renderBitangents = renderData.m_bitangents;
|
||||
|
||||
AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset;
|
||||
AZ::Render::MeshComponentRequestBus::EventResult(modelAsset, m_entityId,
|
||||
&AZ::Render::MeshComponentRequestBus::Events::GetModelAsset);
|
||||
if (!modelAsset.GetId().IsValid())
|
||||
AZ::Render::MeshComponentRequestBus::EventResult(
|
||||
modelAsset, m_entityId, &AZ::Render::MeshComponentRequestBus::Events::GetModelAsset);
|
||||
if (!modelAsset.IsReady())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace NvCloth
|
||||
|
||||
void UpdateConfiguration(AZ::EntityId entityId, const ClothConfiguration& config);
|
||||
|
||||
void CopyRenderDataToModel();
|
||||
|
||||
protected:
|
||||
// Functions used to setup and tear down cloth component mesh
|
||||
void Setup(AZ::EntityId entityId, const ClothConfiguration& config);
|
||||
@@ -85,7 +87,6 @@ namespace NvCloth
|
||||
void UpdateSimulationSkinning();
|
||||
void UpdateSimulationConstraints();
|
||||
void UpdateRenderData(const AZStd::vector<SimParticleFormat>& particles);
|
||||
void CopyRenderDataToModel();
|
||||
|
||||
bool CreateCloth();
|
||||
void ApplyConfigurationToCloth();
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace NvCloth
|
||||
|
||||
if (!m_separationConstraints.empty())
|
||||
{
|
||||
bool normalsCalculated = AZ::Interface<ITangentSpaceHelper>::Get()->CalculateNormals(simParticles, simIndices, m_normals);
|
||||
[[maybe_unused]] bool normalsCalculated = AZ::Interface<ITangentSpaceHelper>::Get()->CalculateNormals(simParticles, simIndices, m_normals);
|
||||
AZ_Assert(normalsCalculated, "Cloth constraints failed to calculate normals.");
|
||||
|
||||
CalculateSeparationConstraints();
|
||||
|
||||
@@ -434,20 +434,25 @@ namespace NvCloth
|
||||
{
|
||||
AzToolsFramework::Components::EditorComponentBase::Activate();
|
||||
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
AZ::Render::MeshComponentNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
|
||||
void EditorClothComponent::Deactivate()
|
||||
{
|
||||
LmbrCentral::MeshComponentNotificationBus::Handler::BusDisconnect();
|
||||
AZ::Render::MeshComponentNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
AzToolsFramework::Components::EditorComponentBase::Deactivate();
|
||||
|
||||
m_clothComponentMesh.reset();
|
||||
}
|
||||
|
||||
void EditorClothComponent::OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
void EditorClothComponent::OnModelReady(
|
||||
const AZ::Data::Asset<AZ::RPI::ModelAsset>& asset,
|
||||
[[maybe_unused]] const AZ::Data::Instance<AZ::RPI::Model>& model)
|
||||
{
|
||||
// [TODO LYN-1886] Remove this call once OnModelDestroyed is part of MeshComponentNotificationBus
|
||||
OnModelDestroyed();
|
||||
|
||||
if (!asset.IsReady())
|
||||
{
|
||||
return;
|
||||
@@ -513,7 +518,7 @@ namespace NvCloth
|
||||
AzToolsFramework::Refresh_EntireTree);
|
||||
}
|
||||
|
||||
void EditorClothComponent::OnMeshDestroyed()
|
||||
void EditorClothComponent::OnModelDestroyed()
|
||||
{
|
||||
m_previousMeshNode = m_config.m_meshNode;
|
||||
|
||||
@@ -537,21 +542,17 @@ namespace NvCloth
|
||||
|
||||
AZ::u32 EditorClothComponent::OnSimulatedInEditorToggled()
|
||||
{
|
||||
m_clothComponentMesh.reset();
|
||||
|
||||
m_simulateInEditor = !m_simulateInEditor;
|
||||
|
||||
if (m_simulateInEditor)
|
||||
{
|
||||
m_clothComponentMesh = AZStd::make_unique<ClothComponentMesh>(GetEntityId(), m_config);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Force MeshComponent to reload current mesh asset in order to restore original mesh
|
||||
AZ::Data::Asset<AZ::Data::AssetData> meshAsset;
|
||||
LmbrCentral::MeshComponentRequestBus::EventResult(meshAsset, GetEntityId(), &LmbrCentral::MeshComponentRequests::GetMeshAsset);
|
||||
m_clothComponentMesh = AZStd::make_unique<ClothComponentMesh>(GetEntityId(), m_config);
|
||||
|
||||
LmbrCentral::MeshComponentRequestBus::Event(GetEntityId(), &LmbrCentral::MeshComponentRequests::SetMeshAsset, meshAsset.GetId());
|
||||
if (!m_simulateInEditor)
|
||||
{
|
||||
// Since the instance was just created this will restore the model
|
||||
// to its original position before cloth simulation.
|
||||
m_clothComponentMesh->CopyRenderDataToModel();
|
||||
|
||||
m_clothComponentMesh.reset();
|
||||
}
|
||||
|
||||
return AZ::Edit::PropertyRefreshLevels::None;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
|
||||
#include <LmbrCentral/Rendering/MeshComponentBus.h>
|
||||
#include <AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h>
|
||||
|
||||
#include <Components/ClothConfiguration.h>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace NvCloth
|
||||
//! Class for in-editor Cloth Component.
|
||||
class EditorClothComponent
|
||||
: public AzToolsFramework::Components::EditorComponentBase
|
||||
, public LmbrCentral::MeshComponentNotificationBus::Handler
|
||||
, public AZ::Render::MeshComponentNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_EDITOR_COMPONENT(EditorClothComponent, "{2C99B4EF-8A5F-4585-89F9-86D50754DF7E}", AzToolsFramework::Components::EditorComponentBase);
|
||||
@@ -50,9 +50,9 @@ namespace NvCloth
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// LmbrCentral::MeshComponentNotificationBus::Handler overrides ...
|
||||
void OnMeshCreated(const AZ::Data::Asset<AZ::Data::AssetData>& asset) override;
|
||||
void OnMeshDestroyed() override;
|
||||
// AZ::Render::MeshComponentNotificationBus::Handler overrides ...
|
||||
void OnModelReady(const AZ::Data::Asset<AZ::RPI::ModelAsset>& modelAsset, const AZ::Data::Instance<AZ::RPI::Model>& model) override;
|
||||
void OnModelDestroyed(); // [TODO LYN-1886] Add override once it's part of MeshComponentNotificationBus
|
||||
|
||||
private:
|
||||
bool IsSimulatedInEditor() const;
|
||||
|
||||
Reference in New Issue
Block a user