beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
222 stars 102 forks source link

Per-piece colvols may be broken #1513

Open sprunk opened 6 months ago

sprunk commented 6 months ago

Shoot a BAR corgant in the back with an armmanni, apparently it deals no damage and apparently it is due to the usePieceCollisionVolumes unit def tag on corgant.

image image

drivver44 commented 6 months ago

removing the tag or adding a collisionvolumes.lua perpiececollision fixes the issue

drivver44 commented 6 months ago

additional notes one of the hitboxes that is being generated is not allowing damage to the corgant units with sufficient aoe are capable of causing damage to the corgant such as the shiva units with 0 aoe or with the impactonly are affected

drivver44 commented 6 months ago

for further note corgant has 31 model pieces that are having their own hitbox is there a cap for when damage checks are stopped?

drivver44 commented 5 months ago

further addition https://github.com/beyond-all-reason/Beyond-All-Reason/issues/1387 this issue as i recall is the exact same as what is going on here this was part of a silent test and i did miss identify the bug that occured yes this is another one of my failures to identify bugs properly

marcushutchings commented 5 months ago

How long has this been an issue on the engine?

sprunk commented 5 months ago

always has been

drivver44 commented 5 months ago

How long has this been an issue on the engine? New WinRAR ZIP archive.zip

i have a replay that is from about two years ago since the toaster at this time had only a usepeicecollisionvolume ( i deleted/change/something to the colisionvolume.lua definition.) so here is the link to said replay for the bar wesbite provider https://bar-rts.com/replays/9bef52636512eaabb2c2f83f1aaebe75 i conviently had this replay in dms from zecrus for an unrelated document

lhog commented 4 months ago

Preliminary results: Looks like the piece collision itself is working fine, but per-piece and per-object collision might return slightly different collision position (TODO: intro a runtime switch to check the difference). Both would be fine if not for the corgant collision volume that is shifted. More investigation is needed.

badosu commented 3 weeks ago

Is this issue fixed?

lhog commented 3 weeks ago

Nope, it's fundamentally broken as model collision volumes can be shifted around in Unit/Feature Defs, but per-piece volumes do not (and cannot) reflect these changes.

lhog commented 3 weeks ago

I have some ideas how to bandage this one up, need to have a closer look.

sprunk commented 3 weeks ago

Having to reflect them is an issue on its own. If per-piece colvols are used then the per-whole-model shouldn't affect anything.

sprunk commented 3 weeks ago

There are multiple related issues: 1) ❌ Here I put the model's colvol far away. If the per-model colvol doesn't cover pieces, they fail to collide: image

2) ❌ Here I made the model's colvol huge. It doesn't collide with projectiles, but these shots deal full damage because they are inside the model colvol (which is not shown on /debugcolvol for units that use per-piece collisions) and this is usually used for damage calculations. image

3) ❌ Same huge colvol, but now a piece is being hit directly by the LLT. The AoE leveler shot now fails to do damage because it no longer uses the model colvol for aoe damage calculation but counts distance to the piece being hit by a different weapon (marked red by debugcolvol). image

4) ✅ On the pic above, the LLT itself works correctly, and direct hits from (at least single) projectiles work correctly. This is because it uses the "count damage against the last piece to be hit" behaviour and in those cases the last hit piece is the one you're actually hitting.

5) ✅ Two LLTs directly hitting two different pieces work correctly, i.e. they actually fire and deal damage "atomically".

6) ❔ I haven't checked what happens if two projectiles, or a projectile and a delayed AoE hit, collide with two different pieces in the same frame. Note that this doesn't have to be the same as question 5 with LLTs, because those are beamlasers which handle their own collisions atomically in CBeamLaser::FireImpl while projectiles have a common collision pass, then a common "deal direct damage and queue up delayed damage" pass, then a common "apply delayed aoe damage" pass. (Do they collide sequentially or will this produce a single "last hit piece" for whichever projectile is calculated last, making one of them fail to deal damage properly?)

7) ❌ /debugcolvol only shows one "last hit piece" (marking it red), making the "multiple hits in 1 frame" cases look incorrect unless you look at events via lua and compare damage falloff. Though you wouldn't be able to catch failures when multiple things happen within a single frame by looking at this anyway.

8) ✅ impactOnly weapons deal damage directly to the unit on collision, skipping AoE calculations, so as long as they collide they seem to work correctly.

9) ❔ I haven't checked what happens if a projectile collides with one piece and you use gadget:Explosion or gadget:UnitPreDamaged to spawn a projectile on a different piece and immediately explode it such that it happens before the first one finishes. This is an "extreme polishing" level of detail so it doesn't really matter if it doesn't work correctly and we probably get it working for free if case 6 works. But it's good to be aware of this possibility.

10) ❔ I haven't checked "footprint based colvols", I assume that it boils down to behaving either the same as per-piece or per-model though.