mirror of
https://github.com/godotengine/godot.git
synced 2025-01-24 03:24:32 -05:00
Clean up GI Probe baking, proper button and progress bar.
This commit is contained in:
parent
1e8c33fc62
commit
495bcd7301
4 changed files with 59 additions and 1 deletions
|
@ -60,6 +60,27 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) {
|
|||
}
|
||||
}
|
||||
|
||||
EditorProgress *GIProbeEditorPlugin::tmp_progress = NULL;
|
||||
|
||||
void GIProbeEditorPlugin::bake_func_begin(int p_steps) {
|
||||
|
||||
ERR_FAIL_COND(tmp_progress != NULL);
|
||||
|
||||
tmp_progress = memnew(EditorProgress("bake_gi", TTR("Bake GI Probe"), p_steps));
|
||||
}
|
||||
|
||||
void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) {
|
||||
|
||||
ERR_FAIL_COND(tmp_progress == NULL);
|
||||
tmp_progress->step(p_description, p_step);
|
||||
}
|
||||
|
||||
void GIProbeEditorPlugin::bake_func_end() {
|
||||
ERR_FAIL_COND(tmp_progress == NULL);
|
||||
memdelete(tmp_progress);
|
||||
tmp_progress = NULL;
|
||||
}
|
||||
|
||||
void GIProbeEditorPlugin::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_bake", &GIProbeEditorPlugin::_bake);
|
||||
|
@ -70,10 +91,15 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
|
|||
editor = p_node;
|
||||
bake = memnew(Button);
|
||||
bake->set_icon(editor->get_gui_base()->get_icon("BakedLight", "EditorIcons"));
|
||||
bake->set_text(TTR("Bake GI Probe"));
|
||||
bake->hide();
|
||||
bake->connect("pressed", this, "_bake");
|
||||
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);
|
||||
gi_probe = NULL;
|
||||
|
||||
GIProbe::bake_begin_function = bake_func_begin;
|
||||
GIProbe::bake_step_function = bake_func_step;
|
||||
GIProbe::bake_end_function = bake_func_end;
|
||||
}
|
||||
|
||||
GIProbeEditorPlugin::~GIProbeEditorPlugin() {
|
||||
|
|
|
@ -44,6 +44,11 @@ class GIProbeEditorPlugin : public EditorPlugin {
|
|||
Button *bake;
|
||||
EditorNode *editor;
|
||||
|
||||
static EditorProgress *tmp_progress;
|
||||
static void bake_func_begin(int p_steps);
|
||||
static void bake_func_step(int p_step, const String &p_description);
|
||||
static void bake_func_end();
|
||||
|
||||
void _bake();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1134,6 +1134,10 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
|
|||
}
|
||||
}
|
||||
|
||||
GIProbe::BakeBeginFunc GIProbe::bake_begin_function = NULL;
|
||||
GIProbe::BakeStepFunc GIProbe::bake_step_function = NULL;
|
||||
GIProbe::BakeEndFunc GIProbe::bake_end_function = NULL;
|
||||
|
||||
void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
|
||||
|
||||
Baker baker;
|
||||
|
@ -1177,14 +1181,25 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
|
|||
|
||||
_find_meshes(p_from_node ? p_from_node : get_parent(), &baker);
|
||||
|
||||
if (bake_begin_function) {
|
||||
bake_begin_function(baker.mesh_list.size() + 1);
|
||||
}
|
||||
|
||||
int pmc = 0;
|
||||
|
||||
for (List<Baker::PlotMesh>::Element *E = baker.mesh_list.front(); E; E = E->next()) {
|
||||
|
||||
print_line("plotting mesh " + itos(pmc++) + "/" + itos(baker.mesh_list.size()));
|
||||
if (bake_step_function) {
|
||||
bake_step_function(pmc, RTR("Plotting Meshes") + " " + itos(pmc) + "/" + itos(baker.mesh_list.size()));
|
||||
}
|
||||
|
||||
pmc++;
|
||||
|
||||
_plot_mesh(E->get().local_xform, E->get().mesh, &baker, E->get().instance_materials, E->get().override_material);
|
||||
}
|
||||
if (bake_step_function) {
|
||||
bake_step_function(pmc++, RTR("Finishing Plot"));
|
||||
}
|
||||
|
||||
_fixup_plot(0, 0, 0, 0, 0, &baker);
|
||||
|
||||
|
@ -1282,6 +1297,10 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
|
|||
|
||||
set_probe_data(probe_data);
|
||||
}
|
||||
|
||||
if (bake_end_function) {
|
||||
bake_end_function();
|
||||
}
|
||||
}
|
||||
|
||||
void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) {
|
||||
|
|
|
@ -95,6 +95,10 @@ public:
|
|||
|
||||
};
|
||||
|
||||
typedef void (*BakeBeginFunc)(int);
|
||||
typedef void (*BakeStepFunc)(int, const String &);
|
||||
typedef void (*BakeEndFunc)();
|
||||
|
||||
private:
|
||||
//stuff used for bake
|
||||
struct Baker {
|
||||
|
@ -190,6 +194,10 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static BakeBeginFunc bake_begin_function;
|
||||
static BakeStepFunc bake_step_function;
|
||||
static BakeEndFunc bake_end_function;
|
||||
|
||||
void set_probe_data(const Ref<GIProbeData> &p_data);
|
||||
Ref<GIProbeData> get_probe_data() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue