From e840fa65ec7a9da478ef78b8feafa2f595db2874 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 3 Nov 2026 23:25:06 +0100 Subject: [PATCH 01/12] Add Edit > Change mesh... (file.changeMesh) to move a project onto another mesh Reimport mesh only re-read the project's own copy of the mesh, so there was no way to put the layers on a different mesh. The new command takes a mesh file, keeps layers, texture sets and settings, and carries painted strokes over by default. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/file_cmds.rs | 37 ++++++++++++++++++++++++++++++ crates/ui-egui/src/i18n/ar.rs | 1 + crates/ui-egui/src/i18n/de.rs | 1 + crates/ui-egui/src/i18n/es.rs | 1 + crates/ui-egui/src/i18n/fr.rs | 1 + crates/ui-egui/src/i18n/it.rs | 1 + crates/ui-egui/src/i18n/ja.rs | 1 + crates/ui-egui/src/i18n/ko.rs | 1 + crates/ui-egui/src/i18n/pt_br.rs | 1 + crates/ui-egui/src/i18n/zh_hans.rs | 1 + crates/ui-egui/src/menus.rs | 1 + crates/ui-egui/src/windows.rs | 7 ++++++ docs/features.md | 3 ++- docs/parity.md | 3 ++- 14 files changed, 58 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 789163289..d8165f514 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -37,6 +37,15 @@ pub fn specs() -> Vec { always, reimport ), + cmd!( + "file.changeMesh", + "Change mesh...", + ["Edit"], + None, + "{path: the new mesh file, preserveStrokes?: bool (painted pixels follow the surface where the UVs differ; default true)} → {preserved?: texels re-projected}. Keeps layers, texture sets and settings; texture sets map to the new mesh by material index", + always, + change_mesh + ), cmd!( "file.exportTextures", "Export textures", @@ -413,6 +422,13 @@ fn reimport(s: &mut Session, p: &Value) -> Result { s.reimport_mesh(file, crate::commands::boolp(p, "preserveStrokes").unwrap_or(false)) } +#[cfg(not(target_arch = "wasm32"))] +fn change_mesh(s: &mut Session, p: &Value) -> Result { + let path = native::path_param(p, "path", "file.changeMesh")?; + let file = native::read_mesh("file.changeMesh", path)?; + s.reimport_mesh(Some(file), crate::commands::boolp(p, "preserveStrokes").unwrap_or(true)) +} + #[cfg(not(target_arch = "wasm32"))] impl Session { /// Replace the mesh with `file` (or re-read the project's own copy) and keep the project: @@ -679,6 +695,27 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + /// A project built on one mesh moves to another mesh file with its layers intact, even when + /// it carries its own copy of the mesh (a plain reimport would only re-read that copy). + #[test] + fn change_mesh_swaps_the_mesh_and_keeps_the_layers() { + let dir = std::env::temp_dir().join(format!("tc_change_mesh_{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let quad = dir.join("quad.obj"); + std::fs::write(&quad, "v 0 0 0\nv 1 0 0\nv 1 1 0\nv 0 1 0\nvt 0 0\nvt 1 0\nvt 1 1\nvt 0 1\nf 1/1 2/2 3/3 4/4\n").unwrap(); + let tri = dir.join("tri.obj"); + std::fs::write(&tri, "v 0 0 0\nv 1 0 0\nv 0 1 0\nvt 0 0\nvt 1 0\nvt 0 1\nf 1/1 2/2 3/3\n").unwrap(); + let mut s = Session::from_mesh_bytes("quad.obj", &std::fs::read(&quad).unwrap(), 128, "quad").unwrap(); + crate::execute(&mut s, "layer.add.fill", &json!({"color": [1.0, 0.0, 0.0]})).unwrap(); + let layers = s.doc.project.layers.len(); + assert!(crate::execute(&mut s, "file.changeMesh", &json!({})).is_err(), "a path is required"); + crate::execute(&mut s, "file.changeMesh", &json!({"path": tri.display().to_string()})).unwrap(); + assert_eq!(s.mesh.triangle_count(), 1, "the new mesh is in use"); + assert_eq!(s.doc.project.mesh_file, "tri.obj"); + assert_eq!(s.doc.project.layers.len(), layers, "the layers stay"); + std::fs::remove_dir_all(&dir).ok(); + } + #[test] fn unnamed_parts_keep_their_names_and_masks_through_save_and_reopen() { // A GLB quad whose mesh and node have no name: its one part is named after the file. diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs index 939b0b3c7..89fadc946 100644 --- a/crates/ui-egui/src/i18n/ar.rs +++ b/crates/ui-egui/src/i18n/ar.rs @@ -663,6 +663,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "إعادة"), ("Reimport mesh", "إعادة استيراد المجسم"), + ("Change mesh...", "تغيير المجسم..."), ("Relative to the bounding box diagonal.", "نسبة إلى قطر المربع المحيط."), ("Remove", "إزالة"), ("Remove channel", "إزالة القناة"), diff --git a/crates/ui-egui/src/i18n/de.rs b/crates/ui-egui/src/i18n/de.rs index ae02fbd2a..de7ee6f24 100644 --- a/crates/ui-egui/src/i18n/de.rs +++ b/crates/ui-egui/src/i18n/de.rs @@ -702,6 +702,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "Wiederholen"), ("Reimport mesh", "Mesh neu importieren"), + ("Change mesh...", "Mesh ändern..."), ("Relative to the bounding box diagonal.", "Relativ zur Diagonale des Begrenzungsrahmens."), ("Remove", "Entfernen"), ("Remove channel", "Kanal entfernen"), diff --git a/crates/ui-egui/src/i18n/es.rs b/crates/ui-egui/src/i18n/es.rs index 00964af6f..5a9941a37 100644 --- a/crates/ui-egui/src/i18n/es.rs +++ b/crates/ui-egui/src/i18n/es.rs @@ -690,6 +690,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "Rehacer"), ("Reimport mesh", "Reimportar malla"), + ("Change mesh...", "Cambiar malla..."), ("Relative to the bounding box diagonal.", "Relativo a la diagonal del cuadro delimitador."), ("Remove", "Quitar"), ("Remove channel", "Quitar canal"), diff --git a/crates/ui-egui/src/i18n/fr.rs b/crates/ui-egui/src/i18n/fr.rs index f9fa0d3bc..e0df73be1 100644 --- a/crates/ui-egui/src/i18n/fr.rs +++ b/crates/ui-egui/src/i18n/fr.rs @@ -705,6 +705,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "Rétablir"), ("Reimport mesh", "Réimporter le maillage"), + ("Change mesh...", "Changer le maillage..."), ("Relative to the bounding box diagonal.", "Relatif à la diagonale de la boîte englobante."), ("Remove", "Supprimer"), ("Remove channel", "Supprimer le canal"), diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rs index 765f5e8cd..409aa31fe 100644 --- a/crates/ui-egui/src/i18n/it.rs +++ b/crates/ui-egui/src/i18n/it.rs @@ -699,6 +699,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "Ripeti"), ("Reimport mesh", "Reimporta mesh"), + ("Change mesh...", "Cambia mesh..."), ("Relative to the bounding box diagonal.", "Relativa alla diagonale del bounding box."), ("Remove", "Rimuovi"), ("Remove channel", "Rimuovi canale"), diff --git a/crates/ui-egui/src/i18n/ja.rs b/crates/ui-egui/src/i18n/ja.rs index 41f6a0480..69c32d774 100644 --- a/crates/ui-egui/src/i18n/ja.rs +++ b/crates/ui-egui/src/i18n/ja.rs @@ -678,6 +678,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "やり直し"), ("Reimport mesh", "メッシュを再インポート"), + ("Change mesh...", "メッシュを変更..."), ("Relative to the bounding box diagonal.", "バウンディングボックスの対角線に対する相対値。"), ("Remove", "削除"), ("Remove channel", "チャンネルを削除"), diff --git a/crates/ui-egui/src/i18n/ko.rs b/crates/ui-egui/src/i18n/ko.rs index 9f6aabbe8..0edab0f67 100644 --- a/crates/ui-egui/src/i18n/ko.rs +++ b/crates/ui-egui/src/i18n/ko.rs @@ -669,6 +669,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "다시 실행"), ("Reimport mesh", "메시 다시 가져오기"), + ("Change mesh...", "메시 변경..."), ("Relative to the bounding box diagonal.", "바운딩 박스 대각선 기준입니다."), ("Remove", "제거"), ("Remove channel", "채널 제거"), diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rs index 67b4697b7..253b263cf 100644 --- a/crates/ui-egui/src/i18n/pt_br.rs +++ b/crates/ui-egui/src/i18n/pt_br.rs @@ -687,6 +687,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "Refazer"), ("Reimport mesh", "Reimportar malha"), + ("Change mesh...", "Alterar malha..."), ("Relative to the bounding box diagonal.", "Relativo à diagonal da caixa delimitadora."), ("Remove", "Remover"), ("Remove channel", "Remover canal"), diff --git a/crates/ui-egui/src/i18n/zh_hans.rs b/crates/ui-egui/src/i18n/zh_hans.rs index 73e05b933..50fe1c665 100644 --- a/crates/ui-egui/src/i18n/zh_hans.rs +++ b/crates/ui-egui/src/i18n/zh_hans.rs @@ -618,6 +618,7 @@ pub const TABLE: &[(&str, &str)] = &[ ), ("Redo", "重做"), ("Reimport mesh", "重新导入网格"), + ("Change mesh...", "更换网格..."), ("Relative to the bounding box diagonal.", "相对于包围盒对角线。"), ("Remove", "移除"), ("Remove channel", "移除通道"), diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 09f19c073..8c1ce5380 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -56,6 +56,7 @@ pub const CATALOG: &[Item] = &[ sep("Edit"), it("Edit", "Project Configuration...", "ui.projectConfig", None), it("Edit", "Reimport mesh", "file.reimportMesh", Some("Ctrl+Shift+R")), + it("Edit", "Change mesh...", "file.changeMesh", None), it("Edit", "Settings...", "ui.settings", None), it("Mode", "Bake Mesh Maps", "ui.mode.bake", Some("F8")), it("Mode", "Painting", "ui.mode.paint", Some("F9")), diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 8ecab2818..08e4a756f 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -1138,6 +1138,13 @@ pub fn file_action(app: &mut TextureCraftApp, _ctx: &egui::Context, id: &str) -> app.run("file.reimportMesh", json!({"path": path, "preserveStrokes": true})); true } + "file.changeMesh" => { + // Layers and texture sets stay; the strokes follow the surface onto the new mesh. + if let Some(p) = rfd::FileDialog::new().add_filter(tr("3D meshes"), &texturecraft_engine::formats::mesh_import::MESH_EXTENSIONS).pick_file() { + app.run("file.changeMesh", json!({"path": p.display().to_string()})); + } + true + } _ => false, } } diff --git a/docs/features.md b/docs/features.md index fcbaca5f4..2e6a98817 100644 --- a/docs/features.md +++ b/docs/features.md @@ -80,7 +80,8 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA - **Open** glTF/GLB, FBX (binary and ASCII), COLLADA, **USD** (usda, usdc, usdz), **Alembic**, OBJ, PLY and STL, or a built-in mesh; UVs are generated when a mesh has none. A `.gltf`'s buffers and images and a loose USD layer's textures are read from its folder and kept in the project. - Reimport a changed mesh and your painted strokes stay on the surface. + Reimport a changed mesh and your painted strokes stay on the surface. **Edit ▸ Change mesh...** + (`file.changeMesh`) moves the project onto a different mesh file and keeps its layers. - **UDIM / UV tiles:** detected on import or switched on later, with a resolution per tile (blurs, other filters and height-to-normal slopes keep their size in UV space at any tile resolution) and one texture per tile on export (`$udim`). diff --git a/docs/parity.md b/docs/parity.md index d6543d546..7724e50f0 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -2,7 +2,7 @@ Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Each row is a menu item of the target menu layout with TextureCraft's command id; **live** means the id is implemented. Feature parity beyond menus is tracked in [`ROADMAP.md`](../ROADMAP.md). -**55 of 55 menu items live (100%).** +**56 of 56 menu items live (100%).** ## File @@ -31,6 +31,7 @@ Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Eac | Redo | `edit.redo` | Ctrl+Y | live | | Project Configuration... | `ui.projectConfig` | | live | | Reimport mesh | `file.reimportMesh` | Ctrl+Shift+R | live | +| Change mesh... | `file.changeMesh` | | live | | Settings... | `ui.settings` | | live | ## Mode From f3217da0a91e9577f181c50362d40f494ce30a37 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 3 Nov 2026 23:33:37 +0100 Subject: [PATCH 02/12] Add wasm stub for file.changeMesh Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/file_cmds.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index d8165f514..9a1a7fc1d 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -605,6 +605,8 @@ use unsupported as save_copy; #[cfg(target_arch = "wasm32")] use unsupported as reimport; #[cfg(target_arch = "wasm32")] +use unsupported as change_mesh; +#[cfg(target_arch = "wasm32")] use unsupported as export_textures; #[cfg(target_arch = "wasm32")] use unsupported as export_mesh; From 00f770ee1b16ab0f59c702b8ce6b1f25d69c7676 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 4 Nov 2026 00:29:04 +0100 Subject: [PATCH 03/12] Change mesh: keep bake meshes and Auto-rebake, mark modified, decode images, stop old bake Review points on Edit > Change mesh (and Reimport mesh, which shares the path): - the high polys, cage (when it fits) and skew map of the project were dropped; - Auto-rebake was switched off, so the old baked map stayed in use; - the project was not marked modified; - image resources were not decoded in the new session; - a bake running during the swap applied its result to the new mesh; - painted pixels of a set with no old surface in reach were blanked, now kept. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/file_cmds.rs | 14 ++++++++++ crates/engine/src/preserve.rs | 29 +++++++++++++++++++-- crates/engine/tests/auto_rebake.rs | 41 ++++++++++++++++++++++++++++++ crates/ui-egui/src/lib.rs | 14 ++++++++-- 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 9a1a7fc1d..4cb190ddb 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -436,6 +436,7 @@ impl Session { /// With `preserve_strokes`, painted pixels follow the surface where the UVs changed. Replies /// like `file.reimportMesh`: `{preserved?}`. pub fn reimport_mesh(&mut self, file: Option, preserve_strokes: bool) -> Result { + let from_file = file.is_some(); let (mesh, source, warnings, mesh_file) = match file { Some(f) => { let m = texturecraft_formats::import_mesh_bytes(&f.name, &f.bytes).map_err(fe)?.mesh; @@ -457,6 +458,19 @@ impl Session { let mut next = Session::new(doc, mesh, source)?; next.log.extend(warnings); next.path = self.path.clone(); + next.sync_images(); + // The high polys and the skew map stay; the cage must have the new mesh's triangles. + next.bake_meshes = self.bake_meshes.clone(); + if next.bake_meshes.cage.as_ref().is_some_and(|c| c.mesh.triangle_count() != next.mesh.triangle_count()) { + next.bake_meshes.cage = None; + next.log.push("the cage mesh was dropped: it does not have the new mesh's triangles".into()); + } + if next.bake_meshes.skew.is_some() && self.source.uvs != next.source.uvs { + next.log.push("the skew map is laid over the old UV layout; check it in Bake mode".into()); + } + // Auto-rebake stays on; the new mesh makes the baked map out of date, so it bakes again. + next.auto_rebake = self.auto_rebake.clone(); + next.modified = self.modified || from_file; let preserved = preserve_strokes.then(|| crate::preserve::preserve_strokes(self, &mut next)); self.switch_to(next); Ok(preserved.map_or(Value::Null, |n| json!({ "preserved": n }))) diff --git a/crates/engine/src/preserve.rs b/crates/engine/src/preserve.rs index 38544edcc..01e14398f 100644 --- a/crates/engine/src/preserve.rs +++ b/crates/engine/src/preserve.rs @@ -16,7 +16,8 @@ use crate::Session; const REACH: f32 = 0.05; /// Re-project the painted pixels of `next` (a session on the reimported mesh holding `old`'s -/// document) from `old`'s UV layout. Returns how many texels found the old surface. +/// document) from `old`'s UV layout. Returns how many texels found the old surface; +/// a texture set where none does keeps its pixels as they are. pub(crate) fn preserve_strokes(old: &Session, next: &mut Session) -> usize { let reach = REACH * 2.0 * old.mesh.radius().max(next.mesh.radius()); let mut found = 0; @@ -52,7 +53,12 @@ pub(crate) fn preserve_strokes(old: &Session, next: &mut Session) -> usize { ((tx, ty), src) }) .collect(); - found += table.values().flatten().filter(|p| p[0].is_finite()).count(); + let matched = table.values().flatten().filter(|p| p[0].is_finite()).count(); + found += matched; + // No old surface within reach anywhere (a moved or unrelated mesh): the paint stays where it is. + if matched == 0 { + continue; + } let map = |x: f32, y: f32| { let (xi, yi) = (x as u32, y as u32); table.get(&(xi / TILE, yi / TILE)).and_then(|t| t.get(((yi % TILE) * TILE + xi % TILE) as usize)).filter(|p| p[0].is_finite()).map(|p| (p[0], p[1])) @@ -104,4 +110,23 @@ mod tests { } assert!(right > 10_000 && wrong == 0, "{right} right, {wrong} wrong"); } + + #[test] + fn a_mesh_with_no_surface_in_reach_keeps_the_paint_where_it_is() { + let mut s = Session::new_project("p", primitives::builtin("plane").unwrap(), "builtin:plane", None, 128).unwrap(); + let id = s.doc.project.texture_sets[0].stack[0]; + let img = s.doc.pixels.layer_mut(id, Channel::BaseColor, (128, 128)); + for x in 0..64 { + img.set(x, 40, &[65535, 0, 0, 65535]); + } + // The same plane far away: nothing of the old surface is within reach. + let mut mesh = (*s.mesh).clone(); + for p in &mut mesh.positions { + p.x += 100.0; + } + let mut next = Session::new(s.doc.clone(), mesh, None).unwrap(); + assert_eq!(preserve_strokes(&s, &mut next), 0); + let img = next.doc.pixels.layer(id, Channel::BaseColor).unwrap(); + assert_eq!(img.get(10, 40)[3], 65535, "the painted texel is still there"); + } } diff --git a/crates/engine/tests/auto_rebake.rs b/crates/engine/tests/auto_rebake.rs index e6a372756..79883634d 100644 --- a/crates/engine/tests/auto_rebake.rs +++ b/crates/engine/tests/auto_rebake.rs @@ -154,3 +154,44 @@ fn painting_or_clearing_the_skew_map_is_a_change() { assert_eq!(due(&mut s), [0], "and so is taking it away"); let _ = std::fs::remove_dir_all(dir); } + +/// Edit > Change mesh swaps the mesh under a baked project: the high poly and Auto-rebake stay (the +/// new mesh makes the map out of date), the project counts as changed, and image resources are decoded. +#[test] +fn changing_the_mesh_keeps_the_bake_setup_and_marks_the_project_changed() { + let (mut s, dir) = baked_session("change"); + let mut obj = String::new(); + let plane = primitives::builtin("plane").unwrap(); + for p in &plane.positions { + obj += &format!("v {} {} {}\n", p.x, p.y, p.z); + } + for uv in &plane.uvs { + obj += &format!("vt {} {}\n", uv.x, 1.0 - uv.y); + } + for t in plane.indices.chunks_exact(3) { + obj += &format!("f {a}/{a} {b}/{b} {c}/{c}\n", a = t[0] + 1, b = t[1] + 1, c = t[2] + 1); + } + let new_mesh = dir.join("low.obj"); + std::fs::write(&new_mesh, obj).unwrap(); + // A 1x1 PNG as an image resource. + let png = &[ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, + 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0xf8, 0xcf, 0xc0, 0xf0, 0x1f, 0x00, + 0x05, 0x00, 0x01, 0xff, 0x89, 0x99, 0x3d, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, + ]; + s.import_resource_bytes("dot.png", png.to_vec()).unwrap(); + execute(&mut s, "bake.skew.set", &json!({ "value": 1.0 })).unwrap(); + execute(&mut s, "bake.autoRebake", &json!({ "map": "height" })).unwrap(); + assert!(due(&mut s).is_empty()); + s.modified = false; + + execute(&mut s, "file.changeMesh", &json!({ "path": new_mesh.display().to_string() })).unwrap(); + assert_eq!(s.bake_meshes.high.len(), 1, "the high poly stays"); + assert!(s.bake_meshes.skew.is_some(), "the skew map stays"); + assert!(s.modified, "the project differs from the saved one"); + assert_eq!(s.images.len(), 1, "image resources are decoded in the new session"); + assert_eq!(execute(&mut s, "bake.autoRebake", &Value::Null).unwrap()["map"], "height", "Auto-rebake stays on"); + assert_eq!(due(&mut s), [0], "and the map baked for the old mesh is out of date"); + + std::fs::remove_dir_all(&dir).ok(); +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 1d0841dc9..5f9b96765 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -53,6 +53,8 @@ pub struct BakeJob { pub total: usize, /// Bake only this map (an Auto-rebake); None bakes every ticked map. pub only: Option, + /// The mesh the job was started on: a result for another mesh (changed or reimported meanwhile) is not applied. + pub mesh_id: u64, } /// A MaterialCraft material re-cooking on a worker thread (one per layer at a time). @@ -209,7 +211,7 @@ impl TextureCraftApp { return; } let total = sets.len(); - self.bake = Some(BakeJob { queue: sets, current: None, total, only: None }); + self.bake = Some(BakeJob { queue: sets, current: None, total, only: None, mesh_id: self.session.mesh_id }); } /// Re-cook MaterialCraft material layer `layer` in the background. While one cook of the layer @@ -263,6 +265,14 @@ impl TextureCraftApp { fn poll_bake(&mut self, ctx: &egui::Context) { let Some(job) = self.bake.as_mut() else { return }; + if job.mesh_id != self.session.mesh_id { + // The mesh was swapped under the job: stop it and drop its result. + if let Some((_, p, _)) = &job.current { + p.cancel.store(true, Ordering::Relaxed); + } + self.bake = None; + return; + } ctx.request_repaint_after(std::time::Duration::from_millis(50)); if let Some((ts, _, rx)) = &job.current { match rx.try_recv() { @@ -328,7 +338,7 @@ impl TextureCraftApp { let due = self.session.auto_rebake_due(); if !due.is_empty() { let total = due.len(); - self.bake = Some(BakeJob { queue: due, current: None, total, only: self.session.auto_rebake.map }); + self.bake = Some(BakeJob { queue: due, current: None, total, only: self.session.auto_rebake.map, mesh_id: self.session.mesh_id }); } } From 0791e9fe35999598c27b71c3f350eed772f40b72 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 7 Nov 2026 16:53:57 +0100 Subject: [PATCH 04/12] changeMesh: reset the low-poly colour cache and drop the cage when the mesh changes Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/file_cmds.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index d6af0410e..6ca53a286 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -465,11 +465,14 @@ impl Session { next.log.extend(warnings); next.path = self.path.clone(); next.sync_images(); - // The high polys and the skew map stay; the cage must have the new mesh's triangles. + // The high polys and the skew map stay. The cage is sampled by triangle index and + // barycentrics, so it stays only for an identical mesh; the low poly's base colours are + // read again from the new mesh. next.bake_meshes = self.bake_meshes.clone(); - if next.bake_meshes.cage.as_ref().is_some_and(|c| c.mesh.triangle_count() != next.mesh.triangle_count()) { + next.bake_meshes.low_base_color = Default::default(); + if next.bake_meshes.cage.is_some() && *next.mesh != *self.mesh { next.bake_meshes.cage = None; - next.log.push("the cage mesh was dropped: it does not have the new mesh's triangles".into()); + next.log.push("the cage mesh was dropped: the low-poly mesh changed".into()); } if self.doc.bake_paint.keys().any(|(_, target)| *target == texturecraft_core::BakePaintTarget::Skew) && self.source.uvs != next.source.uvs { next.log.push("the skew map is laid over the old UV layout; check it in Bake mode".into()); @@ -746,6 +749,28 @@ mod tests { std::fs::remove_dir_all(&dir).ok(); } + #[test] + fn change_mesh_resets_base_colours_and_drops_a_cage_of_another_mesh() { + let dir = std::env::temp_dir().join(format!("tc_change_mesh_cage_{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let a = dir.join("a.obj"); + std::fs::write(&a, "v 0 0 0\nv 1 0 0\nv 0 1 0\nvt 0 0\nvt 1 0\nvt 0 1\nf 1/1 2/2 3/3\n").unwrap(); + // Same triangle count, other vertices. + let b = dir.join("b.obj"); + std::fs::write(&b, "v 0 0 0\nv 2 0 0\nv 0 2 0\nvt 0 0\nvt 1 0\nvt 0 1\nf 1/1 2/2 3/3\n").unwrap(); + let mut s = Session::from_mesh_bytes("a.obj", &std::fs::read(&a).unwrap(), 128, "a").unwrap(); + let cage = crate::bake::BakeMesh { name: "cage".into(), bytes: Default::default(), mesh: s.mesh.clone(), base_color: Vec::new() }; + s.bake_meshes.cage = Some(cage); + let _ = s.bake_meshes.low_base_color.set(Err("old".into())); + // The same mesh again keeps the cage but not the cached colours. + crate::execute(&mut s, "file.changeMesh", &json!({"path": a.display().to_string()})).unwrap(); + assert!(s.bake_meshes.cage.is_some()); + assert!(s.bake_meshes.low_base_color.get().is_none(), "the colours are read again"); + crate::execute(&mut s, "file.changeMesh", &json!({"path": b.display().to_string()})).unwrap(); + assert!(s.bake_meshes.cage.is_none(), "the cage was made for another mesh"); + std::fs::remove_dir_all(&dir).ok(); + } + #[test] fn unnamed_parts_keep_their_names_and_masks_through_save_and_reopen() { // A GLB quad whose mesh and node have no name: its one part is named after the file. From d180ee3112b8a2984533c4e161e8961e892b85ab Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 8 Nov 2026 00:56:13 +0100 Subject: [PATCH 05/12] changeMesh: keep the painted pixels when the UV layout and topology are unchanged preserve_strokes sampled the nearest world-space point, so a mesh moved a little along its surface with the same indices and UVs shifted existing marks, and texels outside reach were cleared. An unchanged layout now skips the reprojection. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/preserve.rs | 36 ++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/preserve.rs b/crates/engine/src/preserve.rs index 01e14398f..b0d0526b4 100644 --- a/crates/engine/src/preserve.rs +++ b/crates/engine/src/preserve.rs @@ -17,8 +17,13 @@ const REACH: f32 = 0.05; /// Re-project the painted pixels of `next` (a session on the reimported mesh holding `old`'s /// document) from `old`'s UV layout. Returns how many texels found the old surface; -/// a texture set where none does keeps its pixels as they are. +/// a texture set where none does keeps its pixels as they are. Nothing is re-projected when the +/// UV layout and topology are unchanged (same triangles, materials and UVs): the pixels already +/// sit where they belong, however far the mesh moved. pub(crate) fn preserve_strokes(old: &Session, next: &mut Session) -> usize { + if same_layout(&old.mesh, &next.mesh) { + return 0; + } let reach = REACH * 2.0 * old.mesh.radius().max(next.mesh.radius()); let mut found = 0; for ts in 0..next.set_count() { @@ -69,6 +74,12 @@ pub(crate) fn preserve_strokes(old: &Session, next: &mut Session) -> usize { found } +/// Same index buffer, same UVs per vertex and the same material ranges. +fn same_layout(a: &texturecraft_geom::Mesh, b: &texturecraft_geom::Mesh) -> bool { + let ranges = |m: &texturecraft_geom::Mesh| m.submeshes.iter().map(|s| (s.material, s.start, s.count)).collect::>(); + a.indices == b.indices && a.uvs == b.uvs && ranges(a) == ranges(b) +} + #[cfg(test)] mod tests { use super::*; @@ -129,4 +140,27 @@ mod tests { let img = next.doc.pixels.layer(id, Channel::BaseColor).unwrap(); assert_eq!(img.get(10, 40)[3], 65535, "the painted texel is still there"); } + + #[test] + fn a_translated_mesh_with_the_same_uvs_keeps_every_pixel() { + let mut s = Session::new_project("p", primitives::builtin("plane").unwrap(), "builtin:plane", None, 128).unwrap(); + let id = s.doc.project.texture_sets[0].stack[0]; + let img = s.doc.pixels.layer_mut(id, Channel::BaseColor, (128, 128)); + for x in 0..128 { + img.set(x, 40, &[65535, 0, 0, 65535]); + } + // Slid along its own surface by a fraction of the plane: half of it still overlaps the old one. + let mut mesh = (*s.mesh).clone(); + let shift = mesh.radius() * 0.5; + for p in &mut mesh.positions { + p.x += shift; + } + let mut next = Session::new(s.doc.clone(), mesh, None).unwrap(); + assert_eq!(preserve_strokes(&s, &mut next), 0); + let img = next.doc.pixels.layer(id, Channel::BaseColor).unwrap(); + for x in 0..128 { + assert_eq!(img.get(x, 40)[3], 65535, "texel {x} of the painted row moved"); + assert_eq!(img.get(x, 41)[3], 0, "texel {x} of the next row got paint"); + } + } } From d5bdeedf8c4ca4a5698e9b97cea1e2861249c2d3 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 8 Nov 2026 01:40:48 +0100 Subject: [PATCH 06/12] Test the zero-match fallback with a different UV layout The no-surface-in-reach test now also mirrors the UVs, so it no longer exits through the unchanged-layout shortcut. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/preserve.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/preserve.rs b/crates/engine/src/preserve.rs index b0d0526b4..d68f20bc6 100644 --- a/crates/engine/src/preserve.rs +++ b/crates/engine/src/preserve.rs @@ -130,11 +130,15 @@ mod tests { for x in 0..64 { img.set(x, 40, &[65535, 0, 0, 65535]); } - // The same plane far away: nothing of the old surface is within reach. + // The same plane far away and with mirrored UVs (so the layout differs and the unchanged-layout + // shortcut is not taken): nothing of the old surface is within reach. let mut mesh = (*s.mesh).clone(); for p in &mut mesh.positions { p.x += 100.0; } + for uv in &mut mesh.uvs { + *uv = Vec2::new(1.0 - uv.x, uv.y); + } let mut next = Session::new(s.doc.clone(), mesh, None).unwrap(); assert_eq!(preserve_strokes(&s, &mut next), 0); let img = next.doc.pixels.layer(id, Channel::BaseColor).unwrap(); From b52fca296d935abe93208f2fb61c2855853fd1f5 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 10 Nov 2026 22:15:57 +0100 Subject: [PATCH 07/12] Use as_chunks in the change-mesh test (clippy) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/tests/it/bake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/tests/it/bake.rs b/crates/engine/tests/it/bake.rs index f834121d0..6d135f4fa 100644 --- a/crates/engine/tests/it/bake.rs +++ b/crates/engine/tests/it/bake.rs @@ -639,7 +639,7 @@ fn changing_the_mesh_keeps_the_bake_setup_and_marks_the_project_changed() { for uv in &plane.uvs { low += &format!("vt {} {}\n", uv.x, 1.0 - uv.y); } - for t in plane.indices.chunks_exact(3) { + for t in plane.indices.as_chunks::<3>().0 { low += &format!("f {a}/{a} {b}/{b} {c}/{c}\n", a = t[0] + 1, b = t[1] + 1, c = t[2] + 1); } let low = temp_file("change_low.obj", &low); From 0cf1edb328460aaed1f63dc16322a4879d5d3e35 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 10 Nov 2026 22:16:28 +0100 Subject: [PATCH 08/12] Use the shared file dialog for Change mesh Co-Authored-By: Claude Sonnet 5.5 --- crates/ui-egui/src/windows.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index f7e817516..df254412e 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -923,9 +923,12 @@ pub fn file_action(app: &mut TextureCraftApp, _ctx: &egui::Context, id: &str) -> } "file.changeMesh" => { // Layers and texture sets stay; the strokes follow the surface onto the new mesh. - if let Some(p) = rfd::FileDialog::new().add_filter(tr("3D meshes"), &texturecraft_engine::formats::mesh_import::MESH_EXTENSIONS).pick_file() { - app.run("file.changeMesh", json!({"path": p.display().to_string()})); - } + let dialog = FileDialog::open().filter(tr("3D meshes"), &texturecraft_engine::formats::mesh_import::MESH_EXTENSIONS); + app.ask_file(dialog, Bound::Project, |app, paths| { + if let Some(p) = paths.first() { + app.run("file.changeMesh", json!({"path": p.display().to_string()})); + } + }); true } _ => false, From 2e021b851be6c5c8e48571eaf38037293c19e980 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 10 Nov 2026 22:16:45 +0100 Subject: [PATCH 09/12] Adapt the bake job tests to RunningBake and mesh_id Co-Authored-By: Claude Sonnet 5.5 --- crates/ui-egui/tests/bake_preview.rs | 2 ++ crates/ui-egui/tests/it/bake_job_mesh.rs | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/tests/bake_preview.rs b/crates/ui-egui/tests/bake_preview.rs index 6860bdc47..1703abdeb 100644 --- a/crates/ui-egui/tests/bake_preview.rs +++ b/crates/ui-egui/tests/bake_preview.rs @@ -125,9 +125,11 @@ fn a_ready_result_waits_for_the_map_stream_to_close() { result_sender.send(Ok(output)).unwrap(); let app = harness.state_mut(); app.start_bake(vec![0]); + let mesh_id = app.session.mesh_id; app.bake = Some(BakeJob { queue: Vec::new(), total: 1, + mesh_id, current: Some(RunningBake { set_index: 0, progress: Arc::new(Progress::new()), diff --git a/crates/ui-egui/tests/it/bake_job_mesh.rs b/crates/ui-egui/tests/it/bake_job_mesh.rs index 6744bb6b9..d38774798 100644 --- a/crates/ui-egui/tests/it/bake_job_mesh.rs +++ b/crates/ui-egui/tests/it/bake_job_mesh.rs @@ -6,7 +6,7 @@ use std::sync::atomic::Ordering; use egui_kittest::Harness; use texturecraft_engine::bake::Progress; -use texturecraft_ui_egui::{BakeJob, TextureCraftApp}; +use texturecraft_ui_egui::{BakeJob, RunningBake, TextureCraftApp}; /// An app with a running bake job (its worker never answers) started on mesh `mesh_id`. fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, TextureCraftApp>, Arc) { @@ -14,11 +14,21 @@ fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, Textu let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let progress = Arc::new(Progress::new()); - let (tx, rx) = std::sync::mpsc::channel(); + let (tx, receiver) = std::sync::mpsc::channel(); + let (maps_tx, maps) = std::sync::mpsc::channel(); let id = mesh_id(h.state().session.mesh_id); // Leak the sender so the channel stays empty instead of closed. std::mem::forget(tx); - h.state_mut().bake = Some(BakeJob { queue: vec![], current: Some((0, progress.clone(), rx)), total: 1, mesh_id: id }); + std::mem::forget(maps_tx); + let running = RunningBake { + set_index: 0, + progress: progress.clone(), + receiver, + maps, + maps_done: Arc::new(std::sync::atomic::AtomicUsize::new(0)), + maps_total: 1, + }; + h.state_mut().bake = Some(BakeJob { queue: vec![], current: Some(running), total: 1, mesh_id: id }); (h, progress) } From 55885011c83f3c6501d1575f70d226df8ecbb39a Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 10 Nov 2026 22:16:56 +0100 Subject: [PATCH 10/12] Format Co-Authored-By: Claude Sonnet 5.5 --- crates/ui-egui/tests/it/bake_job_mesh.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/tests/it/bake_job_mesh.rs b/crates/ui-egui/tests/it/bake_job_mesh.rs index d38774798..0311c0549 100644 --- a/crates/ui-egui/tests/it/bake_job_mesh.rs +++ b/crates/ui-egui/tests/it/bake_job_mesh.rs @@ -20,14 +20,8 @@ fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, Textu // Leak the sender so the channel stays empty instead of closed. std::mem::forget(tx); std::mem::forget(maps_tx); - let running = RunningBake { - set_index: 0, - progress: progress.clone(), - receiver, - maps, - maps_done: Arc::new(std::sync::atomic::AtomicUsize::new(0)), - maps_total: 1, - }; + let running = + RunningBake { set_index: 0, progress: progress.clone(), receiver, maps, maps_done: Arc::new(std::sync::atomic::AtomicUsize::new(0)), maps_total: 1 }; h.state_mut().bake = Some(BakeJob { queue: vec![], current: Some(running), total: 1, mesh_id: id }); (h, progress) } From 052bccedf49d79bcb7660d29bf5c92191c5504c6 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 14 Nov 2026 11:12:04 +0100 Subject: [PATCH 11/12] Remember the new mesh path after Change mesh Change mesh replaced the mesh but left Project::mesh_path on the old file, so Reimport mesh (and a saved project) went back to the original mesh. The path is now stored after the swap succeeded; a failed change keeps the old one. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/file_cmds.rs | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index bdb19e7e7..fa19c9057 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -451,7 +451,10 @@ fn reimport(s: &mut Session, p: &Value) -> Result { fn change_mesh(s: &mut Session, p: &Value) -> Result { let path = native::path_param(p, "path", "file.changeMesh")?; let file = native::read_mesh("file.changeMesh", path)?; - s.reimport_mesh(Some(file), crate::commands::boolp(p, "preserveStrokes").unwrap_or(true)) + let reply = s.reimport_mesh(Some(file), crate::commands::boolp(p, "preserveStrokes").unwrap_or(true))?; + // Only after the swap succeeded: Reimport mesh and Save keep following the new file. + s.doc.project.mesh_path = native::absolute(path); + Ok(reply) } #[cfg(not(target_arch = "wasm32"))] @@ -816,6 +819,39 @@ f 1/1 2/2 3/3 std::fs::remove_dir_all(&dir).ok(); } + /// Open A, change to B, edit B on disk: Reimport mesh (also after save and reopen) must read B, + /// not A. A failed change leaves the remembered path alone. + #[test] + fn change_mesh_remembers_the_new_file_for_reimport() { + let dir = std::env::temp_dir().join(format!("tc_change_mesh_path_{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let obj = |x: f32| format!("v 0 0 0\nv {x} 0 0\nv 0 1 0\nvt 0 0\nvt 1 0\nvt 0 1\nf 1/1 2/2 3/3\n"); + let (a, b) = (dir.join("a.obj"), dir.join("b.obj")); + std::fs::write(&a, obj(1.0)).unwrap(); + std::fs::write(&b, obj(2.0)).unwrap(); + let width = |s: &Session| s.mesh.positions.iter().map(|p| p.x).fold(0.0_f32, f32::max); + let mut s = Session::new_project("t", primitives::material_ball(), "builtin:material_ball", None, 128).unwrap(); + crate::execute(&mut s, "file.new", &json!({"mesh": a.display().to_string(), "resolution": 128})).unwrap(); + let a_abs = s.remembered_mesh_path().map(str::to_string).unwrap(); + // A failed change (unreadable file) keeps A. + let missing = dir.join("missing.obj"); + assert!(crate::execute(&mut s, "file.changeMesh", &json!({"path": missing.display().to_string()})).is_err()); + assert_eq!(s.remembered_mesh_path(), Some(a_abs.as_str())); + crate::execute(&mut s, "file.changeMesh", &json!({"path": b.display().to_string()})).unwrap(); + assert_eq!(width(&s), 2.0); + let b_abs = s.remembered_mesh_path().map(str::to_string).expect("B is remembered"); + assert_ne!(a_abs, b_abs); + // The remembered path survives save and reopen. + let mut reopened = Session::from_project_bytes(&s.to_project_bytes().unwrap()).unwrap(); + assert_eq!(reopened.remembered_mesh_path(), Some(b_abs.as_str())); + // Edit B, then Reimport from the remembered path: B's edits arrive, not A. + std::fs::write(&b, obj(3.0)).unwrap(); + let remembered = reopened.remembered_mesh_path().map(str::to_string).unwrap(); + crate::execute(&mut reopened, "file.reimportMesh", &json!({"path": remembered})).unwrap(); + assert_eq!(width(&reopened), 3.0); + std::fs::remove_dir_all(&dir).ok(); + } + #[test] fn change_mesh_resets_base_colours_and_drops_a_cage_of_another_mesh() { let dir = std::env::temp_dir().join(format!("tc_change_mesh_cage_{}", std::process::id())); From 5828177d8c067eb90e5586292263c53ce2f4a6e0 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 15 Nov 2026 16:43:37 +0100 Subject: [PATCH 12/12] Remove the temporary Edit > Change mesh... menu item The file.changeMesh command stays (trusted local command API and the control channel); the Project Configuration window will offer it in a later PR. The command is no longer listed under the Edit menu. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/file_cmds.rs | 4 ++-- crates/engine/tests/it/bake.rs | 2 +- crates/ui-egui/src/menus.rs | 1 - crates/ui-egui/src/windows.rs | 10 ---------- crates/ui-egui/tests/it/bake_job_mesh.rs | 2 +- docs/features.md | 4 ++-- docs/parity.md | 1 - 7 files changed, 6 insertions(+), 18 deletions(-) diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index fa19c9057..e4d17f53b 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -39,8 +39,8 @@ pub fn specs() -> Vec { ), cmd!( "file.changeMesh", - "Change mesh...", - ["Edit"], + "Change mesh", + [], None, "{path: the new mesh file, preserveStrokes?: bool (painted pixels follow the surface where the UVs differ; default true)} → {preserved?: texels re-projected}. Keeps layers, texture sets and settings; texture sets map to the new mesh by material index", always, diff --git a/crates/engine/tests/it/bake.rs b/crates/engine/tests/it/bake.rs index 6d135f4fa..62afeb630 100644 --- a/crates/engine/tests/it/bake.rs +++ b/crates/engine/tests/it/bake.rs @@ -613,7 +613,7 @@ fn a_failed_multi_set_bake_restores_settings_pixels_and_history() { assert_eq!(session.history_labels(), history); } -/// Edit > Change mesh swaps the mesh under a baked project: the high poly and the skew map stay, +/// `file.changeMesh` swaps the mesh under a baked project: the high poly and the skew map stay, /// the project counts as changed, and image resources are decoded in the new session. #[test] fn changing_the_mesh_keeps_the_bake_setup_and_marks_the_project_changed() { diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 51081b180..72d78b34a 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -57,7 +57,6 @@ pub const CATALOG: &[Item] = &[ sep("Edit"), it("Edit", "Project Configuration...", "ui.projectConfig", None), it("Edit", "Reimport mesh", "file.reimportMesh", Some("Ctrl+Shift+R")), - it("Edit", "Change mesh...", "file.changeMesh", None), it("Edit", "Settings...", "ui.settings", None), it("Mode", "Bake Mesh Maps", "ui.mode.bake", Some("F8")), it("Mode", "Painting", "ui.mode.paint", Some("F9")), diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 145727a72..8d5738992 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -977,16 +977,6 @@ pub fn file_action(app: &mut TextureCraftApp, _ctx: &egui::Context, id: &str) -> }); true } - "file.changeMesh" => { - // Layers and texture sets stay; the strokes follow the surface onto the new mesh. - let dialog = FileDialog::open().filter(tr("3D meshes"), &texturecraft_engine::formats::mesh_import::MESH_EXTENSIONS); - app.ask_file(dialog, Bound::Project, |app, paths| { - if let Some(p) = paths.first() { - app.run("file.changeMesh", json!({"path": p.display().to_string()})); - } - }); - true - } _ => false, } } diff --git a/crates/ui-egui/tests/it/bake_job_mesh.rs b/crates/ui-egui/tests/it/bake_job_mesh.rs index 0311c0549..60f6f03ee 100644 --- a/crates/ui-egui/tests/it/bake_job_mesh.rs +++ b/crates/ui-egui/tests/it/bake_job_mesh.rs @@ -1,4 +1,4 @@ -//! A bake job belongs to the mesh it started on: when Edit > Change mesh (or a reimport) swaps +//! A bake job belongs to the mesh it started on: when `file.changeMesh` (or a reimport) swaps //! the mesh meanwhile, the job is cancelled and its result is dropped. use std::sync::Arc; diff --git a/docs/features.md b/docs/features.md index 9cba8319f..a456a3718 100644 --- a/docs/features.md +++ b/docs/features.md @@ -80,8 +80,8 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA - **Open** glTF/GLB, FBX (binary and ASCII), COLLADA, **USD** (usda, usdc, usdz), **Alembic**, OBJ, PLY and STL, or a built-in mesh; UVs are generated when a mesh has none. A `.gltf`'s buffers and images and a loose USD layer's textures are read from its folder and kept in the project. - Reimport a changed mesh and your painted strokes stay on the surface. **Edit ▸ Change mesh...** - (`file.changeMesh`) moves the project onto a different mesh file and keeps its layers. + Reimport a changed mesh and your painted strokes stay on the surface. The + `file.changeMesh` command (trusted local command API and the control channel) moves the project onto a different mesh file and keeps its layers. - **UDIM / UV tiles:** detected on import or switched on later, with a resolution per tile (blurs, other filters and height-to-normal slopes keep their size in UV space at any tile resolution) and one texture per tile on export (`$udim`). diff --git a/docs/parity.md b/docs/parity.md index 3fd7392be..75f6fd307 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -31,7 +31,6 @@ Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Eac | Redo | `edit.redo` | Ctrl+Y | live | | Project Configuration... | `ui.projectConfig` | | live | | Reimport mesh | `file.reimportMesh` | Ctrl+Shift+R | live | -| Change mesh... | `file.changeMesh` | | live | | Settings... | `ui.settings` | | live | ## Mode