-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathllightmapper_editor_plugin.cpp
80 lines (63 loc) · 2.19 KB
/
llightmapper_editor_plugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "llightmapper_editor_plugin.h"
void LLightmapEditorPlugin::_bake() {
if (lightmap) {
lightmap->lightmap_bake();
//#ifdef TOOLS_ENABLED
// // FIXME: Hack to refresh editor in order to display new properties and signals. See if there is a better alternative.
// if (Engine::get_singleton()->is_editor_hint()) {
// EditorNode::get_singleton()->get_inspector()->update_tree();
// //NodeDock::singleton->update_lists();
// }
//#endif
}
}
void LLightmapEditorPlugin::edit(Object *p_object) {
LLightmap *s = Object::cast_to<LLightmap>(p_object);
if (!s)
return;
lightmap = s;
}
bool LLightmapEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("LLightmap");
}
void LLightmapEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
bake->show();
} else {
bake->hide();
}
}
EditorProgress *LLightmapEditorPlugin::tmp_progress = NULL;
void LLightmapEditorPlugin::bake_func_begin(int p_steps) {
ERR_FAIL_COND(tmp_progress != NULL);
tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), p_steps, true));
}
bool LLightmapEditorPlugin::bake_func_step(int p_step, const String &p_description) {
ERR_FAIL_COND_V(tmp_progress == NULL, false);
OS::get_singleton()->delay_usec(1000);
return tmp_progress->step(p_description, p_step, false);
}
void LLightmapEditorPlugin::bake_func_end() {
ERR_FAIL_COND(tmp_progress == NULL);
memdelete(tmp_progress);
tmp_progress = NULL;
}
void LLightmapEditorPlugin::_bind_methods() {
ClassDB::bind_method("_bake", &LLightmapEditorPlugin::_bake);
}
LLightmapEditorPlugin::LLightmapEditorPlugin(EditorNode *p_node) {
editor = p_node;
bake = memnew(ToolButton);
// bake->set_icon(editor->get_gui_base()->get_icon("Bake", "EditorIcons"));
bake->set_icon(editor->get_gui_base()->get_icon("LLightmapBake", "EditorIcons"));
bake->set_text(TTR("Bake Lightmap"));
bake->hide();
bake->connect("pressed", this, "_bake");
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);
lightmap = NULL;
LightMapper::bake_begin_function = bake_func_begin;
LightMapper::bake_step_function = bake_func_step;
LightMapper::bake_end_function = bake_func_end;
}
LLightmapEditorPlugin::~LLightmapEditorPlugin() {
}