only loading one's model data to the GPU once

This commit is contained in:
devZoGok
2025-06-15 18:41:52 +03:00
parent 6f7702cb19
commit 08907567b0
8 changed files with 150 additions and 125 deletions
+40 -55
View File
@@ -9,62 +9,47 @@
#include "animatable.h"
namespace vb01{
struct MeshData{
struct ShapeKey : public Animatable{
std::string name;
float minValue, value, maxValue;
ShapeKey(std::string n, float v, float mnv, float mxv) : name(n), value(v), minValue(mnv), maxValue(mxv), Animatable(Animatable::SHAPE_KEY, n){}
ShapeKey() : Animatable(Animatable::SHAPE_KEY){}
void animate(float, KeyframeChannel);
};
struct GpuVertex{
Vector3 pos, norm, tan, biTan;
Vector2 uv;
float weights[4]{0, 0, 0, 0};
int boneIndices[4]{-1, -1, -1, -1};
Vector3 shapeKeyOffsets[100];
};
struct Vertex{
Vector3 *pos = nullptr, *norm = nullptr, tan, biTan;
Vector2 uv;
float *weights = nullptr;
int *boneIndices = nullptr;
Vector3 *shapeKeyOffsets = nullptr;
};
GpuVertex* toGpuVerts();
Vector3 *positions = nullptr, *normals = nullptr, **shapeKeyOffsets = nullptr;
float **weights = nullptr;
int **boneIndices = nullptr;
Vertex *vertices;
std::string *vertexGroups = nullptr;
ShapeKey *shapeKeys = nullptr;
u32 *indices, VAO, VBO, EBO;
int numPos, numTris, numVertexGroups = 0, numShapeKeys = 0;
std::string attachableName = "", fullSkeletonName = "";
MeshData(){}
MeshData(Vector3 *pos, float **w, int **bi, Vector3 **sko, int np, Vector3 *norm, Vertex *vert, u32 *ind, int nt, std::string an = "", std::string *vg = nullptr, int nvg = 0, std::string fsn = "", ShapeKey *sk = nullptr, int nsk = 0) :
positions(pos),
weights(w),
boneIndices(bi),
shapeKeyOffsets(sko),
numPos(np),
normals(norm),
vertices(vert),
indices(ind),
numTris(nt),
vertexGroups(vg),
numVertexGroups(nvg),
fullSkeletonName(fsn),
shapeKeys(sk),
numShapeKeys(nsk)
{}
struct MeshData{
struct ShapeKey : public Animatable{
std::string name;
float minValue, value, maxValue;
ShapeKey(std::string n, float v, float mnv, float mxv) : name(n), value(v), minValue(mnv), maxValue(mxv), Animatable(Animatable::SHAPE_KEY, n){}
ShapeKey() : Animatable(Animatable::SHAPE_KEY){}
void animate(float, KeyframeChannel);
};
struct GpuVertex{
Vector3 pos, norm, tan, biTan;
Vector2 uv;
float weights[4]{0, 0, 0, 0};
int boneIndices[4]{-1, -1, -1, -1};
Vector3 shapeKeyOffsets[100];
};
struct Vertex{
Vector3 *pos = nullptr, *norm = nullptr, tan, biTan;
Vector2 uv;
float *weights = nullptr;
int *boneIndices = nullptr;
Vector3 *shapeKeyOffsets = nullptr;
};
GpuVertex* toGpuVerts();
Vector3 *positions = nullptr, *normals = nullptr, **shapeKeyOffsets = nullptr;
float **weights = nullptr;
int **boneIndices = nullptr;
Vertex *vertices;
std::string *vertexGroups = nullptr;
ShapeKey *shapeKeys = nullptr;
u32 *indices, VAO, VBO, EBO;
int numPos, numTris, numVertexGroups = 0, numShapeKeys = 0;
std::string attachableName = "", fullSkeletonName = "";
MeshData(){}
MeshData(Vector3*, float**, int**, Vector3**, int, Vector3*, Vertex*, u32*, int, std::string = "", std::string *vg = nullptr, int = 0, std::string = "", ShapeKey *sk = nullptr, int = 0);
};
}
#endif