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.

Creature bones (#154): a built-in insert set of 13 original fantasy creature bones

islandmedf949cd4da6e6
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83b4c793..56f1dcbd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -221,6 +221,11 @@ embed_files(${CMAKE_CURRENT_BINARY_DIR}/EmbeddedRecipes.cpp sf::assets
recipeDirtAndDust ${CMAKE_CURRENT_SOURCE_DIR}/assets/materials/dirt_and_dust.sfmaterial
recipeRustedIron ${CMAKE_CURRENT_SOURCE_DIR}/assets/materials/rusted_iron.sfmaterial)
target_sources(sculptforge_core PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/EmbeddedRecipes.cpp)
+# The built-in insert sets (core/Parts.h builtinInsertSets): Creature bones (#154), original pieces made by
+# tools/creature-bones/build.sh, a zlib-compressed multi-object OBJ.
+embed_files(${CMAKE_CURRENT_BINARY_DIR}/EmbeddedInsertSets.cpp sf::assets
+ insertSetCreatureBones ${CMAKE_CURRENT_SOURCE_DIR}/assets/insert-sets/creature-bones.obj.z)
+target_sources(sculptforge_core PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/EmbeddedInsertSets.cpp)
target_include_directories(sculptforge_core PUBLIC src PRIVATE third_party/stb third_party/ufbx third_party/xatlas third_party/mikktspace third_party/tinyexr)
if(WIN32)
target_link_libraries(sculptforge_core PRIVATE shell32 advapi32) # core/Trash.cpp: the Recycle Bin; core/DiscordPresence.cpp: the pipe server's user
diff --git a/README.md b/README.md
index 042d95e6..4c8a773d 100644
--- a/README.md
+++ b/README.md
@@ -28,11 +28,6 @@
<a href="https://sculptforge.app/support.html">Membership</a>
</p>
-<p align="center"><sub>
- If sculptforge.app is blocked on your network: <a href="https://github.com/islandmed/SculptForge/releases/latest">download from GitHub Releases</a>
- and read the <a href="docs/guide/index.md">user guide on GitHub</a>.
-</sub></p>
-
<p align="center">
<a href="https://sculptforge.app/#demos"><img src="docs/images/showcase.jpg" width="800" alt="A detailed lion head sculpted in SculptForge"></a>
</p>
@@ -168,7 +163,7 @@ you modify it in-house without publishing your changes. See **[docs/studios.md](
**[Download for macOS](https://github.com/islandmed/SculptForge/releases/latest/download/SculptForge-macos.dmg)** ·
**[Download for Linux](https://github.com/islandmed/SculptForge/releases/latest/download/SculptForge-linux-x86_64.AppImage)** (AppImage, x86_64)
-Every link gets the newest version, straight from GitHub (works where sculptforge.app is blocked; the [guide is here too](docs/guide/index.md)). **[install/](install/README.md)** has the full list (.deb, .rpm, ARM64,
+Every link gets the newest version. **[install/](install/README.md)** has the full list (.deb, .rpm, ARM64,
portable .zip, Arch) and what to do after downloading. Or install with one command:
```sh
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index d7fefff3..705fb6c0 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -43,6 +43,10 @@ and how big, and checks a pinned SHA-256 before use) and runs as separate progra
| [Brush](https://github.com/ArthurBrussee/brush) | 0.3.0 | Apache License 2.0 | Its GitHub release (Windows x64, Linux x64, macOS arm64) |
| [COLMAP](https://github.com/colmap/colmap) | 4.2.1 | BSD 3-Clause License | Its GitHub release (Windows x64, no CUDA); elsewhere the system's package |
+The built-in **Creature bones** insert set (assets/insert-sets/creature-bones.obj.z, embedded) is not third-party:
+its pieces are original SculptForge designs, generated from simple forms by tools/creature-bones (no outside mesh,
+scan, stock model or reference creature was used), under SculptForge's own licence, GPL-3.0-or-later.
+
ffmpeg, used to read video frames, is never downloaded: SculptForge uses the one on the system, if any. The test
capture in tests/data/splat_capture is generated by tools/splat/make_test_capture.py and is CC0.
diff --git a/assets/fonts/NotoSansSC-UI.otf b/assets/fonts/NotoSansSC-UI.otf
index 8d053681..896af984 100644
Binary files a/assets/fonts/NotoSansSC-UI.otf and b/assets/fonts/NotoSansSC-UI.otf differ
diff --git a/assets/fonts/NotoSansTC-UI.otf b/assets/fonts/NotoSansTC-UI.otf
index 1bd2e461..8738599c 100644
Binary files a/assets/fonts/NotoSansTC-UI.otf and b/assets/fonts/NotoSansTC-UI.otf differ
diff --git a/assets/insert-sets/creature-bones.obj.z b/assets/insert-sets/creature-bones.obj.z
new file mode 100644
index 00000000..cdb68820
Binary files /dev/null and b/assets/insert-sets/creature-bones.obj.z differ
diff --git a/changes/feat-creature-bones.md b/changes/feat-creature-bones.md
new file mode 100644
index 00000000..ba0ae4ff
--- /dev/null
+++ b/changes/feat-creature-bones.md
@@ -0,0 +1,18 @@
+---
+whats_new: **Creature bones**: **Append > Insert on the model > Creature bones** is a built-in set of original
+ fantasy creature bones (skull, jaw, teeth, horns, spine, ribs, limb and wing bones, claws, tail): pick one
+ and drag it onto your model, no file needed. Thanks @kenttumanda123-netizen (#154).
+highlight: Creature bones: a built-in insert set of 13 original bones
+added: **Creature bones** (Append > Insert on the model, #154): a built-in insert set of 13 original fantasy creature
+ bones (Skull, Jaw, Fang, Blade tooth, Swept horn, Spiral horn, Claw, Vertebra, Tail vertebrae, Rib, Limb
+ bone, Wing bone, Wing finger), clean closed quad meshes for dividing and sculpting, generated in-house by
+ tools/creature-bones. Commands: `insert_set_items set=builtin:creature-bones`, `insert_mesh set=builtin:creature-bones
+ index=<n>`. Translated piece names. Thanks @kenttumanda123-netizen.
+testers:
+ - Any OS: Append > Insert on the model > Creature bones; the Insert set window shows 13 thumbnails. Click Skull, drag
+ on a sphere: a skull stands on the surface. Try a Claw with Symmetry X on: two mirrored claws. Ctrl+Z removes them.
+ - Windows: the set works on a fresh install (it's written to %APPDATA%\SculptForge\SculptForge\insert-sets).
+ - Preferences > Interface > Language Spanish or Chinese: the menu item, window title and tiles are translated.
+---
+Pieces are designed from distance fields (tools/creature-bones/pieces.py), meshed with surface nets and
+quad-remeshed by sculptforge-cli; build.sh refuses a piece that is open, non-manifold or in several parts.
diff --git a/changes/site-blocked-fallback.md b/changes/site-blocked-fallback.md
deleted file mode 100644
index b3a17a3b..00000000
--- a/changes/site-blocked-fallback.md
+++ /dev/null
@@ -1 +0,0 @@
-- Site: GitHub fallback links in the README for networks that block sculptforge.app; security.txt (RFC 9116) pointing to GitHub private vulnerability reporting.
diff --git a/docs/guide/parts.md b/docs/guide/parts.md
index 0703c798..f2e8a653 100644
--- a/docs/guide/parts.md
+++ b/docs/guide/parts.md
@@ -68,11 +68,25 @@ Click **Append** and choose:
the next item and `[` to the previous one (around the set; brush size keys come back once you stop). Esc or the
window's close button stops. (Commands: `insert_set_items set=<path>` lists them;
`insert_mesh set=<path> index=<n>` inserts item `n`, 0 being the first.)
+ **Creature bones**, at the end of the same menu, is a set that comes with SculptForge: no file to pick (see below).
- **From file...**: a model (`.obj`, `.fbx`, `.glb`, `.gltf`, `.ply`, `.stl`, Bridge files, `.usda`, `.usd`, `.usdz`) or
a project (`.sfproj`). A file with several objects adds one Part per object.
The new Part becomes the active one.
+### Creature bones
+
+**Append > Insert on the model > Creature bones** opens a built-in insert set of original fantasy creature bones to
+start from: Skull, Jaw, Fang, Blade tooth, Swept horn, Spiral horn, Claw, Vertebra, Tail vertebrae, Rib,
+Limb bone, Wing bone and Wing finger. Click one in the **Insert set** window and drag on the model, as with any set;
+horns, claws and teeth grow from where you drag. With **Symmetry** X on, a horn or a claw gets its mirrored twin.
+
+Each piece is a clean, closed quad mesh of 500 to 4,200 faces, so it takes **Divide** and sculpting well: insert, then
+sculpt the joins smooth, or **Voxel Remesh** to fuse the piece into the model. Drag pieces onto an empty **Plane** or **Sphere**
+Part to build a skeleton of their own Part. The pieces were designed for SculptForge (tools/creature-bones in the
+source) and come under the app's licence, GPL-3.0. (Commands: `insert_set_items set=builtin:creature-bones`;
+`insert_mesh set=builtin:creature-bones index=<n>`.)
+
You can also add files as Parts from elsewhere:
- **Import** in the Tool palette header (or **File > Import**) adds a model file as a new Part.
diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD
index 90b01386..5bcbc270 100644
--- a/packaging/arch/PKGBUILD
+++ b/packaging/arch/PKGBUILD
@@ -1,6 +1,6 @@
# Maintainer: The SculptForge contributors <https://github.com/islandmed/SculptForge>
pkgname=sculptforge
-pkgver=0.11.10
+pkgver=0.11.9
pkgrel=1
pkgdesc="Free, open-source digital sculpting app with classic sculpting keys, for artists and game pipelines"
arch=('x86_64' 'aarch64')
@@ -15,7 +15,7 @@ _glm=1.0.1
source=("$pkgname-$pkgver.tar.gz::https://github.com/islandmed/SculptForge/archive/refs/tags/v$pkgver.tar.gz"
"imgui-$_imgui.tar.gz::https://github.com/ocornut/imgui/archive/refs/tags/v$_imgui.tar.gz"
"glm-$_glm.tar.gz::https://github.com/g-truc/glm/archive/refs/tags/$_glm.tar.gz")
-sha256sums=('603ea41a112fdea8ddb1dda219eca32d723b4473da311d718e8fcb65be9588be'
+sha256sums=('89e6db5cfd0ac5d8651c5262c14f2beb644557c94adac8f298cd37b4a1e59414'
'3872a5f90df78fced023c1945f4466b654fd74573370b77b17742149763a7a7c'
'9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c')
diff --git a/src/app/I18nSimplifiedChinese.cpp b/src/app/I18nSimplifiedChinese.cpp
index c5bf7679..bc736d7b 100644
--- a/src/app/I18nSimplifiedChinese.cpp
+++ b/src/app/I18nSimplifiedChinese.cpp
@@ -328,6 +328,21 @@ constexpr Entry kSimplifiedChinese[] = {
{"Active Part's copy", "当前部件的副本"},
{"Insert set from file...", "从文件载入插入集..."},
{"Insert set from folder...", "从文件夹载入插入集..."},
+ {"Creature bones", "生物骨骼"},
+ {"Skull", "头骨"},
+ {"Jaw", "下颌"},
+ {"Fang", "獠牙"},
+ {"Blade tooth", "刃齿"},
+ {"Swept horn", "弯角"},
+ {"Spiral horn", "螺旋角"},
+ {"Claw", "爪"},
+ {"Vertebra", "脊椎骨"},
+ {"Tail vertebrae", "尾椎"},
+ {"Rib", "肋骨"},
+ {"Limb bone", "肢骨"},
+ {"Wing bone", "翼骨"},
+ {"Wing finger", "翼指"},
+ {"Original creature bones to build on: skull, jaw, teeth, horns, spine, ribs, limb and wing bones, claws and tail", "原创的生物骨骼,可直接拿来发展:头骨、下颌、牙齿、角、脊椎、肋骨、肢骨与翼骨、爪和尾巴"},
{"A model file with several objects: insert them one at a time", "包含多个对象的模型文件:逐个插入"},
{"A folder of .obj, .ply or .glb files: insert them one at a time", "存放 .obj、.ply 或 .glb 文件的文件夹:逐个插入"},
{"Insert set", "插入集"},
diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cpp
index 3a4da3d8..c9e57246 100644
--- a/src/app/I18nSpanish.cpp
+++ b/src/app/I18nSpanish.cpp
@@ -371,6 +371,21 @@ constexpr Entry kSpanish[] = {
{"Active Part's copy", "Copia de la pieza activa"},
{"Insert set from file...", "Conjunto para insertar desde archivo..."},
{"Insert set from folder...", "Conjunto para insertar desde carpeta..."},
+ {"Creature bones", "Huesos de criatura"},
+ {"Skull", "Cráneo"},
+ {"Jaw", "Mandíbula"},
+ {"Fang", "Colmillo"},
+ {"Blade tooth", "Diente cortante"},
+ {"Swept horn", "Cuerno curvo"},
+ {"Spiral horn", "Cuerno en espiral"},
+ {"Claw", "Garra"},
+ {"Vertebra", "Vértebra"},
+ {"Tail vertebrae", "Vértebras de la cola"},
+ {"Rib", "Costilla"},
+ {"Limb bone", "Hueso de extremidad"},
+ {"Wing bone", "Hueso del ala"},
+ {"Wing finger", "Dedo del ala"},
+ {"Original creature bones to build on: skull, jaw, teeth, horns, spine, ribs, limb and wing bones, claws and tail", "Huesos de criatura originales para empezar: cráneo, mandíbula, dientes, cuernos, columna, costillas, huesos de extremidades y alas, garras y cola"},
{"A model file with several objects: insert them one at a time", "Un archivo de modelo con varios objetos: insértalos de uno en uno"},
{"A folder of .obj, .ply or .glb files: insert them one at a time", "Una carpeta de archivos .obj, .ply o .glb: insértalos de uno en uno"},
{"Insert set", "Conjunto para insertar"},
diff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cpp
index deab6e0f..da8a9f2f 100644
--- a/src/app/I18nTraditionalChinese.cpp
+++ b/src/app/I18nTraditionalChinese.cpp
@@ -328,6 +328,21 @@ constexpr Entry kTraditionalChinese[] = {
{"Active Part's copy", "作用中部件的副本"},
{"Insert set from file...", "從檔案載入插入集..."},
{"Insert set from folder...", "從資料夾載入插入集..."},
+ {"Creature bones", "生物骨骼"},
+ {"Skull", "頭骨"},
+ {"Jaw", "下顎"},
+ {"Fang", "獠牙"},
+ {"Blade tooth", "刃齒"},
+ {"Swept horn", "彎角"},
+ {"Spiral horn", "螺旋角"},
+ {"Claw", "爪"},
+ {"Vertebra", "脊椎骨"},
+ {"Tail vertebrae", "尾椎"},
+ {"Rib", "肋骨"},
+ {"Limb bone", "肢骨"},
+ {"Wing bone", "翼骨"},
+ {"Wing finger", "翼指"},
+ {"Original creature bones to build on: skull, jaw, teeth, horns, spine, ribs, limb and wing bones, claws and tail", "原創的生物骨骼,可直接拿來發展:頭骨、下顎、牙齒、角、脊椎、肋骨、肢骨與翼骨、爪和尾巴"},
{"A model file with several objects: insert them one at a time", "含有多個物件的模型檔案:逐一插入"},
{"A folder of .obj, .ply or .glb files: insert them one at a time", "存放 .obj、.ply 或 .glb 檔案的資料夾:逐一插入"},
{"Insert set", "插入集"},
diff --git a/src/app/PanelParts.cpp b/src/app/PanelParts.cpp
index 0ba8711f..959e34eb 100644
--- a/src/app/PanelParts.cpp
+++ b/src/app/PanelParts.cpp
@@ -559,6 +559,14 @@ void App::drawPartsContents() {
SDL_ShowOpenFolderDialog(onAppendChosen, &dialogRequests_[int(FileAction::InsertSet)], window_, nullptr, false);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
ImGui::SetTooltip("%s", tr("A folder of .obj, .ply or .glb files: insert them one at a time"));
+ // The built-in sets (core/Parts.h): no file to pick.
+ for (const BuiltinInsertSet& b : builtinInsertSets()) {
+ const std::string path = std::string(kBuiltinInsertSetPrefix) + b.id;
+ if (ImGui::MenuItem(tr(b.name), nullptr, insertSetActive() && insertSet_.path == path)) chooseInsertSet(path);
+ if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
+ ImGui::SetTooltip("%s", tr("Original creature bones to build on: skull, jaw, teeth, horns, spine, "
+ "ribs, limb and wing bones, claws and tail"));
+ }
ImGui::EndMenu();
}
if (ImGui::MenuItem(tr("From file...")))
@@ -836,7 +844,11 @@ void App::drawInsertSetPicker() {
const std::string title = std::string(tr("Insert set")) + "###insertset";
if (ImGui::Begin(title.c_str(), &open, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing)) {
const auto set = std::filesystem::path(std::u8string(insertSet_.path.begin(), insertSet_.path.end())).lexically_normal();
- const std::string name = (set.has_filename() ? set.filename() : set.parent_path().filename()).string();
+ std::string name = (set.has_filename() ? set.filename() : set.parent_path().filename()).string();
+ const BuiltinInsertSet* builtin = nullptr;
+ for (const BuiltinInsertSet& b : builtinInsertSets())
+ if (insertSet_.path == std::string(kBuiltinInsertSetPrefix) + b.id) builtin = &b;
+ if (builtin) name = tr(builtin->name);
ImGui::TextDisabled("%s (%d)", name.c_str(), int(insertSet_.items.size()));
const float spacing = ImGui::GetStyle().ItemSpacing.x;
const int perRow = std::clamp(int(insertSet_.items.size()), 1, 5);
@@ -844,10 +856,11 @@ void App::drawInsertSetPicker() {
const InsertSetItem& it = insertSet_.items[i];
if (i % size_t(perRow)) ImGui::SameLine(0, spacing);
const std::string id = "##insertset" + std::to_string(i);
- if (AssetTile(id.c_str(), thumbs_.insertSetItem(it.file, it.object), ICON_LC_BOX, it.name, tile,
+ const std::string label = builtin ? tr(it.name) : it.name; // a built-in set's names are ours to translate
+ if (AssetTile(id.c_str(), thumbs_.insertSetItem(it.file, it.object), ICON_LC_BOX, label, tile,
int(i) == insertSet_.index))
selectInsertSetItem(int(i));
- if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) ImGui::SetTooltip("%s", it.name.c_str());
+ if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) ImGui::SetTooltip("%s", label.c_str());
}
AssetTileHoverGlow();
ImGui::TextDisabled("%s", tr("[ / ] previous / next Esc stops"));
diff --git a/src/core/Parts.cpp b/src/core/Parts.cpp
index 61c591c1..0ebe9c27 100644
--- a/src/core/Parts.cpp
+++ b/src/core/Parts.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "core/Parts.h"
+#include "core/BrushLibrary.h"
#include "core/Commands.h"
#include "core/Dyntopo.h"
#include "core/Masking.h"
@@ -14,14 +15,27 @@
#include "io/ObjIO.h"
#include "io/PlyIO.h"
+#include <stb_image.h>
+
#include <cctype>
#include <algorithm>
+#include <cstdlib>
#include <filesystem>
+#include <fstream>
+#include <iterator>
#include <map>
+#include <memory>
+#include <mutex>
#include <numeric>
#include <utility>
#include <vector>
+// assets/insert-sets/*.obj.z (zlib-compressed OBJ; tools/creature-bones/build.sh), embedded by CMakeLists.txt.
+namespace sf::assets {
+extern const unsigned char insertSetCreatureBones[];
+extern const unsigned long long insertSetCreatureBones_size;
+} // namespace sf::assets
+
namespace sf {
Mesh mergeMeshes(const std::vector<const Mesh*>& meshes) {
@@ -257,8 +271,70 @@ bool loadInsertObjects(const std::string& path, std::vector<MeshObject>& out, st
} // namespace
-bool listInsertSet(const std::string& path, std::vector<InsertSetItem>& items, std::string& error) {
+const std::vector<BuiltinInsertSet>& builtinInsertSets() {
+ static const std::vector<BuiltinInsertSet> sets = {{"creature-bones", "Creature bones"}};
+ return sets;
+}
+
+bool resolveInsertSetPath(const std::string& path, std::string& file, std::string& error) {
+ const std::string prefix = kBuiltinInsertSetPrefix;
+ if (path.compare(0, prefix.size(), prefix) != 0) {
+ file = path;
+ return true;
+ }
+ const std::string id = path.substr(prefix.size());
+ const unsigned char* data = nullptr;
+ size_t size = 0;
+ if (id == "creature-bones") data = assets::insertSetCreatureBones, size = size_t(assets::insertSetCreatureBones_size);
+ if (!data) return error = "No built-in insert set '" + id + "'", false;
+ // Written once per run (the thumbnails and each insert read the file): the app's copy, unless the file there
+ // already has exactly these bytes.
+ static std::mutex mutex;
+ static std::map<std::string, std::string> written;
+ std::lock_guard<std::mutex> lock(mutex);
+ if (auto it = written.find(id); it != written.end()) return file = it->second, true;
+ int len = 0;
+ const std::unique_ptr<char, decltype(&std::free)> obj(
+ stbi_zlib_decode_malloc(reinterpret_cast<const char*>(data), int(size), &len), &std::free);
+ if (!obj || len <= 0) return error = "The built-in insert set '" + id + "' is damaged", false;
+ const std::string_view content(obj.get(), size_t(len));
+ std::error_code ec;
+ const std::string appData = appDataDir();
+ std::vector<std::filesystem::path> dirs;
+ if (!appData.empty()) dirs.push_back(std::filesystem::path(std::u8string(appData.begin(), appData.end())) / "insert-sets");
+ if (const auto tmp = std::filesystem::temp_directory_path(ec); !ec) dirs.push_back(tmp / "sculptforge-insert-sets");
+ for (const auto& dir : dirs) {
+ const auto target = dir / (id + ".obj");
+ bool same = false;
+ if (std::ifstream in(target, std::ios::binary); in) {
+ const std::string have((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
+ same = have == content;
+ }
+ if (!same) {
+ std::filesystem::create_directories(dir, ec);
+ auto part = target;
+ part += ".part";
+ {
+ std::ofstream out(part, std::ios::binary | std::ios::trunc);
+ if (!out || !out.write(content.data(), std::streamsize(content.size())) || !out.flush()) continue;
+ }
+ std::filesystem::rename(part, target, ec);
+ if (ec) {
+ std::filesystem::remove(part, ec);
+ continue;
+ }
+ }
+ const auto u8 = target.u8string();
+ file = written[id] = std::string(u8.begin(), u8.end());
+ return true;
+ }
+ return error = "Couldn't write the built-in insert set '" + id + "' to the app's data folder", false;
+}
+
+bool listInsertSet(const std::string& setPath, std::vector<InsertSetItem>& items, std::string& error) {
items.clear();
+ std::string path;
+ if (!resolveInsertSetPath(setPath, path, error)) return false;
const std::filesystem::path dir(std::u8string(path.begin(), path.end()));
std::error_code ec;
if (std::filesystem::is_directory(dir, ec)) {
@@ -290,8 +366,10 @@ bool listInsertSet(const std::string& path, std::vector<InsertSetItem>& items, s
return !items.empty();
}
-bool loadInsertSetItem(const std::string& path, int index, Mesh& out, std::string& name, std::string& error) {
+bool loadInsertSetItem(const std::string& setPath, int index, Mesh& out, std::string& name, std::string& error) {
std::vector<InsertSetItem> items;
+ std::string path;
+ if (!resolveInsertSetPath(setPath, path, error)) return false;
const std::filesystem::path dir(std::u8string(path.begin(), path.end()));
std::error_code ec;
if (std::filesystem::is_directory(dir, ec)) {
@@ -543,7 +621,7 @@ void registerPartCommands(CommandRegistry& reg) {
std::vector<ParamSpec> meshParams{
{"part", T::String, "insert a copy of this Part (by name)", false},
{"file", T::String, "insert the mesh in this model file (.obj, .ply or .glb)", false},
- {"set", T::String, "insert one item of this insert set: a folder of model files, or a file with several objects", false},
+ {"set", T::String, "insert one item of this insert set: a folder of model files, a file with several objects, or builtin:creature-bones (the built-in Creature bones)", false},
{"index", T::Number, "with set=: which item (0 = the first; insert_set_items lists them)", false}};
meshParams.insert(meshParams.end(), placeParams.begin(), placeParams.end());
reg.add({"insert_mesh",
@@ -581,8 +659,8 @@ void registerPartCommands(CommandRegistry& reg) {
reg.add({"insert_set_items",
"List the items of an insert set (a folder of .obj / .ply / .glb files, or one file with several "
- "objects), in the order insert_mesh set=<path> index=<n> numbers them.",
- {{"set", T::String, "the folder or file", true}},
+ "objects, or builtin:creature-bones), in the order insert_mesh set=<path> index=<n> numbers them.",
+ {{"set", T::String, "the folder or file, or builtin:creature-bones", true}},
[](Document&, const Args& a) -> CommandResult {
std::vector<InsertSetItem> items;
std::string error;
diff --git a/src/core/Parts.h b/src/core/Parts.h
index 6c1e7e31..488726cd 100644
--- a/src/core/Parts.h
+++ b/src/core/Parts.h
@@ -56,6 +56,17 @@ constexpr int kInsertSetMaxItems = 512;
bool listInsertSet(const std::string& path, std::vector<InsertSetItem>& items, std::string& error);
// One item's mesh, and its name.
bool loadInsertSetItem(const std::string& path, int index, Mesh& out, std::string& name, std::string& error);
+// The built-in insert sets, inside the app (no file to pick): "builtin:<id>" works wherever a set path does.
+// Creature bones (#154): original pieces from tools/creature-bones (assets/insert-sets).
+struct BuiltinInsertSet {
+ const char* id; // "creature-bones"
+ const char* name; // "Creature bones" (English; the UI translates it)
+};
+const std::vector<BuiltinInsertSet>& builtinInsertSets();
+inline constexpr const char* kBuiltinInsertSetPrefix = "builtin:";
+// The file a set path names: a built-in set is written from the app to <app data>/insert-sets/<id>.obj when that
+// file is missing or differs (else the system temp folder); any other path is itself.
+bool resolveInsertSetPath(const std::string& path, std::string& file, std::string& error);
// part_list, part_select, part_append, part_duplicate, part_delete,
// part_rename, part_visibility, part_solo, part_show_all, part_move,
diff --git a/tests/test_i18n.cpp b/tests/test_i18n.cpp
index 127b313d..36625531 100644
--- a/tests/test_i18n.cpp
+++ b/tests/test_i18n.cpp
@@ -7,6 +7,7 @@
#include "TestHarness.h"
#include "app/I18n.h"
+#include "core/Parts.h"
#include <cstdint>
#include <cstdio>
@@ -283,3 +284,20 @@ TEST(i18n_simplified_chinese_lookup) {
}
CHECK(taiwanese == 0);
}
+
+// The built-in insert sets' names and their pieces' names (from the set's file, so a new piece needs its entry)
+// are shown through tr() (PanelParts.cpp): each language has them.
+TEST(i18n_builtin_insert_sets_translated) {
+ for (const sf::BuiltinInsertSet& b : sf::builtinInsertSets()) {
+ std::vector<sf::InsertSetItem> items;
+ std::string err;
+ CHECK(sf::listInsertSet(std::string(sf::kBuiltinInsertSetPrefix) + b.id, items, err));
+ std::vector<std::string> names{b.name};
+ for (const sf::InsertSetItem& it : items) names.push_back(it.name);
+ for (const sf::Language l : {sf::Language::Spanish, sf::Language::TraditionalChinese, sf::Language::SimplifiedChinese})
+ for (const std::string& n : names) {
+ if (!sf::i18n::lookup(l, n)) std::printf(" no %s translation for \"%s\"\n", sf::languageCode(l), n.c_str());
+ CHECK(sf::i18n::lookup(l, n) != nullptr);
+ }
+ }
+}
diff --git a/tests/test_primitives_insert.cpp b/tests/test_primitives_insert.cpp
index 8bcf5f6e..01a26908 100644
--- a/tests/test_primitives_insert.cpp
+++ b/tests/test_primitives_insert.cpp
@@ -15,6 +15,7 @@
#include <algorithm>
#include <cmath>
#include <cstdio>
+#include <cstdlib>
#include <filesystem>
#include <map>
@@ -246,3 +247,63 @@ TEST(insert_mesh_from_set) {
std::filesystem::remove_all(dir);
std::remove(glb.c_str());
}
+
+// The built-in Creature bones set (#154): no file to pick, every piece inserts as quads, one undo step each.
+TEST(insert_builtin_creature_bones) {
+#if defined(_WIN32)
+ const char* var = "APPDATA";
+#else
+ const char* var = "XDG_DATA_HOME";
+#endif
+ // the per-user data folder in a temp folder (the set is written there once per run)
+ const std::filesystem::path data = std::filesystem::temp_directory_path() / "sf_builtin_sets";
+ std::filesystem::remove_all(data);
+ const char* had = std::getenv(var);
+ const std::string old = had ? had : "";
+ auto setVar = [&](const std::string& v) {
+#if defined(_WIN32)
+ _putenv_s(var, v.c_str());
+#else
+ if (v.empty() && !had) unsetenv(var);
+ else setenv(var, v.c_str(), 1);
+#endif
+ };
+ setVar(data.string());
+ CHECK(builtinInsertSets().size() == 1 && std::string(builtinInsertSets()[0].id) == "creature-bones");
+ const std::string set = std::string(kBuiltinInsertSetPrefix) + "creature-bones";
+ std::vector<InsertSetItem> items;
+ std::string err;
+ CHECK(listInsertSet(set, items, err));
+ const std::vector<std::string> names = {"Skull", "Jaw", "Fang", "Blade tooth", "Swept horn", "Spiral horn", "Claw",
+ "Vertebra", "Tail vertebrae", "Rib", "Limb bone", "Wing bone",
+ "Wing finger"};
+ CHECK(items.size() == names.size());
+ for (size_t i = 0; i < items.size() && i < names.size(); ++i) CHECK(items[i].name == names[i]);
+ std::string file;
+ CHECK(resolveInsertSetPath(set, file, err) && std::filesystem::exists(std::filesystem::path(std::u8string(file.begin(), file.end()))));
+ CHECK(file.find("insert-sets") != std::string::npos);
+
+ Document doc;
+ CommandRegistry reg;
+ CHECK(reg.execute(doc, "new_sphere", {{"subdivisions", 3.0}}).ok);
+ const size_t before = doc.mesh.triangleCount();
+ for (size_t i = 0; i < names.size(); ++i) {
+ Mesh piece;
+ std::string name;
+ CHECK(loadInsertSetItem(set, int(i), piece, name, err) && name == names[i]);
+ // clean starting pieces: closed, low-to-mid poly, nearly all quads
+ size_t quads = 0;
+ for (size_t t = 0; t < piece.triangles.size(); ++t)
+ if (piece.hasQuads() && piece.quadPartners[t] != Mesh::kNoQuad) ++quads;
+ CHECK(piece.triangleCount() >= 400 && piece.triangleCount() <= 12000);
+ CHECK(quads >= piece.triangleCount() * 9 / 10);
+ const CommandResult r = reg.execute(doc, "insert_mesh", {{"set", set}, {"index", double(i)}, {"x", 0.0}, {"y", 1.0}, {"z", 0.0}, {"size", 0.4}});
+ CHECK(r.ok && r.message.find(names[i]) != std::string::npos);
+ CHECK(doc.mesh.triangleCount() == before + piece.triangleCount());
+ CHECK(reg.execute(doc, "undo", {}).ok);
+ CHECK(doc.mesh.triangleCount() == before);
+ }
+ CHECK(reg.execute(doc, "insert_set_items", {{"set", set}}).message.find("12. Wing finger") != std::string::npos);
+ CHECK(!listInsertSet(std::string(kBuiltinInsertSetPrefix) + "nothing", items, err));
+ setVar(old);
+}
diff --git a/tests/ui/insert_set_builtin.sfui b/tests/ui/insert_set_builtin.sfui
new file mode 100644
index 00000000..d2031e99
--- /dev/null
+++ b/tests/ui/insert_set_builtin.sfui
@@ -0,0 +1,24 @@
+# #154: the built-in Creature bones set: Append > Insert on the model > Creature bones, no file to pick. Its picker
+# shows every piece; a click picks one, the next drag inserts it (X symmetry is on: a mirrored copy too).
+run new_sphere subdivisions=4
+key f
+remember triangles base
+click "Parts/Append"
+hover "Insert on the model"
+click "Creature bones"
+wait 0.1
+expect_status Insert Skull (1 of 13)
+wait_idle
+shot creature_bones_picker
+
+click "##insertset6"
+expect_status Insert Claw (7 of 13)
+stroke 0.8 0.45 0.86 0.45
+expect_status 2 Claws (mirrored)
+expect_value triangles > $base
+wait_idle
+shot creature_bones_claw
+key ctrl+z
+expect_value triangles == $base
+key escape
+expect_status Insert off
diff --git a/tools/creature-bones/build.py b/tools/creature-bones/build.py
new file mode 100644
index 00000000..d2ff2f95
--- /dev/null
+++ b/tools/creature-bones/build.py
@@ -0,0 +1,99 @@
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Steps of tools/creature-bones/build.sh:
+# build.py raw <work> [name...] mesh each piece's distance field (surface nets) -> <work>/raw/<id>.obj
+# build.py script <work> print the sculptforge-cli script that quad-remeshes them -> <work>/quad/<id>.obj
+# build.py pack <work> <out.obj.z> one OBJ, an `o` object per piece in set order, centred, zlib-compressed
+import os, sys, zlib
+
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import pieces, sdf
+
+
+def ident(name): return name.lower().replace(" ", "-")
+
+
+def raw(work, names):
+ os.makedirs(os.path.join(work, "raw"), exist_ok=True)
+ for name, f, lo, hi, cell, mirror, _ in pieces.PIECES:
+ if names and name not in names: continue
+ v, q, open_edges = sdf.surface_nets(f, lo, hi, cell, os.path.join(work, "raw", ident(name) + ".obj"), name, mirror)
+ print(f"{name}: {v} vertices, {q} quads, {open_edges} open edges", flush=True)
+ if open_edges: sys.exit(f"{name}: the surface isn't closed")
+
+
+def script(work):
+ lines = []
+ for name, _, _, _, _, mirror, target in pieces.PIECES:
+ i = ident(name)
+ lines.append(f"open_obj path={work}/raw/{i}.obj")
+ lines.append(f"qremesh target={target} adaptive=0.3" + (" symmetry=x symmetry_center=0" if mirror else ""))
+ lines.append(f"save_obj path={work}/quad/{i}.obj")
+ print("\n".join(lines))
+
+
+def read_obj(path):
+ verts, faces = [], []
+ for line in open(path):
+ w = line.split()
+ if not w: continue
+ if w[0] == "v": verts.append(tuple(float(x) for x in w[1:4]))
+ elif w[0] == "f": faces.append([int(x.split("/")[0]) for x in w[1:]])
+ return verts, faces
+
+
+def check_closed_piece(nverts, faces):
+ """'' for one closed, manifold piece, else what's wrong (a piece must sculpt and divide cleanly)."""
+ edges = {}
+ for f in faces:
+ for a in range(len(f)):
+ u, v = f[a], f[(a + 1) % len(f)]
+ edges[(min(u, v), max(u, v))] = edges.get((min(u, v), max(u, v)), 0) + 1
+ bad = sum(1 for n in edges.values() if n != 2)
+ if bad: return f"{bad} open or non-manifold edges"
+ parent = list(range(nverts + 1))
+ def find(x):
+ while parent[x] != x:
+ parent[x] = parent[parent[x]]
+ x = parent[x]
+ return x
+ for f in faces:
+ for v in f[1:]: parent[find(v)] = find(f[0])
+ parts = len({find(v) for f in faces for v in f})
+ return f"{parts} separate pieces" if parts != 1 else ""
+
+
+def pack(work, out):
+ text, base, report = [], 0, []
+ text.append("# SculptForge \"Creature bones\" insert set: original procedural pieces by the SculptForge project\n"
+ "# (tools/creature-bones), GPL-3.0-or-later. Metres, +Y up, +Z forward.\n")
+ for name, _, _, _, _, mirror, _ in pieces.PIECES:
+ verts, faces = read_obj(os.path.join(work, "quad", ident(name) + ".obj"))
+ problem = check_closed_piece(len(verts), faces)
+ if problem: sys.exit(f"{name}: {problem}")
+ lo = [min(v[k] for v in verts) for k in range(3)]
+ hi = [max(v[k] for v in verts) for k in range(3)]
+ c = [(lo[k] + hi[k]) / 2 for k in range(3)]
+ if mirror: c[0] = 0.0 # keep the mirror plane at x = 0
+ c[1] = lo[1] # pivot at the bottom: the piece stands on y = 0
+ text.append(f"o {name}\n")
+ text.extend(f"v {v[0] - c[0]:.5f} {v[1] - c[1]:.5f} {v[2] - c[2]:.5f}\n" for v in verts)
+ text.extend("f " + " ".join(str(i + base) for i in f) + "\n" for f in faces)
+ base += len(verts)
+ quads = sum(1 for f in faces if len(f) == 4)
+ report.append(f"{name}: {len(verts)} vertices, {len(faces)} faces ({quads} quads), "
+ f"{hi[0] - lo[0]:.2f} x {hi[1] - lo[1]:.2f} x {hi[2] - lo[2]:.2f} m")
+ data = "".join(text).encode()
+ os.makedirs(os.path.dirname(os.path.abspath(out)), exist_ok=True)
+ with open(out, "wb") as f: f.write(zlib.compress(data, 9))
+ print("\n".join(report))
+ print(f"{out}: {len(data) / 1e6:.2f} MB OBJ, {os.path.getsize(out) / 1e6:.2f} MB compressed")
+
+
+if __name__ == "__main__":
+ step, work = sys.argv[1], os.path.abspath(sys.argv[2])
+ if step == "raw": raw(work, sys.argv[3:])
+ elif step == "script": script(work)
+ elif step == "pack": pack(work, sys.argv[3])
+ else: sys.exit(__doc__)
diff --git a/tools/creature-bones/build.sh b/tools/creature-bones/build.sh
new file mode 100755
index 00000000..2bb1791e
--- /dev/null
+++ b/tools/creature-bones/build.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Rebuilds assets/insert-sets/creature-bones.obj.z, the built-in "Creature bones" insert set (#154), from scratch:
+# tools/creature-bones/build.sh <sculptforge-cli> [piece names...]
+# Every piece is designed here (pieces.py: distance fields from simple forms, no outside meshes or scans): meshed
+# with surface nets (sdf.py, pure Python), quad-remeshed by SculptForge itself (qremesh), then packed as one
+# multi-object OBJ (quads kept; glTF would split them into triangles) and zlib-compressed. Naming pieces re-meshes
+# only those (the rest come from the last run in $BONES_WORK). Python 3 only, a few minutes.
+set -eu
+CLI=${1:?usage: tools/creature-bones/build.sh <sculptforge-cli> [piece names...]}
+shift
+ROOT=$(cd "$(dirname "$0")/../.." && pwd)
+WORK=${BONES_WORK:-$ROOT/build/creature-bones}
+mkdir -p "$WORK/raw" "$WORK/quad" "$ROOT/assets/insert-sets"
+python3 -I "$ROOT/tools/creature-bones/build.py" raw "$WORK" "$@"
+python3 -I "$ROOT/tools/creature-bones/build.py" script "$WORK" > "$WORK/qremesh.txt"
+"$CLI" -q -f "$WORK/qremesh.txt"
+python3 -I "$ROOT/tools/creature-bones/build.py" pack "$WORK" "$ROOT/assets/insert-sets/creature-bones.obj.z"
diff --git a/tools/creature-bones/pieces.py b/tools/creature-bones/pieces.py
new file mode 100644
index 00000000..e8df43b8
--- /dev/null
+++ b/tools/creature-bones/pieces.py
@@ -0,0 +1,356 @@
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# The "Creature bones" insert set (#154): original fantasy creature bones, designed here from simple forms
+# (no reference meshes, scans or stock models). Each piece is a signed-distance function in metres, +Y up
+# (Insert lays +Y along the surface normal: horns, claws and teeth grow along +Y), +Z forward, mirror-symmetric
+# about x = 0 where the anatomy is. tools/creature-bones/build.sh meshes, quad-remeshes and packs them.
+import math
+from sdf import (Chain, add, clamp, ellipsoid, fbm, lerp, round_cone, sample_curve, smax, smin, smoothstep, sphere, ssub, sub,
+ vnoise)
+
+
+def mx(p): # mirror: evaluate the x >= 0 half
+ return (abs(p[0]), p[1], p[2])
+
+def scaled(p, c, s): # p in a space stretched by 1/s about c (s < 1 makes the shape longer on that axis)
+ return (c[0] + (p[0] - c[0]) * s[0], c[1] + (p[1] - c[1]) * s[1], c[2] + (p[2] - c[2]) * s[2])
+
+def rot_z(p, c, a):
+ x, y = p[0] - c[0], p[1] - c[1]
+ ca, sa = math.cos(a), math.sin(a)
+ return (c[0] + ca * x + sa * y, c[1] - sa * x + ca * y, p[2])
+
+def rot_x(p, c, a):
+ y, z = p[1] - c[1], p[2] - c[2]
+ ca, sa = math.cos(a), math.sin(a)
+ return (p[0], c[1] + ca * y + sa * z, c[2] - sa * y + ca * z)
+
+def bone_grain(p, d, size, along=1, seed=0):
+ """Bone surface: long, shallow ridges along the bone's axis plus soft erosion pits. Applied near the
+ surface only; amplitudes are fractions of the piece size."""
+ if abs(d) > 0.05 * size: return d
+ q = list(p)
+ stretch = [6.0, 6.0, 6.0]
+ stretch[along] = 1.2 # grain runs along the bone
+ f = 1.0 / size
+ ridge = abs(vnoise(q[0] * stretch[0] * f, q[1] * stretch[1] * f, q[2] * stretch[2] * f, seed))
+ pits = fbm(p, 14.0 * f, 2, seed + 7)
+ return d + size * (0.0035 * (ridge - 0.5) + 0.004 * max(0.0, pits - 0.15))
+
+
+def cylinder_z(p, r, half, round_r):
+ """A cylinder along z, radius r, from -half to half, its rims rounded by round_r."""
+ dx = math.hypot(p[0], p[1]) - r + round_r
+ dz = abs(p[2]) - half + round_r
+ return min(max(dx, dz), 0.0) + math.hypot(max(dx, 0.0), max(dz, 0.0)) - round_r
+
+
+def curved_tube(n, fn, radius, ring=None):
+ pts = sample_curve(fn, n)
+ rad = []
+ for i in range(n):
+ t = i / (n - 1)
+ r = radius(t)
+ if ring: r *= 1.0 + ring(t)
+ rad.append(r)
+ return Chain(pts, rad)
+
+
+# ---------------------------------------------------------------- skull and jaw
+def rot_y(p, c, a):
+ x, z = p[0] - c[0], p[2] - c[2]
+ ca, sa = math.cos(a), math.sin(a)
+ return (c[0] + ca * x - sa * z, p[1], c[2] + sa * x + ca * z)
+
+
+def loft(q, stations, k):
+ """A smooth body through cross-sections: (z, half width, y bottom, y top) stations, an ellipsoid each, blended."""
+ d = 1e9
+ for i, (z, w, y0, y1) in enumerate(stations):
+ step = abs(stations[min(i + 1, len(stations) - 1)][0] - stations[max(i - 1, 0)][0]) / 2
+ e = ellipsoid(q, (0.0, (y0 + y1) / 2, z), (w, (y1 - y0) / 2, step * 1.25))
+ d = smin(d, e, k)
+ return d
+
+
+# z (back to snout tip), half width, bottom, top: a long wedge, widest across the cheeks
+_skull_body = [(-0.27, 0.075, -0.03, 0.1), (-0.21, 0.11, -0.055, 0.125), (-0.14, 0.125, -0.07, 0.135),
+ (-0.07, 0.115, -0.07, 0.13), (0.0, 0.095, -0.07, 0.115), (0.07, 0.075, -0.068, 0.085),
+ (0.13, 0.064, -0.064, 0.06), (0.19, 0.055, -0.058, 0.042), (0.245, 0.045, -0.05, 0.03),
+ (0.285, 0.032, -0.042, 0.018)]
+
+
+def _tooth_row():
+ """The upper teeth along each side of the jaw line, longest under the eye, rooted in the bone."""
+ row = []
+ for i in range(9):
+ z = -0.1 + i * 0.044
+ for (z0, w0, y0, y1), (z1, w1, y2, y3) in zip(_skull_body, _skull_body[1:]):
+ if z0 <= z <= z1:
+ t = (z - z0) / (z1 - z0)
+ w, bottom, top = lerp(w0, w1, t), lerp(y0, y2, t), lerp(y1, y3, t)
+ x = w * 0.7
+ hh = (top - bottom) / 2
+ y = (top + bottom) / 2 - hh * math.sqrt(1 - 0.7 ** 2) # the body's underside at x
+ size = 0.75 + 0.25 * math.sin(math.pi * (i + 1) / 10)
+ row.append(((x, y + 0.01, z), (x * 0.97, y - 0.03 * size, z - 0.004), 0.0105 * size, 0.003))
+ return row
+_teeth = _tooth_row()
+
+
+def skull(p):
+ q = mx(p)
+ d = loft(q, _skull_body, 0.04)
+ d = smin(d, ellipsoid(q, (0.085, 0.112, -0.05), (0.048, 0.02, 0.085)), 0.05) # the brow over each eye
+ d = smin(d, round_cone(q, (0.06, 0.11, -0.2), (0.1, 0.14, -0.3), 0.04, 0.028), 0.025) # horn roots
+ d = smin(d, round_cone(q, (0.095, -0.03, -0.215), (0.105, -0.05, -0.23), 0.022, 0.018), 0.02) # the jaw hinge
+ d = smin(d, sphere(q, (0.0, 0.0, -0.285), 0.022), 0.015) # the knob the neck turns on
+ d = smin(d, ellipsoid(q, (0.0, 0.135, -0.11), (0.014, 0.022, 0.13)), 0.025) # a low ridge down the middle
+ d = ssub(d, ellipsoid(q, (0.06, 0.048, -0.03), (0.085, 0.05, 0.055)), 0.012) # eye sockets, right through
+ d = ssub(d, ellipsoid(q, (0.1, 0.0, -0.15), (0.06, 0.04, 0.055)), 0.015) # the openings behind them
+ d = ssub(d, ellipsoid(q, (0.075, 0.005, 0.1), (0.03, 0.022, 0.065)), 0.015) # long hollows before them
+ d = ssub(d, ellipsoid(q, (0.022, 0.025, 0.262), (0.014, 0.012, 0.03)), 0.008) # nostrils
+ d = ssub(d, ellipsoid(q, (0.0, -0.085, -0.04), (0.055, 0.05, 0.2)), 0.025) # the palate, open underneath
+ for a, b, ra, rb in _teeth:
+ if abs(q[2] - a[2]) < 0.03: d = smin(d, round_cone(q, a, b, ra, rb), 0.006)
+ return bone_grain(p, d, 0.6, along=2, seed=1)
+
+
+# the lower jaw: one side's bar from the chin back to the hinge (x, z, y centre, half depth), a tall oval section
+_jaw_ctrl = [(0.0, 0.272, -0.09, 0.02), (0.035, 0.235, -0.091, 0.022), (0.064, 0.14, -0.09, 0.026),
+ (0.086, 0.03, -0.086, 0.034), (0.102, -0.07, -0.08, 0.042), (0.11, -0.15, -0.075, 0.036),
+ (0.112, -0.205, -0.072, 0.022)]
+
+
+def _catmull(ctrl, n):
+ out = []
+ for i in range(n):
+ u = i / (n - 1) * (len(ctrl) - 1)
+ k = min(int(u), len(ctrl) - 2)
+ t = u - k
+ p0, p1, p2, p3 = ctrl[max(k - 1, 0)], ctrl[k], ctrl[k + 1], ctrl[min(k + 2, len(ctrl) - 1)]
+ out.append(tuple(0.5 * (2 * b + (c - a) * t + (2 * a - 5 * b + 4 * c - d) * t * t + (3 * b - a - 3 * c + d) * t ** 3)
+ for a, b, c, d in zip(p0, p1, p2, p3)))
+ return out
+_jaw_path = _catmull(_jaw_ctrl, 40)
+
+
+def _jaw_bar(q, half_thick):
+ best, arg = 1e9, None
+ for (x0, z0, y0, h0), (x1, z1, y1, h1) in zip(_jaw_path, _jaw_path[1:]):
+ dx, dz = x1 - x0, z1 - z0
+ t = clamp(((q[0] - x0) * dx + (q[2] - z0) * dz) / (dx * dx + dz * dz), 0.0, 1.0)
+ l = math.hypot(q[0] - (x0 + dx * t), q[2] - (z0 + dz * t))
+ if l < best: best, arg = l, (lerp(y0, y1, t), lerp(h0, h1, t))
+ yc, h = arg
+ a, b = best / half_thick, (q[1] - yc) / h
+ k0 = math.hypot(a, b)
+ k1 = math.hypot(a / half_thick, b / h)
+ return k0 * (k0 - 1.0) / k1 if k1 > 1e-12 else -half_thick
+
+
+def _jaw_teeth():
+ row = []
+ for i in range(1, 9):
+ x, z, y, h = _jaw_path[int(i * 3.6)]
+ size = 0.7 + 0.3 * math.sin(math.pi * i / 9)
+ row.append(((x, y + h * 0.5, z), (x * 0.97, y + h + 0.026 * size, z + 0.004), 0.0095 * size, 0.0028))
+ return row
+_lower_teeth = _jaw_teeth()
+
+
+def jaw(p):
+ q = mx(p)
+ if q[1] > 0.0: return q[1] + 0.02 # nothing above the teeth
+ d = _jaw_bar(q, 0.016)
+ d = smin(d, ellipsoid(q, (0.108, -0.048, -0.13), (0.013, 0.036, 0.03)), 0.022) # the rise for the muscle
+ d = smin(d, ellipsoid(q, (0.106, -0.066, -0.205), (0.026, 0.016, 0.019)), 0.012) # the hinge knob
+ for a, b, ra, rb in _lower_teeth:
+ if abs(q[2] - a[2]) < 0.03: d = smin(d, round_cone(q, a, b, ra, rb), 0.006)
+ return bone_grain(p, d, 0.45, along=2, seed=2)
+
+
+# ---------------------------------------------------------------- teeth, horns, claws
+def _fang_curve(t): return (0.0, 0.1 * t, 0.018 * t * t)
+_fang = curved_tube(24, _fang_curve, lambda t: 0.0115 * (1 - t) ** 0.8 + 0.0008)
+
+
+def fang(p):
+ d = _fang(scaled(p, (0, 0, 0), (1.15, 1.0, 1.0)))
+ d = smin(d, ellipsoid(p, (0, 0.012, 0.0), (0.0095, 0.022, 0.011)), 0.006) # the root's swell
+ return bone_grain(p, d, 0.1, along=1, seed=3)
+
+
+def _blade_curve(t): return (0.0, 0.085 * t, -0.03 * t * t)
+_blade = curved_tube(24, _blade_curve, lambda t: 0.019 * (1 - t) ** 0.7 + 0.0016)
+
+
+def blade_tooth(p):
+ d = _blade(scaled(p, (0, 0, 0), (2.4, 1.0, 1.0))) # thin side to side, a cutting edge front and back
+ return bone_grain(p, d, 0.09, along=1, seed=4)
+
+
+def _horn_curve(t):
+ a = 1.5 * t
+ return (0.06 * t * t, 0.32 * math.sin(a) / 1.5 * 1.1, -0.3 * (1 - math.cos(a)) / 1.5)
+_horn = curved_tube(48, _horn_curve, lambda t: 0.048 * (1 - t) ** 0.9 + 0.0015,
+ ring=lambda t: 0.05 * smoothstep(0.0, 0.08, 1 - t) * math.sin(t * 2 * math.pi * 11) ** 2 * (1 - t))
+
+
+def swept_horn(p):
+ d = _horn(scaled(p, (0, 0, 0), (1.0, 1.0, 0.92)))
+ return bone_grain(p, d, 0.45, along=1, seed=5)
+
+
+def _spiral_curve(t):
+ a = t * 1.35 * 2 * math.pi
+ r = 0.11 * math.exp(-0.18 * a)
+ return (0.16 * t, r * math.sin(a), 0.11 - r * math.cos(a))
+_spiral = curved_tube(80, _spiral_curve, lambda t: 0.042 * (1 - t) ** 0.85 + 0.0015,
+ ring=lambda t: 0.06 * math.sin(t * 2 * math.pi * 16) ** 2 * (1 - t))
+
+
+def spiral_horn(p):
+ d = _spiral(p)
+ return bone_grain(p, d, 0.35, along=0, seed=6)
+
+
+def _claw_curve(t):
+ a = 1.75 * t
+ return (0.0, 0.075 * math.sin(a), 0.075 * (1 - math.cos(a)))
+_claw = curved_tube(32, _claw_curve, lambda t: 0.022 * (1 - t) ** 0.85 + 0.0008)
+
+
+def claw(p):
+ d = _claw(scaled(p, (0, 0, 0), (1.7, 1.0, 1.0)))
+ d = smin(d, ellipsoid(p, (0.0, 0.01, -0.012), (0.012, 0.012, 0.012)), 0.008) # the tendon's knob
+ return bone_grain(p, d, 0.12, along=1, seed=7)
+
+
+# ---------------------------------------------------------------- spine, ribs, tail
+def _vertebra(q, s, spine_h, transverse=True, chevron=False):
+ """One vertebra of size s about the origin (spine along z), x >= 0 half."""
+ r = 0.042 * s
+ if abs(q[2]) < 0.045 * s: r -= 0.007 * s * (1 - (q[2] / (0.045 * s)) ** 2) # the waist
+ body = cylinder_z(q, r, 0.045 * s, 0.01 * s)
+ for z in (1, -1): # shallow cups at both ends
+ body = ssub(body, ellipsoid(q, (0, 0, z * 0.05 * s), (0.03 * s, 0.03 * s, 0.012 * s)), 0.006 * s)
+ yc = 0.064 * s # the canal's centre
+ ring = abs(math.hypot(q[0], q[1] - yc) - 0.036 * s) - 0.013 * s
+ arch = smax(ring, abs(q[2]) - 0.032 * s, 0.008 * s)
+ arch = smax(arch, -(q[1] - 0.02 * s), 0.01 * s)
+ d = smin(body, arch, 0.012 * s)
+ spine = round_cone(scaled(q, (0, 0, 0), (2.4, 1.0, 0.75)), (0, 0.085 * s, 0), (0, spine_h * s, -0.03 * s),
+ 0.024 * s, 0.011 * s)
+ d = smin(d, spine, 0.018 * s)
+ for z in (1, -1): # the joints with the next vertebrae, leaning out of the arch
+ d = smin(d, ellipsoid(q, (0.03 * s, 0.096 * s, z * 0.045 * s), (0.012 * s, 0.009 * s, 0.022 * s)), 0.01 * s)
+ if transverse:
+ tp = round_cone(scaled(q, (0, 0, 0), (1.0, 1.0, 1.6)), (0.032 * s, 0.05 * s, 0), (0.12 * s, 0.07 * s, -0.008 * s),
+ 0.017 * s, 0.009 * s)
+ d = smin(d, tp, 0.02 * s)
+ if chevron:
+ ch = round_cone(scaled(q, (0, 0, 0), (2.0, 1.0, 1.0)), (0.01 * s, -0.035 * s, 0.01 * s), (0, -0.12 * s, -0.035 * s),
+ 0.012 * s, 0.006 * s)
+ d = smin(d, ch, 0.014 * s)
+ return d
+
+
+def vertebra(p):
+ d = _vertebra(mx(p), 1.0, 0.21)
+ return bone_grain(p, d, 0.25, along=1, seed=8)
+
+
+_tail_n = 5
+def _tail_frame(i):
+ t = i / (_tail_n - 1)
+ # each vertebra 8% smaller than the one before, spaced by their sizes, the tail arching up a little
+ return 0.62 * 0.92 ** i, (0.0, 0.025 * math.sin(t * math.pi), -0.065 * sum(0.92 ** k for k in range(i)))
+
+
+def tail(p):
+ q = mx(p)
+ d = 1e9
+ for i in range(_tail_n):
+ s, c = _tail_frame(i)
+ local = sub(q, c)
+ d = min(d, _vertebra(local, s, 0.16, transverse=i < 2, chevron=True))
+ if i + 1 < _tail_n: # the discs between them keep the tail one piece
+ s2, c2 = _tail_frame(i + 1)
+ disc = round_cone(q, add(c, (0, 0, -0.04 * s)), add(c2, (0, 0, 0.04 * s2)), 0.036 * s, 0.036 * s2)
+ d = smin(d, disc, 0.012)
+ return bone_grain(p, d, 0.4, along=2, seed=9)
+
+
+def _rib_curve(t):
+ a = 2.5 * t
+ return (0.26 * math.sin(a) * (1 - 0.12 * t), 0.2 * math.cos(a) - 0.2 + 0.0, -0.05 * t * t)
+_rib = curved_tube(40, _rib_curve, lambda t: 0.013 * (1.0 - 0.35 * t) + 0.004 * (1 - smoothstep(0, 0.12, t)))
+
+
+def rib(p):
+ d = _rib(scaled(p, (0, 0, 0), (1.0, 1.0, 0.42))) # a flat band, wide along the body
+ d = smin(d, round_cone(p, (0.0, 0.0, 0.0), (-0.03, 0.022, 0.0), 0.016, 0.013), 0.01) # the head
+ d = smin(d, sphere(p, (0.03, 0.012, 0.0), 0.017), 0.01) # the tubercle
+ return bone_grain(p, d, 0.45, along=1, seed=10)
+
+
+# ---------------------------------------------------------------- limbs and wings
+_shaft = Chain([(0.0, 0.07, 0.0), (0.004, 0.2, 0.006), (0.0, 0.34, 0.004), (-0.01, 0.43, 0.0)],
+ [0.03, 0.024, 0.025, 0.032])
+
+
+def limb_bone(p):
+ d = _shaft(p)
+ d = smin(d, round_cone(p, (-0.012, 0.44, 0.0), (-0.05, 0.475, 0.0), 0.026, 0.02), 0.02) # the neck
+ d = smin(d, sphere(p, (-0.058, 0.478, 0.0), 0.034), 0.012) # the ball
+ d = smin(d, sphere(p, (0.03, 0.455, 0.0), 0.026), 0.02) # the outer knob
+ for x in (-0.028, 0.028): # the knee's two rollers
+ d = smin(d, ellipsoid(p, (x, 0.04, 0.008), (0.024, 0.034, 0.036)), 0.02)
+ d = ssub(d, ellipsoid(p, (0.0, 0.005, 0.012), (0.009, 0.04, 0.05)), 0.008) # the groove between them
+ return bone_grain(p, d, 0.52, along=1, seed=12)
+
+
+_wing = Chain([(0.0, 0.04, 0.0), (0.008, 0.2, -0.004), (0.01, 0.4, -0.006), (0.0, 0.56, 0.0)],
+ [0.02, 0.014, 0.013, 0.018])
+
+
+def wing_bone(p):
+ d = _wing(p)
+ d = smin(d, ellipsoid(p, (0.0, 0.035, 0.0), (0.03, 0.03, 0.024)), 0.02) # the shoulder end
+ d = smin(d, sphere(p, (0.012, 0.03, 0.012), 0.016), 0.012)
+ for x in (-0.012, 0.012): # the pulley at the wrist end
+ d = smin(d, ellipsoid(p, (x, 0.575, 0.0), (0.013, 0.02, 0.019)), 0.01)
+ return bone_grain(p, d, 0.6, along=1, seed=13)
+
+
+def _finger_curve(t): return (0.0, 0.56 * t, 0.05 * math.sin(t * math.pi) - 0.015 * t)
+_finger = curved_tube(40, _finger_curve, lambda t: 0.021 * (1 - t) ** 0.7 + 0.0045)
+
+
+def wing_finger(p):
+ d = _finger(scaled(p, (0, 0, 0), (1.0, 1.0, 0.85)))
+ d = smin(d, ellipsoid(p, (0.0, 0.008, 0.0), (0.032, 0.028, 0.029)), 0.018) # the knuckle
+ for t in (0.33, 0.64): # two joints along it
+ r = 0.021 * (1 - t) ** 0.7 + 0.0045
+ d = smin(d, ellipsoid(p, _finger_curve(t), (r * 1.35, r * 1.1, r * 1.25)), 0.012)
+ return bone_grain(p, d, 0.56, along=1, seed=14)
+
+
+# name, sdf, bounds lo, bounds hi, cell size (m), mirror about x = 0, quad target
+PIECES = [
+ ("Skull", skull, (-0.2, -0.16, -0.38), (0.2, 0.22, 0.34), 0.003, True, 4000),
+ ("Jaw", jaw, (-0.17, -0.15, -0.26), (0.17, 0.05, 0.34), 0.003, True, 1800),
+ ("Fang", fang, (-0.02, -0.02, -0.02), (0.02, 0.11, 0.04), 0.0007, False, 500),
+ ("Blade tooth", blade_tooth, (-0.02, -0.025, -0.05), (0.02, 0.1, 0.03), 0.0008, False, 500),
+ ("Swept horn", swept_horn, (-0.07, -0.06, -0.4), (0.13, 0.4, 0.07), 0.003, False, 1200),
+ ("Spiral horn", spiral_horn, (-0.06, -0.15, -0.07), (0.22, 0.17, 0.27), 0.0026, False, 1600),
+ ("Claw", claw, (-0.03, -0.03, -0.04), (0.03, 0.11, 0.11), 0.0009, False, 600),
+ ("Vertebra", vertebra, (-0.15, -0.07, -0.09), (0.15, 0.24, 0.08), 0.0022, True, 1500),
+ ("Tail vertebrae", tail, (-0.1, -0.12, -0.39), (0.1, 0.15, 0.06), 0.0018, True, 2800),
+ ("Rib", rib, (-0.08, -0.42, -0.2), (0.3, 0.07, 0.06), 0.0024, False, 900),
+ ("Limb bone", limb_bone, (-0.1, -0.02, -0.06), (0.07, 0.53, 0.06), 0.0022, False, 1400),
+ ("Wing bone", wing_bone, (-0.04, -0.01, -0.04), (0.04, 0.61, 0.04), 0.0018, False, 1000),
+ ("Wing finger", wing_finger, (-0.05, -0.04, -0.06), (0.05, 0.6, 0.09), 0.0016, False, 900),
+]
diff --git a/tools/creature-bones/sdf.py b/tools/creature-bones/sdf.py
new file mode 100644
index 00000000..8065e839
--- /dev/null
+++ b/tools/creature-bones/sdf.py
@@ -0,0 +1,220 @@
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Small signed-distance toolkit for tools/creature-bones (pure Python, no dependencies): primitives, smooth
+# blends, value noise, and a narrow-band naive surface-nets mesher that writes an all-quad, watertight OBJ.
+import math
+
+# ---------------------------------------------------------------- vectors
+def sub(a, b): return (a[0] - b[0], a[1] - b[1], a[2] - b[2])
+def add(a, b): return (a[0] + b[0], a[1] + b[1], a[2] + b[2])
+def mul(a, s): return (a[0] * s, a[1] * s, a[2] * s)
+def dot(a, b): return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
+def length(a): return math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])
+def lerp(a, b, t): return a + (b - a) * t
+def clamp(x, lo, hi): return lo if x < lo else hi if x > hi else x
+def smoothstep(e0, e1, x):
+ t = clamp((x - e0) / (e1 - e0), 0.0, 1.0)
+ return t * t * (3 - 2 * t)
+
+
+# ---------------------------------------------------------------- blends
+def smin(a, b, k):
+ if k <= 0: return min(a, b)
+ h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0)
+ return lerp(b, a, h) - k * h * (1 - h)
+
+def smax(a, b, k): return -smin(-a, -b, k)
+def ssub(a, b, k): return smax(a, -b, k) # a minus b
+
+
+# ---------------------------------------------------------------- primitives (exact or close bounds)
+def sphere(p, c, r): return length(sub(p, c)) - r
+
+def ellipsoid(p, c, r):
+ q = sub(p, c)
+ k0 = length((q[0] / r[0], q[1] / r[1], q[2] / r[2]))
+ k1 = length((q[0] / (r[0] * r[0]), q[1] / (r[1] * r[1]), q[2] / (r[2] * r[2])))
+ return k0 * (k0 - 1.0) / k1 if k1 > 1e-12 else -min(r)
+
+def round_cone(p, a, b, ra, rb):
+ """A capsule from a (radius ra) to b (radius rb), tangent-continuous (iq's round cone)."""
+ ba = sub(b, a)
+ l2 = dot(ba, ba)
+ rr = ra - rb
+ a2 = l2 - rr * rr
+ il2 = 1.0 / l2
+ pa = sub(p, a)
+ y = dot(pa, ba)
+ z = y - l2
+ xv = sub(mul(pa, l2), mul(ba, y))
+ x2 = dot(xv, xv)
+ y2 = y * y * l2
+ z2 = z * z * l2
+ k = math.copysign(1.0, rr) * rr * rr * x2
+ if math.copysign(1.0, z) * a2 * z2 > k: return math.sqrt(x2 + z2) * il2 - rb
+ if math.copysign(1.0, y) * a2 * y2 < k: return math.sqrt(x2 + y2) * il2 - ra
+ return (math.sqrt(x2 * a2 * il2) + y * rr) * il2 - ra
+
+def round_box(p, c, half, r):
+ q = sub(p, c)
+ dx, dy, dz = abs(q[0]) - half[0] + r, abs(q[1]) - half[1] + r, abs(q[2]) - half[2] + r
+ out = length((max(dx, 0), max(dy, 0), max(dz, 0)))
+ return out + min(max(dx, dy, dz), 0.0) - r
+
+def torus_xz(p, c, R, r):
+ """A torus around the Y axis through c."""
+ q = sub(p, c)
+ return length((math.hypot(q[0], q[2]) - R, q[1], 0.0)) - r
+
+
+class Chain:
+ """A swept tube: round cones between consecutive (point, radius) samples, with a bounding box per segment
+ so far segments are skipped cheaply."""
+ def __init__(self, pts, radii):
+ self.segs = []
+ for i in range(len(pts) - 1):
+ a, b, ra, rb = pts[i], pts[i + 1], radii[i], radii[i + 1]
+ if length(sub(b, a)) < 1e-9: continue
+ m = max(ra, rb)
+ lo = tuple(min(a[k], b[k]) - m for k in range(3))
+ hi = tuple(max(a[k], b[k]) + m for k in range(3))
+ self.segs.append((a, b, ra, rb, lo, hi))
+
+ def __call__(self, p):
+ best = 1e9
+ for a, b, ra, rb, lo, hi in self.segs:
+ # distance to the segment's box: a lower bound of its distance
+ dx = max(lo[0] - p[0], 0.0, p[0] - hi[0])
+ dy = max(lo[1] - p[1], 0.0, p[1] - hi[1])
+ dz = max(lo[2] - p[2], 0.0, p[2] - hi[2])
+ if dx * dx + dy * dy + dz * dz >= best * best and best > 0: continue
+ d = round_cone(p, a, b, ra, rb)
+ if d < best: best = d
+ return best
+
+
+def sample_curve(fn, n):
+ return [fn(i / (n - 1)) for i in range(n)]
+
+
+# ---------------------------------------------------------------- noise
+def _hash(ix, iy, iz, seed):
+ h = (ix * 374761393 + iy * 668265263 + iz * 2147483647 + seed * 144269504) & 0xFFFFFFFF
+ h = ((h ^ (h >> 13)) * 1274126177) & 0xFFFFFFFF
+ return ((h ^ (h >> 16)) & 0xFFFF) / 32767.5 - 1.0
+
+def vnoise(x, y, z, seed=0):
+ ix, iy, iz = math.floor(x), math.floor(y), math.floor(z)
+ fx, fy, fz = x - ix, y - iy, z - iz
+ ux, uy, uz = fx * fx * (3 - 2 * fx), fy * fy * (3 - 2 * fy), fz * fz * (3 - 2 * fz)
+ def h(a, b, c): return _hash(ix + a, iy + b, iz + c, seed)
+ x00 = lerp(h(0, 0, 0), h(1, 0, 0), ux); x10 = lerp(h(0, 1, 0), h(1, 1, 0), ux)
+ x01 = lerp(h(0, 0, 1), h(1, 0, 1), ux); x11 = lerp(h(0, 1, 1), h(1, 1, 1), ux)
+ return lerp(lerp(x00, x10, uy), lerp(x01, x11, uy), uz)
+
+def fbm(p, freq, octaves=3, seed=0):
+ s, amp, tot = 0.0, 1.0, 0.0
+ for o in range(octaves):
+ s += amp * vnoise(p[0] * freq, p[1] * freq, p[2] * freq, seed + o)
+ tot += amp
+ amp *= 0.5
+ freq *= 2.03
+ return s / tot
+
+
+# ---------------------------------------------------------------- mesher
+def surface_nets(f, lo, hi, cell, path, name="piece", mirror_x=False):
+ """Meshes {f < 0} inside the box lo..hi with cubic cells of size `cell` (naive surface nets: one vertex per
+ sign-changing cell, one quad per sign-changing edge), narrow band: a coarse pass finds the blocks near the
+ surface. With mirror_x the field is evaluated for x <= 0 only and mirrored (an exactly symmetric mesh)."""
+ n = [max(2, int(math.ceil((hi[k] - lo[k]) / cell))) for k in range(3)]
+ if mirror_x: # the grid symmetric about x = 0, x = 0 on a grid plane
+ half = int(math.ceil(max(-lo[0], hi[0]) / cell))
+ n[0] = 2 * half
+ lo = (-half * cell, lo[1], lo[2])
+ B = 4 # block size in cells
+ nb = [(n[k] + B - 1) // B for k in range(3)]
+ vals = {}
+
+ def val(i, j, k):
+ key = (i, j, k)
+ v = vals.get(key)
+ if v is None:
+ x = lo[0] + i * cell
+ if mirror_x and x > 0: x = -x
+ v = f((x, lo[1] + j * cell, lo[2] + k * cell))
+ if v == 0.0: v = 1e-9
+ vals[key] = v
+ return v
+
+ margin = 1.6 * B * cell * math.sqrt(3) / 2 * 1.6
+ active = []
+ for bi in range(nb[0]):
+ for bj in range(nb[1]):
+ for bk in range(nb[2]):
+ c = (lo[0] + (bi + 0.5) * B * cell, lo[1] + (bj + 0.5) * B * cell, lo[2] + (bk + 0.5) * B * cell)
+ x = c[0]
+ if mirror_x and x > 0: x = -x
+ if abs(f((x, c[1], c[2]))) < margin: active.append((bi, bj, bk))
+ # cells to examine: every cell of an active block
+ verts, index = [], {}
+ def cell_vertex(i, j, k):
+ key = (i, j, k)
+ if key in index: return index[key]
+ corners = [val(i + a, j + b, k + c) for c in (0, 1) for b in (0, 1) for a in (0, 1)]
+ inside = [v < 0 for v in corners]
+ if all(inside) or not any(inside):
+ index[key] = -1
+ return -1
+ sx = sy = sz = 0.0
+ cnt = 0
+ for (u, w) in ((0, 1), (2, 3), (4, 5), (6, 7), (0, 2), (1, 3), (4, 6), (5, 7), (0, 4), (1, 5), (2, 6), (3, 7)):
+ if inside[u] != inside[w]:
+ t = corners[u] / (corners[u] - corners[w])
+ au, bu, cu = u & 1, (u >> 1) & 1, (u >> 2) & 1
+ aw, bw, cw = w & 1, (w >> 1) & 1, (w >> 2) & 1
+ sx += lerp(au, aw, t); sy += lerp(bu, bw, t); sz += lerp(cu, cw, t)
+ cnt += 1
+ pos = (lo[0] + (i + sx / cnt) * cell, lo[1] + (j + sy / cnt) * cell, lo[2] + (k + sz / cnt) * cell)
+ index[key] = len(verts)
+ verts.append(pos)
+ return index[key]
+
+ quads, seen = [], set()
+ for bi, bj, bk in active:
+ for i in range(bi * B, min((bi + 1) * B, n[0])):
+ for j in range(bj * B, min((bj + 1) * B, n[1])):
+ for k in range(bk * B, min((bk + 1) * B, n[2])):
+ v0 = val(i, j, k)
+ # the three edges leaving grid point (i,j,k) in +x, +y, +z
+ for axis in range(3):
+ e = (i + (axis == 0), j + (axis == 1), k + (axis == 2))
+ if e[0] > n[0] or e[1] > n[1] or e[2] > n[2]: continue
+ v1 = val(*e)
+ if (v0 < 0) == (v1 < 0): continue
+ if (i, j, k, axis) in seen: continue
+ seen.add((i, j, k, axis))
+ # the four cells around this edge
+ if axis == 0: cs = [(i, j - 1, k - 1), (i, j, k - 1), (i, j, k), (i, j - 1, k)]
+ elif axis == 1: cs = [(i - 1, j, k - 1), (i - 1, j, k), (i, j, k), (i, j, k - 1)]
+ else: cs = [(i - 1, j - 1, k), (i, j - 1, k), (i, j, k), (i - 1, j, k)]
+ if any(c[0] < 0 or c[1] < 0 or c[2] < 0 or c[0] >= n[0] or c[1] >= n[1] or c[2] >= n[2] for c in cs):
+ continue
+ ids = [cell_vertex(*c) for c in cs]
+ if min(ids) < 0: continue
+ if v0 > 0: ids.reverse() # faces point from inside to outside
+ quads.append(ids)
+ # the narrow band may miss a few edges at block borders: they are inside active blocks of a neighbour, so
+ # the surface is closed as long as the margin is generous; report open edges so a build can fail loudly
+ edges = {}
+ for q in quads:
+ for a in range(4):
+ e = (q[a], q[(a + 1) % 4])
+ edges[e] = edges.get(e, 0) + 1
+ open_edges = sum(1 for (a, b) in edges if (b, a) not in edges)
+ with open(path, "w") as out:
+ out.write(f"o {name}\n")
+ for v in verts: out.write(f"v {v[0]:.6f} {v[1]:.6f} {v[2]:.6f}\n")
+ for q in quads: out.write("f " + " ".join(str(i + 1) for i in q) + "\n")
+ return len(verts), len(quads), open_edges
diff --git a/website/.well-known/security.txt b/website/.well-known/security.txt
deleted file mode 100644
index 84ba7741..00000000
--- a/website/.well-known/security.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-Contact: https://github.com/islandmed/SculptForge/security/advisories/new
-Expires: 2027-11-05T00:00:00Z
-Policy: https://github.com/islandmed/SculptForge/blob/main/SECURITY.md
-Preferred-Languages: en
-Canonical: https://sculptforge.app/.well-known/security.txt
-Canonical: https://sculptforge.app/security.txt
diff --git a/website/index.html b/website/index.html
index e7d2b6a7..b991e544 100644
--- a/website/index.html
+++ b/website/index.html
@@ -19,7 +19,7 @@
<meta property="og:url" content="https://sculptforge.app/">
<link rel="canonical" href="https://sculptforge.app/">
<script type="application/ld+json">
- {"@context": "https://schema.org", "@type": "SoftwareApplication", "name": "SculptForge", "url": "https://sculptforge.app/", "applicationCategory": "MultimediaApplication", "applicationSubCategory": "3D sculpting", "operatingSystem": "Windows 10, Windows 11, macOS, Linux", "softwareVersion": "0.11.10", "description": "Free, open-source digital sculpting for VFX, animation and game studios.", "license": "https://www.gnu.org/licenses/gpl-3.0.html", "isAccessibleForFree": true, "offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD"}, "downloadUrl": "https://github.com/islandmed/SculptForge/releases/latest", "image": "https://sculptforge.app/img/social-lion.png?v=1", "sameAs": ["https://github.com/islandmed/SculptForge"]}
+ {"@context": "https://schema.org", "@type": "SoftwareApplication", "name": "SculptForge", "url": "https://sculptforge.app/", "applicationCategory": "MultimediaApplication", "applicationSubCategory": "3D sculpting", "operatingSystem": "Windows 10, Windows 11, macOS, Linux", "softwareVersion": "0.11.9", "description": "Free, open-source digital sculpting for VFX, animation and game studios.", "license": "https://www.gnu.org/licenses/gpl-3.0.html", "isAccessibleForFree": true, "offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD"}, "downloadUrl": "https://github.com/islandmed/SculptForge/releases/latest", "image": "https://sculptforge.app/img/social-lion.png?v=1", "sameAs": ["https://github.com/islandmed/SculptForge"]}
</script>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://sculptforge.app/img/social-lion.png?v=1">
@@ -415,7 +415,7 @@ rez-env sculptforge -- sculptforge troll.usda \
<section id="download" class="section alt">
<div class="wrap">
<h2>Download</h2>
- <p class="section-lede">Version 0.11.10. All builds come from the
+ <p class="section-lede">Version 0.11.9. All builds come from the
<a href="https://github.com/islandmed/SculptForge/releases/latest">latest GitHub release</a>, with
SHA-256 checksums. Free forever; <a href="support.html">membership</a> adds betas and early builds, Member Requests, a roadmap vote and credits.</p>
<div class="downloads">
diff --git a/website/latest.json b/website/latest.json
index 90a1cc8b..7bffa767 100644
--- a/website/latest.json
+++ b/website/latest.json
@@ -1,11 +1,12 @@
{
- "version": "0.11.10",
+ "version": "0.11.9",
"download": "https://github.com/islandmed/SculptForge/releases/latest",
"notes": "https://sculptforge.app/guide/whats-new.html",
"highlights": [
- "Exports keep their real size: what you import in mm or cm comes back out the same size, for 3D printing and other apps (thanks @Swar55, @NicTanghe, #148)",
- "Alt+Q sculpts the Part under the cursor, in every input style (thanks @ziel9627 on Discord)",
- "Insert sets: pick a piece from a multi-object file or folder by its thumbnail, step through them with [ and ]",
- "Spanish and Chinese everywhere: the Generate 3D panel and the last untranslated labels now read in your language"
+ "Folders in Tool > Parts: drag Parts in, fold, hide and move them together (thanks @ebarranco, #96)",
+ "Line Gradient: drag a colour ramp across the model (thanks @Devon0209, #99)",
+ "Auto UV runs in the background and can be cancelled",
+ "Paint colour stays visible while you orbit or paint dense models",
+ "Hyper3D Rodin, direct: generate a model from an image or a description with your own Hyper3D key (thanks @ElgoogUdiab, #123)"
]
}
diff --git a/website/security.txt b/website/security.txt
deleted file mode 100644
index 84ba7741..00000000
--- a/website/security.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-Contact: https://github.com/islandmed/SculptForge/security/advisories/new
-Expires: 2027-11-05T00:00:00Z
-Policy: https://github.com/islandmed/SculptForge/blob/main/SECURITY.md
-Preferred-Languages: en
-Canonical: https://sculptforge.app/.well-known/security.txt
-Canonical: https://sculptforge.app/security.txt