[Bf-blender-cvs] [8e5ed4cfe07] collada: Cleanup: prepended bc_ to utility functions (satisfy name convention)

Gaia Clary noreply at git.blender.org
Wed Mar 28 21:30:13 CEST 2018


Commit: 8e5ed4cfe07717765a89354803ab305243ec2694
Author: Gaia Clary
Date:   Thu Mar 1 14:39:53 2018 +0100
Branches: collada
https://developer.blender.org/rB8e5ed4cfe07717765a89354803ab305243ec2694

Cleanup: prepended bc_ to utility functions (satisfy name convention)

All utility functions from collada should contain the prependix bc_
Some of the new added functions did not comply to the convention.

===================================================================

M	source/blender/collada/AnimationExporter.cpp
M	source/blender/collada/collada_utils.cpp
M	source/blender/collada/collada_utils.h

===================================================================

diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 2247f42b5de..6519420a939 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -147,7 +147,7 @@ void AnimationExporter::create_sampled_animation(int channel_count,
  */
 void AnimationExporter::export_keyframed_animation_set(Object *ob)
 {
-	bAction *action = getSceneObjectAction(ob);
+	bAction *action = bc_getSceneObjectAction(ob);
 	if (!action) {
 		return; /* Object has no animation */
 	}
@@ -200,7 +200,7 @@ void AnimationExporter::export_keyframed_animation_set(Object *ob)
  */
 void AnimationExporter::export_sampled_animation_set(Object *ob)
 {
-	bAction *action = getSceneObjectAction(ob);
+	bAction *action = bc_getSceneObjectAction(ob);
 	if (!action) {
 		return; /* Object has no animation */
 	}
@@ -302,7 +302,7 @@ void AnimationExporter::operator()(Object *ob)
 	/* bool isMatAnim = false; */ /* UNUSED */
 
 	//Export transform animations
-	bAction *action = getSceneObjectAction(ob);
+	bAction *action = bc_getSceneObjectAction(ob);
 
 	if (action) {
 
@@ -328,7 +328,7 @@ void AnimationExporter::operator()(Object *ob)
 	//export_morph_animation(ob);
 		
 	//Export Lamp parameter animations
-	action = getSceneLampAction(ob);
+	action = bc_getSceneLampAction(ob);
 	if (action) {
 		FCurve *fcu = (FCurve *)action->curves.first;
 		while (fcu) {
@@ -344,7 +344,7 @@ void AnimationExporter::operator()(Object *ob)
 	}
 
 	//Export Camera parameter animations
-	action = getSceneCameraAction(ob);
+	action = bc_getSceneCameraAction(ob);
 	if (action) {
 		FCurve *fcu = (FCurve *)action->curves.first;
 		while (fcu) {
@@ -364,7 +364,7 @@ void AnimationExporter::operator()(Object *ob)
 	//Export Material parameter animations.
 	for (int a = 0; a < ob->totcol; a++) {
 		Material *ma = give_current_material(ob, a + 1);
-		action = getSceneMaterialAction(ma);
+		action = bc_getSceneMaterialAction(ma);
 		if (action) {
 			/* isMatAnim = true; */
 			FCurve *fcu = (FCurve *)action->curves.first;
@@ -438,7 +438,7 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
 			for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) {
 				obtar = ct->tar;
 				if (obtar) {
-					find_keyframes(getSceneObjectAction(obtar), frames);
+					find_keyframes(bc_getSceneObjectAction(obtar), frames);
 				}
 			}
 
@@ -454,7 +454,7 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
 */
 float *AnimationExporter::get_eul_source_for_quat(Object *ob)
 {
-	bAction *action = getSceneObjectAction(ob);
+	bAction *action = bc_getSceneObjectAction(ob);
 
 	FCurve *fcu = (FCurve *)action->curves.first;
 	const int keys = fcu->totvert;  
@@ -682,7 +682,7 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char
 //write bone animations in transform matrix sources
 void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone)
 {
-	bAction *action = getSceneObjectAction(ob_arm);
+	bAction *action = bc_getSceneObjectAction(ob_arm);
 	if (!action)
 		return;
 
@@ -736,7 +736,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
 	if (!pchan)
 		return;
 
-	bAction *action = getSceneObjectAction(ob_arm);
+	bAction *action = bc_getSceneObjectAction(ob_arm);
 	if (action) {
 		if (this->export_settings->sampling_rate < 1)
 			find_keyframes(action, fra);
@@ -1308,7 +1308,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &ctimes, std
 */
 std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Object *ob, Bone *bone, const std::string &anim_id)
 {
-	bAction *action = getSceneObjectAction(ob);
+	bAction *action = bc_getSceneObjectAction(ob);
 
 	bool is_bone_animation = ob->type == OB_ARMATURE && bone;
 
@@ -1724,12 +1724,12 @@ bool AnimationExporter::hasAnimations(Scene *sce)
 		FCurve *fcu = 0;
 
 		/* Check for object,lamp and camera transform animations */
-		if (getSceneObjectAction(ob))
-			fcu = (FCurve *)getSceneObjectAction(ob)->curves.first;
-		else if (getSceneLampAction(ob))
-			fcu = (FCurve *)getSceneLampAction(ob)->curves.first;
-		else if (getSceneCameraAction(ob))
-			fcu = (FCurve *)getSceneCameraAction(ob)->curves.first;
+		if (bc_getSceneObjectAction(ob))
+			fcu = (FCurve *)bc_getSceneObjectAction(ob)->curves.first;
+		else if (bc_getSceneLampAction(ob))
+			fcu = (FCurve *)bc_getSceneLampAction(ob)->curves.first;
+		else if (bc_getSceneCameraAction(ob))
+			fcu = (FCurve *)bc_getSceneCameraAction(ob)->curves.first;
 
 		//Check Material Effect parameter animations.
 		for (int a = 0; a < ob->totcol; a++) {
@@ -1860,7 +1860,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
 	if (!pchan)
 		return;
 	//Fill frame array with key frame values framed at \param:transform_type
-	bAction *action = getSceneObjectAction(ob_arm);
+	bAction *action = bc_getSceneObjectAction(ob_arm);
 	switch (transform_type) {
 		case 0:
 			find_rotation_frames(action, fra, prefix, pchan->rotmode);
@@ -1913,7 +1913,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
 
 void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan)
 {
-	bAction *action = getSceneObjectAction(ob_arm);
+	bAction *action = bc_getSceneObjectAction(ob_arm);
 	if (!action) {
 		return;
 	}
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index fcd92e220c0..a70de989140 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -138,6 +138,19 @@ Main *bc_get_main()
 	return G.main;
 }
 
+std::vector<bAction *> bc_getSceneActions()
+{
+	std::vector<bAction *> actions;
+	Main *main = bc_get_main();
+	ID *id;
+
+	for (id = (ID *)main->action.first; id; id = (ID *)(id->next)) {
+		bAction *act = (bAction *)id;
+		actions.push_back(act);
+	}
+	return actions;
+}
+
 EvaluationContext *bc_get_evaluation_context()
 {
 	Main *bmain = G.main;
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 0b937a8aaef..533f5f30c50 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -73,12 +73,14 @@ extern void bc_update_scene(Scene *scene, float ctime);
 
 /* Action helpers */
 
-inline bAction *getSceneObjectAction(Object *ob)
+std::vector<bAction *> bc_getSceneActions();
+
+inline bAction *bc_getSceneObjectAction(Object *ob)
 {
 	return (ob->adt && ob->adt->action) ? ob->adt->action : NULL;
 }
 
-inline bAction *getSceneLampAction(Object *ob)
+inline bAction *bc_getSceneLampAction(Object *ob)
 {
 	if (ob->type != OB_LAMP)
 		return NULL;
@@ -87,7 +89,7 @@ inline bAction *getSceneLampAction(Object *ob)
 	return (lamp->adt && lamp->adt->action) ? lamp->adt->action : NULL;
 }
 
-inline bAction *getSceneCameraAction(Object *ob)
+inline bAction *bc_getSceneCameraAction(Object *ob)
 {
 	if (ob->type != OB_CAMERA)
 		return NULL;
@@ -96,7 +98,7 @@ inline bAction *getSceneCameraAction(Object *ob)
 	return (camera->adt && camera->adt->action) ? camera->adt->action : NULL;
 }
 
-inline bAction *getSceneMaterialAction(Material *ma)
+inline bAction *bc_getSceneMaterialAction(Material *ma)
 {
 	if (ma == NULL)
 		return NULL;
@@ -104,6 +106,13 @@ inline bAction *getSceneMaterialAction(Material *ma)
 	return (ma->adt && ma->adt->action) ? ma->adt->action : NULL;
 }
 
+inline void bc_setSceneObjectAction(bAction *action, Object *ob)
+{
+	if (ob->adt)
+		ob->adt->action = action;
+}
+
+
 extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index);
 extern int bc_test_parent_loop(Object *par, Object *ob);
 extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true);



More information about the Bf-blender-cvs mailing list