Skip to content
Snippets Groups Projects
Verified Commit ef9dd3a7 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#96] Completed docs for scene module

parent e9dfe29e
No related branches found
No related tags found
1 merge request!97Resolve "Dokumentation vervollständigen"
Pipeline #27273 failed
...@@ -40,12 +40,36 @@ namespace vkcv::scene { ...@@ -40,12 +40,36 @@ namespace vkcv::scene {
* @param[in] max Maximum values of the box as 3D vector * @param[in] max Maximum values of the box as 3D vector
*/ */
Bounds(const glm::vec3& min, const glm::vec3& max); Bounds(const glm::vec3& min, const glm::vec3& max);
/**
* Destructor of an axis aligned bounding box.
*/
~Bounds() = default; ~Bounds() = default;
/**
* Copy-constructor of an axis aligned bounding box.
* @param[in] other Other box as Bounds
*/
Bounds(const Bounds& other) = default; 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; 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; Bounds& operator=(Bounds&& other) = default;
/** /**
......
...@@ -12,43 +12,118 @@ namespace vkcv::scene { ...@@ -12,43 +12,118 @@ namespace vkcv::scene {
* @addtogroup 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; typedef typename event_function<const glm::mat4&, const glm::mat4&, PushConstants&, vkcv::DrawcallInfo&>::type RecordMeshDrawcallFunction;
class Node; class Node;
/**
* A class to represent a whole mesh to render.
*/
class Mesh { class Mesh {
friend class Node; friend class Node;
private: private:
/**
* Parent scene of the mesh.
*/
Scene& m_scene; Scene& m_scene;
/**
* List of the meshes parts.
*/
std::vector<MeshPart> m_parts; std::vector<MeshPart> m_parts;
/**
* List of the meshes drawcalls to render.
*/
std::vector<DrawcallInfo> m_drawcalls; std::vector<DrawcallInfo> m_drawcalls;
/**
* Local transformation matrix of the mesh.
*/
glm::mat4 m_transform; glm::mat4 m_transform;
/**
* Axis aligned bounding box of the mesh.
*/
Bounds m_bounds; Bounds m_bounds;
/**
* Constructor of a new mesh with a given scene as parent.
* @param[in,out] scene Scene
*/
explicit Mesh(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, void load(const asset::Scene& scene,
const asset::Mesh& mesh); 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, void recordDrawcalls(const glm::mat4& viewProjection,
PushConstants& pushConstants, PushConstants& pushConstants,
std::vector<DrawcallInfo>& drawcalls, std::vector<DrawcallInfo>& drawcalls,
const RecordMeshDrawcallFunction& record); const RecordMeshDrawcallFunction& record);
/**
* Return the amount of drawcalls of the mesh
* as sum of all its parts.
* @return Amount of drawcalls
*/
[[nodiscard]] [[nodiscard]]
size_t getDrawcallCount() const; size_t getDrawcallCount() const;
public: public:
/**
* Destructor of a mesh.
*/
~Mesh(); ~Mesh();
/**
* Copy-constructor of a mesh.
* @param[in] other Other mesh instance
*/
Mesh(const Mesh& other) = default; 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); 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; Mesh& operator=(Mesh&& other) noexcept;
/**
* Return the axis aligned bounding box of the mesh.
* @return Axis aligned bounding box of this mesh
*/
[[nodiscard]] [[nodiscard]]
const Bounds& getBounds() const; const Bounds& getBounds() const;
......
...@@ -17,41 +17,128 @@ namespace vkcv::scene { ...@@ -17,41 +17,128 @@ namespace vkcv::scene {
class Scene; class Scene;
class Mesh; class Mesh;
/**
* A class to represent a group of vertices to render
* a part of a mesh.
*/
class MeshPart { class MeshPart {
friend class Mesh; friend class Mesh;
private: private:
/**
* Parent scene of the mesh part.
*/
Scene& m_scene; Scene& m_scene;
/**
* The buffer handle of its vertex buffer.
*/
BufferHandle m_vertices; BufferHandle m_vertices;
/**
* The list of the used vertex buffer bindings.
*/
std::vector<VertexBufferBinding> m_vertexBindings; std::vector<VertexBufferBinding> m_vertexBindings;
/**
* The buffer handle of its index buffer.
*/
BufferHandle m_indices; BufferHandle m_indices;
/**
* The amount of indices in its index buffer.
*/
size_t m_indexCount; size_t m_indexCount;
/**
* Axis aligned bounding box of the mesh part.
*/
Bounds m_bounds; Bounds m_bounds;
/**
* The index of the material used to render
* this part of the mesh.
*/
size_t m_materialIndex; 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); 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, void load(const asset::Scene& scene,
const asset::VertexGroup& vertexGroup, const asset::VertexGroup& vertexGroup,
std::vector<DrawcallInfo>& drawcalls); std::vector<DrawcallInfo>& drawcalls);
public: public:
/**
* Destructor of a mesh part.
*/
~MeshPart(); ~MeshPart();
/**
* Copy-constructor of a mesh part.
* @param[in] other Other mesh part
*/
MeshPart(const MeshPart& other); 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=(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]] [[nodiscard]]
const material::Material& getMaterial() const; 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]] [[nodiscard]]
const Bounds& getBounds() const; 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; 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; bool operator!() const;
}; };
......
...@@ -81,7 +81,11 @@ namespace vkcv::scene { ...@@ -81,7 +81,11 @@ namespace vkcv::scene {
* @param[in] maxMeshesPerNode Maximum amount of meshes per node * @param[in] maxMeshesPerNode Maximum amount of meshes per node
*/ */
void splitMeshesToSubNodes(size_t maxMeshesPerNode); void splitMeshesToSubNodes(size_t maxMeshesPerNode);
/**
* Return the sum of drawcalls in the graph of this node.
* @return Amount of drawcalls
*/
[[nodiscard]] [[nodiscard]]
size_t getDrawcallCount() const; size_t getDrawcallCount() const;
......
...@@ -16,7 +16,7 @@ namespace vkcv::shader { ...@@ -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; typedef typename event_function<ShaderStage, const std::filesystem::path&>::type ShaderCompiledFunction;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment