-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty and invisible CSG shapes. #43381
Conversation
The difference between our approaches boils down to keeping or discarding collision with invisible shapes. The reason I don't agree with this approach is because it's inconsistent with the behavior of all other collisions in the engine. |
EDIT: Nvm I've mistaken visual layers for light layers. |
Updated the documentation to drop the caveat. |
Perhaps they shouldn't, but the point is: CSG shapes have a useful feature that allows us to create a However, the root of the problem is, no matter how it is implemented, there will always be inconsistent behaviour. Visibility cannot be used to simply prevent a CSG component from being drawn, because depending on the |
OK, but what about toggling the root shape's visibility? Currently (3.2.3, not 3.2.4 beta 1) it's possible to hide it with This is what #40814 intended to do; fix the problems without sacrificing function. The root shape deserves the ability to be hidden without disabling collision as no changes to the shape are taking place. |
Also, and I should clarify why this I'm contesting this PR; for my project I'm toggling visibility of With this PR, my RigidBody props will fall through the floor if using I really hope you may review #40814 and give feedback or make changes, for it's what I believe to be the best of all worlds here. |
Testing your demo project with #40814 yields the following results: Only toggling a child shape's visibility should affect collision. Thus, the ones highlighted in pink should have their collision updated, which are as follows:
The most important reason why I believe #40814 to be preferable over this PR is consistency over collision with invisible objects. No other nodes lose collision if you hide them. Secondly, and almost as important, #40814 aims to mitigate stuttering caused by unnecessary regeneration of shapes when toggling the root shape's visibility. This requires that root shapes never recalculate when their visibility is toggled. It's been many months now without an approved solution for those issues, and the only thing preventing any sort of fix is our disagreement on the approach. |
Currently, there is inconsistency in how CSG shapes create collision shapes when they or their components are invisible or change their visibility:
#40919 significantly improved this, but some inconsistency remains:
This PR makes the collision shapes consistent with the CSG shape:
Fixes #43251.
For those that are interested, the project used to create the above tests is: 43251.zip. It consists of 20 tests: every combination of changing the visibility of a platform or part thereof and a
RigidBody
ball above it to test theCollisionShape
.There are two layers. The top layer creates the shapes with the toggled components visible. The bottom layer creates the shapes with the toggled components invisible. Then the visibility of the CSG shape, or a part of it, is toggled every two seconds.
Each layer has three rows. The front row of each layer has three shapes that consist of a single shape. The second row of each layer has three shapes that consist of double shapes created from two shapes without a
CSGCombiner
. The back row of each layer has four shapes that consist of double shapes created from two shapes inside aCSGCombiner
.In the front row, the left two shapes are contained within a
CSGCombiner
; the right one is on its own. The left shape (Test1 and Test11) toggles the visibility of theCSGCombiner
. The middle shape (Test2 and Test12) toggles the visibility of the shape inside theCSGCombiner
. The right shape (Test3 and Test13) toggles the visibility of the shape.In the middle row, the left two shapes toggle the visibility of the parent shape; the right shape toggles the visibility of the child shape. In the left shape (Test4 and Test14) the ball is above the parent shape. In the middle shape (Test5 and Test15) the ball is above the child shape. In the right shape (Test 6 and Test16) the ball is also above the child shape.
In the back row, the left two shapes toggle the visibility of the
CSGCombiner
; the right two shapes toggle the visibility of a child shape. In the left most shape (Test7 and Test17) the ball is above the first child. In the second to left most shape (Test8 and Test18) the ball is above the second child. In the second to right most shape (Test9 and Test19) the ball is above the first child. In the right most shape (Test10 and Test20) the ball is above the second child.Finally, there was a discussion in #43251 about what the right solution was. Two options were floated:
This PR implements option 1. However, @hoontee preferred option 2 and created #43322 to implement that approach. I think option 1 is the better solution, because it is more intuitive. Furthermore, if a user has a need for separating the
VisualInstance
and theCollisionShape
, they can already do this: they literally create two separate meshes and, with one, enableUse Collision
and remove it from theVisualInstance
layer. To demonstrate this I've recreated the project presented in #43322: 43251a.zip. This approach has the added advantage of not constraining the differences to the components of the CSG shape.