diff --git a/doc/classes/BakedLightmap.xml b/doc/classes/BakedLightmap.xml index c206b517ef6..d1605334e27 100644 --- a/doc/classes/BakedLightmap.xml +++ b/doc/classes/BakedLightmap.xml @@ -16,7 +16,7 @@ - Bakes the lightmap, scanning from the given [code]from_node[/code] root and saves the resulting [BakedLightmapData] in [code]data_save_path[/code]. If no save path is provided it will try to match the path from the current [member light_data]. + Bakes the lightmap, scanning from the given [code]from_node[/code] root and saves the resulting [BakedLightmapData] in [code]data_save_path[/code]. If no root node is provided, parent of this node will be used as root instead. If no save path is provided it will try to match the path from the current [member light_data]. @@ -128,6 +128,10 @@ Returns if user cancels baking. + Returns if lightmapper can't be created. Unless you are using a custom lightmapper, please report this as bug. + + + There is no root node to start baking from. Either provide [code]from_node[/code] argument or attach this node to a parent that should be used as root. No environment is used during baking. diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index b40385b0f90..3aa94ba5401 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -572,6 +572,10 @@ bool BakedLightmap::_lightmap_bake_step_function(float p_completion, const Strin } BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_data_save_path) { + if (!p_from_node && !get_parent()) { + return BAKE_ERROR_NO_ROOT; + } + bool no_save_path = false; if (p_data_save_path == "" && (get_light_data().is_null() || !get_light_data()->get_path().is_resource_file())) { no_save_path = true; @@ -1595,6 +1599,7 @@ void BakedLightmap::_bind_methods() { BIND_ENUM_CONSTANT(BAKE_ERROR_INVALID_MESH); BIND_ENUM_CONSTANT(BAKE_ERROR_USER_ABORTED); BIND_ENUM_CONSTANT(BAKE_ERROR_NO_LIGHTMAPPER); + BIND_ENUM_CONSTANT(BAKE_ERROR_NO_ROOT); BIND_ENUM_CONSTANT(ENVIRONMENT_MODE_DISABLED); BIND_ENUM_CONSTANT(ENVIRONMENT_MODE_SCENE); diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h index 54a85dc8eee..8ef28267b89 100644 --- a/scene/3d/baked_lightmap.h +++ b/scene/3d/baked_lightmap.h @@ -120,8 +120,8 @@ public: BAKE_ERROR_LIGHTMAP_SIZE, BAKE_ERROR_INVALID_MESH, BAKE_ERROR_USER_ABORTED, - BAKE_ERROR_NO_LIGHTMAPPER - + BAKE_ERROR_NO_LIGHTMAPPER, + BAKE_ERROR_NO_ROOT, }; enum EnvironmentMode {