62 for (
int i = 0; i < motion_path.
length; i++) {
79 int current_id_index = 0;
81 ids[current_id_index++] = &mpt.ob->id;
111 Bone *bone = pchan.bone_get(*ob);
138 float4x4 perspective_matrix = window_matrix * cam_eval->world_to_object();
139 const float4 co_clip_space = perspective_matrix *
float4(point.x, point.y, point.z, 1.0);
153 Depsgraph &depsgraph,
185 mul_m4_v3(ob_eval->object_to_world().ptr(), calculated_point);
189 copy_v3_v3(calculated_point, ob_eval->object_to_world().location());
196 return calculated_point;
202 Depsgraph *depsgraph,
211 if ((cframe < mpath->start_frame) || (cframe >= mpath->
end_frame)) {
236 const bool has_changed = previous_point != calculated_point;
239 return has_changed || !was_already_evaluated;
245 if (mpt.
pchan !=
nullptr) {
266 avs->
path_sf = scene->playback_start();
267 avs->
path_ef = scene->playback_end();
288 BLI_assert_msg(
false,
"This should not happen, function should have exited earlier.");
316 if (range.contains(frame)) {
338 return pchan_eval->
mpath;
340 return ob_eval->
mpath;
370 const int modified_frame)
374 "Motion path calculation should always happen with a minimal depsgraph.");
417 const int start_frame =
clamp_i(modified_frame, mpt.mpath->start_frame, mpt.mpath->end_frame);
425 int frame = start_frame;
426 Bounds<int> evaluated_range = {start_frame, start_frame};
428 bool finished_left =
false;
429 bool finished_right =
false;
432 int stable_result_counter = 0;
436 constexpr int stable_result_threshold = 2;
438 while (!finished_left || !finished_right) {
443 bool any_modified =
false;
447 if (frame == start_frame) {
453 stable_result_counter = 0;
456 stable_result_counter++;
459 if (frame < start_frame) {
460 if (stable_result_counter >= stable_result_threshold) {
461 finished_left =
true;
464 stable_result_counter = 0;
466 evaluated_range.
min = frame;
469 if (stable_result_counter >= stable_result_threshold) {
470 finished_right =
true;
471 stable_result_counter = 0;
473 evaluated_range.
max = frame;
476 if (!finished_left) {
477 frame = evaluated_range.
min - 1;
480 frame = evaluated_range.
max + 1;
484 evaluated_ranges.
append(evaluated_range);
Functions and classes to work with Actions.
Functions for backward compatibility with the legacy Action API.
Functions to work with AnimData.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
Blender kernel action and pose functionality.
Camera data-block and utility functions.
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
constexpr bool is_empty() const
constexpr int64_t size() const
void append(const T &value)
const bActionGroup * channel_group_find(StringRef name) const
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
bool assigned_action_has_keyframes(AnimData *adt)
bool fcurve_matches_collection_path(const FCurve &fcurve, StringRefNull collection_rna_path, StringRefNull data_name)
const animrig::Channelbag * channelbag_for_action_slot(const Action &action, slot_handle_t slot_handle)
Span< FCurve * > fcurves_for_assigned_action(AnimData *adt)
void clear_preview_location(bMotionPath &mpath)
void set_preview_location(bMotionPath &mpath, const float location[3])
void tag_for_recalc(bMotionPath &motion_path)
T max(const T &a, const T &b)
void animviz_clear_motionpath_preview(Span< MPathTarget > targets)
static bool any_range_contains(const Span< Bounds< int > > ranges, const int frame)
static float3 get_evaluated_point_for_target(const MPathTarget &mpt, Depsgraph &depsgraph, Object *camera)
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool DEG_is_active(const Depsgraph *depsgraph)
static bool motionpaths_calc_bake_target(const MPathTarget &mpt, const int cframe, Depsgraph *depsgraph, Object *camera)
bool ED_keylist_selected_keys_frame_range(const AnimKeylist *keylist, Bounds< float > *r_frame_range)
@ MOTIONPATH_FLAG_BAKE_CAMERA
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone)
MatBase< float, 4, 4 > float4x4
const ActKeyColumn * ED_keylist_find_exact(const AnimKeylist *keylist, const float cfra)
VecBase< float, 4 > float4
void mul_m4_v3(const float M[4][4], float r[3])
AnimData * BKE_animdata_from_id(const ID *id)
static bAnimVizSettings * animviz_target_settings_get(const MPathTarget &mpt)
void animviz_build_motionpath_targets(Object *ob, Vector< MPathTarget > &r_targets)
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, float2 range, const bool use_nla_remapping)
static float3 transform_mpath_point_to_camera(Depsgraph &depsgraph, Object &camera, const float3 point)
Depsgraph * animviz_depsgraph_build(Main *bmain, Scene *scene, ViewLayer *view_layer, const Span< MPathTarget > targets)
void BKE_camera_multiview_window_matrix(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_winmat[4][4])
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void DEG_graph_build_from_ids(Depsgraph *graph, Span< ID * > ids)
void action_group_to_keylist(AnimData *adt, bActionGroup *agrp, AnimKeylist *keylist, const int saction_flag, float2 range)
void ED_keylist_prepare_for_direct_access(AnimKeylist *keylist)
void animviz_calc_motionpaths(Depsgraph *depsgraph, Scene *scene, MutableSpan< MPathTarget > targets, const int modified_frame)
AnimKeylist * ED_keylist_create()
static void build_keylist_for_target(MPathTarget &target, AnimKeylist &keylist)
void animviz_motionpath_compute_range(Object *ob, Scene *scene)
@ MOTIONPATH_VERT_EVALUATED
@ MOTIONPATH_RANGE_KEYS_ALL
@ MOTIONPATH_RANGE_MANUAL
@ MOTIONPATH_RANGE_KEYS_SELECTED
static bMotionPath * get_evaluated_motion_path(Depsgraph &depsgraph, const MPathTarget &mpt)
Scene * DEG_get_input_scene(const Depsgraph *graph)
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame, DepsgraphEvaluateSyncWriteback sync_writeback=DEG_EVALUATE_SYNC_WRITEBACK_NO)
void ED_keylist_free(AnimKeylist *keylist)
VecBase< float, 3 > float3
MINLINE int clamp_i(int value, int min, int max)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
bool ED_keylist_all_keys_frame_range(const AnimKeylist *keylist, Bounds< float > *r_frame_range)
void animviz_update_motionpath_preview(Depsgraph &depsgraph, Span< MPathTarget > targets)
const c_style_mat & ptr() const
eMotionPath_Ranges path_range
eMotionPaths_ViewFlag path_viewflag
eAnimViz_RecalcFlags recalc
eMotionPathVert_Flag flag
gpu::VertBuf * points_vbo
gpu::Batch * batch_points
ListBaseT< bPoseChannel > chanbase