Browse Source

Cleanup, refactoring and additional comments/documentation.

Signed-off-by: Jason Dela Cruz <[email protected]>
Jason Dela Cruz 2 years ago
parent
commit
61e8c5d04e

+ 0 - 1
Gems/O3DE/GeomNodes/Code/Include/GeomNodes/GeomNodesTypeIds.h

@@ -29,7 +29,6 @@ namespace GeomNodes
 
     // Other TypeIds
     inline constexpr const char* GNRenderMeshTypeId = "{4E293CD2-F9E6-417C-92B7-DDAF312F46CF}";
-    inline constexpr const char* GNRenderMeshInterfaceTypeId = "{908CB056-4814-42FF-9D60-2D67A720D829}";
     inline constexpr const char* GeomNodesSystemTypeId = "{23791BF8-D9DE-4827-88D8-37DA39258570}";
     inline constexpr const char* GNPropertyTypeId = "{71904E43-F0A1-45EA-B87F-4CC5234E1E52}";
     inline constexpr const char* GNParamNilTypeId = "{519D98C7-054A-4047-BCEB-28DCD38CFCD4}";

+ 25 - 16
Gems/O3DE/GeomNodes/Code/Source/Editor/Components/EditorGeomNodesComponent.h

@@ -52,25 +52,24 @@ namespace GeomNodes
     private:
 		
     protected:
-        //got this from ScriptEditorComponent
+        //! got this from ScriptEditorComponent
         struct ElementInfo
         {
-            AZ::Uuid m_uuid;                    // Type uuid for the class field that should use this edit data.
-            AZ::Edit::ElementData m_editData;   // Edit metadata (name, description, attribs, etc).
-            bool m_isAttributeOwner;            // True if this ElementInfo owns the internal attributes. We can use a single
-                                                // ElementInfo for more than one class field, but only one owns the Attributes.
-            float m_sortOrder;                  // Sort order of the property as defined by using the "order" attribute, by default the order is FLT_MAX
-                                                // which means alphabetical sort will be used
+            AZ::Uuid m_uuid;                    //! Type uuid for the class field that should use this edit data.
+            AZ::Edit::ElementData m_editData;   //! Edit metadata (name, description, attribs, etc).
+            bool m_isAttributeOwner;            //! True if this ElementInfo owns the internal attributes. We can use a single
+                                                //! ElementInfo for more than one class field, but only one owns the Attributes.
+            float m_sortOrder;                  //! Sort order of the property as defined by using the "order" attribute, by default the order is FLT_MAX
+                                                //! which means alphabetical sort will be used
         };
         
-		void Clear();
-        void OnPathChange(const AZStd::string& path);
-        // IpcHandlerNotificationBus overrides...
+		// IpcHandlerNotificationBus overrides...
         void OnMessageReceived(const AZ::u8* content, const AZ::u64 length) override;
 
+		void Clear();
+		void OnPathChange(const AZStd::string& path);
         void ExportToStaticMesh();
         bool IsBlenderFileLoaded();
-        
         AZStd::string ExportButtonText();
 
         void LoadObjects(const rapidjson::Value& objectNameArray, const rapidjson::Value& objectArray);
@@ -99,19 +98,29 @@ namespace GeomNodes
 
         StringVector m_enumValues;
 
+        //! Handles the dynamic parameter
         GNParamContext m_paramContext;
+
+        //! Stores the model data
         GNModelData m_modelData;
+        //! A reference to the mesh controller.
         AZStd::unique_ptr<GNMeshController> m_controller;
 
-        AZStd::string m_blenderFile;
-        AZStd::string m_currentObject;
-        AZStd::string m_currentObjectInfo; //!< in JSON form. This is the representation of the current selected object along with the current parameters.
+        //! Current blender file loaded.
+        AZStd::string m_blenderFile;        
+        //! The current object name selected.
+        AZStd::string m_currentObject;      
+        //! in JSON form. This is the representation of the current selected object along with the current parameters.
+        AZStd::string m_currentObjectInfo;  
 
+        //! a handle on the blender instance.
         GNInstance* m_instance = nullptr;
-        AzToolsFramework::EntityIdList m_entityIdList;
-
+        
+        //! Flag if the component is done initializing.
         bool m_initialized = false;
+        //! Flag to set if parameters needs to be disabled or not.
         bool m_workInProgress = false;
+        //! Flag if set true triggers a parameter reload coming from a saved point.
         bool m_fromActivate = false;
     };
 }

+ 5 - 1
Gems/O3DE/GeomNodes/Code/Source/Editor/EBus/EditorGeomNodesComponentBus.h

