diff --git a/CreoManager.cpp b/CreoManager.cpp index b1682f6..113f08c 100644 --- a/CreoManager.cpp +++ b/CreoManager.cpp @@ -2820,21 +2820,21 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti projections.push_back({minProj, maxProj, comp.featureId}); } - // Sort by maximum projection value (farthest first) + // Sort by minimum projection value (nearest first) std::sort(projections.begin(), projections.end(), [](const ProjectionData& a, const ProjectionData& b) { - return a.maxProj > b.maxProj; + return a.minProj < b.minProj; }); - // Occlusion detection: only unoccluded components are visible - double occlusionBoundary = std::numeric_limits::max(); + // Occlusion detection: near components occlude far components + double occlusionBoundary = -std::numeric_limits::max(); for (const auto& proj : projections) { - // If component's farthest point is in front of occlusion boundary, it's visible - if (proj.maxProj < occlusionBoundary) { + // If component's nearest point is beyond occlusion boundary, it's visible + if (proj.minProj > occlusionBoundary) { result.visibilityVotes[proj.featureId]++; - // Update occlusion boundary to this component's nearest point - occlusionBoundary = proj.minProj; + // Update occlusion boundary to this component's farthest point + occlusionBoundary = std::max(occlusionBoundary, proj.maxProj); } } }