aboutsummaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
authorJuan Linietsky2016-12-23 00:37:38 -0300
committerJuan Linietsky2016-12-23 00:37:38 -0300
commit4e729f38e02274afc91319d8dc9d2dfea9e9438e (patch)
tree48fa8b974220e1e1de3edf32c15906af18d98fe0 /tools/editor/plugins
parentf9603d82365823938129e68823a19739a3dd0b23 (diff)
downloadgodot-4e729f38e02274afc91319d8dc9d2dfea9e9438e.tar.gz
godot-4e729f38e02274afc91319d8dc9d2dfea9e9438e.tar.zst
godot-4e729f38e02274afc91319d8dc9d2dfea9e9438e.zip
baking now shows a proper button, and bakes can be saved.
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/gi_probe_editor_plugin.cpp58
-rw-r--r--tools/editor/plugins/gi_probe_editor_plugin.h37
2 files changed, 95 insertions, 0 deletions
diff --git a/tools/editor/plugins/gi_probe_editor_plugin.cpp b/tools/editor/plugins/gi_probe_editor_plugin.cpp
new file mode 100644
index 000000000..5beee1d91
--- /dev/null
+++ b/tools/editor/plugins/gi_probe_editor_plugin.cpp
@@ -0,0 +1,58 @@
+#include "gi_probe_editor_plugin.h"
+
+
+void GIProbeEditorPlugin::_bake() {
+
+ if (gi_probe) {
+ gi_probe->bake();
+ }
+}
+
+
+void GIProbeEditorPlugin::edit(Object *p_object) {
+
+ GIProbe * s = p_object->cast_to<GIProbe>();
+ if (!s)
+ return;
+
+ gi_probe=s;
+}
+
+bool GIProbeEditorPlugin::handles(Object *p_object) const {
+
+ return p_object->is_type("GIProbe");
+}
+
+void GIProbeEditorPlugin::make_visible(bool p_visible) {
+
+ if (p_visible) {
+ bake->show();
+ } else {
+
+ bake->hide();
+ }
+
+}
+
+void GIProbeEditorPlugin::_bind_methods() {
+
+ ObjectTypeDB::bind_method("_bake",&GIProbeEditorPlugin::_bake);
+}
+
+GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
+
+ editor=p_node;
+ bake = memnew( Button );
+ bake->set_text("Bake GI!");
+ bake->set_icon(editor->get_gui_base()->get_icon("BakedLight","EditorIcons"));
+ bake->hide();;
+ bake->connect("pressed",this,"_bake");
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU,bake);
+ gi_probe=NULL;
+}
+
+
+GIProbeEditorPlugin::~GIProbeEditorPlugin() {
+
+ memdelete(bake);
+}
diff --git a/tools/editor/plugins/gi_probe_editor_plugin.h b/tools/editor/plugins/gi_probe_editor_plugin.h
new file mode 100644
index 000000000..7db91beba
--- /dev/null
+++ b/tools/editor/plugins/gi_probe_editor_plugin.h
@@ -0,0 +1,37 @@
+#ifndef GIPROBEEDITORPLUGIN_H
+#define GIPROBEEDITORPLUGIN_H
+
+#include "tools/editor/editor_plugin.h"
+#include "tools/editor/editor_node.h"
+#include "scene/resources/material.h"
+#include "scene/3d/gi_probe.h"
+
+
+
+class GIProbeEditorPlugin : public EditorPlugin {
+
+ OBJ_TYPE( GIProbeEditorPlugin, EditorPlugin );
+
+ GIProbe *gi_probe;
+
+ Button *bake;
+ EditorNode *editor;
+
+ void _bake();
+protected:
+
+ static void _bind_methods();
+public:
+
+ virtual String get_name() const { return "GIProbe"; }
+ bool has_main_screen() const { return false; }
+ virtual void edit(Object *p_node);
+ virtual bool handles(Object *p_node) const;
+ virtual void make_visible(bool p_visible);
+
+ GIProbeEditorPlugin(EditorNode *p_node);
+ ~GIProbeEditorPlugin();
+
+};
+
+#endif // GIPROBEEDITORPLUGIN_H