@@ -12,13 +12,17 @@
 
 namespace GeomNodes
 {
-    
+    //! Bus that EditorGeomNodesComponent handles like UI and parameter changes or sending an IPC message.
     class EditorGeomNodesComponentRequests : public AZ::ComponentBus
     {
     public:
+        //! Toggles the state of the component's parameters. true if disabled(working in the background); false if enabled.
         virtual void SetWorkInProgress(bool flag) = 0;
+        //! Gets the value of work in progress variable.
         virtual bool GetWorkInProgress() = 0;
+        //! Sends an IPC message to the script running on the blender instance.
         virtual void SendIPCMsg(const AZStd::string& msg) = 0;
+        //! Tells the component that a parameter value has changed. Usually tied to AZ::Edit::Attributes::ChangeNotify
 		virtual void OnParamChange() = 0;
 
 	protected:

+ 0 - 41
Gems/O3DE/GeomNodes/Code/Source/Editor/EBus/GeomNodesBus.h

@@ -1,41 +0,0 @@
-/*
- * 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 <AzCore/EBus/EBus.h>
-#include <AzCore/std/smart_ptr/unique_ptr.h>
-
-// This is similar to the WhiteBox implementation
-namespace GeomNodes
-{
-    class GNRenderMeshInterface;
-
-    //! Function object alias for creating a GNRenderMeshInterface.
-    //! @note Used by SetGNRenderMeshInterfaceBuilder in GeomNodesRequests.
-    using GNRenderMeshInterfaceBuilderFn = AZStd::function<AZStd::unique_ptr<GNRenderMeshInterface>(AZ::EntityId)>;
-
-    //! system level requests.
-    class GeomNodesRequests : public AZ::EBusTraits
-    {
-    public:
-        // EBusTraits overrides ...
-        static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
-        static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
-
-        //! Create a render mesh for use with geometry nodes data.
-        virtual AZStd::unique_ptr<GNRenderMeshInterface> CreateGNRenderMeshInterface(AZ::EntityId) = 0;
-        //! Control what concrete implementation of GNRenderMeshInterface CreateGNRenderMeshInterface returns.
-        virtual void SetGNRenderMeshInterfaceBuilder(GNRenderMeshInterfaceBuilderFn builder) = 0;
-
-    protected:
-        ~GeomNodesRequests() = default;
-    };
-
-    using WhiteBoxRequestBus = AZ::EBus<GeomNodesRequests>;
-} // namespace GeomNodes

+ 2 - 0
Gems/O3DE/GeomNodes/Code/Source/Editor/EBus/IpcHandlerBus.h

@@ -12,6 +12,7 @@
 
 namespace Ipc
 {
+    //! IPC related notifications
     class IpcHandlerNotifications : public AZ::EBusTraits
     {
     public:
@@ -23,6 +24,7 @@ namespace Ipc
 
         virtual ~IpcHandlerNotifications() {}
 
+        //! Triggered when an IPC message is sent from the client(s) to the gem.
         virtual void OnMessageReceived(const AZ::u8* content, const AZ::u64 length) = 0;
     };
 

+ 7 - 12
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNMeshController.cpp

@@ -37,8 +37,8 @@ namespace GeomNodes
 		AZ::TransformNotificationBus::Handler::BusConnect(m_entityId);
 		AzFramework::AssetCatalogEventBus::Handler::BusConnect();
 
-		m_worldFromLocal = AZ::Transform::CreateIdentity();
-		AZ::TransformBus::EventResult(m_worldFromLocal, m_entityId, &AZ::TransformBus::Events::GetWorldTM);
+		m_world = AZ::Transform::CreateIdentity();
+		AZ::TransformBus::EventResult(m_world, m_entityId, &AZ::TransformBus::Events::GetWorldTM);
     }
 
     GNMeshController::~GNMeshController()
@@ -89,7 +89,7 @@ namespace GeomNodes
 		if (!m_worldAabb.has_value())
 		{
 			m_worldAabb = GetLocalBounds();
-			m_worldAabb->ApplyTransform(m_worldFromLocal);
+			m_worldAabb->ApplyTransform(m_world);
 		}
 
 		return m_worldAabb.value();
@@ -117,8 +117,8 @@ namespace GeomNodes
 				[=]() {
 				AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect();
 				AzFramework::BoundsRequestBus::Handler::BusDisconnect();
-				m_renderMesh->BuildMesh(m_modelData, m_worldFromLocal);
-				m_renderMesh->UpdateTransform(m_worldFromLocal);
+				m_renderMesh->BuildMesh(m_modelData);
+				m_renderMesh->UpdateTransform(m_world);
 				AzFramework::BoundsRequestBus::Handler::BusConnect(m_entityId);
 				AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(m_entityId);
 				EditorGeomNodesComponentRequestBus::Event(m_entityId, &EditorGeomNodesComponentRequests::SetWorkInProgress, false);
@@ -139,7 +139,7 @@ namespace GeomNodes
 			materialList.push_back(azMaterialPath);
 		}
 
-		m_renderMesh->SetMaterialList(materialList);
+		m_renderMesh->SetMaterialPathList(materialList);
 	}
 
 	void GNMeshController::LoadMaterials(const rapidjson::Value& materialArray)
@@ -197,17 +197,12 @@ namespace GeomNodes
 		return m_blenderFilename + "_" + AZStd::string::format("%llu", (AZ::u64)m_entityId);
 	}
 
-	AZStd::string GNMeshController::GenerateAZModelFilename()
-	{
-		return GenerateModelAssetName() + AzModelExtension.data();
-	}
-
     void GNMeshController::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
     {
 		m_worldAabb.reset();
 		m_localAabb.reset();
 
-		m_worldFromLocal = world;
+		m_world = world;
 
 		if (m_renderMesh)
 		{

+ 22 - 10
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNMeshController.h

@@ -16,6 +16,8 @@
 namespace GeomNodes
 {
 	class GNRenderMesh;
+	//! A common class that handles everything from storing the model data, rendering the mesh via GNRenderMesh
+	//! handling different mesh events like bound request, transform updates and others.
     class GNMeshController
 		: public AzFramework::BoundsRequestBus::Handler
 		, public AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
@@ -37,36 +39,46 @@ namespace GeomNodes
 		AZ::Aabb GetWorldBounds() override;
 		AZ::Aabb GetLocalBounds() override;
 
+		//! Builds the model for atom rendering.
 		void RebuildRenderMesh();
+		//! Read the data from the shared memory and setup everything before building the render mesh.
 		void ReadData(AZ::u64 mapId);
 
+		//! Load the materials giver the json array. If there materials that are still in the AP in will tag them for waiting
+		//! so that the render mesh can properly load the materials.
 		void LoadMaterials(const rapidjson::Value& materialArray);
+		//! Sets the blender filename.
 		void SetFileName(const AZStd::string& path);
+		//! Generates the full FBX Path. This is usually used when exporting. 
 		AZStd::string GenerateFBXPath();
+		//! Generates the Model asset name with the full path but without the file extension.
 		AZStd::string GenerateModelAssetName();
-		AZStd::string GenerateAZModelFilename();
-
 
     private:
 		// TransformNotificationBus overrides ...
 		void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
 
 		// AssetCatalogEventBus::Handler ...
+		//! we use these functions to know if our assets like materials are already loaded so we can proceed with rendering the model/meshes
 		void OnCatalogAssetAdded(const AZ::Data::AssetId& assetId) override;
 		void OnCatalogAssetChanged(const AZ::Data::AssetId& assetId) override;
 
+		//! assigned EntityId to this Mesh Controller
         AZ::EntityId m_entityId;
-
+		//! Stores the model's data.
 		GNModelData m_modelData;
-
+		//! Reference to our render mesh.
 		AZStd::unique_ptr<GNRenderMesh> m_renderMesh;
-		AZ::Transform m_worldFromLocal = AZ::Transform::CreateIdentity();
-
-		AZStd::optional<AZ::Aabb> m_worldAabb; //!< Cached world aabb (used for selection/view determination).
-		AZStd::optional<AZ::Aabb> m_localAabb; //!< Cached local aabb (used for center pivot calculation).
-
+		//! Current world transform of the object.
+		AZ::Transform m_world = AZ::Transform::CreateIdentity();
+		//! Cached world aabb (used for selection/view determination).
+		AZStd::optional<AZ::Aabb> m_worldAabb; 
+		//! Cached local aabb (used for center pivot calculation).
+		AZStd::optional<AZ::Aabb> m_localAabb; 
+		//! Current loaded blender filename
 		AZStd::string m_blenderFilename;
-		AZStd::vector<AZStd::string> m_materialWaitList;	//!< List for materials building in AP. Having an empty list all materials are built and ready for loading.
+		//! List for materials building in AP. Having an empty list all materials are built and ready for loading.
+		AZStd::vector<AZStd::string> m_materialWaitList;
     };
 
 } // namespace GeomNodes

+ 14 - 7
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNMeshData.h

@@ -17,6 +17,7 @@ namespace GeomNodes
 {
     using MaterialList = AZStd::vector<AZStd::string>;
 
+    //! Mesh specific data class
     class GNMeshData
     {
     public:
@@ -91,6 +92,15 @@ namespace GeomNodes
         U32Vector m_indices;
         S32Vector m_loops;
         S32Vector m_materialIndices;
+        
+		//! hash are used to easily matched if you have the same mesh.
+		AZ::s64 m_hash = 0;
+		//! List of material names used by the mesh.
+		MaterialList m_materialNames;
+		//! List of instances. Instances are used so that you have the same mesh but on a different transform.
+		Mat4Vector m_instances;
+
+		AZ::Aabb m_aabb = AZ::Aabb::CreateNull();
 
         Vert3Vector m_positions;
         Vert3Vector m_normals;
@@ -99,6 +109,8 @@ namespace GeomNodes
         Vert2Vector m_uvs;
         Vert4Vector m_colors;
         
+        //! As meshes are eventually merged to common buffers we need to keep track of the offset and element count.
+        //! When we create the Atom Buffers we will need these infos while the mesh buffers will be held in GNModelData.
         DataRange m_indicesRange;
         DataRange m_positionsRange;
         DataRange m_normalsRange;
@@ -107,13 +119,8 @@ namespace GeomNodes
         DataRange m_uvsRange;
         DataRange m_colorsRange;
 
-        MaterialList m_materialNames;
-
+        //! Material index or slot that will be used by the mesh. Note that eventually a mesh will only be assigned to one material.
+        //! This way they can be grouped together by material and merge the vertices.
         AZ::u32 m_materialIndex = 0;
-
-        AZ::Aabb m_aabb = AZ::Aabb::CreateNull();
-        AZ::s64 m_hash = 0;
-
-        Mat4Vector m_instances;
     };
 }

+ 14 - 7
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNModelData.h

@@ -13,6 +13,7 @@
 
 namespace GeomNodes
 {
+    //! Handle parsing, handling and storing model data.
     class GNModelData
     {
     public:
@@ -22,13 +23,17 @@ namespace GeomNodes
         GNModelData(AZ::u64 mapId);
         ~GNModelData() = default;
 
+        //! Read all model data in the shared memory given the map id.
         void ReadData(AZ::u64 mapId);
 
+        //! return number of meshes in the model.
         const AZ::u32 MeshCount() const;
+        //! return list of mesh data.
         const MeshDataList GetMeshes() const;
+        //! return the list of material names.
         MaterialList GetMaterials();
 
-        // These functions are the combination of all mesh buffers in order based on their position in MeshDataList
+        //! These functions are the combination of all mesh buffers in order based on their position in MeshDataList
 		const U32Vector& GetIndices() const;
 		const Vert3Vector& GetPositions() const;
 		const Vert3Vector& GetNormals() const;
@@ -40,20 +45,22 @@ namespace GeomNodes
         AZ::Aabb GetAabb() const;
 
     private:
+        //! Merges all indices and buffers into one buffer. Keeping track of the offsets and sizes.
         void MergeMeshBuffers();
-
+        //! Given the map id as the SHM name read data array from the shared memory based on typename T.
         template<typename T>
         AZStd::vector<T> ReadArray(AZ::u64 mapId);
-
-        template<typename T>
+		//! Given the map id as the SHM name read data from the shared memory based on typename T.
+		template<typename T>
         T Read(AZ::u64 mapId);
 
+        //! stores the mesh data.
         MeshDataList m_meshes;
+        //! stores the material names.
         MaterialList m_materials;
-
-        // These are all data combined from the meshes in single arrays
+        //! These are all data combined from the meshes in single arrays
+        //! Combine them to one buffer to avoid the 256 mesh limit.
 		U32Vector m_indices;
-
 		Vert3Vector m_positions;
 		Vert3Vector m_normals;
 		Vert4Vector m_tangents;

+ 6 - 6
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNRenderMesh.cpp

@@ -160,7 +160,7 @@ namespace GeomNodes
 
         m_materialMap.clear();
         AZ::RPI::ModelMaterialSlot::StableId slotId = 0;
-        for (auto materialPath : m_materialList)
+        for (auto materialPath : m_materialPathList)
         {
 			if (auto materialAsset = AZ::RPI::AssetUtils::LoadAssetByProductPath<AZ::RPI::MaterialAsset>(materialPath.c_str()))
 			{
@@ -236,25 +236,25 @@ namespace GeomNodes
 
     void GNRenderMesh::SetMaterials()
     {
-		if (m_meshFeatureProcessor)
+		if (m_meshFeatureProcessor && m_meshHandle.IsValid())
 		{
 			m_meshFeatureProcessor->SetCustomMaterials(m_meshHandle, AZ::Render::ConvertToCustomMaterialMap(m_materialMap));
 		}
     }
 
-    void GNRenderMesh::SetMaterialList(const AZStd::vector<AZStd::string>& materials)
+    void GNRenderMesh::SetMaterialPathList(const AZStd::vector<AZStd::string>& materialPaths)
     {
-        m_materialList = materials;
+        m_materialPathList = materialPaths;
     }
 
-    void GNRenderMesh::BuildMesh(const GNModelData& modelData, const AZ::Transform& /*worldFromLocal*/)
+    void GNRenderMesh::BuildMesh(const GNModelData& modelData)
     {
         CreateMesh(modelData);
     }
 
     void GNRenderMesh::UpdateTransform(const AZ::Transform& worldFromLocal, const AZ::Vector3& /*scale*/)
     {
-        if (m_meshHandle.IsValid())
+        if (m_meshFeatureProcessor && m_meshHandle.IsValid())
         {
             m_meshFeatureProcessor->SetTransform(m_meshHandle, worldFromLocal);
         }

+ 32 - 7
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNRenderMesh.h

@@ -43,11 +43,13 @@ namespace GeomNodes
         explicit GNRenderMesh(AZ::EntityId entityId);
         ~GNRenderMesh();
 
-        // RenderMeshInterface ...
-        void BuildMesh(const GNModelData& renderData, const AZ::Transform& worldFromLocal);
+        //! For building the mesh.
+        void BuildMesh(const GNModelData& renderData);
+        //! Updates the models transform
         void UpdateTransform(const AZ::Transform& worldFromLocal, const AZ::Vector3& scale = AZ::Vector3::CreateOne());
-        //void UpdateMaterial(const GNMaterial& material);
+        //! Returns if the Model/Mesh is visible or not.
         bool IsVisible() const;
+        //! Sets the visibility of the Model/Mesh
         void SetVisiblity(bool visibility);
 
         // AZ::TickBus overrides ...
@@ -63,9 +65,12 @@ namespace GeomNodes
 		// MaterialComponentNotificationBus::Handler overrides...
 		void OnMaterialsUpdated(const AZ::Render::MaterialAssignmentMap& materials) override;
 
+        //! Returns the Model's data instance
         AZ::Data::Instance<AZ::RPI::Model> GetModel() const;
 
-        void SetMaterialList(const AZStd::vector<AZStd::string>& materials);
+        //! Sets the material paths used by the model. These are full paths with the azmaterial extension.
+        void SetMaterialPathList(const AZStd::vector<AZStd::string>& materialPaths);
+
     private:
         //! Creates an attribute buffer in the slot dictated by AttributeTypeT.
         template<AttributeType AttributeTypeT, typename VertexStreamDataType>
@@ -87,28 +92,45 @@ namespace GeomNodes
         // MeshHandleStateRequestBus overrides ...
         const AZ::Render::MeshFeatureProcessorInterface::MeshHandle* GetMeshHandle() const override;
 
+        //! Creates the attribute mesh buffers
 		bool CreateMeshBuffers(const GNModelData& modelData);
+        //! Creates everything related to the model for Atom Rendering. 
         bool CreateMesh(const GNModelData& modelData);
+        //! Using the ModelLodAssetCreator creates the Model LOD asset and the meshes.
         bool CreateLodAsset(const GNModelData& modelData);
+        //! Using the ModelAssetCreator creates the model asset and sets the material slots.
         void CreateModelAsset();
+        //! Final step for create the model by acquiring the mesh handle from the mesh feature processor 
         bool CreateModel();
+        //! Add LOD buffers to ModelLodAsset
         void AddLodBuffers(AZ::RPI::ModelLodAssetCreator& modelLodCreator);
+        //! Add Mesh Buffers to ModelLodAsset
         void AddMeshBuffers(AZ::RPI::ModelLodAssetCreator& modelLodCreator, const GNMeshData& meshData);
+        //! Checks if attributes are valid.
         bool AreAttributesValid() const;
         bool DoesMeshRequireFullRebuild(const GNMeshData& meshData) const;
-
+        //! Set the material map in the mesh feature processor.
         void SetMaterials();
 
+        //! Stores the assigned EntityId.
         AZ::EntityId m_entityId;
+        //! Reference to a ModelLodAsset
         AZ::Data::Asset<AZ::RPI::ModelLodAsset> m_lodAsset;
+        //! Reference to a ModelAsset
         AZ::Data::Asset<AZ::RPI::ModelAsset> m_modelAsset;
+        //! Reference to a Model instance
         AZ::Data::Instance<AZ::RPI::Model> m_model;
+        //! Reference to MeshFeatureProcessor
 		AZ::Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr;
+        //! Reference to MeshHandle
         AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
+        //! Material map
         AZ::Render::MaterialAssignmentMap m_materialMap;
-        AZStd::vector<AZStd::string> m_materialList;
-        uint32_t m_vertexCount = 0;
+        //! List of Material paths (i.e. azmodel)
+        AZStd::vector<AZStd::string> m_materialPathList;
+        //! LOD Index buffer
         AZStd::unique_ptr<IndexBuffer> m_indexBuffer;
+        //! Buffers
         AZStd::array<
             AZStd::variant<
                 AZStd::unique_ptr<PositionAttribute>,
@@ -119,12 +141,15 @@ namespace GeomNodes
                 AZStd::unique_ptr<ColorAttribute>>,
             NumAttributes>
             m_attributes;
+        //! For toggling visibility
         bool m_visible = true;
 
         //! model name.
         static constexpr AZStd::string_view ModelName = "GeomNodesMesh";
 
+        //! current model transform
         AZ::Transform m_transform;
+        //! current model scale
         AZ::Vector3 m_scale;
     };
 }

