Brought back the basics for transform manipulators. Martin will
hook it all up to new transform system.

Some notes:
- Still uses G.moving
- BIF_do_manipulator() is called as a View3D Operator
  I've tested selecting handles, added a print to confirm
- BIF_GetTransInfo() returns a dummy struct now, just to get
  it running.
- Marked some other issues with XXX
This commit is contained in:
2009-07-08 15:01:28 +00:00
parent 031ed0431c
commit f3fd7d8800
15 changed files with 417 additions and 379 deletions
@@ -128,8 +128,8 @@ void BIF_selectOrientation(void);
void initManipulator(int mode);
void ManipulatorTransform();
//int BIF_do_manipulator(struct ScrArea *sa);
//void BIF_draw_manipulator(struct ScrArea *sa);
int BIF_do_manipulator(struct bContext *C, short mval[2]);
void BIF_draw_manipulator(const struct bContext *C);
/* Snapping */
@@ -565,58 +565,6 @@ static void view3d_object_text_draw(View3D *v3d, ARegion *ar)
BLI_freelistN(&strings);
}
void drawsolidcube(float size)
{
float n[3];
glPushMatrix();
glScalef(size, size, size);
n[0]=0; n[1]=0; n[2]=0;
glBegin(GL_QUADS);
n[0]= -1.0;
glNormal3fv(n);
glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
n[0]=0;
glEnd();
glBegin(GL_QUADS);
n[1]= -1.0;
glNormal3fv(n);
glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]);
n[1]=0;
glEnd();
glBegin(GL_QUADS);
n[0]= 1.0;
glNormal3fv(n);
glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]);
n[0]=0;
glEnd();
glBegin(GL_QUADS);
n[1]= 1.0;
glNormal3fv(n);
glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]);
n[1]=0;
glEnd();
glBegin(GL_QUADS);
n[2]= 1.0;
glNormal3fv(n);
glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]);
n[2]=0;
glEnd();
glBegin(GL_QUADS);
n[2]= -1.0;
glNormal3fv(n);
glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]);
glEnd();
glPopMatrix();
}
static void drawcube(void)
{
@@ -70,6 +70,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "BIF_transform.h"
#include "WM_api.h"
#include "BLF_api.h"
@@ -2019,7 +2020,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
if(rv3d->rflag & RV3D_CLIPPING)
view3d_clr_clipping();
// BIF_draw_manipulator(ar);
BIF_draw_manipulator(C);
if(v3d->zbuf) {
v3d->zbuf= FALSE;
@@ -63,6 +63,7 @@
#include "BIF_gl.h"
#include "BIF_retopo.h"
#include "BIF_transform.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -1858,6 +1859,43 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
}
/* ***************** manipulator op ******************* */
static int manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
View3D *v3d = CTX_wm_view3d(C);
if(!(v3d->twflag & V3D_USE_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
if(!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
if(0==BIF_do_manipulator(C, event->mval))
return OPERATOR_PASS_THROUGH;
return OPERATOR_FINISHED;
}
void VIEW3D_OT_manipulator(wmOperatorType *ot)
{
/* identifiers */
ot->name= "3D Manipulator";
ot->description = "";
ot->idname= "VIEW3D_OT_manipulator";
/* api callbacks */
ot->invoke= manipulator_invoke;
ot->poll= ED_operator_view3d_active;
/* rna later */
}
/* ************************* below the line! *********************** */
@@ -4978,16 +4978,22 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event)
break;
case B_MAN_TRANS:
if( shift==0 || v3d->twtype==0)
if( shift==0 || v3d->twtype==0) {
v3d->twtype= V3D_MANIP_TRANSLATE;
ED_area_tag_redraw(sa);
}
break;
case B_MAN_ROT:
if( shift==0 || v3d->twtype==0)
if( shift==0 || v3d->twtype==0) {
v3d->twtype= V3D_MANIP_ROTATE;
ED_area_tag_redraw(sa);
}
break;
case B_MAN_SCALE:
if( shift==0 || v3d->twtype==0)
if( shift==0 || v3d->twtype==0) {
v3d->twtype= V3D_MANIP_SCALE;
ED_area_tag_redraw(sa);
}
break;
case B_NDOF:
break;
@@ -76,6 +76,7 @@ void VIEW3D_OT_view_persportho(struct wmOperatorType *ot);
void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
void VIEW3D_OT_clipping(struct wmOperatorType *ot);
void VIEW3D_OT_cursor3d(struct wmOperatorType *ot);
void VIEW3D_OT_manipulator(struct wmOperatorType *ot);
void VIEW3D_OT_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
void VIEW3D_OT_drawtype(struct wmOperatorType *ot);
@@ -79,6 +79,7 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_smoothview);
WM_operatortype_append(VIEW3D_OT_render_border);
WM_operatortype_append(VIEW3D_OT_zoom_border);
WM_operatortype_append(VIEW3D_OT_manipulator);
WM_operatortype_append(VIEW3D_OT_cursor3d);
WM_operatortype_append(VIEW3D_OT_select_lasso);
WM_operatortype_append(VIEW3D_OT_setcameratoview);
@@ -136,6 +137,7 @@ void view3d_keymap(wmWindowManager *wm)
km = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(km->ptr, "snap", 1);
WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", ACTIONMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_viewrotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
@@ -454,6 +454,7 @@ static void view_editmove(unsigned short event)
#endif
}
#if 0
static char *transform_to_undostr(TransInfo *t)
{
switch (t->mode) {
@@ -500,6 +501,7 @@ static char *transform_to_undostr(TransInfo *t)
}
return "Transform";
}
#endif
/* ************************************************* */
@@ -1460,6 +1462,8 @@ int transformEnd(bContext *C, TransInfo *t)
void initManipulator(int mode)
{
printf("init manipulator mode %d\n", mode);
#if 0 // TRANSFORM_FIX_ME
Trans.state = TRANS_RUNNING;
+3 -4
View File
@@ -481,8 +481,7 @@ void flushTransNodes(TransInfo *t);
void flushTransSeq(TransInfo *t);
/*********************** exported from transform_manipulator.c ********** */
void draw_manipulator_ext(struct ScrArea *sa, int type, char axis, int col, float vec[3], float mat[][3]);
int calc_manipulator_stats(struct ScrArea *sa);
int calc_manipulator_stats(const struct bContext *C);
float get_drawsize(struct ARegion *ar, float *co);
/*********************** TransData Creation and General Handling *********** */
@@ -631,7 +630,7 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
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);
void applyTransformOrientation(const struct bContext *C, TransInfo *t);
#define ORIENTATION_NONE 0
@@ -640,7 +639,7 @@ void applyTransformOrientation(struct bContext *C, TransInfo *t);
#define ORIENTATION_EDGE 3
#define ORIENTATION_FACE 4
int getTransformOrientation(struct bContext *C, float normal[3], float plane[3], int activeOnly);
int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3], int activeOnly);
int createSpaceNormal(float mat[3][3], float normal[3]);
int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]);
@@ -2566,6 +2566,7 @@ int clipUVTransform(TransInfo *t, float *vec, int resize)
* It also makes sure gp-frames are still stored in chronological order after
* transform.
*/
#if 0
static void posttrans_gpd_clean (bGPdata *gpd)
{
bGPDlayer *gpl;
@@ -2650,6 +2651,7 @@ static void posttrans_gpd_clean (bGPdata *gpd)
}
}
}
#endif
/* Called during special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
@@ -2709,6 +2711,7 @@ static void posttrans_fcurve_clean (FCurve *fcu)
}
/* Called by special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
* remake_action_ipos should have already been called
@@ -2783,6 +2786,7 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
#if 0
static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
@@ -2801,6 +2805,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
return count;
}
#endif
/* This function assigns the information to transdata */
static void TimeToTransData(TransData *td, float *time, Object *ob)
@@ -2883,6 +2888,7 @@ void flushTransGPactionData (TransInfo *t)
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
* on the named side are used.
*/
#if 0
static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
@@ -2909,6 +2915,7 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
return count;
}
#endif
static void createTransActionData(bContext *C, TransInfo *t)
{
@@ -114,8 +114,6 @@
extern ListBase editelems;
extern TransInfo Trans; /* From transform.c */
/* ************************** Functions *************************** */
void getViewVector(TransInfo *t, float coord[3], float vec[3])
@@ -1275,9 +1273,12 @@ void calculatePropRatio(TransInfo *t)
}
}
/* XXX only to make manipulators run now */
TransInfo *BIF_GetTransInfo()
{
return NULL;
static struct TransInfo trans;
memset(&trans, 0, sizeof(struct TransInfo));
return &trans;
}
float get_drawsize(ARegion *ar, float *co)
File diff suppressed because it is too large Load Diff
@@ -402,7 +402,7 @@ int BIF_countTransformOrientation(const bContext *C) {
return count;
}
void applyTransformOrientation(bContext *C, TransInfo *t) {
void applyTransformOrientation(const bContext *C, TransInfo *t) {
TransformOrientation *ts;
View3D *v3d = CTX_wm_view3d(C);
int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
@@ -532,7 +532,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
}
}
int getTransformOrientation(bContext *C, float normal[3], float plane[3], int activeOnly)
int getTransformOrientation(const bContext *C, float normal[3], float plane[3], int activeOnly)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -82,6 +82,9 @@ typedef struct RegionView3D {
float viewmatob[4][4];
float persmatob[4][4];
/* transform widget matrix */
float twmat[4][4];
float viewquat[4], dist, zfac; /* zfac is initgrabz() result */
float camdx, camdy; /* camera view offsets, 1.0 = viewplane moves entire width/height */
float pixsize;
@@ -547,23 +547,28 @@ static void rna_def_space_3dview(BlenderRNA *brna)
prop= RNA_def_property(srna, "manipulator", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_USE_MANIPULATOR);
RNA_def_property_ui_text(prop, "Manipulator", "Use a 3D manipulator widget for controlling transforms.");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
prop= RNA_def_property(srna, "manipulator_translate", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "twtype", V3D_MANIP_TRANSLATE);
RNA_def_property_ui_text(prop, "Manipulator Translate", "Use the manipulator for movement transformations.");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
prop= RNA_def_property(srna, "manipulator_rotate", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "twtype", V3D_MANIP_ROTATE);
RNA_def_property_ui_text(prop, "Manipulator Rotate", "Use the manipulator for rotation transformations.");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
prop= RNA_def_property(srna, "manipulator_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "twtype", V3D_MANIP_SCALE);
RNA_def_property_ui_text(prop, "Manipulator Scale", "Use the manipulator for scale transformations.");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
prop= RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "twmode");
RNA_def_property_enum_items(prop, transform_orientation_items);
RNA_def_property_ui_text(prop, "Transform Orientation", "The alignment of manipulator handles.");
RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, NULL);
}