Correctly cancel operator is there's no transform data.
Don't access RegionView3D if region is of the wrong type. Correctly draw extra transform stuff (like snap and pet circles) in multiple 3d regions.
This commit is contained in:
@@ -163,7 +163,7 @@ static void helpline(TransInfo *t, float *vec)
|
||||
|
||||
void setTransformViewMatrices(TransInfo *t)
|
||||
{
|
||||
if(t->spacetype==SPACE_VIEW3D) {
|
||||
if(t->spacetype==SPACE_VIEW3D && t->ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
|
||||
Mat4CpyMat4(t->viewmat, rv3d->viewmat);
|
||||
@@ -186,8 +186,11 @@ void setTransformViewMatrices(TransInfo *t)
|
||||
void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
|
||||
{
|
||||
if (t->spacetype==SPACE_VIEW3D) {
|
||||
if (t->ar->regiontype == RGN_TYPE_WINDOW)
|
||||
{
|
||||
window_to_3d_delta(t->ar, vec, dx, dy);
|
||||
}
|
||||
}
|
||||
else if(t->spacetype==SPACE_IMAGE) {
|
||||
View2D *v2d = t->view;
|
||||
float divx, divy, aspx, aspy;
|
||||
@@ -935,9 +938,9 @@ void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg)
|
||||
{
|
||||
TransInfo *t = arg;
|
||||
|
||||
drawConstraint(t);
|
||||
drawPropCircle(t);
|
||||
drawSnapping(t);
|
||||
drawConstraint(C, t);
|
||||
drawPropCircle(C, t);
|
||||
drawSnapping(C, t);
|
||||
}
|
||||
|
||||
void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
|
||||
@@ -1016,7 +1019,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int mode)
|
||||
int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int mode)
|
||||
{
|
||||
int options = 0;
|
||||
|
||||
@@ -1028,15 +1031,21 @@ void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, in
|
||||
|
||||
t->mode = mode;
|
||||
|
||||
initTransInfo(C, t, op, event); // internal data, mouse, vectors
|
||||
if (!initTransInfo(C, t, op, event)) // internal data, mouse, vectors
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
initTransformOrientation(C, t);
|
||||
|
||||
if(t->spacetype == SPACE_VIEW3D)
|
||||
{
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
//calc_manipulator_stats(curarea);
|
||||
if (t->ar->regiontype == RGN_TYPE_WINDOW)
|
||||
{
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
Mat3CpyMat4(t->spacemtx, rv3d->twmat);
|
||||
}
|
||||
Mat3Ortho(t->spacemtx);
|
||||
|
||||
t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
|
||||
@@ -1050,13 +1059,13 @@ void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, in
|
||||
|
||||
createTransData(C, t); // make TransData structs from selection
|
||||
|
||||
initSnapping(t); // Initialize snapping data AFTER mode flags
|
||||
|
||||
if (t->total == 0) {
|
||||
postTrans(t);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
initSnapping(t); // Initialize snapping data AFTER mode flags
|
||||
|
||||
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
|
||||
/* EVIL2: we gave as argument also texture space context bit... was cleared */
|
||||
/* EVIL3: extend mode for animation editors also switches modes... but is best way to avoid duplicate code */
|
||||
@@ -1190,6 +1199,8 @@ void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, in
|
||||
setUserConstraint(t, t->con.mode, "%s");
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void transformApply(bContext *C, TransInfo *t)
|
||||
@@ -3078,8 +3089,6 @@ int Translation(TransInfo *t, short mval[2])
|
||||
|
||||
ED_area_headerprint(t->sa, str);
|
||||
|
||||
drawSnapping(t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ typedef struct TransInfo {
|
||||
|
||||
void TFM_OT_transform(struct wmOperatorType *ot);
|
||||
|
||||
void initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event, int mode);
|
||||
int initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event, int mode);
|
||||
void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op);
|
||||
void transformEvent(TransInfo *t, struct wmEvent *event);
|
||||
void transformApply(struct bContext *C, TransInfo *t);
|
||||
@@ -454,7 +454,7 @@ void initAlign(TransInfo *t);
|
||||
int Align(TransInfo *t, short mval[2]);
|
||||
|
||||
|
||||
void drawPropCircle(TransInfo *t);
|
||||
void drawPropCircle(const struct bContext *C, TransInfo *t);
|
||||
|
||||
/*********************** transform_conversions.c ********** */
|
||||
struct ListBase;
|
||||
@@ -488,7 +488,7 @@ void autokeyframe_pose_cb_func(struct Scene *scene, struct View3D *v3d, struct O
|
||||
|
||||
/*********************** Constraints *****************************/
|
||||
|
||||
void drawConstraint(TransInfo *t);
|
||||
void drawConstraint(const struct bContext *C, TransInfo *t);
|
||||
|
||||
void getConstraintMatrix(TransInfo *t);
|
||||
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]);
|
||||
@@ -526,7 +526,7 @@ void initSnapping(struct TransInfo *t);
|
||||
void applySnapping(TransInfo *t, float *vec);
|
||||
void resetSnapping(TransInfo *t);
|
||||
int handleSnapping(TransInfo *t, struct wmEvent *event);
|
||||
void drawSnapping(TransInfo *t);
|
||||
void drawSnapping(const struct bContext *C, TransInfo *t);
|
||||
int usingSnappingNormal(TransInfo *t);
|
||||
int validSnappingNormal(TransInfo *t);
|
||||
|
||||
@@ -552,7 +552,7 @@ void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, short mval[2],
|
||||
|
||||
/*********************** Generics ********************************/
|
||||
|
||||
void initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, struct wmEvent *event);
|
||||
int initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, struct wmEvent *event);
|
||||
void postTrans (TransInfo *t);
|
||||
void resetTransRestrictions(TransInfo *t);
|
||||
|
||||
|
||||
@@ -710,7 +710,7 @@ void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text) {
|
||||
|
||||
/*----------------- DRAWING CONSTRAINTS -------------------*/
|
||||
|
||||
void drawConstraint(TransInfo *t)
|
||||
void drawConstraint(const struct bContext *C, TransInfo *t)
|
||||
{
|
||||
TransCon *tc = &(t->con);
|
||||
|
||||
@@ -769,17 +769,16 @@ void drawConstraint(TransInfo *t)
|
||||
}
|
||||
|
||||
/* called from drawview.c, as an extra per-window draw option */
|
||||
void drawPropCircle(TransInfo *t)
|
||||
void drawPropCircle(const struct bContext *C, TransInfo *t)
|
||||
{
|
||||
if (t->flag & T_PROP_EDIT) {
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
float tmat[4][4], imat[4][4];
|
||||
|
||||
UI_ThemeColor(TH_GRID);
|
||||
|
||||
if(t->spacetype == SPACE_VIEW3D)
|
||||
if(t->spacetype == SPACE_VIEW3D && rv3d != NULL)
|
||||
{
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
|
||||
Mat4CpyMat4(tmat, rv3d->viewmat);
|
||||
Mat4Invert(imat, tmat);
|
||||
}
|
||||
|
||||
@@ -5013,18 +5013,20 @@ void createTransData(bContext *C, TransInfo *t)
|
||||
t->flag |= T_POINTS;
|
||||
}
|
||||
else {
|
||||
View3D *v3d = t->view;
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
|
||||
t->flag &= ~T_PROP_EDIT; /* no proportional edit in object mode */
|
||||
createTransObject(C, t);
|
||||
t->flag |= T_OBJECT;
|
||||
|
||||
if (t->ar->regiontype == RGN_TYPE_WINDOW)
|
||||
{
|
||||
View3D *v3d = t->view;
|
||||
RegionView3D *rv3d = t->ar->regiondata;
|
||||
if((t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==V3D_CAMOB)
|
||||
{
|
||||
t->flag |= T_CAMERA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TRANSFORM_FIX_ME
|
||||
// /* temporal...? */
|
||||
|
||||
@@ -663,7 +663,7 @@ void resetTransRestrictions(TransInfo *t)
|
||||
t->flag &= ~T_ALL_RESTRICTIONS;
|
||||
}
|
||||
|
||||
void initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
|
||||
int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Scene *sce = CTX_data_scene(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
@@ -828,6 +828,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
|
||||
setTransformViewMatrices(t);
|
||||
initNumInput(&t->num);
|
||||
initNDofInput(&t->ndof);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
|
||||
|
||||
@@ -150,8 +150,9 @@ static void transformops_exit(bContext *C, wmOperator *op)
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
||||
static void transformops_data(bContext *C, wmOperator *op, wmEvent *event)
|
||||
static int transformops_data(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
int retval = 1;
|
||||
if (op->customdata == NULL)
|
||||
{
|
||||
TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
|
||||
@@ -171,11 +172,13 @@ static void transformops_data(bContext *C, wmOperator *op, wmEvent *event)
|
||||
mode = RNA_int_get(op->ptr, "mode");
|
||||
}
|
||||
|
||||
initTransform(C, t, op, event, mode);
|
||||
retval = initTransform(C, t, op, event, mode);
|
||||
|
||||
/* store data */
|
||||
op->customdata = t;
|
||||
}
|
||||
|
||||
return retval; /* return 0 on error */
|
||||
}
|
||||
|
||||
static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
@@ -214,7 +217,10 @@ static int transform_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
TransInfo *t;
|
||||
|
||||
transformops_data(C, op, NULL);
|
||||
if (!transformops_data(C, op, NULL))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
t = op->customdata;
|
||||
|
||||
@@ -231,7 +237,10 @@ static int transform_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
transformops_data(C, op, event);
|
||||
if (!transformops_data(C, op, event))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "value")) {
|
||||
return transform_exec(C, op);
|
||||
|
||||
@@ -448,7 +448,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
|
||||
void initTransformOrientation(bContext *C, TransInfo *t)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Object *obedit = CTX_data_active_object(C);
|
||||
float normal[3]={0.0, 0.0, 0.0};
|
||||
|
||||
@@ -121,7 +121,7 @@ int BIF_snappingSupported(Object *obedit)
|
||||
return status;
|
||||
}
|
||||
|
||||
void drawSnapping(TransInfo *t)
|
||||
void drawSnapping(const struct bContext *C, TransInfo *t)
|
||||
{
|
||||
if ((t->tsnap.status & (SNAP_ON|POINT_INIT|TARGET_INIT)) == (SNAP_ON|POINT_INIT|TARGET_INIT) &&
|
||||
(t->modifiers & MOD_SNAP_GEARS))
|
||||
@@ -132,8 +132,8 @@ void drawSnapping(TransInfo *t)
|
||||
glColor4ub(col[0], col[1], col[2], 128);
|
||||
|
||||
if (t->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = t->view;
|
||||
RegionView3D *rv3d= t->ar->regiondata;
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
float tmat[4][4], imat[4][4];
|
||||
float size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user