mohsenph69 / Godot-MTerrain-plugin

A GDExtension plugin which give godot the ability to produce highly optimized Terrain for Open world games
MIT License
427 stars 23 forks source link

Not working when running headless Godot #11

Closed nickpolet closed 11 months ago

nickpolet commented 11 months ago

Just added a map to a multiplayer game I'm developing, and I noticed that the terrain doesn't seem to calculate and set the heightmap for collisions when running the exported game with --headless as a server.

There don't seem to be any errors in the logs when running the server, it's just that the terrain collision seems to be completely flat. Tree/grass collisions seem to be placed on the xz coordinates, just fine, but they are also completely flat on the terrain plane.

When I run the server without --headless, the collisions seem to work perfectly.

Do you know if this is due to there not being a renderer when running as headless. I thought this might have something to do with the issue.

I don't have a minimum reproduction project to hand, but I could make one if that helps. It does require some basic multiplayer setup, but wouldn't take too long to get an MRP up and running. Let me know. I thought I'd just start a conversation on this issue to begin with.

mohsenph69 commented 11 months ago

Hello dear Nick

I never test this in --headless mode

But when the heightmap is flat it can have one problem, But I am not sure about that If Terrain does not find any heightmap data in data directory it will create an empty flat heightmap data by default, It could be that it can not find the heightmap data, so it will create the flat one

Make sure it can find the heightmap data

If you know how to code c++ in the mregion.cpp in line 65

if(heightmap==nullptr){
        String f_name = "heightmap_x"+itos(pos.x)+"_y"+itos(pos.z)+".res";
        String f_path = grid->dataDir.path_join(f_name);

This is where if the heightmap is not founded it will create a flat heightmap data, you can print something in this if statement and if this Runs it means it can not find heightmap data so it create a flat heightmap data by default

If that was not the case, try to create a minimal project I will test that and see what is the problem

One other thing, in --headless mode there is no RenderingServer is that right?

nickpolet commented 11 months ago

Hey @mohsenph69, thanks for that. I added the some debug output in the mregion.cpp file, and discovered that the data was not there. I was using Docker to spin up the servers, but had an issue the amount of files in the terrain_data directory. Found a little workaround for now.

Closing this out, as it turns out the issue is nothing to do with MTerrain.