improved docs

This commit is contained in:
Jorijn van der Graaf 2025-06-14 14:58:02 +02:00
commit dfe9b1abe9
16 changed files with 315 additions and 40 deletions

View file

@ -31,6 +31,10 @@ import :VulkanBuffer;
import :Types;
namespace Crafter {
/**
* @brief Holder for a indexed mesh.
* @tparam VertexType The vertex type to use that is internally stored, this must match the type the glsl shader expects.
*/
export template <typename VertexType>
class Mesh {
public:
@ -49,8 +53,8 @@ namespace Crafter {
}
/**
* @brief Constructs Mesh from an in memory char buffer
* @param asset pointer to the char buffer
* @brief Constructs Mesh from an in memory char buffer.
* @param asset pointer to the char buffer.
*/
Mesh(const char* asset) requires(std::same_as<VertexType, Vertex>) : vertexCount(reinterpret_cast<const std::uint32_t*>(asset)[0]), indexCount(((reinterpret_cast<const std::uint32_t*>(asset)[1]) + 63) & ~63), verticies(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, vertexCount), indicies(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, indexCount) {
uint32_t indexCountNoPadding = reinterpret_cast<const std::uint32_t*>(asset)[1];
@ -73,8 +77,8 @@ namespace Crafter {
/**
* @brief Constructs UV Mesh from an in memory char buffer
* @param asset pointer to the char buffer
* @brief Constructs UV Mesh from an in memory char buffer.
* @param asset pointer to the char buffer.
*/
Mesh(const char* asset) requires(std::same_as<VertexType, VertexUV>) : vertexCount(reinterpret_cast<const std::uint32_t*>(asset)[0]), indexCount(((reinterpret_cast<const std::uint32_t*>(asset)[1]) + 63) & ~63), verticies(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, vertexCount), indicies(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, indexCount) {
uint32_t indexCountNoPadding = reinterpret_cast<const std::uint32_t*>(asset)[1];
@ -96,11 +100,11 @@ namespace Crafter {
}
/**
* @brief Constructs heightmap Mesh from an in memory char buffer
* @param heights pointer to heights
* @param sizeX size in the X dimension
* @param sizeZ size in the Y dimension
* @param spacing spacing between the points
* @brief Constructs heightmap Mesh from an in memory char buffer.
* @param heights pointer to heights.
* @param sizeX size in the X dimension.
* @param sizeZ size in the Y dimension.
* @param spacing spacing between the points .
*/
Mesh(float* heights, uint32_t sizeX, uint32_t sizeZ, float spacing) : vertexCount(sizeX*sizeZ), indexCount(((((sizeX-1)*(sizeZ-1))*6)+ 63) & ~63), verticies(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, vertexCount), indicies(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, indexCount) {
uint32_t indexCountNoPadding = ((sizeX-1)*(sizeZ-1))*6;