2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edtransform
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
#include "DNA_gpencil_types.h"
|
2009-03-06 15:50:15 +00:00
|
|
|
|
2012-03-24 01:24:58 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_math.h"
|
2012-03-24 01:24:58 +00:00
|
|
|
#include "BLI_rand.h"
|
|
|
|
|
|
2018-06-12 17:00:07 +02:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-02-19 15:45:56 +00:00
|
|
|
|
2009-03-06 15:50:15 +00:00
|
|
|
#include "RNA_access.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2017-01-26 12:13:50 -02:00
|
|
|
#include "GPU_immediate.h"
|
2017-03-21 17:49:21 -04:00
|
|
|
#include "GPU_matrix.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_layer.h"
|
|
|
|
|
#include "BKE_mask.h"
|
2021-02-10 12:27:01 -03:00
|
|
|
#include "BKE_modifier.h"
|
2014-07-21 12:02:05 +02:00
|
|
|
#include "BKE_paint.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2021-10-07 12:32:04 +11:00
|
|
|
#include "SEQ_transform.h"
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_clip.h"
|
2009-01-28 21:43:43 +00:00
|
|
|
#include "ED_image.h"
|
2015-02-23 23:05:54 +11:00
|
|
|
#include "ED_object.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_screen.h"
|
2009-01-10 18:33:16 +00:00
|
|
|
#include "ED_space_api.h"
|
2009-01-28 21:43:43 +00:00
|
|
|
#include "ED_uvedit.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-12-07 18:10:11 +00:00
|
|
|
#include "WM_api.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "WM_types.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2009-01-10 18:33:16 +00:00
|
|
|
#include "UI_resources.h"
|
2014-07-21 12:02:05 +02:00
|
|
|
#include "UI_view2d.h"
|
2009-01-10 18:33:16 +00:00
|
|
|
|
2021-09-21 09:38:30 +02:00
|
|
|
#include "SEQ_sequencer.h"
|
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include "transform.h"
|
2021-08-17 16:53:29 -03:00
|
|
|
#include "transform_convert.h"
|
2020-02-14 08:42:17 -03:00
|
|
|
#include "transform_mode.h"
|
2020-10-08 11:42:14 -03:00
|
|
|
#include "transform_orientations.h"
|
2019-10-29 00:45:05 +11:00
|
|
|
#include "transform_snap.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
|
/* ************************** GENERICS **************************** */
|
|
|
|
|
|
2012-08-05 20:40:26 +00:00
|
|
|
void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2021-10-08 12:09:27 +02:00
|
|
|
if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_SEQ)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
float v1[3], v2[3], v3[3];
|
2020-04-03 16:21:24 +11:00
|
|
|
uchar col[3], col2[3];
|
2009-07-12 02:01:13 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
2009-01-10 18:33:16 +00:00
|
|
|
View3D *v3d = t->view;
|
2018-05-13 06:44:03 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(v3, dir);
|
2019-02-16 12:21:44 +11:00
|
|
|
mul_v3_fl(v3, v3d->clip_end);
|
2018-05-13 06:44:03 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(v2, center, v3);
|
|
|
|
|
add_v3_v3v3(v1, center, v3);
|
2021-10-08 12:09:27 +02:00
|
|
|
}
|
|
|
|
|
else if (t->spacetype == SPACE_SEQ) {
|
|
|
|
|
View2D *v2d = t->view;
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(v3, dir);
|
|
|
|
|
float max_dist = max_ff(BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur));
|
|
|
|
|
mul_v3_fl(v3, max_dist);
|
|
|
|
|
|
|
|
|
|
sub_v3_v3v3(v2, center, v3);
|
|
|
|
|
add_v3_v3v3(v1, center, v3);
|
|
|
|
|
}
|
2018-05-13 06:44:03 +02:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
GPU_matrix_push();
|
2017-01-26 12:13:50 -02:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
if (options & DRAWLIGHT) {
|
|
|
|
|
col[0] = col[1] = col[2] = 220;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColor3ubv(TH_GRID, col);
|
|
|
|
|
}
|
|
|
|
|
UI_make_axis_color(col, col2, axis);
|
2017-01-26 12:13:50 -02:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
2017-01-26 12:13:50 -02:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
|
|
|
|
immUniformColor3ubv(col2);
|
2017-01-26 12:13:50 -02:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
|
|
|
|
immVertex3fv(pos, v1);
|
|
|
|
|
immVertex3fv(pos, v2);
|
|
|
|
|
immEnd();
|
2017-01-26 12:13:50 -02:00
|
|
|
|
2021-10-08 12:09:27 +02:00
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
|
|
GPU_matrix_pop();
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-24 15:15:01 +00:00
|
|
|
void resetTransModal(TransInfo *t)
|
|
|
|
|
{
|
2018-04-26 10:08:41 +02:00
|
|
|
freeTransCustomDataForMode(t);
|
2013-04-24 15:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
void resetTransRestrictions(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
t->flag &= ~T_ALL_RESTRICTIONS;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 13:09:02 -03:00
|
|
|
static void *t_view_get(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
View3D *v3d = t->area->spacedata.first;
|
|
|
|
|
return (void *)v3d;
|
|
|
|
|
}
|
2021-11-19 23:48:51 -05:00
|
|
|
if (t->region) {
|
2021-11-16 13:09:02 -03:00
|
|
|
return (void *)&t->region->v2d;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int t_around_get(TransInfo *t)
|
|
|
|
|
{
|
2021-11-16 13:50:05 -03:00
|
|
|
if (t->flag & T_OVERRIDE_CENTER) {
|
|
|
|
|
/* Avoid initialization of individual origins (#V3D_AROUND_LOCAL_ORIGINS). */
|
|
|
|
|
return V3D_AROUND_CENTER_BOUNDS;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 13:09:02 -03:00
|
|
|
ScrArea *area = t->area;
|
2021-11-23 10:13:31 -03:00
|
|
|
switch (t->spacetype) {
|
|
|
|
|
case SPACE_VIEW3D: {
|
|
|
|
|
if (t->mode == TFM_BEND) {
|
|
|
|
|
/* Bend always uses the cursor. */
|
|
|
|
|
return V3D_AROUND_CURSOR;
|
|
|
|
|
}
|
2021-11-16 13:09:02 -03:00
|
|
|
return t->settings->transform_pivot_point;
|
|
|
|
|
}
|
2021-11-23 10:13:31 -03:00
|
|
|
case SPACE_IMAGE: {
|
|
|
|
|
SpaceImage *sima = area->spacedata.first;
|
|
|
|
|
return sima->around;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_GRAPH: {
|
|
|
|
|
SpaceGraph *sipo = area->spacedata.first;
|
|
|
|
|
return sipo->around;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_CLIP: {
|
|
|
|
|
SpaceClip *sclip = area->spacedata.first;
|
|
|
|
|
return sclip->around;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_SEQ: {
|
|
|
|
|
if (t->region->regiontype == RGN_TYPE_PREVIEW) {
|
|
|
|
|
return SEQ_tool_settings_pivot_point_get(t->scene);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2021-11-16 13:09:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return V3D_AROUND_CENTER_BOUNDS;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 07:49:49 +11:00
|
|
|
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
|
Scene *sce = CTX_data_scene(C);
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2019-11-09 16:12:27 -03:00
|
|
|
Object *obact = OBACT(view_layer);
|
|
|
|
|
const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT;
|
2009-06-23 00:41:55 +00:00
|
|
|
ToolSettings *ts = CTX_data_tool_settings(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
bGPdata *gpd = CTX_data_gpencil_data(C);
|
2013-06-16 04:37:39 +00:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-02 18:00:52 +10:00
|
|
|
t->mbus = CTX_wm_message_bus(C);
|
2019-07-25 16:36:22 +02:00
|
|
|
t->depsgraph = CTX_data_depsgraph_pointer(C);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
t->scene = sce;
|
2017-11-23 13:51:49 -02:00
|
|
|
t->view_layer = view_layer;
|
2020-04-03 13:25:03 +02:00
|
|
|
t->area = area;
|
2020-03-06 16:56:42 +01:00
|
|
|
t->region = region;
|
2009-06-23 00:41:55 +00:00
|
|
|
t->settings = ts;
|
2013-08-20 06:04:46 +00:00
|
|
|
t->reports = op ? op->reports : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
t->helpline = HLP_NONE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
t->flag = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-16 13:45:27 -03:00
|
|
|
if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) &&
|
|
|
|
|
ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) {
|
2019-11-09 16:12:27 -03:00
|
|
|
t->obedit_type = obact->type;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t->obedit_type = -1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-03-09 17:18:31 +11:00
|
|
|
if (t->options & CTX_CURSOR) {
|
|
|
|
|
/* Cursor should always use the drag start as the combination of click-drag to place & move
|
|
|
|
|
* doesn't work well if the click location isn't used when transforming. */
|
|
|
|
|
t->flag |= T_EVENT_DRAG_START;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
/* Many kinds of transform only use a single handle. */
|
|
|
|
|
if (t->data_container == NULL) {
|
|
|
|
|
t->data_container = MEM_callocN(sizeof(*t->data_container), __func__);
|
|
|
|
|
t->data_container_len = 1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-23 06:48:36 +00:00
|
|
|
t->redraw = TREDRAW_HARD; /* redraw first time */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-27 16:42:34 -03:00
|
|
|
int mval[2];
|
|
|
|
|
if (event) {
|
2022-03-09 08:36:36 +11:00
|
|
|
if (t->flag & T_EVENT_DRAG_START) {
|
|
|
|
|
WM_event_drag_start_mval(event, region, mval);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v2_v2_int(mval, event->mval);
|
|
|
|
|
}
|
2020-02-27 16:42:34 -03:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
zero_v2_int(mval);
|
|
|
|
|
}
|
|
|
|
|
copy_v2_v2_int(t->mval, mval);
|
|
|
|
|
copy_v2_v2_int(t->mouse.imval, mval);
|
|
|
|
|
copy_v2_v2_int(t->con.imval, mval);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
t->transform = NULL;
|
|
|
|
|
t->handleEvent = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
t->data_len_all = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-26 16:19:39 +10:00
|
|
|
zero_v3(t->center_global);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m3(t->mat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-28 02:30:26 +11:00
|
|
|
/* Default to rotate on the Z axis. */
|
|
|
|
|
t->orient_axis = 2;
|
|
|
|
|
t->orient_axis_ortho = 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-27 16:15:34 +00:00
|
|
|
/* if there's an event, we're modal */
|
|
|
|
|
if (event) {
|
|
|
|
|
t->flag |= T_MODAL;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-01-09 20:42:35 +00:00
|
|
|
/* Crease needs edge flag */
|
Subdivision: add support for vertex creasing
This adds vertex creasing support for OpenSubDiv for modeling, rendering,
Alembic and USD I/O.
For modeling, vertex creasing follows the edge creasing implementation with an
operator accessible through the Vertex menu in Edit Mode, and some parameter in
the properties panel. The option in the Subsurf and Multires to use edge
creasing also affects vertex creasing.
The vertex crease data is stored as a CustomData layer, unlike edge creases
which for now are stored in `MEdge`, but will in the future also be moved to
a `CustomData` layer. See comments for details on the difference in behavior
for the `CD_CREASE` layer between egdes and vertices.
For Cycles this adds sockets on the Mesh node to hold data about which vertices
are creased (one socket for the indices, one for the weigths).
Viewport rendering of vertex creasing reuses the same color scheme as for edges
and creased vertices are drawn bigger than uncreased vertices.
For Alembic and USD, vertex crease support follows the edge crease
implementation, they are always read, but only exported if a `Subsurf` modifier
is present on the Mesh.
Reviewed By: brecht, fclem, sergey, sybren, campbellbarton
Differential Revision: https://developer.blender.org/D10145
2022-01-20 12:20:30 +01:00
|
|
|
if (ELEM(t->mode, TFM_EDGE_CREASE, TFM_BWEIGHT)) {
|
2021-02-05 11:56:43 -03:00
|
|
|
t->options |= CTX_EDGE_DATA;
|
2010-01-09 20:42:35 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-17 13:07:48 +00:00
|
|
|
t->remove_on_cancel = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-17 16:12:05 +00:00
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "remove_on_cancel")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop)) {
|
2013-09-17 13:07:48 +00:00
|
|
|
if (RNA_property_boolean_get(op->ptr, prop)) {
|
|
|
|
|
t->remove_on_cancel = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
/* GPencil editing context */
|
2018-09-18 22:36:39 +02:00
|
|
|
if (GPENCIL_EDIT_MODE(gpd)) {
|
2015-12-13 21:03:13 +13:00
|
|
|
t->options |= CTX_GPENCIL_STROKES;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-19 04:19:09 +00:00
|
|
|
/* Assign the space type, some exceptions for running in different mode */
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area == NULL) {
|
2011-04-19 04:19:09 +00:00
|
|
|
/* background mode */
|
2012-06-10 19:59:02 +00:00
|
|
|
t->spacetype = SPACE_EMPTY;
|
2011-04-19 04:19:09 +00:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
else if ((region == NULL) && (area->spacetype == SPACE_VIEW3D)) {
|
2011-04-19 04:19:09 +00:00
|
|
|
/* running in the text editor */
|
2012-06-10 19:59:02 +00:00
|
|
|
t->spacetype = SPACE_EMPTY;
|
2011-04-19 04:19:09 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* normal operation */
|
2020-04-03 13:25:03 +02:00
|
|
|
t->spacetype = area->spacetype;
|
2011-04-19 04:19:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-05-25 15:45:56 +10:00
|
|
|
/* handle T_ALT_TRANSFORM initialization, we may use for different operators */
|
|
|
|
|
if (op) {
|
|
|
|
|
const char *prop_id = NULL;
|
|
|
|
|
if (t->mode == TFM_SHRINKFATTEN) {
|
|
|
|
|
prop_id = "use_even_offset";
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-24 21:19:38 +02:00
|
|
|
if (prop_id && (prop = RNA_struct_find_property(op->ptr, prop_id))) {
|
2019-01-03 15:13:46 +11:00
|
|
|
SET_FLAG_FROM_TEST(t->flag, RNA_property_boolean_get(op->ptr, prop), T_ALT_TRANSFORM);
|
2015-05-25 15:45:56 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
2012-05-25 12:56:29 +00:00
|
|
|
bScreen *animscreen = ED_screen_animation_playing(CTX_wm_manager(C));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
t->animtimer = (animscreen) ? animscreen->animtimer : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-13 06:37:36 +02:00
|
|
|
if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) {
|
|
|
|
|
t->flag |= T_V3D_ALIGN;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
if (object_mode & OB_MODE_ALL_PAINT) {
|
2014-07-21 12:02:05 +02:00
|
|
|
Paint *p = BKE_paint_get_active_from_context(C);
|
|
|
|
|
if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
|
|
|
|
|
t->options |= CTX_PAINT_CURVE;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-03 08:02:32 +00:00
|
|
|
/* initialize UV transform from */
|
2013-06-16 04:37:39 +00:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "correct_uv")))) {
|
|
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
if (RNA_property_boolean_get(op->ptr, prop)) {
|
2020-07-01 17:45:27 +10:00
|
|
|
t->settings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT_SLIDE;
|
2011-08-03 08:02:32 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2020-07-01 17:45:27 +10:00
|
|
|
t->settings->uvcalc_flag &= ~UVCALC_TRANSFORM_CORRECT_SLIDE;
|
2011-08-03 08:02:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-08-03 08:02:32 +00:00
|
|
|
else {
|
2015-02-19 12:33:14 +11:00
|
|
|
RNA_property_boolean_set(
|
2020-07-01 17:45:27 +10:00
|
|
|
op->ptr, prop, (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_SLIDE) != 0);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-06-10 19:59:02 +00:00
|
|
|
else if (t->spacetype == SPACE_IMAGE) {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceImage *sima = area->spacedata.first;
|
2018-04-16 16:27:55 +02:00
|
|
|
if (ED_space_image_show_uvedit(sima, OBACT(t->view_layer))) {
|
2012-07-25 16:03:08 +00:00
|
|
|
/* UV transform */
|
|
|
|
|
}
|
|
|
|
|
else if (sima->mode == SI_MODE_MASK) {
|
|
|
|
|
t->options |= CTX_MASK;
|
|
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
else if (sima->mode == SI_MODE_PAINT) {
|
|
|
|
|
Paint *p = &sce->toolsettings->imapaint.paint;
|
|
|
|
|
if (p->brush && (p->brush->flag & BRUSH_CURVE)) {
|
|
|
|
|
t->options |= CTX_PAINT_CURVE;
|
2012-07-25 16:03:08 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
/* image not in uv edit, nor in mask mode, can happen for some tools */
|
2011-05-02 05:24:59 +00:00
|
|
|
}
|
2012-06-10 19:59:02 +00:00
|
|
|
else if (t->spacetype == SPACE_CLIP) {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceClip *sclip = area->spacedata.first;
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ED_space_clip_check_show_trackedit(sclip)) {
|
2012-05-30 07:38:33 +00:00
|
|
|
t->options |= CTX_MOVIECLIP;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else if (ED_space_clip_check_show_maskedit(sclip)) {
|
2012-06-04 16:42:58 +00:00
|
|
|
t->options |= CTX_MASK;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-05-30 07:38:33 +00:00
|
|
|
}
|
2021-09-21 09:38:30 +02:00
|
|
|
else if (t->spacetype == SPACE_SEQ && region->regiontype == RGN_TYPE_PREVIEW) {
|
|
|
|
|
t->options |= CTX_SEQUENCER_IMAGE;
|
|
|
|
|
}
|
2021-11-16 13:09:02 -03:00
|
|
|
|
2021-11-16 13:50:05 -03:00
|
|
|
setTransformViewAspect(t, t->aspect);
|
|
|
|
|
|
|
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
RNA_property_float_get_array(op->ptr, prop, t->center_global);
|
|
|
|
|
mul_v3_v3(t->center_global, t->aspect);
|
|
|
|
|
t->flag |= T_OVERRIDE_CENTER;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 13:09:02 -03:00
|
|
|
t->view = t_view_get(t);
|
|
|
|
|
t->around = t_around_get(t);
|
|
|
|
|
|
|
|
|
|
/* Exceptional case. */
|
|
|
|
|
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
|
|
|
|
|
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
|
|
|
|
|
const bool use_island = transdata_check_local_islands(t, t->around);
|
|
|
|
|
|
|
|
|
|
if ((t->obedit_type != -1) && !use_island) {
|
|
|
|
|
t->options |= CTX_NO_PET;
|
|
|
|
|
}
|
2011-05-18 09:58:17 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-07 16:51:30 -03:00
|
|
|
bool t_values_set_is_array = false;
|
2020-09-24 19:16:41 -03:00
|
|
|
|
2020-05-07 16:51:30 -03:00
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "value")) &&
|
2020-04-29 08:07:25 -03:00
|
|
|
RNA_property_is_set(op->ptr, prop)) {
|
2021-06-24 15:56:58 +10:00
|
|
|
float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory. */
|
2020-05-07 16:51:30 -03:00
|
|
|
if (RNA_property_array_check(prop)) {
|
2021-12-08 13:56:13 -03:00
|
|
|
RNA_property_float_get_array(op->ptr, prop, values);
|
2020-05-07 16:51:30 -03:00
|
|
|
t_values_set_is_array = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2021-12-08 13:56:13 -03:00
|
|
|
values[0] = RNA_property_float_get(op->ptr, prop);
|
2020-05-07 16:51:30 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-07 16:51:30 -03:00
|
|
|
if (t->flag & T_MODAL) {
|
|
|
|
|
/* Run before init functions so 'values_modal_offset' can be applied on mouse input. */
|
|
|
|
|
copy_v4_v4(t->values_modal_offset, values);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v4_v4(t->values, values);
|
|
|
|
|
t->flag |= T_INPUT_IS_VALUES_FINAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
|
|
|
|
|
bool constraint_axis[3] = {false, false, false};
|
2021-02-27 17:10:18 -03:00
|
|
|
if (t_values_set_is_array && t->flag & T_INPUT_IS_VALUES_FINAL) {
|
|
|
|
|
/* For operators whose `t->values` is array (as Move and Scale), set constraint so that the
|
|
|
|
|
* orientation is more intuitive in the Redo Panel. */
|
|
|
|
|
constraint_axis[0] = constraint_axis[1] = constraint_axis[2] = true;
|
2020-05-07 16:51:30 -03:00
|
|
|
}
|
2020-09-24 19:16:41 -03:00
|
|
|
else if (RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
|
|
|
|
|
}
|
2020-04-29 08:07:25 -03:00
|
|
|
|
|
|
|
|
if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
|
|
|
|
|
t->con.mode |= CON_APPLY;
|
|
|
|
|
|
|
|
|
|
if (constraint_axis[0]) {
|
|
|
|
|
t->con.mode |= CON_AXIS0;
|
|
|
|
|
}
|
|
|
|
|
if (constraint_axis[1]) {
|
|
|
|
|
t->con.mode |= CON_AXIS1;
|
|
|
|
|
}
|
|
|
|
|
if (constraint_axis[2]) {
|
|
|
|
|
t->con.mode |= CON_AXIS2;
|
|
|
|
|
}
|
2018-11-01 07:24:10 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-04-29 08:07:25 -03:00
|
|
|
|
|
|
|
|
{
|
2020-09-24 19:16:41 -03:00
|
|
|
short orient_types[3];
|
|
|
|
|
float custom_matrix[3][3];
|
|
|
|
|
|
2021-04-09 16:01:53 -03:00
|
|
|
int orient_type_scene = V3D_ORIENT_GLOBAL;
|
|
|
|
|
int orient_type_default = -1;
|
|
|
|
|
int orient_type_set = -1;
|
|
|
|
|
int orient_type_matrix_set = -1;
|
2020-05-30 18:11:36 -03:00
|
|
|
|
|
|
|
|
if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
|
|
|
|
|
TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT];
|
|
|
|
|
orient_type_scene = orient_slot->type;
|
|
|
|
|
if (orient_type_scene == V3D_ORIENT_CUSTOM) {
|
|
|
|
|
const int index_custom = orient_slot->index_custom;
|
|
|
|
|
orient_type_scene += index_custom;
|
|
|
|
|
}
|
2020-05-11 15:10:50 -03:00
|
|
|
}
|
|
|
|
|
|
2021-04-09 16:01:53 -03:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop))) {
|
|
|
|
|
orient_type_set = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
|
if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
|
|
|
|
|
orient_type_set = V3D_ORIENT_GLOBAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-18 09:33:54 -03:00
|
|
|
|
2021-02-04 10:43:57 -03:00
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
|
|
|
|
|
t->orient_axis = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 08:07:25 -03:00
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
|
|
|
|
|
t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-09 16:01:53 -03:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
|
2020-04-29 08:07:25 -03:00
|
|
|
RNA_property_is_set(op->ptr, prop))) {
|
2021-04-09 16:01:53 -03:00
|
|
|
RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
|
|
|
|
|
|
|
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop);
|
|
|
|
|
}
|
|
|
|
|
else if (orient_type_set == -1) {
|
|
|
|
|
orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
|
2020-05-12 15:44:08 -03:00
|
|
|
}
|
2021-04-09 16:01:53 -03:00
|
|
|
}
|
2020-05-12 15:44:08 -03:00
|
|
|
|
2021-11-26 10:45:28 -03:00
|
|
|
orient_type_default = orient_type_scene;
|
|
|
|
|
|
2021-04-09 16:01:53 -03:00
|
|
|
if (orient_type_set != -1) {
|
2021-11-26 10:45:28 -03:00
|
|
|
if (!(t->con.mode & CON_APPLY)) {
|
|
|
|
|
/* Only overwrite default if not constrained. */
|
|
|
|
|
orient_type_default = orient_type_set;
|
|
|
|
|
t->is_orient_default_overwrite = true;
|
|
|
|
|
}
|
2020-09-24 19:16:41 -03:00
|
|
|
}
|
2021-04-09 16:01:53 -03:00
|
|
|
else if (orient_type_matrix_set != -1) {
|
2021-11-26 10:45:28 -03:00
|
|
|
orient_type_set = orient_type_matrix_set;
|
|
|
|
|
if (!(t->con.mode & CON_APPLY)) {
|
|
|
|
|
/* Only overwrite default if not constrained. */
|
|
|
|
|
orient_type_default = orient_type_set;
|
|
|
|
|
t->is_orient_default_overwrite = true;
|
|
|
|
|
}
|
2021-04-09 16:01:53 -03:00
|
|
|
}
|
2020-09-24 19:16:41 -03:00
|
|
|
else if (t->con.mode & CON_APPLY) {
|
2021-11-26 10:45:28 -03:00
|
|
|
orient_type_set = orient_type_scene;
|
|
|
|
|
}
|
|
|
|
|
else if (orient_type_scene == V3D_ORIENT_GLOBAL) {
|
|
|
|
|
orient_type_set = V3D_ORIENT_LOCAL;
|
2020-05-12 15:44:08 -03:00
|
|
|
}
|
|
|
|
|
else {
|
2021-11-26 10:45:28 -03:00
|
|
|
orient_type_set = V3D_ORIENT_GLOBAL;
|
2021-04-09 16:01:53 -03:00
|
|
|
}
|
2020-04-29 08:07:25 -03:00
|
|
|
|
2021-04-09 16:01:53 -03:00
|
|
|
BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
|
|
|
|
|
if (orient_type_matrix_set == orient_type_set) {
|
|
|
|
|
/* Constraints are forced to use the custom matrix when redoing. */
|
|
|
|
|
orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
|
2020-05-11 09:47:15 -03:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 23:40:06 -03:00
|
|
|
orient_types[O_DEFAULT] = (short)orient_type_default;
|
|
|
|
|
orient_types[O_SCENE] = (short)orient_type_scene;
|
|
|
|
|
orient_types[O_SET] = (short)orient_type_set;
|
2020-05-22 12:34:29 -03:00
|
|
|
|
2020-09-24 19:16:41 -03:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
|
/* For efficiency, avoid calculating the same orientation twice. */
|
|
|
|
|
int j;
|
|
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
|
if (orient_types[j] == orient_types[i]) {
|
|
|
|
|
memcpy(&t->orient[i], &t->orient[j], sizeof(*t->orient));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (j == i) {
|
|
|
|
|
t->orient[i].type = transform_orientation_matrix_get(
|
|
|
|
|
C, t, orient_types[i], custom_matrix, t->orient[i].matrix);
|
|
|
|
|
}
|
2020-05-12 15:44:08 -03:00
|
|
|
}
|
2020-05-22 12:34:29 -03:00
|
|
|
|
2021-11-11 21:14:10 +11:00
|
|
|
t->orient_type_mask = 0;
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
|
const int type = t->orient[i].type;
|
|
|
|
|
if (type < V3D_ORIENT_CUSTOM_MATRIX) {
|
|
|
|
|
BLI_assert(type < 32);
|
|
|
|
|
t->orient_type_mask |= (1 << type);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 19:16:41 -03:00
|
|
|
transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
|
2015-09-09 02:05:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-16 04:37:39 +00:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop))) {
|
|
|
|
|
if (RNA_property_boolean_get(op->ptr, prop)) {
|
2010-04-02 19:40:51 +00:00
|
|
|
t->flag |= T_RELEASE_CONFIRM;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2019-10-04 15:50:42 +02:00
|
|
|
/* Release confirms preference should not affect node editor (T69288, T70504). */
|
2020-12-04 10:35:26 -03:00
|
|
|
if (ISMOUSE(t->launch_event) &&
|
2019-10-07 15:17:44 +11:00
|
|
|
((U.flag & USER_RELEASECONFIRM) || (t->spacetype == SPACE_NODE))) {
|
2019-07-31 17:59:03 +02:00
|
|
|
/* Global "release confirm" on mouse bindings */
|
2010-04-02 19:40:51 +00:00
|
|
|
t->flag |= T_RELEASE_CONFIRM;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-16 04:37:39 +00:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "mirror")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop))) {
|
2019-01-14 14:59:18 +11:00
|
|
|
if (!RNA_property_boolean_get(op->ptr, prop)) {
|
|
|
|
|
t->flag |= T_NO_MIRROR;
|
2009-03-06 15:50:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-01-14 14:59:18 +11:00
|
|
|
else if ((t->spacetype == SPACE_VIEW3D) && (t->obedit_type == OB_MESH)) {
|
|
|
|
|
/* pass */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Avoid mirroring for unsupported contexts. */
|
2021-04-24 11:24:53 -03:00
|
|
|
t->flag |= T_NO_MIRROR;
|
2009-03-06 15:50:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-05-11 09:28:00 +00:00
|
|
|
/* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */
|
2019-04-30 13:42:18 +10:00
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
|
2013-06-16 04:37:39 +00:00
|
|
|
if (RNA_property_is_set(op->ptr, prop)) {
|
2019-05-01 08:36:36 +10:00
|
|
|
if (RNA_property_boolean_get(op->ptr, prop)) {
|
2020-06-27 14:19:43 -03:00
|
|
|
t->flag |= T_PROP_EDIT;
|
2019-04-30 14:32:35 +02:00
|
|
|
if (RNA_boolean_get(op->ptr, "use_proportional_connected")) {
|
2020-06-27 14:19:43 -03:00
|
|
|
t->flag |= T_PROP_CONNECTED;
|
2019-04-30 14:32:35 +02:00
|
|
|
}
|
|
|
|
|
if (RNA_boolean_get(op->ptr, "use_proportional_projected")) {
|
2020-06-27 14:19:43 -03:00
|
|
|
t->flag |= T_PROP_PROJECTED;
|
2019-04-30 14:32:35 +02:00
|
|
|
}
|
2019-04-30 13:42:18 +10:00
|
|
|
}
|
2009-03-06 15:50:15 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2020-06-27 11:12:46 -03:00
|
|
|
/* use settings from scene only if modal */
|
|
|
|
|
if (t->flag & T_MODAL) {
|
|
|
|
|
if ((t->options & CTX_NO_PET) == 0) {
|
2020-06-27 14:19:43 -03:00
|
|
|
bool use_prop_edit = false;
|
2020-06-27 11:12:46 -03:00
|
|
|
if (t->spacetype == SPACE_GRAPH) {
|
2020-06-27 14:19:43 -03:00
|
|
|
use_prop_edit = ts->proportional_fcurve;
|
2020-06-27 11:12:46 -03:00
|
|
|
}
|
|
|
|
|
else if (t->spacetype == SPACE_ACTION) {
|
2020-06-27 14:19:43 -03:00
|
|
|
use_prop_edit = ts->proportional_action;
|
2020-06-27 11:12:46 -03:00
|
|
|
}
|
2020-06-27 14:19:43 -03:00
|
|
|
else if (t->options & CTX_MASK) {
|
|
|
|
|
use_prop_edit = ts->proportional_mask;
|
2020-06-27 11:12:46 -03:00
|
|
|
}
|
2020-06-27 14:19:43 -03:00
|
|
|
else if (obact && obact->mode == OB_MODE_OBJECT) {
|
|
|
|
|
use_prop_edit = ts->proportional_objects;
|
2020-06-27 11:12:46 -03:00
|
|
|
}
|
2020-06-27 14:19:43 -03:00
|
|
|
else {
|
|
|
|
|
use_prop_edit = (ts->proportional_edit & PROP_EDIT_USE) != 0;
|
2020-06-27 11:12:46 -03:00
|
|
|
}
|
2020-06-27 14:19:43 -03:00
|
|
|
|
|
|
|
|
if (use_prop_edit) {
|
2020-06-27 11:12:46 -03:00
|
|
|
t->flag |= T_PROP_EDIT;
|
2020-06-27 14:19:43 -03:00
|
|
|
if (ts->proportional_edit & PROP_EDIT_CONNECTED) {
|
|
|
|
|
t->flag |= T_PROP_CONNECTED;
|
|
|
|
|
}
|
|
|
|
|
if (ts->proportional_edit & PROP_EDIT_PROJECTED) {
|
|
|
|
|
t->flag |= T_PROP_PROJECTED;
|
|
|
|
|
}
|
2020-06-27 11:12:46 -03:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-16 04:37:39 +00:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop))) {
|
|
|
|
|
t->prop_size = RNA_property_float_get(op->ptr, prop);
|
2010-10-03 21:10:59 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2010-10-03 21:10:59 +00:00
|
|
|
t->prop_size = ts->proportional_size;
|
2009-03-06 15:50:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-10-03 21:10:59 +00:00
|
|
|
/* TRANSFORM_FIX_ME rna restrictions */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->prop_size <= 0.00001f) {
|
2012-10-20 20:36:51 +00:00
|
|
|
printf("Proportional size (%f) under 0.00001, resetting to 1!\n", t->prop_size);
|
2010-10-03 21:10:59 +00:00
|
|
|
t->prop_size = 1.0f;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-16 04:37:39 +00:00
|
|
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop))) {
|
|
|
|
|
t->prop_mode = RNA_property_enum_get(op->ptr, prop);
|
2010-10-03 21:10:59 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
else {
|
2010-10-03 21:10:59 +00:00
|
|
|
t->prop_mode = ts->prop_mode;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
else { /* add not pet option to context when not available */
|
2010-10-03 21:10:59 +00:00
|
|
|
t->options |= CTX_NO_PET;
|
2009-03-06 15:50:15 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-15 11:55:22 -03:00
|
|
|
if (t->obedit_type == OB_MESH) {
|
|
|
|
|
if (op && (prop = RNA_struct_find_property(op->ptr, "use_automerge_and_split")) &&
|
|
|
|
|
RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
if (RNA_property_boolean_get(op->ptr, prop)) {
|
|
|
|
|
t->flag |= T_AUTOMERGE | T_AUTOSPLIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
char automerge = t->scene->toolsettings->automerge;
|
|
|
|
|
if (automerge & AUTO_MERGE) {
|
|
|
|
|
t->flag |= T_AUTOMERGE;
|
|
|
|
|
if (automerge & AUTO_MERGE_AND_SPLIT) {
|
|
|
|
|
t->flag |= T_AUTOSPLIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-04 23:42:06 +00:00
|
|
|
/* Mirror is not supported with PET, turn it off. */
|
2013-06-20 18:19:42 +00:00
|
|
|
#if 0
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->flag & T_PROP_EDIT) {
|
2011-10-04 23:42:06 +00:00
|
|
|
t->flag &= ~T_MIRROR;
|
|
|
|
|
}
|
2013-06-20 18:19:42 +00:00
|
|
|
#endif
|
2011-10-04 23:42:06 +00:00
|
|
|
|
2021-08-24 17:45:40 +01:00
|
|
|
/* Disable cursor wrap when edge panning is enabled. */
|
|
|
|
|
if (t->options & CTX_VIEW2D_EDGE_PAN) {
|
|
|
|
|
t->flag |= T_NO_CURSOR_WRAP;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-30 07:15:33 +11:00
|
|
|
setTransformViewMatrices(t);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
initNumInput(&t->num);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-26 10:08:41 +02:00
|
|
|
static void freeTransCustomData(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data)
|
|
|
|
|
{
|
|
|
|
|
if (custom_data->free_cb) {
|
|
|
|
|
/* Can take over freeing t->data and data_2d etc... */
|
|
|
|
|
custom_data->free_cb(t, tc, custom_data);
|
|
|
|
|
BLI_assert(custom_data->data == NULL);
|
|
|
|
|
}
|
|
|
|
|
else if ((custom_data->data != NULL) && custom_data->use_free) {
|
|
|
|
|
MEM_freeN(custom_data->data);
|
|
|
|
|
custom_data->data = NULL;
|
|
|
|
|
}
|
|
|
|
|
/* In case modes are switched in the same transform session. */
|
2019-10-03 07:31:24 +10:00
|
|
|
custom_data->free_cb = NULL;
|
2018-04-26 10:08:41 +02:00
|
|
|
custom_data->use_free = false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
static void freeTransCustomDataContainer(TransInfo *t,
|
|
|
|
|
TransDataContainer *tc,
|
|
|
|
|
TransCustomDataContainer *tcdc)
|
|
|
|
|
{
|
|
|
|
|
TransCustomData *custom_data = &tcdc->first_elem;
|
|
|
|
|
for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) {
|
2018-04-26 10:08:41 +02:00
|
|
|
freeTransCustomData(t, tc, custom_data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void freeTransCustomDataForMode(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
freeTransCustomData(t, NULL, &t->custom.mode);
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2018-04-26 10:08:41 +02:00
|
|
|
freeTransCustomData(t, tc, &tc->custom.mode);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-29 17:11:40 +00:00
|
|
|
void postTrans(bContext *C, TransInfo *t)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2019-04-22 09:19:45 +10:00
|
|
|
if (t->draw_handle_view) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_draw_cb_exit(t->region->type, t->draw_handle_view);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
if (t->draw_handle_apply) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_draw_cb_exit(t->region->type, t->draw_handle_apply);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
if (t->draw_handle_pixel) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_draw_cb_exit(t->region->type, t->draw_handle_pixel);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
if (t->draw_handle_cursor) {
|
2020-06-04 18:35:43 +10:00
|
|
|
WM_paint_cursor_end(t->draw_handle_cursor);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-24 14:23:32 +02:00
|
|
|
if (t->flag & T_MODAL_CURSOR_SET) {
|
|
|
|
|
WM_cursor_modal_restore(CTX_wm_window(C));
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-01 15:15:10 +11:00
|
|
|
/* Free all custom-data */
|
2018-04-16 16:27:55 +02:00
|
|
|
freeTransCustomDataContainer(t, NULL, &t->custom);
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2018-04-16 16:27:55 +02:00
|
|
|
freeTransCustomDataContainer(t, tc, &tc->custom);
|
2009-01-10 18:33:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/* postTrans can be called when nothing is selected, so data is NULL already */
|
2018-04-16 16:27:55 +02:00
|
|
|
if (t->data_len_all != 0) {
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2018-04-16 16:27:55 +02:00
|
|
|
/* free data malloced per trans-data */
|
2022-02-18 09:50:29 -06:00
|
|
|
if (ELEM(t->obedit_type, OB_CURVES_LEGACY, OB_SURF, OB_GPENCIL) ||
|
|
|
|
|
(t->spacetype == SPACE_GRAPH)) {
|
2018-04-16 16:27:55 +02:00
|
|
|
TransData *td = tc->data;
|
|
|
|
|
for (int a = 0; a < tc->data_len; a++, td++) {
|
|
|
|
|
if (td->flag & TD_BEZTRIPLE) {
|
|
|
|
|
MEM_freeN(td->hdata);
|
|
|
|
|
}
|
2012-09-28 14:51:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-16 16:27:55 +02:00
|
|
|
MEM_freeN(tc->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-08 08:23:04 -03:00
|
|
|
MEM_SAFE_FREE(tc->data_mirror);
|
2018-04-16 16:27:55 +02:00
|
|
|
MEM_SAFE_FREE(tc->data_ext);
|
|
|
|
|
MEM_SAFE_FREE(tc->data_2d);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
MEM_SAFE_FREE(t->data_container);
|
|
|
|
|
t->data_container = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-01 18:26:18 +00:00
|
|
|
BLI_freelistN(&t->tsnap.points);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
if (t->spacetype == SPACE_IMAGE) {
|
2014-07-21 12:02:05 +02:00
|
|
|
if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) {
|
2012-07-25 16:03:08 +00:00
|
|
|
/* pass */
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceImage *sima = t->area->spacedata.first;
|
2019-04-22 09:19:45 +10:00
|
|
|
if (sima->flag & SI_LIVE_UNWRAP) {
|
2012-07-25 16:03:08 +00:00
|
|
|
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-07-25 16:03:08 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (t->mouse.data) {
|
2009-10-22 23:22:05 +00:00
|
|
|
MEM_freeN(t->mouse.data);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-12 17:00:07 +02:00
|
|
|
if (t->rng != NULL) {
|
|
|
|
|
BLI_rng_free(t->rng);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-04-21 11:29:32 +10:00
|
|
|
freeSnapping(t);
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
|
void applyTransObjects(TransInfo *t)
|
|
|
|
|
{
|
2018-04-16 16:27:55 +02:00
|
|
|
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
TransData *td;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
for (td = tc->data; td < tc->data + tc->data_len; td++) {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(td->iloc, td->loc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (td->ext->rot) {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(td->ext->irot, td->ext->rot);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
if (td->ext->size) {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(td->ext->isize, td->ext->size);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2009-07-12 02:01:13 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
recalcData(t);
|
2009-07-12 02:01:13 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2020-06-08 08:23:04 -03:00
|
|
|
static void transdata_restore_basic(TransDataBasic *td_basic)
|
2011-09-28 05:53:40 +00:00
|
|
|
{
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/* TransData for crease has no loc */
|
2020-06-08 08:23:04 -03:00
|
|
|
if (td_basic->loc) {
|
|
|
|
|
copy_v3_v3(td_basic->loc, td_basic->iloc);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2020-06-08 08:23:04 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void restoreElement(TransData *td)
|
|
|
|
|
{
|
|
|
|
|
transdata_restore_basic((TransDataBasic *)td);
|
|
|
|
|
|
2021-09-07 11:03:48 -03:00
|
|
|
if (td->val && td->val != td->loc) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
*td->val = td->ival;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
if (td->ext && (td->flag & TD_NO_EXT) == 0) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (td->ext->rot) {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(td->ext->rot, td->ext->irot);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (td->ext->rotAngle) {
|
2012-06-10 19:59:02 +00:00
|
|
|
*td->ext->rotAngle = td->ext->irotAngle;
|
2010-10-19 11:15:08 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (td->ext->rotAxis) {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(td->ext->rotAxis, td->ext->irotAxis);
|
2010-10-19 11:15:08 +00:00
|
|
|
}
|
|
|
|
|
/* XXX, drotAngle & drotAxis not used yet */
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (td->ext->size) {
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(td->ext->size, td->ext->isize);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2011-05-11 09:28:00 +00:00
|
|
|
if (td->ext->quat) {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_qt_qt(td->ext->quat, td->ext->iquat);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2011-05-11 09:28:00 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (td->flag & TD_BEZTRIPLE) {
|
|
|
|
|
*(td->hdata->h1) = td->hdata->ih1;
|
|
|
|
|
*(td->hdata->h2) = td->hdata->ih2;
|
|
|
|
|
}
|
2011-05-11 09:28:00 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
|
|
|
|
void restoreTransObjects(TransInfo *t)
|
|
|
|
|
{
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 17:54:33 +02:00
|
|
|
TransData *td;
|
|
|
|
|
TransData2D *td2d;
|
2020-06-08 08:23:04 -03:00
|
|
|
TransDataMirror *tdm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 17:54:33 +02:00
|
|
|
for (td = tc->data; td < tc->data + tc->data_len; td++) {
|
|
|
|
|
restoreElement(td);
|
2010-05-06 19:54:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-08 08:23:04 -03:00
|
|
|
for (tdm = tc->data_mirror; tdm < tc->data_mirror + tc->data_mirror_len; tdm++) {
|
|
|
|
|
transdata_restore_basic((TransDataBasic *)tdm);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-16 17:54:33 +02:00
|
|
|
for (td2d = tc->data_2d; tc->data_2d && td2d < tc->data_2d + tc->data_len; td2d++) {
|
|
|
|
|
if (td2d->h1) {
|
|
|
|
|
td2d->h1[0] = td2d->ih1[0];
|
|
|
|
|
td2d->h1[1] = td2d->ih1[1];
|
|
|
|
|
}
|
|
|
|
|
if (td2d->h2) {
|
|
|
|
|
td2d->h2[0] = td2d->ih2[0];
|
|
|
|
|
td2d->h2[1] = td2d->ih2[1];
|
2010-05-06 19:54:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 17:54:33 +02:00
|
|
|
unit_m3(t->mat);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
recalcData(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void calculateCenter2D(TransInfo *t)
|
|
|
|
|
{
|
2016-03-30 07:15:33 +11:00
|
|
|
BLI_assert(!is_zero_v3(t->aspect));
|
2018-04-16 16:27:55 +02:00
|
|
|
projectFloatView(t, t->center_global, t->center2d);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
void calculateCenterLocal(TransInfo *t, const float center_global[3])
|
2015-06-26 16:19:39 +10:00
|
|
|
{
|
2021-07-03 23:08:40 +10:00
|
|
|
/* Setting constraint center. */
|
|
|
|
|
/* NOTE: init functions may over-ride `t->center`. */
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2018-05-04 14:41:51 +02:00
|
|
|
if (tc->use_local_mat) {
|
|
|
|
|
mul_v3_m4v3(tc->center_local, tc->imat, center_global);
|
2018-04-16 16:27:55 +02:00
|
|
|
}
|
2018-05-04 14:41:51 +02:00
|
|
|
else {
|
2018-04-16 16:27:55 +02:00
|
|
|
copy_v3_v3(tc->center_local, center_global);
|
|
|
|
|
}
|
2015-06-26 16:19:39 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
void calculateCenterCursor(TransInfo *t, float r_center[3])
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2018-11-26 13:49:17 +11:00
|
|
|
const float *cursor = t->scene->cursor.location;
|
2014-05-09 16:52:09 +10:00
|
|
|
copy_v3_v3(r_center, cursor);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/* If edit or pose mode, move cursor in local space */
|
2018-04-16 16:27:55 +02:00
|
|
|
if (t->options & CTX_PAINT_CURVE) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (ED_view3d_project_float_global(t->region, cursor, r_center, V3D_PROJ_TEST_NOP) !=
|
2014-07-21 12:02:05 +02:00
|
|
|
V3D_PROJ_RET_OK) {
|
2020-03-06 16:56:42 +01:00
|
|
|
r_center[0] = t->region->winx / 2.0f;
|
|
|
|
|
r_center[1] = t->region->winy / 2.0f;
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
|
r_center[2] = 0.0f;
|
|
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
void calculateCenterCursor2D(TransInfo *t, float r_center[2])
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2021-10-07 12:32:04 +11:00
|
|
|
float cursor_local_buf[2];
|
2014-04-27 00:22:49 +10:00
|
|
|
const float *cursor = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
if (t->spacetype == SPACE_IMAGE) {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
|
2010-03-30 05:52:05 +00:00
|
|
|
cursor = sima->cursor;
|
|
|
|
|
}
|
2021-10-07 12:32:04 +11:00
|
|
|
if (t->spacetype == SPACE_SEQ) {
|
|
|
|
|
SpaceSeq *sseq = (SpaceSeq *)t->area->spacedata.first;
|
|
|
|
|
SEQ_image_preview_unit_to_px(t->scene, sseq->cursor, cursor_local_buf);
|
|
|
|
|
cursor = cursor_local_buf;
|
|
|
|
|
}
|
2013-08-29 13:04:12 +00:00
|
|
|
else if (t->spacetype == SPACE_CLIP) {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first;
|
2013-08-29 13:04:12 +00:00
|
|
|
cursor = space_clip->cursor;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-03-30 11:38:06 +00:00
|
|
|
if (cursor) {
|
2012-07-26 10:52:59 +00:00
|
|
|
if (t->options & CTX_MASK) {
|
|
|
|
|
float co[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-08-29 13:04:12 +00:00
|
|
|
if (t->spacetype == SPACE_IMAGE) {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceImage *sima = (SpaceImage *)t->area->spacedata.first;
|
2014-05-28 18:44:15 +06:00
|
|
|
BKE_mask_coord_from_image(sima->image, &sima->iuser, co, cursor);
|
2013-08-29 13:04:12 +00:00
|
|
|
}
|
|
|
|
|
else if (t->spacetype == SPACE_CLIP) {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceClip *space_clip = (SpaceClip *)t->area->spacedata.first;
|
2014-05-28 18:44:15 +06:00
|
|
|
BKE_mask_coord_from_movieclip(space_clip->clip, &space_clip->user, co, cursor);
|
2013-08-29 13:04:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2021-07-15 18:23:28 +10:00
|
|
|
BLI_assert_msg(0, "Shall not happen");
|
2013-08-29 13:04:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-26 15:45:09 +10:00
|
|
|
r_center[0] = co[0] * t->aspect[0];
|
|
|
|
|
r_center[1] = co[1] * t->aspect[1];
|
2012-07-26 10:52:59 +00:00
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
else if (t->options & CTX_PAINT_CURVE) {
|
|
|
|
|
if (t->spacetype == SPACE_IMAGE) {
|
2020-03-06 16:56:42 +01:00
|
|
|
r_center[0] = UI_view2d_view_to_region_x(&t->region->v2d, cursor[0]);
|
|
|
|
|
r_center[1] = UI_view2d_view_to_region_y(&t->region->v2d, cursor[1]);
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-07-26 10:52:59 +00:00
|
|
|
else {
|
2015-06-26 15:45:09 +10:00
|
|
|
r_center[0] = cursor[0] * t->aspect[0];
|
|
|
|
|
r_center[1] = cursor[1] * t->aspect[1];
|
2012-07-26 10:52:59 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2])
|
2009-11-01 00:06:53 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
|
2012-06-10 19:59:02 +00:00
|
|
|
Scene *scene = t->scene;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-01 00:06:53 +00:00
|
|
|
/* cursor is combination of current frame, and graph-editor cursor value */
|
2015-10-26 20:15:27 +13:00
|
|
|
if (sipo->mode == SIPO_MODE_DRIVERS) {
|
|
|
|
|
r_center[0] = sipo->cursorTime;
|
|
|
|
|
r_center[1] = sipo->cursorVal;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
r_center[0] = (float)(scene->r.cfra);
|
|
|
|
|
r_center[1] = sipo->cursorVal;
|
|
|
|
|
}
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-08 08:23:04 -03:00
|
|
|
static bool transdata_center_global_get(const TransDataContainer *tc,
|
|
|
|
|
const TransDataBasic *td_basic,
|
|
|
|
|
float r_vec[3])
|
|
|
|
|
{
|
|
|
|
|
if (td_basic->flag & TD_SELECTED) {
|
|
|
|
|
if (!(td_basic->flag & TD_NOCENTER)) {
|
|
|
|
|
if (tc->use_local_mat) {
|
|
|
|
|
mul_v3_m4v3(r_vec, tc->mat, td_basic->center);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(r_vec, td_basic->center);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
void calculateCenterMedian(TransInfo *t, float r_center[3])
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
|
|
|
|
float partial[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
int total = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2020-06-08 08:23:04 -03:00
|
|
|
float center[3];
|
2018-05-13 07:17:36 +02:00
|
|
|
for (int i = 0; i < tc->data_len; i++) {
|
2020-06-08 08:23:04 -03:00
|
|
|
if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data[i], center)) {
|
|
|
|
|
add_v3_v3(partial, center);
|
|
|
|
|
total++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < tc->data_mirror_len; i++) {
|
|
|
|
|
if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data_mirror[i], center)) {
|
|
|
|
|
add_v3_v3(partial, center);
|
|
|
|
|
total++;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-19 20:13:05 +02:00
|
|
|
if (total) {
|
|
|
|
|
mul_v3_fl(partial, 1.0f / (float)total);
|
|
|
|
|
}
|
2014-05-09 16:52:09 +10:00
|
|
|
copy_v3_v3(r_center, partial);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
void calculateCenterBound(TransInfo *t, float r_center[3])
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2018-05-13 07:17:36 +02:00
|
|
|
float max[3], min[3];
|
|
|
|
|
bool changed = false;
|
|
|
|
|
INIT_MINMAX(min, max);
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2020-06-08 08:23:04 -03:00
|
|
|
float center[3];
|
2018-05-13 07:17:36 +02:00
|
|
|
for (int i = 0; i < tc->data_len; i++) {
|
2020-06-08 08:23:04 -03:00
|
|
|
if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data[i], center)) {
|
|
|
|
|
minmax_v3v3_v3(min, max, center);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < tc->data_mirror_len; i++) {
|
|
|
|
|
if (transdata_center_global_get(tc, (TransDataBasic *)&tc->data_mirror[i], center)) {
|
|
|
|
|
minmax_v3v3_v3(min, max, center);
|
|
|
|
|
changed = true;
|
2018-04-16 17:54:33 +02:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-05-13 07:17:36 +02:00
|
|
|
if (changed) {
|
|
|
|
|
mid_v3_v3v3(r_center, min, max);
|
|
|
|
|
}
|
2014-05-09 16:52:09 +10:00
|
|
|
}
|
2012-10-30 14:22:49 +00:00
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3])
|
|
|
|
|
{
|
2018-04-16 16:27:55 +02:00
|
|
|
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-27 18:39:39 +01:00
|
|
|
if (t->spacetype != SPACE_VIEW3D) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-07-03 17:25:04 +02:00
|
|
|
if (tc->obedit) {
|
2018-12-13 10:37:01 +11:00
|
|
|
if (ED_object_calc_active_center_for_editmode(tc->obedit, select_only, r_center)) {
|
2018-04-16 16:27:55 +02:00
|
|
|
mul_m4_v3(tc->obedit->obmat, r_center);
|
2018-12-27 18:39:39 +01:00
|
|
|
return true;
|
2014-05-09 16:52:09 +10:00
|
|
|
}
|
|
|
|
|
}
|
2021-02-05 11:56:43 -03:00
|
|
|
else if (t->options & CTX_POSE_BONE) {
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = t->view_layer;
|
2018-12-13 10:37:01 +11:00
|
|
|
Object *ob = OBACT(view_layer);
|
|
|
|
|
if (ED_object_calc_active_center_for_posemode(ob, select_only, r_center)) {
|
|
|
|
|
mul_m4_v3(ob->obmat, r_center);
|
2018-12-27 18:39:39 +01:00
|
|
|
return true;
|
2014-05-09 16:52:09 +10:00
|
|
|
}
|
|
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
else if (t->options & CTX_PAINT_CURVE) {
|
2018-04-05 18:20:27 +02:00
|
|
|
Paint *p = BKE_paint_get_active(t->scene, t->view_layer);
|
2014-07-21 12:02:05 +02:00
|
|
|
Brush *br = p->brush;
|
|
|
|
|
PaintCurve *pc = br->paint_curve;
|
|
|
|
|
copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]);
|
|
|
|
|
r_center[2] = 0.0f;
|
2018-12-27 18:39:39 +01:00
|
|
|
return true;
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
2014-05-09 16:52:09 +10:00
|
|
|
else {
|
|
|
|
|
/* object mode */
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = t->view_layer;
|
|
|
|
|
Object *ob = OBACT(view_layer);
|
|
|
|
|
Base *base = BASACT(view_layer);
|
2017-02-09 16:34:26 +01:00
|
|
|
if (ob && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) {
|
2014-05-09 16:52:09 +10:00
|
|
|
copy_v3_v3(r_center, ob->obmat[3]);
|
2018-12-27 18:39:39 +01:00
|
|
|
return true;
|
2014-05-09 16:52:09 +10:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-27 18:39:39 +01:00
|
|
|
return false;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-31 23:56:59 +10:00
|
|
|
static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[3])
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2016-05-31 23:56:59 +10:00
|
|
|
switch (around) {
|
2015-12-01 18:52:24 +11:00
|
|
|
case V3D_AROUND_CENTER_BOUNDS:
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterBound(t, r_center);
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
2018-12-14 11:01:01 +11:00
|
|
|
case V3D_AROUND_CENTER_MEDIAN:
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterMedian(t, r_center);
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
2015-12-01 18:52:24 +11:00
|
|
|
case V3D_AROUND_CURSOR:
|
2021-10-07 12:32:04 +11:00
|
|
|
if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_SEQ, SPACE_CLIP)) {
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterCursor2D(t, r_center);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else if (t->spacetype == SPACE_GRAPH) {
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterCursorGraph2D(t, r_center);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterCursor(t, r_center);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
2015-12-01 18:52:24 +11:00
|
|
|
case V3D_AROUND_LOCAL_ORIGINS:
|
2012-06-10 19:59:02 +00:00
|
|
|
/* Individual element center uses median center for helpline and such */
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterMedian(t, r_center);
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
2015-12-01 18:52:24 +11:00
|
|
|
case V3D_AROUND_ACTIVE: {
|
2016-05-31 23:56:59 +10:00
|
|
|
if (calculateCenterActive(t, false, r_center)) {
|
2014-05-09 16:52:09 +10:00
|
|
|
/* pass */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* fallback */
|
2016-05-31 23:56:59 +10:00
|
|
|
calculateCenterMedian(t, r_center);
|
2009-11-05 04:37:42 +00:00
|
|
|
}
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-05-31 23:56:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void calculateCenter(TransInfo *t)
|
|
|
|
|
{
|
2017-08-28 16:28:50 +10:00
|
|
|
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
|
2018-04-16 16:27:55 +02:00
|
|
|
calculateCenter_FromAround(t, t->around, t->center_global);
|
2017-08-28 16:28:50 +10:00
|
|
|
}
|
2018-04-16 16:27:55 +02:00
|
|
|
calculateCenterLocal(t, t->center_global);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-05-09 16:52:09 +10:00
|
|
|
calculateCenter2D(t);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* For panning from the camera-view. */
|
2021-02-05 11:56:43 -03:00
|
|
|
if ((t->options & CTX_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (t->spacetype == SPACE_VIEW3D && t->region && t->region->regiontype == RGN_TYPE_WINDOW) {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 11:56:43 -03:00
|
|
|
if (t->options & CTX_CAMERA) {
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
float axis[3];
|
|
|
|
|
/* persinv is nasty, use viewinv instead, always right */
|
2011-09-12 04:14:12 +00:00
|
|
|
copy_v3_v3(axis, t->viewinv[2]);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(axis);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/* 6.0 = 6 grid units */
|
2018-04-16 16:27:55 +02:00
|
|
|
axis[0] = t->center_global[0] - 6.0f * axis[0];
|
|
|
|
|
axis[1] = t->center_global[1] - 6.0f * axis[1];
|
|
|
|
|
axis[2] = t->center_global[2] - 6.0f * axis[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-12 03:42:06 +00:00
|
|
|
projectFloatView(t, axis, t->center2d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-03-01 10:56:28 +11:00
|
|
|
/* Rotate only needs correct 2d center, grab needs #ED_view3d_calc_zfac() value. */
|
2012-06-10 19:59:02 +00:00
|
|
|
if (t->mode == TFM_TRANSLATION) {
|
2018-04-16 16:27:55 +02:00
|
|
|
copy_v3_v3(t->center_global, axis);
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-12 02:01:13 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
if (t->spacetype == SPACE_VIEW3D) {
|
2022-03-01 10:56:28 +11:00
|
|
|
/* #ED_view3d_calc_zfac() defines a factor for perspective depth correction,
|
|
|
|
|
* used in #ED_view3d_win_to_delta(). */
|
2021-11-18 14:19:59 -03:00
|
|
|
|
2022-03-01 10:56:28 +11:00
|
|
|
/* NOTE: `t->zfac` is only used #convertViewVec only in cases operator was invoked in
|
|
|
|
|
* #RGN_TYPE_WINDOW and never used in other cases.
|
2021-11-18 14:19:59 -03:00
|
|
|
*
|
2022-03-01 10:56:28 +11:00
|
|
|
* We need special case here as well, since #ED_view3d_calc_zfac will crash when called
|
|
|
|
|
* for a region different from #RGN_TYPE_WINDOW. */
|
2021-11-18 14:19:59 -03:00
|
|
|
if (t->region->regiontype == RGN_TYPE_WINDOW) {
|
2022-03-01 10:56:28 +11:00
|
|
|
t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global);
|
2021-11-18 14:19:59 -03:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
t->zfac = 0.0f;
|
2013-06-10 09:45:51 +00:00
|
|
|
}
|
2008-12-29 20:37:54 +00:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void calculatePropRatio(TransInfo *t)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
float dist;
|
2015-02-04 05:43:34 +11:00
|
|
|
const bool connected = (t->flag & T_PROP_CONNECTED) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-02-04 05:43:34 +11:00
|
|
|
t->proptext[0] = '\0';
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
if (t->flag & T_PROP_EDIT) {
|
2015-02-04 05:43:34 +11:00
|
|
|
const char *pet_id = NULL;
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2018-04-16 17:54:33 +02:00
|
|
|
TransData *td = tc->data;
|
|
|
|
|
for (i = 0; i < tc->data_len; i++, td++) {
|
|
|
|
|
if (td->flag & TD_SELECTED) {
|
|
|
|
|
td->factor = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) ||
|
|
|
|
|
(connected == 0 && td->rdist > t->prop_size)) {
|
|
|
|
|
td->factor = 0.0f;
|
|
|
|
|
restoreElement(td);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Use rdist for falloff calculations, it is the real distance */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (connected) {
|
2018-04-16 17:54:33 +02:00
|
|
|
dist = (t->prop_size - td->dist) / t->prop_size;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2018-04-16 17:54:33 +02:00
|
|
|
dist = (t->prop_size - td->rdist) / t->prop_size;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 17:54:33 +02:00
|
|
|
/*
|
|
|
|
|
* Clamp to positive numbers.
|
|
|
|
|
* Certain corner cases with connectivity and individual centers
|
|
|
|
|
* can give values of rdist larger than propsize.
|
|
|
|
|
*/
|
2019-04-22 09:19:45 +10:00
|
|
|
if (dist < 0.0f) {
|
2018-04-16 17:54:33 +02:00
|
|
|
dist = 0.0f;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-16 17:54:33 +02:00
|
|
|
switch (t->prop_mode) {
|
|
|
|
|
case PROP_SHARP:
|
|
|
|
|
td->factor = dist * dist;
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SMOOTH:
|
|
|
|
|
td->factor = 3.0f * dist * dist - 2.0f * dist * dist * dist;
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ROOT:
|
|
|
|
|
td->factor = sqrtf(dist);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_LIN:
|
|
|
|
|
td->factor = dist;
|
|
|
|
|
break;
|
|
|
|
|
case PROP_CONST:
|
|
|
|
|
td->factor = 1.0f;
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SPHERE:
|
|
|
|
|
td->factor = sqrtf(2 * dist - dist * dist);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RANDOM:
|
2018-06-12 17:00:07 +02:00
|
|
|
if (t->rng == NULL) {
|
|
|
|
|
/* Lazy initialization. */
|
|
|
|
|
uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
|
|
|
|
|
t->rng = BLI_rng_new(rng_seed);
|
|
|
|
|
}
|
|
|
|
|
td->factor = BLI_rng_get_float(t->rng) * dist;
|
2018-04-16 17:54:33 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_INVSQUARE:
|
|
|
|
|
td->factor = dist * (2.0f - dist);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
td->factor = 1;
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-04-16 17:54:33 +02:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (t->prop_mode) {
|
2012-06-10 19:59:02 +00:00
|
|
|
case PROP_SHARP:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Sharp)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
|
|
|
|
case PROP_SMOOTH:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Smooth)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
|
|
|
|
case PROP_ROOT:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Root)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
|
|
|
|
case PROP_LIN:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Linear)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
|
|
|
|
case PROP_CONST:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Constant)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
|
|
|
|
case PROP_SPHERE:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Sphere)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
|
|
|
|
case PROP_RANDOM:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(Random)");
|
2012-06-10 19:59:02 +00:00
|
|
|
break;
|
2015-02-04 05:35:09 +11:00
|
|
|
case PROP_INVSQUARE:
|
2015-02-04 05:43:34 +11:00
|
|
|
pet_id = N_("(InvSquare)");
|
2015-02-04 05:35:09 +11:00
|
|
|
break;
|
2012-06-10 19:59:02 +00:00
|
|
|
default:
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-02-04 05:43:34 +11:00
|
|
|
if (pet_id) {
|
|
|
|
|
BLI_strncpy(t->proptext, IFACE_(pet_id), sizeof(t->proptext));
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2015-02-04 05:43:34 +11:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
else {
|
2019-04-21 04:40:16 +10:00
|
|
|
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
2018-04-16 16:27:55 +02:00
|
|
|
TransData *td = tc->data;
|
|
|
|
|
for (i = 0; i < tc->data_len; i++, td++) {
|
|
|
|
|
td->factor = 1.0;
|
|
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-14 04:27:32 +10:00
|
|
|
|
|
|
|
|
void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot)
|
|
|
|
|
{
|
|
|
|
|
float totmat[3][3];
|
|
|
|
|
float smat[3][3];
|
|
|
|
|
float fmat[3][3];
|
|
|
|
|
float obmat[3][3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
float dmat[3][3]; /* delta rotation */
|
|
|
|
|
float dmat_inv[3][3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
mul_m3_m3m3(totmat, mat, td->mtx);
|
|
|
|
|
mul_m3_m3m3(smat, td->smtx, mat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* logic from BKE_object_rot_to_mat3 */
|
|
|
|
|
if (use_drot) {
|
|
|
|
|
if (td->ext->rotOrder > 0) {
|
|
|
|
|
eulO_to_mat3(dmat, td->ext->drot, td->ext->rotOrder);
|
|
|
|
|
}
|
|
|
|
|
else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
|
|
|
|
|
#if 0
|
|
|
|
|
axis_angle_to_mat3(dmat, td->ext->drotAxis, td->ext->drotAngle);
|
|
|
|
|
#else
|
|
|
|
|
unit_m3(dmat);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float tquat[4];
|
|
|
|
|
normalize_qt_qt(tquat, td->ext->dquat);
|
|
|
|
|
quat_to_mat3(dmat, tquat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
invert_m3_m3(dmat_inv, dmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
if (td->ext->rotOrder == ROT_MODE_QUAT) {
|
|
|
|
|
float quat[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Calculate the total rotation. */
|
2015-07-14 04:27:32 +10:00
|
|
|
quat_to_mat3(obmat, td->ext->iquat);
|
|
|
|
|
if (use_drot) {
|
|
|
|
|
mul_m3_m3m3(obmat, dmat, obmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* mat = transform, obmat = object rotation */
|
|
|
|
|
mul_m3_m3m3(fmat, smat, obmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
if (use_drot) {
|
|
|
|
|
mul_m3_m3m3(fmat, dmat_inv, fmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
mat3_to_quat(quat, fmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* apply */
|
|
|
|
|
copy_qt_qt(td->ext->quat, quat);
|
|
|
|
|
}
|
|
|
|
|
else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
|
|
|
|
|
float axis[3], angle;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Calculate the total rotation. */
|
2015-07-14 04:27:32 +10:00
|
|
|
axis_angle_to_mat3(obmat, td->ext->irotAxis, td->ext->irotAngle);
|
|
|
|
|
if (use_drot) {
|
|
|
|
|
mul_m3_m3m3(obmat, dmat, obmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* mat = transform, obmat = object rotation */
|
|
|
|
|
mul_m3_m3m3(fmat, smat, obmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
if (use_drot) {
|
|
|
|
|
mul_m3_m3m3(fmat, dmat_inv, fmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
mat3_to_axis_angle(axis, &angle, fmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* apply */
|
|
|
|
|
copy_v3_v3(td->ext->rotAxis, axis);
|
|
|
|
|
*td->ext->rotAngle = angle;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float eul[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Calculate the total rotation. */
|
2015-07-14 04:27:32 +10:00
|
|
|
eulO_to_mat3(obmat, td->ext->irot, td->ext->rotOrder);
|
|
|
|
|
if (use_drot) {
|
|
|
|
|
mul_m3_m3m3(obmat, dmat, obmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* mat = transform, obmat = object rotation */
|
|
|
|
|
mul_m3_m3m3(fmat, smat, obmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
if (use_drot) {
|
|
|
|
|
mul_m3_m3m3(fmat, dmat_inv, fmat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
mat3_to_compatible_eulO(eul, td->ext->rot, td->ext->rotOrder, fmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-07-14 04:27:32 +10:00
|
|
|
/* apply */
|
|
|
|
|
copy_v3_v3(td->ext->rot, eul);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-10 12:27:01 -03:00
|
|
|
|
2021-02-10 15:19:51 -03:00
|
|
|
Object *transform_object_deform_pose_armature_get(const TransInfo *t, Object *ob)
|
2021-02-10 12:27:01 -03:00
|
|
|
{
|
|
|
|
|
if (!(ob->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
/* Important that ob_armature can be set even when its not selected T23412.
|
|
|
|
|
* Lines below just check is also visible. */
|
|
|
|
|
Object *ob_armature = BKE_modifiers_is_deformed_by_armature(ob);
|
|
|
|
|
if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
|
|
|
|
|
Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
|
|
|
|
|
if (base_arm) {
|
|
|
|
|
View3D *v3d = t->view;
|
|
|
|
|
if (BASE_VISIBLE(v3d, base_arm)) {
|
|
|
|
|
return ob_armature;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|