Clear bsp_data from bsp_info after it has been used - #7754
Open
Shivansps wants to merge 2 commits into
Open
Conversation
Goober5000
requested changes
Aug 30, 2026
Goober5000
left a comment
Contributor
There was a problem hiding this comment.
Looks good overall; one thing
Comment on lines
+3512
to
+3515
| if (sm->bsp_data == nullptr) { | ||
| sm->num_polys = 0; | ||
| continue; | ||
| } |
Contributor
There was a problem hiding this comment.
This unfortunately has the side effect of leaving a collision tree with dangling data. So model_remove_bsp_collision_tree should be updated to set the freed pointers to nullptr and the counts to 0.
Contributor
Author
There was a problem hiding this comment.
right, then ill remove the if and the continue and move the nullprt check on before calling submodel_get_num_polys_sub()
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.
After taking a look at were bsp_data is used, i noticed that only submodel_get_num_polys() used it after it had completed model_load(), and this function was called only from freespace2.cpp when the -pofspew was used.
So i changed it to save the result of submodel_get_num_polys_sub() that submodel_get_num_polys() used when the -pofspew cmdline is used. Then i reseted the buffer.
Then i noticed -pofspew was causing an abort because submodel_get_num_polys_sub() had an infinite recursion bug when one of the list had a value of 0 and called submodel_get_num_polys_sub() again.
I confirmed this by running -pofspew on the current nightly and it crashes before exporting all models on BP 3.3.3 dataset, so this was probably broken for like, forever. I added a check to avoid this and how it works again.
As for the results of clearing the bsp_data cache:
On Icarus (with a dgpu)
Before:

After:

Im not noticing any problems with this change, but ill recommend someone who knows more about the model system (and virtual pof) might want to check it out first.
P.D. i moved model_get_textures_used() declaration from models.h to modelinterp.h i just added because it seems cleaner since i was adding a new header.