Blender V5.3
transform_mode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_armature_types.h"
13#include "DNA_space_types.h"
15
16#include "BLI_listbase.hh"
17#include "BLI_math_base.hh"
18#include "BLI_math_matrix_c.hh"
20#include "BLI_math_vector_c.hh"
21#include "BLI_string_utf8.hh"
22
23#include "BKE_constraint.h"
24#include "BKE_context.hh"
25#include "BKE_layer.hh"
26
27#include "BLT_translation.hh"
28
29#include "transform.hh"
30#include "transform_convert.hh"
31#include "transform_gizmo.hh"
33#include "transform_snap.hh"
34
35/* Own include. */
36#include "transform_mode.hh"
37
38namespace blender::ed::transform {
39
41{
42 if (mode == TFM_BONESIZE) {
43 /* Use context here as `TransInfo` scene/view_layer members aren't yet initialized. */
44 Main &bmain = *CTX_data_main(C);
45 Scene *scene = CTX_data_scene(C);
46 ViewLayer *view_layer = CTX_data_view_layer(C);
47 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
48 const Object *ob = BKE_view_layer_active_object_get(view_layer);
49 BLI_assert(ob);
50 if (ob->type != OB_ARMATURE) {
51 return TFM_RESIZE;
52 }
53 }
54
55 return mode;
56}
57
58bool transdata_check_local_center(const TransInfo *t, short around)
59{
60 return ((around == V3D_AROUND_LOCAL_ORIGINS) &&
61 ((t->options & (CTX_OBJECT | CTX_POSE_BONE)) ||
62 /* Implicit: `(t->flag & T_EDIT)`. */
64 OB_MESH,
69 OB_ARMATURE) ||
70 (t->spacetype == SPACE_GRAPH) ||
72}
73
85
87{
88 return (t->flag & T_V3D_ALIGN) && (t->options & CTX_OBJECT) &&
90 (CTX_DATA_COUNT(t->context, selected_editable_objects) == 1);
91}
92
93/* -------------------------------------------------------------------- */
96
97void protectedTransBits(short protectflag, float vec[3])
98{
99 if (protectflag & OB_LOCK_LOCX) {
100 vec[0] = 0.0f;
101 }
102 if (protectflag & OB_LOCK_LOCY) {
103 vec[1] = 0.0f;
104 }
105 if (protectflag & OB_LOCK_LOCZ) {
106 vec[2] = 0.0f;
107 }
108}
109
110/* This function only does the delta rotation. */
111static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
112{
113 /* Check that protection flags are set. */
114 if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
115 return;
116 }
117
118 if (protectflag & OB_LOCK_ROT4D) {
119 /* Quaternions getting limited as 4D entities that they are. */
120 if (protectflag & OB_LOCK_ROTW) {
121 quat[0] = oldquat[0];
122 }
123 if (protectflag & OB_LOCK_ROTX) {
124 quat[1] = oldquat[1];
125 }
126 if (protectflag & OB_LOCK_ROTY) {
127 quat[2] = oldquat[2];
128 }
129 if (protectflag & OB_LOCK_ROTZ) {
130 quat[3] = oldquat[3];
131 }
132 }
133 else {
134 /* Quaternions get limited with euler... (compatibility mode). */
135 float eul[3], oldeul[3], nquat[4], noldquat[4];
136 float qlen;
137
138 qlen = normalize_qt_qt(nquat, quat);
139 normalize_qt_qt(noldquat, oldquat);
140
141 quat_to_eul(eul, nquat);
142 quat_to_eul(oldeul, noldquat);
143
144 if (protectflag & OB_LOCK_ROTX) {
145 eul[0] = oldeul[0];
146 }
147 if (protectflag & OB_LOCK_ROTY) {
148 eul[1] = oldeul[1];
149 }
150 if (protectflag & OB_LOCK_ROTZ) {
151 eul[2] = oldeul[2];
152 }
153
154 eul_to_quat(quat, eul);
155
156 /* Restore original quat size. */
157 mul_qt_fl(quat, qlen);
158
159 /* Quaternions flip w sign to accumulate rotations correctly. */
160 if ((nquat[0] < 0.0f && quat[0] > 0.0f) || (nquat[0] > 0.0f && quat[0] < 0.0f)) {
161 mul_qt_fl(quat, -1.0f);
162 }
163 }
164}
165
166static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
167{
168 if (protectflag & OB_LOCK_ROTX) {
169 eul[0] = oldeul[0];
170 }
171 if (protectflag & OB_LOCK_ROTY) {
172 eul[1] = oldeul[1];
173 }
174 if (protectflag & OB_LOCK_ROTZ) {
175 eul[2] = oldeul[2];
176 }
177}
178
184 short protectflag, float axis[3], float *angle, const float oldAxis[3], float oldAngle)
185{
186 /* Check that protection flags are set. */
187 if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
188 return;
189 }
190
191 if (protectflag & OB_LOCK_ROT4D) {
192 /* Axis-angle getting limited as 4D entities that they are... */
193 if (protectflag & OB_LOCK_ROTW) {
194 *angle = oldAngle;
195 }
196 if (protectflag & OB_LOCK_ROTX) {
197 axis[0] = oldAxis[0];
198 }
199 if (protectflag & OB_LOCK_ROTY) {
200 axis[1] = oldAxis[1];
201 }
202 if (protectflag & OB_LOCK_ROTZ) {
203 axis[2] = oldAxis[2];
204 }
205 }
206 else {
207 /* Axis-angle get limited with euler. */
208 float eul[3], oldeul[3];
209
211 axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle);
212
213 if (protectflag & OB_LOCK_ROTX) {
214 eul[0] = oldeul[0];
215 }
216 if (protectflag & OB_LOCK_ROTY) {
217 eul[1] = oldeul[1];
218 }
219 if (protectflag & OB_LOCK_ROTZ) {
220 eul[2] = oldeul[2];
221 }
222
224
225 /* When converting to axis-angle,
226 * we need a special exception for the case when there is no axis. */
227 if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
228 /* For now, rotate around y-axis then (so that it simply becomes the roll). */
229 axis[1] = 1.0f;
230 }
231 }
232}
233
234void protectedScaleBits(short protectflag, float scale[3])
235{
236 if (protectflag & OB_LOCK_SCALEX) {
237 scale[0] = 1.0f;
238 }
239 if (protectflag & OB_LOCK_SCALEY) {
240 scale[1] = 1.0f;
241 }
242 if (protectflag & OB_LOCK_SCALEZ) {
243 scale[2] = 1.0f;
244 }
245}
246
248
249/* -------------------------------------------------------------------- */
252
254{
255 if (td->con) {
260
261 bConstraintOb cob = {nullptr};
262 bConstraint *con;
263 float ctime = float(t->scene->r.cfra);
264
265 /* Make a temporary bConstraintOb for using these limit constraints
266 * - They only care that cob->matrix is correctly set.
267 * - Current space should be local.
268 */
269 unit_m4(cob.matrix);
270 copy_v3_v3(cob.matrix[3], td->loc);
271
272 /* Evaluate valid constraints. */
273 for (con = td->con; con; con = con->next) {
275 continue;
276 }
277
278 const bConstraintTypeInfo *cti = nullptr;
279 ListBaseT<bConstraintTarget> targets = {nullptr, nullptr};
280
281 /* Only use it if it's tagged for this purpose (and the right type). */
282 if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
283 bLocLimitConstraint *data = static_cast<bLocLimitConstraint *>(con->data);
284
285 if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
286 continue;
287 }
288 cti = ctiLoc;
289 }
290 else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) {
291 bDistLimitConstraint *data = static_cast<bDistLimitConstraint *>(con->data);
292
293 if ((data->flag & LIMITDIST_TRANSFORM) == 0) {
294 continue;
295 }
296 cti = ctiDist;
297 }
298
299 if (cti) {
300 /* Do space conversions. */
301 if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
302 mul_m3_v3(td->mtx, cob.matrix[3]);
303 if (tc->use_local_mat) {
304 add_v3_v3(cob.matrix[3], tc->mat[3]);
305 }
306 }
307 else if (con->ownspace == CONSTRAINT_SPACE_POSE) {
308 /* Bone space without considering object transformations. */
309 mul_m3_v3(td->mtx, cob.matrix[3]);
310 mul_m3_v3(tc->imat3, cob.matrix[3]);
311 }
312 else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
313 /* Skip... incompatible spacetype. */
314 continue;
315 }
316
317 /* Initialize the custom space for use in calculating the matrices. */
319
320 /* Get constraint targets if needed. */
321 BKE_constraint_targets_for_solving_get(t->depsgraph, con, &cob, &targets, ctime);
322
323 /* Do constraint. */
324 cti->evaluate_constraint(con, &cob, &targets);
325
326 /* Convert spaces again. */
327 if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
328 if (tc->use_local_mat) {
329 sub_v3_v3(cob.matrix[3], tc->mat[3]);
330 }
331 mul_m3_v3(td->smtx, cob.matrix[3]);
332 }
333 else if (con->ownspace == CONSTRAINT_SPACE_POSE) {
334 mul_m3_v3(tc->mat3, cob.matrix[3]);
335 mul_m3_v3(td->smtx, cob.matrix[3]);
336 }
337
338 /* Free targets list. */
339 targets.free_no_destruct();
340 }
341 }
342
343 /* Copy results from `cob->matrix`. */
344 copy_v3_v3(td->loc, cob.matrix[3]);
345 }
346}
347
349{
350 /* Make a temporary bConstraintOb for use by limit constraints
351 * - They only care that cob->matrix is correctly set.
352 * - Current space should be local
353 */
354 memset(cob, 0, sizeof(bConstraintOb));
355 if (!td_ext) {
356 return;
357 }
358 if (td_ext->rotOrder == ROT_MODE_QUAT) {
359 /* Quaternion. */
360 /* Objects and bones do normalization first too, otherwise
361 * we don't necessarily end up with a rotation matrix, and
362 * then conversion back to quat gives a different result. */
363 float quat[4];
364 normalize_qt_qt(quat, td_ext->quat);
365 quat_to_mat4(cob->matrix, quat);
366 }
367 else if (td_ext->rotOrder == ROT_MODE_AXISANGLE) {
368 /* Axis angle. */
369 axis_angle_to_mat4(cob->matrix, td_ext->rotAxis, *td_ext->rotAngle);
370 }
371 else {
372 /* Eulers. */
373 eulO_to_mat4(cob->matrix, td_ext->rot, td_ext->rotOrder);
374 }
375}
376
377static void constraintRotLim(const TransInfo * /*t*/, TransData *td, TransDataExtension *td_ext)
378{
379 if (td->con) {
381 bConstraintOb cob;
382 bConstraint *con;
383 bool do_limit = false;
384
385 /* Evaluate valid constraints. */
386 for (con = td->con; con; con = con->next) {
388 continue;
389 }
390
391 /* We're only interested in Limit-Rotation constraints. */
392 if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
393 bRotLimitConstraint *data = static_cast<bRotLimitConstraint *>(con->data);
394
395 /* Only use it if it's tagged for this purpose. */
396 if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
397 continue;
398 }
399
400 /* Skip incompatible space-types. */
402 continue;
403 }
404
405 /* Only do conversion if necessary, to preserve quaternion and euler rotations. */
406 if (do_limit == false) {
407 constraintob_from_transdata(&cob, td_ext);
408 do_limit = true;
409 }
410
411 /* Do space conversions. */
412 if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
413 /* Just multiply by `td->mtx` (this should be ok). */
414 mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
415 }
416
417 /* Do constraint. */
418 cti->evaluate_constraint(con, &cob, nullptr);
419
420 /* Convert spaces again. */
421 if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
422 /* Just multiply by `td->smtx` (this should be ok). */
423 mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
424 }
425 }
426 }
427
428 if (do_limit) {
429 /* Copy results from `cob->matrix`. */
430 if (td_ext->rotOrder == ROT_MODE_QUAT) {
431 /* Quaternion. */
432 mat4_to_quat(td_ext->quat, cob.matrix);
433 }
434 else if (td_ext->rotOrder == ROT_MODE_AXISANGLE) {
435 /* Axis angle. */
436 mat4_to_axis_angle(td_ext->rotAxis, td_ext->rotAngle, cob.matrix);
437 }
438 else {
439 /* Eulers. */
440 mat4_to_eulO(td_ext->rot, td_ext->rotOrder, cob.matrix);
441 }
442 }
443 }
444}
445
446void constraintScaleLim(const TransInfo *t, const TransDataContainer *tc, int td_index)
447{
448 if (!tc->data_ext) {
449 return;
450 }
451
452 TransData *td = &tc->data[td_index];
453 if (!td->con) {
454 return;
455 }
456
457 /* Make a temporary bConstraintOb for using these limit constraints
458 * - they only care that cob->matrix is correctly set ;-)
459 * - current space should be local
460 */
461 if ((td->flag & TD_SINGLE_SCALE) && !(t->con.mode & CON_APPLY)) {
462 /* Scale val and reset the "scale". */
463 return; /* TODO: fix this case. */
464 }
465
466 /* Reset val if SINGLESIZE but using a constraint. */
467 if (td->flag & TD_SINGLE_SCALE) {
468 return;
469 }
470
472 bConstraintOb cob = {nullptr};
473 bConstraint *con;
474 float scale_sign[3], scale_abs[3];
475 int i;
476
477 TransDataExtension *td_ext = &tc->data_ext[td_index];
478
479 /* Separate out sign to apply back later. */
480 for (i = 0; i < 3; i++) {
481 scale_sign[i] = signf(td_ext->scale[i]);
482 scale_abs[i] = fabsf(td_ext->scale[i]);
483 }
484
485 size_to_mat4(cob.matrix, scale_abs);
486
487 /* Evaluate valid constraints. */
488 for (con = td->con; con; con = con->next) {
490 continue;
491 }
492
493 /* We're only interested in Limit-Scale constraints. */
494 if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
495 bSizeLimitConstraint *data = static_cast<bSizeLimitConstraint *>(con->data);
496
497 /* Only use it if it's tagged for this purpose. */
498 if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
499 continue;
500 }
501
502 /* Do space conversions. */
503 if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
504 /* Just multiply by `td->mtx` (this should be ok). */
505 mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
506 }
507 else if (con->ownspace == CONSTRAINT_SPACE_POSE) {
508 /* Bone space without considering object transformations. */
509 mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
510 mul_m4_m3m4(cob.matrix, tc->imat3, cob.matrix);
511 }
512 else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
513 /* Skip... incompatible `spacetype`. */
514 continue;
515 }
516
517 /* Do constraint. */
518 cti->evaluate_constraint(con, &cob, nullptr);
519
520 /* Convert spaces again. */
521 if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
522 /* Just multiply by `td->smtx` (this should be ok). */
523 mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
524 }
525 else if (con->ownspace == CONSTRAINT_SPACE_POSE) {
526 mul_m4_m3m4(cob.matrix, tc->mat3, cob.matrix);
527 mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
528 }
529 }
530 }
531
532 /* Copy results from `cob->matrix`. */
533 if ((td->flag & TD_SINGLE_SCALE) && !(t->con.mode & CON_APPLY)) {
534 /* Scale val and reset the "scale". */
535 return; /* TODO: fix this case. */
536 }
537
538 /* Reset val if SINGLESIZE but using a constraint. */
539 if (td->flag & TD_SINGLE_SCALE) {
540 return;
541 }
542
543 /* Extract scale from matrix and apply back sign. */
544 mat4_to_size(td_ext->scale, cob.matrix);
545 mul_v3_v3(td_ext->scale, scale_sign);
546}
547
549
550/* -------------------------------------------------------------------- */
553
554void headerRotation(TransInfo *t, char *str, const int str_maxncpy, float final)
555{
556 size_t ofs = 0;
557
558 if (hasNumInput(&t->num)) {
559 char c[NUM_STR_REP_LEN];
560
561 outputNumInput(&(t->num), c, t->scene->unit);
562
563 ofs += BLI_snprintf_utf8_rlen(str + ofs,
564 str_maxncpy - ofs,
565 IFACE_("Rotation: %s %s %s"),
566 &c[0],
567 t->con.text,
568 t->proptext);
569 }
570 else {
571 ofs += BLI_snprintf_utf8_rlen(str + ofs,
572 str_maxncpy - ofs,
573 IFACE_("Rotation: %.2f%s %s"),
574 RAD2DEGF(final),
575 t->con.text,
576 t->proptext);
577 }
578
579 if (t->flag & T_PROP_EDIT_ALL) {
581 str + ofs, str_maxncpy - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size);
582 }
583}
584
586 const TransDataContainer *tc,
587 TransData *td,
588 TransDataExtension *td_ext,
589 const float mat[3][3],
590 const float *center)
591{
592 float vec[3], totmat[3][3], smat[3][3];
593 float eul[3], fmat[3][3], quat[4];
594
595 if (t->flag & T_POINTS) {
596 mul_m3_m3m3(totmat, mat, td->mtx);
597 mul_m3_m3m3(smat, td->smtx, totmat);
598
599 /* Apply gpencil falloff. */
600 if (t->options & CTX_GPENCIL_STROKES) {
601 if (t->obedit_type == OB_GREASE_PENCIL) {
602 const float *gp_falloff = static_cast<const float *>(td->extra);
603 if (gp_falloff != nullptr && *gp_falloff != 1.0f) {
604 float ident_mat[3][3];
605 unit_m3(ident_mat);
606 interp_m3_m3m3(smat, ident_mat, smat, *gp_falloff);
607 }
608 }
609 }
610
611 sub_v3_v3v3(vec, td->iloc, center);
612 mul_m3_v3(smat, vec);
613
614 add_v3_v3v3(td->loc, vec, center);
615
616 sub_v3_v3v3(vec, td->loc, td->iloc);
618 add_v3_v3v3(td->loc, td->iloc, vec);
619
620 if (td->flag & TD_USEQUAT) {
621 mul_m3_series(fmat, td->smtx, mat, td->mtx);
622 mat3_to_quat(quat, fmat); /* Actual transform. */
623
624 if (td_ext->quat) {
625 mul_qt_qtqt(td_ext->quat, quat, td_ext->iquat);
626
627 /* Is there a reason not to have this here? -jahka. */
628 protectedQuaternionBits(td->protectflag, td_ext->quat, td_ext->iquat);
629 }
630 }
631 }
644 else if (t->options & CTX_POSE_BONE) {
645 /* Extract and invert armature object matrix. */
646
647 if ((td->flag & TD_NO_LOC) == 0) {
648 sub_v3_v3v3(vec, td_ext->center_no_override, center);
649
650 mul_m3_v3(tc->mat3, vec); /* To Global space. */
651 mul_m3_v3(mat, vec); /* Applying rotation. */
652 mul_m3_v3(tc->imat3, vec); /* To Local space. */
653
654 add_v3_v3(vec, center);
655 /* `vec` now is the location where the object has to be. */
656
657 /* Translation needed from the initial location. */
658 sub_v3_v3v3(vec, vec, td_ext->center_no_override);
659
660 /* Special exception, see TD_PBONE_LOCAL_MTX definition comments. */
661 if (td->flag & TD_PBONE_LOCAL_MTX_P) {
662 /* Do nothing. */
663 }
664 else if (td->flag & TD_PBONE_LOCAL_MTX_C) {
665 mul_m3_v3(tc->mat3, vec); /* To Global space. */
666 mul_m3_v3(td_ext->l_smtx, vec); /* To Pose space (Local Location). */
667 }
668 else {
669 mul_m3_v3(tc->mat3, vec); /* To Global space. */
670 mul_m3_v3(td->smtx, vec); /* To Pose space. */
671 }
672
674
675 add_v3_v3v3(td->loc, td->iloc, vec);
676
677 constraintTransLim(t, tc, td);
678 }
679
680 /* Rotation. */
681 /* MORE HACK: as in some cases the matrix to apply location and rot/scale is not the same,
682 * and ElementRotation() might be called in Translation context (with align snapping),
683 * we need to be sure to actually use the *rotation* matrix here...
684 * So no other way than storing it in some dedicated members of `td_ext`! */
685 if ((t->flag & T_V3D_ALIGN) == 0) { /* Align mode doesn't rotate objects itself. */
686 /* Euler or quaternion/axis-angle? */
687 if (td_ext->rotOrder == ROT_MODE_QUAT) {
688 mul_m3_series(fmat, td_ext->r_smtx, mat, td_ext->r_mtx);
689
690 mat3_to_quat(quat, fmat); /* Actual transform. */
691
692 mul_qt_qtqt(td_ext->quat, quat, td_ext->iquat);
693 /* This function works on end result. */
694 protectedQuaternionBits(td->protectflag, td_ext->quat, td_ext->iquat);
695 }
696 else if (td_ext->rotOrder == ROT_MODE_AXISANGLE) {
697 /* Calculate effect based on quaternions. */
698 float iquat[4], tquat[4];
699
700 axis_angle_to_quat(iquat, td_ext->irotAxis, td_ext->irotAngle);
701
702 mul_m3_series(fmat, td_ext->r_smtx, mat, td_ext->r_mtx);
703 mat3_to_quat(quat, fmat); /* Actual transform. */
704 mul_qt_qtqt(tquat, quat, iquat);
705
706 quat_to_axis_angle(td_ext->rotAxis, td_ext->rotAngle, tquat);
707
708 /* This function works on end result. */
710 td_ext->rotAxis,
711 td_ext->rotAngle,
712 td_ext->irotAxis,
713 td_ext->irotAngle);
714 }
715 else {
716 float eulmat[3][3];
717
718 mul_m3_m3m3(totmat, mat, td_ext->r_mtx);
719 mul_m3_m3m3(smat, td_ext->r_smtx, totmat);
720
721 /* Calculate the total rotation in eulers. */
722 copy_v3_v3(eul, td_ext->irot);
723 eulO_to_mat3(eulmat, eul, td_ext->rotOrder);
724
725 /* `mat = transform`, `obmat = bone rotation`. */
726 mul_m3_m3m3(fmat, smat, eulmat);
727
728 mat3_to_compatible_eulO(eul, td_ext->rot, td_ext->rotOrder, fmat);
729
730 /* And apply (to end result only). */
731 protectedRotateBits(td->protectflag, eul, td_ext->irot);
732 copy_v3_v3(td_ext->rot, eul);
733 }
734
735 constraintRotLim(t, td, td_ext);
736 }
737 }
738 else {
739 if ((td->flag & TD_NO_LOC) == 0) {
740 /* Translation. */
741 sub_v3_v3v3(vec, td->center, center);
742 mul_m3_v3(mat, vec);
743 add_v3_v3(vec, center);
744 /* `vec` now is the location where the object has to be. */
745 sub_v3_v3(vec, td->center);
746 mul_m3_v3(td->smtx, vec);
747
749
750 add_v3_v3v3(td->loc, td->iloc, vec);
751 }
752
753 constraintTransLim(t, tc, td);
754
755 /* Rotation. */
756 if ((t->flag & T_V3D_ALIGN) == 0) { /* Align mode doesn't rotate objects itself. */
757 /* Euler or quaternion? */
758 if ((td_ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
759 /* Can be called for texture space translate for example, then opt out. */
760 if (td_ext->quat) {
761 mul_m3_series(fmat, td->smtx, mat, td->mtx);
762
763 if (!is_zero_v3(td_ext->dquat)) {
764 /* Correct for delta quat. */
765 float tmp_mat[3][3];
766 quat_to_mat3(tmp_mat, td_ext->dquat);
767 mul_m3_m3m3(fmat, fmat, tmp_mat);
768 }
769
770 mat3_to_quat(quat, fmat); /* Actual transform. */
771
772 if (!is_zero_v4(td_ext->dquat)) {
773 /* Correct back for delta quaternion. */
774 float idquat[4];
775 invert_qt_qt_normalized(idquat, td_ext->dquat);
776 mul_qt_qtqt(quat, idquat, quat);
777 }
778
779 mul_qt_qtqt(td_ext->quat, quat, td_ext->iquat);
780
781 /* This function works on end result. */
782 protectedQuaternionBits(td->protectflag, td_ext->quat, td_ext->iquat);
783 }
784 }
785 else if (td_ext->rotOrder == ROT_MODE_AXISANGLE) {
786 /* Calculate effect based on quaternions. */
787 float iquat[4], tquat[4];
788
789 axis_angle_to_quat(iquat, td_ext->irotAxis, td_ext->irotAngle);
790
791 mul_m3_series(fmat, td->smtx, mat, td->mtx);
792 mat3_to_quat(quat, fmat); /* Actual transform. */
793 mul_qt_qtqt(tquat, quat, iquat);
794
795 quat_to_axis_angle(td_ext->rotAxis, td_ext->rotAngle, tquat);
796
797 /* This function works on end result. */
799 td_ext->rotAxis,
800 td_ext->rotAngle,
801 td_ext->irotAxis,
802 td_ext->irotAngle);
803 }
804 else {
805 /* Calculate the total rotation in eulers. */
806 float obmat[3][3];
807
808 mul_m3_m3m3(totmat, mat, td->mtx);
809 mul_m3_m3m3(smat, td->smtx, totmat);
810
811 if (!is_zero_v3(td_ext->drot)) {
812 /* Correct for delta rot. */
813 add_eul_euleul(eul, td_ext->irot, td_ext->drot, td_ext->rotOrder);
814 }
815 else {
816 copy_v3_v3(eul, td_ext->irot);
817 }
818
819 eulO_to_mat3(obmat, eul, td_ext->rotOrder);
820 mul_m3_m3m3(fmat, smat, obmat);
821 mat3_to_compatible_eulO(eul, td_ext->rot, td_ext->rotOrder, fmat);
822
823 if (!is_zero_v3(td_ext->drot)) {
824 /* Correct back for delta rot. */
825 sub_eul_euleul(eul, eul, td_ext->drot, td_ext->rotOrder);
826 }
827
828 /* And apply. */
829 protectedRotateBits(td->protectflag, eul, td_ext->irot);
830 copy_v3_v3(td_ext->rot, eul);
831 }
832
833 constraintRotLim(t, td, td_ext);
834 }
835 }
836}
837
839 const TransDataContainer *tc,
840 TransData *td,
841 TransDataExtension *td_ext,
842 const float mat[3][3],
843 const short around)
844{
845 const float *center;
846
847 /* Local constraint shouldn't alter center. */
848 if (transdata_check_local_center(t, around)) {
849 center = td->center;
850 }
851 else {
852 center = tc->center_local;
853 }
854
855 ElementRotation_ex(t, tc, td, td_ext, mat, center);
856}
857
859
860/* -------------------------------------------------------------------- */
863
864void headerResize(TransInfo *t, const float vec[3], char *str, const int str_maxncpy)
865{
866 char tvec[NUM_STR_REP_LEN * 3];
867 size_t ofs = 0;
868 if (hasNumInput(&t->num)) {
869 outputNumInput(&(t->num), tvec, t->scene->unit);
870 }
871 else {
872 BLI_snprintf_utf8(&tvec[0], NUM_STR_REP_LEN, "%.4f", vec[0]);
873 BLI_snprintf_utf8(&tvec[NUM_STR_REP_LEN], NUM_STR_REP_LEN, "%.4f", vec[1]);
874 BLI_snprintf_utf8(&tvec[NUM_STR_REP_LEN * 2], NUM_STR_REP_LEN, "%.4f", vec[2]);
875 }
876
877 if (t->con.mode & CON_APPLY) {
878 switch (t->num.idx_max) {
879 case 0:
880 ofs += BLI_snprintf_utf8_rlen(str + ofs,
881 str_maxncpy - ofs,
882 IFACE_("Scale: %s%s %s"),
883 &tvec[0],
884 t->con.text,
885 t->proptext);
886 break;
887 case 1:
888 ofs += BLI_snprintf_utf8_rlen(str + ofs,
889 str_maxncpy - ofs,
890 IFACE_("Scale: %s : %s%s %s"),
891 &tvec[0],
892 &tvec[NUM_STR_REP_LEN],
893 t->con.text,
894 t->proptext);
895 break;
896 case 2:
897 ofs += BLI_snprintf_utf8_rlen(str + ofs,
898 str_maxncpy - ofs,
899 IFACE_("Scale: %s : %s : %s%s %s"),
900 &tvec[0],
901 &tvec[NUM_STR_REP_LEN],
902 &tvec[NUM_STR_REP_LEN * 2],
903 t->con.text,
904 t->proptext);
905 break;
906 }
907 }
908 else {
909 if (t->flag & T_2D_EDIT) {
910 ofs += BLI_snprintf_utf8_rlen(str + ofs,
911 str_maxncpy - ofs,
912 IFACE_("Scale X: %s Y: %s%s %s"),
913 &tvec[0],
914 &tvec[NUM_STR_REP_LEN],
915 t->con.text,
916 t->proptext);
917 }
918 else {
919 ofs += BLI_snprintf_utf8_rlen(str + ofs,
920 str_maxncpy - ofs,
921 IFACE_("Scale X: %s Y: %s Z: %s%s %s"),
922 &tvec[0],
923 &tvec[NUM_STR_REP_LEN],
924 &tvec[NUM_STR_REP_LEN * 2],
925 t->con.text,
926 t->proptext);
927 }
928 }
929
930 if (t->flag & T_PROP_EDIT_ALL) {
932 str + ofs, str_maxncpy - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size);
933 }
934}
935
941static void TransMat3ToSize(const float mat[3][3], const float smat[3][3], float size[3])
942{
943 float rmat[3][3];
944
945 mat3_to_rot_size(rmat, size, mat);
946
947 /* First tried with dot-product... but the sign flip is crucial. */
948 if (dot_v3v3(rmat[0], smat[0]) < 0.0f) {
949 size[0] = -size[0];
950 }
951 if (dot_v3v3(rmat[1], smat[1]) < 0.0f) {
952 size[1] = -size[1];
953 }
954 if (dot_v3v3(rmat[2], smat[2]) < 0.0f) {
955 size[2] = -size[2];
956 }
957}
958
960 const TransDataContainer *tc,
961 int td_index,
962 const float mat[3][3])
963{
964 TransData *td = &tc->data[td_index];
965
966 float tmat[3][3], smat[3][3], center[3];
967 float vec[3];
968
969 if (t->flag & T_EDIT) {
970 mul_m3_m3m3(smat, mat, td->mtx);
971 mul_m3_m3m3(tmat, td->smtx, smat);
972 }
973 else {
974 copy_m3_m3(tmat, mat);
975 }
976
977 if (t->con.applySize) {
978 t->con.applySize(t, tc, td, tmat);
979 }
980
981 /* Local constraint shouldn't alter center. */
983 copy_v3_v3(center, td->center);
984 }
985 else if (t->options & CTX_MOVIECLIP) {
986 if (td->flag & TD_INDIVIDUAL_SCALE) {
987 copy_v3_v3(center, td->center);
988 }
989 else {
990 copy_v3_v3(center, tc->center_local);
991 }
992 }
993 else {
994 copy_v3_v3(center, tc->center_local);
995 }
996
997 if (tc->data_ext) {
998 TransDataExtension *td_ext = &tc->data_ext[td_index];
999
1000 /* Size checked needed since the 3D cursor only uses rotation fields. */
1001 if (td_ext->scale) {
1002 float fscale[3];
1003
1004 if (ELEM(t->data_type,
1009 {
1010 float ob_scale_mat[3][3];
1011 /* Reorient the size mat to fit the oriented object. */
1012 mul_m3_m3m3(ob_scale_mat, tmat, td->axismtx);
1013 // print_m3("ob_scale_mat", ob_scale_mat);
1014 TransMat3ToSize(ob_scale_mat, td->axismtx, fscale);
1015 // print_v3("fscale", fscale);
1016 }
1017 else {
1018 mat3_to_size(fscale, tmat);
1019 }
1020
1021 protectedScaleBits(td->protectflag, fscale);
1022
1023 if ((t->flag & T_V3D_ALIGN) == 0) { /* Align mode doesn't resize objects itself. */
1024 if ((td->flag & TD_SINGLE_SCALE) && !(t->con.mode & CON_APPLY)) {
1025 /* Scale val and reset scale. */
1026 *td->val = td->ival * (1 + (fscale[0] - 1) * td->factor);
1027
1028 td_ext->scale[0] = td_ext->iscale[0];
1029 td_ext->scale[1] = td_ext->iscale[1];
1030 td_ext->scale[2] = td_ext->iscale[2];
1031 }
1032 else {
1033 /* Reset val if #TD_SINGLE_SCALE but using a constraint. */
1034 if (td->flag & TD_SINGLE_SCALE) {
1035 *td->val = td->ival;
1036 }
1037
1038 td_ext->scale[0] = td_ext->iscale[0] * (1 + (fscale[0] - 1) * td->factor);
1039 td_ext->scale[1] = td_ext->iscale[1] * (1 + (fscale[1] - 1) * td->factor);
1040 td_ext->scale[2] = td_ext->iscale[2] * (1 + (fscale[2] - 1) * td->factor);
1041 }
1042 }
1043
1044 constraintScaleLim(t, tc, td_index);
1045 }
1046 }
1047
1048 /* For individual element center, Editmode need to use iloc. */
1049 if (t->flag & T_POINTS) {
1050 sub_v3_v3v3(vec, td->iloc, center);
1051 }
1052 else {
1053 sub_v3_v3v3(vec, td->center, center);
1054 }
1055
1056 mul_m3_v3(tmat, vec);
1057
1058 add_v3_v3(vec, center);
1059 if (t->flag & T_POINTS) {
1060 sub_v3_v3(vec, td->iloc);
1061 }
1062 else {
1063 sub_v3_v3(vec, td->center);
1064 }
1065
1066 /* Grease pencil falloff.
1067 *
1068 * FIXME: This is bad on multiple levels!
1069 *
1070 * - #applyNumInput is not intended to be run for every element,
1071 * this writes back into the number input in a way that doesn't make sense to run many times.
1072 *
1073 * - Writing into #TransInfo should be avoided since it means order of operations
1074 * may impact the result and isn't thread-safe.
1075 *
1076 * Operating on copies as a temporary solution.
1077 */
1078 if (t->options & CTX_GPENCIL_STROKES) {
1079 const float *gp_falloff_ptr = static_cast<const float *>(td->extra);
1080 const float gp_falloff = gp_falloff_ptr != nullptr ? *gp_falloff_ptr : 1.0f;
1081 mul_v3_fl(vec, td->factor * gp_falloff);
1082
1083 /* Scale stroke thickness. */
1084 if (td->val) {
1085 NumInput num_evil = t->num;
1086 float values_final_evil[4];
1087 copy_v4_v4(values_final_evil, t->values_final);
1088 transform_snap_increment(t, values_final_evil);
1089 applyNumInput(&num_evil, values_final_evil);
1090
1091 float ratio = values_final_evil[0];
1092 float transformed_value = td->ival * fabs(ratio);
1093 *td->val = math::max(math::interpolate(td->ival, transformed_value, gp_falloff), 0.001f);
1094 }
1095 }
1096 else {
1097 mul_v3_fl(vec, td->factor);
1098 }
1099
1100 if (t->options & (CTX_OBJECT | CTX_POSE_BONE)) {
1101 if (t->options & CTX_POSE_BONE) {
1102 /* Without this, the resulting location of scaled bones aren't correct,
1103 * especially noticeable scaling root or disconnected bones around the cursor, see #92515. */
1104 mul_mat3_m4_v3(tc->poseobj->object_to_world().ptr(), vec);
1105 }
1106 mul_m3_v3(td->smtx, vec);
1107 }
1108
1110 if (td->loc) {
1111 add_v3_v3v3(td->loc, td->iloc, vec);
1112 }
1113
1114 constraintTransLim(t, tc, td);
1115}
1116
1118
1119/* -------------------------------------------------------------------- */
1122
1123static TransModeInfo *mode_info_get(TransInfo *t, const int mode)
1124{
1125 switch (mode) {
1126 case TFM_TRANSLATION:
1127 return &TransMode_translate;
1128 case TFM_ROTATION:
1129 return &TransMode_rotate;
1130 case TFM_RESIZE:
1131 return &TransMode_resize;
1132 case TFM_SKIN_RESIZE:
1133 return &TransMode_skinresize;
1134 case TFM_TOSPHERE:
1135 return &TransMode_tosphere;
1136 case TFM_SHEAR:
1137 return &TransMode_shear;
1138 case TFM_BEND:
1139 return &TransMode_bend;
1140 case TFM_SHRINKFATTEN:
1141 return &TransMode_shrinkfatten;
1142 case TFM_TILT:
1143 return &TransMode_tilt;
1148 case TFM_TRACKBALL:
1149 return &TransMode_trackball;
1150 case TFM_PUSHPULL:
1151 return &TransMode_pushpull;
1152 case TFM_EDGE_CREASE:
1153 return &TransMode_edgecrease;
1154 case TFM_VERT_CREASE:
1155 return &TransMode_vertcrease;
1156 case TFM_BONESIZE:
1157 return &TransMode_bboneresize;
1158 case TFM_BONE_ENVELOPE:
1160 return &TransMode_boneenvelope;
1161 case TFM_EDGE_SLIDE:
1162 return &TransMode_edgeslide;
1163 case TFM_VERT_SLIDE:
1164 return &TransMode_vertslide;
1165 case TFM_BONE_ROLL:
1166 return &TransMode_boneroll;
1167 case TFM_TIME_TRANSLATE:
1169 case TFM_TIME_SLIDE:
1170 return &TransMode_timeslide;
1171 case TFM_TIME_SCALE:
1172 return &TransMode_timescale;
1173 case TFM_TIME_EXTEND:
1174 /* Do TFM_TIME_TRANSLATE (for most Animation Editors because they have only 1D transforms for
1175 * time values) or TFM_TRANSLATION (for Graph/NLA Editors only since they uses 'standard'
1176 * transforms to get 2D movement) depending on which editor this was called from. */
1177 if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
1178 return &TransMode_translate;
1179 }
1181 case TFM_MIRROR:
1182 return &TransMode_mirror;
1183 case TFM_BWEIGHT:
1184 return &TransMode_bevelweight;
1185 case TFM_ALIGN:
1186 return &TransMode_align;
1187 case TFM_SEQ_SLIDE:
1188 return &TransMode_seqslide;
1190 return &TransMode_rotatenormal;
1192 return &TransMode_gpopacity;
1193 }
1194 return nullptr;
1195}
1196
1197void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
1198{
1199 t->mode = eTfmMode(mode);
1200 t->mode_info = mode_info_get(t, mode);
1201
1202 if (t->mode_info) {
1203 t->flag |= eTFlag(t->mode_info->flags);
1204 t->mode_info->init_fn(t, op);
1205 }
1206
1207 if (t->data_type == &TransConvertType_Mesh) {
1208 /* Init Custom Data correction.
1209 * Ideally this should be called when creating the TransData. */
1211 }
1212
1214
1215 /* TODO(@mano-wii): Some of these operations change the `t->mode`.
1216 * This can be bad for Redo. */
1217 // BLI_assert(t->mode == mode);
1218}
1219
1221{
1222 /* Currently only these types are supported. */
1224
1226 return;
1227 }
1228
1229 if (!(t->flag & T_MODAL)) {
1230 return;
1231 }
1232
1233 if (t->orient[O_DEFAULT].type == type) {
1234 return;
1235 }
1236
1237 View3D *v3d = nullptr;
1238 RegionView3D *rv3d = nullptr;
1239 if ((type == V3D_ORIENT_VIEW) && (t->spacetype == SPACE_VIEW3D) && t->region &&
1241 {
1242 v3d = static_cast<View3D *>(t->view);
1243 rv3d = static_cast<RegionView3D *>(t->region->regiondata);
1244 }
1245
1247 t->scene,
1248 t->view_layer,
1249 v3d,
1250 rv3d,
1251 nullptr,
1252 nullptr,
1253 type,
1255 t->orient[O_DEFAULT].matrix);
1256
1257 if (t->orient_curr == O_DEFAULT) {
1258 /* Update Orientation. */
1260 }
1261}
1262
1264{
1265 if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
1266 t->con.applyRot(t, nullptr, nullptr, r_axis);
1267 }
1268 else {
1269 r_axis = t->spacemtx[t->orient_axis];
1270 /* For unconstrained rotation in the 3D viewport and UV editor, flip the axis so the rotation
1271 * direction matches the mouse movement in view space. */
1272 if ((t->mode == TFM_ROTATION) && (t->con.mode & CON_APPLY) == 0 &&
1274 {
1275 r_axis = -r_axis;
1276 }
1277 }
1278}
1279
1281{
1282 float view_vector[3];
1283 view_vector_calc(t, t->center_global, view_vector);
1284 return dot_v3v3(axis, view_vector) > 0.0f;
1285}
1286
1288{
1290 if (tc->custom.mode.data) {
1291 return tc;
1292 }
1293 }
1294 BLI_assert_msg(0, "Should never happen, at least one container must have valid data");
1295 return nullptr;
1296}
1297
1299
1300} // namespace blender::ed::transform
#define CTX_DATA_COUNT(C, member)
#define RAD2DEGF(_rad)
#define mul_m3_series(...)
#define IFACE_(msgid)
#define NUM_STR_REP_LEN
#define C
Definition RandGen.cpp:29
#define ELEM(...)
#define IS_EQF(a, b)
#define BLI_assert_msg(a, msg)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define str(s)
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
TransDataContainer * transform_mode_container_first_ok(TransInfo *t)
TransConvertTypeInfo TransConvertType_Pose
TransConvertTypeInfo TransConvertType_Mesh
static void protectedAxisAngleBits(short protectflag, float axis[3], float *angle, const float oldAxis[3], float oldAngle)
TransConvertTypeInfo TransConvertType_Sculpt
bool transform_mode_is_changeable(const int mode)
static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
bool transform_snap_increment(const TransInfo *t, float *r_val)
bool transform_mode_is_axis_pointing_to_screen(const TransInfo *t, const float3 &axis)
void protectedTransBits(short protectflag, float vec[3])
void protectedScaleBits(short protectflag, float scale[3])
void view_vector_calc(const TransInfo *t, const float focus[3], float r_vec[3])
static void constraintob_from_transdata(bConstraintOb *cob, TransDataExtension *td_ext)
void headerRotation(TransInfo *t, char *str, const int str_maxncpy, float final)
void transform_convert_mesh_customdatacorrect_init(TransInfo *t)
void ElementRotation_ex(const TransInfo *t, const TransDataContainer *tc, TransData *td, TransDataExtension *td_ext, const float mat[3][3], const float *center)
static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
void transform_mode_default_modal_orientation_set(TransInfo *t, int type)
eTfmMode transform_mode_really_used(bContext *C, eTfmMode mode)
void transform_gizmo_3d_model_from_constraint_and_mode_set(TransInfo *t)
short calc_orientation_from_type_ex(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d, const RegionView3D *rv3d, Object *ob, Object *obedit, short orientation_index, int pivot_point, float r_mat[3][3])
void constraintScaleLim(const TransInfo *t, const TransDataContainer *tc, int td_index)
bool transform_mode_affect_only_locations(const TransInfo *t)
static TransModeInfo * mode_info_get(TransInfo *t, const int mode)
void ElementRotation(const TransInfo *t, const TransDataContainer *tc, TransData *td, TransDataExtension *td_ext, const float mat[3][3], const short around)
void constraintTransLim(const TransInfo *t, const TransDataContainer *tc, TransData *td)
TransConvertTypeInfo TransConvertType_Object
bool transdata_check_local_center(const TransInfo *t, short around)
void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
void headerResize(TransInfo *t, const float vec[3], char *str, const int str_maxncpy)
void ElementResize(const TransInfo *t, const TransDataContainer *tc, int td_index, const float mat[3][3])
void transform_mode_rotation_axis_get(const TransInfo *t, float3 &r_axis)
static void constraintRotLim(const TransInfo *, TransData *td, TransDataExtension *td_ext)
static void TransMat3ToSize(const float mat[3][3], const float smat[3][3], float size[3])
void transform_orientations_current_set(TransInfo *t, const short orient_index)
T interpolate(const T &a, const T &b, const FactorT &t)
T max(const T &a, const T &b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void mul_m3_v3(const float M[3][3], float r[3])
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void axis_angle_to_eulO(float eul[3], short order, const float axis[3], float angle)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void mat4_to_quat(float q[4], const float mat[4][4])
const bConstraintTypeInfo * BKE_constraint_typeinfo_from_type(int type)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_LOCAL_ORIGINS
void quat_to_eul(float eul[3], const float quat[4])
void mat3_to_compatible_eulO(float eul[3], const float oldrot[3], short order, const float mat[3][3])
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
bool hasNumInput(const NumInput *n)
Definition numinput.cc:188
void axis_angle_to_mat4(float R[4][4], const float axis[3], float angle)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void sub_eul_euleul(float r_eul[3], float a[3], float b[3], short order)
ViewLayer * CTX_data_view_layer(const bContext *C)
void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE bool is_zero_v4(const float v[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3(float r[3], const float a[3])
void eulO_to_mat3(float M[3][3], const float e[3], short order)
void add_eul_euleul(float r_eul[3], float a[3], float b[3], short order)
void quat_to_mat3(float m[3][3], const float q[4])
void size_to_mat4(float R[4][4], const float size[3])
void BKE_constraint_custom_object_space_init(struct bConstraintOb *cob, struct bConstraint *con)
MINLINE void mul_v3_v3(float r[3], const float a[3])
void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], short order)
bool BKE_constraint_has_influence(const struct bConstraint *con)
BMesh const char void * data
MINLINE float signf(float f)
void eul_to_quat(float quat[4], const float eul[3])
void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void unit_m4(float m[4][4])
void mat4_to_eulO(float eul[3], short order, const float m[4][4])
void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *ob, ListBaseT< bConstraintTarget > *targets, float ctime)
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:207
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void mat4_to_size(float size[3], const float M[4][4])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mat4_to_axis_angle(float axis[3], float *angle, const float mat[4][4])
void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], float t)
Main * CTX_data_main(const bContext *C)
void unit_m3(float m[3][3])
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:104
void eulO_to_mat4(float mat[4][4], const float e[3], short order)
Scene * CTX_data_scene(const bContext *C)
void invert_qt_qt_normalized(float q1[4], const float q2[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
VecBase< float, 3 > float3
void mat3_to_size(float size[3], const float M[3][3])
size_t BLI_snprintf_utf8_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mul_qt_fl(float q[4], float f)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void mat3_to_quat(float q[4], const float mat[3][3])
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
void quat_to_mat4(float m[4][4], const float q[4])
float normalize_qt_qt(float r[4], const float q[4])
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eRegion_Type regiontype
struct UnitSettings unit
struct RenderData r
void(*) evaluate_constraint(struct bConstraint *con, struct bConstraintOb *cob, ListBaseT< bConstraintTarget > *targets)
eBConstraint_SpaceTypes ownspace
struct bConstraint * next
void(*) applySize(const TransInfo *t, const TransDataContainer *tc, const TransData *td, float r_smat[3][3])
Definition transform.hh:612
void(*) applyRot(const TransInfo *t, const TransDataContainer *tc, const TransData *td, float r_axis[3])
Definition transform.hh:617
struct blender::ed::transform::TransInfo::@074260112357037217233016050204226071352346123342 orient[3]
TransConvertTypeInfo * data_type
Definition transform.hh:836
void(*) init_fn(TransInfo *, wmOperator *)
#define T_PROP_EDIT_ALL
Definition transform.hh:34
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:48
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.