Zylann / godot_heightmap_plugin

HeightMap terrain for Godot implemented in GDScript
Other
1.71k stars 159 forks source link

godot4.3.beta3 error #456

Open yythlj opened 1 month ago

yythlj commented 1 month ago

ERROR: Parser bug: Mismatched external parser. at: (modules/gdscript/gdscript_analyzer.cpp:909) SCRIPT ERROR: Parse Error: Cannot infer the type of "i" variable because the value doesn't have a set type. at: GDScript::reload (res://addons/zylann.hterrain/tools/brush/brush_editor.gd:158) ERROR: Failed to load script "res://addons/zylann.hterrain/tools/brush/brush_editor.gd" with error "Parse error". at: load (modules/gdscript/gdscript.cpp:2925) ERROR: Parser bug: Mismatched external parser. at: (modules/gdscript/gdscript_analyzer.cpp:909) ERROR: Parser bug: Mismatched external parser. at: (modules/gdscript/gdscript_analyzer.cpp:909) SCRIPT ERROR: Invalid call. Nonexistent function 'set_terrain_painter' in base 'HBoxContainer (brush_editor.gd)'. at: set_terrain_painter (res://addons/zylann.hterrain/tools/panel.gd:47) SCRIPT ERROR: Invalid call. Nonexistent function 'setup_dialogs' in base 'HBoxContainer (brush_editor.gd)'. at: setup_dialogs (res://addons/zylann.hterrain/tools/panel.gd:25)

occur on load

yythlj commented 1 month ago

and no error on godot4.3.beta2

Zylann commented 1 month ago

Looks like a Godot bug. It worked all the way before and I don't see anything wrong with the code. If you really want to use beta3 immediately, you could try to replace the line with this as a workaround:

    var i : int = brush.get_shape_index()
yythlj commented 1 month ago

thanks I found a nother performece problem the fps will below when I change the grass detailayer distance from 100 to 500

and I try to change the paint density to less more, I confirm the density change from full to smallest. but fps still low same if the distance is high

full density 100 distance is 60 fps full density 500 distance is 40 fps smallest density and use qua_1,100 distance is 60 fps smallest density and use qua_1,500 distance is 40 fps

it seems the distance must be low to 100 have any way to increase performce(the grass update on once is okay for me,I just want to fix the problem that, my camera see too far ,and it will show no grass at far,)

---Original--- From: @.> Date: Fri, Jul 12, 2024 10:34 AM To: @.>; Cc: @.**@.>; Subject: Re: [Zylann/godot_heightmap_plugin] godot4.3.beta3 error (Issue #456)

Looks like a Godot bug. It worked all the way before and I don't see anything wrong with the code. If you really want to use beta3 immediately, you may have to replace the line with this as a workaround: var i : int = brush.get_shape_index()

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Zylann commented 1 month ago

I found a nother performece problem

Don't post different stuff in the same issue unless they are really related. In the current case it's completely unrelated.

the fps will below when I change the grass detailayer distance from 100 to 500

I assume you mean FPS goes down? It will indeed affect FPS to increase the render distance of detail layers. But also they aren't particularly optimized unfortunately (due to how chunks are handled, not how they render). I don't expect a huge difference though, unless you have many or your computer isn't a fast one or something.

full density 100 distance is 60 fps full density 500 distance is 40 fps

On my computer in the editor if I set render distance to 500 FPS doesn't even go below 60. But to be honest, FPS does drop, so it must just be that your computer is much slower than mine (I dont even have the most powerful ones, it's like 5 years old with an AMD Ryzen 5 and nVidia 1060). Right now you would have to keep distance low, or modify the plugin to implement better grass chunk handling. The issue is what happens in the process function of hterrain_detail_layer.gd.

smallest density and use qua_1,100 distance is 60 fps smallest density and use qua_1,500 distance is 40 fps

I don't understand what qua and those distances mean.

have any way to increase performce

As I said, the chunk handling code has to be improved. It's iterating every chunk every frame to test whether they should load or unload. In C++ or C# that's usually fast, but the plugin uses GDScript so only a better algorithm can improve it. Maybe something that only updates the difference in loaded region rather than the whole region each time, something like that...

Most of the time is spent here A really quick and dirty fix would be to insert this in the code:

    for k in _chunks:
        if randf() < 0.9: # <--
            continue

This has the effect of spreading out chunk updates over multiple frames. With this hack, that part of the code goes from 4.3ms to 0.5ms, which is almost 10 times faster with seemingly no visual difference. Though a proper solution nowadays I would re-implement the process by only calculating changes instead of polling every frame.

I tested a bit further and then eventually realized that view distance 500 with density of 4 had a big impact on my FPS too, but that's on the GPU. So that may be tuned down if you want to see that far.

Zylann commented 1 month ago

Pushed 8c1b660033b41f333ebd3ea8eadfca6750cabecc, which optimizes the process function of HTerrainDetailLayer.

32kda commented 1 month ago

Hello! I've tried a fix suggested above (adding :int) but still unable to edit height map under 4.3.

Seeing messages like: Parser bug: Mismatched external parser. Parser bug: Mismatched external parser. modules/gdscript/gdscript_byte_codegen.cpp:919 - Compiler bug: unresolved assign. res://addons/zylann.hterrain/tools/brush/brush_editor.gd:133 - Invalid type in function 'set_shapes' in base 'RefCounted (brush.gd)'. The array of argument 1 (Array) does not have the same element type as the expected typed array argument. ... res://addons/zylann.hterrain/tools/brush/brush.gd:171 - Assertion failed.

Last one when trying to draw terrain Is there a way to fix this? Thanks

Zylann commented 1 month ago

I don't know, AFAIK the error still looks the same and is a bug in Godot 4.3 beta. You'll probably have to use a more stable version of Godot. The Godot issue was moved to https://github.com/godotengine/godot/issues/94654 also

MJacred commented 3 weeks ago

@yythlj, @32kda: Issue #94654 was closed and the PR is part of 4.3. So this should be fixed, please re-test