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

The collision seems to be lost in the Editor but not when playing the Scene #129

Open
RonanZe opened this issue Mar 21, 2020 · 8 comments
Open
Labels
bug Something isn't working Waiting for Godot Godot has a bug and should be fixed first

Comments

@RonanZe
Copy link

RonanZe commented Mar 21, 2020

I'm trying to use the Scatter plugin an the snapping with "Page Down" shortcut and It do not always works.
It's a bit fishy because sometimes it comes back when I'm loading an other scene with a Terrain and then I work everywhere again.

I have a more precise case to describe:
My project have 2 scenes. Each scene have 1 Terrain Node in 4k.
When I "Save All Scenes", the Scatter Tool still works on the current scene.
But when I switch to the second scene, It do not works anymore.
Then I go back to the first scene and It is not working either.

And when I switch again on the second scene, everything seems to go back to normal.

Hope that's clear,
Ron

@Zylann Zylann added the bug Something isn't working label Mar 22, 2020
@Zylann
Copy link
Owner

Zylann commented Mar 23, 2020

I added some debug code in the plugin which throws a bunch of raycasts down to see where they land on the terrain (if they ever land). The collider is correct. I could not reproduce the problem by just switching scenes, unless you meant closing and reopening them?

I tried the "Page Down" tool, it just doesn't work. Even though my collision tests did. In fact, it snaps to somewhere way higher than the terrain, while the boxes I snapped using intersect_ray all landed on the surface.
image
Worse, it is detecting the box itself as collision... if I turn off its collision, it displays the message can not find solid floor. Which leads me to believe this snap tool relies on the presence of built-in nodes to work, doesn't consider plugin nodes like terrain, and does not even use the available collision information... I'm really confused, but I believe the snap tool needs improvements. It uses intersect_ray, but somehow it still misses the presence of my collider.
See godotengine/godot#20022 (comment)

I tried with the scatter plugin, could not reproduce the problem. I opened two scenes with a terrain in them, put a scatter node in one, switched to the other, clicked "Save All Scenes". The collider of the second scene was still correct. I switched to the first scene, the collider also remained correct and the scatter plugin continued to work.

Note: currently the collider does not update automatically when the terrain is modeled, which is done by going to Terrain -> Update editor collider. But that's a different issue.

@Zylann Zylann added Waiting for Godot Godot has a bug and should be fixed first Need more info labels Mar 24, 2020
@RonanZe
Copy link
Author

RonanZe commented Mar 24, 2020

Thanx for your investigations.
The snap tool need in fact a lot of improvements. In it's current state, it feel more like a work in progress stuff that a well design build-in tool.

I'll tried to send you a simplified demo file later today. Is it possible in GitHub or do I have to make a link?

@Zylann
Copy link
Owner

Zylann commented Mar 24, 2020

If your project is small enough you can zip it and drag and drop in a github post.

@RonanZe
Copy link
Author

RonanZe commented Mar 25, 2020

With the heightmap and all the png, it's 100Mo.
I put a temporary link that will last 30 days or more:
https://www.dropbox.com/s/hntlx1hdvqmiuiy/Terrain-Scatter-Bug.zip?dl=0

When cleaning the project, the bug seems to have evolved a little bit:
Just open the project, click on the scatter node and try to paint (and move the camera above the terrain if you don't see it).
It works when you Scatter/paint on the the Arrow Widget (?!) of the "Select Mode" but not everywhere else on the viewport.
Arrow

Note: it always print "Paint scenes" in the Output window even when it do not put a new scatter object.

I have removed the 2de scene with the 2de Terrain from the projet.
When clicking between the 2 scenes, the problem did disappeared until closing and reopen the project

@Zylann
Copy link
Owner

Zylann commented Mar 25, 2020

From what I can see so far, the collider appears to only exist within the +X+Z quadrant of the map. No hits get registered elsewhere. The hits within the collidable area are correct so it's not really offset. I'll keep investigating the cause.

@Zylann
Copy link
Owner

Zylann commented Mar 25, 2020

So this is what the raycasts "see":
image
Now I haven't the faintest idea why a whole part isn't detected, but I can say this is view-dependent.
image
image
It really feels like there is a "Bounding Box" surrounding that quadrant of the map, and raycasts going through it can reach any point of the terrain. But if they don't go through that box, they will always miss, even if the terrain is actually present in front of them.
This happens despite the collider being translated here:

trans = _terrain_transform * trans

I thought it would be a bug I introduced in Bullet when implementing raycast acceleration, but it also reproduces in Godot 3.1, so it's not that:
image
(partial preview cuz raycasts are deadly slow in this version).

Only workaround for now is to not translate the terrain...

@Zylann
Copy link
Owner

Zylann commented Mar 26, 2020

I can also confirm this does not reproduce in-game. This is really specific to the editor...

@Zylann
Copy link
Owner

Zylann commented Aug 18, 2020

The following workaround seems to work:
Go to the Terrain menu, click "Update editor collider". This forces to recreate the collider.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Waiting for Godot Godot has a bug and should be fixed first
Projects
None yet
Development

No branches or pull requests

2 participants