Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Recent colours on the left shelf: the last eight paint colours, click to use (Oslen on Discord)
islandmedd8ee46ef4f51
diff --git a/changes/feat-recent-colours.md b/changes/feat-recent-colours.mdnew file mode 100644index 00000000..a3688bb1--- /dev/null+++ b/changes/feat-recent-colours.md@@ -0,0 +1,11 @@+---+whats_new: **Recent colours**: the last eight colours you painted with sit under the colour picker on the left+ shelf; click one to paint with it again. Thanks Oslen on Discord.+added: **Recent colours** (Oslen on Discord): under the left shelf's two swatches, the last eight paint colours a+ stroke or Fill used, newest first, in rows of four; click one to paint with it. Kept in the preferences, so they+ survive a restart.+testers:+ - Any OS: Paint brush (P), paint with three colours; three swatches appear under the colour picker, newest first.+ Click the oldest: the picker shows it. Restart: the swatches are still there.+ - Windows at 150%: the left shelf's recent row and Fill stay visible.+---diff --git a/docs/guide/vertex-paint.md b/docs/guide/vertex-paint.mdindex 92803a9b..fe33ecb9 100644--- a/docs/guide/vertex-paint.md+++ b/docs/guide/vertex-paint.md@@ -45,6 +45,8 @@ paints the current colour along its stroke. The Smooth brush and <kbd>Shift</kbd- The **left shelf** has a colour picker (a square plus a hue strip), two swatches and a **Fill** button. Clickingthe second swatch swaps it with the main colour.+- Under the two swatches, the **recent colours** are the last eight you painted with or filled with, newest first.+ Click one to paint with it again. They are kept when you restart.- The **Paint** menu has a larger hue wheel with a hex value, ten preset swatches (white, near black, red,orange, yellow, green, blue, purple, skin and brown) and the fill buttons.- Press <kbd>C</kbd> with the cursor over the model to pick the colour under it (the mesh needs vertex paint for this,diff --git a/src/app/App.h b/src/app/App.hindex c2d83209..0e5d6eb9 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -1828,6 +1828,11 @@ private:std::vector<std::string> collapsedPalettes_; // tray palettes showing only their headervoid autoCollapseTray(bool right, const std::string& keep);glm::vec3 secondaryColor_{1.0f, 1.0f, 1.0f}; // the left shelf's second swatch (click swaps, "Alternate")+ // The left shelf's recent colours: the last paint colours a stroke or Fill used, newest first (Oslen on Discord).+ // Saved in project.json (the app's preferences), linear like doc_.paintColor.+ static constexpr size_t kRecentColorsMax = 8;+ std::vector<glm::vec3> recentColors_;+ void rememberPaintColor(const glm::vec3& linear);uint64_t activeTrisKey_ = ~uint64_t(0); // the top shelf's ActiveTris, recounted when the scene changessize_t activeTris_ = 0;float bottomTileW_ = 58.0f; // bottom shelf tiles shrink (down to 44 px) before the shelf scrollsdiff --git a/src/app/I18nSimplifiedChinese.cpp b/src/app/I18nSimplifiedChinese.cppindex 239c2c00..916a159f 100644--- a/src/app/I18nSimplifiedChinese.cpp+++ b/src/app/I18nSimplifiedChinese.cpp@@ -4376,6 +4376,11 @@ constexpr Entry kSimplifiedChinese[] = {"旋转模板,以逆时针度数表示;Ctrl+点击以输入。"},{"Centre the Stencil again, upright, 80% of the view's height.","将模板重新居中、摆正,高度为视图的 80%。"},+ // Recent colours (Oslen on Discord)+ {"Recent colour",+ "最近颜色"},+ {"A colour you painted with lately: click to paint with it again.",+ "你最近用过的绘制颜色:点击即可再次使用。"},};} // namespacediff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cppindex 3dc741f0..bf01c1e7 100644--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@ -4854,6 +4854,11 @@ constexpr Entry kSpanish[] = {"Barra superior"},{"Status bar","Barra de estado"},+ // Recent colours (Oslen on Discord)+ {"Recent colour",+ "Color reciente"},+ {"A colour you painted with lately: click to paint with it again.",+ "Un color con el que pintaste hace poco: haz clic para volver a pintar con él."},};} // namespacediff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cppindex 9a588b62..cb3cf0a4 100644--- a/src/app/I18nTraditionalChinese.cpp+++ b/src/app/I18nTraditionalChinese.cpp@@ -4374,6 +4374,11 @@ constexpr Entry kTraditionalChinese[] = {"旋轉模板,以逆時針度數表示;Ctrl+點擊以輸入。"},{"Centre the Stencil again, upright, 80% of the view's height.","將模板重新置中、擺正,高度為視圖的 80%。"},+ // Recent colours (Oslen on Discord)+ {"Recent colour",+ "最近顏色"},+ {"A colour you painted with lately: click to paint with it again.",+ "你最近用過的繪製顏色:點擊即可再次使用。"},};} // namespacediff --git a/src/app/PanelProject.cpp b/src/app/PanelProject.cppindex 8dc77b39..1142be6d 100644--- a/src/app/PanelProject.cpp+++ b/src/app/PanelProject.cpp@@ -135,6 +135,13 @@ void App::initProject() {newLookCardDone_ = prefs["new_look_card_done"].asBool(false);quickTourDone_ = prefs["quick_tour_done"].asBool(false);uiPrefs_.confirmSubdivide = prefs["confirm_subdivide"].asBool(uiPrefs_.confirmSubdivide); // (Don't ask again)+ recentColors_.clear();+ for (const auto& c : prefs["recent_colors"].items()) {+ if (recentColors_.size() >= kRecentColorsMax || !c.isArray()) break;+ glm::vec3 v(0.0f);+ readVec3(c, v);+ recentColors_.push_back(glm::clamp(v, glm::vec3(0.0f), glm::vec3(1.0f)));+ }if (!uiPrefs_.lookSaved && !uiConfigDeterministic_) {UiPrefs saved = uiPrefs_;if (!lookFromJson(prefs["ui_look"], saved)) {@@ -219,10 +226,23 @@ void App::saveProjectPrefs() {prefs.set("new_look_card_done", newLookCardDone_);prefs.set("quick_tour_done", quickTourDone_);prefs.set("confirm_subdivide", uiPrefs_.confirmSubdivide);+ Json colours = Json::array(); // the left shelf's recent colours, newest first+ for (const glm::vec3& c : recentColors_) colours.push(vec3Json(c));+ prefs.set("recent_colors", std::move(colours));std::string err; // (temp file, then rename: a quit that ends mid-write leaves the last one whole)if (!writeJsonAtomic(prefDir_ + "project.json", prefs, err)) SDL_Log("%s", err.c_str());}+void App::rememberPaintColor(const glm::vec3& linear) {+ // Already the newest: nothing to move or save (each stroke with the same colour lands here).+ auto same = [&](const glm::vec3& c) { return glm::all(glm::lessThan(glm::abs(c - linear), glm::vec3(0.5f / 255.0f))); };+ if (!recentColors_.empty() && same(recentColors_.front())) return;+ recentColors_.erase(std::remove_if(recentColors_.begin(), recentColors_.end(), same), recentColors_.end());+ recentColors_.insert(recentColors_.begin(), linear);+ if (recentColors_.size() > kRecentColorsMax) recentColors_.resize(kRecentColorsMax);+ saveProjectPrefs();+}+void App::rememberRecent(const std::string& path) {if (path.empty() || prefDir_.empty()) return;std::error_code ec;diff --git a/src/app/PanelVertexPaint.cpp b/src/app/PanelVertexPaint.cppindex 1816346d..0b5b66a6 100644--- a/src/app/PanelVertexPaint.cpp+++ b/src/app/PanelVertexPaint.cpp@@ -421,6 +421,7 @@ void App::paintAt(const DabParams& dab) {void App::beginPaintStroke() {paintSnapshot_.reset();+ if (strokePaint_) rememberPaintColor(doc_.paintColor); // (the left shelf's recent colours)const Mesh& m = doc_.mesh;if (strokePaint_ && paintsTexture(m)) { // texture painting: tiles go into the stroke's undo stepif (!texturePainter_.begin(doc_.mesh, doc_.paintMaterial.channels)) {diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cppindex c41faed6..1fdf8240 100644--- a/src/app/Pickers.cpp+++ b/src/app/Pickers.cpp@@ -54,6 +54,7 @@ constexpr ImU32 kMarkerDark = IM_COL32(0, 0, 0, 150); // their outline,constexpr float kFieldGap = 4.0f; // one gap between every part of the colour field (square, strip, swatches, Fill)constexpr float kHueStripW = 10.0f; // wide enough to read as a control next to the squareconstexpr float kSwatchH = 18.0f;+constexpr float kRecentH = 12.0f; // the recent colours' rows: thinconst SDL_DialogFileFilter kAlphaFilters[] = {{"Images", "png;jpg;jpeg;bmp;tga;psd;gif"}, {"All files", "*"}};@@ -1636,6 +1637,23 @@ void App::drawColorWidget(float width) {rounding, s, ImGui::IsItemHovered());ui::HelpText("Second colour", nullptr, "Click to swap it with the main colour.", "Left shelf");if (swap) std::swap(doc_.paintColor, secondaryColor_);+ // The recent colours (Oslen on Discord): the last ones painted with, newest first, in rows of four (a second row+ // once there are more than four) across the column's width. Click one to paint with it.+ if (!recentColors_.empty()) {+ constexpr int kCols = 4;+ const float rw = std::floor((width - gap * float(kCols - 1)) / float(kCols)), rh = kRecentH * s;+ for (size_t i = 0; i < recentColors_.size(); ++i) {+ if (i % kCols != 0) ImGui::SameLine();+ const ImVec2 ra = ImGui::GetCursorScreenPos();+ const std::string id = "##recent" + std::to_string(i);+ const bool use = ImGui::InvisibleButton(id.c_str(), ImVec2(rw, rh));+ const glm::vec3 c = linearToSrgb(recentColors_[i]);+ swatch(dl, ra, ImVec2(ra.x + rw, ra.y + rh), ImVec4(c.x, c.y, c.z, 1.0f), theme::rounding(2.0f * s), s,+ ImGui::IsItemHovered());+ ui::HelpText("Recent colour", nullptr, "A colour you painted with lately: click to paint with it again.", "Left shelf");+ if (use) doc_.paintColor = recentColors_[i];+ }+ }ui::ActionButton(*this, "color.fill", ImVec2(width, 0), ui::Look::IconLabel);ImGui::PopStyleVar();ui::HelpAction(*this, "color.fill");diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex ad87321d..3a8a4b8a 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -660,7 +660,10 @@ void App::registerShellActions() {add({"geometry.to_splats", "Sculpt to Splats", nullptr, "Turn the sculpt into Gaussian splats.", "Splats", "","mesh_to_splats", [this] { runCommand("mesh_to_splats"); }, nullptr, nullptr});add({"color.fill", "Fill", ICON_LC_PAINT_BUCKET, "Fill the unmasked area with the colour.", "Color", "",- "paint_fill", [this] { runCommand("paint_fill", {{"color", colorToHex(doc_.paintColor)}}); }, nullptr, nullptr});+ "paint_fill", [this] {+ rememberPaintColor(doc_.paintColor);+ runCommand("paint_fill", {{"color", colorToHex(doc_.paintColor)}});+ }, nullptr, nullptr});// The shell itself.add({"ui.toggle_shelves", "Shelves", ICON_LC_MAXIMIZE, "Hide or show the shelves and trays around the canvas.", "Preferences",diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex b8b4cea9..b3ce6391 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -185,7 +185,7 @@// the pick filter, x1000 radii), dabs, pixel_density (2 on a HiDPI screen), input_style (0 classic, 1 SculptForge, 2 Blender), turntable, orbit_lock (0 free, 1 Y, 2 X, 3 Z),// camera_ortho, mask_brush (Blender's Mask brush on), shortcut_conflicts (keys two actions// claim), brush_type (BrushType-// index, -1 for a custom brush or Paint), last_dab_x / last_dab_y (window pixels), paint_r+// index, -1 for a custom brush or Paint), last_dab_x / last_dab_y (window pixels), paint_r, recent_colors (the left shelf's recent paint colours)// gizmo_mode (0 Draw, 1 Move, 2 Scale, 3 Rotate), gizmo_hover (handle under the cursor,// 0 = none, in gizmo_drag's order from 1), gizmo_falloff, pivot_x / pivot_y / pivot_z,// center_x / center_y / center_z and size_x / size_y / size_z (active mesh bounds)@@ -857,6 +857,7 @@ double Demo::query(const std::string& name, bool& known) const {}if (name == "last_dab_x") return app_.lastDabScreen_.x;if (name == "last_dab_y") return app_.lastDabScreen_.y;+ if (name == "recent_colors") return double(app_.recentColors_.size()); // the left shelf's recent coloursif (name == "paint_r") return std::round(255.0f * linearToSrgb(app_.doc_.paintColor).x);if (name == "gizmo_mode") return double(int(app_.gizmo_.mode));if (name == "gizmo_hover") return double(int(app_.gizmo_.hover));diff --git a/tests/ui/recent_colors.sfui b/tests/ui/recent_colors.sfuinew file mode 100644index 00000000..a494eccb--- /dev/null+++ b/tests/ui/recent_colors.sfui@@ -0,0 +1,54 @@+# The left shelf's recent colours (Oslen on Discord): a paint stroke or Fill puts its colour first in a thin row under+# the two swatches; clicking one paints with it again. Kept in the preferences (project.json).+run ui_look look=classic layout=classic+run new_sphere subdivisions=4+expect_value recent_colors == 0+expect_not "##recent0"++# Two strokes in red, then one in blue: two recent colours, blue first.+run set_color color=c81e1e+key p+stroke 0.40 0.45 0.60 0.45+stroke 0.40 0.50 0.60 0.50+expect_value recent_colors == 1+run set_color color=1e3cc8+stroke 0.40 0.55 0.60 0.55+expect_value recent_colors == 2+expect_value paint_r == 30+shot two-recent++# Red is second: clicking it makes it the paint colour (the row keeps its order until it is painted with).+click "##recent1"+expect_value paint_r == 200+expect_value recent_colors == 2++# Fill counts too: green joins the front; red painted again moves back to the front without a duplicate.+run set_color color=1ec83c+click "Fill##color.fill"+expect_value recent_colors == 3+run set_color color=c81e1e+stroke 0.40 0.60 0.60 0.60+expect_value recent_colors == 3+click "##recent0"+expect_value paint_r == 200++# Nine colours keep only the newest eight.+run set_color color=1a1a1a+stroke 0.40 0.62 0.60 0.62+run set_color color=2b2b2b+stroke 0.40 0.64 0.60 0.64+run set_color color=3c3c3c+stroke 0.40 0.66 0.60 0.66+run set_color color=4d4d4d+stroke 0.40 0.68 0.60 0.68+run set_color color=5e5e5e+stroke 0.40 0.70 0.60 0.70+run set_color color=6f6f6f+stroke 0.40 0.72 0.60 0.72+expect_value recent_colors == 8+expect "##recent7"+shot eight-recent+ui_scale 200+wait_idle 10+expect "##recent7"+shot eight-recent-200