50 : export_settings(export_settings)
52 BCObjectSet::iterator it;
53 for (it = object_set.begin(); it != object_set.end(); ++it) {
61 BCAnimationObjectMap::iterator it;
62 for (it = objects.begin(); it != objects.end(); ++it) {
70 BlenderContext blender_context = export_settings.get_blender_context();
72 objects[ob] = animation;
74 initialize_keyframes(animation->
frame_set, ob);
75 initialize_curves(animation->
curve_map, ob);
82 initialize_curves(animation.
curve_map, ob);
92 sample_frames.clear();
94 if (sampling_rate < 1) {
102 for (frame_index = nearbyint(sfra); frame_index < efra; frame_index += sampling_rate) {
103 sample_frames.insert(frame_index);
106 if (frame_index >= efra && keyframe_at_end) {
107 sample_frames.insert(efra);
122 for (
int i = 0; i < fcu->
totvert; bezt++, i++) {
123 int frame_index = nearbyint(bezt->
vec[1][0]);
124 frameset.insert(frame_index);
130 void BCAnimationSampler::check_property_is_animated(
131 BCAnimation &animation,
float *ref,
float *val, std::string data_path,
int length)
133 for (
int array_index = 0; array_index <
length; array_index++) {
136 BCAnimationCurveMap::iterator it = animation.
curve_map.find(key);
144 void BCAnimationSampler::update_animation_curves(
BCAnimation &animation,
149 BCAnimationCurveMap::iterator it;
152 if (
curve->is_transform_curve()) {
156 curve->add_value_from_rna(frame);
161 BCSample &BCAnimationSampler::sample_object(
Object *ob,
int frame_index,
bool for_opensim)
163 BCSample &ob_sample = sample_data.
add(ob, frame_index);
185 BlenderContext blender_context = export_settings.get_blender_context();
186 int sampling_rate = export_settings.get_sampling_rate();
187 bool for_opensim = export_settings.get_open_sim();
188 bool keep_keyframes = export_settings.get_keep_keyframes();
194 BCFrameSet::iterator it;
199 for (
int frame_index = startframe; frame_index <= endframe; frame_index++) {
201 bool is_scene_sample_frame =
false;
202 bool needs_update =
true;
203 if (scene_sample_frames.find(frame_index) != scene_sample_frames.end()) {
205 needs_update =
false;
206 is_scene_sample_frame =
true;
209 bool needs_sampling = is_scene_sample_frame || keep_keyframes ||
211 if (!needs_sampling) {
215 BCAnimationObjectMap::iterator obit;
216 for (obit = objects.begin(); obit != objects.end(); ++obit) {
220 if (is_scene_sample_frame || object_keyframes.find(frame_index) != object_keyframes.end()) {
224 needs_update =
false;
228 update_animation_curves(*animation,
sample, ob, frame_index);
236 std::set<Object *> &animated_objects)
240 ListBase targets = {
nullptr,
nullptr};
255 if (animated_objects.find(obtar) != animated_objects.end()) {
266 std::set<Object *> &candidates)
271 std::set<Object *>::iterator it;
272 for (it = candidates.begin(); it != candidates.end(); ++it) {
276 animated_objects.insert(cob);
277 candidates.erase(cob);
282 }
while (found_more && !candidates.empty());
294 animated_objects.clear();
295 std::set<Object *> static_objects;
296 std::set<Object *> candidates;
302 animated_objects.insert(cob);
307 candidates.insert(cob);
353 int array_index =
curve.get_array_index();
354 const BC_animation_transform_type tm_type =
curve.get_transform_type();
356 BCFrameSampleMap::iterator it;
357 for (it = samples.begin(); it != samples.end(); ++it) {
358 const int frame_index = nearbyint(it->first);
364 int subindex =
curve.get_subindex();
366 if (subindex == -1) {
367 good =
sample->get_value(tm_type, array_index, &val);
370 good =
sample->get_value(tm_type, array_index, &val, subindex);
374 curve.add_value(val, frame_index);
378 curve.remove_unused_keyframes();
383 void BCAnimationSampler::generate_transform(
Object *ob,
387 BCAnimationCurveMap::const_iterator it = curves.find(key);
388 if (it == curves.end()) {
393 void BCAnimationSampler::generate_transforms(
Object *ob,
394 const std::string prep,
398 generate_transform(ob,
BCCurveKey(
type, prep +
"location", 0), curves);
399 generate_transform(ob,
BCCurveKey(
type, prep +
"location", 1), curves);
400 generate_transform(ob,
BCCurveKey(
type, prep +
"location", 2), curves);
401 generate_transform(ob,
BCCurveKey(
type, prep +
"rotation_euler", 0), curves);
402 generate_transform(ob,
BCCurveKey(
type, prep +
"rotation_euler", 1), curves);
403 generate_transform(ob,
BCCurveKey(
type, prep +
"rotation_euler", 2), curves);
404 generate_transform(ob,
BCCurveKey(
type, prep +
"scale", 0), curves);
405 generate_transform(ob,
BCCurveKey(
type, prep +
"scale", 1), curves);
406 generate_transform(ob,
BCCurveKey(
type, prep +
"scale", 2), curves);
411 std::string prep =
"pose.bones[\"" + std::string(bone->
name) +
"\"].";
415 generate_transforms(ob, child, curves);
424 void BCAnimationSampler::initialize_keyframes(
BCFrameSet &frameset,
Object *ob)
445 for (; fcu; fcu = fcu->
next) {
463 generate_transforms(ob,
EMPTY_STRING, object_type, curves);
467 generate_transforms(ob, root_bone, curves);
485 for (; fcu; fcu = fcu->
next) {
501 for (; fcu; fcu = fcu->
next) {
522 BCSampleMap::const_iterator it = sampleMap.find(ob);
523 if (it == sampleMap.end()) {
531 BCSampleMap::const_iterator it = sampleMap.find(ob);
532 if (it == sampleMap.end()) {
536 return &
sample->get_matrix();
542 BCSampleMap::const_iterator it = sampleMap.find(ob);
543 if (it == sampleMap.end()) {
555 return sampleMap.find(ob) != sampleMap.end();
570 return frame.
add(ob);
580 BCSampleFrameMap::iterator it = sample_frames.find(frame_index);
581 BCSampleFrame *frame = (it == sample_frames.end()) ?
nullptr : &it->second;
589 BCSampleFrameMap::const_iterator it;
590 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
591 frames.push_back(it->first);
593 return frames.size();
599 BCSampleFrameMap::const_iterator it;
600 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
603 frames.push_back(it->first);
606 return frames.size();
612 BCSampleFrameMap::const_iterator it;
613 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
616 frames.push_back(it->first);
619 return frames.size();
625 BCSampleFrameMap::const_iterator it;
626 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
630 samples[it->first] =
sample;
633 return samples.size();
639 BCSampleFrameMap::const_iterator it;
640 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
644 samples[it->first] = matrix;
647 return samples.size();
653 BCSampleFrameMap::const_iterator it;
654 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
658 samples[it->first] =
sample;
661 return samples.size();
@ BC_ANIMATION_TYPE_MATERIAL
@ BC_ANIMATION_TYPE_LIGHT
@ BC_ANIMATION_TYPE_OBJECT
@ BC_ANIMATION_TYPE_CAMERA
std::map< BCCurveKey, BCAnimationCurve * > BCAnimationCurveMap
std::vector< float > BCFrames
std::set< float > BCFrameSet
static BCAnimationCurveMap BCEmptyAnimationCurves
static bool is_object_keyframe(Object *ob, int frame_index)
static void add_keyframes_from(bAction *action, BCFrameSet &frameset)
static void get_sample_frames(BCFrameSet &sample_frames, int sampling_rate, bool keyframe_at_end, Scene *scene)
static std::string EMPTY_STRING
std::map< int, const BCSample * > BCFrameSampleMap
std::map< int, const BCMatrix * > BCMatrixSampleMap
Blender kernel action and pose functionality.
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
char * BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
struct ListBase * ED_object_constraint_active_list(struct Object *ob)
@ BC_ANIMATION_EXPORT_KEYS
@ BC_ANIMATION_EXPORT_SAMPLES
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void get_object_frames(BCFrames &frames, Object *ob)
static void find_depending_animated(std::set< Object * > &animated_objects, std::set< Object * > &candidates)
bool get_bone_samples(BCMatrixSampleMap &samples, Object *ob, Bone *bone)
static void get_animated_from_export_set(std::set< Object * > &animated_objects, LinkNode &export_set)
void get_bone_frames(BCFrames &frames, Object *ob, Bone *bone)
BCAnimationSampler(BCExportSettings &export_settings, BCObjectSet &object_set)
void add_object(Object *ob)
void sample_scene(BCExportSettings &export_settings, bool keyframe_at_end)
static bool is_animated_by_constraint(Object *ob, ListBase *conlist, std::set< Object * > &animated_objects)
bool get_object_samples(BCMatrixSampleMap &samples, Object *ob)
BCAnimationCurveMap * get_curves(Object *ob)
BCAnimationCurveMap curve_map
BCSample & add(Object *ob, int frame_index)
int get_frames(std::vector< int > &frames) const
BCSampleFrame * get_frame(int frame_index)
int get_samples(Object *ob, BCFrameSampleMap &samples) const
int get_matrices(Object *ob, BCMatrixSampleMap &samples) const
const BCMatrix * get_sample_matrix(Object *ob) const
bool has_sample_for(Object *ob) const
const BCSample * get_sample(Object *ob) const
BCSample & add(Object *ob)
void add_bone_matrix(Bone *bone, Matrix &mat)
bool bc_has_animations(Object *ob)
bool bc_is_animated(BCMatrixSampleMap &values)
bool bc_validateConstraints(bConstraint *con)
void bc_update_scene(BlenderContext &blender_context, float ctime)
bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_opensim)
std::set< Object * > BCObjectSet
bAction * bc_getSceneObjectAction(Object *ob)
bool bc_in_range(float a, float b, float range)
bAction * bc_getSceneLightAction(Object *ob)
bAction * bc_getSceneMaterialAction(Material *ma)
bAction * bc_getSceneCameraAction(Object *ob)
void(* MEM_freeN)(void *vmemh)
static void sample(SocketReader *reader, int x, int y, float color[4])
struct bConstraintTarget * next
int(* get_constraint_targets)(struct bConstraint *con, struct ListBase *list)
struct bConstraint * next
struct bPoseChannel * next