+ 0 - 46
Gems/O3DE/GeomNodes/Code/Source/Editor/Rendering/GNRenderMeshInterface.h

@@ -1,46 +0,0 @@
-/*
- * 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
- *
- */
-
-#include <AzCore/Component/Component.h>
-#include <GeomNodes/GeomNodesTypeIds.h>
-
-namespace AZ
-{
-    class Transform;
-}
-
-namespace GeomNodes
-{
-    //struct GNMaterial;
-    struct WhiteBoxRenderData;
-
-    //! A generic interface for the GeomNodes Component to communicate
-    //! with regardless of the rendering backend.
-    class GNRenderMeshInterface
-    {
-    public:
-        AZ_RTTI(GNRenderMeshInterface, GNRenderMeshInterfaceTypeId);
-
-        virtual ~GNRenderMeshInterface() = 0;
-
-        //! Take GeomNodes render data and populate the render mesh from it.
-        virtual void BuildMesh(const GNModelData& renderData, const AZ::Transform& worldFromLocal) = 0;
-
-        //! Update the transform of the render mesh.
-        virtual void UpdateTransform(const AZ::Transform& worldFromLocal) = 0;
-
-        //! Update the material of the render mesh.
-        //virtual void UpdateMaterial(const GNMaterial& material) = 0;
-
-        // Return if the GeomNodes mesh is visible or not.
-        virtual bool IsVisible() const = 0;
-
-        //! Set the GeomNodes mesh visible (true) or invisible (false).
-        virtual void SetVisiblity(bool visibility) = 0;
-    };
-} // namespace GeomNodes

