diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-11-25 01:29:15 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-11-25 01:29:35 -0300 |
commit | 66a8a07c2cdb49476bf2055ea405657799bdd9a8 (patch) | |
tree | b053ac63e029d433e40b14073b8805b0c5ae36a5 /editor/import | |
parent | 2c7b4c2053e36d33d19298debe611edc7b74743c (diff) |
Add importer option to make meshes bakeable by default.
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 13 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 8 |
2 files changed, 17 insertions, 4 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 63d4039295..af766128b0 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -156,12 +156,12 @@ static String _fixstr(const String &p_what, const String &p_str) { return p_what; } -Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map) { +Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode) { // children first.. for (int i = 0; i < p_node->get_child_count(); i++) { - Node *r = _fix_node(p_node->get_child(i), p_root, collision_map); + Node *r = _fix_node(p_node->get_child(i), p_root, collision_map, p_light_bake_mode); if (!r) { print_line("was erased.."); i--; //was erased @@ -205,6 +205,11 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array } } } + + if (p_light_bake_mode != LIGHT_BAKE_DISABLED) { + + mi->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + } } if (Object::cast_to<AnimationPlayer>(p_node)) { @@ -1022,6 +1027,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/light_baking", PROPERTY_HINT_ENUM, "Disabled,Enable"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); @@ -1131,10 +1137,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p float anim_optimizer_linerr = p_options["animation/optimizer/max_linear_error"]; float anim_optimizer_angerr = p_options["animation/optimizer/max_angular_error"]; float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"]; + int light_bake_mode = p_options["meshes/light_baking"]; Map<Ref<ArrayMesh>, Ref<Shape> > collision_map; - scene = _fix_node(scene, scene, collision_map); + scene = _fix_node(scene, scene, collision_map, LightBakeMode(light_bake_mode)); if (use_optimizer) { _optimize_animations(scene, anim_optimizer_linerr, anim_optimizer_angerr, anim_optimizer_maxang); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 5bf3145148..92777fafb6 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -100,6 +100,12 @@ class ResourceImporterScene : public ResourceImporter { PRESET_MAX }; + enum LightBakeMode { + LIGHT_BAKE_DISABLED, + LIGHT_BAKE_ENABLE, + //LIGHT_BAKE_LIGHTMAPS + }; + void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner); public: @@ -124,7 +130,7 @@ public: void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); - Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map); + Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode); void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all); void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep); |