RavEngine
Loading...
Searching...
No Matches
MeshCollection.hpp
1#pragma once
2#if !RVE_SERVER
3#include "Ref.hpp"
4#include "DataStructures.hpp"
5#include "BufferedVRAMVector.hpp"
6#include "MeshAsset.hpp"
7#include "MeshAssetSkinned.hpp"
8
9namespace RavEngine {
10
11 class MeshAssetSkinned;
12 struct MeshRange;
13 struct SkeletonAsset;
14
15 template<typename T>
17 Vector<Ref<T>> meshes;
18 struct Entry {
19 Ref<T> mesh;
20 float minDistance = 0; // the minimum distance from the object to the camera for this LOD to be usable
21 };
22 };
23
24 struct MeshCollectionStatic : public MeshCollection<MeshAsset> {
25 friend class RenderEngine;
27 MeshCollectionStatic(std::span<Entry> meshes);
28 MeshCollectionStatic(std::initializer_list<Entry> meshes);
31
32 void AddMesh(const Entry& m);
33
34 void RemoveMeshAtIndex(uint16_t idx);
35
36 void Reserve(uint16_t size);
37 void Resize(uint16_t size);
38
39 auto GetNumLods() const {
40 return lodDistances.Size();
41 }
42
43 auto GetMeshForLOD(uint32_t i) const {
44 return meshes[i];
45 }
46
47 void SetMeshForLOD(uint32_t i, Ref<MeshAsset> mesh) {
48 meshes.at(i) = mesh;
49 }
50
51 float GetRadius() const;
52
53 private:
54 BufferedVRAMVector<float> lodDistances;
55 };
56
57 struct MeshCollectionSkinned : protected MeshCollection<MeshAssetSkinned> {
58 friend class RenderEngine;
59 MeshCollectionSkinned(const Entry& m);
61
62 uint32_t GetNumVerts() const;
63 uint32_t GetNumIndices() const;
64 uint32_t GetNumLods() const;
65 float GetRadius() const;
66 RGLBufferPtr GetWeightsBuffer() const;
67 MeshRange GetAllocation() const;
68
69 private:
70 BufferedVRAMVector<float> lodDistances;
71 };
72
73 struct MeshCollectionStaticManager : public GenericWeakReadThroughCache<std::string, MeshCollectionStatic> {};
74 struct MeshCollectionSkinnedManager : public GenericWeakReadThroughCache<std::string, MeshCollectionSkinned> {};
75
76}
77#endif
Definition RenderEngine.hpp:64
Definition concurrentqueue.h:747
Definition Animation.hpp:6
static Ref< MeshAsset > Get(const std::string &str, A ... extras)
Definition Manager.hpp:33
Definition MeshAsset.hpp:22
Definition MeshCollection.hpp:74
Definition MeshCollection.hpp:57
Definition MeshCollection.hpp:73
Definition MeshCollection.hpp:24
Definition MeshCollection.hpp:18
Definition MeshCollection.hpp:16
Definition MeshAllocation.hpp:9