[Bf-blender-cvs] [2b158861a3a] blender2.8: merged collada rework from master into blender 2.8
Gaia Clary
noreply at git.blender.org
Sun Feb 25 00:11:24 CET 2018
Commit: 2b158861a3a516dd8f4dac73f8984230f02bc9de
Author: Gaia Clary
Date: Sun Feb 25 00:06:41 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB2b158861a3a516dd8f4dac73f8984230f02bc9de
merged collada rework from master into blender 2.8
===================================================================
===================================================================
diff --cc source/blender/collada/AnimationExporter.cpp
index cc772535e37,759fb1546c7..24e5ecb8d10
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@@ -756,14 -943,60 +944,60 @@@ void AnimationExporter::get_source_valu
}
}
+ // old function to keep compatibility for calls where offset and object are not needed
std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name)
{
- std::string source_id = anim_id + get_semantic_suffix(semantic);
+ return create_source_from_fcurve(semantic, fcu, anim_id, axis_name, NULL);
+ }
- //bool is_angle = STREQ(fcu->rna_path, "rotation");
- bool is_angle = false;
+ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime)
+ {
+ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
- ListBase *conlist = get_active_constraints(ob);
++ ListBase *conlist = get_active_constraints(this->eval_ctx, ob);
+ bConstraint *con;
+ for (con = (bConstraint *)conlist->first; con; con = con->next) {
+ ListBase targets = { NULL, NULL };
- if (strstr(fcu->rna_path, "rotation") || strstr(fcu->rna_path,"spot_size")) is_angle = true;
+ const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
+
+ if (cti && cti->get_constraint_targets) {
+ bConstraintTarget *ct;
+ Object *obtar;
+ cti->get_constraint_targets(con, &targets);
+ for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) {
+ obtar = ct->tar;
+
+ if (obtar) {
+ BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(scene, obtar, ctime);
++ BKE_object_where_is_calc_time(this->eval_ctx, scene, obtar, ctime);
+ }
+ }
+
+ if (cti->flush_constraint_targets)
+ cti->flush_constraint_targets(con, &targets, 1);
+ }
+ }
- BKE_object_where_is_calc_time(scene, ob, ctime);
++ BKE_object_where_is_calc_time(this->eval_ctx, scene, ob, ctime);
+ }
+
+ /*
+ * ob is needed to aply parent inverse information to fcurve.
+ * TODO: Here we have to step over all keyframes for each object and for each fcurve.
+ * Instead of processing each fcurve one by one,
+ * step over the animation from keyframe to keyframe,
+ * then create adjusted fcurves (and entries) for all affected objects.
+ * Then we would need to step through the scene only once.
+ */
+ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name, Object *ob)
+ {
+ std::string source_id = anim_id + get_semantic_suffix(semantic);
+
+ bool is_angle = (strstr(fcu->rna_path, "rotation") || strstr(fcu->rna_path, "spot_size"));
+ bool is_euler = strstr(fcu->rna_path, "rotation_euler");
+ bool is_translation = strstr(fcu->rna_path, "location");
+ bool is_scale = strstr(fcu->rna_path, "scale");
+ bool is_tangent = false;
+ int offset_index = 0;
COLLADASW::FloatSourceF source(mSW);
source.setId(source_id);
@@@ -936,10 -1221,11 +1222,11 @@@ std::string AnimationExporter::create_4
int j = 0;
for (it = frames.begin(); it != frames.end(); it++) {
float mat[4][4], ipar[4][4];
+ float frame = *it;
- float ctime = BKE_scene_frame_get_from_ctime(scene, frame);
- CFRA = BKE_scene_frame_get_from_ctime(scene, frame);
- //BKE_scene_update_for_newframe(G.main->eval_ctx, G.main,scene,scene->lay);
+ float ctime = BKE_scene_frame_get_from_ctime(scene, *it);
+ CFRA = BKE_scene_frame_get_from_ctime(scene, *it);
+ //BKE_scene_graph_update_for_newframe(G.main->eval_ctx, depsgraph, G.main,scene);
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
if (bone) {
@@@ -981,7 -1268,11 +1269,10 @@@
}
else {
- calc_ob_mat_at_time(ob, ctime, mat);
+ BKE_scene_frame_set(scene, ctime);
+ Main *bmain = bc_get_main();
- EvaluationContext *ev_context = bc_get_evaluation_context();
- BKE_scene_update_for_newframe(ev_context, bmain, scene, scene->lay);
++ BKE_animsys_evaluate_all_animation(bmain, scene, ctime);
+ copy_m4_m4(mat, ob->obmat);
}
UnitConverter converter;
@@@ -1540,9 -1855,24 +1855,28 @@@ bool AnimationExporter::validateConstra
return valid;
}
- void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[][4])
+ #if 0
+ /*
+ * Needed for sampled animations.
+ * This function calculates the object matrix at a given time,
+ * also taking constraints into account.
+ *
+ * XXX: Why looking at the constraints here is necessary?
+ * Maybe this can be done better?
+ */
+ void AnimationExporter::calc_obmat_at_time(Object *ob, float ctime )
{
++<<<<<<< HEAD
+ ListBase *conlist = get_active_constraints(this->eval_ctx, ob);
++=======
+ BKE_scene_frame_set(scene, ctime);
+
+ Main *bmain = bc_get_main();
+ EvaluationContext *ev_context = bc_get_evaluation_context();
+ BKE_scene_update_for_newframe(ev_context, bmain, scene, scene->lay);
+
+ ListBase *conlist = get_active_constraints(ob);
++>>>>>>> master
bConstraint *con;
for (con = (bConstraint *)conlist->first; con; con = con->next) {
ListBase targets = {NULL, NULL};
@@@ -1566,7 -1896,7 +1900,12 @@@
cti->flush_constraint_targets(con, &targets, 1);
}
}
++<<<<<<< HEAD
+ BKE_object_where_is_calc_time(eval_ctx, scene, ob, ctime);
+ copy_m4_m4(mat, ob->obmat);
++=======
+ BKE_object_where_is_calc_time(scene, ob, ctime);
++>>>>>>> master
}
+ #endif
diff --cc source/blender/collada/AnimationExporter.h
index 5af5d884455,b26b0427f33..3bb510e51d6
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@@ -91,11 -90,13 +91,13 @@@ private
public:
AnimationExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
- COLLADASW::LibraryAnimations(sw), export_settings(export_settings)
- { this->sw = sw; }
-
+ COLLADASW::LibraryAnimations(sw),
+ export_settings(export_settings)
+ {
+ this->sw = sw;
+ }
- bool exportAnimations(Scene *sce);
+ bool exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce);
// called for each exported object
void operator() (Object *ob);
diff --cc source/blender/collada/ExportSettings.h
index 33a7527f383,3b0b5708c7c..0483449e513
--- a/source/blender/collada/ExportSettings.h
+++ b/source/blender/collada/ExportSettings.h
@@@ -40,9 -39,10 +40,10 @@@ public
bool include_armatures;
bool include_shapekeys;
bool deform_bones_only;
+ int sampling_rate;
bool active_uv_only;
- BC_export_texture_type export_texture_type;
+ bool include_material_textures;
bool use_texture_copies;
bool triangulate;
diff --cc source/blender/collada/collada.cpp
index 6c5fb0b33f3,718ae1d876b..286444882e4
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@@ -37,6 -37,6 +37,7 @@@ extern "C
{
#include "BKE_scene.h"
#include "BKE_context.h"
++#include "DEG_depsgraph.h"
/* make dummy file */
#include "BLI_fileops.h"
@@@ -80,9 -78,10 +79,10 @@@ int collada_export(bContext *C
int include_armatures,
int include_shapekeys,
int deform_bones_only,
+ int sampling_rate,
int active_uv_only,
- BC_export_texture_type export_texture_type,
+ int include_material_textures,
int use_texture_copies,
int triangulate,
@@@ -96,6 -95,6 +96,11 @@@
{
ExportSettings export_settings;
++ EvaluationContext eval_ctx;
++ CTX_data_eval_ctx(C, &eval_ctx);
++ Scene *sce = CTX_data_scene(C);
++ ViewLayer *view_layer = CTX_data_view_layer(C);
++
export_settings.filepath = (char *)filepath;
export_settings.apply_modifiers = apply_modifiers != 0;
@@@ -105,9 -104,10 +110,10 @@@
export_settings.include_armatures = include_armatures != 0;
export_settings.include_shapekeys = include_shapekeys != 0;
export_settings.deform_bones_only = deform_bones_only != 0;
+ export_settings.sampling_rate = sampling_rate;
export_settings.active_uv_only = active_uv_only != 0;
- export_settings.export_texture_type = export_texture_type;
+ export_settings.include_material_textures= include_material_textures != 0;
export_settings.use_texture_copies = use_texture_copies != 0;
export_settings.triangulate = triangulate != 0;
@@@ -124,7 -124,8 +130,9 @@@
if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : OB_SET_ALL;
- Scene *sce = CTX_data_scene(C);
- export_settings.export_set = BKE_object_relational_superset(sce, objectSet, (eObRelationTypes)includeFilter);
++
+ export_settings.export_set = BKE_object_relational_superset(view_layer, objectSet, (eObRelationTypes)includeFilter);
++
int export_count = BLI_linklist_count(export_settings.export_set);
if (export_count == 0) {
@@@ -141,7 -142,7 +149,7 @@@
}
DocumentExporter exporter(&export_settings);
- int status = exporter.exportCurrentScene(eval_ctx, sce);
- int status = exporter.exportCurrentScene(sce);
++ int status = exporter.exportCurrentScene(&eval_ctx, sce);
BLI_linklist_free(export_settings.export_set, NULL);
diff --cc source/blender/collada/collada.h
index eb3964f9cb7,e546e1f1056..89853b8849f
--- a/source/blender/collada/collada.h
+++ b/source/blender/collada/collada.h
@@@ -76,9 -77,10 +74,10 @@@ int collada_export(struct bContext *C
int include_armatures,
int include_shapekeys,
int deform_bones_only,
+ int sampling_rate,
int active_uv_only,
- BC_export_texture_type export_texture_type,
+ int include_material_textures,
int use_texture_copies,
int triangulate,
diff --cc source/blender/collada/collada_utils.cpp
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list