| … | … | @@ -100,7 +100,9 @@ bool DCGeneratorMeshSDF::_build_from_verts_indices(const std::vector<Vec3>& vert |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // Compute proper pseudonormals for robust sign determination |
| 103 | | compute_pseudonormals(vertices, face_indices); |
| 103 | if (!unsigned_only_) { |
| 104 | compute_pseudonormals(vertices, face_indices); |
| 105 | } |
| 104 | 106 | |
| 105 | 107 | // Compute bounds |
| 106 | 108 | bounds_min_[0] = bounds_min_[1] = bounds_min_[2] = std::numeric_limits<float>::max(); |
| … | … | @@ -584,9 +586,14 @@ float DCGeneratorMeshSDF::evaluate(float x, float y, float z, float /*lod_voxel_ |
| 584 | 586 | Vec3 closest_normal; |
| 585 | 587 | float signed_dist_sq = closest_distance_sq(x, y, z, closest_normal); |
| 586 | 588 | |
| 587 | | float sign = (signed_dist_sq >= 0.0f) ? 1.0f : -1.0f; |
| 588 | 589 | float dist = std::sqrt(std::fabs(signed_dist_sq)); |
| 590 | if (unsigned_only_) { |
| 591 | // No pseudonormals were built, so the sign carried in signed_dist_sq is |
| 592 | // meaningless. The caller supplies it. |
| 593 | return dist; |
| 594 | } |
| 589 | 595 | |
| 596 | float sign = (signed_dist_sq >= 0.0f) ? 1.0f : -1.0f; |
| 590 | 597 | // Convention: positive = solid (inside), negative = air (outside) |
| 591 | 598 | return dist * sign; |
| 592 | 599 | } |