dreadpon / godot_spatial_gardener

A Godot plugin for painting plants and props on arbitrary 3D surfaces implemented in GDScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Large Amount of nodes slow to reload

rick551a opened this issue · comments

Godot version
"3.5 stable"

Plugin version
1.1.0

Platform
Win10

Issue description
I was testing this amazing plugin and filled up a scene with thousands of blades of grass.
The scene is over 20MB!
Yet, I cannot reopen it in Godot now, as it's possibly too big. It eventually loads (after 5 minutes).

Steps to Reproduce

  1. Fill up scene with thousands of nodes
  2. Save the scene
  3. CLose the scene
    4.Try to reopen

Minimal reproduction project
If applicable, please paste a link to minimal reproduction project that shows this issue in action.

commented

@rick551a

Please send the minimal reproduction project with this issue.

The size you described seems expected, but I don't see why it would take so long to load.
My demo level has around 35k-40k instances, weights around 33mb and takes 10-20 seconds to load.
And that kind of density is considered by me to be almost on the excessive end.

I made a similar scene just now. Not AS big but takes a while to even open.
It should be attached here. (testSpatialGardener.zip)

Github dislikes my brower so the file (testSpatialGardener.zip) is here:
https://ufile.io/ii2bw5xg

commented

Okay, I took a look at your project.
If you have the same setup in your actual game, then the plugin itself is not the issue here.
I opened the scene, it loaded after around 15 seconds, and then lagged hard, and the lag persisted.

However, I noticed that you have a Spawned Spatial assigned for your sole LOD Variant. This means that every one of 15 thousand instances spawns a node in your level. Godot is simply not meant to handle this amount of 3D nodes. You don't really need to assign a Spawned Spatial unless you want custom logic or physics on each of your plants/cones. Assigning a Mesh is enough. Spawned Spatial was primarily made to handle collision with rarer plants, like trees (100-500 instances for one level).

I deleted the Spawned Spatial, reopened the project and it took only around 3-5 seconds to load. AND the lag was gone.

Also, your current scene totals at around 1'000'000 triangles (64 per cone), which might have a performance impact if you want other geometry in your level like terrain, buildings and characters. Stick with simpler meshes for grass and make heavy use of LODing and KIll Distance.

If you're not familiar with these, check out my tutorials:

commented

That said, if you were to go into into 50k-100k instances you would see some saving/loading slowdown.
To reiterate: it's not the root of your problem.
But I think I know of a way to optimize level size, but it will affect/break backward compatability.

So I'll have to consider it carefully for now.

Ah yes, it is the spatials, I see.

Some thoughts:
1)Could a message appear if the scene was taking too long to load, e.g.:

"Spatials are causing a long delay. Do you wish to stop loading the spatials and just load the meshes?"

It would allow the user to open the scene quickly and delete some spatials.

2)A dream addition to this plugin would be:

When the mesh is loaded the spatial is loaded, when the mesh is killed, the spatial is killed too!
But this is probably not possible, just putting it out there!

Thank you anyway for this fine plugin

commented

If by 'when the mesh is killed, the spatial is killed too' you meant zooming away and triggering the KIll Distance Treshold - it's already a thing.

If you meant clearing the Mesh property inside LOD Variant - that's counterintuitive and souldn't happen.

I'll think about adding a message, but that seems like a bit too much handholding. It is also explicitly stressed in the tutorial, so it seems excessive

Perhaps there can be an additional counter which shows how many Spatials are spawned? That way you'll see the problem before it leads to lags. Idk.

commented

Optimized in v1.2.0