diff --git a/modules/scene/include/vkcv/scene/Bounds.hpp b/modules/scene/include/vkcv/scene/Bounds.hpp index 56d9e6b87abe10aaeb407dc882995a8fb9b01735..2ab081c1f42c221239e4b0c724e41968e561b50f 100644 --- a/modules/scene/include/vkcv/scene/Bounds.hpp +++ b/modules/scene/include/vkcv/scene/Bounds.hpp @@ -40,12 +40,36 @@ namespace vkcv::scene { * @param[in] max Maximum values of the box as 3D vector */ Bounds(const glm::vec3& min, const glm::vec3& max); + + /** + * Destructor of an axis aligned bounding box. + */ ~Bounds() = default; - + + /** + * Copy-constructor of an axis aligned bounding box. + * @param[in] other Other box as Bounds + */ Bounds(const Bounds& other) = default; - Bounds(Bounds&& other) = default; - + + /** + * Move-constructor of an axis aligned bounding box. + * @param[in,out] other Other box as Bounds + */ + Bounds(Bounds&& other) = default; + + /** + * Copy-operator of an axis aligned bounding box. + * @param[in] other Other box as Bounds + * @return Reference to this box + */ Bounds& operator=(const Bounds& other) = default; + + /** + * Move-operator of an axis aligned bounding box. + * @param[in,out] other Other box as Bounds + * @return Reference to this box + */ Bounds& operator=(Bounds&& other) = default; /** diff --git a/modules/scene/include/vkcv/scene/Mesh.hpp b/modules/scene/include/vkcv/scene/Mesh.hpp index fc89cd02747450f6019b78f8c55df4793efe2141..3118696bdc270506bc6197e7d853148072294663 100644 --- a/modules/scene/include/vkcv/scene/Mesh.hpp +++ b/modules/scene/include/vkcv/scene/Mesh.hpp @@ -12,43 +12,118 @@ namespace vkcv::scene { * @addtogroup vkcv_scene * @{ */ - + + /** + * An event function type to be called on per drawcall recording level to adjust data + * like push constants with provided matrices. + */ typedef typename event_function<const glm::mat4&, const glm::mat4&, PushConstants&, vkcv::DrawcallInfo&>::type RecordMeshDrawcallFunction; class Node; - + + /** + * A class to represent a whole mesh to render. + */ class Mesh { friend class Node; private: + /** + * Parent scene of the mesh. + */ Scene& m_scene; + + /** + * List of the meshes parts. + */ std::vector<MeshPart> m_parts; + + /** + * List of the meshes drawcalls to render. + */ std::vector<DrawcallInfo> m_drawcalls; + + /** + * Local transformation matrix of the mesh. + */ glm::mat4 m_transform; + + /** + * Axis aligned bounding box of the mesh. + */ Bounds m_bounds; - + + /** + * Constructor of a new mesh with a given scene as parent. + * @param[in,out] scene Scene + */ explicit Mesh(Scene& scene); - + + /** + * Load mesh data from a scene structure from the asset loader + * creating and loading all mesh parts being required. + * @param[in] scene Scene structure from asset loader + * @param[in] mesh Mesh structure from asset loader + */ void load(const asset::Scene& scene, const asset::Mesh& mesh); - + + /** + * Record drawcalls of the mesh, equally to all its visible parts. + * @param[in] viewProjection View-transformation and projection as 4x4 matrix + * @param[out] pushConstants Structure to store push constants per drawcall + * @param[out] drawcalls List of drawcall structures + * @param[in] record Drawcall recording event function + */ void recordDrawcalls(const glm::mat4& viewProjection, PushConstants& pushConstants, std::vector<DrawcallInfo>& drawcalls, const RecordMeshDrawcallFunction& record); - + + /** + * Return the amount of drawcalls of the mesh + * as sum of all its parts. + * @return Amount of drawcalls + */ [[nodiscard]] size_t getDrawcallCount() const; public: + /** + * Destructor of a mesh. + */ ~Mesh(); - + + /** + * Copy-constructor of a mesh. + * @param[in] other Other mesh instance + */ Mesh(const Mesh& other) = default; - Mesh(Mesh&& other) = default; - + + /** + * Move-constructor of a mesh. + * @param[in,out] other Other mesh instance + */ + Mesh(Mesh&& other) = default; + + /** + * Copy-operator of a mesh. + * @param[in] other Other mesh instance + * @return Reference to this mesh instance + */ Mesh& operator=(const Mesh& other); + + /** + * Move-operator of a mesh. + * @param[in,out] other Other mesh instance + * @return Reference to this mesh instance + */ Mesh& operator=(Mesh&& other) noexcept; - + + /** + * Return the axis aligned bounding box of the mesh. + * @return Axis aligned bounding box of this mesh + */ [[nodiscard]] const Bounds& getBounds() const; diff --git a/modules/scene/include/vkcv/scene/MeshPart.hpp b/modules/scene/include/vkcv/scene/MeshPart.hpp index ec1e6c7db26f3221047933dd7a7599c7cdcc4fff..8d77efd7a112ea92a6c4192e5a5cf43cea53e800 100644 --- a/modules/scene/include/vkcv/scene/MeshPart.hpp +++ b/modules/scene/include/vkcv/scene/MeshPart.hpp @@ -17,41 +17,128 @@ namespace vkcv::scene { class Scene; class Mesh; - + + /** + * A class to represent a group of vertices to render + * a part of a mesh. + */ class MeshPart { friend class Mesh; private: + /** + * Parent scene of the mesh part. + */ Scene& m_scene; + + /** + * The buffer handle of its vertex buffer. + */ BufferHandle m_vertices; + + /** + * The list of the used vertex buffer bindings. + */ std::vector<VertexBufferBinding> m_vertexBindings; + + /** + * The buffer handle of its index buffer. + */ BufferHandle m_indices; + + /** + * The amount of indices in its index buffer. + */ size_t m_indexCount; + + /** + * Axis aligned bounding box of the mesh part. + */ Bounds m_bounds; + + /** + * The index of the material used to render + * this part of the mesh. + */ size_t m_materialIndex; - + + /** + * Constructor of a new mesh part with a given scene as parent. + * @param[in,out] scene Scene + */ explicit MeshPart(Scene& scene); - + + /** + * Load vertex and index data from structures provided by the asset loader + * and add a matching drawcall to the list if the loaded mesh part is valid. + * @param[in] scene Scene structure from asset loader + * @param[in] vertexGroup Vertex group structure from asset loader + * @param[out] drawcalls List of drawcalls + */ void load(const asset::Scene& scene, const asset::VertexGroup& vertexGroup, std::vector<DrawcallInfo>& drawcalls); public: + /** + * Destructor of a mesh part. + */ ~MeshPart(); - + + /** + * Copy-constructor of a mesh part. + * @param[in] other Other mesh part + */ MeshPart(const MeshPart& other); - MeshPart(MeshPart&& other); - + + /** + * Move-constructor of a mesh part. + * @param[in,out] other Other mesh part + */ + MeshPart(MeshPart&& other) noexcept; + + /** + * Copy-operator of a mesh part. + * @param[in] other Other mesh part + * @return Reference to this mesh part + */ MeshPart& operator=(const MeshPart& other); - MeshPart& operator=(MeshPart&& other) noexcept; - + + /** + * Move-operator of a mesh part. + * @param[in,out] other Other mesh part + * @return Reference to this mesh part + */ + MeshPart& operator=(MeshPart&& other) noexcept; + + /** + * Get the material used by this specific part of + * the mesh for rendering. + * @return Material + */ [[nodiscard]] const material::Material& getMaterial() const; - + + /** + * Return the axis aligned bounding box of this + * specific part of the mesh. + * @return Axis aligned bounding box of this mesh part + */ [[nodiscard]] const Bounds& getBounds() const; - + + /** + * Return the status if this part of the mesh is valid + * as boolean value. + * @return true if the mesh part is valid, otherwise false + */ explicit operator bool() const; + + /** + * Return the status if this part of the mesh is invalid + * as boolean value. + * @return true if the mesh part is invalid, otherwise false + */ bool operator!() const; }; diff --git a/modules/scene/include/vkcv/scene/Node.hpp b/modules/scene/include/vkcv/scene/Node.hpp index 85305dd2ed6765d8412431b8a62857c7471f0323..51088f2564fb56a9d63d99238cb0665c6989bc9e 100644 --- a/modules/scene/include/vkcv/scene/Node.hpp +++ b/modules/scene/include/vkcv/scene/Node.hpp @@ -81,7 +81,11 @@ namespace vkcv::scene { * @param[in] maxMeshesPerNode Maximum amount of meshes per node */ void splitMeshesToSubNodes(size_t maxMeshesPerNode); - + + /** + * Return the sum of drawcalls in the graph of this node. + * @return Amount of drawcalls + */ [[nodiscard]] size_t getDrawcallCount() const; diff --git a/modules/shader_compiler/include/vkcv/shader/Compiler.hpp b/modules/shader_compiler/include/vkcv/shader/Compiler.hpp index 3ffa251694ba408e3cd0ee3aba8c83fa97a6a0cb..ddaaf3d995397dbf7b6b25e2ddd675c5d52a1b47 100644 --- a/modules/shader_compiler/include/vkcv/shader/Compiler.hpp +++ b/modules/shader_compiler/include/vkcv/shader/Compiler.hpp @@ -16,7 +16,7 @@ namespace vkcv::shader { */ /** - * An event function type to react on shader compilation. + * An event function type to be called on compilation completion. */ typedef typename event_function<ShaderStage, const std::filesystem::path&>::type ShaderCompiledFunction;