Cleanup: comments (long lines) in collada

This commit is contained in:
2019-04-30 13:41:21 +10:00
parent d9fb06f876
commit 5d7ee02b17
22 changed files with 537 additions and 492 deletions

View File

@@ -130,7 +130,7 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
{
bool container_is_open = false;
//Transform animations (trans, rot, scale)
/* Transform animations (trans, rot, scale). */
container_is_open = open_animation_container(container_is_open, ob);
/* Now take care of the Object Animations
@@ -141,8 +141,8 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
BC_TRANSFORMATION_TYPE_MATRIX;
if (export_as_matrix) {
export_matrix_animation(
ob, sampler); // export all transform_curves as one single matrix animation
/* export all transform_curves as one single matrix animation */
export_matrix_animation(ob, sampler);
}
export_curve_animation_set(ob, sampler, export_as_matrix);
@@ -237,7 +237,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
}
}
//write bone animations in transform matrix sources
/* Write bone animations in transform matrix sources. */
void AnimationExporter::export_bone_animations_recursive(Object *ob,
Bone *bone,
BCAnimationSampler &sampler)
@@ -280,7 +280,7 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
BCCurveKey key(BC_ANIMATION_TYPE_CAMERA, "xfov", 0);
mcurve = new BCAnimationCurve(key, ob);
// now tricky part: transform the fcurve
/* now tricky part: transform the fcurve */
BCValueMap lens_values;
curve.get_value_map(lens_values);
@@ -306,7 +306,8 @@ BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
float value = RAD2DEGF(focallength_to_fov(lens_value, sensor_value));
mcurve->add_value(value, frame);
}
mcurve->clean_handles(); // to reset the handles
/* to reset the handles */
mcurve->clean_handles();
}
return mcurve;
}
@@ -322,7 +323,8 @@ void AnimationExporter::export_curve_animation(Object *ob, BCAnimationCurve &cur
*/
int channel_index = curve.get_channel_index();
std::string axis = get_axis_name(channel_target, channel_index); // RGB or XYZ or ""
/* RGB or XYZ or "" */
std::string axis = get_axis_name(channel_target, channel_index);
std::string action_name;
bAction *action = bc_getSceneObjectAction(ob);
@@ -365,19 +367,19 @@ void AnimationExporter::export_bone_animation(Object *ob,
bool AnimationExporter::is_bone_deform_group(Bone *bone)
{
bool is_def;
//Check if current bone is deform
/* Check if current bone is deform */
if ((bone->flag & BONE_NO_DEFORM) == 0)
return true;
//Check child bones
/* Check child bones */
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
//loop through all the children until deform bone is found, and then return
/* loop through all the children until deform bone is found, and then return */
is_def = is_bone_deform_group(child);
if (is_def)
return true;
}
}
//no deform bone found in children also
/* no deform bone found in children also */
return false;
}
@@ -466,7 +468,7 @@ void AnimationExporter::export_collada_matrix_animation(std::string id,
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION,
COLLADABU::URI(EMPTY_STRING, interpolation_id));
// Matrix animation has no tangents
/* Matrix animation has no tangents */
addSampler(sampler);
addChannel(COLLADABU::URI(EMPTY_STRING, sampler_id), target);
@@ -514,7 +516,8 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
else if (transform) {
param.push_back("TRANSFORM");
}
else { //assumes if axis isn't specified all axises are added
else {
/* assumes if axis isn't specified all axises are added */
param.push_back("X");
param.push_back("Y");
param.push_back("Z");
@@ -641,7 +644,8 @@ std::string AnimationExporter::collada_source_from_values(BCMatrixSampleMap &sam
source.prepareToAppendValues();
BCMatrixSampleMap::iterator it;
int precision = (this->export_settings->limit_precision) ? 6 : -1; // could be made configurable
/* could be made configurable */
int precision = (this->export_settings->limit_precision) ? 6 : -1;
for (it = samples.begin(); it != samples.end(); it++) {
const BCMatrix *sample = it->second;
double daemat[4][4];
@@ -686,11 +690,12 @@ std::string AnimationExporter::collada_interpolation_source(const BCAnimationCur
else if (ipo == BEZT_IPO_CONST) {
source.appendValues(STEP_NAME);
}
else { // BEZT_IPO_LIN
else {
/* BEZT_IPO_LIN */
source.appendValues(LINEAR_NAME);
}
}
// unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS
/* unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS */
source.finish();

View File

@@ -48,7 +48,7 @@
#include <algorithm>
// first try node name, if not available (since is optional), fall back to original id
/* first try node name, if not available (since is optional), fall back to original id */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
@@ -69,7 +69,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
float value,
eBezTriple_Interpolation ipo)
{
//float fps = (float)FPS;
// float fps = (float)FPS;
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
bez.vec[1][0] = frame;
@@ -81,7 +81,7 @@ void AnimationImporter::add_bezt(FCurve *fcu,
calchandles_fcurve(fcu);
}
// create one or several fcurves depending on the number of parameters being animated
/* create one or several fcurves depending on the number of parameters being animated */
void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
{
COLLADAFW::FloatOrDoubleArray &input = curve->getInputValues();
@@ -94,10 +94,10 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
std::vector<FCurve *> &fcurves = curve_map[curve->getUniqueId()];
switch (dim) {
case 1: // X, Y, Z or angle
case 3: // XYZ
case 1: /* X, Y, Z or angle */
case 3: /* XYZ */
case 4:
case 16: // matrix
case 16: /* matrix */
{
for (i = 0; i < dim; i++) {
FCurve *fcu = (FCurve *)MEM_callocN(sizeof(FCurve), "FCurve");
@@ -110,7 +110,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
BezTriple bez;
memset(&bez, 0, sizeof(BezTriple));
// input, output
/* input, output */
bez.vec[1][0] = bc_get_float_value(input, j) * fps;
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
bez.h1 = bez.h2 = HD_AUTO;
@@ -120,11 +120,11 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
COLLADAFW::FloatOrDoubleArray &intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray &outtan = curve->getOutTangentValues();
// intangent
/* intangent */
bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i) + 1);
// outtangent
/* 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) {
@@ -138,7 +138,9 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
else {
bez.ipo = BEZT_IPO_LIN;
}
// bez.ipo = U.ipo_new; /* use default interpolation mode here... */
#if 0
bez.ipo = U.ipo_new; /* use default interpolation mode here... */
#endif
bez.f1 = bez.f2 = bez.f3 = SELECT;
insert_bezt_fcurve(fcu, &bez, INSERTKEY_NOFLAGS);
@@ -161,7 +163,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
{
for (unsigned int i = 0; i < cu->totvert; i++) {
// TODO convert handles too
/* TODO convert handles too */
cu->bezt[i].vec[1][1] *= DEG2RADF(1.0f);
cu->bezt[i].vec[0][1] *= DEG2RADF(1.0f);
cu->bezt[i].vec[2][1] *= DEG2RADF(1.0f);
@@ -195,7 +197,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
char *p = strstr(rna_path, "rotation_euler");
bool is_rotation = p && *(p + strlen("rotation_euler")) == '\0';
// convert degrees to radians for rotation
/* convert degrees to radians for rotation */
if (is_rotation)
fcurve_deg_to_rad(fcu);
#endif
@@ -253,7 +255,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
AnimationImporter::~AnimationImporter()
{
// free unused FCurves
/* free unused FCurves */
for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
free_fcurve(*it);
@@ -266,15 +268,15 @@ 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?
/* XXX Don't know if it's necessary
* Should we check outPhysicalDimension? */
if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
fprintf(stderr, "Inputs physical dimension is not time.\n");
return true;
}
// a curve can have mixed interpolation type,
// in this case curve->getInterpolationTypes returns a list of interpolation types per key
/* a curve can have mixed interpolation type,
* in this case curve->getInterpolationTypes returns a list of interpolation types per key */
COLLADAFW::AnimationCurve::InterpolationType interp = curve->getInterpolationType();
if (interp != COLLADAFW::AnimationCurve::INTERPOLATION_MIXED) {
@@ -285,14 +287,14 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
animation_to_fcurves(curve);
break;
default:
// TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
/* TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types */
fprintf(stderr,
"CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
break;
}
}
else {
// not supported yet
/* not supported yet */
fprintf(stderr, "MIXED anim interpolation type is not supported yet.\n");
}
}
@@ -303,7 +305,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
return true;
}
// called on post-process stage after writeVisualScenes
/* called on post-process stage after writeVisualScenes */
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
{
const COLLADAFW::UniqueId &animlist_id = animlist->getUniqueId();
@@ -311,21 +313,21 @@ bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *ani
#if 0
// should not happen
/* should not happen */
if (uid_animated_map.find(animlist_id) == uid_animated_map.end()) {
return true;
}
// for bones rna_path is like: pose.bones["bone-name"].rotation
/* for bones rna_path is like: pose.bones["bone-name"].rotation */
#endif
return true;
}
// \todo refactor read_node_transform to not automatically apply anything,
// but rather return the transform matrix, so caller can do with it what is
// necessary. Same for \ref get_node_mat
/* \todo refactor read_node_transform to not automatically apply anything,
* but rather return the transform matrix, so caller can do with it what is
* necessary. Same for \ref get_node_mat */
void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob)
{
float mat[4][4];
@@ -392,7 +394,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
eulcu[2] ? evaluate_fcurve(eulcu[2], frame) : 0.0f,
};
// make eul relative to bone rest pose
/* make eul relative to bone rest pose */
float rot[3][3], rel[3][3], quat[4];
# if 0
@@ -408,7 +410,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
}
// now replace old Euler curves
/* now replace old Euler curves */
for (i = 0; i < 3; i++) {
if (!eulcu[i])
@@ -431,7 +433,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
#endif
//sets the rna_path and array index to curve
/* sets the rna_path and array index to curve */
void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
const char *rna_path,
int array_index)
@@ -453,7 +455,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
void AnimationImporter::unused_fcurve(std::vector<FCurve *> *curves)
{
// when an error happens and we can't actually use curve remove it from unused_curves
/* when an error happens and we can't actually use curve remove it from unused_curves */
std::vector<FCurve *>::iterator it;
for (it = curves->begin(); it != curves->end(); it++) {
FCurve *fcu = *it;
@@ -468,16 +470,17 @@ void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCur
FCurve *fcu = *iter;
for (unsigned int k = 0; k < fcu->totvert; k++) {
//get frame value from bezTriple
/* get frame value from bezTriple */
float fra = fcu->bezt[k].vec[1][0];
//if frame already not added add frame to frames
/* if frame already not added add frame to frames */
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
frames->push_back(fra);
}
}
}
//creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation.
/* creates the rna_paths and array indices of fcurves from animations using transformation and
* bound animation class of each animation. */
void AnimationImporter::Assign_transform_animations(
COLLADAFW::Transformation *transform,
const COLLADAFW::AnimationList::AnimationBinding *binding,
@@ -489,7 +492,7 @@ void AnimationImporter::Assign_transform_animations(
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
//to check if the no of curves are valid
/* to check if the no of curves are valid */
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||
tm_type == COLLADAFW::Transformation::SCALE) &&
binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
@@ -542,7 +545,7 @@ void AnimationImporter::Assign_transform_animations(
for (iter = curves->begin(); iter != curves->end(); iter++) {
FCurve *fcu = *iter;
//if transform is rotation the fcurves values must be turned in to radian.
/* if transform is rotation the fcurves values must be turned in to radian. */
if (is_rotation)
fcurve_deg_to_rad(fcu);
}
@@ -564,7 +567,7 @@ void AnimationImporter::Assign_transform_animations(
unused_fcurve(curves);
break;
case COLLADAFW::AnimationList::AXISANGLE:
// TODO convert axis-angle to quat? or XYZ?
/* TODO convert axis-angle to quat? or XYZ? */
default:
unused_fcurve(curves);
fprintf(stderr,
@@ -594,7 +597,8 @@ void AnimationImporter::Assign_transform_animations(
}
}
//creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation.
/* creates the rna_paths and array indices of fcurves from animations using color and bound
* animation class of each animation. */
void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listid,
ListBase *AnimCurves,
const char *anim_type)
@@ -612,7 +616,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
}
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
/* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -628,7 +632,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
modify_fcurve(&animcurves, rna_path, 2);
break;
case COLLADAFW::AnimationList::COLOR_RGB:
case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity
case COLLADAFW::AnimationList::COLOR_RGBA: /* to do-> set intensity */
modify_fcurve(&animcurves, rna_path, -1);
break;
@@ -641,7 +645,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi
}
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
/* 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);
@@ -659,10 +663,10 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
return;
}
else {
//anim_type has animations
/* anim_type has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
/* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -670,10 +674,11 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
/* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
/* All anim_types whose values are to be converted from Degree to Radians can be ORed here */
/* All anim_types whose values are to be converted from Degree to Radians can be ORed here
*/
if (STREQ("spot_size", anim_type)) {
/* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10
* Reason: old blender versions stored spot_size in radians (was a bug)
@@ -697,7 +702,7 @@ float AnimationImporter::convert_to_focal_length(float in_xfov,
float aspect,
float sensorx)
{
// NOTE: Needs more testing (As we curretnly have no official test data for this)
/* NOTE: Needs more testing (As we curretnly have no official test data for this) */
float xfov = (fov_type == CAMERA_YFOV) ?
(2.0f * atanf(aspect * tanf(DEG2RADF(in_xfov) * 0.5f))) :
DEG2RADF(in_xfov);
@@ -721,10 +726,10 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
return;
}
else {
//anim_type has animations
/* anim_type has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
/* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -733,7 +738,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
/* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
@@ -785,8 +790,8 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
}
// new curves to assign matrix transform animation
FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
/* new curves to assign matrix transform animation */
FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = 10;
const char *tm_str = NULL;
char rna_path[200];
@@ -822,10 +827,12 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
std::vector<float>::iterator it;
//float qref[4];
//unit_qt(qref);
#if 0
float qref[4];
unit_qt(qref);
#endif
// sample values at each frame
/* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -834,23 +841,26 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
unit_m4(matfra);
// calc object-space mat
/* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
// for joints, we need a special matrix
/* for joints, we need a special matrix */
if (is_joint) {
// special matrix: iR * M * iR_dae * R
// where R, iR are bone rest and inverse rest mats in world space (Blender bones),
// iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
/* special matrix: iR * M * iR_dae * R
* where R, iR are bone rest and inverse rest mats in world space (Blender bones),
* iR_dae is joint inverse rest matrix (DAE)
* and M is an evaluated joint world-space matrix (DAE) */
float temp[4][4], par[4][4];
// calc M
/* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
// evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
#if 0
evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
#endif
// calc special matrix
/* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
}
else {
@@ -860,7 +870,7 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
float rot[4], loc[3], scale[3];
mat4_decompose(loc, rot, scale, mat);
// add keys
/* add keys */
for (int i = 0; i < totcu; i++) {
if (i < 4)
add_bezt(newcu[i], fra, rot[i]);
@@ -875,13 +885,15 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
ListBase *curves = &ob->adt->action->curves;
// add curves
/* add curves */
for (int i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
else
BLI_addtail(curves, newcu[i]);
// fcurve_is_used(newcu[i]); // never added to unused
#if 0
fcurve_is_used(newcu[i]); /* never added to unused */
#endif
}
if (is_joint) {
@@ -913,7 +925,7 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
const double yfov = camera->getYFov().getValue();
if (yfov == 0) {
aspect = 1; // assume yfov and xfov are equal
aspect = 1; /* assume yfov and xfov are equal */
}
else {
const double xfov = camera->getXFov().getValue();
@@ -976,12 +988,12 @@ void AnimationImporter::translate_Animations(
else
act = ob->adt->action;
//Get the list of animation curves of the object
/* Get the list of animation curves of the object */
ListBase *AnimCurves = &(act->curves);
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();
@@ -991,16 +1003,16 @@ void AnimationImporter::translate_Animations(
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
//check if transformation has animations
/* check if transformation has animations */
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
else {
//transformation has animations
/* transformation has animations */
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings &bindings =
animlist->getAnimationBindings();
//all the curves belonging to the current binding
/* all the curves belonging to the current binding */
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
@@ -1012,12 +1024,13 @@ void AnimationImporter::translate_Animations(
add_bone_animation_sampled(ob, animcurves, root, node, transform);
}
else {
//calculate rnapaths and array index of fcurves according to transformation and animation class
/* calculate rnapaths and array index of fcurves according to transformation and
* animation class */
Assign_transform_animations(
transform, &bindings[j], &animcurves, is_joint, joint_path);
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
/* Add the curves of the current animation to the object */
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve *fcu = *iter;
@@ -1192,7 +1205,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
std::vector<float> frames;
find_frames(&frames, &animcurves);
// convert degrees to radians
/* convert degrees to radians */
if (tm->getTransformationType() == COLLADAFW::Transformation::ROTATE) {
std::vector<FCurve *>::iterator iter;
@@ -1219,8 +1232,8 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
copy_m4_m4(rest, bone->arm_mat);
invert_m4_m4(irest, rest);
// new curves to assign matrix transform animation
FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
/* new curves to assign matrix transform animation */
FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale. */
unsigned int totcu = 10;
const char *tm_str = NULL;
char rna_path[200];
@@ -1257,7 +1270,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
std::vector<float>::iterator it;
// sample values at each frame
/* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -1266,22 +1279,23 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
unit_m4(matfra);
// calc object-space mat
/* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
// for joints, we need a special matrix
// special matrix: iR * M * iR_dae * R
// where R, iR are bone rest and inverse rest mats in world space (Blender bones),
// iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
/* for joints, we need a special matrix
* special matrix: iR * M * iR_dae * R
* where R, iR are bone rest and inverse rest mats in world space (Blender bones),
* iR_dae is joint inverse rest matrix (DAE)
* and M is an evaluated joint world-space matrix (DAE). */
float temp[4][4], par[4][4];
// calc M
/* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
// evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
/* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
// calc special matrix
/* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
float rot[4], loc[3], scale[3];
@@ -1292,7 +1306,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
copy_v3_v3(loc, mat[3]);
mat4_to_size(scale, mat);
// add keys
/* add keys */
for (int i = 0; i < totcu; i++) {
if (i < 4)
add_bezt(newcu[i], fra, rot[i]);
@@ -1305,17 +1319,20 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
Main *bmain = CTX_data_main(mContext);
verify_adt_action(bmain, (ID *)&ob->id, 1);
// add curves
/* add curves */
for (int i = 0; i < totcu; i++) {
add_bone_fcurve(ob, node, newcu[i]);
// fcurve_is_used(newcu[i]); // never added to unused
#if 0
fcurve_is_used(newcu[i]); /* never added to unused */
#endif
}
bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name);
chan->rotmode = ROT_MODE_QUAT;
}
//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
/* Check if object is animated by checking if animlist_map
* holds the animlist_id of node transforms */
AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
@@ -1324,12 +1341,12 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
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();
//check if transformation has animations
/* check if transformation has animations */
if (animlist_map.find(listid) == animlist_map.end()) {
continue;
}
@@ -1356,7 +1373,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *)
FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
if (camera == NULL) {
// Can happen if the node refers to an unknown camera.
/* Can happen if the node refers to an unknown camera. */
continue;
}
@@ -1398,7 +1415,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
&(efc->getSpecular().getColor()), (types->material), MATERIAL_SPEC_COLOR);
types->material = setAnimType(
&(efc->getDiffuse().getColor()), (types->material), MATERIAL_DIFF_COLOR);
// types->material = setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
#if 0
types->material = setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
#endif
types->material = setAnimType(
&(efc->getIndexOfRefraction()), (types->material), MATERIAL_IOR);
}
@@ -1420,26 +1439,26 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types,
return anim_type;
}
// Is not used anymore.
/* Is not used anymore. */
void AnimationImporter::find_frames_old(std::vector<float> *frames,
COLLADAFW::Node *node,
COLLADAFW::Transformation::TransformationType tm_type)
{
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
// for each <rotate>, <translate>, etc. there is a separate Transformation
/* for each <rotate>, <translate>, etc. there is a separate Transformation */
const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
unsigned int i;
// find frames at which to sample plus convert all rotation keys to radians
/* find frames at which to sample plus convert all rotation keys to radians */
for (i = 0; i < nodeTransforms.getCount(); i++) {
COLLADAFW::Transformation *transform = nodeTransforms[i];
COLLADAFW::Transformation::TransformationType nodeTmType = transform->getTransformationType();
if (nodeTmType == tm_type) {
//get animation bindings for the current transformation
/* get animation bindings for the current transformation */
const COLLADAFW::UniqueId &listid = transform->getAnimationList();
//if transform is animated its animlist must exist.
/* if transform is animated its animlist must exist. */
if (animlist_map.find(listid) != animlist_map.end()) {
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
@@ -1447,7 +1466,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
animlist->getAnimationBindings();
if (bindings.getCount()) {
//for each AnimationBinding get the fcurves which animate the transform
/* for each AnimationBinding get the fcurves which animate the transform */
for (unsigned int j = 0; j < bindings.getCount(); j++) {
std::vector<FCurve *> &curves = curve_map[bindings[j].animation];
bool xyz = ((nodeTmType == COLLADAFW::Transformation::TRANSLATE ||
@@ -1460,14 +1479,14 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
for (iter = curves.begin(); iter != curves.end(); iter++) {
FCurve *fcu = *iter;
//if transform is rotation the fcurves values must be turned in to radian.
/* if transform is rotation the fcurves values must be turned in to radian. */
if (is_rotation)
fcurve_deg_to_rad(fcu);
for (unsigned int k = 0; k < fcu->totvert; k++) {
//get frame value from bezTriple
/* get frame value from bezTriple */
float fra = fcu->bezt[k].vec[1][0];
//if frame already not added add frame to frames
/* if frame already not added add frame to frames */
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
frames->push_back(fra);
}
@@ -1483,9 +1502,9 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
}
}
// prerequisites:
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
/* prerequisites:
* animlist_map - map animlist id -> animlist
* curve_map - map anim id -> curve(s) */
Object *AnimationImporter::translate_animation_OLD(
COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object *> &object_map,
@@ -1509,7 +1528,7 @@ Object *AnimationImporter::translate_animation_OLD(
return NULL;
}
// frames at which to sample
/* frames at which to sample */
std::vector<float> frames;
find_frames_old(&frames, node, tm_type);
@@ -1569,8 +1588,8 @@ Object *AnimationImporter::translate_animation_OLD(
if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
// new curves
FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale
/* new curves */
FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
unsigned int totcu = is_matrix ? 10 : (is_rotation ? 4 : 3);
for (i = 0; i < totcu; i++) {
@@ -1606,7 +1625,7 @@ Object *AnimationImporter::translate_animation_OLD(
std::vector<float>::iterator it;
// sample values at each frame
/* sample values at each frame */
for (it = frames.begin(); it != frames.end(); it++) {
float fra = *it;
@@ -1615,23 +1634,24 @@ Object *AnimationImporter::translate_animation_OLD(
unit_m4(matfra);
// calc object-space mat
/* calc object-space mat */
evaluate_transform_at_frame(matfra, node, fra);
// for joints, we need a special matrix
/* for joints, we need a special matrix */
if (is_joint) {
// special matrix: iR * M * iR_dae * R
// where R, iR are bone rest and inverse rest mats in world space (Blender bones),
// iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE)
/* special matrix: iR * M * iR_dae * R
* where R, iR are bone rest and inverse rest mats in world space (Blender bones),
* iR_dae is joint inverse rest matrix (DAE)
* and M is an evaluated joint world-space matrix (DAE). */
float temp[4][4], par[4][4];
// calc M
/* calc M */
calc_joint_parent_mat_rest(par, NULL, root, node);
mul_m4_m4m4(temp, par, matfra);
// evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
/* evaluate_joint_world_transform_at_frame(temp, NULL, node, fra); */
// calc special matrix
/* calc special matrix */
mul_m4_series(mat, irest, temp, irest_dae, rest);
}
else {
@@ -1660,7 +1680,7 @@ Object *AnimationImporter::translate_animation_OLD(
break;
}
// add keys
/* add keys */
for (i = 0; i < totcu; i++) {
if (is_matrix) {
if (i < 4)
@@ -1717,7 +1737,7 @@ Object *AnimationImporter::translate_animation_OLD(
ListBase *curves = &ob->adt->action->curves;
// add curves
/* add curves */
for (i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
@@ -1743,9 +1763,9 @@ Object *AnimationImporter::translate_animation_OLD(
return job;
}
// internal, better make it private
// warning: evaluates only rotation and only assigns matrix transforms now
// prerequisites: animlist_map, curve_map
/* internal, better make it private
* warning: evaluates only rotation and only assigns matrix transforms now
* prerequisites: animlist_map, curve_map */
void AnimationImporter::evaluate_transform_at_frame(float mat[4][4],
COLLADAFW::Node *node,
float fra)
@@ -1804,7 +1824,7 @@ static void report_class_type_unsupported(const char *path,
}
}
// return true to indicate that mat contains a sane value
/* return true to indicate that mat contains a sane value */
bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
float mat[4][4],
float fra,
@@ -1865,7 +1885,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return false;
}
// TODO support other animclasses
/* TODO support other animclasses */
if (animclass != COLLADAFW::AnimationList::ANGLE) {
report_class_type_unsupported(path, animclass, type);
return false;
@@ -1911,7 +1931,8 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
}
}
else if (type == COLLADAFW::Transformation::MATRIX) {
// for now, of matrix animation, support only the case when all values are packed into one animation
/* for now, of matrix animation,
* support only the case when all values are packed into one animation */
if (curves.size() != 16) {
fprintf(stderr, "%s: expected 16 curves, got %d\n", path, (int)curves.size());
return false;
@@ -1945,13 +1966,13 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
return false;
}
// gives a world-space mat of joint at rest position
/* gives a world-space mat of joint at rest position */
void AnimationImporter::get_joint_rest_mat(float mat[4][4],
COLLADAFW::Node *root,
COLLADAFW::Node *node)
{
// if bind mat is not available,
// use "current" node transform, i.e. all those tms listed inside <node>
/* if bind mat is not available,
* use "current" node transform, i.e. all those tms listed inside <node> */
if (!armature_importer->get_joint_bind_mat(mat, node)) {
float par[4][4], m[4][4];
@@ -1961,7 +1982,7 @@ void AnimationImporter::get_joint_rest_mat(float mat[4][4],
}
}
// gives a world-space mat, end's mat not included
/* gives a world-space mat, end's mat not included */
bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
float par[4][4],
COLLADAFW::Node *node,
@@ -1974,7 +1995,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
return true;
}
// use bind matrix if available or calc "current" world mat
/* use bind matrix if available or calc "current" world mat */
if (!armature_importer->get_joint_bind_mat(m, node)) {
if (par) {
float temp[4][4];
@@ -2033,7 +2054,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root,
BKE_object_where_is_calc(scene, job);
// after parenting and layer change
/* after parenting and layer change */
DEG_relations_tag_update(CTX_data_main(C));
joint_objects[node->getUniqueId()] = job;
@@ -2044,8 +2065,8 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root,
#endif
#if 0
// recursively evaluates joint tree until end is found, mat then is world-space matrix of end
// mat must be identity on enter, node must be root
/* recursively evaluates joint tree until end is found,
* mat then is world-space matrix of end mat must be identity on enter, node must be root. */
bool AnimationImporter::evaluate_joint_world_transform_at_frame(
float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end, float fra)
{

View File

@@ -246,7 +246,7 @@ void ArmatureExporter::add_bone_node(Bone *bone,
void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node &node)
{
//bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
// bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
float mat[4][4];
float bone_rest_mat[4][4]; /* derived from bone->arm_mat */

View File

@@ -39,7 +39,7 @@ extern "C" {
#include "collada_utils.h"
#include "ArmatureImporter.h"
// use node name, or fall back to original id if not present (name is optional)
/* use node name, or fall back to original id if not present (name is optional) */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
@@ -65,7 +65,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv,
ArmatureImporter::~ArmatureImporter()
{
// free skin controller data if we forget to do this earlier
/* free skin controller data if we forget to do this earlier */
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
it->second.free();
@@ -102,7 +102,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
float joint_bind_mat[4][4];
int chain_length = 0;
//Checking if bone is already made.
/* Checking if bone is already made. */
std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if (it != finished_joints.end())
@@ -122,10 +122,10 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
SkinInfo *b = &skin_it->second;
if (b->get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
// get original world-space matrix
/* get original world-space matrix */
invert_m4_m4(mat, joint_inv_bind_mat);
copy_m4_m4(joint_bind_mat, mat);
// And make local to armature
/* And make local to armature */
Object *ob_arm = skin->BKE_armature_from_object();
if (ob_arm) {
float invmat[4][4];
@@ -138,7 +138,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
}
}
// create a bone even if there's no joint data for it (i.e. it has no influence)
/* create a bone even if there's no joint data for it (i.e. it has no influence) */
if (!bone_is_skinned) {
get_node_mat(mat, node, NULL, NULL, parent_mat);
}
@@ -185,7 +185,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
bc_set_IDPropertyMatrix(bone, "rest_mat", rest_mat);
}
add_v3_v3v3(bone->tail, bone->head, tail); //tail must be non zero
add_v3_v3v3(bone->tail, bone->head, tail); /* tail must be non zero */
/* find smallest bone length in armature (used later for leaf bone length) */
if (parent) {
@@ -385,7 +385,7 @@ void ArmatureImporter::set_leaf_bone_shapes(Object *ob_arm)
void ArmatureImporter::set_euler_rotmode()
{
// just set rotmode = ROT_MODE_EUL on pose channel for each joint
/* just set rotmode = ROT_MODE_EUL on pose channel for each joint */
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>::iterator it;
@@ -445,14 +445,14 @@ Object *ArmatureImporter::find_armature(COLLADAFW::Node *node)
ArmatureJoints &ArmatureImporter::get_armature_joints(Object *ob_arm)
{
// try finding it
/* try finding it */
std::vector<ArmatureJoints>::iterator it;
for (it = armature_joints.begin(); it != armature_joints.end(); it++) {
if ((*it).ob_arm == ob_arm)
return *it;
}
// not found, create one
/* not found, create one */
ArmatureJoints aj;
aj.ob_arm = ob_arm;
armature_joints.push_back(aj);
@@ -465,7 +465,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
std::vector<COLLADAFW::Node *>::iterator ri;
std::vector<std::string> layer_labels;
//if there is an armature created for root_joint next root_joint
/* 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;
@@ -519,12 +519,12 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
{
// just do like so:
// - get armature
// - enter editmode
// - add edit bones and head/tail properties using matrices and parent-child info
// - exit edit mode
// - set a sphere shape to leaf bones
/* just do like so:
* - get armature
* - enter editmode
* - add edit bones and head/tail properties using matrices and parent-child info
* - exit edit mode
* - set a sphere shape to leaf bones */
Object *ob_arm = NULL;
@@ -543,8 +543,8 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
* for each root in root_joints:
* for each joint in joints:
* if find_node_in_tree(joint, root):
* if (std::find(root_joints.begin(), root_joints.end(), root) == root_joints.end())
* root_joints.push_back(root);
* if (std::find(root_joints.begin(), root_joints.end(), root) ==
* root_joints.end()) root_joints.push_back(root);
*
* for (each skin B with armature) {
* find all root joints for skin B
@@ -588,13 +588,13 @@ 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
// strict relationship between geometries and armatures
// So when we reimport a Blender collada file, then we have
// to guess what is meant.
// XXX This is not safe when we have more than one armatures
// in the import.
/* 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.
* XXX This is not safe when we have more than one armatures
* in the import. */
shared = this->joint_parent_map.begin()->second;
}
@@ -602,28 +602,29 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
ob_arm = skin.set_armature(shared);
}
else {
ob_arm = skin.create_armature(m_bmain, scene, view_layer); //once for every armature
ob_arm = skin.create_armature(m_bmain, scene, view_layer); // once for every armature
}
// enter armature edit mode
/* enter armature edit mode */
bArmature *armature = (bArmature *)ob_arm->data;
ED_armature_to_edit(armature);
totbone = 0;
// bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on default row
// bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on
/* default row */
// create bones
/* create bones */
/* TODO:
* check if bones have already been created for a given joint */
std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
// for shared armature check if bone tree is already created
/* for shared armature check if bone tree is already created */
if (shared &&
std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end())
continue;
// since root_joints may contain joints for multiple controllers, we need to filter
/* since root_joints may contain joints for multiple controllers, we need to filter */
if (skin.uses_joint_or_descendant(*ri)) {
create_bone(
@@ -662,14 +663,14 @@ void ArmatureImporter::set_pose(Object *ob_arm,
float mat[4][4];
float obmat[4][4];
// object-space
/* object-space */
get_node_mat(obmat, root_node, NULL, NULL);
//if (*edbone)
// if (*edbone)
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone_name);
//else fprintf ( "",
// else fprintf ( "",
// get world-space
/* get world-space */
if (parentname) {
mul_m4_m4m4(mat, parent_mat, obmat);
bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname);
@@ -725,7 +726,7 @@ void ArmatureImporter::add_root_joint(COLLADAFW::Node *node)
}
#endif
// here we add bones to armatures, having armatures previously created in write_controller
/* here we add bones to armatures, having armatures previously created in write_controller */
void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &objects_to_scale)
{
Main *bmain = CTX_data_main(C);
@@ -741,7 +742,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
Object *ob_arm = create_armature_bones(bmain, skin);
// link armature with a mesh object
/* link armature with a mesh object */
const COLLADAFW::UniqueId &uid = skin.get_controller_uid();
const COLLADAFW::UniqueId *guid = get_geometry_uid(uid);
if (guid != NULL) {
@@ -772,19 +773,19 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
else
fprintf(stderr, "Cannot find geometry to link armature with.\n");
// set armature parent if any
/* set armature parent if any */
Object *par = skin.get_parent();
if (par)
bc_set_parent(skin.BKE_armature_from_object(), par, C, false);
// free memory stolen from SkinControllerData
/* free memory stolen from SkinControllerData */
skin.free();
}
//for bones without skins
/* for bones without skins */
create_armature_bones(bmain, ob_arms);
// Fix bone relations
/* Fix bone relations */
std::vector<Object *>::iterator ob_arm_it;
for (ob_arm_it = ob_arms.begin(); ob_arm_it != ob_arms.end(); ob_arm_it++) {
@@ -802,7 +803,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
}
#if 0
// link with meshes, create vertex groups, assign weights
/* link with meshes, create vertex groups, assign weights */
void ArmatureImporter::link_armature(Object *ob_arm,
const COLLADAFW::UniqueId &geom_id,
const COLLADAFW::UniqueId &controller_data_id)
@@ -821,25 +822,25 @@ void ArmatureImporter::link_armature(Object *ob_arm,
SkinInfo &skin = skin_by_data_uid[conroller_data_id];
// create vertex groups
/* create vertex groups */
}
#endif
bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData *data)
{
// at this stage we get vertex influence info that should go into me->verts and ob->defbase
// there's no info to which object this should be long so we associate it with skin controller data UID
/* at this stage we get vertex influence info that should go into me->verts and ob->defbase
* there's no info to which object this should be long so we associate it with
* skin controller data UID. */
// don't forget to call defgroup_unique_name before we copy
/* don't forget to call defgroup_unique_name before we copy */
// controller data uid -> [armature] -> joint data,
// [mesh object]
//
/* controller data uid -> [armature] -> joint data,
* [mesh object] */
SkinInfo skin(unit_converter);
skin.borrow_skin_controller_data(data);
// store join inv bind matrix to use it later in armature construction
/* store join inv bind matrix to use it later in armature construction */
const COLLADAFW::Matrix4Array &inv_bind_mats = data->getInverseBindMatrices();
for (unsigned int i = 0; i < data->getJointsCount(); i++) {
skin.add_joint(inv_bind_mats[i]);
@@ -852,12 +853,12 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
{
// - create and store armature object
/* - create and store armature object */
const COLLADAFW::UniqueId &con_id = controller->getUniqueId();
if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_SKIN) {
COLLADAFW::SkinController *co = (COLLADAFW::SkinController *)controller;
// to be able to find geom id by controller id
/* to be able to find geom id by controller id */
geom_uid_by_controller_uid[con_id] = co->getSource();
const COLLADAFW::UniqueId &data_uid = co->getSkinControllerData();
@@ -868,12 +869,12 @@ bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
skin_by_data_uid[data_uid].set_controller(co);
}
// morph controller
/* morph controller */
else if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_MORPH) {
COLLADAFW::MorphController *co = (COLLADAFW::MorphController *)controller;
// to be able to find geom id by controller id
/* to be able to find geom id by controller id */
geom_uid_by_controller_uid[con_id] = co->getSource();
//Shape keys are applied in DocumentImporter->finish()
/* Shape keys are applied in DocumentImporter->finish() */
morph_controllers.push_back(co);
}
@@ -887,29 +888,29 @@ void ArmatureImporter::make_shape_keys(bContext *C)
float weight;
for (mc = morph_controllers.begin(); mc != morph_controllers.end(); mc++) {
//Controller data
/* Controller data */
COLLADAFW::UniqueIdArray &morphTargetIds = (*mc)->getMorphTargets();
COLLADAFW::FloatOrDoubleArray &morphWeights = (*mc)->getMorphWeights();
//Prereq: all the geometries must be imported and mesh objects must be made
/* 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;
//insert key to source mesh
/* insert key to source mesh */
Key *key = source_me->key = BKE_key_add(bmain, (ID *)source_me);
key->type = KEY_RELATIVE;
KeyBlock *kb;
//insert basis key
/* insert basis key */
kb = BKE_keyblock_add_ctime(key, "Basis", false);
BKE_keyblock_convert_from_mesh(source_me, key, kb);
//insert other shape keys
/* insert other shape keys */
for (int i = 0; i < morphTargetIds.getCount(); i++) {
//better to have a separate map of morph objects,
//This'll do for now since only mesh morphing is imported
/* better to have a separate map of morph objects,
* This'll do for now since only mesh morphing is imported */
Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
@@ -920,7 +921,7 @@ void ArmatureImporter::make_shape_keys(bContext *C)
kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false);
BKE_keyblock_convert_from_mesh(me, key, kb);
//apply weights
/* apply weights */
weight = morphWeights.getFloatValues()->getData()[i];
kb->curval = weight;
}
@@ -973,7 +974,7 @@ void ArmatureImporter::get_rna_path_for_joint(COLLADAFW::Node *node,
BLI_snprintf(joint_path, count, "pose.bones[\"%s\"]", bc_get_joint_name(node));
}
// gives a world-space mat
/* gives a world-space mat */
bool ArmatureImporter::get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint)
{
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;

View File

@@ -118,7 +118,7 @@ void BCAnimationCurve::create_bezt(float frame, float output)
BCAnimationCurve::~BCAnimationCurve()
{
if (curve_is_local_copy && fcurve) {
//fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
// fprintf(stderr, "removed fcurve %s\n", fcurve->rna_path);
delete_fcurve(fcurve);
this->fcurve = NULL;
}
@@ -637,7 +637,8 @@ void BCBezTriple::get_tangent(Scene *scene, float point[2], bool as_angle, int i
{
point[0] = FRA2TIME(bezt.vec[index][0]);
if (bezt.ipo != BEZT_IPO_BEZ) {
/* We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data */
/* We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain
* unused data */
point[0] = 0;
point[1] = 0;
}

View File

@@ -82,7 +82,7 @@ bool ControllerExporter::add_instance_controller(Object *ob)
if (!me->dvert)
return false;
// write root bone URLs
/* write root bone URLs */
Bone *bone;
for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
write_bone_URLs(ins, ob_arm, bone);
@@ -162,17 +162,17 @@ std::string ControllerExporter::get_controller_id(Key *key, Object *ob)
return translate_id(id_name(ob)) + MORPH_CONTROLLER_ID_SUFFIX;
}
// ob should be of type OB_MESH
// both args are required
/* ob should be of type OB_MESH
* both args are required */
void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
{
// joint names
// joint inverse bind matrices
// vertex weights
/* joint names
* joint inverse bind matrices
* vertex weights */
// input:
// joint names: ob -> vertex group names
// vertex group weights: me->dvert -> groups -> index, weight
/* input:
* joint names: ob -> vertex group names
* vertex group weights: me->dvert -> groups -> index, weight */
#if 0
me->dvert :
@@ -222,7 +222,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
{
int i, j;
// def group index -> joint index
/* def group index -> joint index */
std::vector<int> joint_index_by_def_index;
bDeformGroup *def;
@@ -238,14 +238,14 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
MDeformVert *vert = &me->dvert[i];
std::map<int, float> jw;
// We're normalizing the weights later
/* We're normalizing the weights later */
float sumw = 0.0f;
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
// why the Out Of Bound indexes get created ?
/* XXX: Maybe better find out where and
* why the Out Of Bound indexes get created ? */
oob_counter += 1;
}
else {
@@ -331,8 +331,8 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
BKE_id_free(NULL, me);
//support for animations
//can also try the base element and param alternative
/* support for animations
* can also try the base element and param alternative */
add_weight_extras(key);
closeMorph();
closeController();
@@ -354,7 +354,7 @@ std::string ControllerExporter::add_morph_targets(Key *key, Object *ob)
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
//skip the basis
/* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name);
@@ -382,7 +382,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
source.prepareToAppendValues();
KeyBlock *kb = (KeyBlock *)key->block.first;
//skip the basis
/* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
float weight = kb->curval;
@@ -393,18 +393,18 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
return source_id;
}
//Added to implement support for animations.
/* Added to implement support for animations. */
void ControllerExporter::add_weight_extras(Key *key)
{
// can also try the base element and param alternative
/* can also try the base element and param alternative */
COLLADASW::BaseExtraTechnique extra;
KeyBlock *kb = (KeyBlock *)key->block.first;
//skip the basis
/* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
// XXX why is the weight not used here and set to 0.0?
// float weight = kb->curval;
/* XXX why is the weight not used here and set to 0.0?
* float weight = kb->curval; */
extra.addExtraTechniqueParameter("KHR", "morph_weights", 0.000, "MORPH_WEIGHT_TO_TARGET");
}
}
@@ -431,7 +431,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob)
float f_obmat[4][4];
BKE_object_matrix_local_get(ob, f_obmat);
//UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
// UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
UnitConverter::mat4_to_dae_double(bind_mat, f_obmat);
if (this->export_settings->limit_precision)
bc_sanitize_mat(bind_mat, LIMITTED_PRECISION);
@@ -489,7 +489,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
COLLADASW::FloatSourceF source(mSW);
source.setId(source_id);
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
source.setAccessorCount(totjoint); //BLI_listbase_count(defbase));
source.setAccessorCount(totjoint); // BLI_listbase_count(defbase));
source.setAccessorStride(16);
source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
@@ -503,7 +503,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
int flag = arm->flag;
// put armature in rest position
/* put armature in rest position */
if (!(arm->flag & ARM_RESTPOS)) {
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene = blender_context.get_scene();
@@ -531,7 +531,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
bc_create_restpose_mat(
this->export_settings, pchan->bone, bind_mat, pchan->bone->arm_mat, true);
// SL/OPEN_SIM COMPATIBILITY
/* SL/OPEN_SIM COMPATIBILITY */
if (export_settings->open_sim) {
float loc[3];
@@ -539,12 +539,12 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
float scale[3];
bc_decompose(bind_mat, loc, NULL, NULL, scale);
// Only translations, no rotation vs armature
/* Only translations, no rotation vs armature */
loc_eulO_size_to_mat4(bind_mat, loc, rot, scale, 6);
}
}
// make world-space matrix (bind_mat is armature-space)
/* make world-space matrix (bind_mat is armature-space) */
mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
invert_m4_m4(mat, world);
@@ -555,7 +555,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
}
}
// back from rest position
/* back from rest position */
if (!(flag & ARM_RESTPOS)) {
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene = blender_context.get_scene();
@@ -625,7 +625,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
weightselem.setCount(vcounts.size());
// write number of deformers per vertex
/* write number of deformers per vertex */
COLLADASW::PrimitivesBase::VCountList vcountlist;
vcountlist.resize(vcounts.size());
@@ -636,7 +636,7 @@ void ControllerExporter::add_vertex_weights_element(const std::string &weights_s
weightselem.CloseVCountAndOpenVElement();
// write deformer index - weight index pairs
/* write deformer index - weight index pairs */
int weight_index = 0;
for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) {
weightselem.appendValues(*i, weight_index++);

View File

@@ -198,7 +198,7 @@ int DocumentExporter::exportCurrentScene()
RNA_id_pointer_create(&(sce->id), &sceneptr);
unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
system = RNA_struct_find_property(&unit_settings, "system");
//scale = RNA_struct_find_property(&unit_settings, "scale_length");
// scale = RNA_struct_find_property(&unit_settings, "scale_length");
std::string unitname = "meter";
float linearmeasure = RNA_float_get(&unit_settings, "scale_length");
@@ -338,5 +338,6 @@ void DocumentExporter::exportScenes(const char *filename)
/*
* NOTES:
*
* AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
* AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a
* user
*/

View File

@@ -18,9 +18,9 @@
* \ingroup collada
*/
// TODO:
// * name imported objects
// * import object rotation as euler
/* TODO:
* * name imported objects
* * import object rotation as euler */
#include <string>
#include <map>
@@ -131,7 +131,7 @@ bool DocumentImporter::import()
loader.registerExtraDataCallbackHandler(ehandler);
// deselect all to select new objects
/* deselect all to select new objects */
BKE_view_layer_base_deselect_all(view_layer);
std::string mFilename = std::string(this->import_settings->filepath);
@@ -165,12 +165,12 @@ bool DocumentImporter::import()
void DocumentImporter::cancel(const COLLADAFW::String &errorMessage)
{
// TODO: if possible show error info
//
// Should we get rid of invisible Meshes that were created so far
// or maybe create objects at coordinate space origin?
//
// The latter sounds better.
/* TODO: if possible show error info
*
* Should we get rid of invisible Meshes that were created so far
* or maybe create objects at coordinate space origin?
*
* The latter sounds better. */
}
void DocumentImporter::start()
@@ -183,7 +183,8 @@ void DocumentImporter::finish()
return;
Main *bmain = CTX_data_main(mContext);
// TODO: create a new scene except the selected <visual_scene> - use current blender scene for it
/* TODO: create a new scene except the selected <visual_scene> -
* use current blender scene for it */
Scene *sce = CTX_data_scene(mContext);
unit_converter.calculate_scale(*sce);
@@ -195,7 +196,7 @@ void DocumentImporter::finish()
PointerRNA sceneptr, unit_settings;
PropertyRNA *system, *scale;
// for scene unit settings: system, scale_length
/* for scene unit settings: system, scale_length */
RNA_id_pointer_create(&sce->id, &sceneptr);
unit_settings = RNA_pointer_get(&sceneptr, "unit_settings");
@@ -220,7 +221,7 @@ void DocumentImporter::finish()
fprintf(stdout, "Collada: Adjusting Blender units to Importset units: %f.\n", unit_factor);
}
// Write nodes to scene
/* Write nodes to scene */
fprintf(stderr, "+-- Import Scene --------\n");
const COLLADAFW::NodePointerArray &roots = (*sit)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++) {
@@ -254,7 +255,7 @@ void DocumentImporter::finish()
if (libnode_ob.size()) {
fprintf(stderr, "| Cleanup: free %d library nodes\n", (int)libnode_ob.size());
// free all library_nodes
/* free all library_nodes */
std::vector<Object *>::iterator it;
for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
Object *ob = *it;
@@ -267,7 +268,7 @@ void DocumentImporter::finish()
delete objects_to_scale;
// update scene
/* update scene */
DEG_id_tag_update(&sce->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -277,15 +278,15 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
COLLADAFW::Node *par = NULL,
Object *parob = NULL)
{
// The split in #29246, rootmap must point at actual root when
// calculating bones in apply_curves_as_matrix. - actual root is the root node.
// This has to do with inverse bind poses being world space
// (the sources for skinned bones' restposes) and the way
// non-skinning nodes have their "restpose" recursively calculated.
// XXX TODO: design issue, how to support unrelated joints taking
// part in skinning.
/* The split in #29246, rootmap must point at actual root when
* calculating bones in apply_curves_as_matrix. - actual root is the root node.
* This has to do with inverse bind poses being world space
* (the sources for skinned bones' restposes) and the way
* non-skinning nodes have their "restpose" recursively calculated.
* XXX TODO: design issue, how to support unrelated joints taking
* part in skinning. */
if (par) { // && par->getType() == COLLADAFW::Node::JOINT) {
// par is root if there's no corresp. key in root_map
/* par is root if there's no corresp. key in root_map */
if (root_map.find(par->getUniqueId()) == root_map.end())
root_map[node->getUniqueId()] = node;
else
@@ -305,9 +306,9 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
unsigned int i;
if (node->getType() == COLLADAFW::Node::JOINT && par == NULL) {
// For Skeletons without root node we have to simulate the
// root node here and recursively enter the same function
// XXX: maybe this can be made more elegant.
/* For Skeletons without root node we have to simulate the
* root node here and recursively enter the same function
* XXX: maybe this can be made more elegant. */
translate_anim_recursive(node, node, parob);
}
else {
@@ -335,7 +336,7 @@ std::string DocumentImporter::get_import_version(const COLLADAFW::FileInfo *asse
const COLLADAFW::String &value = valuePair->second;
if (key == AUTORING_TOOL) {
if (value.compare(0, BLENDER.length(), BLENDER) == 0) {
// Was made with Blender, now get version string
/* Was made with Blender, now get version string */
std::string v = value.substr(BLENDER.length());
std::string::size_type n = v.find(" ");
if (n > 0) {
@@ -361,7 +362,7 @@ bool DocumentImporter::writeGlobalAsset(const COLLADAFW::FileInfo *asset)
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene)
{
// XXX could store the scene id, but do nothing for now
/* XXX could store the scene id, but do nothing for now */
return true;
}
Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
@@ -404,7 +405,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
Scene *sce,
bool is_library_node)
{
//fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL);
// fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ?
// instance_node->getOriginalId().c_str() : NULL, source_node ?
// source_node->getOriginalId().c_str() : NULL);
Main *bmain = CTX_data_main(mContext);
Object *obn = BKE_object_copy(bmain, source_ob);
@@ -413,10 +416,10 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
if (instance_node) {
anim_importer.read_node_transform(instance_node, obn);
// if we also have a source_node (always ;), take its
// transformation matrix and apply it to the newly instantiated
// object to account for node hierarchy transforms in
// .dae
/* if we also have a source_node (always ;), take its
* transformation matrix and apply it to the newly instantiated
* object to account for node hierarchy transforms in
* .dae */
if (source_node) {
COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix();
COLLADABU::Math::Matrix4 bmat4 =
@@ -427,7 +430,7 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
mat[i][j] = bmat4[i][j];
}
}
// calc new matrix and apply
/* calc new matrix and apply */
mul_m4_m4m4(obn->obmat, obn->obmat, mat);
BKE_object_apply_mat4(obn, obn->obmat, 0, 0);
}
@@ -467,8 +470,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
return obn;
}
// to create constraints off node <extra> tags. Assumes only constraint data in
// current <extra> with blender profile.
/* to create constraints off node <extra> tags. Assumes only constraint data in
* current <extra> with blender profile. */
void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
{
if (et && et->isProfile("blender")) {
@@ -504,7 +507,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
std::string id = node->getOriginalId();
std::string name = node->getName();
// if node has child nodes write them
/* if node has child nodes write them */
COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
std::vector<Object *> *objects_done = new std::vector<Object *>();
@@ -515,8 +518,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
if (is_joint) {
if (parent_node == NULL && !is_library_node) {
// A Joint on root level is a skeleton without root node.
// Here we add the armature "on the fly":
/* A Joint on root level is a skeleton without root node.
* Here we add the armature "on the fly": */
par = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, std::string("Armature").c_str());
objects_done->push_back(par);
root_objects->push_back(par);
@@ -528,8 +531,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
if (parent_node == NULL) {
// for skeletons without root node all has been done above.
// Skeletons with root node are handled further down.
/* for skeletons without root node all has been done above.
* Skeletons with root node are handled further down. */
goto finally;
}
}
@@ -545,9 +548,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
size_t controller_done = 0;
size_t inst_done = 0;
// XXX linking object with the first <instance_geometry>, though a node may have more of them...
// maybe join multiple <instance_...> meshes into 1, and link object with it? not sure...
// <instance_geometry>
/* XXX linking object with the first <instance_geometry>, though a node may have more of
* them... maybe join multiple <instance_...> meshes into 1, and link object with it? not
* sure... <instance_geometry> */
while (geom_done < geom.getCount()) {
ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map);
if (ob == NULL) {
@@ -602,7 +605,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
++controller_done;
}
// XXX instance_node is not supported yet
/* XXX instance_node is not supported yet */
while (inst_done < inst_node.getCount()) {
const COLLADAFW::UniqueId &node_id = inst_node[inst_done]->getInstanciatedObjectId();
if (object_map.find(node_id) == object_map.end()) {
@@ -632,10 +635,10 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
read_transform = false;
}
// if node is empty - create empty object
// XXX empty node may not mean it is empty object, not sure about this
/* if node is empty - create empty object
* XXX empty node may not mean it is empty object, not sure about this */
if ((geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) {
//Check if Object is armature, by checking if immediate child is a JOINT node.
/* Check if Object is armature, by checking if immediate child is a JOINT node. */
if (is_armature(node)) {
ob = bc_add_object(bmain, sce, view_layer, OB_ARMATURE, name.c_str());
}
@@ -648,7 +651,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
}
}
// XXX: if there're multiple instances, only one is stored
/* XXX: if there're multiple instances, only one is stored */
if (!ob) {
goto finally;
@@ -666,7 +669,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
libnode_ob.push_back(ob);
}
//create_constraints(et,ob);
// create_constraints(et,ob);
}
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end();
@@ -682,7 +685,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
ob->partype = PAROBJECT;
ob->parsubstr[0] = 0;
//bc_set_parent(ob, par, mContext, false);
// bc_set_parent(ob, par, mContext, false);
}
}
}
@@ -715,16 +718,17 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
if (mImportStage == Fetching_Controller_data)
return true;
// this method called on post process after writeGeometry, writeMaterial, etc.
// for each <node> in <visual_scene>:
// create an Object
// if Mesh (previously created in writeGeometry) to which <node> corresponds exists, link Object with that mesh
// update: since we cannot link a Mesh with Object in
// writeGeometry because <geometry> does not reference <node>,
// we link Objects with Meshes here
/* This method called on post process after writeGeometry, writeMaterial, etc. */
/* For each <node> in <visual_scene>:
* create an Object
* if Mesh (previously created in writeGeometry) to which <node> corresponds exists,
* link Object with that mesh.
*
* Update: since we cannot link a Mesh with Object in
* writeGeometry because <geometry> does not reference <node>,
* we link Objects with Meshes here.
*/
vscenes.push_back(visualScene);
return true;
@@ -819,8 +823,8 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
fprintf(stderr, "Couldn't find <profile_COMMON>.\n");
return true;
}
// XXX TODO: Take all <profile_common>s
// Currently only first <profile_common> is supported
/* XXX TODO: Take all <profile_common>s
* Currently only first <profile_common> is supported */
COLLADAFW::EffectCommon *ef = common_efs[0];
write_profile_COMMON(ef, ma);
this->FW_object_map[effect->getUniqueId()] = effect;
@@ -888,7 +892,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
double yfov = camera->getYFov().getValue();
double aspect = camera->getAspectRatio().getValue();
// NOTE: Needs more testing (As we curretnly have no official test data for this)
/* NOTE: Needs more testing (As we curretnly have no official test data for this) */
double xfov = 2.0f * atanf(aspect * tanf(DEG2RADF(yfov) * 0.5f));
cam->lens = fov_to_focallength(xfov, cam->sensor_x);
@@ -907,7 +911,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case CAM_PERSP:
default: {
double x = camera->getXFov().getValue();
// x is in degrees, cam->lens is in millimiters
/* x is in degrees, cam->lens is in millimiters */
cam->lens = fov_to_focallength(DEG2RADF(x), cam->sensor_x);
} break;
}
@@ -920,19 +924,19 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
case CAM_PERSP:
default: {
double yfov = camera->getYFov().getValue();
// yfov is in degrees, cam->lens is in millimiters
/* yfov is in degrees, cam->lens is in millimiters */
cam->lens = fov_to_focallength(DEG2RADF(yfov), cam->sensor_x);
} break;
}
} break;
case COLLADAFW::Camera::UNDEFINED:
// read nothing, use blender defaults.
/* read nothing, use blender defaults. */
break;
}
this->uid_camera_map[camera->getUniqueId()] = cam;
this->FW_object_map[camera->getUniqueId()] = camera;
// XXX import camera options
/* XXX import camera options */
return true;
}
@@ -955,7 +959,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
workpath = absolute_path;
}
else {
// Maybe imagepath was already absolute ?
/* Maybe imagepath was already absolute ? */
if (!BLI_exists(imagepath.c_str())) {
fprintf(stderr, "|! Image not found: %s\n", imagepath.c_str());
return true;
@@ -1006,7 +1010,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
return true;
}
// if we find an ExtraTags for this, use that instead.
/* if we find an ExtraTags for this, use that instead. */
if (et && et->isProfile("blender")) {
et->setData("type", &(lamp->type));
et->setData("flag", &(lamp->flag));
@@ -1057,7 +1061,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
att2 = quadatt;
d = sqrt(1.0f / quadatt);
}
// linear light
/* linear light */
else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
att1 = linatt;
d = (1.0f / linatt);
@@ -1066,7 +1070,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
att1 = 1.0f;
}
else {
// assuming point light (const att = 1.0);
/* assuming point light (const att = 1.0); */
att1 = 1.0f;
}
@@ -1077,7 +1081,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
switch (light->getLightType()) {
case COLLADAFW::Light::AMBIENT_LIGHT: {
lamp->type = LA_SUN; //TODO needs more thoughts
lamp->type = LA_SUN; // TODO needs more thoughts
} break;
case COLLADAFW::Light::SPOT_LIGHT: {
lamp->type = LA_SPOT;
@@ -1115,36 +1119,37 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
return true;
}
// this function is called only for animations that pass COLLADAFW::validate
/* this function is called only for animations that pass COLLADAFW::validate */
bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
{
if (mImportStage == Fetching_Controller_data)
return true;
// return true;
/* return true; */
return anim_importer.write_animation(anim);
}
// called on post-process stage after writeVisualScenes
/* called on post-process stage after writeVisualScenes */
bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
{
if (mImportStage == Fetching_Controller_data)
return true;
// return true;
/* return true; */
return anim_importer.write_animation_list(animationList);
}
#if WITH_OPENCOLLADA_ANIMATION_CLIP
// Since opencollada 1.6.68
// called on post-process stage after writeVisualScenes
/* Since opencollada 1.6.68
* called on post-process stage after writeVisualScenes */
bool DocumentImporter::writeAnimationClip(const COLLADAFW::AnimationClip *animationClip)
{
if (mImportStage == Fetching_Controller_data)
return true;
return true;
//return animation_clip_importer.write_animation_clip(animationClip); // TODO: implement import of AnimationClips
/* TODO: implement import of AnimationClips */
// return animation_clip_importer.write_animation_clip(animationClip);
}
#endif
@@ -1155,7 +1160,7 @@ bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerDa
return armature_importer.write_skin_controller_data(skin);
}
// this is called on postprocess, before writeVisualScenes
/* this is called on postprocess, before writeVisualScenes */
bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
{
if (mImportStage == Fetching_Controller_data)
@@ -1200,6 +1205,6 @@ bool DocumentImporter::is_armature(COLLADAFW::Node *node)
}
}
//no child is JOINT
/* no child is JOINT */
return false;
}

View File

@@ -81,7 +81,8 @@ class DocumentImporter : COLLADAFW::IWriter {
/** This is the method called. The writer hast to prepare to receive data.*/
void start();
/** This method is called after the last write* method. No other methods will be called after this.*/
/** This method is called after the last write* method. No other methods will be called after
* this.*/
void finish();
bool writeGlobalAsset(const COLLADAFW::FileInfo *);

View File

@@ -92,8 +92,8 @@ void EffectsExporter::exportEffects(bContext *C, Scene *sce)
void EffectsExporter::set_shader_type(COLLADASW::EffectProfile &ep, Material *ma)
{
ep.setShaderType(
COLLADASW::EffectProfile::LAMBERT); //XXX check if BLINN and PHONG can be supported as well
/* XXX check if BLINN and PHONG can be supported as well */
ep.setShaderType(COLLADASW::EffectProfile::LAMBERT);
}
void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *ma)
@@ -268,7 +268,7 @@ COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
COLLADASW::Texture texture(translate_id(id_name(ima)));
texture.setTexcoord(uv_layer_name);
//texture.setSurface(*surface);
// texture.setSurface(*surface);
texture.setSampler(*sampler);
COLLADASW::ColorOrTexture cot(texture);

View File

@@ -35,9 +35,9 @@ ExtraHandler::~ExtraHandler()
bool ExtraHandler::elementBegin(const char *elementName, const char **attributes)
{
// \todo attribute handling for profile tags
/* \todo attribute handling for profile tags */
currentElement = std::string(elementName);
//addToSidTree(attributes[0], attributes[1]);
// addToSidTree(attributes[0], attributes[1]);
return true;
}
@@ -72,7 +72,11 @@ bool ExtraHandler::parseElement(const char *profileName,
COLLADAFW::Object *object)
{
if (BLI_strcaseeq(profileName, "blender")) {
//printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
#if 0
printf("In parseElement for supported profile %s for id %s\n",
profileName,
uniqueId.toAscii().c_str());
#endif
currentUid = uniqueId;
ExtraTags *et = dimp->getExtraTags(uniqueId);
if (!et) {
@@ -82,6 +86,7 @@ bool ExtraHandler::parseElement(const char *profileName,
currentExtraTags = et;
return true;
}
//printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
// printf("In parseElement for unsupported profile %s for id %s\n", profileName,
// uniqueId.toAscii().c_str());
return false;
}

View File

@@ -50,7 +50,8 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler {
/** 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. */
/** 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,
const COLLADAFW::UniqueId &uniqueId,

View File

@@ -66,7 +66,7 @@ void GeometryExporter::operator()(Object *ob)
std::vector<Normal> nor;
std::vector<BCPolygonNormalsIndices> norind;
// Skip if linked geometry was already exported from another reference
/* Skip if linked geometry was already exported from another reference */
if (use_instantiation && exportedGeometry.find(geom_id) != exportedGeometry.end()) {
return;
}
@@ -80,18 +80,18 @@ void GeometryExporter::operator()(Object *ob)
create_normals(nor, norind, me);
// openMesh(geoId, geoName, meshId)
/* openMesh(geoId, geoName, meshId) */
openMesh(geom_id, geom_name);
// writes <source> for vertex coords
/* writes <source> for vertex coords */
createVertsSource(geom_id, me);
// writes <source> for normal coords
/* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
// writes <source> for uv coords if mesh has uv coords
/* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
createTexcoordsSource(geom_id, me);
}
@@ -99,7 +99,7 @@ void GeometryExporter::operator()(Object *ob)
if (has_color) {
createVertexColorSource(geom_id, me);
}
// <vertices>
/* <vertices> */
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
@@ -111,9 +111,9 @@ void GeometryExporter::operator()(Object *ob)
createLooseEdgeList(ob, me, geom_id);
// Only create Polylists if number of faces > 0
/* Only create Polylists if number of faces > 0 */
if (me->totface > 0) {
// XXX slow
/* XXX slow */
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
create_mesh_primitive_list(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -137,7 +137,7 @@ void GeometryExporter::operator()(Object *ob)
Key *key = BKE_key_from_object(ob);
if (key) {
KeyBlock *kb = (KeyBlock *)key->block.first;
//skip the basis
/* skip the basis */
kb = kb->next;
for (; kb; kb = kb->next) {
BKE_keyblock_convert_to_mesh(kb, me);
@@ -170,15 +170,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
/* writes <source> for vertex coords */
createVertsSource(geom_id, me);
// writes <source> for normal coords
/* writes <source> for normal coords */
createNormalsSource(geom_id, me, nor);
bool has_uvs = (bool)CustomData_has_layer(&me->ldata, CD_MLOOPUV);
// writes <source> for uv coords if mesh has uv coords
/* writes <source> for uv coords if mesh has uv coords */
if (has_uvs) {
createTexcoordsSource(geom_id, me);
}
@@ -187,7 +187,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
createVertexColorSource(geom_id, me);
}
// <vertices>
/* <vertices> */
COLLADASW::Vertices verts(mSW);
verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
@@ -197,9 +197,9 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
input_list.push_back(input);
verts.add();
//createLooseEdgeList(ob, me, geom_id, norind);
// createLooseEdgeList(ob, me, geom_id, norind);
// XXX slow
/* XXX slow */
if (ob->totcol) {
for (int a = 0; a < ob->totcol; a++) {
create_mesh_primitive_list(a, has_uvs, has_color, ob, me, geom_id, norind);
@@ -228,8 +228,8 @@ void GeometryExporter::createLooseEdgeList(Object *ob, Mesh *me, std::string &ge
std::vector<unsigned int> edge_list;
int index;
// Find all loose edges in Mesh
// and save vertex indices in edge_list
/* Find all loose edges in Mesh
* and save vertex indices in edge_list */
for (index = 0; index < totedges; index++) {
MEdge *edge = &medges[index];
@@ -241,14 +241,14 @@ void GeometryExporter::createLooseEdgeList(Object *ob, Mesh *me, std::string &ge
}
if (edges_in_linelist > 0) {
// Create the list of loose edges
/* Create the list of loose edges */
COLLADASW::Lines lines(mSW);
lines.setCount(edges_in_linelist);
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);
@@ -268,12 +268,12 @@ static void prepareToAppendValues(bool is_triangulated,
COLLADASW::PrimitivesBase &primitive_list,
std::vector<unsigned long> &vcount_list)
{
// performs the actual writing
/* performs the actual writing */
if (is_triangulated) {
((COLLADASW::Triangles &)primitive_list).prepareToAppendValues();
}
else {
// sets <vcount>
/* sets <vcount> */
primitive_list.setVCountList(vcount_list);
((COLLADASW::Polylist &)primitive_list).prepareToAppendValues();
}
@@ -314,7 +314,7 @@ static bool collect_vertex_counts_per_poly(Mesh *me,
bool is_triangulated = true;
int i;
// Expecting that p->mat_nr is always 0 if the mesh has no materials assigned
/* Expecting that p->mat_nr is always 0 if the mesh has no materials assigned */
for (i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
if (p->mat_nr == material_index) {
@@ -334,7 +334,7 @@ std::string GeometryExporter::makeVertexColorSourceId(std::string &geom_id, char
return result;
}
// powerful because it handles both cases when there is material and when there's not
/* powerful because it handles both cases when there is material and when there's not */
void GeometryExporter::create_mesh_primitive_list(short material_index,
bool has_uvs,
bool has_color,
@@ -353,7 +353,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
bool is_triangulated = collect_vertex_counts_per_poly(me, material_index, vcount_list);
int polygon_count = vcount_list.size();
// no faces using this material
/* no faces using this material */
if (polygon_count == 0) {
fprintf(
stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index);
@@ -363,10 +363,10 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
COLLADASW::PrimitivesBase *primitive_list = create_primitive_list(is_triangulated, mSW);
// sets count attribute in <polylist>
/* sets count attribute in <polylist> */
primitive_list->setCount(polygon_count);
// sets material name
/* sets material name */
if (ma) {
std::string material_id = get_material_id(ma);
std::ostringstream ostr;
@@ -385,7 +385,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
til.push_back(vertex_input);
til.push_back(normals_input);
// if mesh has uv coords writes <input> for TEXCOORD
/* if mesh has uv coords writes <input> for TEXCOORD */
int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (int i = 0; i < num_layers; i++) {
@@ -397,7 +397,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
COLLADASW::InputSemantic::TEXCOORD,
makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings->active_uv_only)),
2, // this is only until we have optimized UV sets
(this->export_settings->active_uv_only) ? 0 : layer_index - 1 //set (0,1,2,...)
(this->export_settings->active_uv_only) ? 0 : layer_index - 1 /* set (0,1,2,...) */
);
til.push_back(texcoord_input);
}
@@ -419,10 +419,10 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
}
}
// performs the actual writing
/* performs the actual writing */
prepareToAppendValues(is_triangulated, *primitive_list, vcount_list);
// <p>
/* <p> */
int texindex = 0;
for (int i = 0; i < totpolys; i++) {
MPoly *p = &mpolys[i];
@@ -449,7 +449,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
finish_and_delete_primitive_List(is_triangulated, primitive_list);
}
// creates <source> for positions
/* creates <source> for positions */
void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
{
#if 0
@@ -473,7 +473,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
/* main function, it creates <source id = "">, <float_array id = ""
* count = ""> */
source.prepareToAppendValues();
//appends data to <float_array>
/* appends data to <float_array> */
int i = 0;
for (i = 0; i < totverts; i++) {
source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
@@ -542,7 +542,7 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string &geom_id,
return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix;
}
//creates <source> for texcoords
/* creates <source> for texcoords */
void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
{
@@ -552,8 +552,8 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
// write <source> for each layer
// each <source> will get id like meshName + "map-channel-1"
/* write <source> for each layer
* each <source> will get id like meshName + "map-channel-1" */
int active_uv_index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV);
for (int a = 0; a < num_layers; a++) {
int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, a);
@@ -593,7 +593,7 @@ bool operator<(const Normal &a, const Normal &b)
return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z < b.z)));
}
//creates <source> for normals
/* creates <source> for normals */
void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor)
{
#if 0
@@ -645,7 +645,7 @@ void GeometryExporter::create_normals(std::vector<Normal> &normals,
bool use_vertex_normals = use_custom_normals || mpoly->flag & ME_SMOOTH;
if (!use_vertex_normals) {
// For flat faces use face normal as vertex normal:
/* For flat faces use face normal as vertex normal: */
float vector[3];
BKE_mesh_calc_poly_normal(mpoly, mloops + mpoly->loopstart, verts, vector);

View File

@@ -54,7 +54,7 @@ class Normal {
bool operator<(const Normal &, const Normal &);
// TODO: optimize UV sets by making indexed list with duplicates removed
/* TODO: optimize UV sets by making indexed list with duplicates removed */
class GeometryExporter : COLLADASW::LibraryGeometries {
struct Face {
unsigned int v1, v2, v3, v4;
@@ -63,7 +63,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
Normal n;
public:
// TODO: optimize UV sets by making indexed list with duplicates removed
/* TODO: optimize UV sets by making indexed list with duplicates removed */
GeometryExporter(BlenderContext &blender_context,
COLLADASW::StreamWriter *sw,
const ExportSettings *export_settings)
@@ -79,7 +79,7 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
void createLooseEdgeList(Object *ob, Mesh *me, std::string &geom_id);
// powerful because it handles both cases when there is material and when there's not
/* powerful because it handles both cases when there is material and when there's not */
void create_mesh_primitive_list(short material_index,
bool has_uvs,
bool has_color,
@@ -88,18 +88,18 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
std::string &geom_id,
std::vector<BCPolygonNormalsIndices> &norind);
// creates <source> for positions
/* creates <source> for positions */
void createVertsSource(std::string geom_id, Mesh *me);
void createVertexColorSource(std::string geom_id, Mesh *me);
std::string makeTexcoordSourceId(std::string &geom_id, int layer_index, bool is_single_layer);
//creates <source> for texcoords
/* creates <source> for texcoords */
void createTexcoordsSource(std::string geom_id, Mesh *me);
void createTesselatedTexcoordsSource(std::string geom_id, Mesh *me);
//creates <source> for normals
/* creates <source> for normals */
void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal> &nor);
void create_normals(std::vector<Normal> &nor,
@@ -128,8 +128,8 @@ class GeometryExporter : COLLADASW::LibraryGeometries {
};
struct GeometryFunctor {
// f should have
// void operator()(Object *ob)
/* f should have
* void operator()(Object *ob) */
template<class Functor>
void forEachMeshObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{

View File

@@ -75,27 +75,27 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
char export_dir[FILE_MAX];
char export_file[FILE_MAX];
// Destination folder for exported assets
/* Destination folder for exported assets */
BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir));
if (is_generated || is_dirty || use_copies || is_packed) {
// make absolute destination path
/* make absolute destination path */
BLI_strncpy(export_file, name.c_str(), sizeof(export_file));
BKE_image_path_ensure_ext_from_imformat(export_file, &imageFormat);
BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file);
// make dest directory if it doesn't exist
/* make dest directory if it doesn't exist */
BLI_make_existing_file(export_path);
}
if (is_generated || is_dirty || is_packed) {
// This image in its current state only exists in Blender memory.
// So we have to export it. The export will keep the image state intact,
// so the exported file will not be associated with the image.
/* This image in its current state only exists in Blender memory.
* So we have to export it. The export will keep the image state intact,
* so the exported file will not be associated with the image. */
if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) {
fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path);
@@ -105,18 +105,18 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
}
else {
// make absolute source path
/* make absolute source path */
BLI_strncpy(source_path, image->name, sizeof(source_path));
BLI_path_abs(source_path, BKE_main_blendfile_path_from_global());
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.
// Note: If an image is already located in the export folder,
// then skip the copy (as it would result in a file copy error).
/* This image is already located on the file system.
* But we want to create copies here.
* To move images into the same export directory.
* Note: If an image is already located in the export folder,
* then skip the copy (as it would result in a file copy error). */
if (BLI_path_cmp(source_path, export_path) != 0) {
if (BLI_copy(source_path, export_path) != 0) {
@@ -132,17 +132,18 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
}
else {
// Do not make any copies, but use the source path directly as reference
// to the original image
/* Do not make any copies, but use the source path directly as reference
* to the original image */
BLI_strncpy(export_path, source_path, sizeof(export_path));
}
}
COLLADASW::Image img(
COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)),
translated_name,
translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */
/* Set name also to mNameNC.
* This helps other viewers import files exported from Blender better. */
COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)),
translated_name,
translated_name);
img.add(mSW);
fprintf(stdout, "Collada export: Added image: %s\n", export_file);

View File

@@ -266,9 +266,8 @@ void MeshImporter::print_index_list(COLLADAFW::IndexList &index_list)
}
#endif
bool MeshImporter::is_nice_mesh(
COLLADAFW::Mesh *
mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
/* checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans */
bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
{
COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();

View File

@@ -47,7 +47,7 @@ extern "C" {
#include "DNA_scene_types.h"
}
// only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid
/* only for ArmatureImporter to "see" MeshImporter::get_object_by_geom_uid */
class MeshImporterBase {
public:
virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) = 0;
@@ -86,22 +86,24 @@ class MeshImporter : public MeshImporterBase {
ArmatureImporter *armature_importer;
std::map<std::string, std::string> mesh_geom_map; // needed for correct shape key naming
std::map<COLLADAFW::UniqueId, Mesh *> uid_mesh_map; // geometry unique id-to-mesh map
std::map<COLLADAFW::UniqueId, Object *> uid_object_map; // geom uid-to-object
std::vector<Object *> imported_objects; // list of imported objects
std::map<std::string, std::string> mesh_geom_map; /* needed for correct shape key naming */
std::map<COLLADAFW::UniqueId, Mesh *> uid_mesh_map; /* geometry unique id-to-mesh map */
std::map<COLLADAFW::UniqueId, Object *> uid_object_map; /* geom uid-to-object */
std::vector<Object *> imported_objects; /* list of imported objects */
// this structure is used to assign material indices to polygons
// it holds a portion of Mesh faces and corresponds to a DAE primitive list (<triangles>, <polylist>, etc.)
/* this structure is used to assign material indices to polygons
* it holds a portion of Mesh faces and corresponds to a DAE primitive list
* (<triangles>, <polylist>, etc.) */
struct Primitive {
MPoly *mpoly;
unsigned int totpoly;
};
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
/* crazy name! */
std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map;
/* < materials that have already been mapped to a geometry.
* A pair/of geom uid and mat uid, one geometry can have several materials */
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom;
bool set_poly_indices(
MPoly *mpoly, MLoop *mloop, int loop_index, unsigned int *indices, int loop_count);
@@ -137,7 +139,7 @@ class MeshImporter : public MeshImporterBase {
void allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me);
// TODO: import uv set names
/* TODO: import uv set names */
void read_polys(COLLADAFW::Mesh *mesh, Mesh *me);
void read_lines(COLLADAFW::Mesh *mesh, Mesh *me);
unsigned int get_vertex_count(COLLADAFW::Polygons *mp, int index);
@@ -172,7 +174,7 @@ class MeshImporter : public MeshImporterBase {
bool isController,
std::map<COLLADAFW::UniqueId, Material *> &uid_material_map);
// create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
/* create a mesh storing a pointer in a map so it can be retrieved later by geometry UID */
bool write_geometry(const COLLADAFW::Geometry *geom);
std::string *get_geometry_name(const std::string &mesh_name);
};

View File

@@ -32,7 +32,7 @@ void SceneExporter::exportScene()
{
Scene *scene = blender_context.get_scene();
// <library_visual_scenes> <visual_scene>
/* <library_visual_scenes> <visual_scene> */
std::string name = id_name(scene);
openVisualScene(translate_id(name), encode_xml(name));
exportHierarchy();
@@ -45,13 +45,13 @@ void SceneExporter::exportHierarchy()
LinkNode *node;
std::vector<Object *> base_objects;
// Ensure all objects in the export_set are marked
/* Ensure all objects in the export_set are marked */
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
ob->id.tag |= LIB_TAG_DOIT;
}
// Now find all exportable base objects (highest in export hierarchy)
/* Now find all exportable base objects (highest in export hierarchy) */
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
if (bc_is_base_node(this->export_settings->export_set, ob)) {
@@ -68,7 +68,7 @@ void SceneExporter::exportHierarchy()
}
}
// And now export the base objects:
/* And now export the base objects: */
for (int index = 0; index < base_objects.size(); index++) {
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
@@ -103,7 +103,7 @@ void SceneExporter::writeNodes(Object *ob)
bc_get_children(child_objects, ob, view_layer);
bool can_export = bc_is_in_Export_set(this->export_settings->export_set, ob, view_layer);
// Add associated armature first if available
/* Add associated armature first if available */
bool armature_exported = false;
Object *ob_arm = bc_get_assigned_armature(ob);
@@ -125,7 +125,7 @@ void SceneExporter::writeNodes(Object *ob)
colladaNode.start();
if (ob->type == OB_MESH && armature_exported) {
// for skinned mesh we write obmat in <bind_shape_matrix>
/* for skinned mesh we write obmat in <bind_shape_matrix> */
TransformWriter::add_node_transform_identity(colladaNode);
}
else {
@@ -135,7 +135,7 @@ void SceneExporter::writeNodes(Object *ob)
this->export_settings->limit_precision);
}
// <instance_geometry>
/* <instance_geometry> */
if (ob->type == OB_MESH) {
bool instance_controller_created = false;
if (armature_exported) {
@@ -153,27 +153,27 @@ void SceneExporter::writeNodes(Object *ob)
}
}
// <instance_controller>
/* <instance_controller> */
else if (ob->type == OB_ARMATURE) {
arm_exporter->add_armature_bones(ob, view_layer, this, child_objects);
}
// <instance_camera>
/* <instance_camera> */
else if (ob->type == OB_CAMERA) {
COLLADASW::InstanceCamera instCam(
mSW, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_camera_id(ob)));
instCam.add();
}
// <instance_light>
/* <instance_light> */
else if (ob->type == OB_LAMP) {
COLLADASW::InstanceLight instLa(
mSW, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_light_id(ob)));
instLa.add();
}
// empty object
else if (ob->type == OB_EMPTY) { // TODO: handle groups (OB_DUPLICOLLECTION
/* empty object */
else if (ob->type == OB_EMPTY) { /* TODO: handle groups (OB_DUPLICOLLECTION */
if ((ob->transflag & OB_DUPLICOLLECTION) == OB_DUPLICOLLECTION && ob->instance_collection) {
Collection *collection = ob->instance_collection;
/* printf("group detected '%s'\n", group->id.name + 2); */
@@ -206,9 +206,9 @@ void SceneExporter::writeNodes(Object *ob)
colladaNode.addExtraTechniqueChildParameter(
"blender", con_tag, "lin_error", con->lin_error);
//not ideal: add the target object name as another parameter.
//No real mapping in the .dae
//Need support for multiple target objects also.
/* 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) {

View File

@@ -45,16 +45,16 @@
#include "SkinInfo.h"
#include "collada_utils.h"
// use name, or fall back to original id if name not present (name is optional)
/* use name, or fall back to original id if name not present (name is optional) */
template<class T> static const char *bc_get_joint_name(T *node)
{
const std::string &id = node->getName();
return id.size() ? id.c_str() : node->getOriginalId().c_str();
}
// This is used to store data passed in write_controller_data.
// Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
// so that arrays don't get freed until we free them explicitly.
/* This is used to store data passed in write_controller_data.
* Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
* so that arrays don't get freed until we free them explicitly. */
SkinInfo::SkinInfo()
{
/* pass */
@@ -79,7 +79,7 @@ SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), pa
{
}
// nobody owns the data after this, so it should be freed manually with releaseMemory
/* nobody owns the data after this, so it should be freed manually with releaseMemory */
template<class T> void SkinInfo::transfer_array_data(T &src, T &dest)
{
dest.setData(src.getData(), src.getCount());
@@ -87,7 +87,7 @@ template<class T> void SkinInfo::transfer_array_data(T &src, T &dest)
dest.yieldOwnerShip();
}
// when src is const we cannot src.yieldOwnerShip, this is used by copy constructor
/* when src is const we cannot src.yieldOwnerShip, this is used by copy constructor */
void SkinInfo::transfer_int_array_data_const(const COLLADAFW::IntValuesArray &src,
COLLADAFW::IntValuesArray &dest)
{
@@ -109,7 +109,7 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *
transfer_array_data((COLLADAFW::IntValuesArray &)skin->getJointIndices(), joint_indices);
// transfer_array_data(skin->getWeights(), weights);
// cannot transfer data for FloatOrDoubleArray, copy values manually
/* cannot transfer data for FloatOrDoubleArray, copy values manually */
const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
for (unsigned int i = 0; i < weight.getValuesCount(); i++)
weights.push_back(bc_get_float_value(weight, i));
@@ -125,9 +125,9 @@ void SkinInfo::free()
// weights.releaseMemory();
}
// using inverse bind matrices to construct armature
// it is safe to invert them to get the original matrices
// because if they are inverse matrices, they can be inverted
/* using inverse bind matrices to construct armature
* it is safe to invert them to get the original matrices
* because if they are inverse matrices, they can be inverted */
void SkinInfo::add_joint(const COLLADABU::Math::Matrix4 &matrix)
{
JointData jd;
@@ -139,21 +139,21 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController *co)
{
controller_uid = co->getUniqueId();
// fill in joint UIDs
/* fill in joint UIDs */
const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
for (unsigned int i = 0; i < joint_uids.getCount(); i++) {
joint_data[i].joint_uid = joint_uids[i];
// // store armature pointer
/* store armature pointer */
// JointData& jd = joint_index_to_joint_info_map[i];
// jd.ob_arm = ob_arm;
// now we'll be able to get inv bind matrix from joint id
/* now we'll be able to get inv bind matrix from joint id */
// joint_id_to_joint_index_map[joint_ids[i]] = i;
}
}
// called from write_controller
/* called from write_controller */
Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer)
{
ob_arm = bc_add_object(bmain, scene, view_layer, OB_ARMATURE, NULL);
@@ -193,11 +193,11 @@ const COLLADAFW::UniqueId &SkinInfo::get_controller_uid()
return 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
/* 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 */
bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node)
{
const COLLADAFW::UniqueId &uid = node->getUniqueId();
@@ -248,17 +248,17 @@ void SkinInfo::link_armature(bContext *C,
amd->deformflag = ARM_DEF_VGROUP;
// create all vertex groups
/* create all vertex groups */
std::vector<JointData>::iterator it;
int joint_index;
for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
const char *name = "Group";
// skip joints that have invalid UID
/* skip joints that have invalid UID */
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID)
continue;
// name group by joint node name
/* 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]);
@@ -267,16 +267,16 @@ void SkinInfo::link_armature(bContext *C,
BKE_object_defgroup_add_name(ob, name);
}
// <vcount> - number of joints per vertex - joints_per_vertex
// <v> - [[bone index, weight index] * joints per vertex] * vertices - weight indices
// ^ bone index can be -1 meaning weight toward bind shape, how to express this in Blender?
// for each vertex in weight indices
// for each bone index in vertex
// add vertex to group at group index
// treat group index -1 specially
// get def group by index with BLI_findlink
/* <vcount> - number of joints per vertex - joints_per_vertex
* <v> - [[bone index, weight index] * joints per vertex] * vertices - weight indices
* ^ bone index can be -1 meaning weight toward bind shape, how to express this in Blender?
*
* for each vertex in weight indices
* for each bone index in vertex
* add vertex to group at group index
* treat group index -1 specially
*
* get def group by index with BLI_findlink */
for (unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
@@ -284,7 +284,7 @@ void SkinInfo::link_armature(bContext *C,
for (; weight < limit; weight++) {
int joint = joint_indices[weight], joint_weight = weight_indices[weight];
// -1 means "weight towards the bind shape", we just don't assign it to any group
/* -1 means "weight towards the bind shape", we just don't assign it to any group */
if (joint != -1) {
bDeformGroup *def = (bDeformGroup *)BLI_findlink(&ob->defbase, joint);
@@ -314,17 +314,17 @@ void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joint
std::vector<COLLADAFW::Node *> &result)
{
std::vector<COLLADAFW::Node *>::const_iterator it;
// for each root_joint
/* for each root_joint */
for (it = root_joints.begin(); it != root_joints.end(); it++) {
COLLADAFW::Node *root = *it;
std::vector<JointData>::iterator ji;
//for each joint_data in this skin
/* for each joint_data in this skin */
for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
//get joint node from joint map
/* get joint node from joint map */
COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
//find if joint node is in the tree belonging to the root_joint
/* find if joint node is in the tree belonging to the root_joint */
if (find_node_in_tree(joint, root)) {
if (std::find(result.begin(), result.end(), root) == result.end())
result.push_back(root);

View File

@@ -35,7 +35,7 @@
#include "collada_internal.h"
//struct Object;
// struct Object;
class TransformReader {
protected:

View File

@@ -98,7 +98,8 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
add_transform(node, loc, rot, scale);
#endif
/* Export the local Matrix (relative to the object parent, be it an object, bone or vertex(-tices)) */
/* Export the local Matrix (relative to the object parent,
* be it an object, bone or vertex(-tices)). */
float f_obmat[4][4];
BKE_object_matrix_local_get(ob, f_obmat);

View File

@@ -63,7 +63,7 @@ extern "C" {
#include "MEM_guardedalloc.h"
#include "WM_api.h" // XXX hrm, see if we can do without this
#include "WM_api.h" /* XXX hrm, see if we can do without this */
#include "WM_types.h"
#include "bmesh.h"
@@ -91,7 +91,7 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned in
return array.getDoubleValues()->getData()[index];
}
// copied from /editors/object/object_relations.c
/* copied from /editors/object/object_relations.c */
int bc_test_parent_loop(Object *par, Object *ob)
{
/* test if 'ob' is a parent somewhere in par's parents */
@@ -146,8 +146,8 @@ bool bc_validateConstraints(bConstraint *con)
return true;
}
// a shortened version of parent_set_exec()
// if is_parent_space is true then ob->obmat will be multiplied by par->obmat before parenting
/* a shortened version of parent_set_exec()
* if is_parent_space is true then ob->obmat will be multiplied by par->obmat before parenting */
int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
{
Object workob;
@@ -164,18 +164,18 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
if (is_parent_space) {
float mat[4][4];
// calc par->obmat
/* calc par->obmat */
BKE_object_where_is_calc(depsgraph, sce, par);
// move child obmat into world space
/* move child obmat into world 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)
/* apply child obmat (i.e. decompose it into rot/loc/size) */
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
// compute parentinv
/* compute parentinv */
BKE_object_workob_calc_parent(depsgraph, sce, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
@@ -381,7 +381,7 @@ void bc_set_mark(Object *ob)
ob->id.tag |= LIB_TAG_DOIT;
}
// Use bubble sort algorithm for sorting the export set
/* Use bubble sort algorithm for sorting the export set */
void bc_bubble_sort_by_Object_name(LinkNode *export_set)
{
bool sorted = false;
@@ -520,21 +520,22 @@ void bc_rotate_from_reference_quat(float quat_to[4], float quat_from[4], float m
float mat_from[4][4];
quat_to_mat4(mat_from, quat_from);
// Calculate the difference matrix matd between mat_from and mat_to
/* Calculate the difference matrix matd between mat_from and mat_to */
invert_m4_m4(mati, mat_from);
mul_m4_m4m4(matd, mati, mat_to);
mat4_to_quat(qd, matd);
mul_qt_qtqt(quat_to, qd, quat_from); // rot is the final rotation corresponding to mat_to
mul_qt_qtqt(quat_to, qd, quat_from); /* rot is the final rotation corresponding to mat_to */
}
void bc_triangulate_mesh(Mesh *me)
{
bool use_beauty = false;
bool tag_only = false;
int quad_method =
MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */
/* XXX: The triangulation method selection could be offered in the UI. */
int quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE;
const struct BMeshCreateParams bm_create_params = {0};
BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_create_params);
@@ -774,8 +775,8 @@ std::string BoneExtended::get_bone_layers(int bitfield)
int BoneExtended::get_bone_layers()
{
return (bone_layers == 0) ? 1 :
bone_layers; // ensure that the bone is in at least one bone layer!
/* ensure that the bone is in at least one bone layer! */
return (bone_layers == 0) ? 1 : bone_layers;
}
void BoneExtended::set_use_connect(int use_connect)
@@ -983,7 +984,7 @@ bool bc_is_animated(BCMatrixSampleMap &values)
static float MIN_DISTANCE = 0.00001;
if (values.size() < 2)
return false; // need at least 2 entries to be not flat
return false; /* need at least 2 entries to be not flat */
BCMatrixSampleMap::iterator it;
const BCMatrix *refmat = NULL;
@@ -1009,7 +1010,7 @@ bool bc_has_animations(Object *ob)
(bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first))
return true;
//Check Material Effect parameter animations.
/* Check Material Effect parameter animations. */
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
if (!ma)
@@ -1254,7 +1255,7 @@ bNode *bc_add_node(bContext *C, bNodeTree *ntree, int node_type, int locx, int l
}
#if 0
// experimental, probably not used
/* experimental, probably not used */
static bNodeSocket *bc_group_add_input_socket(bNodeTree *ntree,
bNode *to_node,
int to_index,
@@ -1337,7 +1338,7 @@ void bc_add_default_shader(bContext *C, Material *ma)
bc_node_add_link(ntree, nmap["transparent"], 0, nmap["mix"], 2);
bc_node_add_link(ntree, nmap["mix"], 0, nmap["out"], 0);
// experimental, probably not used.
/* experimental, probably not used. */
bc_make_group(C, ntree, nmap);
#else
nmap["main"] = bc_add_node(C, ntree, SH_NODE_BSDF_PRINCIPLED, 0, 300);
@@ -1366,7 +1367,7 @@ COLLADASW::ColorOrTexture bc_get_base_color(bNode *shader)
return bc_get_cot(col[0], col[1], col[2], col[3]);
}
else {
return bc_get_cot(0.8, 0.8, 0.8, 1.0); //default white
return bc_get_cot(0.8, 0.8, 0.8, 1.0); /* default white */
}
}
@@ -1383,7 +1384,7 @@ bool bc_get_reflectivity(bNode *shader, double &reflectivity)
double bc_get_reflectivity(Material *ma)
{
double reflectivity = ma->spec; // fallback if no socket found
double reflectivity = ma->spec; /* fallback if no socket found */
bNode *master_shader = bc_get_master_shader(ma);
if (ma->use_nodes && master_shader) {
bc_get_reflectivity(master_shader, reflectivity);