From f82e626686a7ff43413e29b23a98f78496ef3faa Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Mon, 21 Jul 2025 13:01:48 +0300 Subject: [PATCH] Levels of detail for brush stroke decreased to save on memory --- src/DrawComponents/DrawBrushStroke.cpp | 15 ++------------- src/DrawComponents/DrawBrushStroke.hpp | 2 +- src/DrawComponents/DrawComponent.cpp | 8 +------- src/DrawComponents/DrawComponent.hpp | 7 ++----- src/DrawData.cpp | 3 --- src/DrawData.hpp | 3 --- 6 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/DrawComponents/DrawBrushStroke.cpp b/src/DrawComponents/DrawBrushStroke.cpp index 9535a76..d0184d5 100644 --- a/src/DrawComponents/DrawBrushStroke.cpp +++ b/src/DrawComponents/DrawBrushStroke.cpp @@ -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); } } diff --git a/src/DrawComponents/DrawBrushStroke.hpp b/src/DrawComponents/DrawBrushStroke.hpp index 878a2e7..7966785 100644 --- a/src/DrawComponents/DrawBrushStroke.hpp +++ b/src/DrawComponents/DrawBrushStroke.hpp @@ -47,7 +47,7 @@ class DrawBrushStroke : public DrawComponent { virtual SCollision::AABB get_obj_coord_bounds() const override; sk_sp vertices; - std::array, 5> verticesMipMap; + std::array, 3> verticesMipMap; SCollision::BVHContainer collisionTree; private: diff --git a/src/DrawComponents/DrawComponent.cpp b/src/DrawComponents/DrawComponent.cpp index a30c2be..c1b7e7e 100644 --- a/src/DrawComponents/DrawComponent.cpp +++ b/src/DrawComponents/DrawComponent.cpp @@ -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; diff --git a/src/DrawComponents/DrawComponent.hpp b/src/DrawComponents/DrawComponent.hpp index 8dab64d..2c5c42b 100644 --- a/src/DrawComponents/DrawComponent.hpp +++ b/src/DrawComponents/DrawComponent.hpp @@ -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; diff --git a/src/DrawData.cpp b/src/DrawData.cpp index 414da87..3c3d778 100644 --- a/src/DrawData.cpp +++ b/src/DrawData.cpp @@ -6,8 +6,5 @@ void DrawData::refresh_draw_optimizing_values() { clampDrawMinimum = cam.c.inverseScale >> DRAWCOMP_MIN_SHIFT_BEFORE_DISAPPEAR; mipMapLevelOne = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_ONE; mipMapLevelTwo = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_TWO; - mipMapLevelThree = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_THREE; - mipMapLevelFour = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_FOUR; - mipMapLevelFive = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_FOUR; clampDrawMaximum = cam.c.inverseScale << DRAWCOMP_MAX_SHIFT_BEFORE_DISAPPEAR; } diff --git a/src/DrawData.hpp b/src/DrawData.hpp index a42d553..631154b 100644 --- a/src/DrawData.hpp +++ b/src/DrawData.hpp @@ -18,8 +18,5 @@ struct DrawData { WorldScalar clampDrawMaximum; WorldScalar mipMapLevelOne; WorldScalar mipMapLevelTwo; - WorldScalar mipMapLevelThree; - WorldScalar mipMapLevelFour; - WorldScalar mipMapLevelFive; void refresh_draw_optimizing_values(); };