-
-
Notifications
You must be signed in to change notification settings - Fork 156
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 data is not saved #232
Comments
There is nothing changing saving stuff in 1.5.2 so I really wonder what kind of black magic is going on Oo
You mean there is no file at all in the data directory? Was there files before? Did any errors occur? And of freaking* course, I tested it following your steps, and could not reproduce your issue :| I tried this twice:
One of the reports hinted that the resource saver was not even invoked by Godot. So far I only suspect that Godot's resource saving system might contains a Heisenbug... This system is tied to |
Ok after fiddling around with this a bit more, I can reproduce this in other versions as 1.5.2 too. Though, I cannot reproduce this reliably. It sometimes works, but sometimes doesn't. I will put some print statements into all your resource handling code and log that to a file. If I do encounter this bug again, I will share the logs. Very very weird.
In the data dir? I think no, but will need to check again once I am able to reproduce this again.
No, though I might have missed them. I may be able to report this in more detail soon since I now log everything to a file. PS: Sorry for opening yet another issue. I thought it was introduced in 1.5.2, and I saw that none of the issues created since that release mentioned this bug. So I did not search for other existing bugs. Should have used the search regardless... |
Some advice when doing that: always add them while the plugin is turned off. Or in doubt, do it when Godot is not running. It has a tendency to badly reload modified tool scripts, causing all sorts of errors. |
I had the same problem, in a new project, it worked fine in other projects so I disabled new plugins I was trying (Hungry Proton's Scatter and Jake Young's Mono debugger) and now the terrain saves correctly. |
Just for reference, for me this happened with only the heightmap plugin. So it may not be caused by other plugins. On another note: since I added some logging it did not happen again. Really really weird. |
My plugin uses a custom
Yes indeed :D I'll never say it enough but: so far the only clue I got is that sometimes, for some reason, Godot just doesn't call it (from an earlier report). And it's completely random, of course, and could never be reproduced on my end... so could not fix it so far... It could also be that the workflow I had to go for (choosing a directory path rather than forcing you to create the file yourself or embedding the resource in the scene) follows a code path Godot was largely untested for, and somehow causes such random issues. I don't know. So the only things I can do is make shots in the dark. For example here is one: Did any of you have this problem with an existing terrain? Was it always with a new one?
This is called when you choose the data directory. It creates the resource in memory and assigns the path where it will be saved. At this point the resource does not exist yet as a file, but in theory, when you save your scene, Godot is supposed to call HTerrainResourceSaver which will produce the files at the specified path. And it does! ... but not reliably, I guess.The file is not saved immediately because it's legit to open a new scene with some new terrain, mess around, and then decide you don't want that scene and close without saving. Godot doesnt force you to create a .tscn . No files will be created until you actually save.Now, back to the hypothesis: if the problem always occurs with new terrains, mayyybe you could try to add this line to force the resource to be saved immediately after the data directory is chosen? # Create new
var d := HTerrainData.new()
d.resource_path = fpath
set_data(d)
ResourceSaver.save(fpath, d) # <-- HERE I have no idea if that's supposed to work, and no idea if that will help working around the problem. But it's just a random idea. |
No, I mean that no other plugin was installed when the error occured for me. Therefore I don't think that the combination of your plugin with another plugin is the error, as for me the error occures without any other plugins installed.
For me, no. I only had this happen with new terrains.
I personally won't add it, as that would (hopefully) prevent the error from happening. I still hope to recreate this error with my logging on... so I will not try this fix for now. Thank you for the suggestion though! I will probably put it in if I can't reproduce soon. |
Hi folks! Well I was all excited to try making terrain but I am hitting this bug. It never saves for me. I tried adding:
Along with the appropriate import at the top of the file for Errors:
If yall even could figure out how to get this workaround working that would help for me. And if there's anything I can do to debug please let me know. Thanks! |
And I just double checked and I am running godot 3.2-stable, built from scratch on my Ubuntu 20.04 machine from git commit 4e7d75ccd350b98bccea517c034b367f52cf127e |
I've tried three versions of this plugin from 2020 and going back to Oct 2019 and they don't save data for me. Here is how I reproduce: I can compile godot if that helps with debugging at all. Thank you! |
Have you tried godot 3.2.3? Godot 3.2 is fairly older.
if I take instructions to the letter, so without unfocusing the editor, I do get an error, but the files did get saved. I know you didnt see files in the terminal, but I'd like clarify things: Case 1: The error happens while there are files in the directoryWhen you save a terrain (for the first time OR after editing), the plugin creates or updates a bunch of PNG files in the terrain data folder. But Godot does not automatically import or re-import these files, and there is no GDScript API allowing me to force Godot to do this. I suspect this happened to many people here. Before reporting that it did not save at all, please look outside of Godot if your terrain files are present. There is a description of this in the documentation. Because this is a very different issue, and it's difficult to track down what really happened in each report so far. Case 2: files are not present at all
Now this is the situation I was completely unable to reproduce for months (years?), and this is what the present issue is about. Even with your specific steps followed to the letter, in an existing project as well, I can only get Case 1. Exactly like this video I recorded in an older version: https://zylannprods.fr/dl/godot/godot_hterrain_trying_to_repro_issue120.mp4 One reason was due to the @tlalexander Are you able to reproduce Case 2 every single time? If you can, you may be able to debug it further than me, and it might involve debugging Godot itself. (And of course: if you plan to debug the GDScript part, close Godot before each attempt, because editing tool scripts has its own issues and could compromise reproduction tests.) |
Oops sorry, I thought I replied. It turns out 3.2.3 works fine for me. I had a lot of fun making terrain last weekend. So yes in 3.2-stable I did have Case 2 every time. The folder was named addons (lowercase). I thought I could help by debugging with modifications to the GDScript, but for some reason a search of your repo only shows "ResourceSaver" a single time, so I am not seeing where it is defined... I do see "HTerrainDataSaver" and "ResourceFormatSaver". Where is ResourceSaver defined? If there's anything I can do to debug let me know! |
Also note this project's readme says:
So if 3.2.3 is needed we could update the docs. |
This is the one. |
I am having similar issues, and have tried the "ResourceSaver.save(fpath, d) # <-- HERE" modification as well. Godot's Debugger is showing: E 0:00:00.508 _load: Resource file not found: res://Scenes/Terrain/data.hterrain. E 0:00:00.508 poll: res://Main.tscn:16 - Parse Error: [ext_resource] referenced nonexistent resource at: res://Scenes/Terrain/data.hterrain Note: The scene isnt saved AND I can not hit F5 to run the game due to this either. I am not sure what's occuring. I am in the process of comparing the setting in the demo to see if perhaps a missing setting is stopping the layer from being saved. |
I still haven't advanced at all on that issue. I've been blocked for almost a year. There are a few cases that are simple to figure out in case the issue comes from textures, but more people keep getting the issue about
What does that mean? If you didn't save the scene how come it's loading |
@CoreVamore what version is your godot? Have you tried 3.2.3? |
I was on 3.2.2, I just tried 3.2.3 with the same result. I am going to try it from an empty project and see if I get the same behavior. |
Note that if this happens while the |
Give me a sec, im reading through the usage doc's, I may have missed a step. I'll get back to you shortly.
OK, I think ive worked out the issue, though I need to retest it. Firstly, I got the plugin working on my existing project by disabling the plugin, removing the HTerrains etc related to it. Removed the "addons/zylann.hterrain" folder from within Godots FileSystem Tool, then closed Godot. Made sure there was nothing left in the addons file system using the normal linux system file browser. Then using the linux file manager copied a fresh new copy of the "zylann.hterrain" plugin folder back under the "addons" folder within the Godot project; Opened the project and then activated the plugin, added a HTerrain instance in the project, told that instance where the Data Directory was, made some changes on the height map, and hit F5 - and it worked/file created! Now, I THINK I may know what caused the original issue. I think the first time around I IMPORTED the pluggin directory, then copied across the files that didnt import manually using the linux file system tool. Im trying it again now to see if I can replicate it Hope that helps - at least there is a fix for it now ;) |
Looks like the same things I suspect again:
|
Perhaps the scene tree is loading before the plugin finishes loading and doesnt call the classes for the plugin? (Just a wild guess - I am very much a beginner in all of this) |
No I think the plugin loads before that, and the resource loader loads even before plugins. The terrain classes should work without the editor plugin as well (so even if you turn it off the node will still run). |
I ran into this issue and ended up doing a couple things that made this work, but I'm not sure why.... I preloaded the logger into both the My process was to first start with While doing this, I noticed that the icon of my |
Unfortunately there isn't much I can do about it, even with that example. It just keeps showing Godot sometimes randomly fails to use the saver and loader, and that ability may be affected by anything that touches the script, like editing it. |
Not sure if you want feedback on the godot4 branch but this issue is present there. After reloading Godot, the terrain is visually gone. The configuration is there but no data.hterrain is saved and no terrain is visually present. |
I lost motivation in fixing this... it's been so long and I just have no idea what causes it at this point. The plugin isn't doing black magic here, it modifies a resource using Godot's UndoRedo feature (granted, using a dummy function because it's so inadapted to terrain painting, but as far as Godot is concerned, a function is called to change the resource). The test scene I made in Godot 4 didn't have this problem. I just made another test scene right now, painted on it, saved, and it did save. Then I restarted Godot, reopened the scene, sculpted some more, then saved, and it did save. Sometimes it happens, sometimes it doesn't... I just need a way to reproduce this 100%, and so far nobody has found anything. |
Man I feel you. I read through all the issues and tried to reproduce a way to fix it or work around it but I haven't got it to save once haha... typical. Anyway, I feel like this is some good closure until someone can find a reproduction case. |
In my case the "Data Directory" field is never saved. So the plugin never knows were the data directory is. |
@Janders1800 any errors in the console? That looks like a different issue. |
Error: The reproduction steps are just the bare minimum.
The Data Directory field is empty and so is the data folder. |
The loader is right here: https://github.com/Zylann/godot_heightmap_plugin/blob/master/addons/zylann.hterrain/hterrain_resource_loader.gd For some reason Godot is not detecting it. That's the issue. But the problem is HOW does that issue happen. I can't force Godot to find it.
But then if that's true, how come is Godot printing Video of retrying from scratch, unedited: Something particular must be happening somewhere that's different from all of my attempts... some specific condition, timing... I'm out of ideas |
Just deleted the plugin and installed it again and now it works OK. ¯\_(ツ)_/¯ Edit: Had to nuke the project cache tho. |
This is a behavior change to attempt working around issue #232.
More reports of this in #425 I'm quite fed up of this issue so I decided to attempt a different behavior to workaround it. I added this logic: f95447d Now if you assign a new data directory, if that directory doesn't contain Note: remember Godot also has to import terrain textures when they are saved, so sometimes the terrain might not always look changed when you play the game (in particular color, normals or textures; heights dont go through import at the moment). This is different. If that happens, make sure Godot has imported the files. You can do that by just tabbing in/out of Godot. |
This seems to have fixed it for me. It used not to load the terrain every other time when I ran the scene, now it works fine. |
Describe the bug
When creating a terrain the data is not saved. Therefore it will not appear when running or exporting the game. Also, when reopening godot the terrain disappears. This happens only in 1.5.2 and not in 1.5.1
To Reproduce
Expected behavior
Terrain data should be saved.
Environment
The text was updated successfully, but these errors were encountered: