Skip to content
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

Removing and re-adding child CSG shape stops collision mechanics #58050

Closed
lfry512 opened this issue Feb 13, 2022 · 3 comments
Closed

Removing and re-adding child CSG shape stops collision mechanics #58050

lfry512 opened this issue Feb 13, 2022 · 3 comments

Comments

@lfry512
Copy link

lfry512 commented Feb 13, 2022

Godot version

v3.4.stable.official [206ba70]

System information

Ubuntu 20.04.3 LTS

Issue description

Hi there, when I remove a 3D collision CSG shape from a scene and add it again, intersect_ray no longer returns hits but the shape renders normally. I'm not sure if this is a bug but my expectation is that the collision mechanics should still be active upon re-adding the shape to the scene. The shape flag use_collision is unchanged after removal and re-addition to the scene tree apparently. I tried understanding what might be happening from the add_child and remove_child source code but nothing stands out to me.

I attach a minimal test project that tests both in-script and editor instanced collision shape in case that matters.

Steps to reproduce

Run the minimal reproduction project attached. Double click to remove and add the collision shape. See the console output, after re-adding the collision shape, no hits are triggered when mouse is hovered over object.

Minimal reproduction project

ColliderTest.zip

@lfry512 lfry512 changed the title removing and re-adding child stops collision mechanics [bug] removing and re-adding child stops collision mechanics Feb 13, 2022
@Calinou Calinou changed the title [bug] removing and re-adding child stops collision mechanics Removing and re-adding child CSG shape stops collision mechanics Feb 13, 2022
@Calinou
Copy link
Member

Calinou commented Feb 13, 2022

If you enable Debug > Visible Collision Shapes and run the project, can you still see the generated trimesh collision for the CSG shape after it was readded to the scene tree?

As a workaround, you can likely modify the CSG shape's geometry slightly after readding it to the scene tree. This will cause it to regenerate its collision.

@Calinou Calinou added this to the 4.0 milestone Feb 13, 2022
@lfry512
Copy link
Author

lfry512 commented Feb 13, 2022

Thanks Calinou,

If you enable Debug > Visible Collision Shapes and run the project, can you still see the generated trimesh collision for the CSG shape after it was readded to the scene tree?

I do not see a detected collision whether that option is true or false ,upon readding the shape to the tree. In both cases the geometry is not rendered when removed from the tree.

As a workaround, you can likely modify the CSG shape's geometry slightly after readding it to the scene tree. This will cause it to regenerate its collision.

Thanks for suggestion, this appears to not work either however: After readding, I tried to increase the radial segment and ring count of the CSG sphere and although the assignment works, the rendered shape is not drawn as expected. It appears to have the same parameters as when first initialised.

My current workaround is to just reinitialise it and that does work.

@akien-mga
Copy link
Member

Fixed by #58938.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants