Skip to content

Comments

tr_model_iqm: detect and rewrite NaN in IQM model#1469

Merged
illwieckz merged 1 commit intomasterfrom
illwieckz/iqm-nan
Feb 18, 2025
Merged

tr_model_iqm: detect and rewrite NaN in IQM model#1469
illwieckz merged 1 commit intomasterfrom
illwieckz/iqm-nan

Conversation

@illwieckz
Copy link
Member

@illwieckz illwieckz commented Dec 20, 2024

Rewrite NaN in model IQM input.

The prifle_view.iqm model has some NaN in the input data:

When such model file is used, it is impossible to get anything useful when trapping for invalid operations because the first call of R_TBNtoQtangents() when loading the model will stop the execution.

There are other floats in the IQM file, we may want to not hack BuildTangents() and sanitize all the floats in the future with a generic function, but this works for now.

Here is the IQE text equivalent of the IQM format, there are many float fields like that:

pq 0 0 0 0.707107008 0.000172803004 0.707107008 -0

vp -7.02030039 -5.93917179 -10.5407791
vn -0.373933047 -0.803014815 -0.464048833
vx 0.618980289 0.156532541 -0.769649923 -1
vt 0.857393026 0.983985007
vb 9 1

Here is an example of broken input, the current code currently only cares about vx.

vp -4.99237871 -17.1318531 -6.18218517
vn -0.0307731722 8.04468016e-07 -0.999526381
vx nan nan nan 1
vt 0.548720002 0.101943001
vb 1 1

@VReaperV
Copy link
Contributor

I assume this doesn't have much of an effect on loading times?

There are other floats in the IQM file, we may want to not hack BuildTangents() and sanitize all the floats in the future ith a generic function, but this work for now.

This should be added as a comment.

@VReaperV
Copy link
Contributor

Tested, there's no discernible impact on loading times. The warn that tells which exact input is NaN is a bit spammy though. That might not be much of an issue if the prifle model is fixed though.

@illwieckz illwieckz force-pushed the illwieckz/iqm-nan branch 2 times, most recently from 1e0ecf3 to 6179377 Compare February 6, 2025 18:48
@illwieckz
Copy link
Member Author

I modified the whole loading to check for NaN in all IQM floats.

@illwieckz illwieckz force-pushed the illwieckz/iqm-nan branch 2 times, most recently from 97a39d6 to debaca5 Compare February 14, 2025 17:29
@illwieckz illwieckz changed the title tr_model_iqm: rewrite NaN in model IQM input tr_model_iqm: detect and rewrite NaN in IQM model Feb 14, 2025
@slipher
Copy link
Member

slipher commented Feb 17, 2025

LGTM

@illwieckz illwieckz merged commit cddf4fb into master Feb 18, 2025
9 checks passed
@illwieckz illwieckz deleted the illwieckz/iqm-nan branch February 18, 2025 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants