godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.87k stars 21.02k forks source link

Invisible Meshlib/Tilemap Models #48790

Open Dente222 opened 3 years ago

Dente222 commented 3 years ago

Godot version: 3.3 Stable "Latest"

OS/device including version: GTX 1660 GLES3

Issue description: While working on my game I have noticed that some random tiles like floor/walls/deco were missing from my map then it has turned out that they were just invisible for some odd reasons and had to place something on them or next to them to update their visibility "Something like in Minecraft"

Example in link below https://i.imgur.com/hckWSTn.gifv

Steps to reproduce: This occurs randomly when loading project/map Idk which one exactly

Minimal reproduction project: Any project will work with it as long as its using Tilemap

Calinou commented 3 years ago

@Dente222 Please upload a minimal reproduction project to make this easier to troubleshoot.

This may be a regression related to the new BVH. Try disabling the rendering BVH in the Project Settings. Edit: Even if disabling BVH fixes the issue, please upload a project that exhibits the issue with BVH enabled anyway :slightly_smiling_face:

lawnjelly commented 3 years ago

@Dente222 Please upload a minimal reproduction project to make this easier to troubleshoot.

This may be a regression related to the new BVH. Try disabling the rendering BVH in the Project Settings.

There's a slight danger here, there have been 3 reports of a BVH bug, but no reproduction projects, so I can't fix it. If users just switch off the BVH, they may consider it 'fixed', and not bother to make a reproduction project (understandable as it takes time).

So the upshot is it has no opportunity to get fixed. What we may need to do if we don't get any reproduction projects is make some of the betas without this option available (at least in the editor), so affected users have no choice but to address it. This is fairly important as we are rolling it out to physics and to Godot 4.

Dente222 commented 3 years ago

@Dente222 Please upload a minimal reproduction project to make this easier to troubleshoot. This may be a regression related to the new BVH. Try disabling the rendering BVH in the Project Settings.

There's a slight danger here, there have been 3 reports of a BVH bug, but no reproduction projects, so I can't fix it. If users just switch off the BVH, they may consider it 'fixed', and not bother to make a reproduction project (understandable as it takes time).

So the upshot is it has no opportunity to get fixed. What we may need to do if we don't get any reproduction projects is make some of the betas without this option available (at least in the editor), so affected users have no choice but to address it. This is fairly important as we are rolling it out to physics and to Godot 4.

Will send you my project but keep in mind that its a bit big soo yeah... also as I said this is pure random wich means that it can affect different tiles in different locations

The project as is, nothing has been changed in settings: https://drive.google.com/file/d/1QZIJLC-UxkorMUcyJArBf3RN-s8dgkiB/view?usp=sharing

lawnjelly commented 3 years ago

Thank you for the project. :+1:

No luck so far though I haven't been able to reproduce yet but I'll keep trying (but have no doubt it happens for you). What platform are you using, just in case it is platform dependent (I'm on linux)?

I'm slightly suspecting these are due to the BVH being accessed on multiple threads at the same time. What I'm thinking about is making sure as many of the functions are re-entrant as possible (there is a member variable for the current tree in particular, which could be passed in arguments), and seeing what the penalty is for putting a lock on the functions. If I could reproduce it, that would be the first thing I'd try, just using something like a mutex to test. But really I don't like making changes without confirming where the problem lies.

Dente222 commented 3 years ago

Thank you for the project. 👍

No luck so far though I haven't been able to reproduce yet but I'll keep trying (but have no doubt it happens for you). What platform are you using, just in case it is platform dependent (I'm on linux)?

I'm slightly suspecting these are due to the BVH being accessed on multiple threads at the same time. What I'm thinking about is making sure as many of the functions are re-entrant as possible (there is a member variable for the current tree in particular, which could be passed in arguments), and seeing what the penalty is for putting a lock on the functions. If I could reproduce it, that would be the first thing I'd try, just using something like a mutex to test. But really I don't like making changes without confirming where the problem lies.

I'm on Windows 10 But I have noticed that it's affecting all 3D objects, not only Tilemaps

lawnjelly commented 3 years ago

I'm going to make a tentative PR to try and make the BVH a little more robust. After making the current_tree variable a function argument that is passed around instead of a member variable, I discovered one case I possibly missed when deactivating where the current_tree could have got out of sync. That could possibly be it.

Also I'm going to add an option to the BVH template to make it thread safe with a mutex or lock of some kind. If nothing else, this will enable us to quickly find identify whether problems are due to threading in future.

lawnjelly commented 3 years ago

I have now got some test builds available in the linked PR #48892. Please if anyone gets these BVH visual bugs, try out the test builds following the instructions in the PR. This will hopefully enable us to pin down the problem and fix it.