+ 18 - 1
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GNInstance.h

@@ -15,32 +15,49 @@
 
 namespace GeomNodes
 {
+    //! Handles the Blender instance and communication between Gem and Client Script
     class GNInstance
     {
     public:
         GNInstance() = default;
         virtual ~GNInstance();
 
+        //! Standard initialization function.
         bool Init(const AZStd::string& filePath, const AZStd::string& scriptPath, const AZStd::string& exePath, AZ::EntityId entityId);
+        //! Do some cleanup. Like terminating the running process.
         void Cleanup();
+        //! Check if the Blender instance is still valid or running.
         bool IsValid();
+        //! Checks if the path provided is the same one as the Blender instance is currently using.
         bool IsSamePath(const AZStd::string& path);
+        //! Send a generic IPC message.
         void SendIPCMsg(const AZStd::string& content);
+        //! Start or Restart the Blender instance.
         bool RestartProcess();
 
-        // Ipc messaging
+        //! IPC messaging
+        //! Send Parameter updates so the client can update the Geometry Node in the Blender side.
         AZStd::string SendParamUpdates(const AZStd::string& params, const AZStd::string& objectName);
+        //! Send a Heartbeat message to the client so it knows the Gem is still running.
         void SendHeartbeat();
+        //! Request for Object Parameter info from the client script.
         void RequestObjectParams();
+        //! Tells the client script to close the SHM map on the client side as the gem will manage it.
         void CloseMap(AZ::u64 mapId);
+        //! Tells the client script that we need to export and write it to an FBX file.
         void RequestExport(const AZStd::string& params, const AZStd::string& objectName, const AZStd::string& fbxPath);
 
     private:
+        //! Blender instance's Process Watcher
         AZStd::unique_ptr<AzFramework::ProcessWatcher> m_blenderProcessWatcher = nullptr;
 
+        //! Stores assigned EntityId
         AZ::EntityId m_entityId;
+        //! Stores the blender file path that has a Geometry Nodes Modifier
         AZStd::string m_path = "";
+        //! Stores the script path. i.e. <GeomNodes Gem Path>/External/Scripts/__init__.py
         AZStd::string m_scriptPath = "";
+        //! Stores the path where Bridge.dll is located
         AZStd::string m_exePath = "";
     };
 } // namespace GeomNodes

