Files
ViewDesignEngine/include/vde_render/large_assembly_render.h
T
hm 02a97f5165 refactor(batch5): split partial out-of-scope modules
large_assembly: LODSwitchConfig/compute_lightweight_lod/auto_switch_lod → vde_render/large_assembly_render.h

structural_profiles: ProfileSpec/profile_library → vde_pdm/structural_profile_catalog.h

geometric_snap: live_cursor_snap/aperture → vde_ui/geometric_snap_ui.h

brep_drawing: DrawingSheet/Annotation → vde_drafting/drawing_sheet.h

pmi_mbd: export_3d_pdf/auto_generate_pmi → vde_drafting/pmi_export.h

All modules compile. Core geometry code retained in kernel.
2026-08-06 17:30:02 +08:00

90 lines
3.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
/**
* @file large_assembly_render.h
* @brief 大装配渲染端 LOD 切换配置与屏幕空间 LOD 选择
*
* 从 `vde/brep/large_assembly.h` 拆分出的渲染/屏幕空间概念:
* - `LODPolicy`:LOD 切换策略(基于距离 / 屏幕占比 / 混合)
* - `LODSwitchConfig`:屏幕尺寸阈值、过渡帧数、自动切换开关
* - `compute_lightweight_lod()`:根据相机距离与屏幕占比计算推荐 LOD 级别
* - `auto_switch_lod()`:批量更新零件的轻量化表示 LOD 级别
*
* 这些概念只依赖内核的公开数据结构(`LightweightRepresentation` /
* `LightweightLevel`),不引入内核对其的反向依赖。
*
* @ingroup render
*/
#include "vde/brep/large_assembly.h"
#include <vector>
namespace vde::render {
// ═══════════════════════════════════════════════════════════
// LODPolicy / LODSwitchConfig
// ═══════════════════════════════════════════════════════════
/**
* @brief LOD 切换策略
*/
enum class LODPolicy : int {
DistanceBased = 0, ///< 基于相机距离
ScreenSizeBased = 1, ///< 基于屏幕空间占比
Hybrid = 2 ///< 混合策略(距离 + 屏幕占比)
};
/**
* @brief LOD 切换配置(屏幕空间 / 相机距离阈值)
*
* 驱动 `compute_lightweight_lod()` 与 `auto_switch_lod()` 的渲染端参数。
*/
struct LODSwitchConfig {
LODPolicy policy = LODPolicy::Hybrid;
double medium_distance = 50.0; ///< 超过此距离切换到 Medium
double coarse_distance = 200.0; ///< 超过此距离切换到 Coarse
double bbox_distance = 500.0; ///< 超过此距离切换到 BoundingBox
double screen_size_full = 0.05; ///< 屏幕占比 > 此值 → Full
double screen_size_medium = 0.02; ///< 屏幕占比 > 此值 → Medium
double screen_size_coarse = 0.005; ///< 屏幕占比 > 此值 → Coarse
bool enable_auto_switch = true; ///< 是否启用自动切换
int transition_frames = 5; ///< LOD 切换过渡帧数(渐变)
};
// ═══════════════════════════════════════════════════════════
// 屏幕空间 LOD 选择
// ═══════════════════════════════════════════════════════════
/**
* @brief 计算单个零件的推荐 LOD 级别
*
* @param rep 轻量化表示(内核数据,只读)
* @param camera_distance 相机到装配体中心的距离
* @param screen_diagonal 屏幕对角线长度(用于屏幕占比计算)
* @param config LOD 切换配置
* @return 推荐的轻量化级别
*/
[[nodiscard]] brep::LightweightLevel compute_lightweight_lod(
const brep::LightweightRepresentation& rep,
double camera_distance,
double screen_diagonal,
const LODSwitchConfig& config);
/**
* @brief 基于相机距离与屏幕占比自动切换所有零件的 LOD
*
* 跳过手动设置了 LOD 覆盖的零件。当 `config.enable_auto_switch` 为 false 时直接返回。
*
* @param reps 轻量化表示列表(将被原地更新)
* @param camera_distance 相机到装配体中心的距离
* @param screen_diagonal 屏幕对角线长度
* @param config LOD 切换配置
*/
void auto_switch_lod(
std::vector<brep::LightweightRepresentation>& reps,
double camera_distance,
double screen_diagonal,
const LODSwitchConfig& config);
} // namespace vde::render