codecat / godot-tbloader

TrenchBroom Loader for Godot 4. (Alternative to Qodot)
MIT License
232 stars 29 forks source link

Crash when building map when TBLoader is the scene root #22

Open MortimerMcMire opened 1 year ago

MortimerMcMire commented 1 year ago

Godot 4 alpha 12 and Godot 4 alpha 14 both crash when building the default Trenchbroom map (single untextured block). Default TBLoader node settings

codecat commented 1 year ago

Hmm the latest version worked fine for me with Alpha 14, but I will try again.

codecat commented 1 year ago

Is this on Windows? Or on Mac/Linux? And which version of TBLoader are you using?

MortimerMcMire commented 1 year ago

Windows, using 0.1.1 -I opened Alpha 14 in a brand new project -Installed 0.1.1 from the asset store -Closed and reopened Godot, then enabled TBLoader -Put a single TBLoader node in my tree and set the map to the default Trenchbroom map. (No other options were changed) -Clicked Build Meshes

The window hangs for a few seconds and then Godot crashes. Maybe there's a step in there I'm missing

codecat commented 1 year ago

I just followed the exact steps you wrote, and it works for me:

image

Can you post the exact .map file you are using? Perhaps there's some differences there.

MortimerMcMire commented 1 year ago

Sure, this is just the default cube output from TB

// Game: Godot // Format: Standard // entity 0 { "classname" "worldspawn" // brush 0 { ( -64 -64 -16 ) ( -64 -63 -16 ) ( -64 -64 -15 ) TB_empty 0 0 0 1 1 ( -64 -64 -16 ) ( -64 -64 -15 ) ( -63 -64 -16 ) __TB_empty 0 0 0 1 1 ( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) TB_empty 0 0 0 1 1 ( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) TB_empty 0 0 0 1 1 ( 64 64 16 ) ( 65 64 16 ) ( 64 64 17 ) __TB_empty 0 0 0 1 1 ( 64 64 16 ) ( 64 64 17 ) ( 64 65 16 ) TB_empty 0 0 0 1 1 } }

codecat commented 1 year ago

Yeah that's the exact same file as I have :(

Are you able to compile TBLoader manually (in debug mode) and attach a debugger?

MortimerMcMire commented 1 year ago

Exception thrown: read access violation.

was 0x8. stack trace ``` tbloader.windows.x86_64.dll!godot::internal::_call_native_mb_no_ret(void * const mb, void * instance, void * const & ) Line 67 C++ tbloader.windows.x86_64.dll!godot::Node::set_owner(godot::Node * owner) Line 243 C++ tbloader.windows.x86_64.dll!Builder::build_worldspawn(int idx, LMEntity & ent) Line 76 C++ tbloader.windows.x86_64.dll!Builder::build_entity(int idx, LMEntity & ent, const godot::String & classname) Line 121 C++ tbloader.windows.x86_64.dll!Builder::build_map() Line 64 C++ tbloader.windows.x86_64.dll!TBLoader::build_meshes() Line 153 C++ tbloader.windows.x86_64.dll!godot::call_with_variant_args_helper(TBLoader * p_instance, void(TBLoader::*)() p_method, const godot::Variant * * p_args, GDNativeCallError & r_error, IndexSequence<> __formal) Line 221 C++ tbloader.windows.x86_64.dll!godot::call_with_variant_args_dv(TBLoader * p_instance, void(TBLoader::*)() p_method, void * const * p_args, int p_argcount, GDNativeCallError & r_error, const std::vector> & default_values) Line 290 C++ tbloader.windows.x86_64.dll!godot::MethodBindT::call(void * p_instance, void * const * p_args, const __int64 p_argument_count, GDNativeCallError & r_error) Line 309 C++ tbloader.windows.x86_64.dll!godot::MethodBind::bind_call(void * p_method_userdata, void * p_instance, void * const * p_args, const __int64 p_argument_count, void * r_return, GDNativeCallError * r_error) Line 111 C++ [External Code] ``` as far as I can tell its attempting to set owner to null which godot doesn't like
MortimerMcMire commented 1 year ago

I apologize if you've been spending time on this, but I found the error. I did some detective work and studied your screenshot. You can't have TBLoader as the root node in a scene when you Build Meshes - it has to be a child of a Node3D, or you crash.

codecat commented 1 year ago

Oh, interesting! Thanks for checking this. I might be able to fix this though! So I'll re-open this issue for now.