Merge pull request #54049 from rxlecky/baked-lightmap-add-no-root-error-53774

This commit is contained in:
Rémi Verschelde 2021-10-21 13:51:30 +02:00 committed by GitHub
commit 2c548d5005
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View file

@ -16,7 +16,7 @@
<argument index="0" name="from_node" type="Node" default="null" />
<argument index="1" name="data_save_path" type="String" default="&quot;&quot;" />
<description>
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].
</description>
</method>
</methods>
@ -128,6 +128,10 @@
Returns if user cancels baking.
</constant>
<constant name="BAKE_ERROR_NO_LIGHTMAPPER" value="7" enum="BakeError">
Returns if lightmapper can't be created. Unless you are using a custom lightmapper, please report this as bug.
</constant>
<constant name="BAKE_ERROR_NO_ROOT" value="8" enum="BakeError">
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.
</constant>
<constant name="ENVIRONMENT_MODE_DISABLED" value="0" enum="EnvironmentMode">
No environment is used during baking.

View file

@ -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);

View file

@ -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 {