[Bf-blender-cvs] [c103a3903f5] collada: Merge branch 'master' into collada
Gaia Clary
noreply at git.blender.org
Wed Oct 24 21:51:45 CEST 2018
Commit: c103a3903f5e1d9e2101a69941864ac34af0b42a
Author: Gaia Clary
Date: Wed Oct 24 21:37:26 2018 +0200
Branches: collada
https://developer.blender.org/rBc103a3903f5e1d9e2101a69941864ac34af0b42a
Merge branch 'master' into collada
===================================================================
===================================================================
diff --cc source/blender/collada/AnimationImporter.h
index 0623edd1e17,ff49bc369cf..cfee9d12af2
--- a/source/blender/collada/AnimationImporter.h
+++ b/source/blender/collada/AnimationImporter.h
@@@ -182,11 -181,12 +182,11 @@@ public
// prerequisites:
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
- Object * translate_animation_OLD(COLLADAFW::Node *node,
- std::map<COLLADAFW::UniqueId, Object*>& object_map,
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
- COLLADAFW::Transformation::TransformationType tm_type,
- Object *par_job = NULL);
- Object *translate_animation_OLD(
- Main *bmain, COLLADAFW::Node *node,
- std::map<COLLADAFW::UniqueId, Object*>& object_map,
- std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
- COLLADAFW::Transformation::TransformationType tm_type,
- Object *par_job = NULL);
++ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
++ std::map<COLLADAFW::UniqueId, Object *>& object_map,
++ std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
++ COLLADAFW::Transformation::TransformationType tm_type,
++ Object *par_job = NULL);
void find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves );
void find_frames_old( std::vector<float>* frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type );
diff --cc source/blender/collada/ArmatureExporter.cpp
index 113d1732bf9,432ce92b49d..d0ac47b8920
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@@ -65,14 -62,14 +65,14 @@@ ArmatureExporter::ArmatureExporter(bCon
}
// write bone nodes
-void ArmatureExporter::add_armature_bones(bContext *C, Object *ob_arm, Scene *sce,
+void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
SceneExporter *se,
- std::list<Object *>& child_objects)
+ std::vector<Object *>& child_objects)
{
- Main *bmain = CTX_data_main(C);
+ Main *bmain = CTX_data_main(mContext);
// write bone nodes
- bArmature * armature = (bArmature *)ob_arm->data;
+ bArmature *armature = (bArmature *)ob_arm->data;
bool is_edited = armature->edbo != NULL;
if (!is_edited)
diff --cc source/blender/collada/DocumentImporter.cpp
index af4ac72d1c4,67fd9d648c7..60c22f034d5
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@@ -701,11 -703,13 +701,13 @@@ finally
return root_objects;
}
- /** When this method is called, the writer must write the entire visual scene.
- * Return The writer should return true, if writing succeeded, false otherwise. */
+ /**
+ * When this method is called, the writer must write the entire visual scene.
+ * Return The writer should return true, if writing succeeded, false otherwise.
+ */
bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
{
- if (mImportStage != General)
+ if (mImportStage == Fetching_Controller_data)
return true;
// this method called on post process after writeGeometry, writeMaterial, etc.
diff --cc source/blender/collada/collada_utils.cpp
index 81a5a1de354,b25a35a5452..bcd43f9aa00
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@@ -918,139 -811,12 +918,139 @@@ static bool has_custom_props(Bone *bone
}
+void bc_enable_fcurves(bAction *act, char *bone_name)
+{
+ FCurve *fcu;
+ char prefix[200];
+
+ if (bone_name)
+ BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name);
+
+ for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
+ if (bone_name) {
+ if (STREQLEN(fcu->rna_path, prefix, strlen(prefix)))
+ fcu->flag &= ~FCURVE_DISABLED;
+ else
+ fcu->flag |= FCURVE_DISABLED;
+ }
+ else {
+ fcu->flag &= ~FCURVE_DISABLED;
+ }
+ }
+}
+
+bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_opensim)
+{
+
+ /* Ok, lets be super cautious and check if the bone exists */
+ bPose *pose = ob->pose;
+ bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
+ if (!pchan) {
+ return false;
+ }
+
+ bAction *action = bc_getSceneObjectAction(ob);
+ bPoseChannel *parchan = pchan->parent;
+
+ bc_enable_fcurves(action, bone->name);
+ float ipar[4][4];
+
+ if (bone->parent) {
+ invert_m4_m4(ipar, parchan->pose_mat);
+ mul_m4_m4m4(mat, ipar, pchan->pose_mat);
+ }
+ else
+ copy_m4_m4(mat, pchan->pose_mat);
+
+ /* OPEN_SIM_COMPATIBILITY
+ * AFAIK animation to second life is via BVH, but no
+ * reason to not have the collada-animation be correct
+ */
+ if (for_opensim) {
+ float temp[4][4];
+ copy_m4_m4(temp, bone->arm_mat);
+ temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
+ invert_m4(temp);
+
+ mul_m4_m4m4(mat, mat, temp);
+
+ if (bone->parent) {
+ copy_m4_m4(temp, bone->parent->arm_mat);
+ temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
+
+ mul_m4_m4m4(mat, temp, mat);
+ }
+ }
+ bc_enable_fcurves(action, NULL);
+ return true;
+}
+
+bool bc_is_animated(BCMatrixSampleMap &values)
+{
+ static float MIN_DISTANCE = 0.00001;
+
+ if (values.size() < 2)
+ return false; // need at least 2 entries to be not flat
+
+ BCMatrixSampleMap::iterator it;
+ const BCMatrix *refmat = NULL;
+ for (it = values.begin(); it != values.end(); ++it) {
+ const BCMatrix *matrix = it->second;
+
+ if (refmat == NULL) {
+ refmat = matrix;
+ continue;
+ }
+
+ if (!matrix->in_range(*refmat, MIN_DISTANCE))
+ return true;
+ }
+ return false;
+}
+
+bool bc_has_animations(Object *ob)
+{
+ /* Check for object,lamp and camera transform animations */
+ if ((bc_getSceneObjectAction(ob) && bc_getSceneObjectAction(ob)->curves.first) ||
+ (bc_getSceneLampAction(ob) && bc_getSceneLampAction(ob)->curves.first) ||
+ (bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first))
+ return true;
+
+ //Check Material Effect parameter animations.
+ for (int a = 0; a < ob->totcol; a++) {
+ Material *ma = give_current_material(ob, a + 1);
+ if (!ma) continue;
+ if (ma->adt && ma->adt->action && ma->adt->action->curves.first)
+ return true;
+ }
+
+ Key *key = BKE_key_from_object(ob);
+ if ((key && key->adt && key->adt->action) && key->adt->action->curves.first)
+ return true;
+
+ return false;
+}
+
+
+bool bc_has_animations(Scene *sce, LinkNode &export_set)
+{
+ LinkNode *node;
+
+ for (node = &export_set; node; node = node->next) {
+ Object *ob = (Object *)node->link;
+
+ if (bc_has_animations(ob))
+ return true;
+ }
+ return false;
+}
+
/**
- * Check if custom information about bind matrix exists and modify the from_mat
- * accordingly.
- *
- * Note: This is old style for Blender <= 2.78 only kept for compatibility
- */
+ * Check if custom information about bind matrix exists and modify the from_mat
+ * accordingly.
+ *
+ * Note: This is old style for Blender <= 2.78 only kept for compatibility
+ */
void bc_create_restpose_mat(const ExportSettings *export_settings, Bone *bone, float to_mat[4][4], float from_mat[4][4], bool use_local_space)
{
float loc[3];
diff --cc source/tools
index 87f7038ee8c,11656ebaf7f..7695e14cfc5
--- a/source/tools
+++ b/source/tools
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 87f7038ee8c4b46a5e73a1a9065e2a9b7367f594
-Subproject commit 11656ebaf7f912cdb1b5eb39c5d0a3b5d492c1aa
++Subproject commit 7695e14cfc5820ac66546e0e515914d85ab81af3
More information about the Bf-blender-cvs
mailing list