Stocken behoben: auf macOS keine JSON-Szene/3D-Modell mehr nach jeder Aenderung aufbauen (niemand liest sie); Auswahl-Hervorhebung ueber eigenen kleinen Befehl, unveraendertes Layout nicht neu senden

This commit is contained in:
karim committed 2026-10-20 00:43:11 +02:00
1 parent e4c164cb29
commit dc6ab429f2
5 files changed
+87 -28

No files matched your search

+11 -4
View File
@@ -205,6 +205,8 @@ pub struct ChunkRenderer {
uniform: Option<(wgpu::Buffer, wgpu::BindGroup, u64)>,
buffers: HashMap<u32, wgpu::Buffer>,
layout: Vec<ChunkGeom>,
/// Auswahl-Hervorhebung: eine Geometrie zuoberst, unabhaengig vom Layout gesetzt.
highlight: Option<ChunkGeom>,
msaa: Option<(wgpu::Texture, (u32, u32))>,
format: wgpu::TextureFormat,
samples: u32,
@@ -389,6 +391,7 @@ impl ChunkRenderer {
uniform: None,
buffers: HashMap::new(),
layout: Vec::new(),
highlight: None,
msaa: None,
format,
samples,
@@ -522,6 +525,10 @@ impl ChunkRenderer {
(tmp.into_iter().map(|(_, i)| i).collect(), groups)
}
pub fn set_highlight(&mut self, geom: Option<ChunkGeom>) {
self.highlight = geom;
}
pub fn set_layout(&mut self, layout: Vec<ChunkGeom>) {
self.layout = layout;
}
@@ -550,7 +557,7 @@ impl ChunkRenderer {
let stride = (std::mem::size_of::<Globals>() as u64).div_ceil(align) * align;
let mut blocks: Vec<Globals> = Vec::new();
let vp = [vw as f32, vh as f32];
for g in &self.layout {
for g in self.layout.iter().chain(self.highlight.iter()) {
if g.fill_pos.is_none() || g.fill_idx.is_none() {
continue;
}
@@ -560,7 +567,7 @@ impl ChunkRenderer {
blocks.push(Globals { view_proj: proj, color: c, viewport_px: vp, stroke_px: 0.0, stroke_scale: 1.0 });
}
}
for g in &self.layout {
for g in self.layout.iter().chain(self.highlight.iter()) {
if g.line_vtx.is_none() || g.line_idx.is_none() {
continue;
}
@@ -698,7 +705,7 @@ impl ChunkRenderer {
});
let mut block = 0u32;
pass.set_pipeline(&self.fill_pipeline);
for g in &self.layout {
for g in self.layout.iter().chain(self.highlight.iter()) {
let (Some(p), Some(i)) = (g.fill_pos, g.fill_idx) else { continue };
let (Some(pb), Some(ib)) = (self.buffers.get(&p), self.buffers.get(&i)) else {
block += g.fill_batches.len() as u32;
@@ -713,7 +720,7 @@ impl ChunkRenderer {
}
}
pass.set_pipeline(&self.line_pipeline);
for g in &self.layout {
for g in self.layout.iter().chain(self.highlight.iter()) {
let (Some(p), Some(i)) = (g.line_vtx, g.line_idx) else { continue };
let (Some(pb), Some(ib)) = (self.buffers.get(&p), self.buffers.get(&i)) else {
block += g.line_batches.len() as u32;
+24 -1
View File
@@ -157,6 +157,21 @@ fn native2d_patch(app: tauri::AppHandle, request: tauri::ipc::Request<'_>) -> Re
}
}
#[tauri::command]
fn native2d_highlight(app: tauri::AppHandle, geom: Option<serde_json::Value>, delete: Vec<u32>) -> Result<(), String> {
#[cfg(all(feature = "native2d", target_os = "macos"))]
{
let geom = match geom {
Some(v) => Some(serde_json::from_value(v).map_err(|e| e.to_string())?),
None => None,
};
native_embed::set_highlight(&app, geom, delete);
}
#[cfg(not(all(feature = "native2d", target_os = "macos")))]
let _ = (app, geom, delete);
Ok(())
}
#[tauri::command]
fn native2d_layout(app: tauri::AppHandle, layout: serde_json::Value, delete: Vec<u32>) -> Result<(), String> {
#[cfg(all(feature = "native2d", target_os = "macos"))]
@@ -197,9 +212,15 @@ fn native2d_frame(app: tauri::AppHandle, view: serde_json::Value, paper_scale: f
Ok(())
}
///
/// macOS: die eingebettete 2D-Fläche (`native_embed`) bekommt ihre Daten über
/// Chunk-Uploads, und es gibt dort kein natives 3D-Fenster — dort also `false`,
/// sonst würde die Webview nach JEDER Plan-/Projektänderung den ganzen Plan bzw.
/// das 3D-Modell als JSON aufbauen, nur damit Rust es verwirft (bei Kataster-
/// Importen sekundenlanges Stocken).
#[tauri::command]
fn native_viewport_enabled() -> bool {
cfg!(any(feature = "native2d", feature = "native3d"))
cfg!(all(any(feature = "native2d", feature = "native3d"), not(target_os = "macos")))
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
@@ -248,6 +269,7 @@ pub fn run() {
native2d_embed_hide,
native2d_upload,
native2d_patch,
native2d_highlight,
native2d_layout,
native2d_frame,
native2d_texts,
@@ -264,6 +286,7 @@ pub fn run() {
native2d_embed_hide,
native2d_upload,
native2d_patch,
native2d_highlight,
native2d_layout,
native2d_frame,
native2d_texts,
+9
View File
@@ -240,3 +240,12 @@ pub fn patch(app: &AppHandle, from: u32, to: u32, ranges: &[(u64, u64)], bytes:
None => false,
}
}
/// Auswahl-Hervorhebung setzen (eigene Geometrie zuoberst) und neu zeichnen.
pub fn set_highlight(app: &AppHandle, geom: Option<ChunkGeom>, delete: Vec<u32>) {
if let Some(e) = app.state::<EmbedState>().0.lock().unwrap().as_mut() {
e.renderer.delete(&delete);
e.renderer.set_highlight(geom);
draw(e);
}
}