RavEngine
Loading...
Searching...
No Matches
Mesh.hpp
1#pragma once
2#include "Vector.hpp"
3#include <glm/mat4x4.hpp>
4#include "Common3D.hpp"
5#include <span>
6#include "MaterialShared.hpp"
7
8namespace RavEngine{
9
10 using VertexAttrib_t = uint8_t;
11
13 const std::array<char, 4> header = {'r','v','e','m'};
14 uint32_t numVertices = 0;
15 uint32_t numIndicies = 0;
16 VertexAttrib_t attributes = 0; // info about the file
17
18 constexpr static VertexAttrib_t
19 SkinnedMeshBit = 1 << 0,
20 hasPositionsBit = 1 << 1,
21 hasNormalsBit = 1 << 2,
22 hasTangentsBit = 1 << 3,
23 hasBitangentsBit = 1 << 4,
24 hasUV0Bit = 1 << 5,
25 hasLightmapUVBit = 1 << 6
26 ;
27};
28
30
31using VertexPosition_t = decltype(VertexNormalUV::position);
32using VertexNormal_t = decltype(VertexNormalUV::normal);
33using VertexTangent_t = decltype(VertexNormalUV::tangent);
34using VertexBitangent_t = decltype(VertexNormalUV::bitangent);
35using VertexUV_t = decltype(VertexNormalUV::uv);
36
37template<template<typename...> class T>
39 T<uint32_t> indices;
40 T<VertexPosition_t> positions;
41 T<VertexNormal_t> normals;
42 T<VertexTangent_t> tangents;
43 T<VertexBitangent_t> bitangents;
44 T<VertexUV_t> uv0;
45 T<VertexUV_t> lightmapUVs;
46
47 uint32_t NumVerts() const {
48 return positions.size();
49 }
50
51 MeshAttributes attributes;
52};
53struct MeshPart : public MeshPartBase<Vector>{
54 void ReserveVerts(uint32_t size) {
55 positions.reserve(size);
56 normals.reserve(size);
57 tangents.reserve(size);
58 bitangents.reserve(size);
59 uv0.reserve(size);
60 lightmapUVs.reserve(size);
61 }
62};
63
64template<typename T>
65struct basic_immutable_span : public std::span<const T,std::dynamic_extent>{
67 basic_immutable_span(const T* ptr, size_t count) : std::span<const T,std::dynamic_extent>(ptr,count){}
68};
69
70struct MeshPartView : public MeshPartBase<basic_immutable_span>{
71 MeshPartView(){}
72 MeshPartView(const MeshPart& other){
73 positions = { other.positions.data(),other.positions.size() };
74 normals = { other.normals.data(),other.normals.size() };
75 tangents = { other.tangents.data(),other.tangents.size() };
76 bitangents = { other.bitangents.data(),other.bitangents.size() };
77 uv0 = { other.uv0.data(),other.uv0.size() };
78 lightmapUVs = { other.lightmapUVs.data(),other.lightmapUVs.size() };
79 indices = { other.indices.data(), other.indices.size() };
80 attributes = other.attributes;
81 }
82};
83
84
85}
Definition concurrentqueue.h:747
uint8 uint8_t
Definition fwd.hpp:103
Definition Animation.hpp:6
Definition MaterialShared.hpp:9
Definition Mesh.hpp:38
Definition Mesh.hpp:70
Definition Mesh.hpp:53
Definition Common3D.hpp:22
Definition Mesh.hpp:65