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.

Blender bridge UI test (File > Blender, auto-receive, send back, undo) and a UI-test copy verb to stage another program's files

islandmedee62644a65df
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 9dcfdf81..965c7046 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -340,6 +340,7 @@ int App::runUiTest(int w, int h, int fps) {
pollBrushRequest();
pollUnreal();
pollGenerator();
+ pollBlender(); // (demo recordings leave the user's Blender bridge alone)
pollAutoUv();
pollBake();
pollQRemesh();
@@ -497,7 +498,6 @@ int App::runRecording() {
animateLayers(dt);
pollBrushRequest();
pollUnreal();
- if (!options_.uiTest.empty()) pollBlender(); // (demos and recordings leave the user's bridge alone)
pollAutoUv();
pollBake();
pollQRemesh();
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index 0bbab85d..466caa47 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -28,6 +28,8 @@
// run COMMANDS sculptforge-cli commands, e.g. run new_sphere subdivisions=4
// drop FILE as if FILE were dropped onto the window (relative to the script's folder)
// env NAME VALUE set an environment variable; $SCRIPT_DIR is the script's folder
+// copy SRC DST copy a file or folder (SRC relative to the script's folder, DST to the working
+// directory), e.g. to stage what another program would write (the Blender bridge)
// wait SECONDS / wait_idle [TIMEOUT] (AI requests, thumbnails, update checks and other background jobs) / wait_for LABEL [TIMEOUT]
// expect LABEL / expect_not LABEL
// expect_text TEXT / expect_no_text TEXT any text drawn this frame contains TEXT
@@ -740,6 +742,17 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
if (file.is_relative()) file = std::filesystem::path(std::u8string(scriptDir_.begin(), scriptDir_.end())) / file;
const auto u8 = file.lexically_normal().u8string();
run([this, path = std::string(u8.begin(), u8.end())] { app_.openPathConfirmed(path); });
+ } else if (verb == "copy") {
+ if (!need(2)) return false;
+ namespace fs = std::filesystem;
+ fs::path src(std::u8string(w[1].begin(), w[1].end())), dst(std::u8string(w[2].begin(), w[2].end()));
+ if (src.is_relative()) src = fs::path(std::u8string(scriptDir_.begin(), scriptDir_.end())) / src;
+ run([src, dst] {
+ std::error_code ec;
+ if (dst.has_parent_path()) fs::create_directories(dst.parent_path(), ec);
+ fs::copy(src, dst, fs::copy_options::recursive | fs::copy_options::overwrite_existing, ec);
+ if (ec) SDL_Log("copy %s: %s", src.string().c_str(), ec.message().c_str());
+ });
} else if (verb == "env") {
if (!need(2)) return false;
std::string value = restOf(lineText_, 2);
diff --git a/tests/ui/blender_bridge.sfui b/tests/ui/blender_bridge.sfui
new file mode 100644
index 00000000..e769f969
--- /dev/null
+++ b/tests/ui/blender_bridge.sfui
@@ -0,0 +1,45 @@
+# The Blender bridge (File > Blender): what the add-on sends loads by itself (checked every frame in UI tests,
+# once a second in the app), Send to Blender writes the SubTools back, and a second send from Blender updates
+# the SubTool it came from (undoable) and adds the new object. The sends are staged from tests/ui/data/blender
+# into an exchange folder in the working directory (the build folder under ctest).
+run new_sphere subdivisions=3
+env SCULPTFORGE_BLENDER_EXCHANGE sf_ui_blender
+copy data/blender/send1 sf_ui_blender/to_sculptforge
+wait 0.2
+expect_status "Received 2 objects from Blender"
+expect_value subtools == 2
+expect_value active_subtool == 0
+expect_text Box
+expect_text Rock
+expect_value colored > 0
+shot received
+
+# The menu: File > Blender, with Ctrl-hover help on its items.
+click "File##palette.file"
+hover "Blender"
+wait 0.2
+expect "Send to Blender##file.send_blender"
+expect "Receive automatically##blender"
+shot menu
+hold ctrl
+hover "Send to Blender##file.send_blender"
+expect_help "back to Blender"
+hover "Receive automatically##blender"
+expect_help "as soon as it arrives"
+hold none
+click "Send to Blender##file.send_blender"
+expect_status "Sent 2 objects to Blender"
+
+# Blender sends again: the box changed and a pebble is new.
+copy data/blender/send2 sf_ui_blender/to_sculptforge
+wait 0.2
+expect_status "Received 2 objects from Blender"
+expect_value subtools == 3
+expect_text Pebble
+expect_value can_undo == 1
+shot updated
+# Both receives into the box are undo steps: the update, then the first one (which replaced the fresh sphere).
+key ctrl+z
+expect_value can_undo == 1
+key ctrl+z
+expect_value can_undo == 0
diff --git a/tests/ui/data/blender/send1/manifest.json b/tests/ui/data/blender/send1/manifest.json
new file mode 100644
index 00000000..ed3d92a3
--- /dev/null
+++ b/tests/ui/data/blender/send1/manifest.json
@@ -0,0 +1,69 @@
+{
+ "format": "sculptforge-bridge",
+ "version": 1,
+ "revision": 1,
+ "sender": "blender",
+ "sender_version": "4.2.0",
+ "objects": [
+ {
+ "name": "Box",
+ "file": "r1_000.GoZ",
+ "matrix_world": [
+ [
+ 0.9396926207859084,
+ -0.3420201433256687,
+ 0,
+ 0
+ ],
+ [
+ 0.3420201433256687,
+ 0.9396926207859084,
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0,
+ 1.0,
+ 0
+ ],
+ [
+ 0,
+ 0,
+ 0,
+ 1
+ ]
+ ]
+ },
+ {
+ "name": "Rock",
+ "file": "r1_001.GoZ",
+ "matrix_world": [
+ [
+ 1.0,
+ -0.0,
+ 0,
+ 1.2
+ ],
+ [
+ 0.0,
+ 1.0,
+ 0,
+ 0.3
+ ],
+ [
+ 0,
+ 0,
+ 1.0,
+ 0.2
+ ],
+ [
+ 0,
+ 0,
+ 0,
+ 1
+ ]
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/tests/ui/data/blender/send1/r1_000.GoZ b/tests/ui/data/blender/send1/r1_000.GoZ
new file mode 100644
index 00000000..4a01d641
Binary files /dev/null and b/tests/ui/data/blender/send1/r1_000.GoZ differ
diff --git a/tests/ui/data/blender/send1/r1_001.GoZ b/tests/ui/data/blender/send1/r1_001.GoZ
new file mode 100644
index 00000000..a2650e14
Binary files /dev/null and b/tests/ui/data/blender/send1/r1_001.GoZ differ
diff --git a/tests/ui/data/blender/send2/manifest.json b/tests/ui/data/blender/send2/manifest.json
new file mode 100644
index 00000000..7acfe6a9
--- /dev/null
+++ b/tests/ui/data/blender/send2/manifest.json
@@ -0,0 +1,69 @@
+{
+ "format": "sculptforge-bridge",
+ "version": 1,
+ "revision": 2,
+ "sender": "blender",
+ "sender_version": "4.2.0",
+ "objects": [
+ {
+ "name": "Box",
+ "file": "r2_000.GoZ",
+ "matrix_world": [
+ [
+ 0.9396926207859084,
+ -0.3420201433256687,
+ 0,
+ 0
+ ],
+ [
+ 0.3420201433256687,
+ 0.9396926207859084,
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0,
+ 1.0,
+ 0
+ ],
+ [
+ 0,
+ 0,
+ 0,
+ 1
+ ]
+ ]
+ },
+ {
+ "name": "Pebble",
+ "file": "r2_001.GoZ",
+ "matrix_world": [
+ [
+ 1.0,
+ -0.0,
+ 0,
+ -1.1
+ ],
+ [
+ 0.0,
+ 1.0,
+ 0,
+ 0
+ ],
+ [
+ 0,
+ 0,
+ 1.0,
+ -0.3
+ ],
+ [
+ 0,
+ 0,
+ 0,
+ 1
+ ]
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/tests/ui/data/blender/send2/r2_000.GoZ b/tests/ui/data/blender/send2/r2_000.GoZ
new file mode 100644
index 00000000..a992faca
Binary files /dev/null and b/tests/ui/data/blender/send2/r2_000.GoZ differ
diff --git a/tests/ui/data/blender/send2/r2_001.GoZ b/tests/ui/data/blender/send2/r2_001.GoZ
new file mode 100644
index 00000000..3b931a52
Binary files /dev/null and b/tests/ui/data/blender/send2/r2_001.GoZ differ