51 MEM_CXX_CLASS_ALLOC_FUNCS(
"TransSeqSnapData")
93 strip_sources.
add(strip);
107 scene, channels,
ed->current_strips(), scene->
r.
cfra, 0);
110 return strip_sources;
121 const bool drag_and_drop)
130 VectorSet effects_of_strip_sources = strip_sources;
133 [&](
Strip *strip) {
return strip->is_effect() && !strip->is_effect_with_inputs(); });
136 for (
Strip &strip : *seqbase) {
147 if (effects_of_strip_sources.
contains(&strip)) {
151 strip_targets.
add(&strip);
154 return strip_targets;
166 return strip_targets;
173 scene, channels,
ed->current_strips(), scene->
r.
cfra, 0);
180 return strip_targets;
189static int cmp_fn(
const void *a,
const void *
b)
192 (*
static_cast<float2 *
>(
const_cast<void *
>(
b)))[0]);
199 for (
Strip *strip : strip_sources) {
200 const int channel = strip->channel;
201 const int left = strip->left_handle();
202 const int right = strip->right_handle(scene);
224 for (
auto item : retiming_selection.
items()) {
225 const int channel = item.value->channel;
236 bool translate_origin)
238 for (
Strip *strip : strip_sources) {
239 if (!translate_origin) {
241 for (
const float2 &point : strip_image_quad) {
242 snap_data->
sources.append(point);
248 snap_data->
sources.append(image_origin);
259 const short snap_mode,
284 for (
Strip *strip : strip_targets) {
285 const int channel = strip->channel;
287 snap_data->
targets.append(
float2(strip->left_handle(), channel));
288 snap_data->
targets.append(
float2(strip->right_handle(scene), channel));
294 if (strip->content_start() > strip->left_handle()) {
295 snap_data->
targets.append(
float2(strip->content_start(), channel));
297 if (strip->content_end(scene) < strip->right_handle(scene)) {
298 snap_data->
targets.append(
float2(strip->content_end(scene), channel));
306 if (strip->intersects_frame(scene, key_frame)) {
318 const short snap_mode,
322 bool translate_origin)
335 auto build_corners = [&](
Strip *strip) {
337 for (
const float2 &point : corners) {
338 snap_data->
targets.append(point);
344 for (
Strip *strip : strip_targets) {
345 build_corners(strip);
347 snap_data->
targets.append(image_origin);
351 if (translate_origin) {
352 for (
Strip *strip : strip_sources) {
354 const float2 center = (corners[0] + corners[1] + corners[2] + corners[3]) * 0.25f;
355 snap_data->
targets.append(center);
399 scene, v2d, snap_mode, snap_data, strip_targets, strip_sources, translate_origin);
403 snap_data->
sources.append(cursor_view);
419 if (snap_data->
sources.is_empty() || snap_data->
targets.is_empty()) {
420 MEM_delete(snap_data);
454 if (ignore_other_channels && target[1] !=
all_channels &&
460 int source_frame = source[0];
461 int target_frame = target[0];
463 if (dist > best_dist) {
468 best_target = target;
469 best_source = source;
477 float2 best_offset(
float(best_target[0] - best_source[0]), 0.0f);
490 float2 best_dist(std::numeric_limits<float>::max());
497 constexpr int num_axes = 2;
499 int dist =
abs(target[i] - (source[i] + t->
values[i]));
500 if (dist > best_dist[i]) {
505 best_target[i] = target[i];
506 best_source[i] = source[i];
514 if (best_dist[0] <= thr) {
520 if (best_dist[1] <= thr) {
526 return (best_dist[0] <= thr || best_dist[1] <= thr);
532 if (snap_data ==
nullptr) {
566 const int left_frame,
567 const int right_frame,
585 t->
tsnap.seq_context = snap_data;
588 t->
tsnap.seq_context =
nullptr;
590 float snap_offset = 0;
604 const int left_frame,
605 const int right_frame,
607 int *r_snap_distance,
Read Blender memory allocation and freeing.
constexpr IndexRange()=default
ValueIterator values() const &
ItemIterator items() const &
bool contains(const Key &key) const
int64_t remove_if(Predicate &&predicate)
MutableSpan< SeqRetimingKey > retiming_keys_get(const Strip *strip)
VectorSet< Strip * > query_selected_strips(ListBaseT< Strip > *seqbase)
ListBaseT< Strip > * active_seqbase_get(const Editing *ed)
Array< float2 > image_transform_quad_get(const Scene *scene, const Strip *strip)
bool render_is_muted(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
Editing * editing_get(const Scene *scene)
int retiming_key_frame_get(const Scene *scene, const Strip *strip, const SeqRetimingKey *key)
void expand_strips(Editing *ed, VectorSet< Strip * > &strips, const StripRelation include)
bool transform_single_image_check(const Strip *strip)
MetaStack * meta_stack_active_get(const Editing *ed)
Editing * editing_ensure(Scene *scene)
float2 image_transform_origin_preview_offset_get(const Scene *scene, const Strip *strip)
short tool_settings_snap_flag_get(Scene *scene)
int tool_settings_snap_distance_get(Scene *scene)
bool transform_is_locked(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
short tool_settings_snap_mode_get(Scene *scene)
ListBaseT< SeqTimelineChannel > * channels_displayed_get(const Editing *ed)
Map< SeqRetimingKey *, Strip * > retiming_selection_get(const Editing *ed)
VectorSet< Strip * > query_rendered_strips(const Scene *scene, ListBaseT< SeqTimelineChannel > *channels, ListBaseT< Strip > *seqbase, const int timeline_frame, const int displayed_channel)
float view2d_region_to_view_x(const View2D *v2d, float x)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE int round_fl_to_int(float a)
MINLINE void copy_v2_v2(float r[2], const float a[2])
VecBase< float, 2 > float2
BMesh const char void * data
@ SEQ_SNAP_TO_ALL_CHANNEL_STRIPS
@ SEQ_SNAP_TO_PREVIEW_BORDERS
@ SEQ_SNAP_TO_PREVIEW_CENTER
@ SEQ_SNAP_TO_STRIPS_PREVIEW
@ SEQ_SNAP_TO_CURRENT_FRAME
@ SEQ_SNAP_TO_FRAME_RANGE
ListBaseT< TimeMarker > markers
ListBaseT< SpaceLink > spacedata