diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2016-11-06 12:04:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-06 12:04:04 +0100 |
commit | 415f5a7cfe1d60b68af4b969bb81cc7490d960c2 (patch) | |
tree | 06ea93c4acfe24e9e3709d91442b11cd8f7bcad1 /tools | |
parent | a3724b596d2a81f2d41f0862804ae54cedf6618e (diff) | |
parent | 0063471eddebc543fd72636bc8e895ab05bb22a5 (diff) |
Merge pull request #7026 from SaracenOne/value_track_flag_fix
Fixed flag for importing animation and skipping value tracks.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/io_plugins/editor_import_collada.cpp | 92 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_scene_import_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_scene_import_plugin.h | 1 |
3 files changed, 51 insertions, 44 deletions
diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 1130e2be30..2211167dbb 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -88,8 +88,8 @@ struct ColladaImport { 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 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); - void create_animations(bool p_make_tracks_in_all_bones); + void create_animation(int p_clip,bool p_make_tracks_in_all_bones, bool p_import_value_tracks); + void create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks); Set<String> tracks_in_clips; Vector<String> missing_textures; @@ -1898,7 +1898,7 @@ void ColladaImport::_fix_param_animation_tracks() { } -void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) { +void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks) { _fix_param_animation_tracks(); @@ -1943,14 +1943,14 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) { } - create_animation(-1,p_make_tracks_in_all_bones); + create_animation(-1,p_make_tracks_in_all_bones, p_import_value_tracks); //print_line("clipcount: "+itos(collada.state.animation_clips.size())); for(int i=0;i<collada.state.animation_clips.size();i++) - create_animation(i,p_make_tracks_in_all_bones); + create_animation(i, p_make_tracks_in_all_bones, p_import_value_tracks); } -void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones) { +void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks) { Ref<Animation> animation = Ref<Animation>( memnew( Animation )); @@ -2251,64 +2251,68 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones + if (p_import_value_tracks) { + for (int i = 0; i < valid_animated_properties.size(); i++) { - for(int i=0;i<valid_animated_properties.size();i++) { + int ti = valid_animated_properties[i]; - int ti = valid_animated_properties[i]; + if (p_clip == -1) { - if (p_clip==-1) { + if (track_filter.has(ti)) + continue; + } + else { - if (track_filter.has(ti)) - continue; - } else { + if (!track_filter.has(ti)) + continue; - if (!track_filter.has(ti)) - continue; + } - } + Collada::AnimationTrack &at = collada.state.animation_tracks[ti]; - Collada::AnimationTrack &at = collada.state.animation_tracks[ ti ]; + // take snapshots + if (!collada.state.scene_map.has(at.target)) + continue; - // take snapshots - if (!collada.state.scene_map.has(at.target)) - continue; + NodeMap &nm = node_map[at.target]; + String path = scene->get_path_to(nm.node); - NodeMap &nm = node_map[at.target]; - String path = scene->get_path_to(nm.node); + animation->add_track(Animation::TYPE_VALUE); + int track = animation->get_track_count() - 1; - animation->add_track(Animation::TYPE_VALUE); - int track = animation->get_track_count() -1; + path = path + ":" + at.param; + animation->track_set_path(track, path); + animation->track_set_imported(track, true); //helps merging later - path = path +":"+at.param; - animation->track_set_path( track , path ); - animation->track_set_imported( track , true ); //helps merging later + for (int i = 0; i < at.keys.size(); i++) { - for(int i=0;i<at.keys.size();i++) { + float time = at.keys[i].time; + Variant value; + Vector<float> data = at.keys[i].data; + if (data.size() == 1) { + //push a float + value = data[0]; - float time = at.keys[i].time; - Variant value; - Vector<float> data = at.keys[i].data; - if (data.size()==1) { - //push a float - value=data[0]; + } + else if (data.size() == 16) { + //matrix + print_line("value keys for matrices not supported"); + } + else { - } else if (data.size()==16) { - //matrix - print_line("value keys for matrices not supported"); - } else { + print_line("don't know what to do with this amount of value keys: " + itos(data.size())); + } - print_line("don't know what to do with this amount of value keys: "+itos(data.size())); + animation->track_insert_key(track, time, value); } - animation->track_insert_key(track,time,value); - } + tracks_found = true; - tracks_found=true; - + } } @@ -2373,7 +2377,7 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_ if (p_flags&IMPORT_ANIMATION) { - state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); + state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS); AnimationPlayer *ap = memnew( AnimationPlayer ); for(int i=0;i<state.animations.size();i++) { String name; @@ -2410,7 +2414,7 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String& p_path ERR_FAIL_COND_V(err!=OK,RES()); - state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); + state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS); if (state.scene) memdelete(state.scene); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 56af35c6db..cb8ec6d0bc 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -2164,6 +2164,8 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from uint32_t import_flags=0; if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_DETECT_LOOP) import_flags|=EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP; + if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_KEEP_VALUE_TRACKS) + import_flags |= EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS; if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_OPTIMIZE) import_flags|=EditorSceneImporter::IMPORT_ANIMATION_OPTIMIZE; if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS) diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h index c31d3a33d3..2c27f06960 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.h +++ b/tools/editor/io_plugins/editor_scene_import_plugin.h @@ -60,6 +60,7 @@ public: IMPORT_ANIMATION_DETECT_LOOP=4, IMPORT_ANIMATION_OPTIMIZE=8, IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=16, + IMPORT_ANIMATION_KEEP_VALUE_TRACKS=32, IMPORT_GENERATE_TANGENT_ARRAYS=256, IMPORT_FAIL_ON_MISSING_DEPENDENCIES=512 |