Levels of detail for brush stroke decreased to save on memory

This commit is contained in:
Yousef Khadadeh 2025-07-21 13:01:48 +03:00
parent 241a0a9588
commit f82e626686
6 changed files with 6 additions and 32 deletions

View file

@ -101,23 +101,12 @@ void DrawBrushStroke::initialize_draw_data(DrawingProgram& drawP) {
vertices_to_draw_data(vertices, vertexData);
vertexData.clear();
create_triangles(triangleFunc, points, 2);
create_triangles(triangleFunc, points, 4);
vertices_to_draw_data(verticesMipMap[0], vertexData);
vertexData.clear();
create_triangles(triangleFunc, points, 4);
vertices_to_draw_data(verticesMipMap[1], vertexData);
vertexData.clear();
create_triangles(triangleFunc, points, 6);
vertices_to_draw_data(verticesMipMap[2], vertexData);
vertexData.clear();
create_triangles(triangleFunc, points, 10);
vertices_to_draw_data(verticesMipMap[3], vertexData);
create_triangles(triangleFunc, points, 30);
vertices_to_draw_data(verticesMipMap[4], vertexData);
vertices_to_draw_data(verticesMipMap[1], vertexData);
}
}

View file

@ -47,7 +47,7 @@ class DrawBrushStroke : public DrawComponent {
virtual SCollision::AABB<float> get_obj_coord_bounds() const override;
sk_sp<SkVertices> vertices;
std::array<sk_sp<SkVertices>, 5> verticesMipMap;
std::array<sk_sp<SkVertices>, 3> verticesMipMap;
SCollision::BVHContainer<float> collisionTree;
private:

View file

@ -204,13 +204,7 @@ void DrawComponent::calculate_draw_transform(const DrawData& drawData) {
if(drawSetupData.shouldDraw) {
drawSetupData.shouldDraw = updateDraw || !worldAABB || SCollision::collide(*worldAABB, drawData.cam.viewingAreaGenerousCollider);
if(drawSetupData.shouldDraw) {
if(drawData.mipMapLevelFive > coords.inverseScale)
drawSetupData.mipmapLevel = 5;
if(drawData.mipMapLevelFour > coords.inverseScale)
drawSetupData.mipmapLevel = 4;
else if(drawData.mipMapLevelThree > coords.inverseScale)
drawSetupData.mipmapLevel = 3;
else if(drawData.mipMapLevelTwo > coords.inverseScale)
if(drawData.mipMapLevelTwo > coords.inverseScale)
drawSetupData.mipmapLevel = 2;
else if(drawData.mipMapLevelOne > coords.inverseScale)
drawSetupData.mipmapLevel = 1;

View file

@ -19,11 +19,8 @@
#define DRAWCOMP_MAX_SHIFT_BEFORE_DISAPPEAR 20
#define DRAWCOMP_MIN_SHIFT_BEFORE_DISAPPEAR 11
#define DRAWCOMP_MIPMAP_LEVEL_ONE 1
#define DRAWCOMP_MIPMAP_LEVEL_TWO 2
#define DRAWCOMP_MIPMAP_LEVEL_THREE 3
#define DRAWCOMP_MIPMAP_LEVEL_FOUR 4
#define DRAWCOMP_MIPMAP_LEVEL_FIVE 5
#define DRAWCOMP_MIPMAP_LEVEL_ONE 2
#define DRAWCOMP_MIPMAP_LEVEL_TWO 5
class DrawingProgram;