refactor: optimize shell analysis to use 6 orthogonal projection directions

- Changed SHELL_ANALYSIS_NUM_DIRECTIONS from 96 to 6
- Replaced Fibonacci sphere sampling with 6 orthogonal directions (X/Y/Z axes)
- Maintains same occlusion detection with Z-buffer algorithm
- Reduces computation while preserving accuracy for most models

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sladro 2025-09-20 08:21:13 +08:00
parent 0a2804a0f2
commit 92cd47549f

View File

@ -30,7 +30,7 @@
#include <vector>
// Shell Analysis Algorithm Constants
const int SHELL_ANALYSIS_NUM_DIRECTIONS = 96; // 多方向投影采样数量
const int SHELL_ANALYSIS_NUM_DIRECTIONS = 6; // 6-direction orthogonal projection sampling
const int SHELL_ANALYSIS_GRID_RESOLUTION = 96; // 网格分辨率96x96
const double SHELL_ANALYSIS_MIN_VISIBLE_RATIO_PER_DIR = 0.001; // 单方向最小可见占比0.1%
const double SHELL_ANALYSIS_MIN_VISIBILITY_RATIO = 0.03; // 最小可见率3%方向可见即为外壳候选(降低阈值)
@ -2602,24 +2602,23 @@ CreoManager::AABB CreoManager::TransformAABB(const AABB& localAABB, pfcTransform
}
}
// Sample directions using Fibonacci sphere distribution
// Sample 6 orthogonal directions (front/back, left/right, up/down)
std::vector<CreoManager::Vector3D> CreoManager::SampleDirections(int count) {
std::vector<Vector3D> directions;
directions.reserve(count);
directions.reserve(6);
double phi = (1.0 + sqrt(5.0)) / 2.0; // Golden ratio
// Six orthogonal directions for comprehensive coverage
// X-axis: front and back
directions.push_back(Vector3D(1.0, 0.0, 0.0)); // Front (+X)
directions.push_back(Vector3D(-1.0, 0.0, 0.0)); // Back (-X)
for (int i = 0; i < count; ++i) {
double t = (double(i) + 0.5) / double(count);
double z = 1.0 - 2.0 * t; // z from 1 to -1 (full sphere)
// Y-axis: left and right
directions.push_back(Vector3D(0.0, 1.0, 0.0)); // Right (+Y)
directions.push_back(Vector3D(0.0, -1.0, 0.0)); // Left (-Y)
// No clamping - use full sphere sampling
double r = sqrt(std::max(0.0, 1.0 - z * z));
double azimuth = 2.0 * M_PI * i / phi;
Vector3D dir(r * cos(azimuth), r * sin(azimuth), z);
directions.push_back(dir.normalize());
}
// Z-axis: up and down
directions.push_back(Vector3D(0.0, 0.0, 1.0)); // Up (+Z)
directions.push_back(Vector3D(0.0, 0.0, -1.0)); // Down (-Z)
return directions;
}