34 : export_settings(export_settings)
36 BCObjectSet::iterator it;
37 for (it = object_set.begin(); it != object_set.end(); ++it) {
45 BCAnimationObjectMap::iterator it;
46 for (it = objects.begin(); it != objects.end(); ++it) {
54 BlenderContext blender_context = export_settings.get_blender_context();
56 objects[ob] = animation;
58 initialize_keyframes(animation->
frame_set, ob);
59 initialize_curves(animation->
curve_map, ob);
66 initialize_curves(animation.
curve_map, ob);
76 sample_frames.clear();
78 if (sampling_rate < 1) {
86 for (frame_index = nearbyint(sfra); frame_index < efra; frame_index += sampling_rate) {
87 sample_frames.insert(frame_index);
90 if (frame_index >= efra && keyframe_at_end) {
91 sample_frames.insert(efra);
106 for (
int i = 0; i < fcu->
totvert; bezt++, i++) {
107 int frame_index = nearbyint(bezt->
vec[1][0]);
108 frameset.insert(frame_index);
114 void BCAnimationSampler::check_property_is_animated(
115 BCAnimation &animation,
float *ref,
float *val, std::string data_path,
int length)
117 for (
int array_index = 0; array_index <
length; array_index++) {
120 BCAnimationCurveMap::iterator it = animation.
curve_map.find(key);
128 void BCAnimationSampler::update_animation_curves(
BCAnimation &animation,
133 BCAnimationCurveMap::iterator it;
136 if (
curve->is_transform_curve()) {
140 curve->add_value_from_rna(frame);
145 BCSample &BCAnimationSampler::sample_object(
Object *ob,
int frame_index,
bool for_opensim)
147 BCSample &ob_sample = sample_data.
add(ob, frame_index);
149 if (export_settings.get_apply_global_orientation()) {
150 const BCMatrix &global_transform = export_settings.get_global_transform();
171 BlenderContext blender_context = export_settings.get_blender_context();
172 int sampling_rate = export_settings.get_sampling_rate();
173 bool for_opensim = export_settings.get_open_sim();
174 bool keep_keyframes = export_settings.get_keep_keyframes();
180 BCFrameSet::iterator it;
185 for (
int frame_index = startframe; frame_index <= endframe; frame_index++) {
187 bool is_scene_sample_frame =
false;
188 bool needs_update =
true;
189 if (scene_sample_frames.find(frame_index) != scene_sample_frames.end()) {
191 needs_update =
false;
192 is_scene_sample_frame =
true;
195 bool needs_sampling = is_scene_sample_frame || keep_keyframes ||
197 if (!needs_sampling) {
201 BCAnimationObjectMap::iterator obit;
202 for (obit = objects.begin(); obit != objects.end(); ++obit) {
206 if (is_scene_sample_frame || object_keyframes.find(frame_index) != object_keyframes.end()) {
210 needs_update =
false;
214 update_animation_curves(*animation,
sample, ob, frame_index);
222 std::set<Object *> &animated_objects)
226 ListBase targets = {
nullptr,
nullptr};
240 if (animated_objects.find(obtar) != animated_objects.end()) {
254 std::set<Object *> &candidates)
259 std::set<Object *>::iterator it;
260 for (it = candidates.begin(); it != candidates.end(); ++it) {
264 animated_objects.insert(cob);
265 candidates.erase(cob);
270 }
while (found_more && !candidates.empty());
282 animated_objects.clear();
283 std::set<Object *> static_objects;
284 std::set<Object *> candidates;
290 animated_objects.insert(cob);
295 candidates.insert(cob);
341 int array_index =
curve.get_array_index();
342 const BC_animation_transform_type tm_type =
curve.get_transform_type();
344 BCFrameSampleMap::iterator it;
345 for (it = samples.begin(); it != samples.end(); ++it) {
346 const int frame_index = nearbyint(it->first);
352 int subindex =
curve.get_subindex();
354 if (subindex == -1) {
355 good =
sample->get_value(tm_type, array_index, &val);
358 good =
sample->get_value(tm_type, array_index, &val, subindex);
362 curve.add_value(val, frame_index);
366 curve.remove_unused_keyframes();
371 void BCAnimationSampler::generate_transform(
Object *ob,
375 BCAnimationCurveMap::const_iterator it =
curves.find(key);
381 void BCAnimationSampler::generate_transforms(
Object *ob,
382 const std::string prep,
399 std::string prep =
"pose.bones[\"" + std::string(bone->
name) +
"\"].";
403 generate_transforms(ob, child,
curves);
407 void BCAnimationSampler::initialize_keyframes(
BCFrameSet &frameset,
Object *ob)
428 for (; fcu; fcu = fcu->
next) {
449 generate_transforms(ob, root_bone,
curves);
467 for (; fcu; fcu = fcu->
next) {
483 for (; fcu; fcu = fcu->
next) {
503 BCSampleMap::const_iterator it = sampleMap.find(ob);
504 if (it == sampleMap.end()) {
512 BCSampleMap::const_iterator it = sampleMap.find(ob);
513 if (it == sampleMap.end()) {
517 return &
sample->get_matrix();
522 BCSampleMap::const_iterator it = sampleMap.find(ob);
523 if (it == sampleMap.end()) {
534 return sampleMap.find(ob) != sampleMap.end();
548 return frame.
add(ob);
557 BCSampleFrameMap::iterator it = sample_frames.find(frame_index);
558 BCSampleFrame *frame = (it == sample_frames.end()) ?
nullptr : &it->second;
565 BCSampleFrameMap::const_iterator it;
566 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
567 frames.push_back(it->first);
569 return frames.size();
575 BCSampleFrameMap::const_iterator it;
576 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
579 frames.push_back(it->first);
582 return frames.size();
588 BCSampleFrameMap::const_iterator it;
589 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
592 frames.push_back(it->first);
595 return frames.size();
601 BCSampleFrameMap::const_iterator it;
602 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
606 samples[it->first] =
sample;
609 return samples.size();
615 BCSampleFrameMap::const_iterator it;
616 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
620 samples[it->first] = matrix;
623 return samples.size();
629 BCSampleFrameMap::const_iterator it;
630 for (it = sample_frames.begin(); it != sample_frames.end(); ++it) {
634 samples[it->first] =
sample;
637 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.
void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targets, bool no_copy)
int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targets)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
bool bool BLI_str_quoted_substr(const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxlen)
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
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
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)
const BCMatrix & get_matrix() const
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)
T length(const vec_base< T, Size > &a)
struct bConstraintTarget * next
struct bConstraint * next
struct bPoseChannel * next