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.

mask_by_polygroup takes 'group' like hide/isolate_polygroup; --polygroups render flag

islandmed8371759eba22
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 127e51ba..77f9d779 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -247,6 +247,7 @@ int App::renderHeadless() {
camera_.pitch = glm::radians(options_.pitchDegrees);
RenderSettings settings = renderSettings_;
settings.wireframe = options_.wireframe;
+ settings.showPolygroups = settings.showPolygroups || options_.polygroups;
settings.showMesh = !options_.hideMesh;
renderer_.sync(doc_.mesh);
renderer_.syncSplats(doc_.splats, doc_.splatsVersion);
diff --git a/src/app/App.h b/src/app/App.h
index ec4f50bd..14c92071 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -33,6 +33,7 @@ struct AppOptions {
float yawDegrees = -30.0f, pitchDegrees = -15.0f;
int turntable = 0; // headless: render N frames around the model (<path>_000.png ...)
bool wireframe = false;
+ bool polygroups = false; // headless: colour each polygroup
bool hideMesh = false; // headless: show only the splats
std::string demo; // scripted demo to play (see Demo.h)
std::string recordPath; // record the session to this .mp4 (needs ffmpeg) and exit
diff --git a/src/app/PanelMasking.cpp b/src/app/PanelMasking.cpp
index 01052ce1..32d11163 100644
--- a/src/app/PanelMasking.cpp
+++ b/src/app/PanelMasking.cpp
@@ -88,7 +88,7 @@ void App::drawMaskingSection() {
ImGui::SameLine();
ImGui::SetNextItemWidth(-1);
ImGui::SliderFloat("##cavitythreshold", &cavityThreshold_, -0.2f, 0.5f, "threshold %.2f");
- if (ImGui::Button("By polygroup", ImVec2(half, 0))) runCommand("mask_by_polygroup", {{"index", double(maskGroup_)}});
+ if (ImGui::Button("By polygroup", ImVec2(half, 0))) runCommand("mask_by_polygroup", {{"group", double(maskGroup_)}});
if (ImGui::IsItemHovered()) ImGui::SetTooltip("Mask one polygroup (replaces the mask)");
ImGui::SameLine();
ImGui::SetNextItemWidth(-1);
diff --git a/src/app/main.cpp b/src/app/main.cpp
index dcc37953..52de9f93 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -20,6 +20,7 @@ void usage() {
" --size WxH Render size (default 1024x1024)\n"
" --view YAW,PITCH Camera angles in degrees (default -30,-15)\n"
" --wireframe Render with wireframe overlay\n"
+ " --polygroups Render with polygroup colours\n"
" --hide-mesh Render only the Gaussian splats\n"
" --demo NAME Play a scripted demo (sculpt, image-to-3d, brush-lab, game-ready, splats)\n"
" --record out.mp4 Record the demo offscreen to a video (needs ffmpeg) and exit\n"
@@ -41,6 +42,7 @@ int main(int argc, char** argv) {
else if (a == "--size") std::sscanf(next().c_str(), "%dx%d", &options.width, &options.height);
else if (a == "--view") std::sscanf(next().c_str(), "%f,%f", &options.yawDegrees, &options.pitchDegrees);
else if (a == "--wireframe") options.wireframe = true;
+ else if (a == "--polygroups") options.polygroups = true;
else if (a == "--hide-mesh") options.hideMesh = true;
else if (a == "--demo") options.demo = next();
else if (a == "--record") options.recordPath = next();
diff --git a/src/core/Masking.cpp b/src/core/Masking.cpp
index 7322b7f7..3b171bc7 100644
--- a/src/core/Masking.cpp
+++ b/src/core/Masking.cpp
@@ -225,10 +225,10 @@ void registerMaskingCommands(CommandRegistry& registry) {
});
add("mask_by_polygroup", "Mask by Polygroup",
"Mask the vertices of one polygroup (meshes without polygroups are all group 0).",
- {{"index", T::Number, "Polygroup id.", true},
+ {{"group", T::Number, "Polygroup id.", true},
{"add", T::Bool, "Add to the current mask instead of replacing it. Default false.", false}},
[](Mesh& m, const Args& a) {
- return maskByPolygroup(m, uint32_t(std::max(0.0, argNumber(a, "index", 0))), argBool(a, "add", false));
+ return maskByPolygroup(m, uint32_t(std::max(0.0, argNumber(a, "group", 0))), argBool(a, "add", false));
});
}
diff --git a/tests/test_masking.cpp b/tests/test_masking.cpp
index 5798753f..4e64fad8 100644
--- a/tests/test_masking.cpp
+++ b/tests/test_masking.cpp
@@ -245,7 +245,7 @@ TEST(mask_by_polygroup) {
const auto& tri = m.triangles[t];
m.polygroups[t] = (m.positions[tri.x].z + m.positions[tri.y].z + m.positions[tri.z].z) > 0.0f ? 2u : 0u;
}
- CHECK(registry().execute(d, "mask_by_polygroup", {{"index", 2.0}}).ok);
+ CHECK(registry().execute(d, "mask_by_polygroup", {{"group", 2.0}}).ok);
bool ok = true;
for (uint32_t v = 0; v < m.vertexCount(); ++v) {
if (m.positions[v].z > 0.2f) ok &= m.mask[v] == 1.0f;
@@ -253,14 +253,14 @@ TEST(mask_by_polygroup) {
}
CHECK(ok);
// Replace vs add.
- CHECK(registry().execute(d, "mask_by_polygroup", {{"index", 0.0}}).ok);
+ CHECK(registry().execute(d, "mask_by_polygroup", {{"group", 0.0}}).ok);
bool replaced = true;
for (uint32_t v = 0; v < m.vertexCount(); ++v)
if (m.positions[v].z > 0.2f) replaced &= m.mask[v] == 0.0f;
CHECK(replaced);
- CHECK(registry().execute(d, "mask_by_polygroup", {{"index", 2.0}, {"add", true}}).ok);
+ CHECK(registry().execute(d, "mask_by_polygroup", {{"group", 2.0}, {"add", true}}).ok);
CHECK(countMasked(m) == m.vertexCount());
- CHECK(!registry().execute(d, "mask_by_polygroup", {}).ok); // index is required
+ CHECK(!registry().execute(d, "mask_by_polygroup", {}).ok); // group is required
CHECK(registry().execute(d, "undo").ok);
CHECK(registry().execute(d, "undo").ok);
CHECK(registry().execute(d, "undo").ok);