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.

Insert on the model (#34): the drag direction turns the shape about the normal (insert_primitive twist)

islandmed66a68095cb2a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dce52971..be931b8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,9 @@ All notable changes to SculptForge are listed here. The format follows
- Draft strokes are no longer chosen by any hardware tier or on battery (they measured no faster and aren't yet
identical to a full stroke); the Draft Strokes setting still turns them on.
+### Added
+- Insert on the model (#34): the drag's direction also turns the inserted shape about the surface normal.
+
### Fixed
- The brush ring that follows the surface (#25) read the mesh while a predictive stroke's thread was changing it,
which could change where that stroke's dabs landed; it now shows the flat ring during such strokes.
diff --git a/src/app/App.cpp b/src/app/App.cpp
index ba27b1a9..6ae945a6 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -1316,7 +1316,9 @@ void App::onMouseUp() {
runCommand("insert_primitive", {{"type", insertType_}, {"x", double(insertAt_.x)}, {"y", double(insertAt_.y)},
{"z", double(insertAt_.z)}, {"nx", double(insertNormal_.x)},
{"ny", double(insertNormal_.y)}, {"nz", double(insertNormal_.z)},
- {"size", double(2.0f * px * worldPerPx)}});
+ {"size", double(2.0f * px * worldPerPx)},
+ // the drag's direction on screen turns it about the normal
+ {"twist", insertPx_ > 4.0f ? double(glm::degrees(std::atan2(mouseY_ - insertY_, mouseX_ - insertX_))) : 0.0}});
}
if (drag_ == Drag::Stroke && maskClickPending_) maskClickRelease(); // Ctrl+click: blur / sharpen the mask
else if (drag_ == Drag::Stroke && asyncStroke_) {
diff --git a/src/core/SubTools.cpp b/src/core/SubTools.cpp
index 9878faad..9353e84a 100644
--- a/src/core/SubTools.cpp
+++ b/src/core/SubTools.cpp
@@ -303,7 +303,8 @@ void registerSubToolCommands(CommandRegistry& reg) {
{{"type", T::String, "sphere, cube, cylinder, cone, torus, capsule or quadsphere", false},
{"x", T::Number, "surface point x", true}, {"y", T::Number, "surface point y", true}, {"z", T::Number, "surface point z", true},
{"nx", T::Number, "surface normal x", false}, {"ny", T::Number, "surface normal y", false}, {"nz", T::Number, "surface normal z", false},
- {"size", T::Number, "size in scene units (default 0.2)", false}},
+ {"size", T::Number, "size in scene units (default 0.2)", false},
+ {"twist", T::Number, "turn about the normal in degrees (default 0)", false}},
[](Document& doc, const Args& a) -> CommandResult {
const std::string blocked = dyntopoBlocker(doc.mesh);
if (!blocked.empty()) return {false, "Can't insert: " + blocked};
@@ -330,6 +331,11 @@ void registerSubToolCommands(CommandRegistry& reg) {
const glm::mat3 k(0, v.z, -v.y, -v.z, 0, v.x, v.y, -v.x, 0);
rot = glm::mat3(1.0f) + k + k * k * (1.0f / (1.0f + c));
}
+ const float twist = glm::radians(float(argNumber(a, "twist", 0.0)));
+ if (twist != 0.0f) { // about the primitive's own axis (Y) first, then onto the normal
+ const float cs = std::cos(twist), sn = std::sin(twist);
+ rot = rot * glm::mat3(cs, 0, -sn, 0, 1, 0, sn, 0, cs);
+ }
const glm::vec3 at(float(argNumber(a, "x", 0.0)), float(argNumber(a, "y", 0.0)), float(argNumber(a, "z", 0.0)));
for (auto& p : prim.positions) p = at + rot * p;
uint32_t group = 0;