FAForever / fa

Lua code for FAF
226 stars 233 forks source link

Draft setup for persistent tree groups #6097

Closed Garanas closed 3 months ago

Garanas commented 5 months ago

Description of the proposed changes

This is based on a suggestion of @clyfordv where when a tree group breaks (because of a collision, damage, etc) we do not delete the group and instead spawn in individual trees that are not reclaimable. That way we can still reclaim the tree group as a whole, and instead reduce the mass value as individual trees are destroyed.

Testing done on the proposed changes

## Additional context Ran into a strange bug where I am unable to change the mesh of a tree group after creating it. When the tree group 'breaks' we want to hide the mesh of the tree group itself. This allows the individual trees to take over, which in turn allows for interactions with units and damage. Attempts: - (1) Hide the mesh - this is not possible. Units are able to do this, but those are unit-specific functions. - (2) Scale the mesh to 0 - this is not possible. The rendering bounding box appears to be used to determine if we're hovering over a tree (group). As a result if we reduce the scale to 0 then the tree group becomes unclickable. - (3) Change the mesh - this appears to be buggy and is where I am now. I can change the mesh to a version with a shader that doesn't render any pixels on screen but only in the tick the prop is created. When I try it at a later moment it simply does not work and the game does not tell me why. I suspect it may be because of batching of the props, but then why does it work for individual trees as they take (fire) damage? ## Checklist - [ ] Changes are annotated, including comments where useful - [ ] Changes are documented in the changelog for the next game version
Garanas commented 5 months ago

@Hdt80bro any idea why the mesh change no longer works 1 tick after creating a tree group?

clyfordv commented 5 months ago

What if instead of hiding the mesh you just spawn an additional prop with the invisible shader? So parent tree group goes away, new invisible reclaim entity appears from the break.

Garanas commented 5 months ago

Because you'd lose the reclaim order on the original tree group when we do that. The nice part about this solution is that you would not lose that order 😃 !

clyfordv commented 5 months ago

Okay what about the reverse--the tree group is always an invisible, but has a submesh/entity/something(?) that gets resized when it breaks (so the parent bounding box remains for clickability). Does that require an additional dummy parent entity?

Garanas commented 5 months ago

I just tried that suggestion; I can't get it to work reliable. I just don't know how the engine determines what is and is not clickable and what the preferences are