Fix surface receiver vertex corruption and Flatpak resource path resolution - #426
Open
diegotonetti99 wants to merge 1 commit into
Conversation
…lution Surface receiver rendering (Universite-Gustave-Eiffel#425): - baseReportManager.cpp: sommetsIndex was populated via memcpy(..., sizeof(ivec3)), copying 24 bytes (ivec3 stores three `long`, 8 bytes each on LP64) into the 12-byte Intb sommetsIndex[3] (int32) field of t_FaceRS. Every face ended up with vertices (a, 0, b) instead of (a, b, c), corrupting every exported surface receiver face on Linux/macOS. Fixed with element-wise assignment at all 4 call sites. - Recepteurs_surfacique.cpp: guard the per-vertex energy average against quantFacesLinked==0 (a vertex whose surrounding faces all recorded zero energy), which produced NaN and broke smooth-color shading for every triangle sharing that vertex. - Recepteurs_surfacique.cpp: clear iso_curves before recomputing them in LoadRecepteursSFile, since Refresh() can run multiple times over a controller's lifetime and stale curves from an earlier pass were never discarded, rendering on top of the current, correct set. - std_rsbin.cpp: FINDMINMAX_RSURF was missing the check for the first triangle vertex (x0), so it never contributed to the iso-contouring min/max range. Flatpak resource path resolution (Universite-Gustave-Eiffel#420): - Resolve a bare relative default.gpl path (baked into older/template projects) against the app's resources folder instead of the process' current working directory, which Flatpak does not guarantee is the app's install dir. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 6, 2026
Member
|
Hello, Thanks for your contribution. There is some duplicate fix here than in the other pull request #418 |
Member
|
You are invited to agree with the Contributor License Agreement: Entity Contributor License Agreement, for institutions Individual Contributor License Agreement, for individual contributors Contributors must fill one of these forms and send the signed version by mail at: I-Simpa@ifsttar.fr If contributions are accepted in a new release, Contributors will be added in the 'About' dialog box of I-Simpa. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #425 and #420.
Surface receiver vertex corruption (#425)
baseReportManager.cpppopulatedt_FaceRS::sommetsIndex(anIntb[3], i.e.int32_t[3]) viamemcpy(..., sizeof(ivec3)).ivec3stores its three components aslong, which is 8 bytes on LP64 (Linux/macOS), so the memcpy wrote 24 bytes into a 12-byte field. In practice every triangle's second vertex index (b) got overwritten by the low half of the third vertex's value, and every triangle's third vertex ended up reading zeroed/adjacent memory — visible in exported.csbinfiles as the vast majority of triangles sharing vertex0. This corrupted every surface receiver's colormap and iso-contour rendering on Linux/macOS (Windows was unaffected, sincelongis 4 bytes there). Fixed with element-wise index assignment at all 4 call sites.Verified by parsing a real
rs_cut.csbinbefore/after the fix: before, vertex 0 was referenced by 121 of 360 face-vertex slots (all faces hadsommetsIndex[1]==0); after, vertex 0 is only referenced by its legitimate ~2-3 corner faces, and the receiver renders as a smooth, correctly-triangulated grid.Two related rendering bugs found and fixed alongside it, both required to fully clear up the broken colormap on Linux:
Recepteurs_surfacique.cpp: the smooth-color per-vertex energy average divided byquantFacesLinkedwithout checking it was non-zero, producingNaN(and visibly corrupting the shading of every triangle sharing that vertex) whenever every face touching a vertex recorded zero energy.Recepteurs_surfacique.cpp:iso_curveswas never cleared before being recomputed inLoadRecepteursSFile, so stale contour lines from an earlierRefresh()call stayed rendered on top of the current, correct set (visible as tangled scribbles over the colormap).std_rsbin.cpp:FINDMINMAX_RSURFnever checked the first triangle vertex (x0) against min/max, only the other two.Flatpak resource path resolution (#420)
Older/template projects can carry a bare relative default
.gplpalette path (e.g.Bitmaps/iso/jet.gpl) baked in from before this was fixed to store an absolute path.LoadGplFilenow resolves such a relative path against the app's resources folder instead of relying on the process' current working directory, which Flatpak does not guarantee is set to the app's install directory.Test plan
flatpak-builder --user --install --force-clean --ccache build org.noise_planet.i-simpa.yml)rs_cut,TR15,TR30) now renders a smooth colormap with clean iso-contour lines, no missing/overlapping triangles.csbinwith a small script to confirm vertex indices are no longer corruptedsurfaceReceiverTest1unit test only checks header metadata (nbTimeStep,recordType), not face vertex indices — worth extending in a follow-up to catch this class of bug in CI🤖 Generated with Claude Code