forked from 1b-agent/opencadstudio-upstream
refactor: remove the legacy full view_proj (CPU cull now relative-to-eye)
The GPU draws exclusively via the rotation-only `view_rot` + eye double- single; the full view-projection survived only to project AABBs in the CPU frustum-cull / scissor / LOD passes. Migrate those to the same relative-to-eye math (project `point - eye` through `view_rot`) — pixel- equivalent but precise at UTM scale — then drop the dead uniform: - pipeline cull/scissor/LOD helpers take (view_rot, eye) instead of the full view_proj; render.rs reconstructs eye from the uniform's eye_high/eye_low and passes the cropped view_rot. - Remove the `view_proj` field from the shared Uniforms struct and all six shader structs that only declared it for layout (none read it), and delete Camera::view_proj(). The struct shrinks by one mat4 on both sides, keeping the Rust / WGSL layouts in lock-step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
5a8ec35f4f
commit
04c93df2c4
10 files changed
+57
-80
No files matched your search
+15
-10
@@ -305,13 +305,20 @@ impl shader::Primitive for Primitive {
|
||||
// refreshed every frame it's present, so a drag never re-uploads
|
||||
// the resident base wire buffer.
|
||||
inner.upload_preview_wires(device, &vp.preview_wires[..], &vp.draw_depths);
|
||||
let vproj = vp.uniforms.view_proj;
|
||||
inner.compute_wire_scissors(vproj, clip_size.width, clip_size.height);
|
||||
inner.compute_wipeout_scissors(vproj, clip_size.width, clip_size.height);
|
||||
inner.compute_image_scissors(vproj, clip_size.width, clip_size.height);
|
||||
inner.compute_hatch_lod(queue, vproj, clip_size.width, clip_size.height);
|
||||
inner.compute_wipeout_lod(vproj, clip_size.width, clip_size.height);
|
||||
inner.compute_mesh_lod(vproj, clip_size.width, clip_size.height);
|
||||
// Cull / scissor / LOD project AABBs relative-to-eye (matching the
|
||||
// GPU's RTE path) so the math stays precise at UTM-scale coords.
|
||||
let view_rot = vp.uniforms.view_rot;
|
||||
let eye = glam::DVec3::new(
|
||||
vp.uniforms.eye_high[0] as f64 + vp.uniforms.eye_low[0] as f64,
|
||||
vp.uniforms.eye_high[1] as f64 + vp.uniforms.eye_low[1] as f64,
|
||||
vp.uniforms.eye_high[2] as f64 + vp.uniforms.eye_low[2] as f64,
|
||||
);
|
||||
inner.compute_wire_scissors(view_rot, eye, clip_size.width, clip_size.height);
|
||||
inner.compute_wipeout_scissors(view_rot, eye, clip_size.width, clip_size.height);
|
||||
inner.compute_image_scissors(view_rot, eye, clip_size.width, clip_size.height);
|
||||
inner.compute_hatch_lod(queue, view_rot, eye, clip_size.width, clip_size.height);
|
||||
inner.compute_wipeout_lod(view_rot, eye, clip_size.width, clip_size.height);
|
||||
inner.compute_mesh_lod(view_rot, eye, clip_size.width, clip_size.height);
|
||||
if vp.show_viewcube {
|
||||
inner.viewcube.upload(
|
||||
queue,
|
||||
@@ -743,9 +750,7 @@ impl Scene {
|
||||
};
|
||||
let mut uniforms =
|
||||
Uniforms::new(&inst.camera, full_bounds, self.document.header.lineweight_display);
|
||||
uniforms.view_proj = crop_view_proj(uniforms.view_proj, uo, vo, us, vs);
|
||||
// The RTE matrix is a view-projection too, so the same clip-space crop
|
||||
// applies — keep it in lock-step with view_proj for tiled / sub-rect panes.
|
||||
// Crop the rotation-only RTE view-projection to the visible sub-rect.
|
||||
uniforms.view_rot = crop_view_proj(uniforms.view_rot, uo, vo, us, vs);
|
||||
uniforms.viewport_size = [visible_w, visible_h];
|
||||
uniforms.flat_shade = if flags.flat_shade { 1.0 } else { 0.0 };
|
||||
|
||||
Reference in new issue
Block a user