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.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Blender bridge: poll the manifest's revision, not its file time (Windows copies keep the time; FAT and network drives store it coarsely)
islandmed9a9dde8fa651
diff --git a/addons/blender/sculptforge_bridge/__init__.py b/addons/blender/sculptforge_bridge/__init__.pyindex 6d893509..a573b279 100644--- a/addons/blender/sculptforge_bridge/__init__.py+++ b/addons/blender/sculptforge_bridge/__init__.py@@ -40,7 +40,6 @@ FACE_SETS = ".sculpt_face_set"class _State:sent = False # this session sent something: what SculptForge sends back loads by itselflaunched = 0.0 # when this session last started SculptForge (time.time())- inbox_time = 0 # last seen modification time of to_blender/manifest.jsonseen = -1 # revision last loaded (or present when the add-on started)message = "" # last result, shown in the panel@@ -350,7 +349,6 @@ def receive(context):if manifest is None:return "ERROR", "Nothing has been sent from SculptForge yet (File > Blender > Send to Blender)"state.seen = int(manifest.get("revision", 0))- state.inbox_time = exchange.file_time(exchange.manifest_path(folder))entries = manifest.get("objects", [])meshes = []for entry in entries:@@ -411,10 +409,7 @@ def _poll_inbox():if p is None or not p.auto_receive or not state.sent:return 1.0folder = exchange.inbox(exchange_root(p))- t = exchange.file_time(exchange.manifest_path(folder))- if t == 0 or t == state.inbox_time:- return 1.0- state.inbox_time = t+ # The revision, not the file time (copies and coarse file systems can keep the time); the file is tiny.rev = exchange.revision(folder)if rev < 0 or rev == state.seen:return 1.0@@ -564,7 +559,6 @@ def register():# What SculptForge sent before Blender started is not loaded by itself (Receive loads it).folder = exchange.inbox(exchange_root())state.seen = exchange.revision(folder)- state.inbox_time = exchange.file_time(exchange.manifest_path(folder))if not bpy.app.timers.is_registered(_poll_inbox):bpy.app.timers.register(_poll_inbox, first_interval=1.0, persistent=True)diff --git a/docs/blender.md b/docs/blender.mdindex f8150786..ecaa0075 100644--- a/docs/blender.md+++ b/docs/blender.md@@ -59,8 +59,8 @@ Windows).```- `revision` is the previous manifest's plus one. A reader loads a manifest whose revision differs from the one- it loaded last (not "greater": a deleted folder restarts at 1). It only parses the manifest when its- modification time changed.+ it loaded last (not "greater": a deleted folder restarts at 1). It reads the revision once a+ second rather than trusting file times (Windows copies keep them; FAT and network drives store them coarsely).- `name` is the exact Blender object name (UTF-8); the .GoZ's own name is GoB's ASCII escape of it. In SculptForgeit is the SubTool's `gozName` (shared with GoZ; saved in projects), so the next send updates the same object.- `file` must be a plain file name in the same folder (`..`, `/`, `\` and `:` are refused).diff --git a/src/app/App.h b/src/app/App.hindex 4982d07f..60a85ca9 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -520,7 +520,6 @@ private:void receiveFromBlender();bool blenderInitialised_ = false;bool blenderAutoReceive_ = true; // load whatever Blender sends while SculptForge runs- long long blenderInboxTime_ = 0; // last seen modification time of to_sculptforge/manifest.jsonint64_t blenderSeenRevision_ = -1; // revision last loaded (or present at start, which is not loaded)Uint64 blenderLastPollNs_ = 0, blenderLastBeatNs_ = 0;// Projects, unsaved-changes safety, recent files and autosave (PanelProject.cpp).diff --git a/src/app/PanelBlender.cpp b/src/app/PanelBlender.cppindex c43e0f64..d473cdeb 100644--- a/src/app/PanelBlender.cpp+++ b/src/app/PanelBlender.cpp@@ -52,7 +52,6 @@ void menuAction(App& app, const char* id) {void App::receiveFromBlender() {const std::string root = blenderExchangeRoot();if (!root.empty()) { // a manual receive counts as seen, so polling doesn't load it again- blenderInboxTime_ = bridgeFileTime(bridgeManifestPath(blenderInbox(root)));blenderSeenRevision_ = bridgeRevision(blenderInbox(root));}runCommand("blender_receive");@@ -78,14 +77,12 @@ void App::pollBlender() {const std::string root = blenderExchangeRoot();if (root.empty()) return;const std::string inbox = blenderInbox(root);- const std::string manifest = bridgeManifestPath(inbox);if (!blenderInitialised_) {blenderInitialised_ = true;writeBridgeAppInfo(root, bridgeExecutable(), SCULPTFORGE_VERSION);// What was sent before this start is old news, unless the add-on started us to load it.- blenderInboxTime_ = bridgeFileTime(manifest);blenderSeenRevision_ = bridgeRevision(inbox);- if (options_.blender && blenderInboxTime_) receiveFromBlender();+ if (options_.blender && blenderSeenRevision_ >= 0) receiveFromBlender();}// UI tests check every frame (their frames are simulated); the app once a second, and at once when a heartbeat// is due (at start, and after Send to Blender).@@ -105,9 +102,8 @@ void App::pollBlender() {writeBridgeHeartbeat(root);}if (!blenderAutoReceive_ || doc_.sculptor.strokeActive()) return;- const long long t = bridgeFileTime(manifest);- if (t == 0 || t == blenderInboxTime_) return;- blenderInboxTime_ = t;+ // The revision, not the file time: a copied or quickly rewritten file can keep its time (Windows copies keep+ // it; FAT and network drives store it coarsely). The manifest is a few hundred bytes.const int64_t revision = bridgeRevision(inbox);if (revision >= 0 && revision != blenderSeenRevision_) receiveFromBlender();}