Skip to content

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.

Merge branch 'worktree-agent-a157f4b50329317d5'

islandmed43eaf167f0f1
diff --cc src/core/SubTools.cpp
index 3683bef1,5ed2e9a0..ed6e0419
--- a/src/core/SubTools.cpp
+++ b/src/core/SubTools.cpp
@@@ -207,22 -233,25 +233,34 @@@ void registerSubToolCommands(CommandReg
const std::string path = argString(a, "path");
CommandResult r = CommandRegistry().execute(scratch, "open", {{"path", path}});
if (!r.ok) return r;
- if (scratch.mesh.triangleCount() == 0) return {false, path + " has no mesh to append"};
- m = mergedVisibleMesh(scratch);
- name = fileStem(path);
+ if (scratch.subtoolCount() == 1) {
+ if (scratch.mesh.triangleCount() == 0) return {false, path + " has no mesh to append"};
+ m = std::move(scratch.mesh);
+ name = fileStem(path);
+ } else {
+ const int first = doc.subtoolCount();
+ size_t tris = 0;
+ for (int i = 0; i < scratch.subtoolCount(); ++i) {
+ tris += scratch.subtoolMesh(i).triangleCount();
+ doc.addSubtool(std::move(scratch.subtoolMesh(i)), scratch.subtools[size_t(i)].name, false);
+ }
+ doc.selectSubtool(first);
+ return {true, "Appended " + std::to_string(scratch.subtoolCount()) + " SubTools from " + path + " (" +
+ countText(tris) + ")"};
+ }
} else {
const std::string type = argString(a, "type", "sphere");
+ // Sized from the largest visible SubTool (so repeated appends neither grow nor shrink),
+ // placed beside everything shown.
const AABB scene = doc.visibleBounds();
- const float extent = scene.valid() ? std::max({scene.extent().x, scene.extent().y, scene.extent().z}) : 2.0f;
+ float extent = 0.0f;
+ for (int i = 0; i < doc.subtoolCount(); ++i) {
+ const Mesh& sm = doc.subtoolMesh(i);
+ if (!doc.subtools[size_t(i)].visible || !sm.vertexCount()) continue;
+ const glm::vec3 e = sm.bounds().extent();
+ extent = std::max({extent, e.x, e.y, e.z});
+ }
+ if (extent <= 0.0f) extent = 2.0f;
const float size = extent * float(std::clamp(argNumber(a, "size", 0.35), 0.05, 2.0));
if (type == "sphere") m = makeIcosphere(5, size * 0.5f);
else if (type == "cube") m = makeCube(48, size);