Skip to content

P3: Check collision LOD pieces that have no detail0 partner - #8072

Open
dustinspace217 wants to merge 2 commits into
scp-fs2open:masterfrom
dustinspace217:collision/lod-only-submodels
Open

dustinspace217 wants to merge 2 commits into
scp-fs2open:masterfrom
dustinspace217:collision/lod-only-submodels

Conversation

@dustinspace217

Copy link
Copy Markdown
Contributor

What?

With $Collision LOD set, pieces that exist only in the lower-detail model now take hits. Only ships that check collisions or spread shields from a lower LOD are affected.

Fixes #4112

Why?

On the Blue Planet GTD Erebus, $Collision LOD: 1 lets shots pass straight through the back half of the ship. Its detail1 hull piece, hull_back1, has no detail0 partner, and collision only reaches lower-detail pieces through a detail0 partner, so it was never checked.

How?

When the detail0 root is swapped for its collision LOD, mc_check_subobj now also walks that LOD's children. Inside that tree it skips pieces that are LOD partners of something in detail0, since their detail0 piece already checks them. Only the root does this, because partners are matched by name and two detail0 pieces can pair with each other.

Goober asked on the issue whether the game could detect this at load. Since these pieces now get checked, I didn't add a load warning.

Testing?

Master 94d278a vs. this branch, Release, OpenGL and Vulkan, MediaVPs 5.0.3, mission sm1-01. The test mod held only the Blue Planet Erebus model, its hull textures, and two ship classes identical except for $Collision LOD: 1. A Lua script fired 90 shots across each Erebus's side and 153 at a retail GTD Orion.

Erebus, no LOD Erebus, LOD 1 Orion
master 79 hits 50 hits 53 hits
branch 79 hits 79 hits 53 hits

The LOD 1 Erebus is now hit along the same lines as the normal one. The other two matched master shot for shot on both renderers. One shot at each turret of an Orion set to $Collision LOD: 1 (its main turrets have LOD partners) gave the same submodels and subsystem damage on master and the branch. A Debug build's log through the shots and the mission to 2:30 showed no new warnings against master's.

Not tested: ship-ship collisions, debris, props, +Spread From LOD shields, $Collision LOD: 2, destroyed subsystems.

Anything Else?

A swapped piece's polygons are still only tested when the shot crosses the detail0 piece's bounding box, as the wiki describes, so LOD geometry sticking out past it can still be missed. Using the partner's own box is a one-line change if you'd like it.

I used Claude Code to help write and test this.

With $Collision LOD set, collision walked the detail0 tree and swapped each
piece for its lower-detail partner, so pieces that exist only in the lower
detail model were never checked and shots passed through them. Also walk the
collision LOD's children that have no detail0 partner.
LOD partners are paired by name, so two pieces in the detail0 tree can pair
with each other; walking a partner's children from every swapped piece could
then revisit the same tree. Only the detail0 root walks its collision LOD's
unpartnered children, and inside that tree lower-detail partners are skipped
because their detail0 piece already checks them.
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.

$Collision LOD: in ships table too narrow

1 participant