Commit: c87899c51016cbca673a65d07b4d2a9fc8e04c31 Author: Gaia Clary Date: Fri Apr 5 21:51:23 2019 +0200 Branches: collada https://developer.blender.org/rBc87899c51016cbca673a65d07b4d2a9fc8e04c31
refactor: Collada: added class wrapper for ExportSettings structure =================================================================== M source/blender/collada/AnimationClipExporter.h M source/blender/collada/AnimationExporter.cpp M source/blender/collada/AnimationExporter.h M source/blender/collada/ArmatureExporter.cpp M source/blender/collada/ArmatureExporter.h M source/blender/collada/CameraExporter.cpp M source/blender/collada/CameraExporter.h M source/blender/collada/ControllerExporter.cpp M source/blender/collada/ControllerExporter.h M source/blender/collada/DocumentExporter.cpp M source/blender/collada/DocumentExporter.h M source/blender/collada/EffectExporter.cpp M source/blender/collada/EffectExporter.h M source/blender/collada/ExportSettings.h M source/blender/collada/GeometryExporter.cpp M source/blender/collada/GeometryExporter.h M source/blender/collada/ImageExporter.cpp M source/blender/collada/ImageExporter.h M source/blender/collada/LightExporter.cpp M source/blender/collada/LightExporter.h M source/blender/collada/MaterialExporter.cpp M source/blender/collada/MaterialExporter.h M source/blender/collada/SceneExporter.cpp M source/blender/collada/SceneExporter.h M source/blender/collada/TransformWriter.cpp M source/blender/collada/TransformWriter.h M source/blender/collada/collada_utils.cpp M source/blender/collada/collada_utils.h =================================================================== diff --git a/source/blender/collada/AnimationClipExporter.h b/source/blender/collada/AnimationClipExporter.h index fd19e8eda5a..8c2825599eb 100644 --- a/source/blender/collada/AnimationClipExporter.h +++ b/source/blender/collada/AnimationClipExporter.h @@ -26,12 +26,12 @@ private: Depsgraph *depsgraph; Scene *scene; COLLADASW::StreamWriter *sw; - const ExportSettings *export_settings; + BCExportSettings &export_settings; std::vector<std::vector<std::string>> anim_meta; public: - AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector<std::vector<std::string>> anim_meta) : + AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, BCExportSettings &export_settings, std::vector<std::vector<std::string>> anim_meta) : COLLADASW::LibraryAnimationClips(sw), depsgraph(depsgraph), scene(nullptr), diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index e9babea7b3d..1a52586f03a 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -80,7 +80,7 @@ bool AnimationExporter::exportAnimations() { Scene *sce = blender_context.get_scene(); - LinkNode &export_set = *this->export_settings->export_set; + LinkNode &export_set = *this->export_settings.get_export_set(); bool has_anim_data = bc_has_animations(sce, export_set); int animation_count = 0; if (has_anim_data) { @@ -92,11 +92,11 @@ bool AnimationExporter::exportAnimations() try { animation_sampler.sample_scene( - export_settings->sampling_rate, + export_settings.get_sampling_rate(), /*keyframe_at_end = */ true, - export_settings->open_sim, - export_settings->keep_keyframes, - export_settings->export_animation_type + export_settings.get_open_sim(), + export_settings.get_keep_keyframes(), + export_settings.get_export_animation_type() ); openLibrary(); @@ -141,7 +141,7 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler) * Note: For Armatures the skeletal animation has already been exported (see above) * However Armatures also can have Object animation. */ - bool export_as_matrix = this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX; + bool export_as_matrix = this->export_settings.get_export_transformation_type() == BC_TRANSFORMATION_TYPE_MATRIX; if (export_as_matrix) { export_matrix_animation(ob, sampler); // export all transform_curves as one single matrix animation @@ -178,7 +178,7 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler) void AnimationExporter::export_curve_animation_set(Object *ob, BCAnimationSampler &sampler, bool export_as_matrix) { BCAnimationCurveMap *curves = sampler.get_curves(ob); - bool keep_flat_curves = this->export_settings->keep_flat_curves; + bool keep_flat_curves = this->export_settings.get_keep_flat_curves(); BCAnimationCurveMap::iterator it; for (it = curves->begin(); it != curves->end(); ++it) { @@ -217,7 +217,7 @@ void AnimationExporter::export_curve_animation_set(Object *ob, BCAnimationSample void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &sampler) { - bool keep_flat_curves = this->export_settings->keep_flat_curves; + bool keep_flat_curves = this->export_settings.get_keep_flat_curves(); std::vector<float> frames; sampler.get_object_frames(frames, ob); @@ -242,7 +242,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler & //write bone animations in transform matrix sources void AnimationExporter::export_bone_animations_recursive(Object *ob, Bone *bone, BCAnimationSampler &sampler) { - bool keep_flat_curves = this->export_settings->keep_flat_curves; + bool keep_flat_curves = this->export_settings.get_keep_flat_curves(); std::vector<float> frames; sampler.get_bone_frames(frames, ob, bone); @@ -399,7 +399,7 @@ void AnimationExporter::export_collada_curve_animation( bool has_tangents = false; std::string interpolation_id; - if (this->export_settings->keep_smooth_curves) + if (this->export_settings.get_keep_smooth_curves()) interpolation_id = collada_interpolation_source(curve, id, axis, &has_tangents); else interpolation_id = collada_linear_interpolation_source(frames.size(), id); @@ -619,7 +619,7 @@ std::string AnimationExporter::collada_source_from_values(BCMatrixSampleMap &sam source.prepareToAppendValues(); BCMatrixSampleMap::iterator it; - int precision = (this->export_settings->limit_precision) ? 6 : -1; // could be made configurable + int precision = (this->export_settings.get_limit_precision()) ? 6 : -1; // could be made configurable for (it = samples.begin(); it != samples.end(); it++) { const BCMatrix *sample = it->second; double daemat[4][4]; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 7af4777331d..70f3f786658 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -92,11 +92,11 @@ class AnimationExporter: COLLADASW::LibraryAnimations private: BlenderContext &blender_context; COLLADASW::StreamWriter *sw; - const ExportSettings *export_settings; + BCExportSettings &export_settings; public: - AnimationExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): + AnimationExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, BCExportSettings &export_settings): COLLADASW::LibraryAnimations(sw), blender_context(blender_context), sw(sw), diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index de4c4794547..15cbd3d879c 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -77,7 +77,7 @@ void ArmatureExporter::add_armature_bones( void ArmatureExporter::write_bone_URLs(COLLADASW::InstanceController &ins, Object *ob_arm, Bone *bone) { - if (bc_is_root_bone(bone, this->export_settings->deform_bones_only)) { + if (bc_is_root_bone(bone, this->export_settings.get_deform_bones_only())) { std::string joint_id = translate_id(id_name(ob_arm) + "_" + bone->name); ins.addSkeleton(COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, joint_id)); } @@ -107,7 +107,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob) write_bone_URLs(ins, ob_arm, bone); } - InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only); + InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings.get_active_uv_only()); ins.add(); return true; @@ -154,7 +154,7 @@ void ArmatureExporter::add_bone_node( SceneExporter *se, std::vector<Object *>& child_objects) { - if (!(this->export_settings->deform_bones_only && bone->flag & BONE_NO_DEFORM)) { + if (can_export(bone)) { std::string node_id = translate_id(id_name(ob_arm) + "_" + bone->name); std::string node_name = std::string(bone->name); std::string node_sid = get_joint_sid(bone); @@ -166,9 +166,9 @@ void ArmatureExporter::add_bone_node( node.setNodeName(node_name); node.setNodeSid(node_sid); - if (this->export_settings->use_blender_profile) + if (this->export_settings.get_use_blender_profile()) { - if (bone->parent) { + if (!is_export_root(bone)) { if (bone->flag & BONE_CONNECTED) { node.addExtraTechniqueParameter("blender", "connect", true); } @@ -214,7 +214,7 @@ void ArmatureExporter::add_bone_node( // TODO: when such objects are animated as // single matrix the tweak must be applied // to the result. - if (export_settings->open_sim) { + if (export_settings.get_open_sim()) { // tweak objects parentinverse to match compatibility float temp[4][4]; @@ -243,6 +243,18 @@ void ArmatureExporter::add_bone_node( } } +bool ArmatureExporter::is_export_root(Bone *bone) +{ + Bone *entry = bone->parent; + while (entry) { + if (can_export(entry)) { + return false; + } + entry = entry->parent; + } + return can_export(bone); +} + void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node) { //bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); @@ -277,7 +289,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: } // OPEN_SIM_COMPATIBILITY - if (export_settings->open_sim) { + if (export_settings.get_open_sim()) { // Remove rotations vs armature from transform // parent_rest_rot * mat * irest_rot float temp[4][4]; @@ -296,8 +308,9 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: } } - if (this->export_settings->limit_precision) + if (this->export_settings.get_limit_precision()) { bc_sanitize_mat(mat, LIMITTED_PRECISION); + } TransformWriter::add_node_transform(node, mat, NULL); diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h index 11f853621a0..2ac480b4cf2 100644 --- a/source/blender/collada/ArmatureExporter.h +++ b/source/blender/collada/ArmatureExporter.h @@ -54,7 +54,7 @@ public: // XXX exporter writes wrong data for shared armatures. A separate // controller should be written for each armature-mesh binding how do // we make controller ids then? - ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : + ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, BCExportSettings &export_settings) : COLLADASW::LibraryControllers(sw), blender_context(blender_context), export_settings(export_settings) @@ -70,7 +70,7 @@ public: private: BlenderContext &blender_context; - const ExportSettings *export_settings; + BCExportSettings &export_settings; #if 0 std::vector<Object *> written_armatures; @@ -90,6 +90,12 @@ private: SceneExporter *se, std::vector<Object *>& child_objects); + @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs