Fix T46003: Scale w/ script ignores axis-align
This commit is contained in:
parent
91264cfdd0
commit
a2b80d4c48
Notes:
blender-bot
2023-02-14 19:53:10 +01:00
Referenced by issue blender/blender-addons#46003, Axis orientation transformation via console (or python script) doesn't work in edit mode
|
@ -127,7 +127,7 @@ void BIF_createTransformOrientation(struct bContext *C, struct ReportList *repor
|
|||
void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
|
||||
void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
|
||||
|
||||
void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], const bool activeOnly);
|
||||
void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], const short around);
|
||||
|
||||
int BIF_countTransformOrientation(const struct bContext *C);
|
||||
|
||||
|
|
|
@ -3769,7 +3769,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar,
|
|||
float twmat[3][3];
|
||||
|
||||
/* same as transform manipulator when normal is set */
|
||||
ED_getTransformOrientationMatrix(C, twmat, true);
|
||||
ED_getTransformOrientationMatrix(C, twmat, V3D_ACTIVE);
|
||||
|
||||
mat3_to_quat(obact_quat, twmat);
|
||||
invert_qt(obact_quat);
|
||||
|
|
|
@ -2075,47 +2075,41 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
t->launch_event = LEFTMOUSE;
|
||||
}
|
||||
|
||||
unit_m3(t->spacemtx);
|
||||
|
||||
initTransInfo(C, t, op, event);
|
||||
initTransformOrientation(C, t);
|
||||
|
||||
if (t->spacetype == SPACE_VIEW3D) {
|
||||
initTransformOrientation(C, t);
|
||||
|
||||
t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);
|
||||
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
|
||||
t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
|
||||
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
|
||||
}
|
||||
else if (t->spacetype == SPACE_IMAGE) {
|
||||
unit_m3(t->spacemtx);
|
||||
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
|
||||
//t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
|
||||
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
|
||||
}
|
||||
else if (t->spacetype == SPACE_CLIP) {
|
||||
unit_m3(t->spacemtx);
|
||||
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
|
||||
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
|
||||
}
|
||||
else if (t->spacetype == SPACE_NODE) {
|
||||
unit_m3(t->spacemtx);
|
||||
/*t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);*/
|
||||
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
|
||||
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
|
||||
}
|
||||
else if (t->spacetype == SPACE_IPO) {
|
||||
unit_m3(t->spacemtx);
|
||||
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
|
||||
//t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
|
||||
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
|
||||
}
|
||||
else if (t->spacetype == SPACE_ACTION) {
|
||||
unit_m3(t->spacemtx);
|
||||
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
|
||||
//t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
|
||||
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
|
||||
}
|
||||
else
|
||||
unit_m3(t->spacemtx);
|
||||
|
||||
createTransData(C, t); // make TransData structs from selection
|
||||
|
||||
|
|
|
@ -727,7 +727,7 @@ bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const floa
|
|||
|
||||
struct TransformOrientation *addMatrixSpace(struct bContext *C, float mat[3][3],
|
||||
const char *name, const bool overwrite);
|
||||
bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char r_name[64]);
|
||||
bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char r_name[64], int index);
|
||||
|
||||
#define ORIENTATION_NONE 0
|
||||
#define ORIENTATION_NORMAL 1
|
||||
|
@ -735,7 +735,8 @@ bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char r
|
|||
#define ORIENTATION_EDGE 3
|
||||
#define ORIENTATION_FACE 4
|
||||
|
||||
int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3], const bool activeOnly);
|
||||
int getTransformOrientation_ex(const struct bContext *C, float normal[3], float plane[3], const short around);
|
||||
int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]);
|
||||
|
||||
void freeEdgeSlideTempFaces(EdgeSlideData *sld);
|
||||
void freeEdgeSlideVerts(TransInfo *t);
|
||||
|
|
|
@ -1207,18 +1207,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
t->around = V3D_CURSOR;
|
||||
}
|
||||
|
||||
if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
||||
RNA_property_is_set(op->ptr, prop)))
|
||||
{
|
||||
t->current_orientation = RNA_property_enum_get(op->ptr, prop);
|
||||
|
||||
if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C)) {
|
||||
t->current_orientation = V3D_MANIP_GLOBAL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
t->current_orientation = v3d->twmode;
|
||||
}
|
||||
t->current_orientation = v3d->twmode;
|
||||
|
||||
/* exceptional case */
|
||||
if (t->around == V3D_LOCAL) {
|
||||
|
@ -1305,6 +1294,16 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
}
|
||||
t->around = V3D_CENTER;
|
||||
}
|
||||
|
||||
if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
||||
RNA_property_is_set(op->ptr, prop)))
|
||||
{
|
||||
t->current_orientation = RNA_property_enum_get(op->ptr, prop);
|
||||
|
||||
if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C)) {
|
||||
t->current_orientation = V3D_MANIP_GLOBAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
|
||||
RNA_property_is_set(op->ptr, prop)))
|
||||
|
|
|
@ -568,7 +568,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
{
|
||||
if (obedit || ob->mode & OB_MODE_POSE) {
|
||||
float mat[3][3];
|
||||
ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE));
|
||||
ED_getTransformOrientationMatrix(C, mat, v3d->around);
|
||||
copy_m4_m3(rv3d->twmat, mat);
|
||||
break;
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
* and users who select many bones will understand whats going on and what local means
|
||||
* when they start transforming */
|
||||
float mat[3][3];
|
||||
ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE));
|
||||
ED_getTransformOrientationMatrix(C, mat, v3d->around);
|
||||
copy_m4_m3(rv3d->twmat, mat);
|
||||
break;
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ static int calc_manipulator_stats(const bContext *C)
|
|||
default: /* V3D_MANIP_CUSTOM */
|
||||
{
|
||||
float mat[3][3];
|
||||
if (applyTransformOrientation(C, mat, NULL)) {
|
||||
if (applyTransformOrientation(C, mat, NULL, v3d->twmode - V3D_MANIP_CUSTOM)) {
|
||||
copy_m4_m3(rv3d->twmat, mat);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
@ -144,7 +145,7 @@ static TransformOrientation *createBoneSpace(bContext *C, ReportList *reports,
|
|||
float mat[3][3];
|
||||
float normal[3], plane[3];
|
||||
|
||||
getTransformOrientation(C, normal, plane, 0);
|
||||
getTransformOrientation(C, normal, plane);
|
||||
|
||||
if (createSpaceNormalTangent(mat, normal, plane) == 0) {
|
||||
BKE_reports_prepend(reports, "Cannot use zero-length bone");
|
||||
|
@ -164,7 +165,7 @@ static TransformOrientation *createCurveSpace(bContext *C, ReportList *reports,
|
|||
float mat[3][3];
|
||||
float normal[3], plane[3];
|
||||
|
||||
getTransformOrientation(C, normal, plane, 0);
|
||||
getTransformOrientation(C, normal, plane);
|
||||
|
||||
if (createSpaceNormalTangent(mat, normal, plane) == 0) {
|
||||
BKE_reports_prepend(reports, "Cannot use zero-length curve");
|
||||
|
@ -186,7 +187,7 @@ static TransformOrientation *createMeshSpace(bContext *C, ReportList *reports,
|
|||
float normal[3], plane[3];
|
||||
int type;
|
||||
|
||||
type = getTransformOrientation(C, normal, plane, 0);
|
||||
type = getTransformOrientation(C, normal, plane);
|
||||
|
||||
switch (type) {
|
||||
case ORIENTATION_VERT:
|
||||
|
@ -390,15 +391,12 @@ int BIF_countTransformOrientation(const bContext *C)
|
|||
return BLI_listbase_count(transform_spaces);
|
||||
}
|
||||
|
||||
bool applyTransformOrientation(const bContext *C, float mat[3][3], char *r_name)
|
||||
bool applyTransformOrientation(const bContext *C, float mat[3][3], char *r_name, int index)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
|
||||
|
||||
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
|
||||
TransformOrientation *ts = BLI_findlink(transform_spaces, selected_index);
|
||||
const TransformOrientation *ts = BLI_findlink(transform_spaces, index);
|
||||
|
||||
BLI_assert(selected_index >= 0);
|
||||
BLI_assert(index >= 0);
|
||||
|
||||
if (ts) {
|
||||
if (r_name) {
|
||||
|
@ -442,7 +440,6 @@ static int count_bone_select(bArmature *arm, ListBase *lb, const bool do_it)
|
|||
|
||||
void initTransformOrientation(bContext *C, TransInfo *t)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Object *obedit = CTX_data_active_object(C);
|
||||
|
||||
|
@ -462,7 +459,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||
case V3D_MANIP_NORMAL:
|
||||
if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
|
||||
BLI_strncpy(t->spacename, IFACE_("normal"), sizeof(t->spacename));
|
||||
ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE));
|
||||
ED_getTransformOrientationMatrix(C, t->spacemtx, t->around);
|
||||
break;
|
||||
}
|
||||
/* fall-through */ /* we define 'normal' as 'local' in Object mode */
|
||||
|
@ -480,7 +477,9 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||
break;
|
||||
|
||||
case V3D_MANIP_VIEW:
|
||||
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
if ((t->spacetype == SPACE_VIEW3D) &&
|
||||
(t->ar->regiontype == RGN_TYPE_WINDOW))
|
||||
{
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
float mat[3][3];
|
||||
|
||||
|
@ -494,7 +493,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||
}
|
||||
break;
|
||||
default: /* V3D_MANIP_CUSTOM */
|
||||
if (applyTransformOrientation(C, t->spacemtx, t->spacename)) {
|
||||
if (applyTransformOrientation(C, t->spacemtx, t->spacename, t->current_orientation - V3D_MANIP_CUSTOM)) {
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
|
@ -585,14 +584,14 @@ static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const
|
|||
}
|
||||
#endif
|
||||
|
||||
int getTransformOrientation(const bContext *C, float normal[3], float plane[3], const bool activeOnly)
|
||||
int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3], const short around)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Base *base;
|
||||
Object *ob = OBACT;
|
||||
int result = ORIENTATION_NONE;
|
||||
const bool activeOnly = (around == V3D_ACTIVE);
|
||||
|
||||
zero_v3(normal);
|
||||
zero_v3(plane);
|
||||
|
@ -855,7 +854,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
|
|||
/* exception */
|
||||
if (flag) {
|
||||
float tvec[3];
|
||||
if ((v3d->around == V3D_LOCAL) ||
|
||||
if ((around == V3D_LOCAL) ||
|
||||
ELEM(flag, SEL_F2, SEL_F1 | SEL_F3, SEL_F1 | SEL_F2 | SEL_F3))
|
||||
{
|
||||
BKE_nurb_bezt_calc_normal(nu, bezt, tvec);
|
||||
|
@ -1017,6 +1016,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
|
|||
}
|
||||
else {
|
||||
/* we need the one selected object, if its not active */
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ob = OBACT;
|
||||
if (ob && (ob->flag & SELECT)) {
|
||||
/* pass */
|
||||
|
@ -1042,14 +1042,22 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
|
|||
return result;
|
||||
}
|
||||
|
||||
void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[3][3], const bool activeOnly)
|
||||
int getTransformOrientation(const bContext *C, float normal[3], float plane[3])
|
||||
{
|
||||
/* dummy value, not V3D_ACTIVE and not V3D_LOCAL */
|
||||
short around = V3D_CENTER;
|
||||
|
||||
getTransformOrientation_ex(C, normal, plane, around);
|
||||
}
|
||||
|
||||
void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[3][3], const short around)
|
||||
{
|
||||
float normal[3] = {0.0, 0.0, 0.0};
|
||||
float plane[3] = {0.0, 0.0, 0.0};
|
||||
|
||||
int type;
|
||||
|
||||
type = getTransformOrientation(C, normal, plane, activeOnly);
|
||||
type = getTransformOrientation_ex(C, normal, plane, around);
|
||||
|
||||
switch (type) {
|
||||
case ORIENTATION_NORMAL:
|
||||
|
|
Loading…
Reference in New Issue