summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/animation.cpp33
-rw-r--r--scene/resources/animation.h6
-rw-r--r--scene/resources/packed_scene.cpp3
-rw-r--r--scene/resources/scene_format_text.cpp11
4 files changed, 42 insertions, 11 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index b6fc3eb419..8be39e3021 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -74,6 +74,8 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
track_set_path(track,p_value);
else if (what=="interp")
track_set_interpolation_type(track,InterpolationType(p_value.operator int()));
+ else if (what=="imported")
+ track_set_imported(track,p_value);
else if (what == "keys" || what=="key_values") {
if (track_get_type(track)==TYPE_TRANSFORM) {
@@ -171,6 +173,7 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
}
+
DVector<float> times=d["times"];
Array values=d["values"];
@@ -267,6 +270,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
r_ret= length;
else if (name=="loop")
r_ret= loop;
+ else if (name=="loop_interpolation")
+ r_ret= loop_interpolation;
else if (name=="step")
r_ret= step;
else if (name.begins_with("tracks/")) {
@@ -290,6 +295,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
r_ret=track_get_path(track);
else if (what=="interp")
r_ret = track_get_interpolation_type(track);
+ else if (what=="imported")
+ r_ret = track_is_imported(track);
else if (what=="keys") {
if (track_get_type(track)==TYPE_TRANSFORM) {
@@ -430,6 +437,7 @@ 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_interpolation"));
p_list->push_back( PropertyInfo( Variant::REAL, "step", PROPERTY_HINT_RANGE, "0,4096,0.001" ));
for (int i=0;i<tracks.size();i++) {
@@ -437,6 +445,7 @@ void Animation::_get_property_list( List<PropertyInfo> *p_list) const {
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) );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "tracks/"+itos(i)+"/imported", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
p_list->push_back( PropertyInfo( Variant::ARRAY, "tracks/"+itos(i)+"/keys", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
}
}
@@ -1235,7 +1244,7 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter
float c=0;
// prepare for all cases of interpolation
- if (loop and loop_interpolation) {
+ if (loop && loop_interpolation) {
// loop
if (idx>=0) {
@@ -1633,7 +1642,7 @@ bool Animation::has_loop() const {
return loop;
}
bool Animation::has_loop_interpolation() const {
-
+
return loop_interpolation;
}
@@ -1648,6 +1657,20 @@ void Animation::track_move_up(int p_track) {
emit_changed();
}
+void Animation::track_set_imported(int p_track,bool p_imported) {
+
+ ERR_FAIL_INDEX(p_track,tracks.size());
+ tracks[p_track]->imported=p_imported;
+}
+
+bool Animation::track_is_imported(int p_track) const{
+
+ ERR_FAIL_INDEX_V(p_track,tracks.size(),false);
+ return tracks[p_track]->imported;
+
+}
+
+
void Animation::track_move_down(int p_track) {
if (p_track>0 && p_track<tracks.size()) {
@@ -1682,6 +1705,10 @@ void Animation::_bind_methods() {
ObjectTypeDB::bind_method(_MD("track_move_up","idx"),&Animation::track_move_up);
ObjectTypeDB::bind_method(_MD("track_move_down","idx"),&Animation::track_move_down);
+ ObjectTypeDB::bind_method(_MD("track_set_imported","idx","imported"),&Animation::track_set_imported);
+ ObjectTypeDB::bind_method(_MD("track_is_imported","idx"),&Animation::track_is_imported);
+
+
ObjectTypeDB::bind_method(_MD("transform_track_insert_key","idx","time","loc","rot","scale"),&Animation::transform_track_insert_key);
ObjectTypeDB::bind_method(_MD("track_insert_key","idx","time","key","transition"),&Animation::track_insert_key,DEFVAL(1));
ObjectTypeDB::bind_method(_MD("track_remove_key","idx","key_idx"),&Animation::track_remove_key);
@@ -2015,5 +2042,3 @@ Animation::~Animation() {
memdelete( tracks[i] );
}
-
-
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index 8b677fe0da..ee643c9678 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -72,7 +72,8 @@ private:
TrackType type;
InterpolationType interpolation;
NodePath path; // path to something
- Track() { interpolation=INTERPOLATION_LINEAR; }
+ bool imported;
+ Track() { interpolation=INTERPOLATION_LINEAR; imported=false;}
virtual ~Track() {}
};
@@ -241,6 +242,9 @@ public:
void track_move_up(int p_track);
void track_move_down(int p_track);
+ void track_set_imported(int p_track,bool p_imported);
+ bool track_is_imported(int p_track) const;
+
int transform_track_insert_key(int p_track, float p_time, const Vector3 p_loc, const Quat& p_rot=Quat(), const Vector3& p_scale=Vector3());
void track_insert_key(int p_track, float p_time, const Variant& p_key, float p_transition=1);
void track_set_key_transition(int p_track, int p_key_idx,float p_transition);
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 5ac7946391..ac528e6659 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -1413,8 +1413,7 @@ NodePath SceneState::get_node_path(int p_idx,bool p_for_parent) const {
}
}
- for(int i=0;i<base_path.get_name_count();i++) {
- StringName sn = base_path.get_name(i);
+ for(int i=base_path.get_name_count()-1;i>=0;i--) {
sub_path.insert(0,base_path.get_name(i));
}
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index a734f63ac2..c7e2fc4e73 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -1140,7 +1140,12 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b
}
+static String _valprop(const String& p_name) {
+ if (p_name.find("\"")!=-1 || p_name.find("=")!=-1 || p_name.find(" ")!=-1)
+ return "\""+p_name.c_escape()+"\"";
+ return p_name;
+}
Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_resource,uint32_t p_flags) {
@@ -1296,7 +1301,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
String vars;
VariantWriter::write_to_string(value,vars,_write_resources,this);
- f->store_string(name+" = "+vars+"\n");
+ f->store_string(_valprop(name)+" = "+vars+"\n");
}
@@ -1320,8 +1325,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
Vector<StringName> groups = state->get_node_groups(i);
- if (instance.is_valid())
- print_line("for path "+String(path)+" instance "+instance->get_path());
String header="[node";
header+=" name=\""+String(name)+"\"";
@@ -1372,7 +1375,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
String vars;
VariantWriter::write_to_string(state->get_node_property_value(i,j),vars,_write_resources,this);
- f->store_string(String(state->get_node_property_name(i,j))+" = "+vars+"\n");
+ f->store_string(_valprop(String(state->get_node_property_name(i,j)))+" = "+vars+"\n");
}
if (state->get_node_property_count(i)) {