+ 4 - 4
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GNParamContext.h

@@ -75,14 +75,14 @@ namespace GeomNodes
         AZStd::vector<GNProperty*> m_properties;
         AZStd::vector<GNPropertyGroup> m_groups;
 
-        // Get the pointer to the specified group in m_groups. Returns nullptr if not found.
+        //! Get the pointer to the specified group in m_groups. Returns nullptr if not found.
         GNPropertyGroup* GetGroup(const char* groupName);
-        // Get the pointer to the specified property in m_properties. Returns nullptr if not found.
+        //! Get the pointer to the specified property in m_properties. Returns nullptr if not found.
         GNProperty* GetProperty(const char* propertyName);
-        // Generate JSON string of all properties/parameters. NOTE: only select details are included.
+        //! Generate JSON string of all properties/parameters. NOTE: only select details are included.
         AZStd::string GetProperties();
 
-        // Remove all properties and groups
+        //! Remove all properties and groups
         void Clear();
 
         GNPropertyGroup() = default;

+ 0 - 72
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GNProperty.cpp

@@ -113,11 +113,6 @@ namespace GeomNodes
         return AZStd::string();
     }
 
-    void GNParamNil::CloneDataFrom(const GNProperty* gnProperty)
-    {
-        (void)gnProperty;
-    }
-
     //////////////////////////
     // GNParamBoolean
     //////////////////////////
