[ATOM-14477] Add clone function to model and/or model asset (#135)

* Added clone methods for the buffer, model lod and model assets.
* Cloning works via the creators.
* Mesh handle/instance now knows about the model asset it originated from as well as the cloned model asset that we need for instancing until instancing works without the dependencies to the asset ids.
* MeshComponentRequestBus returns the original asset id and the model asset. If you need access to the clone, go by the model.
* Cloth component mesh now gettings its model asset from the model as it needs to work on the clone.
* Moved the requires cloning function from the mesh loader in the mesh feature processor to the mesh component controller.
* As we need the model asset to be loaded before we can check if it requires cloning or not, we couldn't pass in a bool from the controller but had to use a callback.
* Using asset hint instead of asset id for the model lod asset creator error.
* Storing a map of source buffer asset ids and the actual cloned buffer assets rather than just their ids.
* Using the buffer assets from the new map directly and removed the search process in the mesh loop where the asset views are created.
* Fixed the vegetation mocks.
* Using the actor's mesh asset when emitting the on model ready event for the mesh component notification bus.
* Mesh components notifications connection policy changed to adapt to cloned model asset.
* Handling empty meshes in model lod asset creator.
* Removed the requires cloning callback from the mesh feature processor and made it a parameter to the acquire mesh function
* Fixing mocks and unit tests
This commit is contained in:
Benjamin Jillich
2021-04-23 18:33:00 +02:00
committed by GitHub
parent e772afa06e
commit 0fa00a117c
18 changed files with 651 additions and 288 deletions
@@ -61,8 +61,15 @@ namespace AZ
//! Otherwise false is returned and result is left untouched.
bool End(Data::Asset<BufferAsset>& result);
private:
//! Clone the given source buffer asset.
//! @param sourceAsset The source buffer asset to clone.
//! @param clonedResult The resulting, cloned buffer asset.
//! @param inOutLastCreatedAssetId The asset id from the model lod asset that owns the cloned buffer asset. The sub id will be increased and
//! used as the asset id for the cloned asset.
//! @result True in case the asset got cloned successfully, false in case an error happened and the clone process got cancelled.
static bool Clone(const Data::Asset<BufferAsset>& sourceAsset, Data::Asset<BufferAsset>& clonedResult, Data::AssetId& inOutLastCreatedAssetId);
private:
bool ValidateBuffer();
};
} // namespace RPI
@@ -41,6 +41,13 @@ namespace AZ
//! Otherwise false is returned and result is left untouched.
bool End(Data::Asset<ModelAsset>& result);
//! Clone the given source model asset.
//! @param sourceAsset The source model asset to clone.
//! @param clonedResult The resulting, cloned model lod asset.
//! @param cloneAssetId The asset id to assign to the cloned model asset
//! @result True in case the asset got cloned successfully, false in case an error happened and the clone process got cancelled.
static bool Clone(const Data::Asset<ModelAsset>& sourceAsset, Data::Asset<ModelAsset>& clonedResult, const Data::AssetId& cloneAssetId);
private:
AZ::Aabb m_modelAabb;
};
@@ -75,6 +75,14 @@ namespace AZ
//! Finalizes the ModelLodAsset and assigns ownership of the asset to result if successful, otherwise returns false and result is left untouched.
bool End(Data::Asset<ModelLodAsset>& result);
//! Clone the given source model lod asset.
//! @param sourceAsset The source model lod asset to clone.
//! @param clonedResult The resulting, cloned model lod asset.
//! @param inOutLastCreatedAssetId The asset id from the model asset that owns the cloned model lod asset. The sub id will be increased and
//! used as the asset id for the cloned asset.
//! @result True in case the asset got cloned successfully, false in case an error happened and the clone process got cancelled.
static bool Clone(const Data::Asset<ModelLodAsset>& sourceAsset, Data::Asset<ModelLodAsset>& clonedResult, Data::AssetId& inOutLastCreatedAssetId);
private:
bool m_meshBegan = false;