-
Notifications
You must be signed in to change notification settings - Fork 137
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
terrain.get_intersection() returns wrong result first but then correct result on second try #511
Comments
Hi, I saw my issue mentioned and decided to do a test. If I do the second click (on the same location), the intersection indeed becomes accurate. so I can confirm that it is (probably) the same bug |
The GPU mouse reads from a viewport. It's probable the viewport isn't updated by the renderer soon enough before it's read. |
Is there something that should be done from our end to rectify that? My apologies if that's an obvious or superfluous question. |
You could intentionally read it twice, or try |
Thanks for the detailed report and project.
@MilesRomanum Does this also fix the near horizontal camera issue? I have no issue in ell1e's demo using a near horizontal camera and this workaround. As noted before the issue is get_intersection() tells the renderingserver to draw a frame, then requests that frame. C++ can't await, so it returns an invalid picture until a subsequent call. I'm not sure how to fix that as there's no current facility Godot to draw the frame right now. We might just have to document this workaround. Maybe we could add another parameter where if enabled works as is using GPU mode. If false, it uses an iterative method. |
Fixed by #567. Either using the documented workaround for gpu mode. Or a raymarched mode without the workaround. |
hi, yeah that makes sense. Pretty sure both the await and the raymarched mode would work. for my personal use case I will probably use raymarched because it might be slightly faster, but really appreciate the work around |
Terrain3D version
v0.9.2
System information
Godot Engine v4.3.stable.flathub [77dcf97d8]
Is the issue reproducable in the demo?
No
Issue description
(Note: I saw #498 but since in our test project the position is only wrong for the first ray and not for the second one, it's probably a different issue. But sorry if this is a duplicate)
We are seeing weird issues with terrain.get_intersection(), where it first returns an invalid ray that is too long as if the terrain wasn't properly detected, but then the second attempt is correct again. We couldn't quite figure out what the problem was, so we made an isolated test project where the error can be seen.
The test project is here: https://github.com/alf632/terrain3dglitch
Steps to reproduce:
git clone https://github.com/alf632/terrain3dglitch
(The project itself also has a README with the reproduction steps)
We narrowed this down to the Terrain3D extension by outputting the coordinates that we get in
source/match/maps/3Dmap/3Dmap.gd
in line 20: https://github.com/alf632/terrain3dglitch/blob/main/source/match/maps/3Dmap/3Dmap.gd#L20We do use
terrain.set_camera()
inDemoMatch.gd
in line 10: https://github.com/alf632/terrain3dglitch/blob/main/DemoMatch.gd#L10If you set a breakpoint in 3Dmap.gd in line 20, you can check the position yourself once you click on the terrain, or just read the debug output in the "Output" tab while the test project is running to see the coordinates and that they are varying wildly, while the camera_pos and camera_dir which are used for the ray are seemingly quite consistent.
I hope this demo works well enough for you to reproduce it, I know that I fell short with that for my previous ticket. Let me know if you can reproduce the issue at all, if you do get around to looking at this. My apologies for the inconvenience, and sorry if we made an obvious mistake here.
Logs
The text was updated successfully, but these errors were encountered: