diff options
Diffstat (limited to 'source/blender/collada')
38 files changed, 371 insertions, 371 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index fc4bbea108b..95298986f5a 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -270,7 +270,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve create_sampled_animation(3, ctimes, baked_curves[SCALE], ob_name, "scale", "", false); create_sampled_animation(3, ctimes, baked_curves[LOC], ob_name, "location", "", false); - /* Not sure how to export rotation as a 3channel animation, + /* Not sure how to export rotation as a 3channel animation, * so separate into 3 single animations for now: */ @@ -314,7 +314,7 @@ void AnimationExporter::operator()(Object *ob) //This needs to be handled by extra profiles, so postponed for now //export_morph_animation(ob); - + //Export Lamp parameter animations if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action) { FCurve *fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first); @@ -338,7 +338,7 @@ void AnimationExporter::operator()(Object *ob) if ((STREQ(transformName, "lens")) || (STREQ(transformName, "ortho_scale")) || - (STREQ(transformName, "clip_end")) || + (STREQ(transformName, "clip_end")) || (STREQ(transformName, "clip_start"))) { create_keyframed_animation(ob, fcu, transformName, true); @@ -380,7 +380,7 @@ void AnimationExporter::export_object_constraint_animation(Object *ob) } void AnimationExporter::export_morph_animation(Object *ob) -{ +{ FCurve *fcu; char *transformName; Key *key = BKE_key_from_object(ob); @@ -388,12 +388,12 @@ void AnimationExporter::export_morph_animation(Object *ob) if (key->adt && key->adt->action) { fcu = (FCurve *)key->adt->action->curves.first; - + while (fcu) { transformName = extract_transform_name(fcu->rna_path); create_keyframed_animation(ob, fcu, transformName, true); - + fcu = fcu->next; } } @@ -407,17 +407,17 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl bConstraint *con; for (con = (bConstraint *)conlist->first; con; con = con->next) { ListBase targets = {NULL, NULL}; - + const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); - + if (!validateConstraints(con)) continue; if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; Object *obtar; - /* get targets + /* get targets * - constraints should use ct->matrix, not directly accessing values - * - ct->matrix members have not yet been calculated here! + * - ct->matrix members have not yet been calculated here! */ cti->get_constraint_targets(con, &targets); @@ -438,7 +438,7 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl float *AnimationExporter::get_eul_source_for_quat(Object *ob) { FCurve *fcu = (FCurve *)ob->adt->action->curves.first; - const int keys = fcu->totvert; + const int keys = fcu->totvert; float *quat = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values"); float *eul = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values"); float temp_quat[4]; @@ -520,11 +520,11 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char /* * Note: Handle transformation animations separately (to apply matrix inverse to fcurves) - * We will use the object to evaluate the animation on all keyframes and calculate the + * We will use the object to evaluate the animation on all keyframes and calculate the * resulting object matrix. We need this to incorporate the * effects of the parent inverse matrix (when it contains a rotation component) * - * TODO: try to combine exported fcurves into 3 channel animations like done + * TODO: try to combine exported fcurves into 3 channel animations like done * in export_sampled_animation(). For now each channel is exported as separate <Animation>. */ @@ -648,7 +648,7 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char "/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); //if shape key animation, this is the main problem, how to define the channel targets. /*target = get_morph_id(ob) + - "/value" +*/ + "/value" +*/ } addChannel(COLLADABU::URI(empty, sampler_id), target); @@ -673,7 +673,7 @@ void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone) } bool AnimationExporter::is_bone_deform_group(Bone *bone) -{ +{ bool is_def; //Check if current bone is deform if ((bone->flag & BONE_NO_DEFORM) == 0) return true; @@ -707,7 +707,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B fcu = fcu->next; } - if (!(fcu)) return;*/ + if (!(fcu)) return;*/ bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); if (!pchan) @@ -728,7 +728,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B dae_baked_animation(fra, ob_arm, bone); } - if (flag & ARM_RESTPOS) + if (flag & ARM_RESTPOS) arm->flag = flag; BKE_pose_where_is(depsgraph, scene, ob_arm); } @@ -921,7 +921,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa if (axis) { param.push_back(axis); } - else + else if (transform) { param.push_back("TRANSFORM"); } @@ -1307,7 +1307,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj enable_fcurves(ob->adt->action, bone->name); } - + std::vector<float>::iterator it; int j = 0; for (it = frames.begin(); it != frames.end(); it++) { @@ -1326,7 +1326,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj else { BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1); } - + // compute bone local mat if (bone->parent) { invert_m4_m4(ipar, parchan->pose_mat); @@ -1334,7 +1334,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj } 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 @@ -1359,7 +1359,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj else { copy_m4_m4(mat, ob->obmat); } - + UnitConverter converter; double outmat[4][4]; @@ -1515,7 +1515,7 @@ std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, if (tm_name.size()) { if (axis_name[0]) return tm_name + "." + std::string(axis_name); - else + else return tm_name; } @@ -1564,7 +1564,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, if (tm_name.size()) { if (axis_name[0]) return tm_name + "." + std::string(axis_name); - else + else return tm_name; } @@ -1751,7 +1751,7 @@ void AnimationExporter::find_sampleframes(Object *ob, std::vector<float> &fra) } while (true); } -/* +/* * find keyframes of all the objects animations */ void AnimationExporter::find_keyframes(Object *ob, std::vector<float> &fra) @@ -1844,7 +1844,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo arm->flag &= ~ARM_RESTPOS; BKE_pose_where_is(depsgraph, scene, ob_arm); } - //v array will hold all values which will be exported. + //v array will hold all values which will be exported. if (fra.size()) { float *values = (float *)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); sample_animation(values, fra, transform_type, bone, ob_arm, pchan); @@ -1870,7 +1870,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo } // restore restpos - if (flag & ARM_RESTPOS) + if (flag & ARM_RESTPOS) arm->flag = flag; BKE_pose_where_is(depsgraph, scene, ob_arm); } diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 2ed0a92d89c..a50bcaf0ef4 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -23,7 +23,7 @@ #include <stdlib.h> #include <stdio.h> #include <math.h> -extern "C" +extern "C" { #include "DNA_scene_types.h" #include "DNA_object_types.h" @@ -100,8 +100,8 @@ public: bool exportAnimations(Scene *sce); // called for each exported object - void operator() (Object *ob); - + void operator() (Object *ob); + protected: const ExportSettings *export_settings; @@ -127,7 +127,7 @@ protected: // dae_bone_animation -> add_bone_animation // (blend this into dae_bone_animation) void dae_bone_animation(std::vector<float> &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name); - + void dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone); void dae_baked_object_animation(std::vector<float> &fra, Object *ob); @@ -140,9 +140,9 @@ protected: void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform); - + void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values, int *length); - + float* get_eul_source_for_quat(Object *ob ); bool is_flat_line(std::vector<float> &values, int channel_count); @@ -171,12 +171,12 @@ protected: std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents); std::string fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name); - + // for rotation, axis name is always appended and the value of append_axis is ignored std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); std::string get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); std::string get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); - + void find_keyframes(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name); void find_keyframes(Object *ob, std::vector<float> &fra); void find_sampleframes(Object *ob, std::vector<float> &fra); @@ -185,13 +185,13 @@ protected: void make_anim_frames_from_targets(Object *ob, std::vector<float> &frames ); void find_rotation_frames(Object *ob, std::vector<float> &fra, const char *prefix, int rotmode); - + // enable fcurves driving a specific bone, disable all the rest // if bone_name = NULL enable all fcurves void enable_fcurves(bAction *act, char *bone_name); - + bool hasAnimations(Scene *sce); - + char *extract_transform_name(char *rna_path); std::string getObjectBoneName(Object *ob, const FCurve * fcu); diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 489aceda0c2..e57f8c2f652 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -118,7 +118,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) // input, output - bez.vec[1][0] = bc_get_float_value(input, j) * fps; + bez.vec[1][0] = bc_get_float_value(input, j) * fps; bez.vec[1][1] = bc_get_float_value(output, j * dim + i); @@ -135,14 +135,14 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) // outtangent bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps; bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1); - if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) + if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) bez.ipo = BEZT_IPO_BEZ; - else + else bez.ipo = BEZT_IPO_CONST; //bez.h1 = bez.h2 = HD_AUTO; } else { - bez.h1 = bez.h2 = HD_AUTO; + bez.h1 = bez.h2 = HD_AUTO; bez.ipo = BEZT_IPO_LIN; } // bez.ipo = U.ipo_new; /* use default interpolation mode here... */ @@ -183,10 +183,10 @@ void AnimationImporter::fcurve_is_used(FCurve *fcu) void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated) { bAction *act; - + if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1); else act = ob->adt->action; - + std::vector<FCurve *>::iterator it; int i; @@ -198,39 +198,39 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vect if (is_rotation) fcurve_deg_to_rad(fcu); #endif - + for (it = curves.begin(), i = 0; it != curves.end(); it++, i++) { FCurve *fcu = *it; fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); - + if (array_index == -1) fcu->array_index = i; else fcu->array_index = array_index; - + if (ob->type == OB_ARMATURE) { bActionGroup *grp = NULL; const char *bone_name = bc_get_joint_name(animated->node); - + if (bone_name) { /* try to find group */ grp = BKE_action_group_find_name(act, bone_name); - + /* no matching groups, so add one */ if (grp == NULL) { /* Add a new group, and make it active */ grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup"); - + grp->flag = AGRP_SELECTED; BLI_strncpy(grp->name, bone_name, sizeof(grp->name)); - + BLI_addtail(&act->groups, grp); BLI_uniquename(&act->groups, grp, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "Group"), '.', offsetof(bActionGroup, name), 64); } - + /* add F-Curve to group */ action_groups_add_channel(act, grp, fcu); fcurve_is_used(fcu); - + } #if 0 if (is_rotation) { @@ -263,7 +263,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim) { if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) { COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim; - + // XXX Don't know if it's necessary // Should we check outPhysicalDimension? if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) { @@ -296,10 +296,10 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim) else { fprintf(stderr, "FORMULA animation type is not supported yet.\n"); } - + return true; } - + // called on post-process stage after writeVisualScenes bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist) { @@ -340,16 +340,16 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) { bActionGroup *grp; int i; - + for (grp = (bActionGroup *)act->groups.first; grp; grp = grp->next) { FCurve *eulcu[3] = {NULL, NULL, NULL}; - + if (fcurves_actionGroup_map.find(grp) == fcurves_actionGroup_map.end()) continue; std::vector<FCurve *> &rot_fcurves = fcurves_actionGroup_map[grp]; - + if (rot_fcurves.size() > 3) continue; for (i = 0; i < rot_fcurves.size(); i++) @@ -437,7 +437,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves, const char for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) { FCurve *fcu = *it; fcu->rna_path = BLI_strdup(rna_path); - + if (array_index == -1) fcu->array_index = i; else fcu->array_index = array_index; @@ -674,7 +674,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list } } } - + } float AnimationImporter::convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx) @@ -711,7 +711,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid //Add the curves of the current animation to the object for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve *fcu = *iter; - + for (unsigned int i = 0; i < fcu->totvert; i++) { fcu->bezt[i].vec[0][1] = convert_to_focal_length(fcu->bezt[i].vec[0][1], fov_type, aspect, cam->sensor_x); fcu->bezt[i].vec[1][1] = convert_to_focal_length(fcu->bezt[i].vec[1][1], fov_type, aspect, cam->sensor_x); @@ -949,7 +949,7 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node, const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); - //for each transformation in node + //for each transformation in node for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) { COLLADAFW::Transformation *transform = nodeTransforms[i]; COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType(); @@ -986,12 +986,12 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node, //Add the curves of the current animation to the object for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve *fcu = *iter; - + BLI_addtail(AnimCurves, fcu); fcurve_is_used(fcu); } } - + } } } @@ -1017,7 +1017,7 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node, const COLLADAFW::Color *col = &(light->getColor()); const COLLADAFW::UniqueId& listid = col->getAnimationList(); - Assign_color_animations(listid, AnimCurves, "color"); + Assign_color_animations(listid, AnimCurves, "color"); } if ((animType->light & LIGHT_FOA) != 0) { const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle()); @@ -1051,14 +1051,14 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node, if ((animType->camera & CAMERA_XFOV) != 0) { const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov()); const COLLADAFW::UniqueId& listid = xfov->getAnimationList(); - double aspect = get_aspect_ratio(camera); + double aspect = get_aspect_ratio(camera); Assign_lens_animations(listid, AnimCurves, aspect, cam, "lens", CAMERA_XFOV); } else if ((animType->camera & CAMERA_YFOV) != 0) { const COLLADAFW::AnimatableFloat *yfov = &(camera->getYFov()); const COLLADAFW::UniqueId& listid = yfov->getAnimationList(); - double aspect = get_aspect_ratio(camera); + double aspect = get_aspect_ratio(camera); Assign_lens_animations(listid, AnimCurves, aspect, cam, "lens", CAMERA_YFOV); } @@ -1281,7 +1281,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAF const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); - //for each transformation in node + //for each transformation in node for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) { COLLADAFW::Transformation *transform = nodeTransforms[i]; const COLLADAFW::UniqueId& listid = transform->getAnimationList(); @@ -1369,7 +1369,7 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types, anim_type = types; return anim_type; -} +} // Is not used anymore. void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::Node *node, COLLADAFW::Transformation::TransformationType tm_type) @@ -1391,7 +1391,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::N const COLLADAFW::UniqueId& listid = transform->getAnimationList(); //if transform is animated its animlist must exist. if (animlist_map.find(listid) != animlist_map.end()) { - + const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); @@ -1441,11 +1441,11 @@ Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node COLLADAFW::Transformation::TransformationType tm_type, Object *par_job) { - + bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; bool is_joint = node->getType() == COLLADAFW::Node::JOINT; - + COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()]; Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()]; const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; @@ -1456,11 +1456,11 @@ Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node // frames at which to sample std::vector<float> frames; - + find_frames_old(&frames, node, tm_type); - + unsigned int i; - + float irest_dae[4][4]; float rest[4][4], irest[4][4]; @@ -1731,9 +1731,9 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW:: } } -static void report_class_type_unsupported(const char *path, +static void report_class_type_unsupported(const char *path, const COLLADAFW::AnimationList::AnimationClass animclass, - const COLLADAFW::Transformation::TransformationType type) + const COLLADAFW::Transformation::TransformationType type) { if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) { fprintf(stderr, "%s: UNKNOWN animation class\n", path); @@ -1828,7 +1828,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size()); return false; } - + switch (animclass) { case COLLADAFW::AnimationList::POSITION_X: vec[0] = evaluate_fcurve(curves[0], fra); @@ -2010,7 +2010,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv { const char *bone_name = bc_get_joint_name(node); bAction *act = ob->adt->action; - + /* try to find group */ bActionGroup *grp = BKE_action_group_find_name(act, bone_name); diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 0957b1e6e06..f63329158f0 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -19,7 +19,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ - + /** \file AnimationImporter.h * \ingroup collada */ @@ -75,9 +75,9 @@ private: std::map<COLLADAFW::UniqueId, const COLLADAFW::AnimationList*> animlist_map; std::vector<FCurve*> unused_curves; std::map<COLLADAFW::UniqueId, Object*> joint_objects; - + FCurve *create_fcurve(int array_index, const char *rna_path); - + void add_bezt(FCurve *fcu, float frame, float value, eBezTriple_Interpolation ipo=BEZT_IPO_LIN); // create one or several fcurves depending on the number of parameters being animated @@ -89,7 +89,7 @@ private: void add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated); - + int typeFlag; std::string import_from_version; @@ -121,7 +121,7 @@ private: MATERIAL_TRANSPARENCY = 1 << 4, MATERIAL_IOR = 1 << 5 }; - + enum AnimationType { INANIMATE = 0, @@ -144,7 +144,7 @@ public: void set_import_from_version(std::string import_from_version); bool write_animation(const COLLADAFW::Animation* anim); - + // called on post-process stage after writeVisualScenes bool write_animation_list(const COLLADAFW::AnimationList* animlist); @@ -163,7 +163,7 @@ public: void apply_matrix_curves(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm ); - + void add_bone_animation_sampled(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm); void Assign_transform_animations(COLLADAFW::Transformation* transform, @@ -175,7 +175,7 @@ public: void Assign_lens_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const double aspect, Camera *cam, const char *anim_type, int fov_type); int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition); - + void modify_fcurve(std::vector<FCurve*>* curves, const char *rna_path, int array_index ); void unused_fcurve(std::vector<FCurve*>* curves ); // prerequisites: @@ -186,7 +186,7 @@ public: 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 ); // internal, better make it private diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index c50de1ef72e..85b9d3297ca 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -118,7 +118,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob) } InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only); - + ins.add(); return true; } @@ -147,7 +147,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O Base *base = (Base *) sce->base.first; while (base) { Object *ob = base->object; - + if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) { objects.push_back(ob); } @@ -265,7 +265,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: if (!has_restmat) { /* Have no restpose matrix stored, try old style <= Blender 2.78 */ - + bc_create_restpose_mat(this->export_settings, bone, bone_rest_mat, bone->arm_mat, true); if (bone->parent) { diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 6bf6087c054..19f174d4840 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -61,7 +61,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, view_layer(view_layer), unit_converter(conv), import_settings(import_settings), - empty(NULL), + empty(NULL), mesh_importer(mesh) { } @@ -103,7 +103,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon std::vector<COLLADAFW::Node *>::iterator it; it = std::find(finished_joints.begin(), finished_joints.end(), node); if (it != finished_joints.end()) return chain_length; - + EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node)); totbone++; @@ -141,7 +141,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon if (parent) bone->parent = parent; - float loc[3], size[3], rot[3][3]; + float loc[3], size[3], rot[3][3]; BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(arm); BoneExtended &be = add_bone_extended(bone, node, totchild, layer_labels, extended_bones); int layer = be.get_bone_layers(); @@ -386,7 +386,7 @@ void ArmatureImporter::set_euler_rotmode() COLLADAFW::Node *joint = it->second; std::map<COLLADAFW::UniqueId, SkinInfo>::iterator sit; - + for (sit = skin_by_data_uid.begin(); sit != skin_by_data_uid.end(); sit++) { SkinInfo& skin = sit->second; @@ -410,7 +410,7 @@ void ArmatureImporter::set_euler_rotmode() Object *ArmatureImporter::get_empty_for_leaves() { if (empty) return empty; - + empty = bc_add_object(scene, view_layer, OB_EMPTY, NULL); empty->empty_drawtype = OB_EMPTY_SPHERE; @@ -456,7 +456,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *> //if there is an armature created for root_joint next root_joint for (ri = root_joints.begin(); ri != root_joints.end(); ri++) { if (get_armature_for_joint(*ri) != NULL) continue; - + Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()]; if (!ob_arm) continue; @@ -572,8 +572,8 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo& skin) } if (!shared && this->joint_parent_map.size() > 0) { - // All armatures have been created while creating the Node tree. - // The Collada exporter currently does not create a + // All armatures have been created while creating the Node tree. + // The Collada exporter currently does not create a // strict relationship between geometries and armatures // So when we reimport a Blender collada file, then we have // to guess what is meant. @@ -657,12 +657,12 @@ void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, con } else { - + copy_m4_m4(mat, obmat); float invObmat[4][4]; invert_m4_m4(invObmat, ob_arm->obmat); mul_m4_m4m4(pchan->pose_mat, invObmat, mat); - + } //float angle = 0.0f; @@ -758,7 +758,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object // free memory stolen from SkinControllerData skin.free(); } - + //for bones without skins create_armature_bones(bmain, ob_arms); @@ -808,9 +808,9 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle // don't forget to call defgroup_unique_name before we copy - // controller data uid -> [armature] -> joint data, + // controller data uid -> [armature] -> joint data, // [mesh object] - // + // SkinInfo skin(unit_converter); skin.borrow_skin_controller_data(data); @@ -868,7 +868,7 @@ void ArmatureImporter::make_shape_keys() //Prereq: all the geometries must be imported and mesh objects must be made Object *source_ob = this->mesh_importer->get_object_by_geom_uid((*mc)->getSource()); - + if (source_ob) { Mesh *source_me = (Mesh *)source_ob->data; @@ -876,7 +876,7 @@ void ArmatureImporter::make_shape_keys() Key *key = source_me->key = BKE_key_add((ID *)source_me); key->type = KEY_RELATIVE; KeyBlock *kb; - + //insert basis key kb = BKE_keyblock_add_ctime(key, "Basis", false); BKE_keyblock_convert_from_mesh(source_me, kb); @@ -887,14 +887,14 @@ void ArmatureImporter::make_shape_keys() //This'll do for now since only mesh morphing is imported Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); - + if (me) { me->key = key; std::string morph_name = *this->mesh_importer->get_geometry_name(me->id.name); kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false); BKE_keyblock_convert_from_mesh(me, kb); - + //apply weights weight = morphWeights.getFloatValues()->getData()[i]; kb->curval = weight; @@ -990,14 +990,14 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone, COLLADAFW::Nod has_connect = et->setData("connect", &connect_type); bool has_roll = et->setData("roll", &roll); - + layers = et->setData("layer", layers); if (has_tail && !has_connect) { /* got a bone tail definition but no connect info -> bone is not connected */ has_connect = true; - connect_type = 0; + connect_type = 0; } be->set_bone_layers(layers, layer_labels); diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index 9f8961a41a2..b13e40bf855 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -158,16 +158,16 @@ public: bool write_controller(const COLLADAFW::Controller* controller); COLLADAFW::UniqueId *get_geometry_uid(const COLLADAFW::UniqueId& controller_uid); - + Object *get_armature_for_joint(COLLADAFW::Node *node); void get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count); - + // gives a world-space mat bool get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint); void set_tags_map( TagsMap& tags_map); - + }; #endif diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp index 649288c2db4..32bd24f1e0b 100644 --- a/source/blender/collada/CameraExporter.cpp +++ b/source/blender/collada/CameraExporter.cpp @@ -56,9 +56,9 @@ void forEachCameraObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set void CamerasExporter::exportCameras(Scene *sce) { openLibrary(); - + forEachCameraObjectInExportSet(sce, *this, this->export_settings->export_set); - + closeLibrary(); } void CamerasExporter::operator()(Object *ob, Scene *sce) diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index f6dbc965b42..122094e33a6 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -99,7 +99,7 @@ bool ControllerExporter::add_instance_controller(Object *ob) } InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only); - + ins.add(); return true; } @@ -148,7 +148,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O Base *base = (Base *) sce->base.first; while (base) { Object *ob = base->object; - + if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) { objects.push_back(ob); } @@ -203,7 +203,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) this->export_settings->export_mesh_type, this->export_settings->apply_modifiers, this->export_settings->triangulate); - + if (!me->dvert) return; std::string controller_name = id_name(ob_arm); @@ -246,7 +246,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) for (j = 0; j < vert->totweight; j++) { int idx = vert->dw[j].def_nr; if (idx >= joint_index_by_def_index.size()) { - // XXX: Maybe better find out where and + // XXX: Maybe better find out where and // why the Out Of Bound indexes get created ? oob_counter += 1; } @@ -314,7 +314,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key) std::string targets_id = add_morph_targets(key, ob); std::string morph_weights_id = add_morph_weights(key, ob); - + COLLADASW::TargetsElement targets(mSW); COLLADASW::InputList &input = targets.getInputList(); @@ -376,7 +376,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob) COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); param.push_back("MORPH_WEIGHT"); - + source.prepareToAppendValues(); KeyBlock *kb = (KeyBlock *)key->block.first; @@ -396,7 +396,7 @@ void ControllerExporter::add_weight_extras(Key *key) { // can also try the base element and param alternative COLLADASW::BaseExtraTechnique extra; - + KeyBlock * kb = (KeyBlock *)key->block.first; //skip the basis kb = kb->next; @@ -447,7 +447,7 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, ListBase *defb source.setArrayId(source_id + ARRAY_ID_SUFFIX); source.setAccessorCount(totjoint); source.setAccessorStride(1); - + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); param.push_back("JOINT"); @@ -480,7 +480,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas source.setArrayId(source_id + ARRAY_ID_SUFFIX); source.setAccessorCount(totjoint); //BLI_listbase_count(defbase)); source.setAccessorStride(16); - + source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); param.push_back("TRANSFORM"); @@ -509,7 +509,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas float bind_mat[4][4]; /* derived from bone->arm_mat */ bool has_bindmat = bc_get_property_matrix(pchan->bone, "bind_mat", bind_mat); - + if (!has_bindmat) { /* Have no bind matrix stored, try old style <= Blender 2.78 */ @@ -571,7 +571,7 @@ std::string ControllerExporter::add_weights_source(Mesh *me, const std::string& source.setArrayId(source_id + ARRAY_ID_SUFFIX); source.setAccessorCount(weights.size()); source.setAccessorStride(1); - + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); param.push_back("WEIGHT"); diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 2e5d1757c4c..9e78c164dad 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -62,7 +62,7 @@ #include "COLLADASWInstanceNode.h" #include "COLLADASWBaseInputElement.h" -extern "C" +extern "C" { #include "DNA_scene_types.h" #include "DNA_object_types.h" @@ -257,14 +257,14 @@ int DocumentExporter::exportCurrentScene(bContext *C, Scene *sce) #endif asset.getContributor().mAuthoringTool = version_buf; asset.add(); - + LinkNode *export_set = this->export_settings->export_set; // <library_cameras> if (bc_has_object_type(export_set, OB_CAMERA)) { CamerasExporter ce(writer, this->export_settings); ce.exportCameras(sce); } - + // <library_lights> if (bc_has_object_type(export_set, OB_LAMP)) { LightsExporter le(writer, this->export_settings); @@ -274,11 +274,11 @@ int DocumentExporter::exportCurrentScene(bContext *C, Scene *sce) // <library_images> ImagesExporter ie(writer, this->export_settings); ie.exportImages(sce); - + // <library_effects> EffectsExporter ee(writer, this->export_settings); ee.exportEffects(sce); - + // <library_materials> MaterialsExporter me(writer, this->export_settings); me.exportMaterials(sce); @@ -292,7 +292,7 @@ int DocumentExporter::exportCurrentScene(bContext *C, Scene *sce) // <library_controllers> ArmatureExporter arm_exporter(writer, this->export_settings); ControllerExporter controller_exporter(writer, this->export_settings); - if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys) + if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys) { controller_exporter.export_controllers(depsgraph, sce); } @@ -307,13 +307,13 @@ int DocumentExporter::exportCurrentScene(bContext *C, Scene *sce) ae.exportAnimations(sce); } se.exportScene(C, depsgraph, sce); - + // <scene> std::string scene_name(translate_id(id_name(sce))); COLLADASW::Scene scene(writer, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, scene_name)); scene.add(); - + // close <Collada> writer->endDocument(); delete writer; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 30e32c346ee..ae573fec0d8 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -130,7 +130,7 @@ bool DocumentImporter::import() COLLADASaxFWL::Loader loader(&errorHandler); COLLADAFW::Root root(&loader, this); ExtraHandler *ehandler = new ExtraHandler(this, &(this->anim_importer)); - + loader.registerExtraDataCallbackHandler(ehandler); // deselect all to select new objects @@ -143,19 +143,19 @@ bool DocumentImporter::import() delete ehandler; return false; } - + if (errorHandler.hasError()) { delete ehandler; return false; } - + /** TODO set up scene graph and such here */ - + mImportStage = Controller; - + COLLADASaxFWL::Loader loader2; COLLADAFW::Root root2(&loader2, this); - + if (!root2.loadDocument(encodedFilename)) { fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n"); delete ehandler; @@ -198,7 +198,7 @@ void DocumentImporter::finish() for (sit = vscenes.begin(); sit != vscenes.end(); sit++) { PointerRNA sceneptr, unit_settings; PropertyRNA *system, *scale; - + // for scene unit settings: system, scale_length RNA_id_pointer_create(&sce->id, &sceneptr); @@ -207,7 +207,7 @@ void DocumentImporter::finish() scale = RNA_struct_find_property(&unit_settings, "scale_length"); if (this->import_settings->import_units) { - + switch (unit_converter.isMetricSystem()) { case UnitConverter::Metric: RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC); @@ -272,7 +272,7 @@ void DocumentImporter::finish() DEG_relations_tag_update(bmain); } - + bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units); delete objects_to_scale; @@ -473,7 +473,7 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) short type = 0; et->setData("type", &type); BKE_constraint_add_for_object(ob, "Test_con", type); - + } } @@ -634,7 +634,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA root_objects->push_back(ob); } } - + // XXX: if there're multiple instances, only one is stored if (!ob) { @@ -700,7 +700,7 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen { if (mImportStage != General) return true; - + // this method called on post process after writeGeometry, writeMaterial, etc. // for each <node> in <visual_scene>: @@ -712,18 +712,18 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen // we link Objects with Meshes here vscenes.push_back(visualScene); - + return true; } -/** When this method is called, the writer must handle all nodes contained in the +/** When this method is called, the writer must handle all nodes contained in the * library nodes. * \return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes) { if (mImportStage != General) return true; - + Scene *sce = CTX_data_scene(mContext); const COLLADAFW::NodePointerArray& nodes = libraryNodes->getNodes(); @@ -743,7 +743,7 @@ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom) { if (mImportStage != General) return true; - + return mesh_importer.write_geometry(geom); } @@ -753,13 +753,13 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat) { if (mImportStage != General) return true; - + const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); Material *ma = BKE_material_add(G.main, (char *)str_mat_id.c_str()); - + this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; this->uid_material_map[cmat->getUniqueId()] = ma; - + return true; } @@ -768,7 +768,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType(); // TODO: add back texture and extended material parameter support - + // blinn if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) { #if 0 @@ -802,9 +802,9 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia #if 0 ma->ang = ef->getIndexOfRefraction().getFloatValue(); #endif - + COLLADAFW::Color col; - + // DIFFUSE // color if (ef->getDiffuse().isColor()) { @@ -816,7 +816,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia // texture else if (ef->getDiffuse().isTexture()) { #if 0 - COLLADAFW::Texture ctex = ef->getDiffuse().getTexture(); + COLLADAFW::Texture ctex = ef->getDiffuse().getTexture(); #endif } // AMBIENT @@ -829,7 +829,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia // texture else if (ef->getAmbient().isTexture()) { #if 0 - COLLADAFW::Texture ctex = ef->getAmbient().getTexture(); + COLLADAFW::Texture ctex = ef->getAmbient().getTexture(); #endif } // SPECULAR @@ -843,7 +843,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia // texture else if (ef->getSpecular().isTexture()) { #if 0 - COLLADAFW::Texture ctex = ef->getSpecular().getTexture(); + COLLADAFW::Texture ctex = ef->getSpecular().getTexture(); #endif } // REFLECTIVE @@ -856,7 +856,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia // texture else if (ef->getReflective().isTexture()) { #if 0 - COLLADAFW::Texture ctex = ef->getReflective().getTexture(); + COLLADAFW::Texture ctex = ef->getReflective().getTexture(); #endif } @@ -869,7 +869,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia // texture else if (ef->getEmission().isTexture()) { #if 0 - COLLADAFW::Texture ctex = ef->getEmission().getTexture(); + COLLADAFW::Texture ctex = ef->getEmission().getTexture(); #endif } @@ -902,14 +902,14 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect) { if (mImportStage != General) return true; - + const COLLADAFW::UniqueId& uid = effect->getUniqueId(); - + if (uid_effect_map.find(uid) == uid_effect_map.end()) { fprintf(stderr, "Couldn't find a material by UID.\n"); return true; } - + Material *ma = uid_effect_map[uid]; std::map<COLLADAFW::UniqueId, Material *>::iterator iter; for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) { @@ -928,7 +928,7 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect) COLLADAFW::EffectCommon *ef = common_efs[0]; write_profile_COMMON(ef, ma); this->FW_object_map[effect->getUniqueId()] = effect; - + return true; } @@ -939,16 +939,16 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) { if (mImportStage != General) return true; - + Camera *cam = NULL; std::string cam_id, cam_name; - + ExtraTags *et=getExtraTags(camera->getUniqueId()); cam_id = camera->getOriginalId(); cam_name = camera->getName(); if (cam_name.size()) cam = (Camera *)BKE_camera_add(G.main, (char *)cam_name.c_str()); else cam = (Camera *)BKE_camera_add(G.main, (char *)cam_id.c_str()); - + if (!cam) { fprintf(stderr, "Cannot create camera.\n"); return true; @@ -961,7 +961,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) } cam->clipsta = camera->getNearClippingPlane().getValue(); cam->clipend = camera->getFarClippingPlane().getValue(); - + COLLADAFW::Camera::CameraType type = camera->getCameraType(); switch (type) { case COLLADAFW::Camera::ORTHOGRAPHIC: @@ -981,7 +981,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) } break; } - + switch (camera->getDescriptionType()) { case COLLADAFW::Camera::ASPECTRATIO_AND_Y: { @@ -1051,7 +1051,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) // read nothing, use blender defaults. break; } - + this->uid_camera_map[camera->getUniqueId()] = cam; this->FW_object_map[camera->getUniqueId()] = camera; // XXX import camera options @@ -1064,7 +1064,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) { if (mImportStage != General) return true; - + const std::string& imagepath = image->getImageURI().toNativePath(); char dir[FILE_MAX]; @@ -1075,7 +1075,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) BLI_join_dirfile(absolute_path, sizeof(absolute_path), dir, imagepath.c_str()); if (BLI_exists(absolute_path)) { workpath = absolute_path; - } + } else { // Maybe imagepath was already absolute ? if (!BLI_exists(imagepath.c_str())) { @@ -1091,7 +1091,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) return true; } this->uid_image_map[image->getUniqueId()] = ima; - + return true; } @@ -1185,7 +1185,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) // assuming point light (const att = 1.0); att1 = 1.0f; } - + d *= (1.0f / unit_converter.getLinearMeter()); lamp->energy = e; @@ -1247,7 +1247,7 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim) { if (mImportStage != General) return true; - + // return true; return anim_importer.write_animation(anim); } @@ -1257,7 +1257,7 @@ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animat { if (mImportStage != General) return true; - + // return true; return anim_importer.write_animation_list(animationList); } @@ -1274,7 +1274,7 @@ bool DocumentImporter::writeController(const COLLADAFW::Controller *controller) { if (mImportStage != General) return true; - + return armature_importer.write_controller(controller); } diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index 758caef7e60..b31a086d710 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -78,7 +78,7 @@ public: void create_constraints(ExtraTags *et, Object *ob); std::vector<Object *> *write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool); void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*); - + void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*); /** @@ -149,7 +149,7 @@ private: ArmatureImporter armature_importer; MeshImporter mesh_importer; AnimationImporter anim_importer; - + /** TagsMap typedef for uid_tags_map. */ typedef std::map<std::string, ExtraTags*> TagsMap; /** Tags map of unique id as a string and ExtraTags instance. */ @@ -165,7 +165,7 @@ private: std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map; std::vector<const COLLADAFW::VisualScene*> vscenes; std::vector<Object*> libnode_ob; - + std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map; diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index dbcdfd01a9c..271dab5deea 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -57,7 +57,7 @@ static std::string getActiveUVLayerName(Object *ob) int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); if (num_layers) return std::string(bc_CustomData_get_active_layer_name(&me->fdata, CD_MTFACE)); - + return ""; } @@ -105,12 +105,12 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // TODO: add back texture and extended material parameter support openEffect(translate_id(id_name(ma)) + "-effect"); - + COLLADASW::EffectProfile ep(mSW); ep.setProfileType(COLLADASW::EffectProfile::COMMON); ep.openProfile(); writeLambert(ep, ma); - + COLLADASW::ColorOrTexture cot; // transparency @@ -144,7 +144,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) //COLLADASW::Surface surfaces[MAX_MTEX]; //void *samp_surf[MAX_MTEX][2]; void *samp_surf[MAX_MTEX]; - + // image to index to samp_surf map // samp_surf[index] stores 2 pointers, sampler and surface std::map<std::string, int> im_samp_map; @@ -153,10 +153,10 @@ void EffectsExporter::operator()(Material *ma, Object *ob) for (a = 0, b = 0; a < tex_indices.size(); a++) { MTex *t = ma->mtex[tex_indices[a]]; Image *ima = t->tex->ima; - + // Image not set for texture if (!ima) continue; - + std::string key(id_name(ima)); key = translate_id(key); @@ -171,7 +171,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // COLLADASW::NewParamSurface surface(mSW); // surface->setParamType(COLLADASW::CSW_SURFACE_TYPE_2D); - + //<newparam> <sampler> <source> COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D, key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX, @@ -180,11 +180,11 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // copy values to arrays since they will live longer samplers[a] = sampler; //surfaces[a] = surface; - + // store pointers so they can be used later when we create <texture>s samp_surf[b] = &samplers[a]; //samp_surf[b][1] = &surfaces[a]; - + im_samp_map[key] = b; b++; } @@ -238,12 +238,12 @@ COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima, COLLADASW::Sampler *sampler /*COLLADASW::Surface *surface*/) { - + COLLADASW::Texture texture(translate_id(id_name(ima))); texture.setTexcoord(uv_layer_name); //texture.setSurface(*surface); texture.setSampler(*sampler); - + COLLADASW::ColorOrTexture cot(texture); return cot; } diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h index eac428ae330..a1395bfde9f 100644 --- a/source/blender/collada/EffectExporter.h +++ b/source/blender/collada/EffectExporter.h @@ -50,25 +50,25 @@ public: void exportEffects(Scene *sce); void operator()(Material *ma, Object *ob); - + COLLADASW::ColorOrTexture createTexture(Image *ima, std::string& uv_layer_name, COLLADASW::Sampler *sampler /*COLLADASW::Surface *surface*/); - + COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a); private: void writeLambert(COLLADASW::EffectProfile &ep, Material *ma); void writeTextures(COLLADASW::EffectProfile &ep, std::string &key, - COLLADASW::Sampler *sampler, + COLLADASW::Sampler *sampler, MTex *t, Image *ima, std::string &uvname ); bool hasEffects(Scene *sce); - + const ExportSettings *export_settings; - + Scene *scene; }; diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp index 7e18328f000..26674445d98 100644 --- a/source/blender/collada/ErrorHandler.cpp +++ b/source/blender/collada/ErrorHandler.cpp @@ -53,7 +53,7 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error) See https://github.com/KhronosGroup/OpenCOLLADA/issues/442 */ bool isWarning = false; - + if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) { COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error; const GeneratedSaxParser::ParserError& parserError = saxParserError->getError(); diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index bef7accd9f7..5d704bc9abc 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -54,9 +54,9 @@ bool ExtraHandler::elementEnd(const char *elementName) bool ExtraHandler::textData(const char *text, size_t textLength) { char buf[1024]; - + if (currentElement.length() == 0 || currentExtraTags == 0) return false; - + BLI_strncpy(buf, text, textLength + 1); currentExtraTags->addTag(currentElement, std::string(buf)); return true; diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h index f380c3d6871..4dda862b3cc 100644 --- a/source/blender/collada/ExtraHandler.h +++ b/source/blender/collada/ExtraHandler.h @@ -50,31 +50,31 @@ public: /** Handle the beginning of an element. */ bool elementBegin( const char* elementName, const char** attributes); - + /** Handle the end of an element. */ bool elementEnd(const char* elementName ); - + /** Receive the data in text format. */ bool textData(const char* text, size_t textLength); /** Method to ask, if the current callback handler want to read the data of the given extra element. */ - bool parseElement ( - const char* profileName, - const unsigned long& elementHash, + bool parseElement ( + const char* profileName, + const unsigned long& elementHash, const COLLADAFW::UniqueId& uniqueId, COLLADAFW::Object* object); /** For backwards compatibility with older OpenCollada, new version added object parameter */ - bool parseElement ( - const char* profileName, - const unsigned long& elementHash, + bool parseElement ( + const char* profileName, + const unsigned long& elementHash, const COLLADAFW::UniqueId& uniqueId); private: /** Disable default copy constructor. */ ExtraHandler(const ExtraHandler& pre); /** Disable default assignment operator. */ const ExtraHandler& operator= ( const ExtraHandler& pre ); - + /** Handle to DocumentImporter for interface to extra element data saving. */ DocumentImporter* dimp; AnimationImporter* aimp; diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index ea225d8a4ae..fd249884c3f 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -50,7 +50,7 @@ bool ExtraTags::isProfile(std::string profile) bool ExtraTags::addTag(std::string tag, std::string data) { tags[tag] = data; - + return true; } diff --git a/source/blender/collada/ExtraTags.h b/source/blender/collada/ExtraTags.h index ad272dcba65..84857622ee8 100644 --- a/source/blender/collada/ExtraTags.h +++ b/source/blender/collada/ExtraTags.h @@ -41,35 +41,35 @@ public: /** Handle the beginning of an element. */ bool addTag(std::string tag, std::string data); - + /** Set given short pointer to value of tag, if it exists. */ bool setData(std::string tag, short *data); - + /** Set given int pointer to value of tag, if it exists. */ bool setData(std::string tag, int *data); - + /** Set given float pointer to value of tag, if it exists. */ bool setData(std::string tag, float *data); - + /** Set given char pointer to value of tag, if it exists. */ bool setData(std::string tag, char *data); std::string setData(std::string tag, std::string &data); /** Return true if the extra tags is for specified profile. */ bool isProfile(std::string profile); - + private: /** Disable default copy constructor. */ ExtraTags(const ExtraTags& pre); /** Disable default assignment operator. */ const ExtraTags& operator= ( const ExtraTags& pre ); - + /** The profile for which the tags are. */ std::string profile; - + /** Map of tag and text pairs. */ std::map<std::string, std::string> tags; - + /** Get text data for tag as an int. */ int asInt(std::string tag, bool *ok); /** Get text data for tag as a float. */ diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 87b47353596..65e844cbe50 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -70,14 +70,14 @@ void GeometryExporter::exportGeom(struct Depsgraph *depsgraph, Scene *sce) } void GeometryExporter::operator()(Object *ob) -{ +{ // XXX don't use DerivedMesh, Mesh instead? -#if 0 +#if 0 DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH); #endif bool use_instantiation = this->export_settings->use_object_instantiation; - Mesh *me = bc_get_mesh_copy(mDepsgraph, mScene, + Mesh *me = bc_get_mesh_copy(mDepsgraph, mScene, ob, this->export_settings->export_mesh_type, this->export_settings->apply_modifiers, @@ -88,7 +88,7 @@ void GeometryExporter::operator()(Object *ob) std::vector<BCPolygonNormalsIndices> norind; // Skip if linked geometry was already exported from another reference - if (use_instantiation && + if (use_instantiation && exportedGeometry.find(geom_id) != exportedGeometry.end()) { return; @@ -104,15 +104,15 @@ void GeometryExporter::operator()(Object *ob) // openMesh(geoId, geoName, meshId) openMesh(geom_id, geom_name); - + // writes <source> for vertex coords createVertsSource(geom_id, me); - + // writes <source> for normal coords createNormalsSource(geom_id, me, nor); bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE); - + // writes <source> for uv coords if mesh has uv coords if (has_uvs) { createTexcoordsSource(geom_id, me); @@ -144,9 +144,9 @@ void GeometryExporter::operator()(Object *ob) createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } } - + closeMesh(); - + if (me->flag & ME_TWOSIDED) { mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>"); } @@ -175,7 +175,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name); std::vector<Normal> nor; std::vector<BCPolygonNormalsIndices> norind; - + if (exportedGeometry.find(geom_id) != exportedGeometry.end()) { return; @@ -191,15 +191,15 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) // openMesh(geoId, geoName, meshId) openMesh(geom_id, geom_name); - + // writes <source> for vertex coords createVertsSource(geom_id, me); - + // writes <source> for normal coords createNormalsSource(geom_id, me, nor); bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE); - + // writes <source> for uv coords if mesh has uv coords if (has_uvs) { createTexcoordsSource(geom_id, me); @@ -220,7 +220,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) //createLooseEdgeList(ob, me, geom_id, norind); - // XXX slow + // XXX slow if (ob->totcol) { for (int a = 0; a < ob->totcol; a++) { createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind); @@ -229,9 +229,9 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) else { createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } - + closeMesh(); - + if (me->flag & ME_TWOSIDED) { mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>"); } @@ -250,9 +250,9 @@ void GeometryExporter::createLooseEdgeList(Object *ob, std::vector<unsigned int> edge_list; int index; - // Find all loose edges in Mesh + // Find all loose edges in Mesh // and save vertex indices in edge_list - for (index = 0; index < totedges; index++) + for (index = 0; index < totedges; index++) { MEdge *edge = &medges[index]; @@ -273,14 +273,14 @@ void GeometryExporter::createLooseEdgeList(Object *ob, COLLADASW::InputList &til = lines.getInputList(); - - // creates <input> in <lines> for vertices + + // creates <input> in <lines> for vertices COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0); til.push_back(input1); lines.prepareToAppendValues(); - for (index = 0; index < edges_in_linelist; index++) + for (index = 0; index < edges_in_linelist; index++) { lines.appendValues(edge_list[2 * index + 1]); lines.appendValues(edge_list[2 * index]); @@ -318,7 +318,7 @@ void GeometryExporter::createPolylist(short material_index, // count faces with this material for (i = 0; i < totpolys; i++) { MPoly *p = &mpolys[i]; - + if (p->mat_nr == material_index) { faces_in_polylist++; vcount_list.push_back(p->totloop); @@ -330,13 +330,13 @@ void GeometryExporter::createPolylist(short material_index, fprintf(stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index); return; } - + Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL; COLLADASW::Polylist polylist(mSW); - + // sets count attribute in <polylist> polylist.setCount(faces_in_polylist); - + // sets material name if (ma) { std::string material_id = get_material_id(ma); @@ -344,18 +344,18 @@ void GeometryExporter::createPolylist(short material_index, ostr << translate_id(material_id); polylist.setMaterial(ostr.str()); } - + COLLADASW::InputList &til = polylist.getInputList(); - - // creates <input> in <polylist> for vertices + + // creates <input> in <polylist> for vertices COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0); - + // creates <input> in <polylist> for normals COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1); - + til.push_back(input1); til.push_back(input2); - + // if mesh has uv coords writes <input> for TEXCOORD int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1; @@ -387,13 +387,13 @@ void GeometryExporter::createPolylist(short material_index, map_index++; } } - + // sets <vcount> polylist.setVCountList(vcount_list); - + // performs the actual writing polylist.prepareToAppendValues(); - + // <p> int texindex = 0; for (i = 0; i < totpolys; i++) { @@ -417,7 +417,7 @@ void GeometryExporter::createPolylist(short material_index, texindex += loop_count; } - + polylist.finish(); } @@ -430,7 +430,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me) #endif int totverts = me->totvert; MVert *verts = me->mvert; - + COLLADASW::FloatSourceF source(mSW); source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION)); source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION) + @@ -450,7 +450,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me) for (i = 0; i < totverts; i++) { source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]); } - + source.finish(); } @@ -502,7 +502,7 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me) ); } } - + source.finish(); } } @@ -537,20 +537,20 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, a); if (!this->export_settings->active_uv_only || layer_index == active_uv_index) { MLoopUV *mloops = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a); - + COLLADASW::FloatSourceF source(mSW); std::string layer_id = makeTexcoordSourceId(geom_id, a, this->export_settings->active_uv_only); source.setId(layer_id); source.setArrayId(layer_id + ARRAY_ID_SUFFIX); - + source.setAccessorCount(totuv); source.setAccessorStride(2); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); param.push_back("S"); param.push_back("T"); - + source.prepareToAppendValues(); - + for (int index = 0; index < totpoly; index++) { MPoly *mpoly = mpolys+index; MLoopUV *mloop = mloops+mpoly->loopstart; @@ -559,7 +559,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) mloop[j].uv[1]); } } - + source.finish(); } } @@ -589,7 +589,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v param.push_back("X"); param.push_back("Y"); param.push_back("Z"); - + source.prepareToAppendValues(); std::vector<Normal>::iterator it; @@ -674,10 +674,10 @@ std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::I COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix) { - + std::string id(getIdBySemantics(geom_id, type, other_suffix)); return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id); - + } COLLADASW::URI GeometryExporter::makeUrl(std::string id) diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 88420b4ad2f..b0cd650adcd 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -96,7 +96,7 @@ public: Mesh *me, std::string& geom_id, std::vector<BCPolygonNormalsIndices>& norind); - + // creates <source> for positions void createVertsSource(std::string geom_id, Mesh *me); @@ -112,7 +112,7 @@ public: void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal>& nor); void create_normals(std::vector<Normal> &nor, std::vector<BCPolygonNormalsIndices> &ind, Mesh *me); - + std::string getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = ""); std::string makeVertexColorSourceId(std::string& geom_id, char *layer_name); @@ -121,10 +121,10 @@ public: COLLADASW::URI makeUrl(std::string id); void export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb); - + private: std::set<std::string> exportedGeometry; - + const ExportSettings *export_settings; Mesh * get_mesh(Scene *sce, Object *ob, int apply_modifiers); diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index d5e3b19e3e7..bb3cebf4cf0 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -34,7 +34,7 @@ extern "C" { #include "DNA_image_types.h" #include "DNA_meshdata_types.h" -#include "BKE_customdata.h" +#include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" @@ -53,7 +53,7 @@ ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings { } -void ImagesExporter::export_UV_Image(Image *image, bool use_copies) +void ImagesExporter::export_UV_Image(Image *image, bool use_copies) { std::string name(id_name(image)); std::string translated_name(translate_id(name)); @@ -117,7 +117,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) BLI_cleanup_path(NULL, source_path); if (use_copies) { - + // This image is already located on the file system. // But we want to create copies here. // To move images into the same export directory. @@ -155,7 +155,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) bool ImagesExporter::hasImages(Scene *sce) { LinkNode *node; - + for (node = this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *)node->link; diff --git a/source/blender/collada/ImageExporter.h b/source/blender/collada/ImageExporter.h index f3dd2b336e4..1867c44ac9c 100644 --- a/source/blender/collada/ImageExporter.h +++ b/source/blender/collada/ImageExporter.h @@ -45,7 +45,7 @@ class ImagesExporter: COLLADASW::LibraryImages { public: ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings); - + void exportImages(Scene *sce); void operator()(Material *ma, Object *ob); private: diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index d96d590597a..68842596550 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -45,7 +45,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia { for (int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a + 1); - + COLLADASW::InstanceMaterialList& iml = bind_material.getInstanceMaterialList(); if (ma) { @@ -54,11 +54,11 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia std::ostringstream ostr; ostr << matid; COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); - + // create <bind_vertex_input> for each uv map Mesh *me = (Mesh *)ob->data; int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE); - + int map_index = 0; int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE) -1; for (int b = 0; b < totlayer; b++) { @@ -67,7 +67,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", map_index++)); } } - + iml.push_back(im); } } diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index d17941574d7..11377e06ce8 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -54,9 +54,9 @@ LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings void LightsExporter::exportLights(Scene *sce) { openLibrary(); - + forEachLampObjectInExportSet(sce, *this, this->export_settings->export_set); - + closeLibrary(); } @@ -67,11 +67,11 @@ void LightsExporter::operator()(Object *ob) std::string la_name(id_name(la)); COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy); float d, constatt, linatt, quadatt; - + d = la->dist; - + constatt = 1.0f; - + if (la->falloff_type == LA_FALLOFF_INVLINEAR) { linatt = 1.0f / d; quadatt = 0.0f; @@ -80,7 +80,7 @@ void LightsExporter::operator()(Object *ob) linatt = 0.0f; quadatt = 1.0f / (d * d); } - + // sun if (la->type == LA_SUN) { COLLADASW::DirectionalLight cla(mSW, la_id, la_name); @@ -130,7 +130,7 @@ void LightsExporter::operator()(Object *ob) exportBlenderProfile(cla, la); addLight(cla); } - + } bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) @@ -164,6 +164,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "area_size", la->area_size); cla.addExtraTechniqueParameter("blender", "area_sizey", la->area_sizey); cla.addExtraTechniqueParameter("blender", "area_sizez", la->area_sizez); - + return true; } diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h index ef44bf8a03e..e830a433432 100644 --- a/source/blender/collada/MaterialExporter.h +++ b/source/blender/collada/MaterialExporter.h @@ -65,7 +65,7 @@ class ForEachMaterialFunctor Functor *f; public: ForEachMaterialFunctor(Functor*f) : f(f) {} - + void operator ()(Object *ob) { int a; diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index add4a93bccd..e95f8ed0888 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -154,7 +154,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv) if (values->empty()) return; uv[0] = (*values)[uv_index * stride]; uv[1] = (*values)[uv_index * stride + 1]; - + } break; case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: @@ -163,7 +163,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv) if (values->empty()) return; uv[0] = (float)(*values)[uv_index * stride]; uv[1] = (float)(*values)[uv_index * stride + 1]; - + } break; case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN: @@ -208,7 +208,7 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol) } MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce, ViewLayer *view_layer): - unitconverter(unitconv), + unitconverter(unitconv), scene(sce), view_layer(view_layer), armature_importer(arm) { @@ -320,7 +320,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has su return false; } } - + return true; } @@ -360,7 +360,7 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) { int normals_count = mp->getNormalIndices().getCount(); if (normals_count > 0) { int index_count = mp->getPositionIndices().getCount(); - if (index_count == normals_count) + if (index_count == normals_count) has_useable_normals = true; else { fprintf(stderr, @@ -391,7 +391,7 @@ bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) { break; } default: { - has_faces = false; + has_faces = false; break; } } @@ -435,7 +435,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) size_t prim_poly_count = mpvc->getFaceCount(); size_t prim_loop_count = 0; - for (int index=0; index < prim_poly_count; index++) + for (int index=0; index < prim_poly_count; index++) { int vcount = get_vertex_count(mpvc, index); if (vcount > 0) { @@ -547,7 +547,7 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) { // This functin is copied from source/blender/editors/mesh/mesh_data.c // // TODO: (As discussed with sergey-) : -// Maybe move this function to blenderkernel/intern/mesh.c +// Maybe move this function to blenderkernel/intern/mesh.c // and add definition to BKE_mesh.c // ================================================================= void MeshImporter::mesh_add_edges(Mesh *mesh, int len) @@ -582,7 +582,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) // ================================================================= // Read all loose edges. -// Important: This function assumes that all edges from existing +// Important: This function assumes that all edges from existing // faces have allready been generated and added to me->medge // So this function MUST be called after read_faces() (see below) // ================================================================= @@ -593,21 +593,21 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) unsigned int face_edge_count = me->totedge; /* unsigned int total_edge_count = loose_edge_count + face_edge_count; */ /* UNUSED */ - + mesh_add_edges(me, loose_edge_count); MEdge *med = me->medge + face_edge_count; COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives(); for (int i = 0; i < prim_arr.getCount(); i++) { - + COLLADAFW::MeshPrimitive *mp = prim_arr[i]; int type = mp->getPrimitiveType(); if (type == COLLADAFW::MeshPrimitive::LINES) { unsigned int edge_count = mp->getFaceCount(); unsigned int *indices = mp->getPositionIndices().getData(); - + for (int j = 0; j < edge_count; j++, med++) { med->bweight = 0; med->crease = 0; @@ -624,7 +624,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) // ======================================================================= // Read all faces from TRIANGLES, TRIANGLE_FANS, POLYLIST, POLYGON -// Important: This function MUST be called before read_lines() +// Important: This function MUST be called before read_lines() // Otherwise we will loose all edges from faces (see read_lines() above) // // TODO: import uv set names @@ -632,7 +632,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) { unsigned int i; - + allocate_poly_data(collada_mesh, me); UVDataWrapper uvs(collada_mesh->getUVCoords()); @@ -648,7 +648,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) COLLADAFW::MeshVertexData& nor = collada_mesh->getNormals(); for (i = 0; i < prim_arr.getCount(); i++) { - + COLLADAFW::MeshPrimitive *mp = prim_arr[i]; // faces @@ -661,7 +661,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) bool mp_has_faces = primitive_has_faces(mp); int collada_meshtype = mp->getPrimitiveType(); - + // since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive Primitive prim = {mpoly, 0}; @@ -688,7 +688,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) mpoly->flag |= ME_SMOOTH; normal_indices++; } - + mpoly++; mloop += 3; loop_index += 3; @@ -798,7 +798,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride) { i *= stride; - + switch (arr.getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { @@ -888,7 +888,7 @@ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2) { if (ob1->totcol != ob2->totcol) return false; // not same number of materials if (ob1->totcol == 0) return false; // no material at all - + for (int index=0; index < ob1->totcol; index++) { if (ob1->matbits[index] != ob2->matbits[index]) return false; // shouldn't happen if (ob1->matbits[index] == 0) return false; // shouldn't happen @@ -1019,34 +1019,34 @@ void MeshImporter::assign_material_to_geom( short mat_index) { const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial(); - + // do we know this material? if (uid_material_map.find(ma_uid) == uid_material_map.end()) { - + fprintf(stderr, "Cannot find material by UID.\n"); return; } // first time we get geom_uid, ma_uid pair. Save for later check. materials_mapped_to_geom.insert(std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid)); - + Material *ma = uid_material_map[ma_uid]; // Attention! This temporaly assigns material to object on purpose! // See note above. ob->actcol=0; assign_material(G.main, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT); - + MaterialIdPrimitiveArrayMap& mat_prim_map = geom_uid_mat_mapping_map[*geom_uid]; COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId(); - + // assign material indices to mesh faces if (mat_prim_map.find(mat_id) != mat_prim_map.end()) { - + std::vector<Primitive>& prims = mat_prim_map[mat_id]; - + std::vector<Primitive>::iterator it; - + for (it = prims.begin(); it != prims.end(); it++) { Primitive& prim = *it; MPoly *mpoly = prim.mpoly; @@ -1055,7 +1055,7 @@ void MeshImporter::assign_material_to_geom( mpoly->mat_nr = mat_index; } } - } + } } Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, @@ -1063,19 +1063,19 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta std::map<COLLADAFW::UniqueId, Material *>& uid_material_map) { const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId(); - + // check if node instanciates controller or geometry if (isController) { - + geom_uid = armature_importer->get_geometry_uid(*geom_uid); - + if (!geom_uid) { fprintf(stderr, "Couldn't find a mesh UID by controller's UID.\n"); return NULL; } } else { - + if (uid_mesh_map.find(*geom_uid) == uid_mesh_map.end()) { // this could happen if a mesh was not created // (e.g. if it contains unsupported geometry) @@ -1084,11 +1084,11 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta } } if (!uid_mesh_map[*geom_uid]) return NULL; - + // name Object const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId(); const char *name = (id.length()) ? id.c_str() : NULL; - + // add object Object *ob = bc_add_object(scene, view_layer, OB_MESH, name); bc_set_mark(ob); // used later for material assignement optimization @@ -1097,7 +1097,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta // store object pointer for ArmatureImporter uid_object_map[*geom_uid] = ob; imported_objects.push_back(ob); - + // replace ob->data freeing the old one Mesh *old_mesh = (Mesh *)ob->data; Mesh *new_mesh = uid_mesh_map[*geom_uid]; @@ -1110,10 +1110,10 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta COLLADAFW::MaterialBindingArray& mat_array = geom->getMaterialBindings(); - + // loop through geom's materials for (unsigned int i = 0; i < mat_array.getCount(); i++) { - + if (mat_array[i].getReferencedMaterial().isValid()) { assign_material_to_geom( mat_array[i], uid_material_map, ob, geom_uid, @@ -1136,14 +1136,14 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom) fprintf(stderr, "Mesh type %s is not supported\n", bc_geomTypeToStr(geom->getType())); return true; } - + COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom; - + if (!is_nice_mesh(mesh)) { fprintf(stderr, "Ignoring mesh %s\n", bc_get_dae_name(mesh).c_str()); return true; } - + const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId(); Mesh *me = BKE_mesh_add(G.main, (char *)str_geom_id.c_str()); id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object @@ -1152,7 +1152,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom) // mesh_geom_map needed to map mesh to its geometry name (for shape key naming) this->uid_mesh_map[mesh->getUniqueId()] = me; this->mesh_geom_map[std::string(me->id.name)] = str_geom_id; - + read_vertices(mesh, me); read_polys(mesh, me); diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 09b3005d795..c98126916d7 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -109,7 +109,7 @@ private: typedef std::map<COLLADAFW::MaterialId, std::vector<Primitive> > MaterialIdPrimitiveArrayMap; std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map; // crazy name! std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials - + bool set_poly_indices(MPoly *mpoly, MLoop *mloop, int loop_index, @@ -135,7 +135,7 @@ private: bool is_nice_mesh(COLLADAFW::Mesh *mesh); void read_vertices(COLLADAFW::Mesh *mesh, Mesh *me); - + bool primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp); bool primitive_has_faces(COLLADAFW::MeshPrimitive *mp); @@ -165,7 +165,7 @@ public: virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid); virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& geom_uid); - + void optimize_material_assignements(); void assign_material_to_geom( @@ -173,8 +173,8 @@ public: std::map<COLLADAFW::UniqueId, Material*>& uid_material_map, Object *ob, const COLLADAFW::UniqueId *geom_uid, short mat_index); - - + + Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, std::map<COLLADAFW::UniqueId, Material*>& uid_material_map); diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 62ab4af5d1a..d909203488e 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -50,7 +50,7 @@ void SceneExporter::exportScene(bContext *C, Depsgraph *depsgraph, Scene *sce) } void SceneExporter::exportHierarchy(bContext *C, Depsgraph *depsgraph, Scene *sce) -{ +{ LinkNode *node; std::vector<Object *> base_objects; @@ -59,7 +59,7 @@ void SceneExporter::exportHierarchy(bContext *C, Depsgraph *depsgraph, Scene *sc Object *ob = (Object *) node->link; ob->id.tag |= LIB_TAG_DOIT; } - + // Now find all exportable base ojects (highest in export hierarchy) for (node = this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *) node->link; @@ -203,17 +203,17 @@ void SceneExporter::writeNodes(bContext *C, Depsgraph *depsgraph, Object *ob, Sc colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"rot_error",con->rot_error); colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"tar_space",con->tarspace); colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"lin_error",con->lin_error); - - //not ideal: add the target object name as another parameter. + + //not ideal: add the target object name as another parameter. //No real mapping in the .dae //Need support for multiple target objects also. const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {NULL, NULL}; if (cti && cti->get_constraint_targets) { - + bConstraintTarget *ct; Object *obtar; - + cti->get_constraint_targets(con, &targets); for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) { diff --git a/source/blender/collada/SceneExporter.h b/source/blender/collada/SceneExporter.h index 24a2dcf08c8..91f98063020 100644 --- a/source/blender/collada/SceneExporter.h +++ b/source/blender/collada/SceneExporter.h @@ -102,7 +102,7 @@ private: friend class ArmatureExporter; void exportHierarchy(bContext *C, struct Depsgraph *depsgraph, Scene *sce); void writeNodes(bContext *C, struct Depsgraph *depsgraph, Object *ob, Scene *sce); - + ArmatureExporter *arm_exporter; const ExportSettings *export_settings; }; diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index a2cb8237d08..7ec3f04aabf 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -121,7 +121,7 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData * unit_converter->dae_matrix_to_mat4_(bind_shape_matrix, skin->getBindShapeMatrix()); } - + void SkinInfo::free() { joints_per_vertex.releaseMemory(); @@ -199,7 +199,7 @@ const COLLADAFW::UniqueId& SkinInfo::get_controller_uid() } // check if this skin controller references a joint or any descendant of it -// +// // some nodes may not be referenced by SkinController, // in this case to determine if the node belongs to this armature, // we need to search down the tree @@ -259,9 +259,9 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique // skip joints that have invalid UID if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) continue; - + // name group by joint node name - + if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) { name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]); } diff --git a/source/blender/collada/SkinInfo.h b/source/blender/collada/SkinInfo.h index a399bff9e3c..fdfee0a943a 100644 --- a/source/blender/collada/SkinInfo.h +++ b/source/blender/collada/SkinInfo.h @@ -88,7 +88,7 @@ public: void transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray& src, COLLADAFW::UIntValuesArray& dest); void borrow_skin_controller_data(const COLLADAFW::SkinControllerData* skin); - + void free(); // using inverse bind matrices to construct armature @@ -110,7 +110,7 @@ public: const COLLADAFW::UniqueId& get_controller_uid(); // check if this skin controller references a joint or any descendant of it - // + // // some nodes may not be referenced by SkinController, // in this case to determine if the node belongs to this armature, // we need to search down the tree diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index 7f742be7e30..bf9c34153b7 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -54,7 +54,7 @@ void TransformReader::get_node_mat( float copy[4][4]; unit_m4(mat); - + for (unsigned int i = 0; i < node->getTransformations().getCount(); i++) { COLLADAFW::Transformation *tm = node->getTransformations()[i]; @@ -87,11 +87,11 @@ void TransformReader::get_node_mat( copy_m4_m4(copy, mat); mul_m4_m4m4(mat, copy, cur); - + if (animation_map) { // AnimationList that drives this Transformation const COLLADAFW::UniqueId& anim_list_id = tm->getAnimationList(); - + // store this so later we can link animation data with ob Animation anim = {ob, node, tm}; (*animation_map)[anim_list_id] = anim; diff --git a/source/blender/collada/TransformReader.h b/source/blender/collada/TransformReader.h index 08bb17ccac1..6544aa1c040 100644 --- a/source/blender/collada/TransformReader.h +++ b/source/blender/collada/TransformReader.h @@ -19,7 +19,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ - + /** \file TransformReader.h * \ingroup collada */ diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 1fb54e99147..9f75a604f96 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -119,7 +119,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, { float loc[3], rot[3], scale[3]; bc_decompose(f_obmat, loc, rot, NULL, scale); - add_transform(node, loc, rot, scale); + add_transform(node, loc, rot, scale); break; } } diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h index 299e13326ce..1eac5b68778 100644 --- a/source/blender/collada/collada_internal.h +++ b/source/blender/collada/collada_internal.h @@ -51,7 +51,7 @@ private: float y_up_mat4[4][4]; float z_up_mat4[4][4]; float scale_mat4[4][4]; - + public: enum UnitSystem { @@ -66,11 +66,11 @@ public: void read_asset(const COLLADAFW::FileInfo *asset); void convertVector3(COLLADABU::Math::Vector3 &vec, float *v); - + UnitConverter::UnitSystem isMetricSystem(void); - + float getLinearMeter(void); - + // TODO need also for angle conversion, time conversion... void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4& in); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index bf441effc81..945dda68745 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -77,7 +77,7 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned in if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT) return array.getFloatValues()->getData()[index]; - else + else return array.getDoubleValues()->getData()[index]; } @@ -85,10 +85,10 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned in int bc_test_parent_loop(Object *par, Object *ob) { /* test if 'ob' is a parent somewhere in par's parents */ - + if (par == NULL) return 0; if (ob == par) return 1; - + return bc_test_parent_loop(par->parent, ob); } @@ -117,7 +117,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) mul_m4_m4m4(mat, par->obmat, ob->obmat); copy_m4_m4(ob->obmat, mat); } - + // apply child obmat (i.e. decompose it into rot/loc/size) BKE_object_apply_mat4(ob, ob->obmat, 0, 0); @@ -231,7 +231,7 @@ Object *bc_get_assigned_armature(Object *ob) // IMPORTANT: This function expects that // all exported objects have set: // ob->id.tag & LIB_TAG_DOIT -Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob) +Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob) { Object *ancestor = ob; while (ob->parent && bc_is_marked(ob->parent)) { @@ -256,7 +256,7 @@ bool bc_is_in_Export_set(LinkNode *export_set, Object *ob) bool bc_has_object_type(LinkNode *export_set, short obtype) { LinkNode *node; - + for (node = export_set; node; node = node->next) { Object *ob = (Object *)node->link; /* XXX - why is this checking for ob->data? - we could be looking for empties */ @@ -290,7 +290,7 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set) for (node = export_set; node->next && !sorted; node = node->next) { sorted = true; - + LinkNode *current; for (current = export_set; current->next; current = current->next) { Object *a = (Object *)current->link; @@ -301,12 +301,12 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set) current->next->link = a; sorted = false; } - + } } } -/* Check if a bone is the top most exportable bone in the bone hierarchy. +/* Check if a bone is the top most exportable bone in the bone hierarchy. * When deform_bones_only == false, then only bones with NO parent * can be root bones. Otherwise the top most deform bones in the hierarchy * are root bones. @@ -367,13 +367,13 @@ void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene) BKE_object_apply_mat4(ob, ob->obmat, 0, 0); } -void bc_match_scale(std::vector<Object *> *objects_done, +void bc_match_scale(std::vector<Object *> *objects_done, UnitConverter &bc_unit, bool scale_to_scene) { for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); - ++it) + ++it) { Object *ob = *it; if (ob -> parent == NULL) { @@ -781,7 +781,7 @@ float bc_get_property(Bone *bone, std::string key, float def) /** * Read a custom bone property and convert to matrix * Return true if conversion was succesfull -* +* * Return false if: * - the property does not exist * - is not an array of size 16 diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index 89765375afb..20c569834d8 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -92,8 +92,8 @@ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only); extern int bc_get_active_UVLayer(Object *ob); -extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement); -extern std::string bc_url_encode(std::string data); +extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement); +extern std::string bc_url_encode(std::string data); extern void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene); extern void bc_match_scale(std::vector<Object *> *objects_done, UnitConverter &unit_converter, bool scale_to_scene); @@ -135,8 +135,8 @@ class BCPolygonNormalsIndices normal_indices.push_back(index); } - unsigned int operator[](unsigned int i) { - return normal_indices[i]; + unsigned int operator[](unsigned int i) { + return normal_indices[i]; } }; |