Title: ifcgeom: fix inverted normals on mirrored MappedRepresentations (#806) by petruconduraru · Pull Request #8469 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: ifcgeom: fix inverted normals on mirrored MappedRepresentations (#806) by petruconduraru · Pull Request #8469 · IfcOpenShell/IfcOpenShell
X Title: ifcgeom: fix inverted normals on mirrored MappedRepresentations (#806) by petruconduraru · Pull Request #8469 · IfcOpenShell/IfcOpenShell
Description: Fixes #806. Problem An element placed through a MappedRepresentation with a mirror (negative-determinant) transform renders with inverted normals (the reporter's case is a toilet mirrored via a MappedRepresentation of a SurfaceModel). It shows as back-faces only in viewers and in IfcConvert to .dae. Cause In OpenCascadeConversionResult.cpp::Triangulate: vertices are transformed by the full 4x4 (correctly mirrored), explicit vertex normals are rotated by the same mirror-inclusive 3x3 (correctly outward), but the emitted triangle winding is taken purely from the topological face.Orientation() and never consults the transform determinant. A mirror reverses coordinate handedness, so after mirroring the vertices the emitted index order describes the opposite winding while the normals stay outward. The two disagree, and consumers that shade from winding see inverted normals. Fix Compute flip_winding = rotation_matrix && rotation_matrix->Determinant() < 0 once, and at the single triangle-emission point reverse the winding (std::swap(n1, n3)) when set, leaving the explicit normals untouched. Gated strictly on det < 0, so positive-determinant (non-mirrored) placements are byte-for-byte unchanged. The CGAL kernel derives normals from the post-transform geometry, so its winding and normals are already consistent; it is intentionally left unchanged (applying the same flip there would introduce the inconsistency). Verification Reproduced live on the bundled 0.8.6 build with a minimal IFC4 file (an IfcExtrudedAreaSolid in an IfcRepresentationMap, referenced by an IfcMappedItem whose MappingTarget mirrors X): with an identity target 12/12 triangles agree winding vs normals, with the mirrored target 0/12 agree (12/12 disagree), matching #806. The patched binary is not runtime-tested (no local kernel build); the fix targets exactly the reproduced disagreement, and CI's build-ifcopenshell compile-checks it. Generated with the assistance of an AI coding tool.
Open Graph Description: Fixes #806. Problem An element placed through a MappedRepresentation with a mirror (negative-determinant) transform renders with inverted normals (the reporter's case is a toilet mirrored via a...
X Description: Fixes #806. Problem An element placed through a MappedRepresentation with a mirror (negative-determinant) transform renders with inverted normals (the reporter's case is a toilet mirrored v...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/8469
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4ec1954a-a18a-3939-34a3-c82d8d84fe96 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E012:31EE77:260F191:319BB42:6B054D7D |
| html-safe-nonce | 94a4ca66022935ca124498707562c8b947e07f89543a61f4714afbd0df9e9c14 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDEyOjMxRUU3NzoyNjBGMTkxOjMxOUJCNDI6NkIwNTREN0QiLCJ2aXNpdG9yX2lkIjoiMzc4ODk3NjQwMTc4OTgzMjU3MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7644d380b0418c953788c356f9d1ced1199653417088883383189cb12ef3b482 |
| hovercard-subject-tag | pull_request:4029668190 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/IfcOpenShell/IfcOpenShell/pull/8469/files |
| twitter:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| og:image:alt | Fixes #806. Problem An element placed through a MappedRepresentation with a mirror (negative-determinant) transform renders with inverted normals (the reporter's case is a toilet mirrored via a... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width