Facepunch / sbox-issues

178 stars 12 forks source link

Physics cache should get cleared immediately after GameObject tags are changed #5077

Closed Gmod4phun closed 8 months ago

Gmod4phun commented 9 months ago

Describe the bug

As is written in the collision matrix description, moving objects away from each other should clear the cache. image

This seems to be the case indeed, however, there is a slight problem. When you change an object's tags so that it should no longer collide with another object, the objects will continue to collide with eacother unless they are moved away from each other, clearing the cache.

I believe it would be an excellent idea to clear the cache when a change to gameobject's tags occurs, otherwise things can collide with shit that it has no business colliding with.

To Reproduce

  1. Have two objects collide with each other (a plane, and a barrel on top of it)
  2. Change the tags on the barrel object so that it should not collide with the plane
  3. Notice that they will continue to collide unless they move away far enough so that cache clears

Expected behavior

Immediate clearing of the cache after a gameobject's tags are changed.

Media/Files

Demonstration video: I spawn a barrel prop on top of a plane, after half a second the prop is moved to a different 'world' where it should no longer collide with the plane (the prop's tags are changed to ignore the plane). Notice that it still collides with the plane until it moves further away from the plane, then the physics updates properly.

https://github.com/Facepunch/sbox-issues/assets/5991682/ad5c90a7-1340-404f-a624-2cf190b159f5

Additional context

No response

aylaylay commented 8 months ago

Contacts should get refreshed on tag change now. Let me know if you find any other situation where contacts should get refreshed.

https://github.com/Facepunch/sbox-issues/assets/1667289/3b02e2c4-328a-443b-b26b-80f3698b9c73

Gmod4phun commented 8 months ago

Seems to work flawlessly now, thanks again. If I find anything that needs similiar adjustments I will let you know.