mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 10:34:31 +00:00
ifcviewer: move section_planes_ + xray_alpha_cap_ + updateFrameUniforms into ViewportCore (#84-m)
Per-frame uniform packing now lives in ViewportCore::updateFrameUniforms, which reads the camera (via the already-migrated buildViewProj), the section_planes_ vector, and the xray_alpha_cap_ scalar — all of which have moved into ViewportCore alongside frame_uniform_buffer_. ViewportWindow keeps reference-aliases on section_planes_ and xray_alpha_cap_ so the section-tool and X-ray toggle (still Qt-input- bound, still living in VW) keep compiling unchanged. The render-path caller in VW::render now does core_.updateFrameUniforms(). Extracted SectionPlane into its own Qt-free header (SectionPlane.h) so ViewportCore doesn't have to include OverlayRenderer.h's QString / QHash. OverlayRenderer.h re-exports it.
This commit is contained in:
@@ -271,6 +271,8 @@ ViewportWindow::ViewportWindow(QWindow* parent)
|
||||
selection_flags_buffer_ (core_.selection_flags_buffer_),
|
||||
selection_flags_capacity_(core_.selection_flags_capacity_),
|
||||
selection_flags_scratch_ (core_.selection_flags_scratch_),
|
||||
section_planes_ (core_.section_planes_),
|
||||
xray_alpha_cap_ (core_.xray_alpha_cap_),
|
||||
selection_ (core_.selection_),
|
||||
visibility_ (core_.visibility_) {
|
||||
// wgpu doesn't need a GL context; we just need a real native window
|
||||
@@ -3941,7 +3943,7 @@ void ViewportWindow::render() {
|
||||
|
||||
WGPUTextureView view = wgpuTextureCreateView(surf_tex.texture, nullptr);
|
||||
|
||||
updateFrameUniforms();
|
||||
core_.updateFrameUniforms();
|
||||
|
||||
// Per-frame cull: extract frustum planes from the same VP we just wrote
|
||||
// into the uniform, then run cullModelCpu on every visible model. The
|
||||
@@ -5817,43 +5819,7 @@ static Eigen::Vector3f orbitEye(const float target[3], float dist,
|
||||
// identically everywhere.
|
||||
// buildViewProj moved to ViewportCore (#84-h).
|
||||
|
||||
void ViewportWindow::updateFrameUniforms() {
|
||||
Eigen::Matrix4f view, proj;
|
||||
core_.buildViewProj(view, proj);
|
||||
|
||||
const Eigen::Matrix4f view_proj = proj * view;
|
||||
|
||||
FrameUniforms u = {};
|
||||
std::memcpy(u.view_proj, view_proj.data(), 16 * sizeof(float));
|
||||
|
||||
// Values match the GL viewport's main fragment shader so a side-by-side
|
||||
// diff of the two backends only shows what the wgpu pipeline has yet to
|
||||
// implement (edge silhouette pass, MSAA polish, etc.) — not lighting
|
||||
// model differences. Key + fill are ~unit-length, ~120° apart.
|
||||
Eigen::Vector3f L( 0.3f, 0.5f, 0.8f); L.normalize();
|
||||
Eigen::Vector3f F(-0.3f, -0.5f, 0.8f); F.normalize();
|
||||
u.light_dir[0] = L.x(); u.light_dir[1] = L.y(); u.light_dir[2] = L.z(); u.light_dir[3] = 0;
|
||||
u.fill_dir [0] = F.x(); u.fill_dir [1] = F.y(); u.fill_dir [2] = F.z(); u.fill_dir [3] = 0;
|
||||
u.sky_color [0] = 0.55f; u.sky_color [1] = 0.60f; u.sky_color [2] = 0.70f;
|
||||
u.ground_color[0] = 0.35f; u.ground_color[1] = 0.32f; u.ground_color[2] = 0.28f;
|
||||
|
||||
// Pack active section planes. `is_section_clipped` (WGSL) reads
|
||||
// u.clip_count and u.clip_planes[0..clip_count) and discards
|
||||
// fragments on the positive side.
|
||||
const int n = std::min<int>(int(section_planes_.size()), kMaxSectionPlanes);
|
||||
u.clip_count = n;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const SectionPlane& p = section_planes_[i];
|
||||
u.clip_planes[i][0] = p.n.x();
|
||||
u.clip_planes[i][1] = p.n.y();
|
||||
u.clip_planes[i][2] = p.n.z();
|
||||
u.clip_planes[i][3] = p.d;
|
||||
}
|
||||
u.xray_alpha_cap = xray_alpha_cap_;
|
||||
u._pad_xray[0] = u._pad_xray[1] = u._pad_xray[2] = 0.0f;
|
||||
|
||||
wgpuQueueWriteBuffer(queue_, frame_uniform_buffer_, 0, &u, sizeof(u));
|
||||
}
|
||||
// updateFrameUniforms moved to ViewportCore (#84-m).
|
||||
|
||||
// computeSceneAabb moved to ViewportCore (#84-h).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user