diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-01-02 21:38:20 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-01-02 21:52:26 +0100 |
commit | 3f3f5a5359973e95e94148676a9793d6f52468f3 (patch) | |
tree | 65adf17c3d3f8d3a83bec29f51142fe884e942d8 /tools | |
parent | db46a344180d4eae1455e97e22bf84c9c304be7c (diff) | |
parent | 2820b2d82b2ed747011e37c543aefc6d4d4edee9 (diff) |
Merge remote-tracking branch 'origin/gles3' into gles3-on-master
Various merge conflicts have been fixed manually and some mistakes
might have been made - time will tell :)
Diffstat (limited to 'tools')
55 files changed, 1106 insertions, 570 deletions
diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp index 5283400354..c62affe5ad 100644 --- a/tools/collada/collada.cpp +++ b/tools/collada/collada.cpp @@ -463,7 +463,7 @@ Transform Collada::_read_transform(XMLParser& parser) { if (parser.is_empty()) return Transform(); - Vector<float> array; + Vector<String> array; while(parser.read()==OK) { // TODO: check for comments inside the element // and ignore them. @@ -471,7 +471,7 @@ Transform Collada::_read_transform(XMLParser& parser) { if (parser.get_node_type() == XMLParser::NODE_TEXT) { // parse float data String str = parser.get_node_data(); - array=str.split_floats(" ",false); + array=str.split_spaces(); } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) @@ -479,7 +479,13 @@ Transform Collada::_read_transform(XMLParser& parser) { } ERR_FAIL_COND_V(array.size()!=16,Transform()); - return _read_transform_from_array(array); + Vector<float> farr; + farr.resize(16); + for(int i=0;i<16;i++) { + farr[i]=array[i].to_double(); + } + + return _read_transform_from_array(farr); } String Collada::_read_empty_draw_type(XMLParser& parser) { diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 0c24d75aec..58576a30f1 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -895,7 +895,7 @@ void FindReplaceDialog::_bind_methods() { FindReplaceDialog::FindReplaceDialog() { - set_self_opacity(0.8); + set_self_modulate(Color(1,1,1,0.8)); VBoxContainer *vb = memnew( VBoxContainer ); add_child(vb); diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp index b88c7093fc..cbe9c81984 100644 --- a/tools/editor/editor_autoload_settings.cpp +++ b/tools/editor/editor_autoload_settings.cpp @@ -399,7 +399,7 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2& p_point, Control for (int i = 0; i < max_size; i++) { Label *label = memnew( Label(autoloads[i]) ); - label->set_self_opacity(Math::lerp(1, 0, float(i)/PREVIEW_LIST_MAX_SIZE)); + label->set_self_modulate(Color(1,1,1,Math::lerp(1, 0, float(i)/PREVIEW_LIST_MAX_SIZE))); preview->add_child(label); } diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index fbcbc2dd1b..611b6a48a7 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -1710,7 +1710,7 @@ EditorHelp::EditorHelp() { search_dialog->get_ok()->set_text(TTR("Find")); search_dialog->connect("confirmed",this,"_search_cbk"); search_dialog->set_hide_on_ok(false); - search_dialog->set_self_opacity(0.8); + search_dialog->set_self_modulate(Color(1,1,1,0.8)); /*class_search = memnew( EditorHelpSearch(editor) ); diff --git a/tools/editor/editor_initialize_ssl.cpp b/tools/editor/editor_initialize_ssl.cpp index 12b08fbc88..b7f8e2aad5 100644 --- a/tools/editor/editor_initialize_ssl.cpp +++ b/tools/editor/editor_initialize_ssl.cpp @@ -35,10 +35,11 @@ void editor_initialize_certificates() { ByteArray data; - data.resize(_certs_uncompressed_size); + data.resize(_certs_uncompressed_size+1); { ByteArray::Write w = data.write(); Compression::decompress(w.ptr(),_certs_uncompressed_size,_certs_compressed,_certs_compressed_size,Compression::MODE_DEFLATE); + w[_certs_uncompressed_size]=0; //make sure it ends at zero } StreamPeerSSL::load_certs_from_memory(data); diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index 26c3893aa2..808f32073f 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -67,6 +67,10 @@ void EditorLog::_error_handler(void *p_self, const char*p_func, const char*p_fil icon = self->get_icon("ScriptError","EditorIcons"); } break; + case ERR_HANDLER_SHADER: { + + icon = self->get_icon("Shader","EditorIcons"); + } break; } diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 98aa5acd43..46e7f0a42f 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/editor_settings.h" @@ -267,16 +268,14 @@ void EditorNode::_notification(int p_what) { circle_step=0; circle_step_msec=tick; - circle_step_frame=frame+1; + circle_step_frame=frame+1; - // update the circle itself only when its enabled - if (!update_menu->get_popup()->is_item_checked(3)){ - update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); - } + // update the circle itself only when its enabled + if (!update_menu->get_popup()->is_item_checked(3)){ + update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons")); + } } - scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height"))); - editor_selection->update(); { @@ -303,7 +302,7 @@ void EditorNode::_notification(int p_what) { } if (p_what==NOTIFICATION_ENTER_TREE) { - + get_tree()->get_root()->set_disable_3d(true); //MessageQueue::get_singleton()->push_call(this,"_get_scene_metadata"); get_tree()->set_editor_hint(true); get_tree()->get_root()->set_as_audio_listener(false); @@ -910,10 +909,11 @@ void EditorNode::_save_scene_with_preview(String p_file) { _editor_select(is2d?EDITOR_2D:EDITOR_3D); - VS::get_singleton()->viewport_queue_screen_capture(viewport); + save.step(TTR("Creating Thumbnail"),2); save.step(TTR("Creating Thumbnail"),3); - Image img = VS::get_singleton()->viewport_get_screen_capture(viewport); +#if 0 + Image img = VS::get_singleton()->viewport_texture(scree_capture(viewport); int preview_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");; preview_size*=EDSCALE; int width,height; @@ -931,7 +931,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { height=img.get_height(); } - img.convert(Image::FORMAT_RGB); + img.convert(Image::FORMAT_RGB8); img.resize(width,height); String pfile = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/last_scene_preview.png"); @@ -943,7 +943,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { if (editor_data.get_edited_scene_import_metadata().is_null()) editor_data.set_edited_scene_import_metadata(Ref<ResourceImportMetadata>( memnew( ResourceImportMetadata ) ) ); editor_data.get_edited_scene_import_metadata()->set_option("thumbnail",imgdata); - +#endif //tamanio tel thumbnail if (screen!=-1) { _editor_select(screen); @@ -1246,7 +1246,7 @@ void EditorNode::_dialog_action(String p_file) { ml = Ref<MeshLibrary>( memnew( MeshLibrary )); } - MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true); +// MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true); Error err = ResourceSaver::save(p_file,ml); if (err) { @@ -5376,6 +5376,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 @@ -5676,6 +5678,7 @@ EditorNode::EditorNode() { scene_root_parent->set_custom_minimum_size(Size2(0,80)*EDSCALE); + //Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer"); //scene_root_parent->add_style_override("panel",sp); @@ -5689,6 +5692,8 @@ EditorNode::EditorNode() { scene_root = memnew( Viewport ); + scene_root->set_disable_3d(true); + //scene_root_base->add_child(scene_root); @@ -5696,7 +5701,7 @@ EditorNode::EditorNode() { VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport(),true); scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); - scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height"))); + //scene_root->set_size_override(true,Size2(Globals::get_singleton()->get("display/width"),Globals::get_singleton()->get("display/height"))); // scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) ); @@ -5709,6 +5714,7 @@ EditorNode::EditorNode() { scene_root_parent->add_child(viewport); + PanelContainer *top_region = memnew( PanelContainer ); top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button")); HBoxContainer *left_menu_hb = memnew( HBoxContainer ); @@ -6554,10 +6560,11 @@ EditorNode::EditorNode() { //more visually meaningful to have this later raise_bottom_panel_item(AnimationPlayerEditor::singleton); - add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) ); + add_editor_plugin( memnew( ShaderEditorPlugin(this) ) ); +/* add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) ); add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) ); - add_editor_plugin( memnew( ShaderEditorPlugin(this,true) ) ); - add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) ); + + add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/ add_editor_plugin( memnew( CameraEditorPlugin(this) ) ); add_editor_plugin( memnew( SampleEditorPlugin(this) ) ); add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) ); @@ -6566,31 +6573,32 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( MeshInstanceEditorPlugin(this) ) ); add_editor_plugin( memnew( AnimationTreeEditorPlugin(this) ) ); //add_editor_plugin( memnew( SamplePlayerEditorPlugin(this) ) ); - this is kind of useless at this point - add_editor_plugin( memnew( MeshLibraryEditorPlugin(this) ) ); +// add_editor_plugin( memnew( MeshLibraryEditorPlugin(this) ) ); //add_editor_plugin( memnew( StreamEditorPlugin(this) ) ); add_editor_plugin( memnew( StyleBoxEditorPlugin(this) ) ); - add_editor_plugin( memnew( ParticlesEditorPlugin(this) ) ); + //add_editor_plugin( memnew( ParticlesEditorPlugin(this) ) ); add_editor_plugin( memnew( ResourcePreloaderEditorPlugin(this) ) ); add_editor_plugin( memnew( ItemListEditorPlugin(this) ) ); //add_editor_plugin( memnew( RichTextEditorPlugin(this) ) ); - add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) ); +// add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) ); add_editor_plugin( memnew( CollisionPolygon2DEditorPlugin(this) ) ); add_editor_plugin( memnew( TileSetEditorPlugin(this) ) ); add_editor_plugin( memnew( TileMapEditorPlugin(this) ) ); 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) ) ); +// add_editor_plugin( memnew( PathEditorPlugin(this) ) ); + //add_editor_plugin( memnew( BakedLightEditorPlugin(this) ) ); add_editor_plugin( memnew( Polygon2DEditorPlugin(this) ) ); add_editor_plugin( memnew( LightOccluder2DEditorPlugin(this) ) ); add_editor_plugin( memnew( NavigationPolygonEditorPlugin(this) ) ); add_editor_plugin( memnew( ColorRampEditorPlugin(this) ) ); add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) ); add_editor_plugin( memnew( TextureEditorPlugin(this) ) ); - add_editor_plugin( memnew( MaterialEditorPlugin(this) ) ); - add_editor_plugin( memnew( MeshEditorPlugin(this) ) ); +// add_editor_plugin( memnew( MaterialEditorPlugin(this) ) ); +// add_editor_plugin( memnew( MeshEditorPlugin(this) ) ); for(int i=0;i<EditorPlugins::get_plugin_count();i++) add_editor_plugin( EditorPlugins::create(i,this) ); @@ -6599,14 +6607,14 @@ EditorNode::EditorNode() { plugin_init_callbacks[i](); } - resource_preview->add_preview_generator( Ref<EditorTexturePreviewPlugin>( memnew(EditorTexturePreviewPlugin ))); + /*resource_preview->add_preview_generator( Ref<EditorTexturePreviewPlugin>( memnew(EditorTexturePreviewPlugin ))); resource_preview->add_preview_generator( Ref<EditorPackedScenePreviewPlugin>( memnew(EditorPackedScenePreviewPlugin ))); resource_preview->add_preview_generator( Ref<EditorMaterialPreviewPlugin>( memnew(EditorMaterialPreviewPlugin ))); resource_preview->add_preview_generator( Ref<EditorScriptPreviewPlugin>( memnew(EditorScriptPreviewPlugin ))); resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin ))); resource_preview->add_preview_generator( Ref<EditorMeshPreviewPlugin>( memnew(EditorMeshPreviewPlugin ))); resource_preview->add_preview_generator( Ref<EditorBitmapPreviewPlugin>( memnew(EditorBitmapPreviewPlugin ))); - +*/ circle_step_msec=OS::get_singleton()->get_ticks_msec(); @@ -6689,6 +6697,7 @@ EditorNode::EditorNode() { load_error_dialog->set_child_rect(load_errors); gui_base->add_child(load_error_dialog); + //EditorImport::add_importer( Ref<EditorImporterCollada>( memnew(EditorImporterCollada ))); EditorFileSystem::get_singleton()->connect("sources_changed",this,"_sources_changed"); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 7d97a50f79..20a7cf4061 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -79,7 +79,7 @@ #include "fileserver/editor_file_server.h" #include "editor_resource_preview.h" - +#include "scene/gui/viewport_container.h" #include "progress_dialog.h" @@ -208,7 +208,7 @@ private: //Ref<ResourceImportMetadata> scene_import_metadata; - Control* scene_root_parent; + PanelContainer* scene_root_parent; Control *gui_base; VBoxContainer *main_vbox; diff --git a/tools/editor/editor_profiler.cpp b/tools/editor/editor_profiler.cpp index 13327f0be9..435ad78b89 100644 --- a/tools/editor/editor_profiler.cpp +++ b/tools/editor/editor_profiler.cpp @@ -338,7 +338,7 @@ void EditorProfiler::_update_plot() { wr = DVector<uint8_t>::Write(); - Image img(w,h,0,Image::FORMAT_RGBA,graph_image); + Image img(w,h,0,Image::FORMAT_RGBA8,graph_image); if (reset_texture) { diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index b20ec8d671..7b3a3b7e3f 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -267,6 +267,8 @@ void EditorResourcePreview::_thread() { memdelete(f); } + cache_valid=false; + if (cache_valid) { texture = ResourceLoader::load(cache_base+".png","ImageTexture",true); diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index af6ebd67fd..f86ae2b10d 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -63,7 +63,7 @@ def make_editor_icons_action(target, source, env): s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") - s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA8); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") s.write("\treturn texture;\n") diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 71aca8dc6f..0bf9b32b08 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -1330,7 +1330,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe if (err==OK) { for(int i=0;i<height;i++){ - color[i]=img.get_pixel(0,i*img.get_height()/height); + //color[i]=img.get_pixel(0,i*img.get_height()/height); } } else { @@ -1514,7 +1514,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe w=DVector<uint8_t>::Write(); - Image img(s.width,s.height,0,Image::FORMAT_RGBA,pixels); + Image img(s.width,s.height,0,Image::FORMAT_RGBA8,pixels); font_data_list[i]->blit=img; font_data_list[i]->blit_ofs=o; @@ -1537,7 +1537,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe res_size.y=nearest_power_of_2(res_size.y); print_line("Atlas size: "+res_size); - Image atlas(res_size.x,res_size.y,0,Image::FORMAT_RGBA); + Image atlas(res_size.x,res_size.y,0,Image::FORMAT_RGBA8); for(int i=0;i<font_data_list.size();i++) { @@ -1565,12 +1565,12 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe } } - atlas=Image(res_size.x,res_size.y,0,Image::FORMAT_RGBA,data); + atlas=Image(res_size.x,res_size.y,0,Image::FORMAT_RGBA8,data); } if (from->has_option("color/monochrome") && bool(from->get_option("color/monochrome"))) { - atlas.convert(Image::FORMAT_GRAYSCALE_ALPHA); + atlas.convert(Image::FORMAT_LA8); } diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 299b74cedc..c1830bf118 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -85,7 +85,7 @@ struct ColladaImport { Error _create_scene(Collada::Node *p_node, Spatial *p_parent); Error _create_resources(Collada::Node *p_node); Error _create_material(const String& p_material); - Error _create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes=Vector<Ref<Mesh> >()); + Error _create_mesh_surfaces(bool p_optimize, Ref<Mesh>& p_mesh, const Map<String,Collada::NodeGeometry::Material>& p_material_map, const Collada::MeshData &meshdata, const Transform& p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data, Vector<Ref<Mesh> > p_morph_meshes=Vector<Ref<Mesh> >(), bool p_for_morph=false); Error load(const String& p_path, int p_flags, bool p_force_make_tangents=false); void _fix_param_animation_tracks(); void create_animation(int p_clip,bool p_make_tracks_in_all_bones, bool p_import_value_tracks); @@ -237,8 +237,8 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { //well, it's an ambient light.. Light *l = memnew( DirectionalLight ); // l->set_color(Light::COLOR_AMBIENT,ld.color); - l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0)); - l->set_color(Light::COLOR_SPECULAR,Color(0,0,0)); +// l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0)); +// l->set_color(Light::COLOR_SPECULAR,Color(0,0,0)); node = l; } else if (ld.mode==Collada::LightData::MODE_DIRECTIONAL) { @@ -248,8 +248,8 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { //if (found_ambient) //use it here // l->set_color(Light::COLOR_AMBIENT,ambient); - l->set_color(Light::COLOR_DIFFUSE,ld.color); - l->set_color(Light::COLOR_SPECULAR,Color(1,1,1)); +// l->set_color(Light::COLOR_DIFFUSE,ld.color); +// l->set_color(Light::COLOR_SPECULAR,Color(1,1,1)); node = l; } else { @@ -259,14 +259,14 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { l=memnew( OmniLight ); else { l=memnew( SpotLight ); - l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle); - l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp); +// l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle); +// l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp); } // - l->set_color(Light::COLOR_DIFFUSE,ld.color); - l->set_color(Light::COLOR_SPECULAR,Color(1,1,1)); - l->approximate_opengl_attenuation(ld.constant_att,ld.linear_att,ld.quad_att); +// l->set_color(Light::COLOR_DIFFUSE,ld.color); +// l->set_color(Light::COLOR_SPECULAR,Color(1,1,1)); +// l->approximate_opengl_attenuation(ld.constant_att,ld.linear_att,ld.quad_att); node=l; } @@ -377,7 +377,7 @@ Error ColladaImport::_create_material(const String& p_target) { ERR_FAIL_COND_V(!collada.state.effect_map.has(src_mat.instance_effect),ERR_INVALID_PARAMETER); Collada::Effect &effect=collada.state.effect_map[src_mat.instance_effect]; - Ref<FixedMaterial> material= memnew( FixedMaterial ); + Ref<FixedSpatialMaterial> material= memnew( FixedSpatialMaterial ); if (src_mat.name!="") material->set_name(src_mat.name); @@ -394,14 +394,15 @@ Error ColladaImport::_create_material(const String& p_target) { Ref<Texture> texture = ResourceLoader::load(texfile,"Texture"); if (texture.is_valid()) { - material->set_texture(FixedMaterial::PARAM_DIFFUSE,texture); - material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,1)); + material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,texture); + material->set_albedo(Color(1,1,1,1)); +// material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } } } else { - material->set_parameter(FixedMaterial::PARAM_DIFFUSE,effect.diffuse.color); +// material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,effect.diffuse.color); } // SPECULAR @@ -413,16 +414,18 @@ Error ColladaImport::_create_material(const String& p_target) { Ref<Texture> texture = ResourceLoader::load(texfile,"Texture"); if (texture.is_valid()) { + material->set_texture(FixedSpatialMaterial::TEXTURE_SPECULAR,texture); + material->set_specular(Color(1,1,1,1)); - material->set_texture(FixedMaterial::PARAM_SPECULAR,texture); - material->set_parameter(FixedMaterial::PARAM_SPECULAR,Color(1,1,1,1)); +// material->set_texture(FixedSpatialMaterial::PARAM_SPECULAR,texture); +// material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } } } else { - material->set_parameter(FixedMaterial::PARAM_SPECULAR,effect.specular.color); +// material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,effect.specular.color); } // EMISSION @@ -435,15 +438,17 @@ Error ColladaImport::_create_material(const String& p_target) { Ref<Texture> texture = ResourceLoader::load(texfile,"Texture"); if (texture.is_valid()) { - material->set_texture(FixedMaterial::PARAM_EMISSION,texture); - material->set_parameter(FixedMaterial::PARAM_EMISSION,Color(1,1,1,1)); + material->set_texture(FixedSpatialMaterial::TEXTURE_EMISSION,texture); + material->set_emission(Color(1,1,1,1)); + +// material->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,Color(1,1,1,1)); }else { - missing_textures.push_back(texfile.get_file()); +// missing_textures.push_back(texfile.get_file()); } } } else { - material->set_parameter(FixedMaterial::PARAM_EMISSION,effect.emission.color); +// material->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,effect.emission.color); } // NORMAL @@ -455,19 +460,23 @@ Error ColladaImport::_create_material(const String& p_target) { Ref<Texture> texture = ResourceLoader::load(texfile,"Texture"); if (texture.is_valid()) { + material->set_texture(FixedSpatialMaterial::TEXTURE_NORMAL,texture); +// material->set_emission(Color(1,1,1,1)); - material->set_texture(FixedMaterial::PARAM_NORMAL,texture); + // material->set_texture(FixedSpatialMaterial::PARAM_NORMAL,texture); }else { - missing_textures.push_back(texfile.get_file()); +// missing_textures.push_back(texfile.get_file()); } } } - material->set_parameter(FixedMaterial::PARAM_SPECULAR_EXP,effect.shininess); - material->set_flag(Material::FLAG_DOUBLE_SIDED,effect.double_sided); - material->set_flag(Material::FLAG_UNSHADED,effect.unshaded); +// material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR_EXP,effect.shininess); + if (effect.double_sided) { + material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + } + material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,effect.unshaded); @@ -597,7 +606,7 @@ static void _generate_tangents_and_binormals(const DVector<int>& p_indices,const } } -Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *skin_controller, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes) { +Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *skin_controller, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes,bool p_for_morph) { bool local_xform_mirror=p_local_xform.basis.determinant() < 0; @@ -1042,7 +1051,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con { - Ref<FixedMaterial> material; + Ref<FixedSpatialMaterial> material; //find material Mesh::PrimitiveType primitive=Mesh::PRIMITIVE_TRIANGLES; @@ -1072,7 +1081,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con DVector<Color> final_color_array; DVector<Vector3> final_uv_array; DVector<Vector3> final_uv2_array; - DVector<float> final_bone_array; + DVector<int> final_bone_array; DVector<float> final_weight_array; uint32_t final_format=0; @@ -1196,7 +1205,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con tarrayw = DVector<real_t>::Write(); final_tangent_array=tarray; - } else if (final_normal_array.size() && primitive==Mesh::PRIMITIVE_TRIANGLES && final_uv_array.size() && (force_make_tangents || (material.is_valid() && material->get_texture(FixedMaterial::PARAM_NORMAL).is_valid()))){ + } else if (final_normal_array.size() && primitive==Mesh::PRIMITIVE_TRIANGLES && final_uv_array.size() && (force_make_tangents || (material.is_valid()))){ //if this uses triangles, there are uvs and the material is using a normalmap, generate tangents and binormals, because they WILL be needed //generate binormals/tangents _generate_tangents_and_binormals(index_array,final_vertex_array,final_uv_array,final_normal_array,final_tangent_array); @@ -1223,12 +1232,12 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con if (has_weights) { DVector<float> weightarray; - DVector<float> bonearray; + DVector<int> bonearray; weightarray.resize(vertex_array.size()*4); DVector<float>::Write weightarrayw = weightarray.write(); bonearray.resize(vertex_array.size()*4); - DVector<float>::Write bonearrayw = bonearray.write(); + DVector<int>::Write bonearrayw = bonearray.write(); for(int k=0;k<vlen;k++) { float sum=0; @@ -1237,7 +1246,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con if (l<vertex_array[k].weights.size()) { weightarrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=vertex_array[k].weights[l].weight; sum+=weightarrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]; - bonearrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=vertex_array[k].weights[l].bone_idx; + bonearrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=int(vertex_array[k].weights[l].bone_idx); //COLLADA_PRINT(itos(k)+": "+rtos(bonearrayw[k*VS::ARRAY_WEIGHTS_SIZE+l])+":"+rtos(weightarray[k*VS::ARRAY_WEIGHTS_SIZE+l])); } else { @@ -1254,7 +1263,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con } weightarrayw = DVector<float>::Write(); - bonearrayw = DVector<float>::Write(); + bonearrayw = DVector<int>::Write(); final_weight_array = weightarray; final_bone_array = bonearray; @@ -1461,14 +1470,20 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con // print_line("want surface "+itos(mi)+" has "+itos(p_morph_meshes[mi]->get_surface_count())); Array a = p_morph_meshes[mi]->surface_get_arrays(surface); - a[Mesh::ARRAY_BONES]=Variant(); - a[Mesh::ARRAY_WEIGHTS]=Variant(); + //add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not) + + if (final_weight_array.size()) + a[Mesh::ARRAY_WEIGHTS]=final_weight_array; + if (final_bone_array.size()) + a[Mesh::ARRAY_BONES]=final_bone_array; + a[Mesh::ARRAY_INDEX]=Variant(); //a.resize(Mesh::ARRAY_MAX); //no need for index mr.push_back(a); } - p_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d,mr); + + p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,d,mr,p_for_morph?0:Mesh::ARRAY_COMPRESS_DEFAULT); if (material.is_valid()) { p_mesh->surface_set_material(surface, material); @@ -1692,7 +1707,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) { if (collada.state.mesh_data_map.has(meshid)) { Ref<Mesh> mesh=Ref<Mesh>(memnew( Mesh )); const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid]; - Error err = _create_mesh_surfaces(false,mesh,ng->material_map,meshdata,apply_xform,bone_remap,skin,NULL); + Error err = _create_mesh_surfaces(false,mesh,ng->material_map,meshdata,apply_xform,bone_remap,skin,NULL,Vector<Ref<Mesh> >(),true); ERR_FAIL_COND_V(err,err); morphs.push_back(mesh); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index fa46128a7b..de75bd41a2 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1407,7 +1407,7 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { if (E->get().type==Variant::OBJECT || E->get().type==Variant::ARRAY || E->get().type==Variant::DICTIONARY) { - if (E->get().type==Variant::OBJECT && res->cast_to<FixedMaterial>() && (E->get().name=="textures/diffuse" || E->get().name=="textures/detail" || E->get().name=="textures/emission")) { + if (E->get().type==Variant::OBJECT && res->cast_to<FixedSpatialMaterial>() && (E->get().name=="textures/diffuse" || E->get().name=="textures/detail" || E->get().name=="textures/emission")) { Ref<ImageTexture> tex =res->get(E->get().name); if (tex.is_valid()) { @@ -1415,15 +1415,15 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag image_map.insert(tex,TEXTURE_ROLE_DIFFUSE); } - } else if (E->get().type==Variant::OBJECT && res->cast_to<FixedMaterial>() && (E->get().name=="textures/normal")) { + } else if (E->get().type==Variant::OBJECT && res->cast_to<FixedSpatialMaterial>() && (E->get().name=="textures/normal")) { Ref<ImageTexture> tex =res->get(E->get().name); if (tex.is_valid()) { image_map.insert(tex,TEXTURE_ROLE_NORMALMAP); - if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY) - res->cast_to<FixedMaterial>()->set_fixed_flag(FixedMaterial::FLAG_USE_XY_NORMALMAP,true); - } + //if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY) + // res->cast_to<FixedSpatialMaterial>()->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_XY_NORMALMAP,true); + }// } else { @@ -1529,12 +1529,12 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> Ref<Mesh> m = mi->get_mesh(); for(int i=0;i<m->get_surface_count();i++) { - Ref<FixedMaterial> fm = m->surface_get_material(i); + Ref<FixedSpatialMaterial> fm = m->surface_get_material(i); if (fm.is_valid()) { - fm->set_flag(Material::FLAG_UNSHADED,true); - fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); + // fm->set_flag(Material::FLAG_UNSHADED,true); + // fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); + // fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); + // fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true); } } } @@ -1552,23 +1552,23 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> for(int i=0;i<m->get_surface_count();i++) { - Ref<FixedMaterial> mat = m->surface_get_material(i); + Ref<FixedSpatialMaterial> mat = m->surface_get_material(i); if (!mat.is_valid()) continue; if (p_flags&SCENE_FLAG_DETECT_ALPHA && _teststr(mat->get_name(),"alpha")) { - mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); - mat->set_name(_fixstr(mat->get_name(),"alpha")); + // mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true); + // mat->set_name(_fixstr(mat->get_name(),"alpha")); } if (p_flags&SCENE_FLAG_DETECT_VCOLOR && _teststr(mat->get_name(),"vcol")) { - mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true); - mat->set_name(_fixstr(mat->get_name(),"vcol")); + //mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true); + //mat->set_name(_fixstr(mat->get_name(),"vcol")); } if (p_flags&SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS && m->surface_get_format(i)&Mesh::ARRAY_FORMAT_TEX_UV2) { - mat->set_flag(Material::FLAG_LIGHTMAP_ON_UV2,true); + //mat->set_flag(Material::FLAG_LIGHTMAP_ON_UV2,true); } } @@ -1627,23 +1627,23 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> float dist = d.to_double(); mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true); mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y,true); - mi->set_draw_range_begin(dist); - mi->set_draw_range_end(100000); + //mi->set_draw_range_begin(dist); + //mi->set_draw_range_end(100000); - mip->set_draw_range_begin(0); - mip->set_draw_range_end(dist); + //mip->set_draw_range_begin(0); + //mip->set_draw_range_end(dist); if (mi->get_mesh().is_valid()) { Ref<Mesh> m = mi->get_mesh(); for(int i=0;i<m->get_surface_count();i++) { - Ref<FixedMaterial> fm = m->surface_get_material(i); + Ref<FixedSpatialMaterial> fm = m->surface_get_material(i); if (fm.is_valid()) { - fm->set_flag(Material::FLAG_UNSHADED,true); - fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); + // fm->set_flag(Material::FLAG_UNSHADED,true); + // fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); + // fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); + // fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true); } } } @@ -1675,23 +1675,23 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> d=d.substr(1,d.length()); if (d.length() && d[0]>='0' && d[0]<='9') { float dist = d.to_double(); - mi->set_draw_range_begin(dist); - mi->set_draw_range_end(100000); + /// mi->set_draw_range_begin(dist); + // mi->set_draw_range_end(100000); - mip->set_draw_range_begin(0); - mip->set_draw_range_end(dist); + // mip->set_draw_range_begin(0); + // mip->set_draw_range_end(dist); /*if (mi->get_mesh().is_valid()) { Ref<Mesh> m = mi->get_mesh(); for(int i=0;i<m->get_surface_count();i++) { - Ref<FixedMaterial> fm = m->surface_get_material(i); + Ref<FixedSpatialMaterial> fm = m->surface_get_material(i); if (fm.is_valid()) { fm->set_flag(Material::FLAG_UNSHADED,true); fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true); - fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); + fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true); } } }*/ @@ -1707,7 +1707,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> String str=name; int layer = str.substr(str.find("lm")+3,str.length()).to_int(); - mi->set_baked_light_texture_id(layer); + //mi->set_baked_light_texture_id(layer); } if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"colonly")) { @@ -1903,8 +1903,8 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> BSP_Tree bsptree(faces); Ref<RoomBounds> area = memnew( RoomBounds ); - area->set_bounds(faces); - area->set_geometry_hint(faces); + //area->set_bounds(faces); + //area->set_geometry_hint(faces); Room * room = memnew( Room ); @@ -1932,7 +1932,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> memdelete(p_node); p_node=room; - room->compute_room_from_subtree(); + //room->compute_room_from_subtree(); } else if (p_flags&SCENE_FLAG_CREATE_PORTALS &&_teststr(name,"portal") && p_node->cast_to<MeshInstance>()) { @@ -2059,18 +2059,18 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> for(int i=0;i<mesh->get_surface_count();i++) { - Ref<FixedMaterial> fm = mesh->surface_get_material(i); + Ref<FixedSpatialMaterial> fm = mesh->surface_get_material(i); if (fm.is_valid()) { String name = fm->get_name(); - if (_teststr(name,"alpha")) { - fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); + /* if (_teststr(name,"alpha")) { + fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true); name=_fixstr(name,"alpha"); } if (_teststr(name,"vcol")) { - fm->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true); + fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true); name=_fixstr(name,"vcol"); - } + }*/ fm->set_name(name); } } diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp index 0e4f10df0f..1cb16843c5 100644 --- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp +++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp @@ -33,7 +33,7 @@ #include "scene/3d/mesh_instance.h" #include "scene/animation/animation_player.h" - +#if 0 String EditorSceneImporterFBXConv::_id(const String& p_id) const { return p_id.replace(":","_").replace("/","_"); @@ -482,29 +482,29 @@ void EditorSceneImporterFBXConv::_parse_materials(State& state) { ERR_CONTINUE(!material.has("id")); String id = _id(material["id"]); - Ref<FixedMaterial> mat = memnew( FixedMaterial ); + Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial ); if (material.has("diffuse")) { - mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,_get_color(material["diffuse"])); + mat->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,_get_color(material["diffuse"])); } if (material.has("specular")) { - mat->set_parameter(FixedMaterial::PARAM_SPECULAR,_get_color(material["specular"])); + mat->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,_get_color(material["specular"])); } if (material.has("emissive")) { - mat->set_parameter(FixedMaterial::PARAM_EMISSION,_get_color(material["emissive"])); + mat->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,_get_color(material["emissive"])); } if (material.has("shininess")) { float exp = material["shininess"]; - mat->set_parameter(FixedMaterial::PARAM_SPECULAR_EXP,exp); + mat->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR_EXP,exp); } if (material.has("opacity")) { - Color c = mat->get_parameter(FixedMaterial::PARAM_DIFFUSE); + Color c = mat->get_parameter(FixedSpatialMaterial::PARAM_DIFFUSE); c.a=material["opacity"]; - mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,c); + mat->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,c); } @@ -536,15 +536,15 @@ void EditorSceneImporterFBXConv::_parse_materials(State& state) { String type=texture["type"]; if (type=="DIFFUSE") - mat->set_texture(FixedMaterial::PARAM_DIFFUSE,tex); + mat->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,tex); else if (type=="SPECULAR") - mat->set_texture(FixedMaterial::PARAM_SPECULAR,tex); + mat->set_texture(FixedSpatialMaterial::PARAM_SPECULAR,tex); else if (type=="SHININESS") - mat->set_texture(FixedMaterial::PARAM_SPECULAR_EXP,tex); + mat->set_texture(FixedSpatialMaterial::PARAM_SPECULAR_EXP,tex); else if (type=="NORMAL") - mat->set_texture(FixedMaterial::PARAM_NORMAL,tex); + mat->set_texture(FixedSpatialMaterial::PARAM_NORMAL,tex); else if (type=="EMISSIVE") - mat->set_texture(FixedMaterial::PARAM_EMISSION,tex); + mat->set_texture(FixedSpatialMaterial::PARAM_EMISSION,tex); } } @@ -1132,3 +1132,4 @@ EditorSceneImporterFBXConv::EditorSceneImporterFBXConv() { #endif } +#endif diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.h b/tools/editor/io_plugins/editor_scene_importer_fbxconv.h index 488616a1ad..e3ed1dcafe 100644 --- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.h +++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.h @@ -32,6 +32,7 @@ #include "tools/editor/io_plugins/editor_scene_import_plugin.h" #include "scene/3d/skeleton.h" +#if 0 class EditorSceneImporterFBXConv : public EditorSceneImporter { @@ -107,3 +108,4 @@ public: }; #endif // EDITOR_SCENE_IMPORTER_FBXCONV_H +#endif diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index b862edc8ce..39ac5ecb16 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -843,33 +843,27 @@ void EditorTextureImportPlugin::compress_image(EditorExportPlatform::ImageCompre //do absolutely nothing - } break; - case EditorExportPlatform::IMAGE_COMPRESSION_INDEXED: { - - //quantize - image.quantize(); - - } break; + } break; case EditorExportPlatform::IMAGE_COMPRESSION_BC: { // for maximum compatibility, BC shall always use mipmaps and be PO2 image.resize_to_po2(); - if (image.get_mipmaps()==0) + if (!image.has_mipmaps()) image.generate_mipmaps(); - image.compress(Image::COMPRESS_BC); + image.compress(Image::COMPRESS_S3TC); /* if (has_alpha) { if (flags&IMAGE_FLAG_ALPHA_BIT) { - image.convert(Image::FORMAT_BC3); + image.convert(Image::FORMAT_DXT5); } else { - image.convert(Image::FORMAT_BC2); + image.convert(Image::FORMAT_DXT3); } } else { - image.convert(Image::FORMAT_BC1); + image.convert(Image::FORMAT_DXT1); }*/ @@ -880,24 +874,24 @@ void EditorTextureImportPlugin::compress_image(EditorExportPlatform::ImageCompre // for maximum compatibility (hi apple!), PVRT shall always // use mipmaps, be PO2 and square - if (image.get_mipmaps()==0) + if (!image.has_mipmaps()) image.generate_mipmaps(); image.resize_to_po2(true); if (p_smaller) { image.compress(Image::COMPRESS_PVRTC2); - //image.convert(has_alpha ? Image::FORMAT_PVRTC2_ALPHA : Image::FORMAT_PVRTC2); + //image.convert(has_alpha ? Image::FORMAT_PVRTC2A : Image::FORMAT_PVRTC2); } else { image.compress(Image::COMPRESS_PVRTC4); - //image.convert(has_alpha ? Image::FORMAT_PVRTC4_ALPHA : Image::FORMAT_PVRTC4); + //image.convert(has_alpha ? Image::FORMAT_PVRTC4A : Image::FORMAT_PVRTC4); } } break; case EditorExportPlatform::IMAGE_COMPRESSION_ETC1: { image.resize_to_po2(); //square or not? - if (image.get_mipmaps()==0) + if (!image.has_mipmaps()) image.generate_mipmaps(); if (!image.detect_alpha()) { //ETC1 is only opaque @@ -930,18 +924,18 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA) { + if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - image.convert(Image::FORMAT_RGB); + image.convert(Image::FORMAT_RGB8); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { image.fix_alpha_edges(); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_PREMULT_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { image.premultiply_alpha(); } @@ -950,7 +944,7 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur image.normalmap_to_xy(); } - //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { + //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // image.srgb_to_linear(); //} @@ -989,18 +983,18 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA) { + if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - image.convert(Image::FORMAT_RGB); + image.convert(Image::FORMAT_RGB8); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { image.fix_alpha_edges(); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_PREMULT_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { image.premultiply_alpha(); } @@ -1009,7 +1003,7 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur image.normalmap_to_xy(); } - //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { + //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // // print_line("CONVERT BECAUSE: "+itos(flags)); // image.srgb_to_linear(); @@ -1200,9 +1194,9 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc Image src = tsources[i]; if (alpha) { - src.convert(Image::FORMAT_RGBA); + src.convert(Image::FORMAT_RGBA8); } else { - src.convert(Image::FORMAT_RGB); + src.convert(Image::FORMAT_RGB8); } DVector<uint8_t> data = src.get_data(); @@ -1280,7 +1274,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc atlas_h=nearest_power_of_2(dst_size.height); } Image atlas; - atlas.create(atlas_w,atlas_h,0,alpha?Image::FORMAT_RGBA:Image::FORMAT_RGB); + atlas.create(atlas_w,atlas_h,0,alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8); atlases.resize(from->get_source_count()); @@ -1411,18 +1405,18 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA) { + if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - image.convert(Image::FORMAT_RGB); + image.convert(Image::FORMAT_RGB8); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { image.fix_alpha_edges(); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_PREMULT_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { image.premultiply_alpha(); } @@ -1431,7 +1425,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc image.normalmap_to_xy(); } - //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { + //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // image.srgb_to_linear(); //} @@ -1470,18 +1464,18 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA) { + if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - image.convert(Image::FORMAT_RGB); + image.convert(Image::FORMAT_RGB8); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { image.fix_alpha_edges(); } - if (image.get_format()==Image::FORMAT_RGBA && flags&IMAGE_FLAG_PREMULT_ALPHA) { + if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { image.premultiply_alpha(); } @@ -1490,7 +1484,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc image.normalmap_to_xy(); } - //if ((image.get_format()==Image::FORMAT_RGB || image.get_format()==Image::FORMAT_RGBA) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { + //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { // // print_line("CONVERT BECAUSE: "+itos(flags)); // image.srgb_to_linear(); diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index abb355113a..2b660c4f94 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -33,7 +33,7 @@ #include "tools/editor/editor_node.h" #include "tools/editor/editor_settings.h" - +#if 0 void baked_light_baker_add_64f(double *dst,double value); void baked_light_baker_add_64i(int64_t *dst,int64_t value); @@ -91,15 +91,15 @@ BakedLightBaker::MeshTexture* BakedLightBaker::_get_mat_tex(const Ref<Texture>& if (image.empty()) return NULL; - if (image.get_format()!=Image::FORMAT_RGBA) { + if (image.get_format()!=Image::FORMAT_RGBA8) { if (image.get_format()>Image::FORMAT_INDEXED_ALPHA) { Error err = image.decompress(); if (err) return NULL; } - if (image.get_format()!=Image::FORMAT_RGBA) - image.convert(Image::FORMAT_RGBA); + if (image.get_format()!=Image::FORMAT_RGBA8) + image.convert(Image::FORMAT_RGBA8); } if (imgtex->get_flags()&Texture::FLAG_CONVERT_TO_LINEAR) { @@ -143,18 +143,18 @@ void BakedLightBaker::_add_mesh(const Ref<Mesh>& p_mesh,const Ref<Material>& p_m MeshMaterial mm; - Ref<FixedMaterial> fm = mat; + Ref<FixedSpatialMaterial> fm = mat; if (fm.is_valid()) { //fixed route - mm.diffuse.color=fm->get_parameter(FixedMaterial::PARAM_DIFFUSE); + mm.diffuse.color=fm->get_parameter(FixedSpatialMaterial::PARAM_DIFFUSE); if (linear_color) mm.diffuse.color=mm.diffuse.color.to_linear(); - mm.diffuse.tex=_get_mat_tex(fm->get_texture(FixedMaterial::PARAM_DIFFUSE)); - mm.specular.color=fm->get_parameter(FixedMaterial::PARAM_SPECULAR); + mm.diffuse.tex=_get_mat_tex(fm->get_texture(FixedSpatialMaterial::PARAM_DIFFUSE)); + mm.specular.color=fm->get_parameter(FixedSpatialMaterial::PARAM_SPECULAR); if (linear_color) mm.specular.color=mm.specular.color.to_linear(); - mm.specular.tex=_get_mat_tex(fm->get_texture(FixedMaterial::PARAM_SPECULAR)); + mm.specular.tex=_get_mat_tex(fm->get_texture(FixedSpatialMaterial::PARAM_SPECULAR)); } else { mm.diffuse.color=Color(1,1,1,1); @@ -2619,7 +2619,7 @@ Error BakedLightBaker::transfer_to_lightmaps() { copymem(w.ptr(),baked_textures[i].data.ptr(),baked_textures[i].data.size()); } - Image img(baked_textures[i].width,baked_textures[i].height,0,Image::FORMAT_RGBA,dv); + Image img(baked_textures[i].width,baked_textures[i].height,0,Image::FORMAT_RGBA8,dv); Ref<ImageTexture> tex = memnew( ImageTexture ); tex->create_from_image(img); baked_light->set_lightmap_texture(i,tex); @@ -2720,3 +2720,4 @@ BakedLightBaker::~BakedLightBaker() { clear(); } +#endif diff --git a/tools/editor/plugins/baked_light_baker.h b/tools/editor/plugins/baked_light_baker.h index cfce1b81e4..5616183cb1 100644 --- a/tools/editor/plugins/baked_light_baker.h +++ b/tools/editor/plugins/baked_light_baker.h @@ -34,6 +34,8 @@ #include "scene/3d/mesh_instance.h" #include "os/thread.h" +#if 0 + class BakedLightBaker { public: @@ -375,3 +377,4 @@ public: }; #endif // BAKED_LIGHT_BAKER_H +#endif diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp index c8e55ca54e..0b576a2d2c 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.cpp +++ b/tools/editor/plugins/baked_light_editor_plugin.cpp @@ -33,7 +33,7 @@ #include "io/resource_saver.h" - +#if 0 void BakedLightEditor::_end_baking() { @@ -145,7 +145,7 @@ void BakedLightEditor::_notification(int p_option) { #if 1 //debug - Image img(baker->baked_octree_texture_w,baker->baked_octree_texture_h,0,Image::FORMAT_RGBA,octree_texture); + Image img(baker->baked_octree_texture_w,baker->baked_octree_texture_h,0,Image::FORMAT_RGBA8,octree_texture); Ref<ImageTexture> it = memnew( ImageTexture ); it->create_from_image(img); ResourceSaver::save("baked_octree.png",it); @@ -373,3 +373,4 @@ BakedLightEditorPlugin::~BakedLightEditorPlugin() } +#endif diff --git a/tools/editor/plugins/baked_light_editor_plugin.h b/tools/editor/plugins/baked_light_editor_plugin.h index 044cd05e87..64f3295b48 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.h +++ b/tools/editor/plugins/baked_light_editor_plugin.h @@ -40,7 +40,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ - +#if 0 class MeshInstance; @@ -116,5 +116,5 @@ public: }; #endif // MULTIMESH_EDITOR_PLUGIN_H - +#endif diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 9b910200a7..a5e388ea90 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -3334,7 +3334,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { vp_base->set_v_size_flags(SIZE_EXPAND_FILL); palette_split->add_child(vp_base); - Control *vp = memnew (Control); + ViewportContainer *vp = memnew (ViewportContainer); + vp->set_stretch(true); vp_base->add_child(vp); vp->set_area_as_parent_rect(); vp->add_child(p_editor->get_scene_root()); @@ -3688,7 +3689,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String>& files) cons Ref<ImageTexture> texture=Ref<ImageTexture> ( ResourceCache::get(path)->cast_to<ImageTexture>() ); Sprite* sprite=memnew(Sprite); sprite->set_texture(texture); - sprite->set_opacity(0.7f); + sprite->set_modulate(Color(1,1,1,0.7f)); preview->add_child(sprite); label->show(); label_desc->show(); diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index 4ba75da4a1..bdd1e325b5 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -33,6 +33,8 @@ #include "scene/3d/camera.h" #include "canvas_item_editor_plugin.h" +#if 0 + void CollisionPolygonEditor::_notification(int p_what) { switch(p_what) { @@ -568,25 +570,25 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { imgeom->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001))); - line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); line_material->set_flag(Material::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); - line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true); + line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1)); - handle_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + handle_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); handle_material->set_flag(Material::FLAG_UNSHADED, true); - handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_POINT_SIZE, true); - handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); - handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false); + handle_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_POINT_SIZE, true); + handle_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1)); + handle_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); + handle_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, false); Ref<Texture> handle=editor->get_gui_base()->get_icon("Editor3DHandle","EditorIcons"); handle_material->set_point_size(handle->get_width()); - handle_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle); + handle_material->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,handle); pointsm = memnew( MeshInstance ); imgeom->add_child(pointsm); @@ -642,3 +644,4 @@ CollisionPolygonEditorPlugin::~CollisionPolygonEditorPlugin() { } +#endif diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.h b/tools/editor/plugins/collision_polygon_editor_plugin.h index 66cf2a3f0a..43a9f0b5fc 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.h +++ b/tools/editor/plugins/collision_polygon_editor_plugin.h @@ -40,6 +40,8 @@ /** @author Juan Linietsky <reduzio@gmail.com> */ + +#if 0 class CanvasItemEditor; class CollisionPolygonEditor : public HBoxContainer { @@ -60,8 +62,8 @@ class CollisionPolygonEditor : public HBoxContainer { ToolButton *button_edit; - Ref<FixedMaterial> line_material; - Ref<FixedMaterial> handle_material; + Ref<FixedSpatialMaterial> line_material; + Ref<FixedSpatialMaterial> handle_material; EditorNode *editor; Panel *panel; @@ -117,5 +119,5 @@ public: ~CollisionPolygonEditorPlugin(); }; - +#endif #endif // COLLISION_POLYGON_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp index dcbe6f225b..c18f611a49 100644 --- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp +++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp @@ -28,6 +28,7 @@ /*************************************************************************/ #include "cube_grid_theme_editor_plugin.h" +#if 0 #include "scene/3d/mesh_instance.h" #include "scene/3d/physics_body.h" #include "scene/main/viewport.h" @@ -353,4 +354,4 @@ MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) { theme_editor->hide(); } - +#endif diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.h b/tools/editor/plugins/cube_grid_theme_editor_plugin.h index 6601983aeb..d50e3156c3 100644 --- a/tools/editor/plugins/cube_grid_theme_editor_plugin.h +++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.h @@ -32,7 +32,7 @@ #include "scene/resources/mesh_library.h" #include "tools/editor/editor_node.h" - +#if 0 class MeshLibraryEditor : public Control { OBJ_TYPE( MeshLibraryEditor, Control ); @@ -93,3 +93,4 @@ public: #endif // CUBE_GRID_THEME_EDITOR_PLUGIN_H +#endif diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index 0804b94e95..0886edb073 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -37,6 +37,7 @@ #include "scene/resources/bit_mask.h" #include "tools/editor/editor_scale.h" +#if 0 bool EditorTexturePreviewPlugin::handles(const String& p_type) const { return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture")); @@ -69,8 +70,8 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES& p_from) { if (img.is_compressed()) { if (img.decompress()!=OK) return Ref<Texture>(); - } else if (img.get_format()!=Image::FORMAT_RGB && img.get_format()!=Image::FORMAT_RGBA) { - img.convert(Image::FORMAT_RGBA); + } else if (img.get_format()!=Image::FORMAT_RGB8 && img.get_format()!=Image::FORMAT_RGBA8) { + img.convert(Image::FORMAT_RGBA8); } int width,height; @@ -138,15 +139,15 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES& p_from) { } - Image img(bm->get_size().width,bm->get_size().height,0,Image::FORMAT_GRAYSCALE,data); + Image img(bm->get_size().width,bm->get_size().height,0,Image::FORMAT_L8,data); int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); thumbnail_size*=EDSCALE; if (img.is_compressed()) { if (img.decompress()!=OK) return Ref<Texture>(); - } else if (img.get_format()!=Image::FORMAT_RGB && img.get_format()!=Image::FORMAT_RGBA) { - img.convert(Image::FORMAT_RGBA); + } else if (img.get_format()!=Image::FORMAT_RGB8 && img.get_format()!=Image::FORMAT_RGBA8) { + img.convert(Image::FORMAT_RGBA8); } int width,height; @@ -434,7 +435,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES& p_from) { int col=0; int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); thumbnail_size*=EDSCALE; - Image img(thumbnail_size,thumbnail_size,0,Image::FORMAT_RGBA); + Image img(thumbnail_size,thumbnail_size,0,Image::FORMAT_RGBA8); @@ -778,7 +779,7 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { imgdata = DVector<uint8_t>::Write(); Ref<ImageTexture> ptex = Ref<ImageTexture>( memnew( ImageTexture)); - ptex->create_from_image(Image(w,h,0,Image::FORMAT_RGB,img),0); + ptex->create_from_image(Image(w,h,0,Image::FORMAT_RGB8,img),0); return ptex; } @@ -888,6 +889,7 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { } + EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { //VS::get_singleton()->free(sphere); @@ -901,3 +903,4 @@ EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { VS::get_singleton()->free(scenario); } +#endif diff --git a/tools/editor/plugins/editor_preview_plugins.h b/tools/editor/plugins/editor_preview_plugins.h index ef484244ee..3c1689e61e 100644 --- a/tools/editor/plugins/editor_preview_plugins.h +++ b/tools/editor/plugins/editor_preview_plugins.h @@ -31,6 +31,7 @@ #include "tools/editor/editor_resource_preview.h" +#if 0 class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator { public: @@ -123,5 +124,5 @@ public: ~EditorMeshPreviewPlugin(); }; - +#endif #endif // EDITORPREVIEWPLUGINS_H 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 0000000000..4ec95eb8c6 --- /dev/null +++ b/tools/editor/plugins/gi_probe_editor_plugin.cpp @@ -0,0 +1,57 @@ +#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_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 0000000000..7db91bebaf --- /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 diff --git a/tools/editor/plugins/material_editor_plugin.cpp b/tools/editor/plugins/material_editor_plugin.cpp index 876fab0d6e..1036016194 100644 --- a/tools/editor/plugins/material_editor_plugin.cpp +++ b/tools/editor/plugins/material_editor_plugin.cpp @@ -1,6 +1,8 @@ #include "material_editor_plugin.h" #include "scene/main/viewport.h" +#if 0 + void MaterialEditor::_input_event(InputEvent p_event) { @@ -379,3 +381,4 @@ MaterialEditorPlugin::~MaterialEditorPlugin() } +#endif diff --git a/tools/editor/plugins/material_editor_plugin.h b/tools/editor/plugins/material_editor_plugin.h index 49e92493b3..68b3b3b1a7 100644 --- a/tools/editor/plugins/material_editor_plugin.h +++ b/tools/editor/plugins/material_editor_plugin.h @@ -8,7 +8,7 @@ #include "scene/3d/mesh_instance.h" #include "scene/3d/camera.h" - +#if 0 class MaterialEditor : public Control { OBJ_TYPE(MaterialEditor, Control); @@ -69,3 +69,4 @@ public: }; #endif // MATERIAL_EDITOR_PLUGIN_H +#endif diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp index bfe99004b5..6574bb8e1a 100644 --- a/tools/editor/plugins/mesh_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_editor_plugin.cpp @@ -28,6 +28,7 @@ /*************************************************************************/ #include "mesh_editor_plugin.h" +#if 0 void MeshEditor::_input_event(InputEvent p_event) { @@ -241,3 +242,4 @@ MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) { MeshEditorPlugin::~MeshEditorPlugin() { } +#endif diff --git a/tools/editor/plugins/mesh_editor_plugin.h b/tools/editor/plugins/mesh_editor_plugin.h index 5d8875e5d3..cd52c5c05c 100644 --- a/tools/editor/plugins/mesh_editor_plugin.h +++ b/tools/editor/plugins/mesh_editor_plugin.h @@ -29,6 +29,8 @@ #ifndef MESH_EDITOR_PLUGIN_H #define MESH_EDITOR_PLUGIN_H +#if 0 + #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" #include "scene/resources/material.h" @@ -93,3 +95,4 @@ public: }; #endif // MESH_EDITOR_PLUGIN_H +#endif diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index 31012f8690..c0f5f6491d 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -195,6 +195,8 @@ void MultiMeshEditor::_populate() { int instance_count=populate_amount->get_val(); + multimesh->set_transform_format(MultiMesh::TRANSFORM_3D); + multimesh->set_color_format(MultiMesh::COLOR_NONE); multimesh->set_instance_count(instance_count); float _tilt_random = populate_tilt_random->get_val(); @@ -247,10 +249,10 @@ void MultiMeshEditor::_populate() { multimesh->set_instance_transform(i,xform); - multimesh->set_instance_color(i,Color(1,1,1,1)); + } - multimesh->generate_aabb(); + node->set_multimesh(multimesh); @@ -386,6 +388,7 @@ MultiMeshEditor::MultiMeshEditor() { populate_scale_random->set_min(0); populate_scale_random->set_max(1); populate_scale_random->set_val(0); + populate_scale_random->set_step(0.01); vbc->add_margin_child(TTR("Random Scale:"),populate_scale_random); @@ -393,6 +396,7 @@ MultiMeshEditor::MultiMeshEditor() { populate_scale->set_min(0.001); populate_scale->set_max(4096); populate_scale->set_val(1); + populate_scale->set_step(0.01); vbc->add_margin_child(TTR("Scale:"),populate_scale); diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp index 0f46c7fd5c..5ba46dc802 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.cpp +++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp @@ -69,8 +69,8 @@ void Particles2DEditorPlugin::_file_selected(const String& p_file) { ERR_EXPLAIN(TTR("Error loading image:")+" "+p_file); ERR_FAIL_COND(err!=OK); - img.convert(Image::FORMAT_GRAYSCALE_ALPHA); - ERR_FAIL_COND(img.get_format()!=Image::FORMAT_GRAYSCALE_ALPHA); + img.convert(Image::FORMAT_LA8); + ERR_FAIL_COND(img.get_format()!=Image::FORMAT_LA8); Size2i s = Size2(img.get_width(),img.get_height()); ERR_FAIL_COND(s.width==0 || s.height==0); diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp index 0fe03e49b7..b17867ffd9 100644 --- a/tools/editor/plugins/particles_editor_plugin.cpp +++ b/tools/editor/plugins/particles_editor_plugin.cpp @@ -26,6 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + +#if 0 #include "particles_editor_plugin.h" #include "io/resource_loader.h" #include "servers/visual/particle_system_sw.h" @@ -456,3 +458,4 @@ ParticlesEditorPlugin::~ParticlesEditorPlugin() } +#endif diff --git a/tools/editor/plugins/particles_editor_plugin.h b/tools/editor/plugins/particles_editor_plugin.h index 9558ab5ad9..0dd759bc75 100644 --- a/tools/editor/plugins/particles_editor_plugin.h +++ b/tools/editor/plugins/particles_editor_plugin.h @@ -37,7 +37,7 @@ /** @author Juan Linietsky <reduzio@gmail.com> */ - +#if 0 class ParticlesEditor : public Control { OBJ_TYPE(ParticlesEditor, Control ); @@ -113,3 +113,4 @@ public: }; #endif // PARTICLES_EDITOR_PLUGIN_H +#endif diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp index 5317e53218..c4e88d3aa8 100644 --- a/tools/editor/plugins/path_editor_plugin.cpp +++ b/tools/editor/plugins/path_editor_plugin.cpp @@ -31,6 +31,7 @@ #include "scene/resources/curve.h" #include "os/keyboard.h" +#if 0 String PathSpatialGizmo::get_handle_name(int p_idx) const { Ref<Curve3D> c = path->get_curve(); @@ -528,16 +529,16 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { editor=p_node; singleton=this; - path_material = Ref<FixedMaterial>( memnew( FixedMaterial )); - path_material->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.5,0.5,1.0,0.8) ); - path_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); + path_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + path_material->set_parameter( FixedSpatialMaterial::PARAM_DIFFUSE,Color(0.5,0.5,1.0,0.8) ); + path_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); path_material->set_line_width(3); path_material->set_flag(Material::FLAG_DOUBLE_SIDED,true); path_material->set_flag(Material::FLAG_UNSHADED,true); - path_thin_material = Ref<FixedMaterial>( memnew( FixedMaterial )); - path_thin_material->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.5,0.5,1.0,0.4) ); - path_thin_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); + path_thin_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + path_thin_material->set_parameter( FixedSpatialMaterial::PARAM_DIFFUSE,Color(0.5,0.5,1.0,0.4) ); + path_thin_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); path_thin_material->set_line_width(1); path_thin_material->set_flag(Material::FLAG_DOUBLE_SIDED,true); path_thin_material->set_flag(Material::FLAG_UNSHADED,true); @@ -599,3 +600,4 @@ PathEditorPlugin::~PathEditorPlugin() { } +#endif diff --git a/tools/editor/plugins/path_editor_plugin.h b/tools/editor/plugins/path_editor_plugin.h index cfe8159108..55920516a2 100644 --- a/tools/editor/plugins/path_editor_plugin.h +++ b/tools/editor/plugins/path_editor_plugin.h @@ -32,6 +32,7 @@ #include "tools/editor/spatial_editor_gizmos.h" #include "scene/3d/path.h" +# if 0 class PathSpatialGizmo : public EditorSpatialGizmo { OBJ_TYPE(PathSpatialGizmo,EditorSpatialGizmo); @@ -78,8 +79,8 @@ public: Path *get_edited_path() { return path; } static PathEditorPlugin* singleton; - Ref<FixedMaterial> path_material; - Ref<FixedMaterial> path_thin_material; + Ref<FixedSpatialMaterial> path_material; + Ref<FixedSpatialMaterial> path_thin_material; virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event); // virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } @@ -95,5 +96,5 @@ public: }; - +#endif #endif // PATH_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp index 20ed762501..6949f0256e 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp @@ -850,7 +850,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { uv_edit = memnew( AcceptDialog ); add_child(uv_edit); uv_edit->set_title(TTR("Polygon 2D UV Editor")); - uv_edit->set_self_opacity(0.9); + uv_edit->set_self_modulate(Color(1,1,1,0.9)); VBoxContainer *uv_main_vb = memnew( VBoxContainer ); uv_edit->add_child(uv_main_vb); diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index 35f0888c76..423e6f6f1f 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -311,7 +311,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag imgdata = DVector<uint8_t>::Write(); - p_texture->set_data(Image(w,h,0,Image::FORMAT_RGB,img)); + p_texture->set_data(Image(w,h,0,Image::FORMAT_RGB8,img)); } @@ -392,7 +392,7 @@ SampleEditor::SampleEditor() { add_child(stop); peakdisplay=Ref<ImageTexture>( memnew( ImageTexture) ); - peakdisplay->create( EDITOR_DEF("audio/sample_editor_preview_width",512),EDITOR_DEF("audio/sample_editor_preview_height",128),Image::FORMAT_RGB); + peakdisplay->create( EDITOR_DEF("audio/sample_editor_preview_width",512),EDITOR_DEF("audio/sample_editor_preview_height",128),Image::FORMAT_RGB8); sample_texframe->set_expand(true); sample_texframe->set_texture(peakdisplay); diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index 3f07fdb8e4..82321962eb 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -236,7 +236,7 @@ void SampleLibraryEditor::_update_library() { // Preview/edit Ref<ImageTexture> preview( memnew( ImageTexture )); - preview->create(128,16,Image::FORMAT_RGB); + preview->create(128,16,Image::FORMAT_RGB8); SampleEditor::generate_preview_texture(smp,preview); ti->set_cell_mode(1,TreeItem::CELL_MODE_ICON); ti->set_selectable(1,false); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 789149fc00..6988d8c6f2 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1841,6 +1841,8 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { void ScriptEditor::_help_class_open(const String& p_class) { + if (p_class=="") + return; for(int i=0;i<tab_container->get_child_count();i++) { diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index 839a49272b..789fdcd6b0 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -37,7 +37,7 @@ #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" #include "os/os.h" - +#include "servers/visual/shader_types.h" /*** SETTINGS EDITOR ****/ @@ -51,19 +51,14 @@ Ref<Shader> ShaderTextEditor::get_edited_shader() const { return shader; } -void ShaderTextEditor::set_edited_shader(const Ref<Shader>& p_shader,ShaderLanguage::ShaderType p_type) { +void ShaderTextEditor::set_edited_shader(const Ref<Shader>& p_shader) { shader=p_shader; - type=p_type; + _load_theme_settings(); - if (p_type==ShaderLanguage::SHADER_MATERIAL_LIGHT || p_type==ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT) - get_text_edit()->set_text(shader->get_light_code()); - else if (p_type==ShaderLanguage::SHADER_MATERIAL_VERTEX || p_type==ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX) - get_text_edit()->set_text(shader->get_vertex_code()); - else - get_text_edit()->set_text(shader->get_fragment_code()); + get_text_edit()->set_text(p_shader->get_code()); _line_col_changed(); @@ -105,7 +100,25 @@ void ShaderTextEditor::_load_theme_settings() { List<String> keywords; - ShaderLanguage::get_keyword_list(type,&keywords); + ShaderLanguage::get_keyword_list(&keywords); + + if (shader.is_valid()) { + + + for(const Map< StringName, Map<StringName,ShaderLanguage::DataType> >::Element *E=ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front();E;E=E->next()) { + + for (const Map<StringName,ShaderLanguage::DataType>::Element *F=E->get().front();F;F=F->next()) { + keywords.push_back(F->key()); + } + + } + + for(const Set<String>::Element *E =ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())).front();E;E=E->next()) { + + keywords.push_back(E->get()); + + } + } for(List<String>::Element *E=keywords.front();E;E=E->next()) { @@ -138,22 +151,34 @@ void ShaderTextEditor::_load_theme_settings() { }*/ } +void ShaderTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) { -void ShaderTextEditor::_validate_script() { + print_line("code complete"); + + ShaderLanguage sl; + String calltip; + + Error err = sl.complete(p_code,ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())),ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())),r_options,calltip); + + if (calltip!="") { + get_text_edit()->set_code_hint(calltip); + } +} - String errortxt; - int line,col; +void ShaderTextEditor::_validate_script() { String code=get_text_edit()->get_text(); //List<StringName> params; //shader->get_param_list(¶ms); - Error err = ShaderLanguage::compile(code,type,NULL,NULL,&errortxt,&line,&col); + ShaderLanguage sl; + + Error err = sl.compile(code,ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())),ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode()))); if (err!=OK) { - String error_text="error("+itos(line+1)+","+itos(col+1)+"): "+errortxt; + String error_text="error("+itos(sl.get_error_line())+"): "+sl.get_error_text(); set_error(error_text); - get_text_edit()->set_line_as_marked(line,true); + get_text_edit()->set_line_as_marked(sl.get_error_line(),true); } else { for(int i=0;i<get_text_edit()->get_line_count();i++) @@ -183,9 +208,7 @@ ShaderTextEditor::ShaderTextEditor() { void ShaderEditor::_menu_option(int p_option) { - ShaderTextEditor *current = tab_container->get_current_tab_control()->cast_to<ShaderTextEditor>(); - if (!current) - return; + ShaderTextEditor *current = shader_editor; switch(p_option) { case EDIT_UNDO: { @@ -241,24 +264,11 @@ void ShaderEditor::_menu_option(int p_option) { } } -void ShaderEditor::_tab_changed(int p_which) { - - ShaderTextEditor *shader_editor = tab_container->get_tab_control(p_which)->cast_to<ShaderTextEditor>(); - - if (shader_editor && is_inside_tree()) - shader_editor->get_text_edit()->grab_focus(); - - ensure_select_current(); -} void ShaderEditor::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { - close->set_normal_texture( get_icon("Close","EditorIcons")); - close->set_hover_texture( get_icon("CloseHover","EditorIcons")); - close->set_pressed_texture( get_icon("Close","EditorIcons")); - close->connect("pressed",this,"_close_callback"); } if (p_what==NOTIFICATION_DRAW) { @@ -361,25 +371,30 @@ void ShaderEditor::clear() { void ShaderEditor::_params_changed() { - fragment_editor->_validate_script(); - vertex_editor->_validate_script(); - light_editor->_validate_script(); + shader_editor->_validate_script(); } void ShaderEditor::_editor_settings_changed() { - vertex_editor->update_editor_settings(); - fragment_editor->update_editor_settings(); - light_editor->update_editor_settings(); + shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); + shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); + shader_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); + shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); + shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); + shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); + shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); + shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); + shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); + shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/line_spacing")); + shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); } void ShaderEditor::_bind_methods() { ObjectTypeDB::bind_method("_editor_settings_changed",&ShaderEditor::_editor_settings_changed); - ObjectTypeDB::bind_method("_tab_changed",&ShaderEditor::_tab_changed); + ObjectTypeDB::bind_method("_menu_option",&ShaderEditor::_menu_option); ObjectTypeDB::bind_method("_params_changed",&ShaderEditor::_params_changed); - ObjectTypeDB::bind_method("_close_callback",&ShaderEditor::_close_callback); ObjectTypeDB::bind_method("apply_shaders",&ShaderEditor::apply_shaders); // ObjectTypeDB::bind_method("_close_current_tab",&ShaderEditor::_close_current_tab); } @@ -405,16 +420,7 @@ void ShaderEditor::edit(const Ref<Shader>& p_shader) { shader=p_shader; - if (shader->get_mode()==Shader::MODE_MATERIAL) { - vertex_editor->set_edited_shader(p_shader,ShaderLanguage::SHADER_MATERIAL_VERTEX); - fragment_editor->set_edited_shader(p_shader,ShaderLanguage::SHADER_MATERIAL_FRAGMENT); - light_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_LIGHT); - } else if (shader->get_mode()==Shader::MODE_CANVAS_ITEM) { - - vertex_editor->set_edited_shader(p_shader,ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX); - fragment_editor->set_edited_shader(p_shader,ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT); - light_editor->set_edited_shader(shader,ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT); - } + shader_editor->set_edited_shader(p_shader); //vertex_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_VERTEX); // see if already has it @@ -438,35 +444,21 @@ void ShaderEditor::apply_shaders() { if (shader.is_valid()) { - shader->set_code(vertex_editor->get_text_edit()->get_text(),fragment_editor->get_text_edit()->get_text(),light_editor->get_text_edit()->get_text(),0,0); + shader->set_code(shader_editor->get_text_edit()->get_text()); shader->set_edited(true); } } -void ShaderEditor::_close_callback() { - - hide(); -} - ShaderEditor::ShaderEditor() { - tab_container = memnew( TabContainer ); - add_child(tab_container); - tab_container->set_area_as_parent_rect(); - tab_container->set_begin(Point2(0,0)); - //tab_container->set_begin(Point2(0,0)); - - close = memnew( TextureButton ); - close->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,20); - close->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,4); - close->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,2); - add_child(close); + HBoxContainer *hbc = memnew( HBoxContainer); + add_child(hbc); edit_menu = memnew( MenuButton ); - add_child(edit_menu); + hbc->add_child(edit_menu); edit_menu->set_pos(Point2(5,-1)); edit_menu->set_text(TTR("Edit")); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z), EDIT_UNDO); @@ -481,7 +473,7 @@ ShaderEditor::ShaderEditor() { search_menu = memnew( MenuButton ); - add_child(search_menu); + hbc->add_child(search_menu); search_menu->set_pos(Point2(38,-1)); search_menu->set_text(TTR("Search")); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD|KEY_F), SEARCH_FIND); @@ -494,34 +486,15 @@ ShaderEditor::ShaderEditor() { search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); - tab_container->connect("tab_changed", this,"_tab_changed"); - - erase_tab_confirm = memnew( ConfirmationDialog ); - add_child(erase_tab_confirm); - erase_tab_confirm->connect("confirmed", this,"_close_current_tab"); - - goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); - vertex_editor = memnew( ShaderTextEditor ); - tab_container->add_child(vertex_editor); - vertex_editor->set_name(TTR("Vertex")); + shader_editor = memnew( ShaderTextEditor ); + add_child(shader_editor); + shader_editor->set_v_size_flags(SIZE_EXPAND_FILL); - fragment_editor = memnew( ShaderTextEditor ); - tab_container->add_child(fragment_editor); - fragment_editor->set_name(TTR("Fragment")); - light_editor = memnew( ShaderTextEditor ); - tab_container->add_child(light_editor); - light_editor->set_name(TTR("Lighting")); - - tab_container->set_current_tab(1); - - - vertex_editor->connect("script_changed", this,"apply_shaders"); - fragment_editor->connect("script_changed", this,"apply_shaders"); - light_editor->connect("script_changed", this,"apply_shaders"); + shader_editor->connect("script_changed", this,"apply_shaders"); EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); _editor_settings_changed(); @@ -531,15 +504,7 @@ ShaderEditor::ShaderEditor() { void ShaderEditorPlugin::edit(Object *p_object) { Shader* s = p_object->cast_to<Shader>(); - if (!s || s->cast_to<ShaderGraph>()) { - shader_editor->hide(); //Dont edit ShaderGraph - return; - } - - if (_2d && s->get_mode()==Shader::MODE_CANVAS_ITEM) - shader_editor->edit(s); - else if (!_2d && s->get_mode()==Shader::MODE_MATERIAL) - shader_editor->edit(s); + shader_editor->edit(s); } @@ -547,24 +512,25 @@ bool ShaderEditorPlugin::handles(Object *p_object) const { bool handles = true; Shader *shader=p_object->cast_to<Shader>(); - if (!shader || shader->cast_to<ShaderGraph>()) // Dont handle ShaderGraph's - handles = false; - if (handles && _2d) - handles = shader->get_mode()==Shader::MODE_CANVAS_ITEM; - else if (handles && !_2d) - return shader->get_mode()==Shader::MODE_MATERIAL; - - if (!handles) - shader_editor->hide(); - return handles; + //if (!shader || shader->cast_to<ShaderGraph>()) // Dont handle ShaderGraph's + // handles = false; + + return shader!=NULL; } void ShaderEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - shader_editor->show(); + button->show(); + editor->make_bottom_panel_item_visible(shader_editor); + } else { + + button->hide(); + if (shader_editor->is_visible()) + editor->hide_bottom_panel(); shader_editor->apply_shaders(); + } } @@ -598,19 +564,14 @@ void ShaderEditorPlugin::apply_changes() { shader_editor->apply_shaders(); } -ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node, bool p_2d) { +ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) { + editor=p_node; shader_editor = memnew( ShaderEditor ); - _2d=p_2d; - if (p_2d) - add_control_to_container(CONTAINER_CANVAS_EDITOR_BOTTOM,shader_editor); - else - add_control_to_container(CONTAINER_SPATIAL_EDITOR_BOTTOM,shader_editor); -// editor->get_viewport()->add_child(shader_editor); -// shader_editor->set_area_as_parent_rect(); - shader_editor->hide(); + shader_editor->set_custom_minimum_size(Size2(0,300)); + button=editor->add_bottom_panel_item("Shader",shader_editor); } @@ -618,3 +579,4 @@ ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node, bool p_2d) { ShaderEditorPlugin::~ShaderEditorPlugin() { } + diff --git a/tools/editor/plugins/shader_editor_plugin.h b/tools/editor/plugins/shader_editor_plugin.h index 9f9576b871..c13d4256a1 100644 --- a/tools/editor/plugins/shader_editor_plugin.h +++ b/tools/editor/plugins/shader_editor_plugin.h @@ -38,33 +38,34 @@ #include "scene/resources/shader.h" #include "servers/visual/shader_language.h" - class ShaderTextEditor : public CodeTextEditor { OBJ_TYPE( ShaderTextEditor, CodeTextEditor ); Ref<Shader> shader; - ShaderLanguage::ShaderType type; protected: static void _bind_methods(); virtual void _load_theme_settings(); + + virtual void _code_complete_script(const String& p_code, List<String>* r_options); + public: virtual void _validate_script(); Ref<Shader> get_edited_shader() const; - void set_edited_shader(const Ref<Shader>& p_shader,ShaderLanguage::ShaderType p_type); + void set_edited_shader(const Ref<Shader>& p_shader); ShaderTextEditor(); }; -class ShaderEditor : public Control { +class ShaderEditor : public VBoxContainer { - OBJ_TYPE(ShaderEditor, Control ); + OBJ_TYPE(ShaderEditor, VBoxContainer ); enum { @@ -88,22 +89,17 @@ class ShaderEditor : public Control { MenuButton *settings_menu; uint64_t idle; - TabContainer *tab_container; GotoLineDialog *goto_line_dialog; ConfirmationDialog *erase_tab_confirm; - TextureButton *close; - ShaderTextEditor *vertex_editor; - ShaderTextEditor *fragment_editor; - ShaderTextEditor *light_editor; + ShaderTextEditor *shader_editor; + - void _tab_changed(int p_which); void _menu_option(int p_optin); void _params_changed(); mutable Ref<Shader> shader; - void _close_callback(); void _editor_settings_changed(); @@ -134,6 +130,8 @@ class ShaderEditorPlugin : public EditorPlugin { bool _2d; ShaderEditor *shader_editor; EditorNode *editor; + Button *button; + public: virtual String get_name() const { return "Shader"; } @@ -150,8 +148,9 @@ public: virtual void save_external_data(); virtual void apply_changes(); - ShaderEditorPlugin(EditorNode *p_node,bool p_2d); + ShaderEditorPlugin(EditorNode *p_node); ~ShaderEditorPlugin(); }; + #endif diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index c82811534a..0a00e47f37 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -28,6 +28,7 @@ /*************************************************************************/ #include "shader_graph_editor_plugin.h" +#if 0 #include "scene/gui/check_box.h" #include "scene/gui/menu_button.h" @@ -1377,7 +1378,7 @@ ToolButton *ShaderGraphView::make_editor(String text,GraphNode* gn,int p_id,int edit->set_icon(ped_popup->get_icon("Matrix", "EditorIcons")); break; case Variant::COLOR: { - Image icon_color = Image(15,15,false,Image::FORMAT_RGB); + Image icon_color = Image(15,15,false,Image::FORMAT_RGB8); Color c = graph->default_get_value(type,p_id,param); for (int x=1;x<14;x++) for (int y=1;y<14;y++) @@ -2945,3 +2946,4 @@ ShaderGraphEditorPlugin::~ShaderGraphEditorPlugin() +#endif diff --git a/tools/editor/plugins/shader_graph_editor_plugin.h b/tools/editor/plugins/shader_graph_editor_plugin.h index c5ea5a3e3d..7b33e586b5 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.h +++ b/tools/editor/plugins/shader_graph_editor_plugin.h @@ -43,7 +43,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ - +#if 0 class GraphColorRampEdit : public Control { OBJ_TYPE(GraphColorRampEdit,Control); @@ -239,4 +239,4 @@ public: }; #endif - +#endif diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index eb0289bd26..83e3cb77f3 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -274,7 +274,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b Vector3 ray=_get_ray(p_pos); Vector3 pos=_get_ray_pos(p_pos); - Vector<RID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() ); + Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() ); Set<Ref<SpatialEditorGizmo> > found_gizmos; //uint32_t closest=0; @@ -286,8 +286,7 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b for (int i=0;i<instances.size();i++) { - uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]); - Object *obj=ObjectDB::get_instance(id); + Object *obj=ObjectDB::get_instance(instances[i]); if (!obj) continue; @@ -405,15 +404,15 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2& p_pos,bool &r_inclu Vector3 ray=_get_ray(p_pos); Vector3 pos=_get_ray_pos(p_pos); - Vector<RID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() ); + Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() ); Set<Ref<SpatialEditorGizmo> > found_gizmos; r_includes_current=false; for (int i=0;i<instances.size();i++) { - uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]); - Object *obj=ObjectDB::get_instance(id); + Object *obj=ObjectDB::get_instance(instances[i]); + if (!obj) continue; @@ -534,14 +533,12 @@ void SpatialEditorViewport::_select_region() { frustum.push_back( far ); - Vector<RID> instances=VisualServer::get_singleton()->instances_cull_convex(frustum,get_tree()->get_root()->get_world()->get_scenario()); + Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_convex(frustum,get_tree()->get_root()->get_world()->get_scenario()); for (int i=0;i<instances.size();i++) { - uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]); - - Object *obj=ObjectDB::get_instance(id); + Object *obj=ObjectDB::get_instance(instances[i]); if (!obj) continue; Spatial *sp = obj->cast_to<Spatial>(); @@ -877,7 +874,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { if (b.mod.control) { - Vector<RID> instances=VisualServer::get_singleton()->instances_cull_ray(ray_origin,ray_dir,get_tree()->get_root()->get_world()->get_scenario() ); + Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(ray_origin,ray_dir,get_tree()->get_root()->get_world()->get_scenario() ); Plane p(ray_origin,_get_camera_normal()); @@ -886,8 +883,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { for (int i=0;i<instances.size();i++) { - uint32_t id=VisualServer::get_singleton()->instance_get_object_instance_ID(instances[i]); - Object *obj=ObjectDB::get_instance(id); + + Object *obj=ObjectDB::get_instance(instances[i]); + if (!obj) continue; @@ -1825,6 +1823,30 @@ void SpatialEditorViewport::_notification(int p_what) { surface->update(); } + //update shadow atlas if changed + + int shadowmap_size = Globals::get_singleton()->get("rendering/shadow_atlas/size"); + int atlas_q0 = Globals::get_singleton()->get("rendering/shadow_atlas/quadrant_0_subdiv"); + int atlas_q1 = Globals::get_singleton()->get("rendering/shadow_atlas/quadrant_1_subdiv"); + int atlas_q2 = Globals::get_singleton()->get("rendering/shadow_atlas/quadrant_2_subdiv"); + int atlas_q3 = Globals::get_singleton()->get("rendering/shadow_atlas/quadrant_3_subdiv"); + + + viewport->set_shadow_atlas_size(shadowmap_size); + viewport->set_shadow_atlas_quadrant_subdiv(0,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0)); + viewport->set_shadow_atlas_quadrant_subdiv(1,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q1)); + viewport->set_shadow_atlas_quadrant_subdiv(2,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q2)); + viewport->set_shadow_atlas_quadrant_subdiv(3,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q3)); + + //update msaa if changed + + int msaa_mode = Globals::get_singleton()->get("rendering/antialias/msaa"); + viewport->set_msaa(Viewport::MSAA(msaa_mode)); + + bool hdr = Globals::get_singleton()->get("rendering/dynamic_range/hdr"); + viewport->set_hdr(hdr); + + } if (p_what==NOTIFICATION_ENTER_TREE) { @@ -2066,9 +2088,9 @@ void SpatialEditorViewport::_menu_option(int p_option) { bool current = view_menu->get_popup()->is_item_checked( idx ); current=!current; if (current) - camera->set_visible_layers( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) ); + camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) ); else - camera->set_visible_layers( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_GRID_LAYER) ); + camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_GRID_LAYER) ); view_menu->get_popup()->set_item_checked( idx, current ); } break; @@ -2355,18 +2377,20 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed message_time=0; spatial_editor=p_spatial_editor; - Control *c=memnew(Control); + ViewportContainer *c=memnew(ViewportContainer); + c->set_stretch(true); add_child(c); c->set_area_as_parent_rect(); viewport = memnew( Viewport ); viewport->set_disable_input(true); + c->add_child(viewport); surface = memnew( Control ); add_child(surface); surface->set_area_as_parent_rect(); camera = memnew(Camera); camera->set_disable_gizmo(true); - camera->set_visible_layers( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+p_index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) ); + camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+p_index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) ); //camera->set_environment(SpatialEditor::get_singleton()->get_viewport_environment()); viewport->add_child(camera); camera->make_current(); @@ -2375,7 +2399,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu = memnew( MenuButton ); surface->add_child(view_menu); view_menu->set_pos( Point2(4,4)); - view_menu->set_self_opacity(0.5); + view_menu->set_self_modulate(Color(1,1,1,0.5)); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT); @@ -2555,11 +2579,12 @@ void SpatialEditor::_generate_selection_box() { } - Ref<FixedMaterial> mat = memnew( FixedMaterial ); - mat->set_flag(Material::FLAG_UNSHADED,true); - mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true); + Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial ); + mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + mat->set_albedo(Color(1,1,1)); + mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true); + mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true); + mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true); st->set_material(mat); selection_box = st->commit(); } @@ -2691,14 +2716,14 @@ void SpatialEditor::set_state(const Dictionary& p_state) { } if (d.has("ambient_light_color")) { settings_ambient_color->set_color(d["ambient_light_color"]); - viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,d["ambient_light_color"]); + //viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,d["ambient_light_color"]); } if (d.has("default_srgb")) { bool use = d["default_srgb"]; - viewport_environment->set_enable_fx(Environment::FX_SRGB,use); - view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB), use ); + //viewport_environment->set_enable_fx(Environment::FX_SRGB,use); + //view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB), use ); } if (d.has("show_grid")) { bool use = d["show_grid"]; @@ -2898,9 +2923,9 @@ void SpatialEditor::_menu_item_pressed(int p_option) { bool is_checked = view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(p_option) ); if (is_checked) { - viewport_environment->set_enable_fx(Environment::FX_SRGB,false); + //viewport_environment->set_enable_fx(Environment::FX_SRGB,false); } else { - viewport_environment->set_enable_fx(Environment::FX_SRGB,true); + //viewport_environment->set_enable_fx(Environment::FX_SRGB,true); } is_checked = ! is_checked; @@ -3146,11 +3171,13 @@ void SpatialEditor::_init_indicators() { { - indicator_mat = VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false ); - VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - VisualServer::get_singleton()->fixed_material_set_flag(indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); + indicator_mat.instance();; + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true); + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true); + indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true); + + indicator_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true); DVector<Color> grid_colors[3]; DVector<Vector3> grid_points[3]; @@ -3192,8 +3219,8 @@ void SpatialEditor::_init_indicators() { d.resize(VS::ARRAY_MAX); d[VisualServer::ARRAY_VERTEX]=grid_points[i]; d[VisualServer::ARRAY_COLOR]=grid_colors[i]; - VisualServer::get_singleton()->mesh_add_surface(grid[i],VisualServer::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i],VisualServer::PRIMITIVE_LINES,d); + VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat->get_rid()); grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i],get_tree()->get_root()->get_world()->get_scenario()); grid_visible[i]=false; @@ -3211,8 +3238,8 @@ void SpatialEditor::_init_indicators() { d[VisualServer::ARRAY_VERTEX]=origin_points; d[VisualServer::ARRAY_COLOR]=origin_colors; - VisualServer::get_singleton()->mesh_add_surface(origin,VisualServer::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin,VisualServer::PRIMITIVE_LINES,d); + VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat->get_rid()); // origin = VisualServer::get_singleton()->poly_create(); @@ -3243,17 +3270,15 @@ void SpatialEditor::_init_indicators() { cursor_points.push_back(Vector3(0,-cs,0)); cursor_points.push_back(Vector3(0,0,+cs)); cursor_points.push_back(Vector3(0,0,-cs)); - cursor_material=VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->fixed_material_set_param(cursor_material,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0,1,1)); - VisualServer::get_singleton()->material_set_flag( cursor_material, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true); - VisualServer::get_singleton()->fixed_material_set_flag(cursor_material, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true); + cursor_material.instance(); + cursor_material->set_albedo(Color(0,1,1)); + cursor_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); Array d; d.resize(VS::ARRAY_MAX); d[VS::ARRAY_VERTEX]=cursor_points; - VisualServer::get_singleton()->mesh_add_surface(cursor_mesh,VS::PRIMITIVE_LINES,d); - VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cursor_material); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh,VS::PRIMITIVE_LINES,d); + VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cursor_material->get_rid()); cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh,get_tree()->get_root()->get_world()->get_scenario()); VS::get_singleton()->instance_set_layer_mask(cursor_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER); @@ -3271,11 +3296,11 @@ void SpatialEditor::_init_indicators() { float gizmo_alph = EditorSettings::get_singleton()->get("3d_editor/manipulator_gizmo_opacity"); - gizmo_hl = Ref<FixedMaterial>( memnew( FixedMaterial ) ); - gizmo_hl->set_flag(Material::FLAG_UNSHADED, true); - gizmo_hl->set_flag(Material::FLAG_ONTOP, true); - gizmo_hl->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - gizmo_hl->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,gizmo_alph+0.2f)); + gizmo_hl = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ) ); + gizmo_hl->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + gizmo_hl->set_flag(FixedSpatialMaterial::FLAG_ONTOP, true); + gizmo_hl->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + gizmo_hl->set_albedo(Color(1,1,1,gizmo_alph+0.2f)); for(int i=0;i<3;i++) { @@ -3283,14 +3308,14 @@ void SpatialEditor::_init_indicators() { rotate_gizmo[i]=Ref<Mesh>( memnew( Mesh ) ); - Ref<FixedMaterial> mat = memnew( FixedMaterial ); - mat->set_flag(Material::FLAG_UNSHADED, true); - mat->set_flag(Material::FLAG_ONTOP, true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); + Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial ); + mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP, true); + mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); Color col; col[i]=1.0; col.a= gizmo_alph; - mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,col); + mat->set_albedo(col); gizmo_color[i]=mat; @@ -3436,8 +3461,6 @@ void SpatialEditor::_finish_indicators() { VisualServer::get_singleton()->free(cursor_instance); VisualServer::get_singleton()->free(cursor_mesh); - VisualServer::get_singleton()->free(indicator_mat); - VisualServer::get_singleton()->free(cursor_material); } void SpatialEditor::_instance_scene() { @@ -3730,7 +3753,7 @@ void SpatialEditor::clear() { settings_default_light_rot_x=Math_PI*0.3; settings_default_light_rot_y=Math_PI*0.2; - viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15)); + //viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15)); settings_ambient_color->set_color(Color(0.15,0.15,0.15)); if (!light_instance.is_valid()) _menu_item_pressed(MENU_VIEW_USE_DEFAULT_LIGHT); @@ -3743,7 +3766,7 @@ void SpatialEditor::clear() { void SpatialEditor::_update_ambient_light_color(const Color& p_color) { - viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color()); +// viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color()); } @@ -3982,7 +4005,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { - settings_light_base = memnew( Control ); + settings_light_base = memnew( ViewportContainer ); settings_light_base->set_custom_minimum_size(Size2(128,128)); settings_light_base->connect("input_event",this,"_default_light_angle_input"); settings_vbc->add_margin_child(TTR("Default Light Normal:"),settings_light_base); @@ -4013,8 +4036,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_vbc->add_margin_child(TTR("Ambient Light Color:"),settings_ambient_color); settings_ambient_color->connect("color_changed",this,"_update_ambient_light_color"); - viewport_environment->set_enable_fx(Environment::FX_AMBIENT_LIGHT,true); - viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15)); +// viewport_environment->set_enable_fx(Environment::FX_AMBIENT_LIGHT,true); +// viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15)); settings_ambient_color->set_color(Color(0.15,0.15,0.15)); diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index 0ee9fcd4bd..deed5072d4 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -332,8 +332,8 @@ private: bool grid_enabled; Ref<Mesh> move_gizmo[3], rotate_gizmo[3]; - Ref<FixedMaterial> gizmo_color[3]; - Ref<FixedMaterial> gizmo_hl; + Ref<FixedSpatialMaterial> gizmo_color[3]; + Ref<FixedSpatialMaterial> gizmo_hl; int over_gizmo_handle; @@ -345,8 +345,8 @@ private: RID indicators_instance; RID cursor_mesh; RID cursor_instance; - RID indicator_mat; - RID cursor_material; + Ref<FixedSpatialMaterial> indicator_mat; + Ref<FixedSpatialMaterial> cursor_material; /* struct Selected { @@ -431,7 +431,7 @@ private: float settings_default_light_rot_x; float settings_default_light_rot_y; - Control *settings_light_base; + ViewportContainer *settings_light_base; Viewport *settings_light_vp; ColorPickerButton *settings_ambient_color; Image settings_light_dir_image; diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index e739c9837f..af2a18ce2b 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -863,7 +863,7 @@ void ProjectManager::_load_recent_projects() { TextureButton *favorite = memnew( TextureButton ); favorite->set_normal_texture(favorite_icon); if (!is_favorite) - favorite->set_opacity(0.2); + favorite->set_modulate(Color(1,1,1,0.2)); favorite->set_v_size_flags(SIZE_EXPAND); favorite->connect("pressed",this,"_favorite_pressed",varray(hb)); favorite_box->add_child(favorite); @@ -886,7 +886,7 @@ void ProjectManager::_load_recent_projects() { Label *fpath = memnew( Label(path) ); fpath->set_name("path"); vb->add_child(fpath); - fpath->set_opacity(0.5); + fpath->set_modulate(Color(1,1,1,0.5)); fpath->add_color_override("font_color",font_color); scroll_childs->add_child(hb); diff --git a/tools/editor/pvrtc_compress.cpp b/tools/editor/pvrtc_compress.cpp index 637f105b65..e9ef311e79 100644 --- a/tools/editor/pvrtc_compress.cpp +++ b/tools/editor/pvrtc_compress.cpp @@ -85,7 +85,7 @@ static void _compress_image(Image::CompressMode p_mode,Image *p_image) { if (EditorSettings::get_singleton()->get("PVRTC/fast_conversion").operator bool()) { args.push_back("-pvrtcfast"); } - if (p_image->get_mipmaps()>0) + if (p_image->has_mipmaps()) args.push_back("-m"); Ref<ImageTexture> t = memnew( ImageTexture ); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index aa74f47e8d..e0cc9573cd 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -959,7 +959,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) Label *label = memnew( Label( selected[i]->get_name() ) ); hb->add_child(label); vb->add_child(hb); - hb->set_opacity(opacity_item); + hb->set_modulate(Color(1,1,1,opacity_item)); opacity_item -= opacity_step; } NodePath p = selected[i]->get_path(); diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index eaa49f9fb0..f170c9b717 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -41,6 +41,8 @@ // Keep small children away from this file. // It's so ugly it will eat them alive + + #define HANDLE_HALF_SIZE 0.05 void EditorSpatialGizmo::clear() { @@ -82,7 +84,6 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base) { if (extra_margin) VS::get_singleton()->instance_set_extra_visibility_margin(instance,1); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance,VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_RECEIVE_SHADOWS,false); VS::get_singleton()->instance_set_layer_mask(instance,1<<SpatialEditorViewport::GIZMO_EDIT_LAYER); //gizmos are 26 } @@ -132,7 +133,7 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat a[Mesh::ARRAY_COLOR]=color; - mesh->add_surface(Mesh::PRIMITIVE_LINES,a); + mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,a); mesh->surface_set_material(0,p_material); if (p_billboard) { @@ -181,7 +182,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material>& p_material, a.resize(Mesh::ARRAY_MAX); a[Mesh::ARRAY_VERTEX]=vs; a[Mesh::ARRAY_TEX_UV]=uv; - mesh->add_surface(Mesh::PRIMITIVE_TRIANGLE_FAN,a); + mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_FAN,a); mesh->surface_set_material(0,p_material); if (true) { @@ -244,6 +245,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi Array a; a.resize(VS::ARRAY_MAX); a[VS::ARRAY_VERTEX]=p_handles; + print_line("handles?: "+itos(p_handles.size())); DVector<Color> colors; { colors.resize(p_handles.size()); @@ -258,7 +260,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi } a[VS::ARRAY_COLOR]=colors; - mesh->add_surface(Mesh::PRIMITIVE_POINTS,a); + mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS,a); mesh->surface_set_material(0,SpatialEditorGizmos::singleton->handle2_material); if (p_billboard) { @@ -667,9 +669,9 @@ String LightSpatialGizmo::get_handle_name(int p_idx) const { Variant LightSpatialGizmo::get_handle_value(int p_idx) const{ if (p_idx==0) - return light->get_parameter(Light::PARAM_RADIUS); + return light->get_param(Light::PARAM_RANGE); if (p_idx==1) - return light->get_parameter(Light::PARAM_SPOT_ANGLE); + return light->get_param(Light::PARAM_SPOT_ANGLE); return Variant(); } @@ -727,7 +729,7 @@ void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_p if (d<0) d=0; - light->set_parameter(Light::PARAM_RADIUS,d); + light->set_param(Light::PARAM_RANGE,d); } else if (light->cast_to<OmniLight>()) { Plane cp=Plane( gt.origin, p_camera->get_transform().basis.get_axis(2)); @@ -736,15 +738,15 @@ void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_p if (cp.intersects_ray(ray_from,ray_dir,&inters)) { float r = inters.distance_to(gt.origin); - light->set_parameter(Light::PARAM_RADIUS,r); + light->set_param(Light::PARAM_RANGE,r); } } } else if (p_idx==1) { - float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],light->get_parameter(Light::PARAM_RADIUS),gt); - light->set_parameter(Light::PARAM_SPOT_ANGLE,CLAMP(a,0.01,89.99)); + float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],light->get_param(Light::PARAM_RANGE),gt); + light->set_param(Light::PARAM_SPOT_ANGLE,CLAMP(a,0.01,89.99)); } } @@ -752,21 +754,21 @@ void LightSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_ if (p_cancel) { - light->set_parameter(p_idx==0?Light::PARAM_RADIUS:Light::PARAM_SPOT_ANGLE,p_restore); + light->set_param(p_idx==0?Light::PARAM_RANGE:Light::PARAM_SPOT_ANGLE,p_restore); } else if (p_idx==0) { UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); - ur->add_do_method(light,"set_parameter",Light::PARAM_RADIUS,light->get_parameter(Light::PARAM_RADIUS)); - ur->add_undo_method(light,"set_parameter",Light::PARAM_RADIUS,p_restore); + ur->add_do_method(light,"set_param",Light::PARAM_RANGE,light->get_param(Light::PARAM_RANGE)); + ur->add_undo_method(light,"set_param",Light::PARAM_RANGE,p_restore); ur->commit_action(); } else if (p_idx==1) { UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); - ur->add_do_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,light->get_parameter(Light::PARAM_SPOT_ANGLE)); - ur->add_undo_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,p_restore); + ur->add_do_method(light,"set_param",Light::PARAM_SPOT_ANGLE,light->get_param(Light::PARAM_SPOT_ANGLE)); + ur->add_undo_method(light,"set_param",Light::PARAM_SPOT_ANGLE,p_restore); ur->commit_action(); } @@ -829,7 +831,7 @@ void LightSpatialGizmo::redraw() { OmniLight *on = light->cast_to<OmniLight>(); - float r = on->get_parameter(Light::PARAM_RADIUS); + float r = on->get_param(Light::PARAM_RANGE); Vector<Vector3> points; @@ -869,9 +871,9 @@ void LightSpatialGizmo::redraw() { Vector<Vector3> points; SpotLight *on = light->cast_to<SpotLight>(); - float r = on->get_parameter(Light::PARAM_RADIUS); - float w = r*Math::sin(Math::deg2rad(on->get_parameter(Light::PARAM_SPOT_ANGLE))); - float d = r*Math::cos(Math::deg2rad(on->get_parameter(Light::PARAM_SPOT_ANGLE))); + float r = on->get_param(Light::PARAM_RANGE); + float w = r*Math::sin(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE))); + float d = r*Math::cos(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE))); @@ -1541,7 +1543,7 @@ void RayCastSpatialGizmo::redraw() { } -RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast){ +RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast) { set_spatial_node(p_raycast); raycast=p_raycast; @@ -2237,6 +2239,321 @@ VisibilityNotifierGizmo::VisibilityNotifierGizmo(VisibilityNotifier* p_notifier) //////// +/// + + +String ReflectionProbeGizmo::get_handle_name(int p_idx) const { + + switch(p_idx) { + case 0: return "Extents X"; + case 1: return "Extents Y"; + case 2: return "Extents Z"; + case 3: return "Origin X"; + case 4: return "Origin Y"; + case 5: return "Origin Z"; + } + + return ""; +} +Variant ReflectionProbeGizmo::get_handle_value(int p_idx) const{ + + return AABB(probe->get_extents(),probe->get_origin_offset()); +} +void ReflectionProbeGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){ + + Transform gt = probe->get_global_transform(); + //gt.orthonormalize(); + Transform gi = gt.affine_inverse(); + + + if (p_idx<3) { + Vector3 extents = probe->get_extents(); + + Vector3 ray_from = p_camera->project_ray_origin(p_point); + Vector3 ray_dir = p_camera->project_ray_normal(p_point); + + Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*16384)}; + + Vector3 axis; + axis[p_idx]=1.0; + + Vector3 ra,rb; + Geometry::get_closest_points_between_segments(Vector3(),axis*16384,sg[0],sg[1],ra,rb); + float d = ra[p_idx]; + if (d<0.001) + d=0.001; + + extents[p_idx]=d; + probe->set_extents(extents); + } else { + + p_idx-=3; + + Vector3 origin = probe->get_origin_offset(); + origin[p_idx]=0; + + Vector3 ray_from = p_camera->project_ray_origin(p_point); + Vector3 ray_dir = p_camera->project_ray_normal(p_point); + + Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*16384)}; + + Vector3 axis; + axis[p_idx]=1.0; + + Vector3 ra,rb; + Geometry::get_closest_points_between_segments(origin-axis*16384,origin+axis*16384,sg[0],sg[1],ra,rb); + float d = ra[p_idx]; + d+=0.25; + + origin[p_idx]=d; + probe->set_origin_offset(origin); + + } +} + +void ReflectionProbeGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){ + + AABB restore = p_restore; + + if (p_cancel) { + probe->set_extents(restore.pos); + probe->set_origin_offset(restore.size); + return; + } + + UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Change Probe Extents")); + ur->add_do_method(probe,"set_extents",probe->get_extents()); + ur->add_do_method(probe,"set_origin_offset",probe->get_origin_offset()); + ur->add_undo_method(probe,"set_extents",restore.pos); + ur->add_undo_method(probe,"set_origin_offset",restore.size); + ur->commit_action(); + +} + +void ReflectionProbeGizmo::redraw(){ + + clear(); + + Vector<Vector3> lines; + Vector<Vector3> internal_lines; + Vector3 extents = probe->get_extents(); + + AABB aabb; + aabb.pos=-extents; + aabb.size=extents*2; + + for(int i=0;i<12;i++) { + Vector3 a,b; + aabb.get_edge(i,a,b); + lines.push_back(a); + lines.push_back(b); + } + + for(int i=0;i<8;i++) { + Vector3 ep = aabb.get_endpoint(i); + internal_lines.push_back(probe->get_origin_offset()); + internal_lines.push_back(ep); + + + } + + Vector<Vector3> handles; + + + for(int i=0;i<3;i++) { + + Vector3 ax; + ax[i]=aabb.pos[i]+aabb.size[i]; + handles.push_back(ax); + } + + for(int i=0;i<3;i++) { + + + Vector3 orig_handle=probe->get_origin_offset(); + orig_handle[i]-=0.25; + lines.push_back(orig_handle); + handles.push_back(orig_handle); + + orig_handle[i]+=0.5; + lines.push_back(orig_handle); + } + + add_lines(lines,SpatialEditorGizmos::singleton->reflection_probe_material); + add_lines(internal_lines,SpatialEditorGizmos::singleton->reflection_probe_material_internal); + //add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05); + add_collision_segments(lines); + add_handles(handles); + +} +ReflectionProbeGizmo::ReflectionProbeGizmo(ReflectionProbe* p_probe){ + + probe=p_probe; + set_spatial_node(p_probe); +} + +//////// + + + +/// + + +String GIProbeGizmo::get_handle_name(int p_idx) const { + + switch(p_idx) { + case 0: return "Extents X"; + case 1: return "Extents Y"; + case 2: return "Extents Z"; + } + + return ""; +} +Variant GIProbeGizmo::get_handle_value(int p_idx) const{ + + return probe->get_extents(); +} +void GIProbeGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){ + + Transform gt = probe->get_global_transform(); + //gt.orthonormalize(); + Transform gi = gt.affine_inverse(); + + + Vector3 extents = probe->get_extents(); + + Vector3 ray_from = p_camera->project_ray_origin(p_point); + Vector3 ray_dir = p_camera->project_ray_normal(p_point); + + Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*16384)}; + + Vector3 axis; + axis[p_idx]=1.0; + + Vector3 ra,rb; + Geometry::get_closest_points_between_segments(Vector3(),axis*16384,sg[0],sg[1],ra,rb); + float d = ra[p_idx]; + if (d<0.001) + d=0.001; + + extents[p_idx]=d; + probe->set_extents(extents); + +} + +void GIProbeGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){ + + Vector3 restore = p_restore; + + if (p_cancel) { + probe->set_extents(restore); + return; + } + + UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Change Probe Extents")); + ur->add_do_method(probe,"set_extents",probe->get_extents()); + ur->add_undo_method(probe,"set_extents",restore); + ur->commit_action(); + +} + +void GIProbeGizmo::redraw(){ + + clear(); + + Vector<Vector3> lines; + Vector3 extents = probe->get_extents(); + + static const int subdivs[GIProbe::SUBDIV_MAX]={64,128,256,512}; + + AABB aabb = AABB(-extents,extents*2); + int subdiv = subdivs[probe->get_subdiv()]; + float cell_size = aabb.get_longest_axis_size()/subdiv; + + + for(int i=0;i<12;i++) { + Vector3 a,b; + aabb.get_edge(i,a,b); + lines.push_back(a); + lines.push_back(b); + } + + add_lines(lines,SpatialEditorGizmos::singleton->gi_probe_material); + add_collision_segments(lines); + + lines.clear(); + + for(int i=1;i<subdiv;i++) { + + for(int j=0;j<3;j++) { + + + + if (cell_size*i>aabb.size[j]) { + continue; + } + + Vector2 dir; + dir[j]=1.0; + Vector2 ta,tb; + int j_n1=(j+1)%3; + int j_n2=(j+2)%3; + ta[j_n1]=1.0; + tb[j_n2]=1.0; + + + for(int k=0;k<4;k++) { + + Vector3 from=aabb.pos,to=aabb.pos; + from[j]+= cell_size*i; + to[j]+=cell_size*i; + + if (k&1) { + to[j_n1]+=aabb.size[j_n1]; + } else { + + to[j_n2]+=aabb.size[j_n2]; + } + + if (k&2) { + from[j_n1]+=aabb.size[j_n1]; + from[j_n2]+=aabb.size[j_n2]; + } + + lines.push_back(from); + lines.push_back(to); + } + + } + + } + + add_lines(lines,SpatialEditorGizmos::singleton->reflection_probe_material_internal); + + Vector<Vector3> handles; + + + for(int i=0;i<3;i++) { + + Vector3 ax; + ax[i]=aabb.pos[i]+aabb.size[i]; + handles.push_back(ax); + } + + + add_handles(handles); + +} +GIProbeGizmo::GIProbeGizmo(GIProbe* p_probe){ + + probe=p_probe; + set_spatial_node(p_probe); +} + +//////// + void NavigationMeshSpatialGizmo::redraw() { @@ -2320,7 +2637,7 @@ void NavigationMeshSpatialGizmo::redraw() { Array a; a.resize(Mesh::ARRAY_MAX); a[0]=tmeshfaces; - m->add_surface(Mesh::PRIMITIVE_TRIANGLES,a); + m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,a); m->surface_set_material(0,navmesh->is_enabled()?SpatialEditorGizmos::singleton->navmesh_solid_material:SpatialEditorGizmos::singleton->navmesh_solid_material_disabled); add_mesh(m); add_collision_segments(lines); @@ -2928,6 +3245,17 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { return misg; } + if (p_spatial->cast_to<ReflectionProbe>()) { + + Ref<ReflectionProbeGizmo> misg = memnew( ReflectionProbeGizmo(p_spatial->cast_to<ReflectionProbe>()) ); + return misg; + } + if (p_spatial->cast_to<GIProbe>()) { + + Ref<GIProbeGizmo> misg = memnew( GIProbeGizmo(p_spatial->cast_to<GIProbe>()) ); + return misg; + } + if (p_spatial->cast_to<VehicleWheel>()) { Ref<VehicleWheelSpatialGizmo> misg = memnew( VehicleWheelSpatialGizmo(p_spatial->cast_to<VehicleWheel>()) ); @@ -2974,25 +3302,26 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { } -Ref<FixedMaterial> SpatialEditorGizmos::create_line_material(const Color& p_base_color) { +Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_line_material(const Color& p_base_color) { - Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); - line_material->set_flag(Material::FLAG_UNSHADED, true); + Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + line_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); - line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,p_base_color); + line_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + //line_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + //->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + line_material->set_albedo(p_base_color); return line_material; } -Ref<FixedMaterial> SpatialEditorGizmos::create_solid_material(const Color& p_base_color) { +Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_solid_material(const Color& p_base_color) { - Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); - line_material->set_flag(Material::FLAG_UNSHADED, true); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,p_base_color); + Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + line_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + line_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + line_material->set_albedo(p_base_color); return line_material; @@ -3002,57 +3331,60 @@ SpatialEditorGizmos::SpatialEditorGizmos() { singleton=this; - handle_material = Ref<FixedMaterial>( memnew( FixedMaterial )); - handle_material->set_flag(Material::FLAG_UNSHADED, true); - handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(0.8,0.8,0.8)); + handle_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + handle_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + handle_material->set_albedo(Color(0.8,0.8,0.8)); - handle2_material = Ref<FixedMaterial>( memnew( FixedMaterial )); - handle2_material->set_flag(Material::FLAG_UNSHADED, true); - handle2_material->set_fixed_flag(FixedMaterial::FLAG_USE_POINT_SIZE, true); + handle2_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + handle2_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + handle2_material->set_flag(FixedSpatialMaterial::FLAG_USE_POINT_SIZE, true); handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons"); handle2_material->set_point_size(handle_t->get_width()); - handle2_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle_t); - handle2_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); - handle2_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - handle2_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); + handle2_material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,handle_t); + handle2_material->set_albedo(Color(1,1,1)); + handle2_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + handle2_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle2_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); light_material = create_line_material(Color(1,1,0.2)); - light_material_omni_icon = Ref<FixedMaterial>( memnew( FixedMaterial )); - light_material_omni_icon->set_flag(Material::FLAG_UNSHADED, true); - light_material_omni_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true); - light_material_omni_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - light_material_omni_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - light_material_omni_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9)); - light_material_omni_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons")); + light_material_omni_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + light_material_omni_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + light_material_omni_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + light_material_omni_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); + light_material_omni_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + light_material_omni_icon->set_albedo(Color(1,1,1,0.9)); + light_material_omni_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons")); - light_material_directional_icon = Ref<FixedMaterial>( memnew( FixedMaterial )); - light_material_directional_icon->set_flag(Material::FLAG_UNSHADED, true); - light_material_directional_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true); - light_material_directional_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - light_material_directional_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - light_material_directional_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9)); - light_material_directional_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons")); + light_material_directional_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + light_material_directional_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + light_material_directional_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + light_material_directional_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); + light_material_directional_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + light_material_directional_icon->set_albedo(Color(1,1,1,0.9)); + light_material_directional_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons")); camera_material = create_line_material(Color(1.0,0.5,1.0)); navmesh_edge_material = create_line_material(Color(0.1,0.8,1.0)); navmesh_solid_material = create_solid_material(Color(0.1,0.8,1.0,0.4)); - navmesh_edge_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false); - navmesh_solid_material->set_flag(Material::FLAG_DOUBLE_SIDED,true); + navmesh_edge_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, false); + navmesh_edge_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, false); + navmesh_solid_material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); navmesh_edge_material_disabled = create_line_material(Color(1.0,0.8,0.1)); navmesh_solid_material_disabled = create_solid_material(Color(1.0,0.8,0.1,0.4)); - navmesh_edge_material_disabled->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false); - navmesh_solid_material_disabled->set_flag(Material::FLAG_DOUBLE_SIDED,true); + navmesh_edge_material_disabled->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, false); + navmesh_edge_material_disabled->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, false); + navmesh_solid_material_disabled->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); skeleton_material = create_line_material(Color(0.6,1.0,0.3)); - skeleton_material->set_flag(Material::FLAG_DOUBLE_SIDED,true); - skeleton_material->set_flag(Material::FLAG_UNSHADED,true); - skeleton_material->set_flag(Material::FLAG_ONTOP,true); - skeleton_material->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); + skeleton_material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + skeleton_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + skeleton_material->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true); + skeleton_material->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); //position 3D Shared mesh @@ -3075,16 +3407,17 @@ SpatialEditorGizmos::SpatialEditorGizmos() { cursor_colors.push_back(Color(0.5,0.5,1,0.7)); cursor_colors.push_back(Color(0.5,0.5,1,0.7)); - Ref<FixedMaterial> mat = memnew( FixedMaterial ); - mat->set_flag(Material::FLAG_UNSHADED,true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); + Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial ); + mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true); + mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true); + mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true); + mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true); mat->set_line_width(3); Array d; d.resize(VS::ARRAY_MAX); d[Mesh::ARRAY_VERTEX]=cursor_points; d[Mesh::ARRAY_COLOR]=cursor_colors; - pos3d_mesh->add_surface(Mesh::PRIMITIVE_LINES,d); + pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,d); pos3d_mesh->surface_set_material(0,mat); } @@ -3098,58 +3431,63 @@ SpatialEditorGizmos::SpatialEditorGizmos() { cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7)); cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7)); - Ref<FixedMaterial> mat = memnew(FixedMaterial); - mat->set_flag(Material::FLAG_UNSHADED, true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); + Ref<FixedSpatialMaterial> mat = memnew(FixedSpatialMaterial); + mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); mat->set_line_width(3); Array d; d.resize(VS::ARRAY_MAX); d[Mesh::ARRAY_VERTEX] = cursor_points; d[Mesh::ARRAY_COLOR] = cursor_colors; - listener_line_mesh->add_surface(Mesh::PRIMITIVE_LINES, d); + listener_line_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d); listener_line_mesh->surface_set_material(0, mat); } - sample_player_icon = Ref<FixedMaterial>( memnew( FixedMaterial )); - sample_player_icon->set_flag(Material::FLAG_UNSHADED, true); - sample_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true); - sample_player_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - sample_player_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - sample_player_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9)); - sample_player_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons")); + sample_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + sample_player_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + sample_player_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + sample_player_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); + sample_player_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + sample_player_icon->set_albedo(Color(1,1,1,0.9)); + sample_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons")); room_material = create_line_material(Color(1.0,0.6,0.9)); portal_material = create_line_material(Color(1.0,0.8,0.6)); raycast_material = create_line_material(Color(1.0,0.8,0.6)); car_wheel_material = create_line_material(Color(0.6,0.8,1.0)); visibility_notifier_material = create_line_material(Color(1.0,0.5,1.0)); + reflection_probe_material = create_line_material(Color(0.5,1.0,0.7)); + reflection_probe_material_internal = create_line_material(Color(0.3,0.8,0.5,0.15)); + gi_probe_material = create_line_material(Color(0.7,1.0,0.5)); + gi_probe_material_internal = create_line_material(Color(0.5,0.8,0.3,0.4)); joint_material = create_line_material(Color(0.6,0.8,1.0)); - stream_player_icon = Ref<FixedMaterial>( memnew( FixedMaterial )); - stream_player_icon->set_flag(Material::FLAG_UNSHADED, true); - stream_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true); - stream_player_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - stream_player_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - stream_player_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9)); - stream_player_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons")); - - visibility_notifier_icon = Ref<FixedMaterial>( memnew( FixedMaterial )); - visibility_notifier_icon->set_flag(Material::FLAG_UNSHADED, true); - visibility_notifier_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true); - visibility_notifier_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - visibility_notifier_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - visibility_notifier_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9)); - visibility_notifier_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons")); - - listener_icon = Ref<FixedMaterial>(memnew(FixedMaterial)); - listener_icon->set_flag(Material::FLAG_UNSHADED, true); - listener_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true); - listener_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - listener_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - listener_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(1, 1, 1, 0.9)); - listener_icon->set_texture(FixedMaterial::PARAM_DIFFUSE, SpatialEditor::get_singleton()->get_icon("GizmoListener", "EditorIcons")); + stream_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + stream_player_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + stream_player_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + stream_player_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); + stream_player_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + stream_player_icon->set_albedo(Color(1,1,1,0.9)); + stream_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons")); + + visibility_notifier_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); + visibility_notifier_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + visibility_notifier_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + visibility_notifier_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); + visibility_notifier_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + visibility_notifier_icon->set_albedo(Color(1,1,1,0.9)); + visibility_notifier_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons")); + + listener_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial)); + listener_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true); + listener_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED); + listener_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED); + listener_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true); + listener_icon->set_albedo( Color(1, 1, 1, 0.9)); + listener_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoListener", "EditorIcons")); { @@ -3198,3 +3536,4 @@ SpatialEditorGizmos::SpatialEditorGizmos() { } + diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h index c3f38f61af..d6bdb39481 100644 --- a/tools/editor/spatial_editor_gizmos.h +++ b/tools/editor/spatial_editor_gizmos.h @@ -45,6 +45,8 @@ #include "scene/3d/portal.h" #include "scene/3d/ray_cast.h" #include "scene/3d/navigation_mesh.h" +#include "scene/3d/reflection_probe.h" +#include "scene/3d/gi_probe.h" #include "scene/3d/vehicle_body.h" #include "scene/3d/collision_polygon.h" @@ -307,6 +309,44 @@ public: }; +class ReflectionProbeGizmo : public EditorSpatialGizmo { + + OBJ_TYPE(ReflectionProbeGizmo ,EditorSpatialGizmo); + + + ReflectionProbe* probe; + +public: + + virtual String get_handle_name(int p_idx) const; + virtual Variant get_handle_value(int p_idx) const; + virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point); + virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false); + + void redraw(); + ReflectionProbeGizmo(ReflectionProbe* p_notifier=NULL); + +}; + +class GIProbeGizmo : public EditorSpatialGizmo { + + OBJ_TYPE(GIProbeGizmo ,EditorSpatialGizmo); + + + GIProbe* probe; + +public: + + virtual String get_handle_name(int p_idx) const; + virtual Variant get_handle_value(int p_idx) const; + virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point); + virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false); + + void redraw(); + GIProbeGizmo(GIProbe* p_notifier=NULL); + +}; + class CollisionShapeSpatialGizmo : public EditorSpatialGizmo { @@ -339,6 +379,7 @@ public: }; + class RayCastSpatialGizmo : public EditorSpatialGizmo { OBJ_TYPE(RayCastSpatialGizmo,EditorSpatialGizmo); @@ -464,34 +505,38 @@ public: class SpatialEditorGizmos { public: - Ref<FixedMaterial> create_line_material(const Color& p_base_color); - Ref<FixedMaterial> create_solid_material(const Color& p_base_color); - Ref<FixedMaterial> handle2_material; - Ref<FixedMaterial> handle_material; - Ref<FixedMaterial> light_material; - Ref<FixedMaterial> light_material_omni_icon; - Ref<FixedMaterial> light_material_directional_icon; - Ref<FixedMaterial> camera_material; - Ref<FixedMaterial> skeleton_material; - Ref<FixedMaterial> room_material; - Ref<FixedMaterial> portal_material; - Ref<FixedMaterial> raycast_material; - Ref<FixedMaterial> visibility_notifier_material; - Ref<FixedMaterial> car_wheel_material; - Ref<FixedMaterial> joint_material; - - Ref<FixedMaterial> navmesh_edge_material; - Ref<FixedMaterial> navmesh_solid_material; - Ref<FixedMaterial> navmesh_edge_material_disabled; - Ref<FixedMaterial> navmesh_solid_material_disabled; - - Ref<FixedMaterial> listener_icon; - - Ref<FixedMaterial> sample_player_icon; - Ref<FixedMaterial> stream_player_icon; - Ref<FixedMaterial> visibility_notifier_icon; - - Ref<FixedMaterial> shape_material; + Ref<FixedSpatialMaterial> create_line_material(const Color& p_base_color); + Ref<FixedSpatialMaterial> create_solid_material(const Color& p_base_color); + Ref<FixedSpatialMaterial> handle2_material; + Ref<FixedSpatialMaterial> handle_material; + Ref<FixedSpatialMaterial> light_material; + Ref<FixedSpatialMaterial> light_material_omni_icon; + Ref<FixedSpatialMaterial> light_material_directional_icon; + Ref<FixedSpatialMaterial> camera_material; + Ref<FixedSpatialMaterial> skeleton_material; + Ref<FixedSpatialMaterial> reflection_probe_material; + Ref<FixedSpatialMaterial> reflection_probe_material_internal; + Ref<FixedSpatialMaterial> gi_probe_material; + Ref<FixedSpatialMaterial> gi_probe_material_internal; + Ref<FixedSpatialMaterial> room_material; + Ref<FixedSpatialMaterial> portal_material; + Ref<FixedSpatialMaterial> raycast_material; + Ref<FixedSpatialMaterial> visibility_notifier_material; + Ref<FixedSpatialMaterial> car_wheel_material; + Ref<FixedSpatialMaterial> joint_material; + + Ref<FixedSpatialMaterial> navmesh_edge_material; + Ref<FixedSpatialMaterial> navmesh_solid_material; + Ref<FixedSpatialMaterial> navmesh_edge_material_disabled; + Ref<FixedSpatialMaterial> navmesh_solid_material_disabled; + + Ref<FixedSpatialMaterial> listener_icon; + + Ref<FixedSpatialMaterial> sample_player_icon; + Ref<FixedSpatialMaterial> stream_player_icon; + Ref<FixedSpatialMaterial> visibility_notifier_icon; + + Ref<FixedSpatialMaterial> shape_material; Ref<Texture> handle_t; Ref<Mesh> pos3d_mesh; @@ -505,5 +550,4 @@ public: SpatialEditorGizmos(); }; - #endif // SPATIAL_EDITOR_GIZMOS_H |