Skip to content

Remove dead modelinterp code and fix big-endian BSP swapping - #7782

Open
Goober5000 wants to merge 3 commits into
scp-fs2open:masterfrom
Goober5000:cleanup/modelinterp
Open

Goober5000 wants to merge 3 commits into
scp-fs2open:masterfrom
Goober5000:cleanup/modelinterp

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

Follow-up cleanup from the memory leak investigation in #7781.

  • Remove dead code. model_interp_defpoints has had no callers since model_interp_sub was removed in 2016. The parse_bsp and find_tri_counts chains have had no entry point since bsp_polygon_data replaced them in 2015. This also removes the globals that only they used.
  • Remove the interp-data allocator. On big-endian builds, swap_bsp_defpoints was the last caller of model_allocate_interp_data, and swap_bsp_flatpoly the last reader of Interp_verts. The BSP swap functions now pass a local vertex list instead, so the allocator, the deallocator, and the Interp_* buffers are gone.
  • Fix two big-endian swap bugs. swap_bsp_sortnorm2 swapped the bounding box at the wrong offsets, and swap_bsp_tmap2poly never swapped its bounding box or normal. Both corrupted models that use these newer chunks on big-endian builds.

Tested with Debug builds of fs2_open, FRED2, qtfred and the unit tests. The big-endian code was compile-checked by temporarily enabling it, since there's no big-endian hardware to test on.

@Goober5000 Goober5000 added the cleanup A modification or rewrite of code to make it more understandable or easier to maintain. label Sep 13, 2026
@notimaginative

Copy link
Copy Markdown
Contributor

This includes #7781, was that intentional?

@Goober5000

Copy link
Copy Markdown
Contributor Author

This includes #7781, was that intentional?

Yes, because this branch is based on that one. I'd do a stacked PR, but those aren't supported across forks unfortunately.

Goober5000 and others added 3 commits September 15, 2026 12:47
model_interp_defpoints has had no callers since model_interp_sub was
removed (1ef7688), and the parse_bsp and find_tri_counts chains have
had no entry point since bsp_polygon_data replaced them (c620372).
Remove them, along with the globals that only they read: tri_count,
model_radius, GEOMETRY_NOISE, Interp_flags, Interp_lights,
Interp_thrust_scale_subobj and Interp_warp_scale_*.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…x list

On big-endian builds, swap_bsp_defpoints was the only remaining caller
of model_allocate_interp_data, and swap_bsp_flatpoly the only reader of
the buffers it allocated (Interp_verts).  Pass a local vertex list
through the BSP swap functions instead, and remove the allocator, the
deallocator, and the Interp_* buffers and lighting globals it managed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
swap_bsp_sortnorm2 swapped the bounding box at offsets 8 and 20, which
re-swapped the front list offset and left the real box (at 16 and 28)
unswapped.  swap_bsp_tmap2poly never swapped the chunk's bounding box
or normal.  Both corrupted models using these chunks on big-endian
builds.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup A modification or rewrite of code to make it more understandable or easier to maintain.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants