Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-01-19 00:36:38 +0300
committerMartin Poirier <theeth@yahoo.com>2009-01-19 00:36:38 +0300
commit6d85a0febaea736ee9172b9c9877e79006b43986 (patch)
tree041d208d56d1beccfa1ee592102dc81775762866
parent54a0f4167b76dddca8288dd54b285c32fab1a945 (diff)
2.5
Transform orientations (Alt-Space and in header) enum for transform operator parameter.
-rw-r--r--source/blender/editors/include/BIF_transform.h16
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c14
-rw-r--r--source/blender/editors/transform/transform.c2
-rw-r--r--source/blender/editors/transform/transform.h19
-rw-r--r--source/blender/editors/transform/transform_constraints.c7
-rw-r--r--source/blender/editors/transform/transform_conversions.c24
-rw-r--r--source/blender/editors/transform/transform_manipulator.c2
-rw-r--r--source/blender/editors/transform/transform_ops.c86
-rw-r--r--source/blender/editors/transform/transform_orientations.c227
9 files changed, 282 insertions, 115 deletions
diff --git a/source/blender/editors/include/BIF_transform.h b/source/blender/editors/include/BIF_transform.h
index 652df094821..5039d5e0f7e 100644
--- a/source/blender/editors/include/BIF_transform.h
+++ b/source/blender/editors/include/BIF_transform.h
@@ -96,7 +96,6 @@ struct ScrArea;
struct Base;
struct Scene;
-struct TransInfo * BIF_GetTransInfo(void);
void BIF_setSingleAxisConstraint(float vec[3], char *text);
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text);
void BIF_setLocalAxisConstraint(char axis, char *text);
@@ -105,16 +104,17 @@ void BIF_setLocalLockConstraint(char axis, char *text);
int BIF_snappingSupported(struct Object *obedit);
struct TransformOrientation;
+struct bContext;
-void BIF_clearTransformOrientation(void);
-void BIF_removeTransformOrientation(struct TransformOrientation *ts);
-void BIF_manageTransformOrientation(int confirm, int set);
+void BIF_clearTransformOrientation(struct bContext *C);
+void BIF_removeTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
+void BIF_manageTransformOrientation(struct bContext *C, int confirm, int set);
int BIF_menuselectTransformOrientation(void);
-void BIF_selectTransformOrientation(struct TransformOrientation *ts);
-void BIF_selectTransformOrientationFromIndex(int index);
+void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
+void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
-char * BIF_menustringTransformOrientation(char *title); /* the returned value was allocated and needs to be freed after use */
-int BIF_countTransformOrientation();
+char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
+int BIF_countTransformOrientation(const struct bContext *C);
void BIF_getPropCenter(float *center);
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 7d3ae203cd2..fd37b5bcddd 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -5821,7 +5821,7 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
xco+= XIC+10;
} else {
/* Manipulators arnt used in weight paint mode */
-// XXX char *str_menu;
+ char *str_menu;
uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, around_pup(C), xco,yco,XIC+10,YIC, &(v3d->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period, Ctrl Period, Alt Period)");
xco+= XIC+10;
@@ -5865,13 +5865,13 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
xco+= XIC;
}
-// XXX if (v3d->twmode > (BIF_countTransformOrientation() - 1) + V3D_MANIP_CUSTOM) {
-// v3d->twmode = 0;
-// }
+ if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
+ v3d->twmode = 0;
+ }
-// XXX str_menu = BIF_menustringTransformOrientation("Orientation");
-// uiDefButS(block, MENU, B_MAN_MODE, str_menu,xco,yco,70,YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation (ALT+Space)");
-// MEM_freeN(str_menu);
+ str_menu = BIF_menustringTransformOrientation(C, "Orientation");
+ uiDefButS(block, MENU, B_MAN_MODE, str_menu,xco,yco,70,YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation (ALT+Space)");
+ MEM_freeN(str_menu);
xco+= 70;
uiBlockEndAlign(block);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 22ecc33c851..95878a35b62 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -990,6 +990,8 @@ void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->mode = mode;
initTransInfo(C, t, event); // internal data, mouse, vectors
+
+ initTransformOrientation(C, t);
if(t->spacetype == SPACE_VIEW3D)
{
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index fb1a82d232c..6198a8ec145 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -307,8 +307,7 @@ typedef struct TransInfo {
#define CON_AXIS2 8
#define CON_SELECT 16
#define CON_NOFLIP 32 /* does not reorient vector to face viewport when on */
-#define CON_LOCAL 64
-#define CON_USER 128
+#define CON_USER 64
/* transdata->flag */
#define TD_SELECTED 1
@@ -577,19 +576,21 @@ int handleNDofInput(NDofInput *n, struct wmEvent *event);
#define NDOF_CANCEL 4
-/*********************** TransSpace ******************************/
+/*********************** Transform Orientations ******************************/
-int manageObjectSpace(int confirm, int set);
-int manageMeshSpace(int confirm, int set);
-int manageBoneSpace(int confirm, int set);
+void initTransformOrientation(struct bContext *C, TransInfo *t);
+
+int manageObjectSpace(struct bContext *C, int confirm, int set);
+int manageMeshSpace(struct bContext *C, int confirm, int set);
+int manageBoneSpace(struct bContext *C, int confirm, int set);
/* Those two fill in mat and return non-zero on success */
int createSpaceNormal(float mat[3][3], float normal[3]);
int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]);
-int addMatrixSpace(float mat[3][3], char name[]);
-int addObjectSpace(struct Object *ob);
-void applyTransformOrientation(void);
+int addMatrixSpace(struct bContext *C, float mat[3][3], char name[]);
+int addObjectSpace(struct bContext *C, struct Object *ob);
+void applyTransformOrientation(struct bContext *C, TransInfo *t);
#define ORIENTATION_NONE 0
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index bebf8ccc0e6..0c0c78c969d 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -490,16 +490,16 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
if (t->flag & T_EDIT) {
float obmat[3][3];
Mat3CpyMat4(obmat, t->scene->obedit->obmat);
- setConstraint(t, obmat, mode|CON_LOCAL, text);
+ setConstraint(t, obmat, mode, text);
}
else {
if (t->total == 1) {
- setConstraint(t, t->data->axismtx, mode|CON_LOCAL, text);
+ setConstraint(t, t->data->axismtx, mode, text);
}
else {
strncpy(t->con.text + 1, text, 48);
Mat3CpyMat3(t->con.mtx, t->data->axismtx);
- t->con.mode = mode|CON_LOCAL;
+ t->con.mode = mode;
getConstraintMatrix(t);
startConstraint(t);
@@ -869,7 +869,6 @@ void initSelectConstraint(TransInfo *t, float mtx[3][3])
Mat3CpyMat3(t->con.mtx, mtx);
t->con.mode |= CON_APPLY;
t->con.mode |= CON_SELECT;
- t->con.mode &= ~CON_LOCAL;
setNearestAxis(t);
t->con.drawExtra = NULL;
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index d8421bb7a60..2f7a3821022 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1553,8 +1553,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
static void createTransLatticeVerts(bContext *C, TransInfo *t)
{
- // TRANSFORM_FIX_ME
-#if 0
+ Lattice *latt = ((Lattice*)t->obedit->data)->editlatt;
TransData *td = NULL;
BPoint *bp;
float mtx[3][3], smtx[3][3];
@@ -1562,8 +1561,8 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t)
int count=0, countsel=0;
int propmode = t->flag & T_PROP_EDIT;
- bp= editLatt->def;
- a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
+ bp = latt->def;
+ a = latt->pntsu * latt->pntsv * latt->pntsw;
while(a--) {
if(bp->hide==0) {
if(bp->f1 & SELECT) countsel++;
@@ -1583,8 +1582,8 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t)
Mat3Inv(smtx, mtx);
td = t->data;
- bp= editLatt->def;
- a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
+ bp = latt->def;
+ a = latt->pntsu * latt->pntsv * latt->pntsw;
while(a--) {
if(propmode || (bp->f1 & SELECT)) {
if(bp->hide==0) {
@@ -1606,7 +1605,6 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t)
}
bp++;
}
-#endif
}
/* ******************* particle edit **************** */
@@ -2342,8 +2340,8 @@ static void UVsToTransData(TransData *td, TransData2D *td2d, float *uv, int sele
static void createTransUVs(bContext *C, TransInfo *t)
{
- // TRANSFORM_FIX_ME
-#if 0
+#if 0 // TRANSFORM_FIX_ME
+ SpaceImage *sima = (SpaceImage*)CTX_wm_space_data(C);
TransData *td = NULL;
TransData2D *td2d = NULL;
MTFace *tf;
@@ -2357,7 +2355,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
if(is_uv_tface_editing_allowed()==0) return;
/* count */
- if (G.sima->flag & SI_BE_SQUARE && !propmode) {
+ if (sima->flag & SI_BE_SQUARE && !propmode) {
for (efa= em->faces.first; efa; efa= efa->next) {
/* store face pointer for second loop, prevent second lookup */
tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -2409,13 +2407,13 @@ static void createTransUVs(bContext *C, TransInfo *t)
treated just as if they were 3d verts */
t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransObData2D(UV Editing)");
- if(G.sima->flag & SI_CLIP_UV)
+ if(sima->flag & SI_CLIP_UV)
t->flag |= T_CLIP_UV;
td= t->data;
td2d= t->data2d;
- if (G.sima->flag & SI_BE_SQUARE && !propmode) {
+ if (sima->flag & SI_BE_SQUARE && !propmode) {
for (efa= em->faces.first; efa; efa= efa->next) {
tf=(MTFace *)efa->tmp.p;
if (tf) {
@@ -2474,7 +2472,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
}
}
- if (G.sima->flag & SI_LIVE_UNWRAP)
+ if (sima->flag & SI_LIVE_UNWRAP)
unwrap_lscm_live_begin();
#endif
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 8dbd5f5c774..5312050b2d9 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -219,7 +219,7 @@ int calc_manipulator_stats(ScrArea *sa)
float plane[3]={0.0, 0.0, 0.0};
int a, totsel=0;
- t = BIF_GetTransInfo();
+//XXX t = BIF_GetTransInfo();
/* transform widget matrix */
Mat4One(v3d->twmat);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 2eec6252c18..c89ab10c2a9 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -38,10 +38,56 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "UI_interface.h"
+
#include "ED_screen.h"
#include "transform.h"
+
+static int select_orientation_exec(bContext *C, wmOperator *op)
+{
+ int orientation = RNA_int_get(op->ptr, "orientation");
+
+ if (orientation > -1)
+ {
+ BIF_selectTransformOrientationValue(C, orientation);
+ return OPERATOR_FINISHED;
+ }
+ else
+ {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ char *string = BIF_menustringTransformOrientation(C, "Orientation");
+
+ op->customdata = string;
+
+ uiPupmenuOperator(C, 0, op, "orientation", string);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void TFM_OT_select_orientation(struct wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Select Orientation";
+ ot->idname = "TFM_OT_select_orientation";
+
+ /* api callbacks */
+ ot->invoke = select_orientation_invoke;
+ ot->exec = select_orientation_exec;
+ ot->poll = ED_operator_areaactive;
+
+ prop = RNA_def_property(ot->srna, "orientation", PROP_INT, PROP_NONE);
+ RNA_def_property_array(prop, -1);
+}
+
static void transformops_exit(bContext *C, wmOperator *op)
{
saveTransform(C, op->customdata, op);
@@ -91,7 +137,7 @@ static int transform_cancel(bContext *C, wmOperator *op)
transformEnd(C, t);
transformops_exit(C, op);
- return OPERATOR_FINISHED;
+ return OPERATOR_CANCELLED;
}
static int transform_exec(bContext *C, wmOperator *op)
@@ -136,6 +182,36 @@ void TFM_OT_transform(struct wmOperatorType *ot)
{
static const float value[4] = {0, 0, 0};
static const float mtx[3][3] = {{1, 0, 0},{0, 1, 0},{0, 0, 1}};
+ static EnumPropertyItem transform_mode_types[] = {
+ {TFM_INIT, "INIT", "Init", ""},
+ {TFM_DUMMY, "DUMMY", "Dummy", ""},
+ {TFM_TRANSLATION, "TRANSLATION", "Translation", ""},
+ {TFM_ROTATION, "ROTATION", "Rotation", ""},
+ {TFM_RESIZE, "RESIZE", "Resize", ""},
+ {TFM_TOSPHERE, "TOSPHERE", "Tosphere", ""},
+ {TFM_SHEAR, "SHEAR", "Shear", ""},
+ {TFM_WARP, "WARP", "Warp", ""},
+ {TFM_SHRINKFATTEN, "SHRINKFATTEN", "Shrinkfatten", ""},
+ {TFM_TILT, "TILT", "Tilt", ""},
+ {TFM_LAMP_ENERGY, "LAMP_ENERGY", "Lamp_Energy", ""},
+ {TFM_TRACKBALL, "TRACKBALL", "Trackball", ""},
+ {TFM_PUSHPULL, "PUSHPULL", "Pushpull", ""},
+ {TFM_CREASE, "CREASE", "Crease", ""},
+ {TFM_MIRROR, "MIRROR", "Mirror", ""},
+ {TFM_BONESIZE, "BONESIZE", "Bonesize", ""},
+ {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", "Bone_Envelope", ""},
+ {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", "Curve_Shrinkfatten", ""},
+ {TFM_BONE_ROLL, "BONE_ROLL", "Bone_Roll", ""},
+ {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", "Time_Translate", ""},
+ {TFM_TIME_SLIDE, "TIME_SLIDE", "Time_Slide", ""},
+ {TFM_TIME_SCALE, "TIME_SCALE", "Time_Scale", ""},
+ {TFM_TIME_EXTEND, "TIME_EXTEND", "Time_Extend", ""},
+ {TFM_BAKE_TIME, "BAKE_TIME", "Bake_Time", ""},
+ {TFM_BEVEL, "BEVEL", "Bevel", ""},
+ {TFM_BWEIGHT, "BWEIGHT", "Bweight", ""},
+ {TFM_ALIGN, "ALIGN", "Align", ""},
+ {0, NULL, NULL, NULL}
+ };
/* identifiers */
ot->name = "Transform";
@@ -149,7 +225,7 @@ void TFM_OT_transform(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_areaactive;
- RNA_def_int(ot->srna, "mode", 0, INT_MIN, INT_MAX, "Mode", "", INT_MIN, INT_MAX);
+ RNA_def_enum(ot->srna, "mode", transform_mode_types, 0, "Mode", "");
RNA_def_int(ot->srna, "options", 0, INT_MIN, INT_MAX, "Options", "", INT_MIN, INT_MAX);
RNA_def_float_vector(ot->srna, "values", 4, value, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
@@ -157,12 +233,16 @@ void TFM_OT_transform(struct wmOperatorType *ot)
RNA_def_int(ot->srna, "constraint_orientation", 0, INT_MIN, INT_MAX, "Constraint Orientation", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "constraint_mode", 0, INT_MIN, INT_MAX, "Constraint Mode", "", INT_MIN, INT_MAX);
+// prop = RNA_def_property(ot->srna, "constraint_matrix", PROP_FLOAT, PROP_MATRIX);
+// RNA_def_property_array(prop, 9);
+// RNA_def_property_float_array_default(prop, (float*)mtx);
RNA_def_float_matrix(ot->srna, "constraint_matrix", 9, mtx[0], -FLT_MAX, FLT_MAX, "Constraint Matrix", "", -FLT_MAX, FLT_MAX);
}
void transform_operatortypes(void)
{
WM_operatortype_append(TFM_OT_transform);
+ WM_operatortype_append(TFM_OT_select_orientation);
}
void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid)
@@ -189,6 +269,8 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
km = WM_keymap_add_item(keymap, "TFM_OT_transform", SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0);
RNA_int_set(km->ptr, "mode", TFM_SHEAR);
+ km = WM_keymap_add_item(keymap, "TFM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
+
break;
case SPACE_ACTION:
km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 4605baa18f6..5fe45f2e94a 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -55,16 +55,15 @@
#include "ED_armature.h"
#include "ED_mesh.h"
+#include "ED_util.h"
#include "transform.h"
-#if 0 // TRANSFORM_FIX_ME
-
/* *********************** TransSpace ************************** */
-void BIF_clearTransformOrientation(void)
+void BIF_clearTransformOrientation(bContext *C)
{
- ListBase *transform_spaces = &G.scene->transform_spaces;
+ ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
BLI_freelistN(transform_spaces);
// TRANSFORM_FIX_ME
@@ -73,45 +72,46 @@ void BIF_clearTransformOrientation(void)
// G.vd->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
-void BIF_manageTransformOrientation(int confirm, int set) {
- Object *ob = OBACT;
+void BIF_manageTransformOrientation(bContext *C, int confirm, int set) {
+ Object *obedit = CTX_data_edit_object(C);
+ Object *ob = CTX_data_active_object(C);
int index = -1;
- if (t->obedit) {
- if (t->obedit->type == OB_MESH)
- index = manageMeshSpace(confirm, set);
- else if (t->obedit->type == OB_ARMATURE)
- index = manageBoneSpace(confirm, set);
+ if (obedit) {
+ if (obedit->type == OB_MESH)
+ index = manageMeshSpace(C, confirm, set);
+ else if (obedit->type == OB_ARMATURE)
+ index = manageBoneSpace(C, confirm, set);
}
else if (ob && (ob->flag & OB_POSEMODE)) {
- index = manageBoneSpace(confirm, set);
+ index = manageBoneSpace(C, confirm, set);
}
else {
- index = manageObjectSpace(confirm, set);
+ index = manageObjectSpace(C, confirm, set);
}
if (set && index != -1)
{
- BIF_selectTransformOrientationFromIndex(index);
+ BIF_selectTransformOrientationValue(C, V3D_MANIP_CUSTOM + index);
}
}
-int manageObjectSpace(int confirm, int set) {
- Base *base = BASACT;
+int manageObjectSpace(bContext *C, int confirm, int set) {
+ Base *base = CTX_data_active_base(C);
if (base == NULL)
return -1;
- if (confirm == 0) {
- if (set && pupmenu("Custom Orientation %t|Add and Use Active Object%x1") != 1) {
- return -1;
- }
- else if (set == 0 && pupmenu("Custom Orientation %t|Add Active Object%x1") != 1) {
- return -1;
- }
- }
+//XXX if (confirm == 0) {
+// if (set && pupmenu("Custom Orientation %t|Add and Use Active Object%x1") != 1) {
+// return -1;
+// }
+// else if (set == 0 && pupmenu("Custom Orientation %t|Add Active Object%x1") != 1) {
+// return -1;
+// }
+// }
- return addObjectSpace(base->object);
+ return addObjectSpace(C, base->object);
}
/* return 1 on confirm */
@@ -126,48 +126,48 @@ int confirmSpace(int set, char text[])
sprintf(menu, "Custom Orientation %%t|Add %s%%x1", text);
}
- if (pupmenu(menu) == 1) {
+//XXX if (pupmenu(menu) == 1) {
return 1;
- }
- else {
- return 0;
- }
+// }
+// else {
+// return 0;
+// }
}
-int manageBoneSpace(int confirm, int set) {
+int manageBoneSpace(bContext *C, int confirm, int set) {
float mat[3][3];
float normal[3], plane[3];
char name[36] = "";
int index;
- getTransformOrientation(normal, plane, 0);
+ getTransformOrientation(C, normal, plane, 0);
if (confirm == 0 && confirmSpace(set, "Bone") == 0) {
return -1;
}
if (createSpaceNormalTangent(mat, normal, plane) == 0) {
- error("Cannot use zero-length bone");
+//XXX error("Cannot use zero-length bone");
return -1;
}
strcpy(name, "Bone");
/* Input name */
- sbutton(name, 1, 35, "name: ");
+//XXX sbutton(name, 1, 35, "name: ");
- index = addMatrixSpace(mat, name);
+ index = addMatrixSpace(C, mat, name);
return index;
}
-int manageMeshSpace(int confirm, int set) {
+int manageMeshSpace(bContext *C, int confirm, int set) {
float mat[3][3];
float normal[3], plane[3];
char name[36] = "";
int index;
int type;
- type = getTransformOrientation(normal, plane, 0);
+ type = getTransformOrientation(C, normal, plane, 0);
switch (type)
{
@@ -213,9 +213,9 @@ int manageMeshSpace(int confirm, int set) {
}
/* Input name */
- sbutton(name, 1, 35, "name: ");
+//XXX sbutton(name, 1, 35, "name: ");
- index = addMatrixSpace(mat, name);
+ index = addMatrixSpace(C, mat, name);
return index;
}
@@ -268,7 +268,7 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
}
-int addObjectSpace(Object *ob) {
+int addObjectSpace(bContext *C, Object *ob) {
float mat[3][3];
char name[36] = "";
@@ -278,13 +278,13 @@ int addObjectSpace(Object *ob) {
strncpy(name, ob->id.name+2, 35);
/* Input name */
- sbutton(name, 1, 35, "name: ");
+//XXX sbutton(name, 1, 35, "name: ");
- return addMatrixSpace(mat, name);
+ return addMatrixSpace(C, mat, name);
}
-int addMatrixSpace(float mat[3][3], char name[]) {
- ListBase *transform_spaces = &G.scene->transform_spaces;
+int addMatrixSpace(bContext *C, float mat[3][3], char name[]) {
+ ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int index = 0;
@@ -306,58 +306,61 @@ int addMatrixSpace(float mat[3][3], char name[]) {
/* copy matrix into transform space */
Mat3CpyMat3(ts->mat, mat);
- BIF_undo_push("Add/Update Transform Orientation");
+ ED_undo_push(C, "Add/Update Transform Orientation");
return index;
}
-void BIF_removeTransformOrientation(TransformOrientation *target) {
- ListBase *transform_spaces = &G.scene->transform_spaces;
+void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) {
+ ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts = transform_spaces->first;
- int selected_index = (G.vd->twmode - V3D_MANIP_CUSTOM);
+ //int selected_index = (G.vd->twmode - V3D_MANIP_CUSTOM);
int i;
for (i = 0, ts = transform_spaces->first; ts; ts = ts->next, i++) {
if (ts == target) {
- if (selected_index == i) {
- G.vd->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
- }
- else if (selected_index > i)
- G.vd->twmode--;
+ // Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D
+// if (selected_index == i) {
+// G.vd->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
+// }
+// else if (selected_index > i)
+// G.vd->twmode--;
BLI_freelinkN(transform_spaces, ts);
break;
}
}
- BIF_undo_push("Remove Transform Orientation");
+ ED_undo_push(C, "Remove Transform Orientation");
}
-void BIF_selectTransformOrientation(TransformOrientation *target) {
- ListBase *transform_spaces = &G.scene->transform_spaces;
+void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) {
+ ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
+ View3D *v3d = CTX_wm_area(C)->spacedata.first;
TransformOrientation *ts = transform_spaces->first;
int i;
for (i = 0, ts = transform_spaces->first; ts; ts = ts->next, i++) {
if (ts == target) {
- G.vd->twmode = V3D_MANIP_CUSTOM + i;
+ v3d->twmode = V3D_MANIP_CUSTOM + i;
break;
}
}
}
-void BIF_selectTransformOrientationFromIndex(int index) {
- G.vd->twmode = V3D_MANIP_CUSTOM + index;
+void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
+ View3D *v3d = CTX_wm_area(C)->spacedata.first;
+ v3d->twmode = orientation;
}
-char * BIF_menustringTransformOrientation(char *title) {
+char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
char menu[] = "%t|Global%x0|Local%x1|Normal%x2|View%x3";
- ListBase *transform_spaces = &G.scene->transform_spaces;
+ ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int i = V3D_MANIP_CUSTOM;
char *str_menu, *p;
- str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + 40 * BIF_countTransformOrientation(), "UserTransSpace from matrix");
+ str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + 40 * BIF_countTransformOrientation(C), "UserTransSpace from matrix");
p = str_menu;
p += sprintf(str_menu, "%s", title);
@@ -370,8 +373,8 @@ char * BIF_menustringTransformOrientation(char *title) {
return str_menu;
}
-int BIF_countTransformOrientation() {
- ListBase *transform_spaces = &G.scene->transform_spaces;
+int BIF_countTransformOrientation(const bContext *C) {
+ ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int count = 0;
@@ -382,26 +385,24 @@ int BIF_countTransformOrientation() {
return count;
}
-void applyTransformOrientation() {
- TransInfo *t = BIF_GetTransInfo();
+void applyTransformOrientation(bContext *C, TransInfo *t) {
TransformOrientation *ts;
- int selected_index = (G.vd->twmode - V3D_MANIP_CUSTOM);
+ View3D *v3d = CTX_wm_area(C)->spacedata.first;
+ int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
int i;
if (selected_index >= 0) {
- for (i = 0, ts = G.scene->transform_spaces.first; ts; ts = ts->next, i++) {
+ for (i = 0, ts = CTX_data_scene(C)->transform_spaces.first; ts; ts = ts->next, i++) {
if (selected_index == i) {
strcpy(t->spacename, ts->name);
Mat3CpyMat3(t->spacemtx, ts->mat);
- Mat4CpyMat3(G.vd->twmat, ts->mat);
+ Mat4CpyMat3(v3d->twmat, ts->mat);
break;
}
}
}
}
-#endif // TRANSFORM_FIX_ME
-
static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
{
Bone *bone;
@@ -426,6 +427,88 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
return total;
}
+void initTransformOrientation(bContext *C, TransInfo *t)
+{
+ View3D *v3d = CTX_wm_area(C)->spacedata.first;
+ Object *ob = CTX_data_active_object(C);
+ Object *obedit = CTX_data_active_object(C);
+ float normal[3]={0.0, 0.0, 0.0};
+ float plane[3]={0.0, 0.0, 0.0};
+
+ switch(v3d->twmode) {
+ case V3D_MANIP_GLOBAL:
+ strcpy(t->spacename, "global");
+ break;
+
+ case V3D_MANIP_NORMAL:
+ if(obedit || ob->flag & OB_POSEMODE) {
+ float mat[3][3];
+ int type;
+
+ strcpy(t->spacename, "normal");
+
+ type = getTransformOrientation(C, normal, plane, (v3d->around == V3D_ACTIVE));
+
+ switch (type)
+ {
+ case ORIENTATION_NORMAL:
+ if (createSpaceNormalTangent(mat, normal, plane) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ case ORIENTATION_VERT:
+ if (createSpaceNormal(mat, normal) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ case ORIENTATION_EDGE:
+ if (createSpaceNormalTangent(mat, normal, plane) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ case ORIENTATION_FACE:
+ if (createSpaceNormalTangent(mat, normal, plane) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ }
+
+ if (type == ORIENTATION_NONE)
+ {
+ Mat4One(v3d->twmat);
+ }
+ else
+ {
+ Mat4CpyMat3(v3d->twmat, mat);
+ }
+ break;
+ }
+ /* no break we define 'normal' as 'local' in Object mode */
+ case V3D_MANIP_LOCAL:
+ strcpy(t->spacename, "local");
+ Mat4CpyMat4(v3d->twmat, ob->obmat);
+ Mat4Ortho(v3d->twmat);
+ break;
+
+ case V3D_MANIP_VIEW:
+ {
+ float mat[3][3];
+ strcpy(t->spacename, "view");
+ Mat3CpyMat4(mat, v3d->viewinv);
+ Mat3Ortho(mat);
+ Mat4CpyMat3(v3d->twmat, mat);
+ }
+ break;
+ default: /* V3D_MANIP_CUSTOM */
+ applyTransformOrientation(C, t);
+ break;
+ }
+}
+
int getTransformOrientation(bContext *C, float normal[3], float plane[3], int activeOnly)
{
Scene *scene = CTX_data_scene(C);
@@ -651,6 +734,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
extern ListBase editelems; /* go away ! */
MetaElem *ml, *ml_sel = NULL;
+#if 0 // XXX
/* loop and check that only one element is selected */
for (ml = editelems.first; ml; ml = ml->next)
{
@@ -666,6 +750,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
}
}
}
+#endif
if (ml_sel)
{