diff options
Diffstat (limited to 'scene/resources')
28 files changed, 445 insertions, 445 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index e8bd6c14ad..f7d5ddc744 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -41,33 +41,33 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { else if (name=="step") set_step(p_value); else if (name.begins_with("tracks/")) { - + int track=name.get_slicec('/',1).to_int(); String what=name.get_slicec('/',2); if (tracks.size()==track && what=="type") { - + String type=p_value; - + if (type=="transform") { - + add_track(TYPE_TRANSFORM); } else if (type=="value") { - + add_track(TYPE_VALUE); } else if (type=="method") { - + add_track(TYPE_METHOD); } else { - + return false; } - + return true; } - + ERR_FAIL_INDEX_V( track, tracks.size(),false ); - + if (what=="path") track_set_path(track,p_value); else if (what=="interp") @@ -261,10 +261,10 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { String what=name.get_slicec('/',2); ERR_FAIL_INDEX_V( track, tracks.size(), false ); if (what=="type") { - - + + switch (track_get_type(track)) { - + case TYPE_TRANSFORM: r_ret= "transform"; break; case TYPE_VALUE: r_ret= "value";break; case TYPE_METHOD: r_ret= "method";break; @@ -281,7 +281,7 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { if (track_get_type(track)==TYPE_TRANSFORM) { DVector<real_t> keys; - int kk=track_get_key_count(track); + int kk=track_get_key_count(track); keys.resize(kk*12); DVector<real_t>::Write w = keys.write(); @@ -406,7 +406,7 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { return false; } else return false; - + return true; } @@ -415,11 +415,11 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { void Animation::_get_property_list( List<PropertyInfo> *p_list) const { p_list->push_back( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_RANGE, "0.001,99999,0.001")); - p_list->push_back( PropertyInfo( Variant::BOOL, "loop" )); + p_list->push_back( PropertyInfo( Variant::BOOL, "loop" )); p_list->push_back( PropertyInfo( Variant::REAL, "step", PROPERTY_HINT_RANGE, "0,4096,0.001" )); for (int i=0;i<tracks.size();i++) { - + p_list->push_back( PropertyInfo( Variant::STRING, "tracks/"+itos(i)+"/type", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) ); p_list->push_back( PropertyInfo( Variant::NODE_PATH, "tracks/"+itos(i)+"/path", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) ); p_list->push_back( PropertyInfo( Variant::INT, "tracks/"+itos(i)+"/interp", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) ); @@ -433,24 +433,24 @@ int Animation::add_track(TrackType p_type,int p_at_pos) { p_at_pos=tracks.size(); switch( p_type ) { - + case TYPE_TRANSFORM: { - + TransformTrack *tt = memnew( TransformTrack ); tracks.insert( p_at_pos,tt ); } break; case TYPE_VALUE: { - + tracks.insert( p_at_pos,memnew( ValueTrack ) ); - + } break; case TYPE_METHOD: { - + tracks.insert( p_at_pos,memnew( MethodTrack ) ); - + } break; default: { - + ERR_PRINT("Unknown track type"); } } @@ -462,29 +462,29 @@ void Animation::remove_track(int p_track) { ERR_FAIL_INDEX(p_track, tracks.size()); Track *t=tracks[p_track]; - + switch(t->type) { - + case TYPE_TRANSFORM: { - + TransformTrack * tt = static_cast<TransformTrack*>(t); _clear(tt->transforms); - + } break; case TYPE_VALUE: { - - ValueTrack * vt = static_cast<ValueTrack*>(t); + + ValueTrack * vt = static_cast<ValueTrack*>(t); _clear(vt->values); - + } break; case TYPE_METHOD: { - + MethodTrack * mt = static_cast<MethodTrack*>(t); _clear(mt->methods); - - } break; - } - + + } break; + } + memdelete( t ); tracks.remove(p_track); emit_changed(); @@ -548,30 +548,30 @@ template<class T> int Animation::_insert_pos(float p_time, T& p_keys) { // simple, linear time inset that should be fast enough in reality. - + int idx=p_keys.size(); - + while(true) { - - + + if (idx==0 || p_keys[idx-1].time < p_time) { //condition for insertion. p_keys.insert(idx,T()); return idx; } else if (p_keys[idx-1].time == p_time) { - + // condition for replacing. return idx-1; - } - + } + idx--; } - + } */ template<class T, class V> int Animation::_insert(float p_time, T& p_keys, const V& p_value) { - + int idx=p_keys.size(); while(true) { @@ -597,7 +597,7 @@ int Animation::_insert(float p_time, T& p_keys, const V& p_value) { template<class T> void Animation::_clear(T& p_keys) { - + p_keys.clear(); } @@ -727,11 +727,11 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant& p_val ERR_FAIL_INDEX(p_track, tracks.size()); Track *t=tracks[p_track]; - + switch(t->type) { - + case TYPE_TRANSFORM: { - + Dictionary d = p_value; Vector3 loc; if (d.has("loc")) @@ -750,36 +750,36 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant& p_val } break; case TYPE_VALUE: { - + ValueTrack * vt = static_cast<ValueTrack*>(t); - + TKey<Variant> k; k.time=p_time; k.transition=p_transition; k.value=p_value; _insert( p_time, vt->values, k ); - + } break; case TYPE_METHOD: { - + MethodTrack * mt = static_cast<MethodTrack*>(t); - + ERR_FAIL_COND( p_value.get_type() != Variant::DICTIONARY ); - + Dictionary d=p_value; ERR_FAIL_COND(!d.has("method") || d["method"].get_type()!=Variant::STRING); ERR_FAIL_COND(!d.has("args") || !d["args"].is_array()); MethodKey k; - + k.time=p_time; k.transition=p_transition; k.method=d["method"]; k.params=d["args"]; _insert( p_time, mt->methods, k ); - - } break; + + } break; } @@ -790,27 +790,27 @@ int Animation::track_get_key_count(int p_track) const { ERR_FAIL_INDEX_V(p_track, tracks.size(),-1); Track *t=tracks[p_track]; - + switch(t->type) { - + case TYPE_TRANSFORM: { - + TransformTrack * tt = static_cast<TransformTrack*>(t); return tt->transforms.size(); } break; case TYPE_VALUE: { - + ValueTrack * vt = static_cast<ValueTrack*>(t); return vt->values.size(); - + } break; case TYPE_METHOD: { - + MethodTrack * mt = static_cast<MethodTrack*>(t); return mt->methods.size(); - } break; + } break; } - + ERR_FAIL_V(-1); } @@ -818,11 +818,11 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const { ERR_FAIL_INDEX_V(p_track, tracks.size(), Variant()); Track *t=tracks[p_track]; - + switch(t->type) { - + case TYPE_TRANSFORM: { - + TransformTrack * tt = static_cast<TransformTrack*>(t); ERR_FAIL_INDEX_V( p_key_idx, tt->transforms.size(), Variant() ); @@ -834,25 +834,25 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const { return d; } break; case TYPE_VALUE: { - - ValueTrack * vt = static_cast<ValueTrack*>(t); + + ValueTrack * vt = static_cast<ValueTrack*>(t); ERR_FAIL_INDEX_V( p_key_idx, vt->values.size(), Variant() ); return vt->values[p_key_idx].value; } break; case TYPE_METHOD: { - + MethodTrack * mt = static_cast<MethodTrack*>(t); ERR_FAIL_INDEX_V( p_key_idx, mt->methods.size(), Variant() ); Dictionary d; d["method"]=mt->methods[p_key_idx].method; d["args"]=mt->methods[p_key_idx].params; - return d; - - } break; + return d; + + } break; } - + ERR_FAIL_V(Variant()); } @@ -860,33 +860,33 @@ float Animation::track_get_key_time(int p_track, int p_key_idx) const { ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); Track *t=tracks[p_track]; - + switch(t->type) { - + case TYPE_TRANSFORM: { - + TransformTrack * tt = static_cast<TransformTrack*>(t); ERR_FAIL_INDEX_V( p_key_idx, tt->transforms.size(), -1 ); return tt->transforms[p_key_idx].time; } break; case TYPE_VALUE: { - - ValueTrack * vt = static_cast<ValueTrack*>(t); + + ValueTrack * vt = static_cast<ValueTrack*>(t); ERR_FAIL_INDEX_V( p_key_idx, vt->values.size(), -1 ); return vt->values[p_key_idx].time; - + } break; case TYPE_METHOD: { - + MethodTrack * mt = static_cast<MethodTrack*>(t); ERR_FAIL_INDEX_V( p_key_idx, mt->methods.size(), -1 ); return mt->methods[p_key_idx].time; - - - } break; + + + } break; } - + ERR_FAIL_V(-1); } @@ -1004,19 +1004,19 @@ void Animation::track_set_key_transition(int p_track, int p_key_idx,float p_tran template<class K> int Animation::_find( const Vector<K>& p_keys, float p_time) const { - + int len=p_keys.size(); if (len==0) return -2; - + int low = 0; int high = len -1; int middle; - + const K* keys =&p_keys[0]; - + while( low <= high ) { - + middle = ( low + high ) / 2; if( p_time == keys[ middle ].time ) { //match @@ -1029,7 +1029,7 @@ int Animation::_find( const Vector<K>& p_keys, float p_time) const { if (keys[middle].time>p_time) middle--; - + return middle; } @@ -1197,58 +1197,58 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter int len=_find( p_keys, length )+1; // try to find last key (there may be more past the end) - if (len<=0) { + if (len<=0) { // (-1 or -2 returned originally) (plus one above) // meaning no keys, or only key time is larger than length if (p_ok) *p_ok=false; return T(); } else if (len==1) { // one key found (0+1), return it - + if (p_ok) *p_ok=true; return p_keys[0].value; } - + int idx=_find(p_keys, p_time); - + ERR_FAIL_COND_V( idx==-2, T()); - + if (p_ok) *p_ok=true; int next=0; - float c=0; + float c=0; // prepare for all cases of interpolation - + if (loop) { // loop if (idx>=0) { - + if ((idx+1) < len) { - + next=idx+1; float delta=p_keys[next].time - p_keys[idx].time; float from=p_time-p_keys[idx].time; if (Math::absf(delta)>CMP_EPSILON) c=from/delta; - else + else c=0; - + } else { - + next=0; float delta=(length - p_keys[idx].time) + p_keys[next].time; float from=p_time-p_keys[idx].time; - + if (Math::absf(delta)>CMP_EPSILON) - c=from/delta; - else + c=from/delta; + else c=0; - + } - + } else { // on loop, behind first key idx=len-1; @@ -1258,47 +1258,47 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter endtime=0; float delta=endtime + p_keys[next].time; float from=endtime+p_time; - + if (Math::absf(delta)>CMP_EPSILON) - c=from/delta; - else + c=from/delta; + else c=0; - } - - } else { // no loop + } + + } else { // no loop if (idx>=0) { - + if ((idx+1) < len) { - + next=idx+1; float delta=p_keys[next].time - p_keys[idx].time; float from=p_time - p_keys[idx].time; - + if (Math::absf(delta)>CMP_EPSILON) c=from/delta; else c=0; - + } else { - + next=idx; } - + } else if (idx<0) { - + idx=next=0; - } - + } + } - + float tr = p_keys[idx].transition; if (tr==0 || idx==next) { // don't interpolate if not needed return p_keys[idx].value; } - + if (tr!=1.0) { c = Math::ease(c,tr); @@ -1331,7 +1331,7 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter // do a barrel roll - + } @@ -1340,7 +1340,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3 ERR_FAIL_INDEX_V(p_track, tracks.size(),ERR_INVALID_PARAMETER); Track *t=tracks[p_track]; ERR_FAIL_COND_V(t->type!=TYPE_TRANSFORM,ERR_INVALID_PARAMETER); - + TransformTrack * tt = static_cast<TransformTrack*>(t); bool ok; @@ -1368,7 +1368,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const { ERR_FAIL_INDEX_V(p_track, tracks.size(),0); Track *t=tracks[p_track]; ERR_FAIL_COND_V(t->type!=TYPE_VALUE, Variant()); - ValueTrack * vt = static_cast<ValueTrack*>(t); + ValueTrack * vt = static_cast<ValueTrack*>(t); bool ok; @@ -1377,7 +1377,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const { if (ok) { - + return res; } @@ -1426,15 +1426,15 @@ void Animation::value_track_get_key_indices(int p_track, float p_time, float p_d float from_time=p_time-p_delta; float to_time=p_time; - + if (from_time>to_time) SWAP(from_time,to_time); - + if (loop) { - - from_time=Math::fposmod(from_time,length); - to_time=Math::fposmod(to_time,length); - + + from_time=Math::fposmod(from_time,length); + to_time=Math::fposmod(to_time,length); + if (from_time>to_time) { // handle loop by splitting _value_track_get_key_indices_in_range(vt,length-from_time,length,p_indices); @@ -1442,12 +1442,12 @@ void Animation::value_track_get_key_indices(int p_track, float p_time, float p_d return; } } else { - + if (from_time<0) from_time=0; if (from_time>length) from_time=length; - + if (to_time<0) to_time=0; if (to_time>length) @@ -1455,10 +1455,10 @@ void Animation::value_track_get_key_indices(int p_track, float p_time, float p_d } - + _value_track_get_key_indices_in_range(vt,from_time,to_time,p_indices); - + } void Animation::value_track_set_continuous(int p_track, bool p_continuous) { @@ -1519,19 +1519,19 @@ void Animation::_method_track_get_key_indices_in_range(const MethodTrack * mt, f void Animation::method_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const { ERR_FAIL_INDEX(p_track, tracks.size()); - Track *t=tracks[p_track]; + Track *t=tracks[p_track]; ERR_FAIL_COND( t->type != TYPE_METHOD ); MethodTrack * mt = static_cast<MethodTrack*>(t); float from_time=p_time-p_delta; float to_time=p_time; - + if (from_time>to_time) SWAP(from_time,to_time); - + if (loop) { - + if (from_time > length || from_time < 0) from_time=Math::fposmod(from_time,length); @@ -1545,19 +1545,19 @@ void Animation::method_track_get_key_indices(int p_track, float p_time, float p_ return; } } else { - + if (from_time<0) from_time=0; if (from_time>length) from_time=length; - + if (to_time<0) to_time=0; if (to_time>length) to_time=length; - + } - + _method_track_get_key_indices_in_range(mt,from_time,to_time,p_indices); @@ -1569,9 +1569,9 @@ Vector<Variant> Animation::method_track_get_params(int p_track,int p_key_idx) co ERR_FAIL_COND_V( t->type != TYPE_METHOD, Vector<Variant>() ); MethodTrack * pm = static_cast<MethodTrack*>(t); - + ERR_FAIL_INDEX_V( p_key_idx, pm->methods.size(), Vector<Variant>() ); - + const MethodKey& mk=pm->methods[p_key_idx]; return mk.params; @@ -1583,9 +1583,9 @@ StringName Animation::method_track_get_name(int p_track,int p_key_idx) const { ERR_FAIL_COND_V( t->type != TYPE_METHOD, StringName() ); MethodTrack * pm = static_cast<MethodTrack*>(t); - + ERR_FAIL_INDEX_V( p_key_idx, pm->methods.size(), StringName() ); - + return pm->methods[ p_key_idx ].method; } @@ -1600,7 +1600,7 @@ void Animation::set_length(float p_length) { float Animation::get_length() const { return length; -} +} void Animation::set_loop(bool p_enabled) { @@ -1678,16 +1678,16 @@ void Animation::_bind_methods() { ObjectTypeDB::bind_method(_MD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate); ObjectTypeDB::bind_method(_MD("value_track_set_continuous","idx","continuous"),&Animation::value_track_set_continuous); ObjectTypeDB::bind_method(_MD("value_track_is_continuous","idx"),&Animation::value_track_is_continuous); - + ObjectTypeDB::bind_method(_MD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices); ObjectTypeDB::bind_method(_MD("method_track_get_key_indices","idx","time_sec","delta"),&Animation::_method_track_get_key_indices); ObjectTypeDB::bind_method(_MD("method_track_get_name","idx","key_idx"),&Animation::method_track_get_name); ObjectTypeDB::bind_method(_MD("method_track_get_params","idx","key_idx"),&Animation::method_track_get_params); - + ObjectTypeDB::bind_method(_MD("set_length","time_sec"),&Animation::set_length); ObjectTypeDB::bind_method(_MD("get_length"),&Animation::get_length); - + ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop); ObjectTypeDB::bind_method(_MD("has_loop"),&Animation::has_loop); @@ -1699,7 +1699,7 @@ void Animation::_bind_methods() { BIND_CONSTANT( TYPE_VALUE ); BIND_CONSTANT( TYPE_TRANSFORM ); BIND_CONSTANT( TYPE_METHOD ); - + BIND_CONSTANT( INTERPOLATION_NEAREST ); BIND_CONSTANT( INTERPOLATION_LINEAR ); BIND_CONSTANT( INTERPOLATION_CUBIC ); diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 405b8b6a05..1f2d9b80ab 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -61,7 +61,7 @@ public: private: struct Track { - + TrackType type; InterpolationType interpolation; NodePath path; // path to something @@ -70,20 +70,20 @@ private: }; struct Key { - + float transition; - float time; // time in secs + float time; // time in secs Key() { transition=1; } }; - + // transform key holds either Vector3 or Quaternion template<class T> struct TKey : public Key { - + float time; T value; }; - + struct TransformKey { @@ -93,45 +93,45 @@ private: }; /* TRANSFORM TRACK */ - + struct TransformTrack : public Track { Vector< TKey<TransformKey> > transforms; - + TransformTrack() { type=TYPE_TRANSFORM; } }; - + /* PROPERTY VALUE TRACK */ struct ValueTrack : public Track { bool continuous; Vector< TKey<Variant> > values; - + ValueTrack() { type=TYPE_VALUE; continuous=true; } }; /* METHOD TRACK */ - + struct MethodKey : public Key { - + StringName method; Vector<Variant> params; }; - + struct MethodTrack : public Track { - + Vector< MethodKey > methods; MethodTrack() { type=TYPE_METHOD; } - }; - + }; + Vector<Track*> tracks; /* template<class T> int _insert_pos(float p_time, T& p_keys);*/ - + template<class T> void _clear(T& p_keys); @@ -140,7 +140,7 @@ private: template<class K> inline int _find( const Vector<K>& p_keys, float p_time) const; - + _FORCE_INLINE_ Animation::TransformKey _interpolate( const Animation::TransformKey& p_a, const Animation::TransformKey& p_b, float p_c) const; _FORCE_INLINE_ Vector3 _interpolate( const Vector3& p_a, const Vector3& p_b, float p_c) const; @@ -163,9 +163,9 @@ private: float length; float step; bool loop; - + // bind helpers -private: +private: Array _transform_track_interpolate(int p_track, float p_time) const { Vector3 loc; @@ -180,25 +180,25 @@ private: } DVector<int> _value_track_get_key_indices(int p_track, float p_time, float p_delta) const { - + List<int> idxs; value_track_get_key_indices(p_track,p_time,p_delta,&idxs); DVector<int> idxr; - + for (List<int>::Element *E=idxs.front();E;E=E->next()) { - + idxr.push_back(E->get()); } return idxr; } DVector<int> _method_track_get_key_indices(int p_track, float p_time, float p_delta) const { - + List<int> idxs; method_track_get_key_indices(p_track,p_time,p_delta,&idxs); DVector<int> idxr; - + for (List<int>::Element *E=idxs.front();E;E=E->next()) { - + idxr.push_back(E->get()); } return idxr; @@ -207,28 +207,28 @@ private: bool _transform_track_optimize_key(const TKey<TransformKey> &t0,const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle,const Vector3& p_norm); void _transform_track_optimize(int p_idx, float p_allowed_err=0.05, float p_alowed_angular_err=0.01,float p_max_optimizable_angle=Math_PI*0.125); -protected: +protected: bool _set(const StringName& p_name, const Variant& p_value); bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list( List<PropertyInfo> *p_list) const; - - static void _bind_methods(); - + + static void _bind_methods(); + public: - + int add_track(TrackType p_type,int p_at_pos=-1); void remove_track(int p_track); int get_track_count() const; TrackType track_get_type(int p_track) const; - + void track_set_path(int p_track,const NodePath& p_path); NodePath track_get_path(int p_track) const; int find_track(const NodePath& p_path) const; // transform - + void track_move_up(int p_track); void track_move_down(int p_track); @@ -248,9 +248,9 @@ public: void track_set_interpolation_type(int p_track,InterpolationType p_interp); InterpolationType track_get_interpolation_type(int p_track) const; - + Error transform_track_interpolate(int p_track, float p_time, Vector3 * r_loc, Quat *r_rot, Vector3 *r_scale) const; - + Variant value_track_interpolate(int p_track, float p_time) const; void value_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const; void value_track_set_continuous(int p_track, bool p_continuous); @@ -259,11 +259,11 @@ public: void method_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const; Vector<Variant> method_track_get_params(int p_track,int p_key_idx) const; StringName method_track_get_name(int p_track,int p_key_idx) const; - + void set_length(float p_length); float get_length() const; - + void set_loop(bool p_enabled); bool has_loop() const; @@ -274,7 +274,7 @@ public: void optimize(float p_allowed_linear_err=0.05,float p_allowed_angular_err=0.01,float p_max_optimizable_angle=Math_PI*0.125); - Animation(); + Animation(); ~Animation(); }; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index ea0dbc43e3..7158d067cf 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -558,10 +558,10 @@ void make_default_theme() { t->set_constant("close_v_ofs","WindowDialog", 20 ); t->set_constant("titlebar_height","WindowDialog", 18 ); t->set_constant("title_height","WindowDialog", 20 ); - - + + // File Dialog - + t->set_icon("reload","FileDialog",make_icon( icon_reload_png )); @@ -784,7 +784,7 @@ void make_default_theme() { t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) ); t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) ); - + t->set_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, "")); t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, "")); diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 4620bf567a..a72cc6a47f 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -51,7 +51,7 @@ public: enum BGParam { BG_PARAM_CANVAS_MAX_LAYER=VS::ENV_BG_PARAM_CANVAS_MAX_LAYER, - BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR, + BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR, BG_PARAM_TEXTURE=VS::ENV_BG_PARAM_TEXTURE, BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP, BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY, diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 0aae6fd978..ef5b7a3eb0 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -272,24 +272,24 @@ Error Font::create_from_fnt(const String& p_string) { void Font::set_height(float p_height) { - + height=p_height; } float Font::get_height() const{ - + return height; } void Font::set_ascent(float p_ascent){ - + ascent=p_ascent; } float Font::get_ascent() const { - + return ascent; } float Font::get_descent() const { - + return height-ascent; } @@ -349,7 +349,7 @@ void Font::add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, con c.v_align=p_align.y; c.advance=p_advance; c.h_align=p_align.x; - + char_map[p_char]=c; } @@ -411,7 +411,7 @@ bool Font::is_distance_field_hint() const{ void Font::clear() { - + height=1; ascent=0; char_map.clear(); @@ -423,14 +423,14 @@ void Font::clear() { Size2 Font::get_string_size(const String& p_string) const { float w=0; - + int l = p_string.length(); if (l==0) return Size2(0,height); const CharType *sptr = &p_string[0]; for (int i=0;i<l;i++) { - + w+=get_char_size(sptr[i],sptr[i+1]).width; } @@ -461,9 +461,9 @@ void Font::draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,fl } void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const { - + Vector2 ofs; - + for (int i=0;i<p_text.length();i++) { int width = get_char_size(p_text[i]).width; @@ -476,15 +476,15 @@ void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, co } float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const { - + const Character * c = char_map.getptr(p_char); - + if (!c) { if (fallback.is_valid()) return fallback->draw_char(p_canvas_item,p_pos,p_char,p_next,p_modulate); return 0; } - + Point2 cpos=p_pos; cpos.x+=c->h_align; cpos.y-=ascent; @@ -492,7 +492,7 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_ ERR_FAIL_COND_V( c->texture_idx<-1 || c->texture_idx>=textures.size(),0); if (c->texture_idx!=-1) VisualServer::get_singleton()->canvas_item_add_texture_rect_region( p_canvas_item, Rect2( cpos, c->rect.size ), textures[c->texture_idx]->get_rid(),c->rect, p_modulate ); - + return get_char_size(p_char,p_next).width; } @@ -561,16 +561,16 @@ void Font::_bind_methods() { } Font::Font() { - + clear(); - + } Font::~Font() { - + clear(); } diff --git a/scene/resources/font.h b/scene/resources/font.h index 61f0352992..03b1ec5191 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -36,21 +36,21 @@ @author Juan Linietsky <reduzio@gmail.com> */ class Font : public Resource { - + OBJ_TYPE( Font, Resource ); RES_BASE_EXTENSION("fnt"); - + Vector< Ref<Texture> > textures; public: struct Character { - + int texture_idx; Rect2 rect; float v_align; float h_align; float advance; - + Character() { texture_idx=0; v_align=0; } }; @@ -69,10 +69,10 @@ public: private: - + HashMap< CharType, Character > char_map; Map<KerningPairKey,int> kerning_map; - + float height; float ascent; bool distance_field_hint; @@ -86,20 +86,20 @@ private: Ref<Font> fallback; protected: - + static void _bind_methods(); public: Error create_from_fnt(const String& p_file); - + void set_height(float p_height); float get_height() const; - + void set_ascent(float p_ascent); - float get_ascent() const; + float get_ascent() const; float get_descent() const; - + void add_texture(const Ref<Texture>& p_texture); void add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, const Size2& p_align, float p_advance=-1); @@ -116,7 +116,7 @@ public: inline Size2 get_char_size(CharType p_char,CharType p_next=0) const; Size2 get_string_size(const String& p_string) const; - + void set_fallback(const Ref<Font> &p_fallback); Ref<Font> get_fallback() const; @@ -125,11 +125,11 @@ public: void set_distance_field_hint(bool p_distance_field); bool is_distance_field_hint() const; - + void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const; void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const; float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const; - + Font(); ~Font(); }; diff --git a/scene/resources/material.h b/scene/resources/material.h index 96b33ce129..dbd05c466f 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -41,7 +41,7 @@ class Material : public Resource { - OBJ_TYPE(Material,Resource); + OBJ_TYPE(Material,Resource); RES_BASE_EXTENSION("mtl"); OBJ_SAVE_TYPE( Material ); diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 9537fa269f..09c0a21f53 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -126,7 +126,7 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) { add_custom_surface(p_value); return true; - } + } //create Dictionary d=p_value; @@ -223,7 +223,7 @@ void Mesh::_get_property_list( List<PropertyInfo> *p_list) const { } for (int i=0;i<surfaces.size();i++) { - + p_list->push_back( PropertyInfo( Variant::DICTIONARY,"surfaces/"+itos(i), PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ) ); p_list->push_back( PropertyInfo( Variant::STRING,"surface_"+itos(i+1)+"/name", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR ) ); p_list->push_back( PropertyInfo( Variant::OBJECT,"surface_"+itos(i+1)+"/material", PROPERTY_HINT_RESOURCE_TYPE,"Material",PROPERTY_USAGE_EDITOR ) ); @@ -238,9 +238,9 @@ void Mesh::_recompute_aabb() { // regenerate AABB aabb=AABB(); - + for (int i=0;i<surfaces.size();i++) { - + if (i==0) aabb=surfaces[i].aabb; else @@ -383,7 +383,7 @@ void Mesh::surface_remove(int p_idx) { ERR_FAIL_INDEX(p_idx, surfaces.size() ); VisualServer::get_singleton()->mesh_remove_surface(mesh,p_idx); surfaces.remove(p_idx); - + triangle_mesh=Ref<TriangleMesh>(); _recompute_aabb(); _change_notify(); @@ -472,14 +472,14 @@ void Mesh::add_surface_from_mesh_data(const Geometry::MeshData& p_mesh_data) { VisualServer::get_singleton()->mesh_add_surface_from_mesh_data( mesh, p_mesh_data ); AABB aabb; for (int i=0;i<p_mesh_data.vertices.size();i++) { - + if (i==0) aabb.pos=p_mesh_data.vertices[i]; else aabb.expand_to(p_mesh_data.vertices[i]); } - + Surface s; s.aabb=aabb; if (surfaces.size()==0) @@ -524,60 +524,60 @@ DVector<Face3> Mesh::get_faces() const { return DVector<Face3>(); /* for (int i=0;i<surfaces.size();i++) { - + if (VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != VisualServer::PRIMITIVE_TRIANGLES ) continue; - + DVector<int> indices; DVector<Vector3> vertices; - + vertices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_VERTEX); - + int len=VisualServer::get_singleton()->mesh_surface_get_array_index_len(mesh, i); bool has_indices; - + if (len>0) { - + indices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_INDEX); has_indices=true; - + } else { - + len=vertices.size(); has_indices=false; } - + if (len<=0) continue; - + DVector<int>::Read indicesr = indices.read(); const int *indicesptr = indicesr.ptr(); - + DVector<Vector3>::Read verticesr = vertices.read(); const Vector3 *verticesptr = verticesr.ptr(); - + int old_faces=faces.size(); int new_faces=old_faces+(len/3); - + faces.resize(new_faces); - + DVector<Face3>::Write facesw = faces.write(); Face3 *facesptr=facesw.ptr(); - - + + for (int i=0;i<len/3;i++) { - + Face3 face; - + for (int j=0;j<3;j++) { - + int idx=i*3+j; face.vertex[j] = has_indices ? verticesptr[ indicesptr[ idx ] ] : verticesptr[idx]; } - + facesptr[i+old_faces]=face; } - + } */ @@ -993,17 +993,17 @@ void Mesh::_bind_methods() { BIND_CONSTANT( NO_INDEX_ARRAY ); BIND_CONSTANT( ARRAY_WEIGHTS_SIZE ); - + BIND_CONSTANT( ARRAY_VERTEX ); BIND_CONSTANT( ARRAY_NORMAL ); BIND_CONSTANT( ARRAY_TANGENT ); BIND_CONSTANT( ARRAY_COLOR ); - BIND_CONSTANT( ARRAY_TEX_UV ); + BIND_CONSTANT( ARRAY_TEX_UV ); BIND_CONSTANT( ARRAY_TEX_UV2 ); BIND_CONSTANT( ARRAY_BONES ); BIND_CONSTANT( ARRAY_WEIGHTS ); BIND_CONSTANT( ARRAY_INDEX ); - + BIND_CONSTANT( ARRAY_FORMAT_VERTEX ); BIND_CONSTANT( ARRAY_FORMAT_NORMAL ); BIND_CONSTANT( ARRAY_FORMAT_TANGENT ); @@ -1013,7 +1013,7 @@ void Mesh::_bind_methods() { BIND_CONSTANT( ARRAY_FORMAT_BONES ); BIND_CONSTANT( ARRAY_FORMAT_WEIGHTS ); BIND_CONSTANT( ARRAY_FORMAT_INDEX ); - + BIND_CONSTANT( PRIMITIVE_POINTS ); BIND_CONSTANT( PRIMITIVE_LINES ); BIND_CONSTANT( PRIMITIVE_LINE_STRIP ); diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index e0d9bdf7a8..dc1d97a49e 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -43,9 +43,9 @@ class Mesh : public Resource { RES_BASE_EXTENSION("msh"); public: - + enum { - + NO_INDEX_ARRAY=VisualServer::NO_INDEX_ARRAY, ARRAY_WEIGHTS_SIZE=VisualServer::ARRAY_WEIGHTS_SIZE }; @@ -63,8 +63,8 @@ public: ARRAY_INDEX=VisualServer::ARRAY_INDEX, ARRAY_MAX=VisualServer::ARRAY_MAX - }; - + }; + enum ArrayFormat { /* ARRAY FORMAT FLAGS */ ARRAY_FORMAT_VERTEX=1<<ARRAY_VERTEX, // mandatory @@ -77,8 +77,8 @@ public: ARRAY_FORMAT_WEIGHTS=1<<ARRAY_WEIGHTS, ARRAY_FORMAT_INDEX=1<<ARRAY_INDEX, - }; - + }; + enum PrimitiveType { PRIMITIVE_POINTS=VisualServer::PRIMITIVE_POINTS, PRIMITIVE_LINES=VisualServer::PRIMITIVE_LINES, @@ -87,7 +87,7 @@ public: PRIMITIVE_TRIANGLES=VisualServer::PRIMITIVE_TRIANGLES, PRIMITIVE_TRIANGLE_STRIP=VisualServer::PRIMITIVE_TRIANGLE_STRIP, PRIMITIVE_TRIANGLE_FAN=VisualServer::PRIMITIVE_TRIANGLE_FAN, - }; + }; enum MorphTargetMode { @@ -95,7 +95,7 @@ public: MORPH_MODE_RELATIVE=VS::MORPH_MODE_RELATIVE, }; -private: +private: struct Surface { String name; AABB aabb; @@ -111,16 +111,16 @@ private: mutable Ref<TriangleMesh> triangle_mesh; - + void _recompute_aabb(); protected: - + bool _set(const StringName& p_name, const Variant& p_value); bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list( List<PropertyInfo> *p_list) const; - + static void _bind_methods(); - + public: void add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),bool p_alphasort=false); @@ -174,7 +174,7 @@ public: DVector<Face3> get_faces() const; Ref<TriangleMesh> generate_triangle_mesh() const; Mesh(); - + ~Mesh(); }; diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index 8643e96303..76bb1c585f 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -103,7 +103,7 @@ void MeshLibrary::create_item(int p_item) { void MeshLibrary::set_item_name(int p_item,const String& p_name) { ERR_FAIL_COND(!item_map.has(p_item)); - item_map[p_item].name=p_name; + item_map[p_item].name=p_name; emit_changed(); _change_notify(); diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h index 9a468d5555..bf0107d7a9 100644 --- a/scene/resources/mesh_library.h +++ b/scene/resources/mesh_library.h @@ -56,7 +56,7 @@ protected: void _get_property_list( List<PropertyInfo> *p_list) const; static void _bind_methods(); -public: +public: void create_item(int p_item); diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index a9010e79a2..ef04c68e8e 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -646,7 +646,7 @@ https://github.com/godotengine/godot/issues/3127 } // Save the right type. If this node was created by an instance - // then flag that the node should not be created but reused + // then flag that the node should not be created but reused if (pack_state_stack.empty()) { //this node is not part of an instancing process, so save the type nd.type=_nm_get_string(p_node->get_type(),name_map); @@ -963,7 +963,7 @@ Ref<SceneState> SceneState::_get_base_scene_state() const { int SceneState::find_node_by_path(const NodePath& p_node) const { - if (!node_path_cache.has(p_node)) { + if (!node_path_cache.has(p_node)) { if (_get_base_scene_state().is_valid()) { int idx = _get_base_scene_state()->find_node_by_path(p_node); if (idx>=0) { @@ -1275,7 +1275,7 @@ Dictionary SceneState::get_bundled_scene() const { rnode_paths.resize(node_paths.size()); for(int i=0;i<node_paths.size();i++) { rnode_paths[i]=node_paths[i]; - } + } d["node_paths"]=rnode_paths; Array reditable_instances; diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index 6a26cc472c..6bde508d72 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -66,7 +66,7 @@ class SceneState : public Reference { }; Vector<Property> properties; - Vector<int> groups; + Vector<int> groups; }; diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index e8cdec66df..1a7dc56e40 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -545,7 +545,7 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2& p_point) const { closest_point=closest; } } - + ERR_FAIL_COND_V(closest_dist==1e20,Vector2()); return closest_point; diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h index 2cbe3e949d..b23dbd0bac 100644 --- a/scene/resources/polygon_path_finder.h +++ b/scene/resources/polygon_path_finder.h @@ -61,7 +61,7 @@ public: bool is_point_inside(const Vector2& p_point) const; Vector2 get_closest_point(const Vector2& p_point) const; - Vector<Vector2> get_intersections(const Vector2& p_from, const Vector2& p_to) const; + Vector<Vector2> get_intersections(const Vector2& p_from, const Vector2& p_to) const; Rect2 get_bounds() const; diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index 0f9eb85244..4024e2f45c 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -48,7 +48,7 @@ BSP_Tree RoomBounds::get_bounds() const { } void RoomBounds::set_geometry_hint(const DVector<Face3>& p_geometry_hint) { - + geometry_hint=p_geometry_hint; } diff --git a/scene/resources/room.h b/scene/resources/room.h index c5aaea311e..a9f159cd46 100644 --- a/scene/resources/room.h +++ b/scene/resources/room.h @@ -38,8 +38,8 @@ class RoomBounds : public Resource { OBJ_TYPE( RoomBounds, Resource ); RES_BASE_EXTENSION("room"); - - RID area; + + RID area; DVector<Face3> geometry_hint; void _regenerate_bsp(); @@ -54,10 +54,10 @@ public: void set_bounds( const BSP_Tree& p_bounds ); BSP_Tree get_bounds() const; - + void set_geometry_hint(const DVector<Face3>& geometry_hint); const DVector<Face3>& get_geometry_hint() const; - + RoomBounds(); ~RoomBounds(); diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 6bd5f520d2..f9f7f7807d 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -1144,7 +1144,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re if (packed_scene->get_state()->is_node_instance_placeholder(i)) continue; - Ref<PackedScene> instance=packed_scene->get_state()->get_node_instance(i); + Ref<PackedScene> instance=packed_scene->get_state()->get_node_instance(i); if (instance.is_valid() && !external_resources.has(instance)) { int index = external_resources.size(); external_resources[instance]=index; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 71a775ee24..75e38f9701 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -37,7 +37,7 @@ void StyleBox::set_default_margin(Margin p_margin, float p_value) { margin[p_margin]=p_value; emit_changed(); - + } float StyleBox::get_default_margin(Margin p_margin) const{ @@ -59,7 +59,7 @@ Size2 StyleBox::get_minimum_size() const { Point2 StyleBox::get_offset() const { - + return Point2( get_margin( MARGIN_LEFT), get_margin( MARGIN_TOP) ); } @@ -94,33 +94,33 @@ void StyleBox::_bind_methods() { } StyleBox::StyleBox() { - + for (int i=0;i<4;i++) { - + margin[i]=-1; } } void StyleBoxTexture::set_texture(RES p_texture) { - + texture=p_texture; emit_changed(); } RES StyleBoxTexture::get_texture() const { - + return texture; } void StyleBoxTexture::set_margin_size(Margin p_margin,float p_size) { - + margin[p_margin]=p_size; emit_changed(); } float StyleBoxTexture::get_margin_size(Margin p_margin) const { - + return margin[p_margin]; } @@ -142,14 +142,14 @@ void StyleBoxTexture::draw(RID p_canvas_item,const Rect2& p_rect) const { } void StyleBoxTexture::set_draw_center(bool p_draw) { - + draw_center=p_draw; emit_changed(); } bool StyleBoxTexture::get_draw_center() const { - + return draw_center; } @@ -204,18 +204,18 @@ void StyleBoxTexture::_bind_methods() { } StyleBoxTexture::StyleBoxTexture() { - - + + for (int i=0;i<4;i++) { margin[i]=0; expand_margin[i]=0; } draw_center=true; - + } StyleBoxTexture::~StyleBoxTexture() { - - + + } //////////////// diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index d0466ed5f1..02d79bc2ac 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -36,60 +36,60 @@ @author Juan Linietsky <reduzio@gmail.com> */ class StyleBox : public Resource { - + OBJ_TYPE( StyleBox, Resource ); RES_BASE_EXTENSION("sbx"); OBJ_SAVE_TYPE( StyleBox ); float margin[4]; - -protected: - + +protected: + virtual float get_style_margin(Margin p_margin) const=0; static void _bind_methods(); public: - + virtual bool test_mask(const Point2& p_point, const Rect2& p_rect) const; - + void set_default_margin(Margin p_margin, float p_value); float get_default_margin(Margin p_margin) const; float get_margin(Margin p_margin) const; virtual Size2 get_center_size() const; - + virtual void draw(RID p_canvas_item,const Rect2& p_rect) const=0; - + Size2 get_minimum_size() const; Point2 get_offset() const; - + StyleBox(); }; class StyleBoxEmpty : public StyleBox { - + OBJ_TYPE( StyleBoxEmpty, StyleBox ); virtual float get_style_margin(Margin p_margin) const { return 0; } -public: - +public: + virtual void draw(RID p_canvas_item,const Rect2& p_rect) const {} StyleBoxEmpty() {} - + }; class StyleBoxTexture : public StyleBox { - + OBJ_TYPE( StyleBoxTexture, StyleBox ); - + float expand_margin[4]; float margin[4]; Ref<Texture> texture; bool draw_center; - -protected: - + +protected: + virtual float get_style_margin(Margin p_margin) const; static void _bind_methods(); - + public: void set_expand_margin_size(Margin p_expand_margin,float p_size); @@ -105,12 +105,12 @@ public: bool get_draw_center() const; virtual Size2 get_center_size() const; - + virtual void draw(RID p_canvas_item,const Rect2& p_rect) const; - - StyleBoxTexture(); + + StyleBoxTexture(); ~StyleBoxTexture(); - + }; class StyleBoxFlat : public StyleBox { diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index bf5070fd7d..e3a02420c7 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -324,7 +324,7 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) { w=DVector<Color>::Write(); a[i]=array; - } break; + } break; case Mesh::ARRAY_FORMAT_BONES: case Mesh::ARRAY_FORMAT_WEIGHTS: { diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 28754480f1..1893bfe524 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -163,7 +163,7 @@ bool ImageTexture::_get(const StringName& p_name,Variant &r_ret) const { r_ret= lossy_storage_quality; else return false; - + return true; } @@ -171,8 +171,8 @@ bool ImageTexture::_get(const StringName& p_name,Variant &r_ret) const { void ImageTexture::_get_property_list( List<PropertyInfo> *p_list) const { - - + + PropertyHint img_hint=PROPERTY_HINT_NONE; if (storage==STORAGE_COMPRESS_LOSSY) { img_hint=PROPERTY_HINT_IMAGE_COMPRESS_LOSSY; @@ -207,16 +207,16 @@ void ImageTexture::_reload_hook(const RID& p_hook) { } void ImageTexture::create(int p_width, int p_height,Image::Format p_format,uint32_t p_flags) { - + flags=p_flags; VisualServer::get_singleton()->texture_allocate(texture,p_width, p_height, p_format, p_flags); format=p_format; w=p_width; h=p_height; - + } void ImageTexture::create_from_image(const Image& p_image, uint32_t p_flags) { - + flags=p_flags; w=p_image.get_width(); h=p_image.get_height(); @@ -228,7 +228,7 @@ void ImageTexture::create_from_image(const Image& p_image, uint32_t p_flags) { } void ImageTexture::set_flags(uint32_t p_flags) { - + /* uint32_t cube = flags & FLAG_CUBEMAP; @@ -238,11 +238,11 @@ void ImageTexture::set_flags(uint32_t p_flags) { flags=p_flags|cube; */ flags=p_flags; VisualServer::get_singleton()->texture_set_flags(texture,p_flags); - + } uint32_t ImageTexture::get_flags() const { - + return ImageTexture::flags; } @@ -252,7 +252,7 @@ Image::Format ImageTexture::get_format() const { } void ImageTexture::load(const String& p_path) { - + Image img; img.load(p_path); create_from_image(img); @@ -260,7 +260,7 @@ void ImageTexture::load(const String& p_path) { } void ImageTexture::set_data(const Image& p_image) { - + VisualServer::get_singleton()->texture_set_data(texture,p_image); VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName()); //hook is erased if data is changed _change_notify(); @@ -282,23 +282,23 @@ void ImageTexture::_resource_path_changed() { } Image ImageTexture::get_data() const { - + return VisualServer::get_singleton()->texture_get_data(texture); } int ImageTexture::get_width() const { - - return w; + + return w; } int ImageTexture::get_height() const { - + return h; } RID ImageTexture::get_rid() const { - + return texture; } @@ -458,13 +458,13 @@ ImageTexture::ImageTexture() { texture = VisualServer::get_singleton()->texture_create(); storage = STORAGE_RAW; lossy_storage_quality=0.7; - + } ImageTexture::~ImageTexture() { - + VisualServer::get_singleton()->free( texture ); } diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 2627b9480a..103b425cd8 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -84,7 +84,7 @@ VARIANT_ENUM_CAST( Texture::Flags ); class ImageTexture : public Texture { - + OBJ_TYPE( ImageTexture, Texture ); RES_BASE_EXTENSION("tex"); public: @@ -97,12 +97,12 @@ private: RID texture; Image::Format format; uint32_t flags; - int w,h; + int w,h; Storage storage; Size2 size_override; float lossy_storage_quality; -protected: +protected: virtual bool can_reload_from_file(); virtual void reload_from_file(); @@ -117,24 +117,24 @@ protected: void _set_data(Dictionary p_data); public: - + void create(int p_width, int p_height,Image::Format p_format,uint32_t p_flags=FLAGS_DEFAULT); void create_from_image(const Image& p_image, uint32_t p_flags=FLAGS_DEFAULT); - + void set_flags(uint32_t p_flags); uint32_t get_flags() const; Image::Format get_format() const; void load(const String& p_path); void set_data(const Image& p_image); Image get_data() const; - + int get_width() const; int get_height() const; - + virtual RID get_rid() const; - + bool has_alpha() const; virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const; virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 685b2e07e1..74e59b09c3 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -104,67 +104,67 @@ bool Theme::_get(const StringName& p_name,Variant &r_ret) const { } void Theme::_get_property_list( List<PropertyInfo> *p_list) const { - + List<PropertyInfo> list; const StringName *key=NULL; - + while((key=icon_map.next(key))) { - + const StringName *key2=NULL; - + while((key2=icon_map[*key].next(key2))) { list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/icons/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture" ) ); } } - + key=NULL; - + while((key=style_map.next(key))) { - + const StringName *key2=NULL; - + while((key2=style_map[*key].next(key2))) { - + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/styles/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox" ) ); } } - + key=NULL; - + while((key=font_map.next(key))) { - + const StringName *key2=NULL; - + while((key2=font_map[*key].next(key2))) { - + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/fonts/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Font" ) ); } } - + key=NULL; - + while((key=color_map.next(key))) { - + const StringName *key2=NULL; - + while((key2=color_map[*key].next(key2))) { - + list.push_back( PropertyInfo( Variant::COLOR, String()+*key+"/colors/"+*key2 ) ); } } - + key=NULL; - + while((key=constant_map.next(key))) { - + const StringName *key2=NULL; - + while((key2=constant_map[*key].next(key2))) { - + list.push_back( PropertyInfo( Variant::INT, String()+*key+"/constants/"+*key2 ) ); } } @@ -173,12 +173,12 @@ void Theme::_get_property_list( List<PropertyInfo> *p_list) const { for(List<PropertyInfo>::Element *E=list.front();E;E=E->next()) { p_list->push_back(E->get()); } - + } Ref<Theme> Theme::get_default() { - - return default_theme; + + return default_theme; } @@ -193,7 +193,7 @@ Ref<Font> Theme::get_default_theme_font() const { } void Theme::set_default(const Ref<Theme>& p_default) { - + default_theme=p_default; } @@ -221,7 +221,7 @@ void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref bool new_value=!icon_map.has(p_type) || !icon_map[p_type].has(p_name); - icon_map[p_type][p_name]=p_icon; + icon_map[p_type][p_name]=p_icon; if (new_value) { _change_notify(); @@ -229,7 +229,7 @@ void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref } } Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) const { - + if (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) { return icon_map[p_type][p_name]; @@ -239,7 +239,7 @@ Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) } bool Theme::has_icon(const StringName& p_name,const StringName& p_type) const { - + return (icon_map.has(p_type) && icon_map[p_type].has(p_name)); } @@ -266,13 +266,13 @@ void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const { p_list->push_back(*key); } - + } void Theme::set_shader(const StringName &p_name,const StringName &p_type,const Ref<Shader>& p_shader) { bool new_value=!shader_map.has(p_type) || !shader_map[p_type].has(p_name); - shader_map[p_type][p_name]=p_shader; + shader_map[p_type][p_name]=p_shader; if (new_value) { _change_notify(); @@ -311,7 +311,7 @@ void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) p_list->push_back(*key); } - + } @@ -331,7 +331,7 @@ void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const Ref<StyleBox> Theme::get_stylebox(const StringName& p_name,const StringName& p_type) const { - + if (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) { return style_map[p_type][p_name]; @@ -341,7 +341,7 @@ Ref<StyleBox> Theme::get_stylebox(const StringName& p_name,const StringName& p_t } bool Theme::has_stylebox(const StringName& p_name,const StringName& p_type) const { - + return (style_map.has(p_type) && style_map[p_type].has(p_name) ); } @@ -384,18 +384,18 @@ void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref } } Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) const { - + if (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid()) - return font_map[p_type][p_name]; + return font_map[p_type][p_name]; else if (default_theme_font.is_valid()) return default_theme_font; else return default_font; - + } bool Theme::has_font(const StringName& p_name,const StringName& p_type) const { - + return (font_map.has(p_type) && font_map[p_type].has(p_name)); } @@ -425,7 +425,7 @@ void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const { } void Theme::set_color(const StringName& p_name,const StringName& p_type,const Color& p_color) { - + bool new_value=!color_map.has(p_type) || !color_map[p_type].has(p_name); color_map[p_type][p_name]=p_color; @@ -440,16 +440,16 @@ void Theme::set_color(const StringName& p_name,const StringName& p_type,const Co Color Theme::get_color(const StringName& p_name,const StringName& p_type) const { - + if (color_map.has(p_type) && color_map[p_type].has(p_name)) - return color_map[p_type][p_name]; + return color_map[p_type][p_name]; else return Color(); - + } bool Theme::has_color(const StringName& p_name,const StringName& p_type) const { - + return (color_map.has(p_type) && color_map[p_type].has(p_name)); } @@ -479,7 +479,7 @@ void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const { } void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p_constant) { - + bool new_value=!constant_map.has(p_type) || !constant_map[p_type].has(p_name); constant_map[p_type][p_name]=p_constant; @@ -490,17 +490,17 @@ void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p } int Theme::get_constant(const StringName& p_name,const StringName& p_type) const { - + if (constant_map.has(p_type) && constant_map[p_type].has(p_name)) - return constant_map[p_type][p_name]; + return constant_map[p_type][p_name]; else { return 0; } - + } bool Theme::has_constant(const StringName& p_name,const StringName& p_type) const { - + return (constant_map.has(p_type) && constant_map[p_type].has(p_name)); } @@ -635,8 +635,8 @@ void Theme::_bind_methods() { } Theme::Theme() { - - + + } diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 180f55381d..36630087f6 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -40,12 +40,12 @@ @author Juan Linietsky <reduzio@gmail.com> */ class Theme : public Resource { - + OBJ_TYPE( Theme, Resource ); RES_BASE_EXTENSION("thm"); - + static Ref<Theme> default_theme; - + HashMap<StringName,HashMap<StringName,Ref<Texture>,StringNameHasher >, StringNameHasher > icon_map; HashMap<StringName,HashMap<StringName,Ref<StyleBox>,StringNameHasher >,StringNameHasher > style_map; HashMap<StringName,HashMap<StringName,Ref<Font>,StringNameHasher >,StringNameHasher > font_map; @@ -56,7 +56,7 @@ protected: bool _set(const StringName& p_name, const Variant& p_value); bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list( List<PropertyInfo> *p_list) const; - + static Ref<Texture> default_icon; static Ref<StyleBox> default_style; static Ref<Font> default_font; @@ -72,10 +72,10 @@ protected: static void _bind_methods(); public: - + static Ref<Theme> get_default(); static void set_default(const Ref<Theme>& p_default); - + static void set_default_icon( const Ref<Texture>& p_icon ); static void set_default_style( const Ref<StyleBox>& p_default_style); static void set_default_font( const Ref<Font>& p_default_font ); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 6f71287750..bf01929191 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -344,13 +344,13 @@ Array TileSet::_tile_get_shapes(int p_id) const{ } Array TileSet::_get_tiles_ids() const{ - + Array arr; for (Map<int, Data>::Element *E = tile_map.front(); E; E = E->next()) { - arr.push_back(E->key()); + arr.push_back(E->key()); } - + return arr; } diff --git a/scene/resources/volume.cpp b/scene/resources/volume.cpp index 8eb96cb4ad..8e056158cb 100644 --- a/scene/resources/volume.cpp +++ b/scene/resources/volume.cpp @@ -33,10 +33,10 @@ void Volume::_set(const String& p_name, const Variant& p_value) { if (p_name.begins_with("shapes/")) { - + int idx=p_name.get_slice("/",1).to_int()-1; ERR_FAIL_COND( idx != get_shape_count() ); - + Dictionary shape = p_value; ERR_FAIL_COND( !shape.has("type") || !shape.has("data")); String type = shape["type"]; @@ -44,7 +44,7 @@ void Volume::_set(const String& p_name, const Variant& p_value) { Transform transform; if (shape.has("transform")) transform=shape["transform"]; - + if (type=="plane") add_shape(SHAPE_PLANE,data,transform); else if (type=="sphere") @@ -59,7 +59,7 @@ void Volume::_set(const String& p_name, const Variant& p_value) { add_shape(SHAPE_CONVEX_POLYGON,data,transform); else if (type=="concave_polygon") add_shape(SHAPE_CONCAVE_POLYGON,data,transform); - else { + else { ERR_FAIL(); } } @@ -68,14 +68,14 @@ void Volume::_set(const String& p_name, const Variant& p_value) { Variant Volume::_get(const String& p_name) const { if (p_name.begins_with("shapes/")) { - + int idx=p_name.get_slice("/",1).to_int()-1; ERR_FAIL_INDEX_V( idx, get_shape_count(), Variant() ); - + Dictionary shape; - + switch( get_shape_type(idx) ) { - + case SHAPE_PLANE: shape["type"]="plane"; break; case SHAPE_SPHERE: shape["type"]="sphere"; break; case SHAPE_BOX: shape["type"]="box"; break; @@ -83,15 +83,15 @@ Variant Volume::_get(const String& p_name) const { case SHAPE_CAPSULE: shape["type"]="capsule"; break; case SHAPE_CONVEX_POLYGON: shape["type"]="convex_polygon"; break; case SHAPE_CONCAVE_POLYGON: shape["type"]="concave_polygon"; break; - + } - + shape["transform"]=get_shape_transform(idx); shape["data"]=get_shape(idx); return shape; } - + return Variant(); } @@ -99,8 +99,8 @@ void Volume::_get_property_list( List<PropertyInfo> *p_list) const { int count=get_shape_count(); for(int i=0;i<count;i++) { - - p_list->push_back( PropertyInfo( Variant::DICTIONARY, "shapes/"+itos(i+1)) ); + + p_list->push_back( PropertyInfo( Variant::DICTIONARY, "shapes/"+itos(i+1)) ); } } @@ -118,7 +118,7 @@ void Volume::add_shape(ShapeType p_shape_type, const Variant& p_data, const Tran void Volume::add_plane_shape(const Plane& p_plane,const Transform& p_transform) { add_shape(SHAPE_PLANE, p_plane, p_transform ); -} +} void Volume::add_sphere_shape(float p_radius,const Transform& p_transform) { @@ -140,7 +140,7 @@ void Volume::add_cylinder_shape(float p_radius, float p_height,const Transform& void Volume::add_capsule_shape(float p_radius, float p_height,const Transform& p_transform) { Dictionary d; - d["radius"]=p_radius; + d["radius"]=p_radius; d["height"]=p_height; add_shape(SHAPE_CAPSULE,d,p_transform); @@ -179,7 +179,7 @@ void Volume::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_shape_type","shape_idx"),&Volume::get_shape_type); ObjectTypeDB::bind_method(_MD("get_shape_transform","shape_idx"),&Volume::get_shape_transform); ObjectTypeDB::bind_method(_MD("get_shape","shape_idx"),&Volume::get_shape); - + BIND_CONSTANT( SHAPE_PLANE ); BIND_CONSTANT( SHAPE_SPHERE ); BIND_CONSTANT( SHAPE_BOX ); @@ -198,7 +198,7 @@ RID Volume::get_rid() { Volume::Volume() { volume= PhysicsServer::get_singleton()->volume_create(); - + } diff --git a/scene/resources/volume.h b/scene/resources/volume.h index be3cbddbbd..f03e48f1d9 100644 --- a/scene/resources/volume.h +++ b/scene/resources/volume.h @@ -38,16 +38,16 @@ */ class Volume : public Resource { - OBJ_TYPE( Volume, Resource ); + OBJ_TYPE( Volume, Resource ); RID volume; - + protected: - + bool _set(const StringName& p_name, const Variant& p_value); bool _get(const StringName& p_name,Variant &r_ret) const; void _get_property_list( List<PropertyInfo> *p_list) const; - - static void _bind_methods(); + + static void _bind_methods(); public: enum ShapeType { @@ -59,22 +59,22 @@ public: SHAPE_CONVEX_POLYGON = PhysicsServer::SHAPE_CONVEX_POLYGON, ///< array of planes:"planes" SHAPE_CONCAVE_POLYGON = PhysicsServer::SHAPE_CONCAVE_POLYGON, ///< vector3 array:"triangles" }; - + void add_shape(ShapeType p_shape_type, const Variant& p_data, const Transform& p_transform=Transform ()); - + void add_plane_shape(const Plane& p_plane,const Transform& p_transform); void add_sphere_shape(float p_radius,const Transform& p_transform); void add_box_shape(const Vector3& p_half_extents,const Transform& p_transform); void add_cylinder_shape(float p_radius, float p_height,const Transform& p_transform); void add_capsule_shape(float p_radius, float p_height,const Transform& p_transform); - + int get_shape_count() const; ShapeType get_shape_type(int p_shape) const; Transform get_shape_transform(int p_shape) const; Variant get_shape(int p_shape) const; virtual RID get_rid(); - + Volume(); ~Volume(); |