@@ -153,12 +148,6 @@ namespace GeomNodes
         return retVal;
     }
     
-
-    bool GNParamBoolean::DoesTypeMatch(GNParamDataContext& context, int valueIndex) const
-    {
-        return context.IsBoolean(valueIndex);
-    }
-
     AZStd::string GNParamBoolean::ToJSONString() const
     {
         auto jsonString = AZStd::string::format(
@@ -187,17 +176,6 @@ namespace GeomNodes
         return AZ::SerializeTypeInfo<bool>::GetUuid();
     }
 
-    void GNParamBoolean::CloneDataFrom(const GNProperty* gnProperty)
-    {
-        const GNParamBoolean* booleanProperty = azrtti_cast<const GNParamBoolean*>(gnProperty);
-        AZ_Error("GNParamBoolean", booleanProperty, "Invalid call to CloneData. Types must match before clone attempt is made.\n");
-
-        if (booleanProperty)
-        {
-            m_value = booleanProperty->m_value;
-        }
-    }
-
     /////////////////////////
     // GNParamInt
     /////////////////////////
@@ -245,13 +223,6 @@ namespace GeomNodes
         return retVal;
     }
 
-    bool GNParamInt::DoesTypeMatch(GNParamDataContext& context, int valueIndex) const
-    {
-        return context.IsInt(valueIndex);
-    }
-
- 
-
     AZ::TypeId GNParamInt::GetDataTypeUuid() const
     {
         return AZ::SerializeTypeInfo<int>::GetUuid();
@@ -280,17 +251,6 @@ namespace GeomNodes
         return jsonString;
     }
 
-    void GNParamInt::CloneDataFrom(const GNProperty* gnProperty)
-    {
-        const GNParamInt* numberProperty = azrtti_cast<const GNParamInt*>(gnProperty);
-        AZ_Error("GNParamValue", numberProperty, "Invalid call to CloneData. Types must match before clone attempt is made.\n");
-
-        if (numberProperty)
-        {
-            m_value = numberProperty->m_value;
-        }
-    }
-
     /////////////////////////
     // GNParamValue
     /////////////////////////
@@ -338,11 +298,6 @@ namespace GeomNodes
         return retVal;
     }
 
-    bool GNParamValue::DoesTypeMatch(GNParamDataContext& context, int valueIndex) const
-    {
-        return context.IsValue(valueIndex);
-    }
-
     AZ::TypeId GNParamValue::GetDataTypeUuid() const
     {
         return AZ::SerializeTypeInfo<double>::GetUuid();
@@ -371,17 +326,6 @@ namespace GeomNodes
         return jsonString;
     }
 
