diff options
-rw-r--r-- | core/math/aabb.h | 18 | ||||
-rw-r--r-- | core/math/octree.h | 12 | ||||
-rw-r--r-- | core/ustring.cpp | 31 | ||||
-rw-r--r-- | core/ustring.h | 2 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 29 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 3 |
6 files changed, 69 insertions, 26 deletions
diff --git a/core/math/aabb.h b/core/math/aabb.h index 7c9c3081ac..0fada859c0 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -66,6 +66,7 @@ public: bool operator!=(const AABB& p_rval) const; _FORCE_INLINE_ bool intersects(const AABB& p_aabb) const; /// Both AABBs overlap + _FORCE_INLINE_ bool intersects_inclusive(const AABB& p_aabb) const; /// Both AABBs (or their faces) overlap _FORCE_INLINE_ bool encloses(const AABB & p_aabb) const; /// p_aabb is completely inside this AABB merge(const AABB& p_with) const; @@ -126,6 +127,23 @@ inline bool AABB::intersects(const AABB& p_aabb) const { return true; } +inline bool AABB::intersects_inclusive(const AABB& p_aabb) const { + + if ( pos.x > (p_aabb.pos.x + p_aabb.size.x) ) + return false; + if ( (pos.x+size.x) < p_aabb.pos.x ) + return false; + if ( pos.y > (p_aabb.pos.y + p_aabb.size.y) ) + return false; + if ( (pos.y+size.y) < p_aabb.pos.y ) + return false; + if ( pos.z > (p_aabb.pos.z + p_aabb.size.z) ) + return false; + if ( (pos.z+size.z) < p_aabb.pos.z ) + return false; + + return true; +} inline bool AABB::encloses(const AABB & p_aabb) const { diff --git a/core/math/octree.h b/core/math/octree.h index b51c4bcba7..69edf80e09 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -201,7 +201,7 @@ private: _FORCE_INLINE_ void _pair_check(PairData *p_pair) { - bool intersect=p_pair->A->aabb.intersects( p_pair->B->aabb ); + bool intersect=p_pair->A->aabb.intersects_inclusive( p_pair->B->aabb ); if (intersect!=p_pair->intersect) { @@ -480,7 +480,7 @@ void Octree<T,use_pairs,AL>::_insert_element(Element *p_element,Octant *p_octant if (p_octant->children[i]) { /* element exists, go straight to it */ - if (p_octant->children[i]->aabb.intersects( p_element->aabb ) ) { + if (p_octant->children[i]->aabb.intersects_inclusive( p_element->aabb ) ) { _insert_element( p_element, p_octant->children[i] ); splits++; } @@ -497,7 +497,7 @@ void Octree<T,use_pairs,AL>::_insert_element(Element *p_element,Octant *p_octant if (i&4) aabb.pos.z+=aabb.size.z; - if (aabb.intersects( p_element->aabb) ) { + if (aabb.intersects_inclusive( p_element->aabb) ) { /* if actually intersects, create the child */ Octant *child = memnew_allocator( Octant, AL ); @@ -1146,7 +1146,7 @@ void Octree<T,use_pairs,AL>::_cull_AABB(Octant *p_octant,const AABB& p_aabb, T** continue; e->last_pass=pass; - if (p_aabb.intersects(e->aabb)) { + if (p_aabb.intersects_inclusive(e->aabb)) { if (*p_result_idx<p_result_max) { @@ -1175,7 +1175,7 @@ void Octree<T,use_pairs,AL>::_cull_AABB(Octant *p_octant,const AABB& p_aabb, T** continue; e->last_pass=pass; - if (p_aabb.intersects(e->aabb)) { + if (p_aabb.intersects_inclusive(e->aabb)) { if (*p_result_idx<p_result_max) { @@ -1193,7 +1193,7 @@ void Octree<T,use_pairs,AL>::_cull_AABB(Octant *p_octant,const AABB& p_aabb, T** for (int i=0;i<8;i++) { - if (p_octant->children[i] && p_octant->children[i]->aabb.intersects(p_aabb)) { + if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_inclusive(p_aabb)) { _cull_AABB(p_octant->children[i],p_aabb, p_result_array,p_result_idx,p_result_max,p_subindex_array,p_mask); } } diff --git a/core/ustring.cpp b/core/ustring.cpp index ee750c39e5..1017fc0ca3 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -507,26 +507,35 @@ String String::capitalize() const { return cap; } -String String::camelcase_to_underscore() const { +String String::camelcase_to_underscore(bool lowercase) const { const CharType * cstr = c_str(); - String newString; + String new_string; const char A = 'A', Z = 'Z'; - int startIndex = 0; + const char a = 'a', z = 'z'; + int start_index = 0; - for ( int i = 1; i < this->size()-1; i++ ) { - bool isCapital = cstr[i] >= A && cstr[i] <= Z; + for ( size_t i = 1; i < this->size(); i++ ) { + bool is_upper = cstr[i] >= A && cstr[i] <= Z; + bool are_next_2_lower = false; + bool was_precedent_upper = cstr[i-1] >= A && cstr[i-1] <= Z; - if ( isCapital ) { - newString += "_" + this->substr(startIndex, i-startIndex); - startIndex = i; + if (i+2 < this->size()) { + are_next_2_lower = cstr[i+1] >= a && cstr[i+1] <= z && cstr[i+2] >= a && cstr[i+2] <= z; } - } - newString += "_" + this->substr(startIndex, this->size()-startIndex); + bool should_split = ((is_upper && !was_precedent_upper) || (was_precedent_upper && is_upper && are_next_2_lower)); + if (should_split) { + new_string += this->substr(start_index, i - start_index) + "_"; + start_index = i; + } + } - return newString; + new_string += this->substr(start_index, this->size() - start_index); + return lowercase ? new_string.to_lower() : new_string; } + + int String::get_slice_count(String p_splitter) const{ if (empty()) diff --git a/core/ustring.h b/core/ustring.h index 9276afa0f7..e65103ff99 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -149,7 +149,7 @@ public: static double to_double(const CharType* p_str, const CharType **r_end=NULL); static int64_t to_int(const CharType* p_str,int p_len=-1); String capitalize() const; - String camelcase_to_underscore() const; + String camelcase_to_underscore(bool lowercase=true) const; int get_slice_count(String p_splitter) const; String get_slice(String p_splitter,int p_slice) const; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b39a1b5350..382cf76181 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -1795,6 +1795,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) { //pause_button->set_pressed(false); play_scene_button->set_pressed(false); play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons")); + play_custom_scene_button->set_pressed(false); + play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons")); String current_filename; String run_filename; @@ -1804,7 +1806,6 @@ void EditorNode::_run(bool p_current,const String& p_custom) { if (p_current || (editor_data.get_edited_scene_root() && p_custom==editor_data.get_edited_scene_root()->get_filename())) { - Node *scene = editor_data.get_edited_scene_root(); if (!scene) { @@ -1913,6 +1914,10 @@ void EditorNode::_run(bool p_current,const String& p_custom) { if (p_current) { play_scene_button->set_pressed(true); play_scene_button->set_icon(gui_base->get_icon("Reload","EditorIcons")); + } else if (p_custom!="") { + run_custom_filename=run_filename; + play_custom_scene_button->set_pressed(true); + play_custom_scene_button->set_icon(gui_base->get_icon("Reload","EditorIcons")); } else { play_button->set_pressed(true); play_button->set_icon(gui_base->get_icon("Reload","EditorIcons")); @@ -2595,9 +2600,15 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case RUN_PLAY_CUSTOM_SCENE: { - _menu_option_confirm(RUN_STOP,true); - quick_run->popup("PackedScene",true); - quick_run->set_title("Quick Run Scene.."); + if (run_custom_filename.empty() || editor_run.get_status()==EditorRun::STATUS_STOP) { + _menu_option_confirm(RUN_STOP,true); + quick_run->popup("PackedScene",true); + quick_run->set_title("Quick Run Scene.."); + } else { + String last_custom_scene=run_custom_filename; + _menu_option_confirm(RUN_STOP,true); + _run(false,last_custom_scene); + } } break; case RUN_PAUSE: { @@ -2611,10 +2622,13 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { break; editor_run.stop(); + run_custom_filename.clear(); play_button->set_pressed(false); play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons")); play_scene_button->set_pressed(false); play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons")); + play_custom_scene_button->set_pressed(false); + play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons")); //pause_button->set_pressed(false); emit_signal("stop_pressed"); @@ -3843,9 +3857,9 @@ void EditorNode::_quick_opened() { } } -void EditorNode::_quick_run(const String& p_resource) { +void EditorNode::_quick_run() { - _run(false,p_resource); + _run(false,quick_run->get_selected()); } @@ -5866,7 +5880,8 @@ EditorNode::EditorNode() { // Ref<EditorSceneImporterFBXConv> _fbxconv_import = memnew( EditorSceneImporterFBXConv); // _scene_import->add_importer(_fbxconv_import); editor_import_export->add_import_plugin( _scene_import); - editor_import_export->add_import_plugin( Ref<EditorSceneAnimationImportPlugin>( memnew(EditorSceneAnimationImportPlugin(this)))); + // TODO: This plugin has no code, it should be either implemented or dropped (GH-3667) + // editor_import_export->add_import_plugin( Ref<EditorSceneAnimationImportPlugin>( memnew(EditorSceneAnimationImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorMeshImportPlugin>( memnew(EditorMeshImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorFontImportPlugin>( memnew(EditorFontImportPlugin(this)))); editor_import_export->add_import_plugin( Ref<EditorSampleImportPlugin>( memnew(EditorSampleImportPlugin(this)))); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index a8aa6ac1f4..a83555d6e8 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -355,6 +355,7 @@ class EditorNode : public Node { Object *current; bool _playing_edited; + String run_custom_filename; bool reference_resource_mem; bool save_external_resources_mem; uint64_t saved_version; @@ -447,7 +448,7 @@ class EditorNode : public Node { void _hide_top_editors(); void _quick_opened(); - void _quick_run(const String& p_resource); + void _quick_run(); void _run(bool p_current=false, const String &p_custom=""); |