Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationImporter.cpp33
-rw-r--r--source/blender/collada/AnimationImporter.h3
-rw-r--r--source/blender/collada/ArmatureImporter.cpp10
-rw-r--r--source/blender/collada/DocumentImporter.cpp36
4 files changed, 58 insertions, 24 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index e5f7bb2eb89..1bcf51f9d1f 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -153,15 +153,13 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
calchandles_fcurve(fcu);
fcurves.push_back(fcu);
+ unused_curves.push_back(fcu);
}
}
break;
default:
fprintf(stderr, "Output dimension of %d is not yet supported (animation id = %s)\n", (int)dim, curve->getOriginalId().c_str());
}
-
- for (std::vector<FCurve *>::iterator it = fcurves.begin(); it != fcurves.end(); it++)
- unused_curves.push_back(*it);
}
@@ -175,6 +173,11 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
}
}
+void AnimationImporter::fcurve_is_used(FCurve *fcu)
+{
+ unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
+}
+
void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
{
@@ -225,6 +228,7 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>&
/* add F-Curve to group */
action_groups_add_channel(act, grp, fcu);
+ fcurve_is_used(fcu);
}
#if 0
@@ -235,10 +239,8 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve *>&
}
else {
BLI_addtail(&act->curves, fcu);
+ fcurve_is_used(fcu);
}
-
- // curve is used, so remove it from unused_curves
- unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
}
}
@@ -438,7 +440,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves, const char
if (array_index == -1) fcu->array_index = i;
else fcu->array_index = array_index;
- unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
+ fcurve_is_used(fcu);
}
}
@@ -448,7 +450,7 @@ void AnimationImporter::unused_fcurve(std::vector<FCurve *> *curves)
std::vector<FCurve *>::iterator it;
for (it = curves->begin(); it != curves->end(); it++) {
FCurve *fcu = *it;
- unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
+ fcurve_is_used(fcu);
}
}
@@ -621,6 +623,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
@@ -660,6 +663,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
/** XXX What About animtype "rotation" ? */
BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
}
@@ -705,6 +709,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid
}
BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
}
@@ -840,8 +845,10 @@ void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& a
add_bone_fcurve(ob, node, newcu[i]);
else
BLI_addtail(curves, newcu[i]);
+ // fcurve_is_used(newcu[i]); // never added to unused
}
+
if (is_joint) {
bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name);
chan->rotmode = ROT_MODE_QUAT;
@@ -891,8 +898,6 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
std::multimap<COLLADAFW::UniqueId, Object *>& object_map,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
{
- AnimationImporter::AnimMix *animType = get_animation_type(node, FW_object_map);
-
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
COLLADAFW::UniqueId uid = node->getUniqueId();
COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid];
@@ -908,6 +913,8 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
return;
}
+
+ AnimationImporter::AnimMix *animType = get_animation_type(node, FW_object_map);
bAction *act;
if ( (animType->transform) != 0) {
@@ -966,6 +973,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
+ fcurve_is_used(fcu);
}
}
@@ -1108,6 +1116,8 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
}
}
}
+
+ delete animType;
}
void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
@@ -1233,6 +1243,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurv
// add curves
for (int i = 0; i < totcu; i++) {
add_bone_fcurve(ob, node, newcu[i]);
+ // fcurve_is_used(newcu[i]); // never added to unused
}
bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name);
@@ -1832,7 +1843,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
i++;
j = 0;
}
- unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), *it), unused_curves.end());
+ fcurve_is_used(*it);
}
COLLADAFW::Matrix tm(matrix);
diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h
index 565fe183d02..15dee8ff5f4 100644
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@ -85,7 +85,10 @@ private:
void fcurve_deg_to_rad(FCurve *cu);
+ void fcurve_is_used(FCurve *fcu);
+
void add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
+
int typeFlag;
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 6ddce75ec33..fd08e1ebfab 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -255,9 +255,13 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone
{
BoneExtended *dominant_child = NULL;
int maxlen = 0;
- Bone *child = (Bone *)parentbone->childbase.first;
- if (child && (import_settings->find_chains || child->next==NULL) )
- {
+ Bone *child;
+
+ if (parentbone == NULL)
+ return;
+
+ child = (Bone *)parentbone->childbase.first;
+ if (child && (import_settings->find_chains || child->next==NULL)) {
for (; child; child = child->next) {
BoneExtended *be = extended_bones[child->name];
if (be != NULL) {
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 0aff5147060..674a79f0fe7 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -136,11 +136,14 @@ bool DocumentImporter::import()
const std::string encodedFilename = bc_url_encode(mFilename);
if (!root.loadDocument(encodedFilename)) {
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n");
+ delete ehandler;
return false;
}
- if (errorHandler.hasError())
+ if (errorHandler.hasError()) {
+ delete ehandler;
return false;
+ }
/** TODO set up scene graph and such here */
@@ -151,10 +154,10 @@ bool DocumentImporter::import()
if (!root2.loadDocument(encodedFilename)) {
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n");
+ delete ehandler;
return false;
}
-
-
+
delete ehandler;
return true;
@@ -223,6 +226,7 @@ void DocumentImporter::finish()
for (unsigned int i = 0; i < roots.getCount(); i++) {
std::vector<Object *> *objects_done = write_node(roots[i], NULL, sce, NULL, false);
objects_to_scale->insert(objects_to_scale->end(), objects_done->begin(), objects_done->end());
+ delete objects_done;
}
// update scene
@@ -275,6 +279,8 @@ void DocumentImporter::finish()
}
bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units);
+
+ delete objects_to_scale;
}
@@ -499,6 +505,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
std::string id = node->getOriginalId();
std::string name = node->getName();
+ // if node has child nodes write them
+ COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
+
std::vector<Object *> *objects_done = new std::vector<Object *>();
std::vector<Object *> *root_objects = new std::vector<Object *>();
@@ -524,7 +533,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
if (parent_node == NULL) {
// for skeletons without root node all has been done above.
// Skeletons with root node are handled further down.
- return root_objects;
+ goto finally;
}
}
else {
@@ -638,7 +647,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
// XXX: if there're multiple instances, only one is stored
- if (!ob) return root_objects;
+ if (!ob) {
+ goto finally;
+ }
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
ob = *it;
@@ -673,9 +684,6 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
}
}
- // if node has child nodes write them
- COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
-
if (objects_done->size() > 0) {
ob = *objects_done->begin();
}
@@ -684,9 +692,15 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
}
for (unsigned int i = 0; i < child_nodes.getCount(); i++) {
- write_node(child_nodes[i], node, sce, ob, is_library_node);
+ std::vector<Object *> *child_objects;
+ child_objects = write_node(child_nodes[i], node, sce, ob, is_library_node);
+ delete child_objects;
}
+
+finally:
+ delete objects_done;
+
return root_objects;
}
@@ -725,7 +739,9 @@ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryN
const COLLADAFW::NodePointerArray& nodes = libraryNodes->getNodes();
for (unsigned int i = 0; i < nodes.getCount(); i++) {
- write_node(nodes[i], NULL, sce, NULL, true);
+ std::vector<Object *> *child_objects;
+ child_objects = write_node(nodes[i], NULL, sce, NULL, true);
+ delete child_objects;
}
return true;