Merge branch 'dev' into Atom/antonmic/SrgDebugImprovements
This commit is contained in:
@@ -90,8 +90,8 @@ namespace AZ
|
||||
private:
|
||||
Model() = default;
|
||||
|
||||
static Data::Instance<Model> CreateInternal(ModelAsset& modelAsset);
|
||||
RHI::ResultCode Init(ModelAsset& modelAsset);
|
||||
static Data::Instance<Model> CreateInternal(const Data::Asset<ModelAsset>& modelAsset);
|
||||
RHI::ResultCode Init(const Data::Asset<ModelAsset>& modelAsset);
|
||||
|
||||
AZStd::fixed_vector<Data::Instance<ModelLod>, ModelLodAsset::LodCountMax> m_lods;
|
||||
Data::Asset<ModelAsset> m_modelAsset;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <Atom/RHI.Reflect/Limits.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Model/ModelLodAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
|
||||
#include <AtomCore/std/containers/array_view.h>
|
||||
#include <AtomCore/std/containers/vector_set.h>
|
||||
@@ -72,6 +73,8 @@ namespace AZ
|
||||
RHI::IndexBufferView m_indexBufferView;
|
||||
|
||||
StreamInfoList m_streamInfo;
|
||||
|
||||
ModelMaterialSlot::StableId m_materialSlotStableId = ModelMaterialSlot::InvalidStableId;
|
||||
|
||||
//! The default material assigned to the mesh by the asset.
|
||||
Data::Instance<Material> m_material;
|
||||
@@ -82,7 +85,7 @@ namespace AZ
|
||||
AZ_INSTANCE_DATA(ModelLod, "{3C796FC9-2067-4E0F-A660-269F8254D1D5}");
|
||||
AZ_CLASS_ALLOCATOR(ModelLod, AZ::SystemAllocator, 0);
|
||||
|
||||
static Data::Instance<ModelLod> FindOrCreate(const Data::Asset<ModelLodAsset>& lodAsset);
|
||||
static Data::Instance<ModelLod> FindOrCreate(const Data::Asset<ModelLodAsset>& lodAsset, const Data::Asset<ModelAsset>& modelAsset);
|
||||
|
||||
~ModelLod() = default;
|
||||
|
||||
@@ -122,8 +125,8 @@ namespace AZ
|
||||
private:
|
||||
ModelLod() = default;
|
||||
|
||||
static Data::Instance<ModelLod> CreateInternal(ModelLodAsset& lodAsset);
|
||||
RHI::ResultCode Init(ModelLodAsset& lodAsset);
|
||||
static Data::Instance<ModelLod> CreateInternal(const Data::Asset<ModelLodAsset>& lodAsset, const AZStd::any* modelAssetAny);
|
||||
RHI::ResultCode Init(const Data::Asset<ModelLodAsset>& lodAsset, const Data::Asset<ModelAsset>& modelAsset);
|
||||
|
||||
bool SetMeshInstanceData(
|
||||
const ModelLodAsset::Mesh::StreamBufferInfo& streamBufferInfo,
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace AZ
|
||||
|
||||
//! Returns the model-space axis aligned bounding box
|
||||
const AZ::Aabb& GetAabb() const;
|
||||
|
||||
//! Returns the list of all ModelMaterialSlot's for the model, across all LODs.
|
||||
const ModelMaterialSlotMap& GetMaterialSlots() const;
|
||||
|
||||
//! Find a material slot with the given stableId, or returns an invalid slot if it isn't found.
|
||||
const ModelMaterialSlot& FindMaterialSlot(uint32_t stableId) const;
|
||||
|
||||
//! Returns the number of Lods in the model
|
||||
size_t GetLodCount() const;
|
||||
@@ -97,6 +103,13 @@ namespace AZ
|
||||
volatile mutable bool m_isKdTreeCalculationRunning = false;
|
||||
mutable AZStd::mutex m_kdTreeLock;
|
||||
mutable AZStd::optional<AZStd::size_t> m_modelTriangleCount;
|
||||
|
||||
// Lists all of the material slots that are used by this LOD.
|
||||
// Note the same slot can appear in multiple LODs in the model, so that LODs don't have to refer back to the model asset.
|
||||
ModelMaterialSlotMap m_materialSlots;
|
||||
|
||||
// A default ModelMaterialSlot to be returned upon error conditions.
|
||||
ModelMaterialSlot m_fallbackSlot;
|
||||
|
||||
AZStd::size_t CalculateTriangleCount() const;
|
||||
};
|
||||
|
||||
@@ -29,6 +29,10 @@ namespace AZ
|
||||
|
||||
//! Assigns a name to the model
|
||||
void SetName(AZStd::string_view name);
|
||||
|
||||
//! Adds a new material slot to the asset.
|
||||
//! If a slot with the same stable ID already exists, it will be replaced.
|
||||
void AddMaterialSlot(const ModelMaterialSlot& materialSlot);
|
||||
|
||||
//! Adds a Lod to the model.
|
||||
void AddLodAsset(Data::Asset<ModelLodAsset>&& lodAsset);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <Atom/RPI.Reflect/Buffer/BufferAssetView.h>
|
||||
#include <Atom/RPI.Reflect/Buffer/BufferAsset.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelMaterialSlot.h>
|
||||
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Math/Aabb.h>
|
||||
@@ -84,8 +85,9 @@ namespace AZ
|
||||
//! Returns the number of indices in this mesh
|
||||
uint32_t GetIndexCount() const;
|
||||
|
||||
//! Returns the reference to material asset used by this mesh
|
||||
const Data::Asset <MaterialAsset>& GetMaterialAsset() const;
|
||||
//! Returns the ID of the material slot used by this mesh.
|
||||
//! This maps into the ModelAsset's material slot list.
|
||||
ModelMaterialSlot::StableId GetMaterialSlotId() const;
|
||||
|
||||
//! Returns the name of this mesh
|
||||
const AZ::Name& GetName() const;
|
||||
@@ -124,7 +126,9 @@ namespace AZ
|
||||
AZ::Name m_name;
|
||||
AZ::Aabb m_aabb = AZ::Aabb::CreateNull();
|
||||
|
||||
Data::Asset<MaterialAsset> m_materialAsset{ Data::AssetLoadBehavior::PreLoad };
|
||||
// Identifies the material slot that is used by this mesh.
|
||||
// References material slot in the ModelAsset that owns this mesh; see ModelAsset::FindMaterialSlot().
|
||||
ModelMaterialSlot::StableId m_materialSlotId = ModelMaterialSlot::InvalidStableId;
|
||||
|
||||
// Both the buffer in m_indexBufferAssetView and the buffers in m_streamBufferInfo
|
||||
// may point to either unique buffers for the mesh or to consolidated
|
||||
@@ -147,7 +151,7 @@ namespace AZ
|
||||
private:
|
||||
AZStd::vector<Mesh> m_meshes;
|
||||
AZ::Aabb m_aabb = AZ::Aabb::CreateNull();
|
||||
|
||||
|
||||
// These buffers owned by the lod are the consolidated super buffers.
|
||||
// Meshes may either have views into these buffers or they may own
|
||||
// their own buffers.
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/Model/ModelLodAsset.h>
|
||||
#include <Atom/RPI.Reflect/AssetCreator.h>
|
||||
|
||||
@@ -45,9 +46,9 @@ namespace AZ
|
||||
//! Begin and BeginMesh must be called first.
|
||||
void SetMeshAabb(AZ::Aabb&& aabb);
|
||||
|
||||
//! Sets the material asset for the current SubMesh.
|
||||
//! Sets the ID of the model's material slot that this mesh uses.
|
||||
//! Begin and BeginMesh must be called first
|
||||
void SetMeshMaterialAsset(const Data::Asset<MaterialAsset>& materialAsset);
|
||||
void SetMeshMaterialSlot(ModelMaterialSlot::StableId id);
|
||||
|
||||
//! Sets the given BufferAssetView to the current SubMesh as the index buffer.
|
||||
//! Begin and BeginMesh must be called first
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class ReflectContext;
|
||||
|
||||
namespace RPI
|
||||
{
|
||||
//! Use by model assets to identify a logical material slot.
|
||||
//! Each slot has a unique ID, a name, and a default material. Each mesh in model will reference a single ModelMaterialSlot.
|
||||
//! Other classes like MeshFeatureProcessor and MaterialComponent can override the material associated with individual slots
|
||||
//! to alter the default appearance of the mesh.
|
||||
struct ModelMaterialSlot
|
||||
{
|
||||
AZ_TYPE_INFO(ModelMaterialSlot, "{0E88A62A-D83D-4C1B-8DE7-CE972B8124B5}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
using StableId = uint32_t;
|
||||
static const StableId InvalidStableId;
|
||||
|
||||
//! This ID must have a consistent value when the asset is reprocessed by the asset pipeline, and must be unique within the ModelLodAsset.
|
||||
//! In practice, this set using the MaterialUid from SceneAPI. See ModelAssetBuilderComponent::CreateMesh.
|
||||
StableId m_stableId = InvalidStableId;
|
||||
|
||||
Name m_displayName; //!< The name of the slot as displayed to the user in UI. (Using Name instead of string for fast copies)
|
||||
|
||||
Data::Asset<MaterialAsset> m_defaultMaterialAsset{ Data::AssetLoadBehavior::PreLoad }; //!< The material that will be applied to this slot by default.
|
||||
};
|
||||
|
||||
using ModelMaterialSlotMap = AZStd::unordered_map<ModelMaterialSlot::StableId, ModelMaterialSlot>;
|
||||
|
||||
} //namespace RPI
|
||||
} // namespace AZ
|
||||
Reference in New Issue
Block a user