Skip to content

Fix animated trace joint surface mapping - #153

Merged
themuffinator merged 1 commit into
mainfrom
codex/fix-nearest-joint-surface-mapping
Sep 4, 2026
Merged

Fix animated trace joint surface mapping#153
themuffinator merged 1 commit into
mainfrom
codex/fix-nearest-joint-surface-mapping

Conversation

@themuffinator

Copy link
Copy Markdown
Owner

Fixes #151.

Animated model traces were passing a transient dynamic-snapshot array position into the source model's NearestJoint lookup. MD5 and MD5R snapshots can omit or reorder authored meshes, and a two-sided material appends an extra reversed surface. A later generated backface can therefore have an array position greater than the source mesh count, which reached the fatal guard reported in the issue.

Trace results now carry the snapshot surface's stable ID into joint lookup. Classic MD5 resolves a generated backface ID to its authored mesh index, while MD5R matches both front and back IDs against the mesh identifier. This also removes the source model's dependence on mutable per-snapshot surface positions.

Validation:

The supplied map archive on the previous binary also reached gameplay by itself, so it does not contain the reporter's complete model/material override trigger. The unsafe generated-surface contract is deterministic in the source and is corrected for both animated model formats.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T18:43:43.690414Z a9a90fd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9a90fdf8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2010 to +2011
if ( meshIndex >= MD5_BackSideSurfaceIdOffset ) {
meshIndex -= MD5_BackSideSurfaceIdOffset;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Disambiguate front surfaces from backside IDs

For an otherwise valid MD5 containing at least 1,001 one-sided meshes, the front surface of mesh 1000 has ID 1000, so this unconditional subtraction resolves its trace to mesh 0 and reports the wrong joint; the loader explicitly permits up to 65,536 meshes. The equivalent first-match alias exists in rvRenderModelMD5R::NearestJoint at Model_md5r.cpp:6122-6123, where ID 1000 matches mesh 0's hypothetical backside before mesh 1000's front, even when mesh 0 does not generate backsides. The backside namespace must not overlap valid front IDs, or resolution must verify that a backside was actually generated before preferring it.

Useful? React with 👍 / 👎.

@themuffinator
themuffinator merged commit 22c1558 into main Sep 4, 2026
21 of 25 checks passed
@themuffinator
themuffinator deleted the codex/fix-nearest-joint-surface-mapping branch September 4, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate NearestJoint surface mismatch during airdefense1 intro

1 participant