-    void GNParamValue::CloneDataFrom(const GNProperty* gnProperty)
-    {
-        const GNParamValue* numberProperty = azrtti_cast<const GNParamValue*>(gnProperty);
-        AZ_Error("GNParamValue", numberProperty, "Invalid call to CloneData. Types must match before clone attempt is made.\n");
-
-        if (numberProperty)
-        {
-            m_value = numberProperty->m_value;
-        }
-    }
-
     /////////////////////////
     // GNParamString
     /////////////////////////
@@ -416,11 +360,6 @@ namespace GeomNodes
         return retVal;
     }
 
-    bool GNParamString::DoesTypeMatch(GNParamDataContext& context, int valueIndex) const
-    {
-        return context.IsString(valueIndex);
-    }
-
     AZ::TypeId GNParamString::GetDataTypeUuid() const
     {
         return AZ::SerializeGenericTypeInfo<AZStd::string>::GetClassTypeId();
@@ -448,15 +387,4 @@ namespace GeomNodes
         );
         return jsonString;
     }
-
-    void GNParamString::CloneDataFrom(const GNProperty* gnProperty)
-    {
-        const GNParamString* stringProperty = azrtti_cast<const GNParamString*>(gnProperty);
-        AZ_Error("GNParamString", stringProperty, "Invalid call to CloneData. Types must match before clone attempt is made.\n");
-
-        if (stringProperty)
-        {
-            m_value = stringProperty->m_value;
-        }
-    }
 } // namespace GeomNodes

+ 1 - 64
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GNProperty.h

@@ -62,35 +62,9 @@ namespace GeomNodes
         virtual const void* GetDataAddress() const = 0;
         virtual AZ::TypeId GetDataTypeUuid() const = 0;
         virtual AZStd::string ToJSONString() const = 0;
-        /**
-         * Test if the value at the index valueIndex is of the same type as that of the instance of GNProperty's subclass.
-         */
-        virtual bool DoesTypeMatch(GNParamDataContext& /*context*/, int /*valueIndex*/) const
-        {
-            return false;
-        }
-
+        
         virtual void ReadSetGNId(GNParamDataContext& context);
         
-        /*virtual bool Write(AZ::ScriptContext& context) = 0;
-        virtual bool TryRead(GNParamDataContext& context, int valueIndex)
-        {
-            (void)context;
-            (void)valueIndex;
-            return false;
-        };*/
-        bool TryUpdate(const GNProperty* gnProperty)
-        {
-            bool allowUpdate = azrtti_typeid(gnProperty) == azrtti_typeid(this);
-
-            if (allowUpdate)
-            {
-                CloneDataFrom(gnProperty);
-            }
-
-            return allowUpdate;
-        }
-
         virtual bool IsReadOnly()
         {
             return m_pReadOnly == nullptr ? false : *m_pReadOnly;
@@ -109,8 +83,6 @@ namespace GeomNodes
         bool            m_isMaxSet = false;
         bool            m_isMinSet = false;
         AZ::EntityId    m_entityId;
-    protected:
-        virtual void CloneDataFrom(const GNProperty* gnProperty) = 0;
     };
 
     class GNParamNil : public GNProperty
@@ -133,12 +105,6 @@ namespace GeomNodes
         const void* GetDataAddress() const override;
         AZ::TypeId GetDataTypeUuid() const override;
         AZStd::string ToJSONString() const override;
-
-        /*bool Write(AZ::ScriptContext& context) override;
-        bool TryRead(GNParamDataContext& context, int valueIndex) override;*/
-
-    protected:
-        void CloneDataFrom(const GNProperty* gnProperty) override;
     };
 
     class GNParamBoolean : public GNProperty
@@ -171,15 +137,7 @@ namespace GeomNodes
 
         AZ::TypeId GetDataTypeUuid() const override;
 
-        bool DoesTypeMatch(GNParamDataContext& context, int valueIndex) const override;
-
-        /*bool Write(AZ::ScriptContext& context) override;
-        bool TryRead(GNParamDataContext& context, int valueIndex) override;*/
-
         bool m_value;
-
-    protected:
-        void CloneDataFrom(const GNProperty* gnProperty) override;
     };
 
     class GNParamInt : public GNProperty
@@ -210,11 +168,6 @@ namespace GeomNodes
         AZ::TypeId GetDataTypeUuid() const override;
         AZStd::string ToJSONString() const override;
 
-        bool DoesTypeMatch(GNParamDataContext& context, int valueIndex) const override;
-
-        /*bool Write(AZ::ScriptContext& context) override;
-        bool TryRead(GNParamDataContext& context, int valueIndex) override;*/
-
         void SetMinValue(int min)
         {
             m_min = min;
@@ -231,8 +184,6 @@ namespace GeomNodes
         int m_max;      // Geometry Node Param Max(int)
         int m_min;      // Geometry Node Param Min(int)
 
-    protected:
-        void CloneDataFrom(const GNProperty* gnProperty) override;
     };
 
     class GNParamValue : public GNProperty
@@ -263,11 +214,6 @@ namespace GeomNodes
         AZ::TypeId GetDataTypeUuid() const override;
         AZStd::string ToJSONString() const override;
 
-        bool DoesTypeMatch(GNParamDataContext& context, int valueIndex) const override;
-
-        /*bool Write(AZ::ScriptContext& context) override;
-        bool TryRead(GNParamDataContext& context, int valueIndex) override;*/
-
         void SetMinValue(double min)
         {
             m_min = min;
@@ -284,8 +230,6 @@ namespace GeomNodes
         double m_max;       // Geometry Node Param Max(double)
         double m_min;       // Geometry Node Param Min(double)
 
-    protected:
-        void CloneDataFrom(const GNProperty* gnProperty) override;
     };
 
     class GNParamString : public GNProperty
