diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index fe8373b20d3..24e6be588ea 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -645,6 +645,10 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image bool srgb; + if (config.keep_original_textures && !(texture->flags&VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { + texture->images[p_cube_side]=p_image; + } + Image img = _get_gl_image_and_format(p_image, p_image.get_format(),texture->flags,format,internal_format,type,compressed,srgb); if (config.shrink_textures_x2 && (p_image.has_mipmaps() || !p_image.is_compressed()) && !(texture->flags&VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { @@ -822,6 +826,9 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c ERR_FAIL_COND_V(texture->data_size==0,Image()); ERR_FAIL_COND_V(texture->render_target,Image()); + if (!texture->images[p_cube_side].empty()) + return texture->images[p_cube_side]; + #ifdef GLES_OVER_GL DVector data; @@ -871,6 +878,7 @@ Image RasterizerStorageGLES3::texture_get_data(RID p_texture,VS::CubeMapSide p_c #else ERR_EXPLAIN("Sorry, It's not posible to obtain images back in OpenGL ES"); + return Image(); #endif } @@ -1047,6 +1055,11 @@ void RasterizerStorageGLES3::texture_set_shrink_all_x2_on_set_data(bool p_enable config.shrink_textures_x2=p_enable; } +void RasterizerStorageGLES3::textures_keep_original(bool p_enable) { + + config.keep_original_textures=p_enable; +} + RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_resolution) const { Texture * texture = texture_owner.get(p_source); @@ -4690,9 +4703,6 @@ RID RasterizerStorageGLES3::gi_probe_create() { GIProbe *gip = memnew( GIProbe ); - gip->data_width=0; - gip->data_height=0; - gip->data_depth=0; gip->bounds=AABB(Vector3(),Vector3(1,1,1)); gip->dynamic_range=1.0; gip->energy=1.0; @@ -4827,64 +4837,6 @@ float RasterizerStorageGLES3::gi_probe_get_energy(RID p_probe) const{ } -void RasterizerStorageGLES3::gi_probe_set_static_data(RID p_gi_probe,const DVector& p_data,VS::GIProbeDataFormat p_format,int p_width,int p_height,int p_depth) { - - GIProbe *gip = gi_probe_owner.getornull(p_gi_probe); - ERR_FAIL_COND(!gip); - - if (gip->data.is_valid()) { - free(gip->data); - } - - gip->data=RID(); - //this is platform dependent - - gip->version++; - gip->instance_change_notify(); - -} -DVector RasterizerStorageGLES3::gi_probe_get_static_data(RID p_gi_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_gi_probe); - ERR_FAIL_COND_V(!gip,DVector()); - - //platform dependent - return DVector(); -} -VS::GIProbeDataFormat RasterizerStorageGLES3::gi_probe_get_static_data_format(RID p_gi_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_gi_probe); - ERR_FAIL_COND_V(!gip,VS::GI_PROBE_DATA_RGBA8); - - return gip->data_format; -} -int RasterizerStorageGLES3::gi_probe_get_static_data_width(RID p_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,0); - - return gip->data_width; -} -int RasterizerStorageGLES3::gi_probe_get_static_data_height(RID p_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,0); - return gip->data_height; -} -int RasterizerStorageGLES3::gi_probe_get_static_data_depth(RID p_probe) const { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,0); - return gip->data_depth; -} - -RID RasterizerStorageGLES3::gi_probe_get_data(RID p_probe) { - - const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip,RID()); - - return gip->data; -} uint32_t RasterizerStorageGLES3::gi_probe_get_version(RID p_probe) { @@ -5892,9 +5844,6 @@ bool RasterizerStorageGLES3::free(RID p_rid){ // delete the texture GIProbe *gi_probe = gi_probe_owner.get(p_rid); - if (gi_probe->data.is_valid()) { - free(gi_probe->data); - } gi_probe_owner.free(p_rid); memdelete(gi_probe); @@ -6119,6 +6068,7 @@ void RasterizerStorageGLES3::initialize() { glEnable(_EXT_TEXTURE_CUBE_MAP_SEAMLESS); frame.count=0; + config.keep_original_textures=false; } void RasterizerStorageGLES3::finalize() { diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index c51cd8d90ba..5a8246f030e 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -56,6 +56,8 @@ public: int max_texture_size; Set extensions; + + bool keep_original_textures; } config; mutable struct Shaders { @@ -221,6 +223,8 @@ public: RenderTarget *render_target; + Image images[6]; + Texture() { using_srgb=false; @@ -272,6 +276,8 @@ public: virtual RID texture_create_radiance_cubemap(RID p_source,int p_resolution=-1) const; + virtual void textures_keep_original(bool p_enable); + /* SKYBOX API */ struct SkyBox : public RID_Data { @@ -898,12 +904,6 @@ public: DVector dynamic_data; - RID data; - int data_width; - int data_height; - int data_depth; - VS::GIProbeDataFormat data_format; - }; @@ -932,14 +932,6 @@ public: virtual void gi_probe_set_interior(RID p_probe,bool p_enable); virtual bool gi_probe_is_interior(RID p_probe) const; - virtual void gi_probe_set_static_data(RID p_gi_probe,const DVector& p_data,VS::GIProbeDataFormat p_format,int p_width,int p_height,int p_depth); - virtual DVector gi_probe_get_static_data(RID p_gi_probe) const; - virtual VS::GIProbeDataFormat gi_probe_get_static_data_format(RID p_gi_probe) const; - virtual int gi_probe_get_static_data_width(RID p_probe) const; - virtual int gi_probe_get_static_data_height(RID p_probe) const; - virtual int gi_probe_get_static_data_depth(RID p_probe) const; - - virtual RID gi_probe_get_data(RID p_probe); //get data in case this is static virtual uint32_t gi_probe_get_version(RID p_probe); struct GIProbeData : public RID_Data { diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 93d3e51a8e3..24ed12027ea 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -1,12 +1,6 @@ #include "gi_probe.h" #include "mesh_instance.h" -enum DataFormat { - DATA_RGBA8, - DATA_DXT5, - DATA_ETC2_EAC, -}; - void GIProbeData::set_bounds(const AABB& p_bounds) { @@ -87,42 +81,47 @@ int GIProbeData::get_dynamic_range() const{ return VS::get_singleton()->gi_probe_get_dynamic_range(probe); } -void GIProbeData::set_static_data(const DVector& p_data,DataFormat p_format,int p_width,int p_height,int p_depth){ - - VS::get_singleton()->gi_probe_set_static_data(probe,p_data,VS::GIProbeDataFormat(p_format),p_width,p_height,p_depth); - -} -DVector GIProbeData::get_static_data() const{ - - return VS::get_singleton()->gi_probe_get_static_data(probe); - -} -GIProbeData::DataFormat GIProbeData::get_static_data_format() const{ - - return GIProbeData::DataFormat(VS::get_singleton()->gi_probe_get_static_data_format(probe)); - -} -int GIProbeData::get_static_data_width() const{ - - return VS::get_singleton()->gi_probe_get_static_data_width(probe); - -} -int GIProbeData::get_static_data_height() const{ - - return VS::get_singleton()->gi_probe_get_static_data_height(probe); - -} -int GIProbeData::get_static_data_depth() const{ - - return VS::get_singleton()->gi_probe_get_static_data_depth(probe); - -} RID GIProbeData::get_rid() const { return probe; } + +void GIProbeData::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("set_bounds","bounds"),&GIProbeData::set_bounds); + ObjectTypeDB::bind_method(_MD("get_bounds"),&GIProbeData::get_bounds); + + ObjectTypeDB::bind_method(_MD("set_cell_size","cell_size"),&GIProbeData::set_cell_size); + ObjectTypeDB::bind_method(_MD("get_cell_size"),&GIProbeData::get_cell_size); + + ObjectTypeDB::bind_method(_MD("set_to_cell_xform","to_cell_xform"),&GIProbeData::set_to_cell_xform); + ObjectTypeDB::bind_method(_MD("get_to_cell_xform"),&GIProbeData::get_to_cell_xform); + + ObjectTypeDB::bind_method(_MD("set_dynamic_data","dynamic_data"),&GIProbeData::set_dynamic_data); + ObjectTypeDB::bind_method(_MD("get_dynamic_data"),&GIProbeData::get_dynamic_data); + + ObjectTypeDB::bind_method(_MD("set_dynamic_range","dynamic_range"),&GIProbeData::set_dynamic_range); + ObjectTypeDB::bind_method(_MD("get_dynamic_range"),&GIProbeData::get_dynamic_range); + + ObjectTypeDB::bind_method(_MD("set_energy","energy"),&GIProbeData::set_energy); + ObjectTypeDB::bind_method(_MD("get_energy"),&GIProbeData::get_energy); + + ObjectTypeDB::bind_method(_MD("set_interior","interior"),&GIProbeData::set_interior); + ObjectTypeDB::bind_method(_MD("is_interior"),&GIProbeData::is_interior); + + ADD_PROPERTY(PropertyInfo(Variant::_AABB,"bounds",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_bounds"),_SCS("get_bounds")); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"cell_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_cell_size"),_SCS("get_cell_size")); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM,"to_cell_xform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_to_cell_xform"),_SCS("get_to_cell_xform")); + + ADD_PROPERTY(PropertyInfo(Variant::INT_ARRAY,"dynamic_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_data"),_SCS("get_dynamic_data")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_range"),_SCS("get_dynamic_range")); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_energy"),_SCS("get_energy")); + ADD_PROPERTY(PropertyInfo(Variant::BOOL,"interior",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_interior"),_SCS("is_interior")); + +} + GIProbeData::GIProbeData() { probe=VS::get_singleton()->gi_probe_create(); diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 297672198cb..aea01b5367c 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -10,13 +10,11 @@ class GIProbeData : public Resource { RID probe; +protected: + + static void _bind_methods(); public: - enum DataFormat { - DATA_RGBA8, - DATA_DXT5, - DATA_ETC2_EAC, - }; void set_bounds(const AABB& p_bounds); @@ -40,20 +38,13 @@ public: void set_interior(bool p_enable); bool is_interior() const; - void set_static_data(const DVector& p_data,DataFormat p_format,int p_width,int p_height,int p_depth); - DVector get_static_data() const; - DataFormat get_static_data_format() const; - int get_static_data_width() const; - int get_static_data_height() const; - int get_static_data_depth() const; - virtual RID get_rid() const; GIProbeData(); ~GIProbeData(); }; -VARIANT_ENUM_CAST(GIProbeData::DataFormat); + class GIProbe : public VisualInstance { OBJ_TYPE(GIProbe,VisualInstance); diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index f22b7e04f65..725a3259090 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -193,6 +193,9 @@ public: virtual RID texture_create_radiance_cubemap(RID p_source,int p_resolution=-1) const=0; + + virtual void textures_keep_original(bool p_enable)=0; + /* SKYBOX API */ virtual RID skybox_create()=0; @@ -427,14 +430,6 @@ public: virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0; virtual bool gi_probe_is_interior(RID p_probe) const=0; - virtual void gi_probe_set_static_data(RID p_gi_probe,const DVector& p_data,VS::GIProbeDataFormat p_format,int p_width,int p_height,int p_depth)=0; - virtual DVector gi_probe_get_static_data(RID p_gi_probe) const=0; - virtual VS::GIProbeDataFormat gi_probe_get_static_data_format(RID p_gi_probe) const=0; - virtual int gi_probe_get_static_data_width(RID p_probe) const=0; - virtual int gi_probe_get_static_data_height(RID p_probe) const=0; - virtual int gi_probe_get_static_data_depth(RID p_probe) const=0; - - virtual RID gi_probe_get_data(RID p_probe)=0; //get data in case this is static virtual uint32_t gi_probe_get_version(RID p_probe)=0; virtual RID gi_probe_dynamic_data_create(int p_width,int p_height,int p_depth)=0; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 9dec587d1ed..fcfaf52e0b3 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -629,6 +629,8 @@ public: BIND1(texture_set_shrink_all_x2_on_set_data,bool) BIND1(texture_debug_usage,List*) + BIND1(textures_keep_original,bool) + /* SKYBOX API */ BIND0R(RID,skybox_create) @@ -828,12 +830,6 @@ public: BIND2(gi_probe_set_dynamic_data,RID,const DVector& ) BIND1RC( DVector,gi_probe_get_dynamic_data,RID) - BIND6(gi_probe_set_static_data,RID,const DVector&,GIProbeDataFormat,int,int,int) - BIND1RC(DVector,gi_probe_get_static_data,RID) - BIND1RC(GIProbeDataFormat,gi_probe_get_static_data_format,RID) - BIND1RC(int,gi_probe_get_static_data_width,RID) - BIND1RC(int,gi_probe_get_static_data_height,RID) - BIND1RC(int,gi_probe_get_static_data_depth,RID) #undef BINDBASE diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index d74f5265e46..a7876d08156 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2390,79 +2390,69 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { probe->dynamic.light_data=VSG::storage->gi_probe_get_dynamic_data(p_instance->base); - if (probe->dynamic.light_data.size()) { - //using dynamic data - DVector::Read r=probe->dynamic.light_data.read(); + if (probe->dynamic.light_data.size()==0) + return; + //using dynamic data + DVector::Read r=probe->dynamic.light_data.read(); - const GIProbeDataHeader *header = (GIProbeDataHeader *)r.ptr(); + const GIProbeDataHeader *header = (GIProbeDataHeader *)r.ptr(); - probe->dynamic.local_data.resize(header->cell_count); + probe->dynamic.local_data.resize(header->cell_count); - DVector::Write ldw = probe->dynamic.local_data.write(); + DVector::Write ldw = probe->dynamic.local_data.write(); - const GIProbeDataCell *cells = (GIProbeDataCell*)&r[16]; + const GIProbeDataCell *cells = (GIProbeDataCell*)&r[16]; - probe->dynamic.level_cell_lists.resize(header->cell_subdiv); + probe->dynamic.level_cell_lists.resize(header->cell_subdiv); - _gi_probe_fill_local_data(0,0,0,0,0,cells,header,ldw.ptr(),probe->dynamic.level_cell_lists.ptr()); + _gi_probe_fill_local_data(0,0,0,0,0,cells,header,ldw.ptr(),probe->dynamic.level_cell_lists.ptr()); - probe->dynamic.probe_data=VSG::storage->gi_probe_dynamic_data_create(header->width,header->height,header->depth); + probe->dynamic.probe_data=VSG::storage->gi_probe_dynamic_data_create(header->width,header->height,header->depth); - probe->dynamic.bake_dynamic_range=VSG::storage->gi_probe_get_dynamic_range(p_instance->base); + probe->dynamic.bake_dynamic_range=VSG::storage->gi_probe_get_dynamic_range(p_instance->base); - probe->dynamic.mipmaps_3d.clear(); + probe->dynamic.mipmaps_3d.clear(); - probe->dynamic.grid_size[0]=header->width; - probe->dynamic.grid_size[1]=header->height; - probe->dynamic.grid_size[2]=header->depth; + probe->dynamic.grid_size[0]=header->width; + probe->dynamic.grid_size[1]=header->height; + probe->dynamic.grid_size[2]=header->depth; - for(int i=0;i<(int)header->cell_subdiv;i++) { + for(int i=0;i<(int)header->cell_subdiv;i++) { - uint32_t x = header->width >> i; - uint32_t y = header->height >> i; - uint32_t z = header->depth >> i; + uint32_t x = header->width >> i; + uint32_t y = header->height >> i; + uint32_t z = header->depth >> i; - //create and clear mipmap - DVector mipmap; - mipmap.resize(x*y*z*4); - DVector::Write w = mipmap.write(); - zeromem(w.ptr(),x*y*z*4); - w = DVector::Write(); + //create and clear mipmap + DVector mipmap; + mipmap.resize(x*y*z*4); + DVector::Write w = mipmap.write(); + zeromem(w.ptr(),x*y*z*4); + w = DVector::Write(); - probe->dynamic.mipmaps_3d.push_back(mipmap); + probe->dynamic.mipmaps_3d.push_back(mipmap); - if (x<=1 || y<=1 || z<=1) - break; - } - - probe->dynamic.updating_stage=GI_UPDATE_STAGE_CHECK; - probe->invalid=false; - probe->dynamic.enabled=true; - - Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base); - AABB bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); - float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base); - - probe->dynamic.light_to_cell_xform=cell_to_xform * p_instance->transform.affine_inverse(); - - VSG::scene_render->gi_probe_instance_set_light_data(probe->probe_instance,p_instance->base,probe->dynamic.probe_data); - VSG::scene_render->gi_probe_instance_set_transform_to_data(probe->probe_instance,probe->dynamic.light_to_cell_xform); - - - - VSG::scene_render->gi_probe_instance_set_bounds(probe->probe_instance,bounds.size/cell_size); - - - } else { - RID data = VSG::storage->gi_probe_get_data(p_instance->base); - - probe->dynamic.enabled=false; - probe->invalid=!data.is_valid(); - if (data.is_valid()) { - VSG::scene_render->gi_probe_instance_set_light_data(probe->probe_instance,p_instance->base,data); - } + if (x<=1 || y<=1 || z<=1) + break; } + probe->dynamic.updating_stage=GI_UPDATE_STAGE_CHECK; + probe->invalid=false; + probe->dynamic.enabled=true; + + Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base); + AABB bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); + float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base); + + probe->dynamic.light_to_cell_xform=cell_to_xform * p_instance->transform.affine_inverse(); + + VSG::scene_render->gi_probe_instance_set_light_data(probe->probe_instance,p_instance->base,probe->dynamic.probe_data); + VSG::scene_render->gi_probe_instance_set_transform_to_data(probe->probe_instance,probe->dynamic.light_to_cell_xform); + + + + VSG::scene_render->gi_probe_instance_set_bounds(probe->probe_instance,bounds.size/cell_size); + probe->base_version=VSG::storage->gi_probe_get_version(p_instance->base); } diff --git a/servers/visual_server.h b/servers/visual_server.h index 20fe8e7d765..ef7cbc03af6 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -139,6 +139,8 @@ public: virtual void texture_debug_usage(List *r_info)=0; + virtual void textures_keep_original(bool p_enable)=0; + /* SKYBOX API */ virtual RID skybox_create()=0; @@ -470,20 +472,6 @@ public: virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0; virtual bool gi_probe_is_interior(RID p_probe) const=0; - enum GIProbeDataFormat { - GI_PROBE_DATA_RGBA8, - GI_PROBE_DATA_DXT5, - GI_PROBE_DATA_ETC2_EAC, - }; - - virtual void gi_probe_set_static_data(RID p_gi_probe,const DVector& p_data,GIProbeDataFormat p_format,int p_width,int p_height,int p_depth)=0; - virtual DVector gi_probe_get_static_data(RID p_gi_probe) const=0; - virtual GIProbeDataFormat gi_probe_get_static_data_format(RID p_gi_probe) const=0; - virtual int gi_probe_get_static_data_width(RID p_probe) const=0; - virtual int gi_probe_get_static_data_height(RID p_probe) const=0; - virtual int gi_probe_get_static_data_depth(RID p_probe) const=0; - - /* CAMERA API */ diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 99c2b468fa9..8ec10756c8f 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -99,6 +99,7 @@ #include "plugins/light_occluder_2d_editor_plugin.h" #include "plugins/color_ramp_editor_plugin.h" #include "plugins/collision_shape_2d_editor_plugin.h" +#include "plugins/gi_probe_editor_plugin.h" #include "main/input_default.h" // end #include "tools/editor/io_plugins/editor_texture_import_plugin.h" @@ -5361,6 +5362,8 @@ void EditorNode::_bind_methods() { EditorNode::EditorNode() { + VisualServer::get_singleton()->textures_keep_original(true); + EditorHelp::generate_doc(); //before any editor classes are crated SceneState::set_disable_placeholders(true); editor_initialize_certificates(); //for asset sharing @@ -6567,6 +6570,7 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( SpriteFramesEditorPlugin(this) ) ); add_editor_plugin( memnew( TextureRegionEditorPlugin(this) ) ); add_editor_plugin( memnew( Particles2DEditorPlugin(this) ) ); + add_editor_plugin( memnew( GIProbeEditorPlugin(this) ) ); add_editor_plugin( memnew( Path2DEditorPlugin(this) ) ); // add_editor_plugin( memnew( PathEditorPlugin(this) ) ); //add_editor_plugin( memnew( BakedLightEditorPlugin(this) ) ); 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 00000000000..5beee1d915a --- /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(); + 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 00000000000..7db91bebaf0 --- /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