Tool System: cursor tool now transforms on drag
This commit is contained in:
@@ -88,6 +88,10 @@ class _defs_view3d_generic:
|
||||
icon="ops.generic.cursor",
|
||||
keymap=(
|
||||
("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='PRESS')),
|
||||
("transform.translate",
|
||||
dict(release_confirm=True, cursor_transform=True),
|
||||
dict(type='EVT_TWEAK_A', value='ANY'),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ enum TfmMode {
|
||||
#define CTX_MASK (1 << 7)
|
||||
#define CTX_PAINT_CURVE (1 << 8)
|
||||
#define CTX_GPENCIL_STROKES (1 << 9)
|
||||
#define CTX_CURSOR (1 << 10)
|
||||
|
||||
/* Standalone call to get the transformation center corresponding to the current situation
|
||||
* returns 1 if successful, 0 otherwise (usually means there's no selection)
|
||||
@@ -152,6 +153,7 @@ int BIF_countTransformOrientation(const struct bContext *C);
|
||||
#define P_NO_TEXSPACE (1 << 11)
|
||||
#define P_CENTER (1 << 12)
|
||||
#define P_GPENCIL_EDIT (1 << 13)
|
||||
#define P_CURSOR_EDIT (1 << 14)
|
||||
|
||||
void Transform_Properties(struct wmOperatorType *ot, int flags);
|
||||
|
||||
|
||||
@@ -2118,6 +2118,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
||||
|
||||
t->state = TRANS_STARTING;
|
||||
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "cursor_transform")) && RNA_property_is_set(op->ptr, prop)) {
|
||||
if (RNA_property_boolean_get(op->ptr, prop)) {
|
||||
options |= CTX_CURSOR;
|
||||
}
|
||||
}
|
||||
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
|
||||
if (RNA_property_boolean_get(op->ptr, prop)) {
|
||||
options |= CTX_TEXTURE;
|
||||
|
||||
@@ -557,6 +557,8 @@ typedef struct TransInfo {
|
||||
#define T_TEXTURE (1 << 3)
|
||||
/* transforming the camera while in camera view */
|
||||
#define T_CAMERA (1 << 4)
|
||||
/* transforming the 3D cursor. */
|
||||
#define T_CURSOR (1 << 5)
|
||||
// trans on points, having no rotation/scale
|
||||
#define T_POINTS (1 << 6)
|
||||
/**
|
||||
|
||||
@@ -345,6 +345,43 @@ static void createTransTexspace(TransInfo *t)
|
||||
copy_v3_v3(td->ext->isize, td->ext->size);
|
||||
}
|
||||
|
||||
static void createTransCursor3D(TransInfo *t)
|
||||
{
|
||||
TransData *td;
|
||||
|
||||
Scene *scene = t->scene;
|
||||
View3D *v3d = ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) ? t->view : NULL;
|
||||
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
|
||||
if ((cursor == &scene->cursor) && ID_IS_LINKED(scene)) {
|
||||
BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
BLI_assert(t->data_container_len == 1);
|
||||
TransDataContainer *tc = t->data_container;
|
||||
tc->data_len = 1;
|
||||
td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace");
|
||||
td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
|
||||
}
|
||||
|
||||
td->flag = TD_SELECTED;
|
||||
copy_v3_v3(td->center, cursor->location);
|
||||
td->ob = NULL;
|
||||
|
||||
unit_m3(td->mtx);
|
||||
quat_to_mat3(td->axismtx, cursor->rotation);
|
||||
normalize_m3(td->axismtx);
|
||||
pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON);
|
||||
|
||||
td->loc = cursor->location;
|
||||
copy_v3_v3(td->iloc, cursor->location);
|
||||
|
||||
td->ext->quat = cursor->rotation;
|
||||
copy_qt_qt(td->ext->iquat, cursor->rotation);
|
||||
}
|
||||
|
||||
/* ********************* edge (for crease) ***** */
|
||||
|
||||
static void createTransEdge(TransInfo *t)
|
||||
@@ -6696,6 +6733,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
else if (t->flag & T_CURSOR) {
|
||||
/* do nothing */
|
||||
}
|
||||
else { /* Objects */
|
||||
int i;
|
||||
|
||||
@@ -8328,7 +8368,14 @@ void createTransData(bContext *C, TransInfo *t)
|
||||
t->data_len_all = -1;
|
||||
|
||||
/* if tests must match recalcData for correct updates */
|
||||
if (t->options & CTX_TEXTURE) {
|
||||
if (t->options & CTX_CURSOR) {
|
||||
t->flag |= T_CURSOR;
|
||||
t->obedit_type = -1;
|
||||
|
||||
createTransCursor3D(t);
|
||||
countAndCleanTransDataContainer(t);
|
||||
}
|
||||
else if (t->options & CTX_TEXTURE) {
|
||||
t->flag |= T_TEXTURE;
|
||||
t->obedit_type = -1;
|
||||
|
||||
|
||||
@@ -1007,6 +1007,11 @@ static void recalcData_objects(TransInfo *t)
|
||||
}
|
||||
}
|
||||
|
||||
static void recalcData_cursor(TransInfo *t)
|
||||
{
|
||||
DEG_id_tag_update(&t->scene->id, DEG_TAG_COPY_ON_WRITE);
|
||||
}
|
||||
|
||||
/* helper for recalcData() - for sequencer transforms */
|
||||
static void recalcData_sequencer(TransInfo *t)
|
||||
{
|
||||
@@ -1056,7 +1061,10 @@ static void recalcData_gpencil_strokes(TransInfo *t)
|
||||
void recalcData(TransInfo *t)
|
||||
{
|
||||
/* if tests must match createTransData for correct updates */
|
||||
if (t->options & CTX_TEXTURE) {
|
||||
if (t->options & CTX_CURSOR) {
|
||||
recalcData_cursor(t);
|
||||
}
|
||||
else if (t->options & CTX_TEXTURE) {
|
||||
recalcData_objects(t);
|
||||
}
|
||||
else if (t->options & CTX_EDGE) {
|
||||
|
||||
@@ -563,6 +563,10 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
|
||||
RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes");
|
||||
}
|
||||
|
||||
if (flags & P_CURSOR_EDIT) {
|
||||
RNA_def_boolean(ot->srna, "cursor_transform", 0, "Transform Cursor", "");
|
||||
}
|
||||
|
||||
if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) {
|
||||
RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
|
||||
prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel");
|
||||
@@ -609,7 +613,10 @@ static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
|
||||
|
||||
WM_operatortype_props_advanced_begin(ot);
|
||||
|
||||
Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS | P_GPENCIL_EDIT);
|
||||
Transform_Properties(
|
||||
ot,
|
||||
P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS |
|
||||
P_GPENCIL_EDIT | P_CURSOR_EDIT);
|
||||
}
|
||||
|
||||
static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
|
||||
|
||||
@@ -550,7 +550,9 @@ static void initSnappingMode(TransInfo *t)
|
||||
{
|
||||
/* In "Edit Strokes" mode, Snap tool can perform snap to selected or active objects (see T49632)
|
||||
* TODO: perform self snap in gpencil_strokes */
|
||||
t->tsnap.modeSelect = ((t->options & CTX_GPENCIL_STROKES) != 0) ? SNAP_ALL : SNAP_NOT_SELECTED;
|
||||
t->tsnap.modeSelect = (
|
||||
((t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR)) != 0) ?
|
||||
SNAP_ALL : SNAP_NOT_SELECTED);
|
||||
}
|
||||
else {
|
||||
/* Grid if snap is not possible */
|
||||
|
||||
Reference in New Issue
Block a user