@@ -315,14 +259,7 @@ namespace GeomNodes
         AZ::TypeId GetDataTypeUuid() const override;
         AZStd::string ToJSONString() const override;
 
-        bool DoesTypeMatch(GNParamDataContext& context, int valueIndex) const override;
-
-        /*bool Write(AZ::ScriptContext& context) override;
-        bool TryRead(GNParamDataContext& context, int valueIndex) override;*/
-
         AZStd::string m_value;
 
-    protected:
-        void CloneDataFrom(const GNProperty* gnProperty) override;
     };
 } // namespace GeomNodes

+ 5 - 4
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GeomNodesSystem.h

@@ -52,13 +52,14 @@ namespace GeomNodes
         AZStd::string GetLastPath();
 
     private:
-        // Un/Registers and dis/connect handlers and buses
+        //! Un/Registers and dis/connect handlers and buses
         void RegisterHandlersAndBuses();
         void UnregisterHandlersAndBuses();
 
-        AZStd::unique_ptr<GNSettingsRegistryManager> m_registryManager; //! Handles all settings registry interactions.
+        //! Handles all settings registry interactions.
+        AZStd::unique_ptr<GNSettingsRegistryManager> m_registryManager; 
 
-        // Allows lookup and contains all allocated QValidators
+        //! Allows lookup and contains all allocated QValidators
         AZStd::unique_ptr<Validator> m_validator;
 
         AZStd::vector<AzToolsFramework::PropertyHandlerBase*> m_propertyHandlers;
@@ -75,6 +76,6 @@ namespace GeomNodes
 		State m_state = State::Uninitialized;
     };
 
-	//! Helper function for getting the GeomNOdes System interface from inside the GeomNodes gem.
+	//! Helper function for getting the GeomNodes System interface from inside the GeomNodes gem.
 	GeomNodesSystem* GetGNSystem();
 }

+ 0 - 2
Gems/O3DE/GeomNodes/Code/geomnodes_editor_private_files.cmake

@@ -25,7 +25,6 @@ set(FILES
     Source/Editor/Configuration/GNSettingsRegistryManager.cpp
     Source/Editor/Configuration/GNSettingsRegistryManager.h
     Source/Editor/EBus/EditorGeomNodesComponentBus.h
-    Source/Editor/EBus/GeomNodesBus.h
     Source/Editor/EBus/ValidatorBus.h
     Source/Editor/EBus/IpcHandlerBus.h
     Source/Editor/UI/ConfigurationWidget.cpp
@@ -60,7 +59,6 @@ set(FILES
     Source/Editor/Rendering/GNModelData.h
     Source/Editor/Rendering/GNRenderMesh.cpp
     Source/Editor/Rendering/GNRenderMesh.h
-    Source/Editor/Rendering/GNRenderMeshInterface.h
     Source/Editor/Systems/GeomNodesSystem.cpp
     Source/Editor/Systems/GeomNodesSystem.h
     Source/Editor/Systems/GNInstance.cpp

+ 0 - 32
Gems/O3DE/GeomNodes/External/Bridge/Ipc.cpp

@@ -902,35 +902,6 @@ namespace Ipc
         }
     }
 
-    void Ipc::ExecuteIPCHandlers()
-    {
-        /*MessageContainer batch;
-        {
-            AZStd::lock_guard<AZStd::recursive_mutex> guard(m_MessageListMutex);
-            batch = AZStd::move(m_MessagesWaitingToExecute);
-        }*/
-
-        // iterate through the messages
-        AZStd::unique_lock<AZStd::mutex> lock(m_MessageListMutex);
-
-        while (!m_MessagesWaitingToExecute.empty())
-        {
-            if (!m_handler) break; // no handlers
-
-            auto msg = m_MessagesWaitingToExecute.front();
-            if (!m_bServer)
-            {
-                m_handler(0, "", 0);
-            }
-            else
-            {
-                m_handler(msg.m_id, (const char*)msg.m_content.data(), msg.m_content.size());
-            }
-
-            m_MessagesWaitingToExecute.pop();
-        }
-    }
-
     void Ipc::ProcessThread()
     {
         // AZ::u32 tCounter = 0;
@@ -1021,9 +992,6 @@ namespace Ipc
                             m_MessagesWaitingToExecute.pop();
                         }
                     }
-                    
-                    //ExecuteIPCHandlers();
-                    //EBUS_QUEUE_FUNCTION(AZ::SystemTickBus, &Ipc::ExecuteIPCHandlers, this);
                 }
                 else
                 {

+ 0 - 1
Gems/O3DE/GeomNodes/External/Bridge/Ipc.h

@@ -208,7 +208,6 @@ namespace Ipc
         void PerformClientCheck(AZStd::sys_time_t ts);
         void ProcessOverlowQueue(AZStd::sys_time_t ts);
         void PollForMessages(IPCMsgSequence& mapMsgSequence);
-        void ExecuteIPCHandlers();
         bool CreateSHMRingBuffer(AZ::u64 mapId, AZ::u64 uSize);
 
         static Ipc* m_Instance;