Orange/include/Orange/Graphics/Vertex.h

67 lines
2.1 KiB
C++

#pragma once
#include <Orange/Core/Array.h>
#include <Orange/Core/Log.h>
#include <Orange/Core/Result.h>
#include <Orange/Core/Traits.h>
#include <Orange/Core/Vector.h>
#include <Orange/Math/Vector.h>
#include <vulkan/vulkan_core.h>
namespace orange
{
enum class MeshVertexType
{
Static,
Skinned,
};
struct alignas(8) StaticVertex
{
vec3 pos;
vec2 texUV;
vec2 lightUV;
vec3 normal;
//vec3 tangent;
static constexpr VkVertexInputAttributeDescription Attributes[] =
{
{ .location = 0, .binding = 0, .format = VK_FORMAT_R32G32B32_SFLOAT, .offset = uint32_t(offsetof2(StaticVertex, pos)) },
{ .location = 1, .binding = 0, .format = VK_FORMAT_R32G32_SFLOAT, .offset = uint32_t(offsetof2(StaticVertex, texUV)) },
{ .location = 2, .binding = 0, .format = VK_FORMAT_R32G32_SFLOAT, .offset = uint32_t(offsetof2(StaticVertex, lightUV)) },
{ .location = 3, .binding = 0, .format = VK_FORMAT_R32G32B32_SFLOAT, .offset = uint32_t(offsetof2(StaticVertex, normal)) },
};
bool operator == (const StaticVertex& other) const
{
return
pos == other.pos &&
texUV == other.texUV &&
lightUV == other.lightUV &&
normal == other.normal;// &&
//tangent == other.tangent;
}
};
struct alignas(8) SkinnedVertex : public StaticVertex
{
static constexpr uint32_t MaxVertexWeights = 4;
bool operator == (const SkinnedVertex& other) const
{
return
pos == other.pos &&
texUV == other.texUV &&
lightUV == other.lightUV &&
normal == other.normal &&
//tangent == other.tangent &&
boneIndices == other.boneIndices &&
boneWeights == other.boneWeights;
}
Array<uint8_t, MaxVertexWeights> boneIndices;
Array<uint8_t, MaxVertexWeights> boneWeights;
};
}