diff options
Diffstat (limited to 'source/blender/editors')
90 files changed, 1093 insertions, 1265 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index cb93d2bf70b..1ba695209b2 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1360,6 +1360,7 @@ void ANIM_OT_keyframe_delete_v3d (wmOperatorType *ot) { /* identifiers */ ot->name= "Delete Keyframe"; + ot->description= "Remove keyframes on current frame for selected object"; ot->idname= "ANIM_OT_keyframe_delete_v3d"; /* callbacks */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 04565b4c236..10886615976 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -578,9 +578,8 @@ void ANIM_keyingset_info_register (KeyingSetInfo *ksi) } /* Remove the given KeyingSetInfo from the list of type infos, and also remove the builtin set if appropriate */ -void ANIM_keyingset_info_unregister (const bContext *C, KeyingSetInfo *ksi) +void ANIM_keyingset_info_unregister (Main *bmain, KeyingSetInfo *ksi) { - Main *bmain= CTX_data_main(C); KeyingSet *ks, *ksn; /* find relevant builtin KeyingSets which use this, and remove them */ diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 86dc2182e03..82decf8d1cf 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -206,7 +206,7 @@ void POSE_OT_propagate(struct wmOperatorType *ot); /* editarmature.c */ EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct EditBone *parent, struct Bone *actBone); -void BIF_sk_selectStroke(struct bContext *C, const short mval[2], short extend); +void BIF_sk_selectStroke(struct bContext *C, const int mval[2], short extend); /* duplicate method */ void preEditBoneDuplicate(struct ListBase *editbones); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f4e9c7c5d3e..06b2c06d4d2 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1698,7 +1698,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ -static EditBone *get_nearest_editbonepoint (ViewContext *vc, const short mval[2], ListBase *edbo, int findunsel, int *selmask) +static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) { EditBone *ebone; rcti rect; @@ -1958,7 +1958,7 @@ static int ebone_select_flag(EditBone *ebone) } /* context: editmode armature in view3d */ -int mouse_armature(bContext *C, const short mval[2], int extend) +int mouse_armature(bContext *C, const int mval[2], int extend) { Object *obedit= CTX_data_edit_object(C); bArmature *arm= obedit->data; @@ -2498,8 +2498,8 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e ARegion *ar; View3D *v3d; RegionView3D *rv3d; - float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3]; - short mx, my, mval[2]; + float *fp = NULL, tvec[3], oldcurs[3]; + int mx, my; int retv; scene= CTX_data_scene(C); @@ -2513,27 +2513,9 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e mx= event->x - ar->winrct.xmin; my= event->y - ar->winrct.ymin; - project_short_noclip(ar, fp, mval); - - initgrabz(rv3d, fp[0], fp[1], fp[2]); - - if(mval[0]!=IS_CLIPPED) { - - window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my); - sub_v3_v3v3(fp, fp, dvec); - } - else { - - dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2); - dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2); - - fz= rv3d->persmat[0][3]*fp[0]+ rv3d->persmat[1][3]*fp[1]+ rv3d->persmat[2][3]*fp[2]+ rv3d->persmat[3][3]; - fz= fz/rv3d->zfac; - - fp[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0]; - fp[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1]; - fp[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2]; - } + + window_to_3d(ar, tvec, fp, mx, my); + copy_v3_v3(fp, tvec); /* extrude to the where new cursor is and store the operation result */ retv= armature_click_extrude_exec(C, op); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 158c0d23ddc..1fa6a88c9f3 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -702,7 +702,7 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) } } -static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], int *dist, int *index, int all_pts) +static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], int *dist, int *index, int all_pts) { ARegion *ar = CTX_wm_region(C); SK_Point *pt = NULL; @@ -736,7 +736,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], } #if 0 /* UNUSED 2.5 */ -static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short mval[2], int *dist) +static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, int mval[2], int *dist) { ARegion *ar = CTX_wm_region(C); SK_Point *pt = NULL; @@ -2157,7 +2157,7 @@ static void sk_applyGesture(bContext *C, SK_Sketch *sketch) /********************************************/ -static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const short mval[2], int extend) +static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], int extend) { ViewContext vc; rcti rect; @@ -2473,7 +2473,7 @@ static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev return OPERATOR_FINISHED; } -void BIF_sk_selectStroke(bContext *C, const short mval[2], short extend) +void BIF_sk_selectStroke(bContext *C, const int mval[2], short extend) { ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *sketch = contextSketch(C, 0); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 5897da97f85..9e0e9374d5d 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -527,7 +527,7 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); + marker= BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose")); if (marker == NULL) { BKE_reportf(op->reports, RPT_ERROR, "Invalid Pose specified %d", RNA_int_get(op->ptr, "pose")); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index cb73f20fe7b..1bfd910523e 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4169,7 +4169,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /***************** pick select from 3d view **********************/ -int mouse_nurb(bContext *C, const short mval[2], int extend) +int mouse_nurb(bContext *C, const int mval[2], int extend) { Object *obedit= CTX_data_edit_object(C); Curve *cu= obedit->data; @@ -4666,7 +4666,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) Curve *cu; ViewContext vc; float location[3]; - short mval[2]; + int mval[2]; Nurb *nu; BezTriple *bezt; @@ -6118,6 +6118,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) mul_m4_v3(cmat, bezt->vec[2]); bezt++; } + calchandlesNurb(newnu); } if( (bp= newnu->bp) ) { a= newnu->pntsu*nu->pntsv; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 2baefc2de8e..4de40bc536c 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -377,8 +377,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi } else { float *fp= give_cursor(scene, v3d); - float dvec[3]; - short mval[2]; + int mval[2]; int mx, my; /* get screen coordinate */ @@ -390,15 +389,13 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi mx= (int)(pt->x / 100 * ar->winx); my= (int)(pt->y / 100 * ar->winy); } - mval[0]= (short)mx; - mval[1]= (short)my; + mval[0]= mx; + mval[1]= my; /* convert screen coordinate to 3d coordinates * - method taken from editview.c - mouse_cursor() */ - project_short_noclip(ar, fp, mval); - window_to_3d(ar, dvec, mval[0]-mx, mval[1]-my); - sub_v3_v3v3(p3d, fp, dvec); + window_to_3d(ar, p3d, fp, mval[0], mval[1]); } } @@ -564,8 +561,6 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op) bGPdata *gpd= gpencil_data_get_active(C); bGPDlayer *gpl= gpencil_layer_getactive(gpd); Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); - float *fp= give_cursor(scene, v3d); int mode= RNA_enum_get(op->ptr, "type"); /* check if there's data to work with */ @@ -574,9 +569,6 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* initialise 3d-cursor correction globals */ - initgrabz(CTX_wm_region_view3d(C), fp[0], fp[1], fp[2]); - /* handle conversion modes */ switch (mode) { case GP_STROKECONVERT_PATH: diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 5763fcde705..7db18eaedf4 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -239,7 +239,7 @@ static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], float *depth) { bGPdata *gpd= p->gpd; @@ -251,7 +251,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], f */ } else { - const short mx=mval[0], my=mval[1]; + const int mx=mval[0], my=mval[1]; float rvec[3], dvec[3]; /* Current method just converts each point in screen-coordinates to @@ -266,7 +266,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], f gp_get_3d_reference(p, rvec); /* method taken from editview.c - mouse_cursor() */ - project_short_noclip(p->ar, rvec, mval); + project_int_noclip(p->ar, rvec, mval); window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my); sub_v3_v3v3(out, rvec, dvec); } @@ -387,8 +387,8 @@ static short gp_stroke_addpoint (tGPsdata *p, int mval[2], float pressure) /* temp struct for gp_stroke_smooth() */ typedef struct tGpSmoothCo { - short x; - short y; + int x; + int y; } tGpSmoothCo; /* smooth a stroke (in buffer) before storing it */ @@ -417,8 +417,8 @@ static void gp_stroke_smooth (tGPsdata *p) const tGPspoint *pd= (i+1 < cmx)?(pc+1):(pc); const tGPspoint *pe= (i+2 < cmx)?(pc+2):(pd); - spc->x= (short)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); - spc->y= (short)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); + spc->x= (int)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); + spc->y= (int)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); } /* second pass: apply smoothed coordinates */ @@ -574,7 +574,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - short mval[2], mval_prev[2]= {0}; + int mval[2], mval_prev[2]= {0}; int interp_depth = 0; int found_depth = 0; @@ -738,7 +738,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho { bGPDspoint *pt1, *pt2; int x0=0, y0=0, x1=0, y1=0; - short xyval[2]; + int xyval[2]; int i; if (gps->totpoints == 0) { @@ -750,7 +750,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho else if (gps->totpoints == 1) { /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { - project_short(p->ar, &gps->points->x, xyval); + project_int(p->ar, &gps->points->x, xyval); x0= xyval[0]; y0= xyval[1]; } @@ -804,11 +804,11 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { - project_short(p->ar, &pt1->x, xyval); + project_int(p->ar, &pt1->x, xyval); x0= xyval[0]; y0= xyval[1]; - project_short(p->ar, &pt2->x, xyval); + project_int(p->ar, &pt2->x, xyval); x1= xyval[0]; y1= xyval[1]; } @@ -1501,8 +1501,8 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) /* get relevant data for this point from stroke */ RNA_float_get_array(&itemptr, "mouse", mousef); - p->mval[0] = (short)mousef[0]; - p->mval[1] = (short)mousef[1]; + p->mval[0] = (int)mousef[0]; + p->mval[1] = (int)mousef[1]; p->pressure= RNA_float_get(&itemptr, "pressure"); if (RNA_boolean_get(&itemptr, "is_start")) { diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 36923736068..a029c5c1f12 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -117,7 +117,7 @@ void ED_armature_deselect_all_visible(struct Object *obedit); int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, short hits, short extend); -int mouse_armature(struct bContext *C, const short mval[2], int extend); +int mouse_armature(struct bContext *C, const int mval[2], int extend); int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone (struct Object *ob, int index); float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index cfafd38ed15..6a92ee2e056 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -66,7 +66,7 @@ void free_editNurb (struct Object *obedit); void free_curve_editNurb (struct Curve *cu); -int mouse_nurb (struct bContext *C, const short mval[2], int extend); +int mouse_nurb (struct bContext *C, const int mval[2], int extend); struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index d06b0d6c4ee..e5715316a31 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -56,7 +56,7 @@ struct wmKeyConfig; * Used as part of the 'stroke cache' used during drawing of new strokes */ typedef struct tGPspoint { - short x, y; /* x and y coordinates of cursor (in relative to area) */ + int x, y; /* x and y coordinates of cursor (in relative to area) */ float pressure; /* pressure of tablet at this point */ } tGPspoint; diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 2c866495503..cfe9ea53d9a 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -68,8 +68,5 @@ int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit) /* UI level image (texture) updating... render calls own stuff (too) */ void ED_image_update_frame(const struct Main *mainp, int cfra); -/* image_render.c, export for screen_ops.c, render operator */ -void ED_space_image_output(struct bContext *C); - #endif /* ED_IMAGE_H */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 7bab563641a..6523a897713 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -36,6 +36,7 @@ extern "C" { #endif +struct Main; struct ListBase; struct ID; struct Scene; @@ -190,7 +191,7 @@ KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]); /* for RNA type registrations... */ void ANIM_keyingset_info_register(KeyingSetInfo *ksi); -void ANIM_keyingset_info_unregister(const struct bContext *C, KeyingSetInfo *ksi); +void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi); /* cleanup on exit */ void ANIM_keyingset_infos_exit(void); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index a742be7337c..2afc3155398 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -42,7 +42,7 @@ void ED_keymap_metaball(struct wmKeyConfig *keyconf); struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname); -int mouse_mball(struct bContext *C, const short mval[2], int extend); +int mouse_mball(struct bContext *C, const int mval[2], int extend); void free_editMball(struct Object *obedit); void make_editMball(struct Object *obedit); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index c3c843154e5..5c4dfc6ba3d 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -169,9 +169,9 @@ void EM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct Object extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs; void EM_cache_x_mirror_vert(struct Object *ob, struct EditMesh *em); -int mouse_mesh(struct bContext *C, const short mval[2], short extend); +int mouse_mesh(struct bContext *C, const int mval[2], short extend); int EM_check_backbuf(unsigned int index); -int EM_mask_init_backbuf_border(struct ViewContext *vc, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); +int EM_mask_init_backbuf_border(struct ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); void EM_free_backbuf(void); int EM_init_backbuf_border(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); int EM_init_backbuf_circle(struct ViewContext *vc, short xs, short ys, short rads); @@ -187,10 +187,10 @@ void EM_automerge(struct Scene *scene, struct Object *obedit, int update); /* editface.c */ void paintface_flush_flags(struct Object *ob); struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloppy); -int paintface_mouse_select(struct bContext *C, struct Object *ob, const short mval[2], int extend); +int paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], int extend); int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int select, int extend); void paintface_deselect_all_visible(struct Object *ob, int action, short flush_flags); -void paintface_select_linked(struct bContext *C, struct Object *ob, short mval[2], int mode); +void paintface_select_linked(struct bContext *C, struct Object *ob, int mval[2], int mode); int paintface_minmax(struct Object *ob, float *min, float *max); void paintface_hide(struct Object *ob, const int unselected); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 3b27fb45f5d..28d0a9520b2 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -126,7 +126,7 @@ void ED_object_constraint_update(struct Object *ob); void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object_lattice.c */ -int mouse_lattice(struct bContext *C, const short mval[2], int extend); +int mouse_lattice(struct bContext *C, const int mval[2], int extend); void undo_push_lattice(struct bContext *C, const char *name); /* object_lattice.c */ diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index f29284fe64d..23997e06aef 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -60,10 +60,10 @@ void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra void PE_update_object(struct Scene *scene, struct Object *ob, int useflag); /* selection tools */ -int PE_mouse_particles(struct bContext *C, const short mval[2], int extend); +int PE_mouse_particles(struct bContext *C, const int mval[2], int extend); int PE_border_select(struct bContext *C, struct rcti *rect, int select, int extend); -int PE_circle_select(struct bContext *C, int selecting, const short mval[2], float rad); -int PE_lasso_select(struct bContext *C, short mcords[][2], short moves, short extend, short select); +int PE_circle_select(struct bContext *C, int selecting, const int mval[2], float rad); +int PE_lasso_select(struct bContext *C, int mcords[][2], short moves, short extend, short select); void PE_deselect_all_visible(struct PTCacheEdit *edit); /* undo */ diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 77b754519fb..50dd2308b6b 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -86,7 +86,6 @@ void undo_editmode_step (struct bContext *C, int step); float *crazyspace_get_mapped_editverts(struct Scene *scene, struct Object *obedit); void crazyspace_set_quats_editmesh(struct EditMesh *em, float *origcos, float *mappedcos, float *quats); void crazyspace_set_quats_mesh(struct Mesh *me, float *origcos, float *mappedcos, float *quats); -int editmesh_get_first_deform_matrices(struct Scene *scene, struct Object *ob, struct EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]); int sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); void crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 297bd234edd..00fb6371d68 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -64,7 +64,7 @@ typedef struct ViewContext { struct View3D *v3d; struct RegionView3D *rv3d; struct EditMesh *em; - short mval[2]; + int mval[2]; } ViewContext; typedef struct ViewDepths { @@ -80,9 +80,9 @@ typedef struct ViewDepths { float *give_cursor(struct Scene *scene, struct View3D *v3d); int initgrabz(struct RegionView3D *rv3d, float x, float y, float z); -void window_to_3d(struct ARegion *ar, float out[3], short mx, short my); -void window_to_3d_delta(struct ARegion *ar, float out[3], short mx, short my); -void window_to_3d_vector(struct ARegion *ar, float out[3], short mx, short my); +void window_to_3d(struct ARegion *ar, float out[3], const float depth_pt[3], const int mx, const int my); +void window_to_3d_delta(struct ARegion *ar, float out[3], const int mx, const int my); +void window_to_3d_vector(struct ARegion *ar, float out[3], const int mx, const int my); void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ @@ -109,9 +109,9 @@ void viewvector(struct RegionView3D *rv3d, float coord[3], float vec[3]); void viewline(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_end[3]); void viewray(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_normal[3]); +void get_object_clip_range(struct Object *ob, float *lens, float *clipsta, float *clipend); int get_view3d_cliprange(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize); -int get_view3d_ortho(struct View3D *v3d, struct RegionView3D *rv3d); void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void view3d_project_float(struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); void view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct RegionView3D *rv3d, struct View3D *v3d, struct rctf *viewborder_r, short do_shift); @@ -133,18 +133,18 @@ void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]); /* backbuffer select and draw support */ void view3d_validate_backbuf(struct ViewContext *vc); struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); -unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, +unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, void *handle, unsigned int (*indextest)(void *handle, unsigned int index)); unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y); /* draws and does a 4x4 sample */ -int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const short mval[2], float mouse_worldloc[3]); +int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3]); /* only draw so view_autodist_simple can be called many times after */ int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode); -int view_autodist_simple(struct ARegion *ar, const short mval[2], float mouse_worldloc[3], int margin, float *force_depth); -int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, float *depth); -int view_autodist_depth_segment(struct ARegion *ar, const short mval_sta[2], const short mval_end[2], int margin, float *depth); +int view_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth); +int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth); +int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth); /* select */ #define MAXPICKBUF 10000 @@ -153,13 +153,13 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar); -int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const short mval[2], const short do_fallback); +int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const int mval[2], const short do_fallback); void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); /* XXX should move to BLI_math */ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2); -int lasso_inside(short mcords[][2], short moves, short sx, short sy); -int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1); +int lasso_inside(int mcords[][2], short moves, int sx, int sy); +int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int y1); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); @@ -178,7 +178,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, char err_out[256]); -Base *ED_view3d_give_base_under_cursor(struct bContext *C, const short mval[2]); +Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip); int ED_view3d_lock(struct RegionView3D *rv3d); @@ -187,9 +187,19 @@ unsigned int ED_viewedit_datamask(struct bScreen *screen); /* assigning view matrix */ -void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist); -void view3d_apply_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens); +void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist); + +void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); +void ED_view3d_to_object(struct Object *ob, const float ofs[3], const float quat[4], const float dist); + +/* camera lock functions */ +/* copy the camera to the view before starting a view transformation */ +void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); +/* copy the view to the camera */ +void ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); + int view3d_is_ortho(struct View3D *v3d, struct RegionView3D *rv3d); + #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ae5af185442..759301cc8f3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -262,14 +262,12 @@ static int ui_is_a_warp_but(uiBut *but) static int ui_is_utf8_but(uiBut *but) { if (but->rnaprop) { - int subtype= RNA_property_subtype(but->rnaprop); - - if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { - return TRUE; - } + const int subtype= RNA_property_subtype(but->rnaprop); + return !(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)); + } + else { + return !(but->flag & UI_BUT_NO_UTF8); } - - return !(but->flag & UI_BUT_NO_UTF8); } /* ********************** button apply/revert ************************/ @@ -300,7 +298,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->func_arg3= but->func_arg3; after->funcN= but->funcN; - after->func_argN= but->func_argN; + after->func_argN= MEM_dupallocN(but->func_argN); after->rename_func= but->rename_func; after->rename_arg1= but->rename_arg1; @@ -404,6 +402,8 @@ static void ui_apply_but_funcs_after(bContext *C) after.func(C, after.func_arg1, after.func_arg2); if(after.funcN) after.funcN(C, after.func_argN, after.func_arg2); + if(after.func_argN) + MEM_freeN(after.func_argN); if(after.handle_func) after.handle_func(C, after.handle_func_arg, after.retval); @@ -1679,7 +1679,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if(but) { - if(!ui_is_utf8_but(but)) { + if(ui_is_utf8_but(but)) { int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); /* not a file?, strip non utf-8 chars */ if(strip) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 9507a1a07f4..037cc22f879 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -798,36 +798,39 @@ void UI_icons_init(int first_dyn_id) init_brush_icons(); } -/* Render size for preview images at level miplevel */ -static int preview_render_size(int miplevel) +/* Render size for preview images and icons + */ +static int preview_render_size(enum eIconSizes size) { - switch (miplevel) { - case 0: return 32; - case 1: return PREVIEW_DEFAULT_HEIGHT; + switch (size) { + case ICON_SIZE_ICON: return 32; + case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT; } return 0; } -static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel) +/* Create rect for the icon + */ +static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size) { - unsigned int size = preview_render_size(miplevel); + unsigned int render_size = preview_render_size(size); if (!prv_img) { if (G.f & G_DEBUG) printf("Error: requested preview image does not exist"); } - if (!prv_img->rect[miplevel]) { - prv_img->w[miplevel] = size; - prv_img->h[miplevel] = size; - prv_img->changed[miplevel] = 1; - prv_img->changed_timestamp[miplevel] = 0; - prv_img->rect[miplevel] = MEM_callocN(size*size*sizeof(unsigned int), "prv_rect"); + if (!prv_img->rect[size]) { + prv_img->w[size] = render_size; + prv_img->h[size] = render_size; + prv_img->changed[size] = 1; + prv_img->changed_timestamp[size] = 0; + prv_img->rect[size] = MEM_callocN(render_size*render_size*sizeof(unsigned int), "prv_rect"); } } /* only called when icon has changed */ /* only call with valid pointer from UI_icon_draw */ -static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miplevel) +static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIconSizes size) { if (!prv_img) { if (G.f & G_DEBUG) @@ -835,11 +838,10 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miple return; } - /* create the preview rect */ - icon_create_mipmap(prv_img, miplevel); + icon_create_rect(prv_img, size); - ED_preview_icon_job(C, prv_img, id, prv_img->rect[miplevel], - prv_img->w[miplevel], prv_img->h[miplevel]); + ED_preview_icon_job(C, prv_img, id, prv_img->rect[size], + prv_img->w[size], prv_img->h[size]); } static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview) @@ -928,17 +930,17 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy glDisable(GL_TEXTURE_2D); } -/* Drawing size for preview images at level miplevel */ -static int preview_size(int miplevel) +/* Drawing size for preview images */ +static int get_draw_size(enum eIconSizes size) { - switch (miplevel) { - case 0: return ICON_DEFAULT_HEIGHT; - case 1: return PREVIEW_DEFAULT_HEIGHT; + switch (size) { + case ICON_SIZE_ICON: return ICON_DEFAULT_HEIGHT; + case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT; } return 0; } -static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, int miplevel, int draw_size, int UNUSED(nocreate), int is_preview) +static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), int is_preview) { Icon *icon = NULL; DrawInfo *di = NULL; @@ -988,11 +990,11 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al if(pi) { /* no create icon on this level in code */ - if(!pi->rect[miplevel]) return; /* something has gone wrong! */ + if(!pi->rect[size]) return; /* something has gone wrong! */ /* preview images use premul alpha ... */ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - icon_draw_rect(x, y, w, h, aspect, pi->w[miplevel], pi->h[miplevel], pi->rect[miplevel], 1.0f, NULL, is_preview); + icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], 1.0f, NULL, is_preview); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } @@ -1024,7 +1026,7 @@ static void ui_id_brush_render(bContext *C, ID *id) if(!pi) return; - for(i = 0; i < PREVIEW_MIPMAPS; i++) { + for(i = 0; i < NUM_ICON_SIZES; i++) { /* check if rect needs to be created; changed only set by dynamic icons */ if((pi->changed[i] || !pi->rect[i])) { @@ -1113,21 +1115,21 @@ int ui_id_icon_get(bContext *C, ID *id, int big) return iconid; } -static void icon_draw_mipmap(float x, float y, int icon_id, float aspect, float alpha, int miplevel, int nocreate) +static void icon_draw_at_size(float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, int nocreate) { - int draw_size = preview_size(miplevel); - icon_draw_size(x, y, icon_id, aspect, alpha, NULL, miplevel, draw_size, nocreate, FALSE); + int draw_size = get_draw_size(size); + icon_draw_size(x, y, icon_id, aspect, alpha, NULL, size, draw_size, nocreate, FALSE); } void UI_icon_draw_aspect(float x, float y, int icon_id, float aspect, float alpha) { - icon_draw_mipmap(x, y, icon_id, aspect, alpha, PREVIEW_MIPMAP_ZERO, 0); + icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, 0); } void UI_icon_draw_aspect_color(float x, float y, int icon_id, float aspect, float *rgb) { - int draw_size = preview_size(PREVIEW_MIPMAP_ZERO); - icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, PREVIEW_MIPMAP_ZERO, draw_size, FALSE, FALSE); + int draw_size = get_draw_size(ICON_SIZE_ICON); + icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, FALSE, FALSE); } void UI_icon_draw(float x, float y, int icon_id) @@ -1137,21 +1139,21 @@ void UI_icon_draw(float x, float y, int icon_id) void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha) { - icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, PREVIEW_MIPMAP_ZERO, size, TRUE, FALSE); + icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, ICON_SIZE_ICON, size, TRUE, FALSE); } void UI_icon_draw_preview(float x, float y, int icon_id) { - icon_draw_mipmap(x, y, icon_id, 1.0f, 1.0f, PREVIEW_MIPMAP_LARGE, 0); + icon_draw_at_size(x, y, icon_id, 1.0f, 1.0f, ICON_SIZE_PREVIEW, 0); } void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect) { - icon_draw_mipmap(x, y, icon_id, aspect, 1.0f, PREVIEW_MIPMAP_LARGE, 0); + icon_draw_at_size(x, y, icon_id, aspect, 1.0f, ICON_SIZE_PREVIEW, 0); } void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspect, int size) { - icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, PREVIEW_MIPMAP_LARGE, size, FALSE, TRUE); + icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, ICON_SIZE_PREVIEW, size, FALSE, TRUE); } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 12506d28593..e9fad382beb 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -97,7 +97,7 @@ static int eyedropper_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static void eyedropper_sample(bContext *C, Eyedropper *eye, short mx, short my) +static void eyedropper_sample(bContext *C, Eyedropper *eye, int mx, int my) { if(RNA_property_type(eye->prop) == PROP_FLOAT) { const int color_manage = CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index a4c2dbb9943..624f06db3c1 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1625,7 +1625,7 @@ void ui_block_func_ICONTEXTROW(bContext *UNUSED(C), uiLayout *layout, void *arg_ } #if 0 -static void ui_warp_pointer(short x, short y) +static void ui_warp_pointer(int x, int y) { /* XXX 2.50 which function to use for this? */ /* OSX has very poor mousewarp support, it sends events; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 7648d5067b4..60a6008de43 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -461,7 +461,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiButSetNFunc(but, NULL, MEM_dupallocN(template), NULL); } else { - but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set users to zero, data gets not saved"); + but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set users to zero, data will then not be saved"); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); if(RNA_property_flag(template->prop) & PROP_NEVER_NULL) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ecadb52ad5d..58ed1e31b81 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -888,7 +888,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) /* textbut exception, clip right when... */ if(but->editstr && but->pos >= 0) { float width; - char buf[256]; + char buf[UI_MAX_DRAW_STR]; /* copy draw string */ BLI_strncpy(buf, but->drawstr, sizeof(buf)); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 32301dd6423..84cf5af5414 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2028,7 +2028,7 @@ typedef struct View2DString { unsigned char ub[4]; int pack; } col; - short mval[2]; + int mval[2]; rcti rect; } View2DString; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 62b191c2c6e..4cb67994704 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -86,6 +86,7 @@ typedef struct v2dViewPanData { /* options for version 1 */ int startx, starty; /* mouse x/y values in window when operator was initiated */ int lastx, lasty; /* previous x/y values of mouse in window */ + int invoke_event; /* event starting pan, for modal exit */ short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */ } v2dViewPanData; @@ -202,7 +203,8 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) /* set initial settings */ vpd->startx= vpd->lastx= event->x; vpd->starty= vpd->lasty= event->y; - + vpd->invoke_event= event->type; + if (event->type == MOUSEPAN) { RNA_int_set(op->ptr, "deltax", event->prevx - event->x); RNA_int_set(op->ptr, "deltay", event->prevy - event->y); @@ -261,17 +263,19 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL); return OPERATOR_FINISHED; } - case MIDDLEMOUSE: - case ESCKEY: - if (event->val==KM_RELEASE) { - /* calculate overall delta mouse-movement for redo */ - RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); - RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); - - view_pan_exit(op); - WM_cursor_restore(CTX_wm_window(C)); - - return OPERATOR_FINISHED; + + default: + if (event->type == vpd->invoke_event || event->type==ESCKEY) { + if (event->val==KM_RELEASE) { + /* calculate overall delta mouse-movement for redo */ + RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); + RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); + + view_pan_exit(op); + WM_cursor_restore(CTX_wm_window(C)); + + return OPERATOR_FINISHED; + } } break; } @@ -519,6 +523,7 @@ typedef struct v2dViewZoomData { double timer_lastdraw; int lastx, lasty; /* previous x/y values of mouse in window */ + int invoke_event; /* event type that invoked, for modal exits */ float dx, dy; /* running tally of previous delta values (for obtaining final zoom) */ float mx_2d, my_2d; /* initial mouse location in v2d coords */ } v2dViewZoomData; @@ -923,6 +928,9 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_float_set(op->ptr, "deltax", 0); RNA_float_set(op->ptr, "deltay", 0); + /* for modal exit test */ + vzd->invoke_event= event->type; + if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { ARegion *ar= CTX_wm_region(C); @@ -1021,8 +1029,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* apply zooming */ view_zoomdrag_apply(C, op); } - else if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) { /* XXX needs modal keymap */ - if (event->val==KM_RELEASE) { + else if (event->type == vzd->invoke_event || event->type==ESCKEY) { + if (event->val == KM_RELEASE) { + /* for redo, store the overall deltas - need to respect zoom-locks here... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) RNA_float_set(op->ptr, "deltax", vzd->dx); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 9cec034af28..ab62c88deaa 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -98,7 +98,7 @@ void paintface_flush_flags(Object *ob) } /* returns 0 if not found, otherwise 1 */ -static int facesel_face_pick(struct bContext *C, Mesh *me, const short mval[2], unsigned int *index, short rect) +static int facesel_face_pick(struct bContext *C, Mesh *me, const int mval[2], unsigned int *index, short rect) { ViewContext vc; view3d_set_viewcontext(C, &vc); @@ -327,7 +327,7 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind MEM_freeN(linkflag); } -void paintface_select_linked(bContext *UNUSED(C), Object *ob, short UNUSED(mval[2]), int mode) +void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2]), int mode) { Mesh *me; unsigned int index=0; @@ -716,7 +716,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) } #endif -int paintface_mouse_select(struct bContext *C, Object *ob, const short mval[2], int extend) +int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], int extend) { Mesh *me; MFace *mface, *msel; diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index 72e9e3b6d9e..d7e59e0a68f 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -199,7 +199,7 @@ static void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcut EditEdge *nearest=NULL, *eed; float fac; int keys = 0, holdnum=0, selectmode, dist; - short mvalo[2] = {0, 0}, mval[2] = {0, 0}; + int mvalo[2] = {0, 0}, mval[2] = {0, 0}; short event=0, val, choosing=1, cancel=0, cuthalf = 0, smooth=0; short hasHidden = 0; char msg[128]; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 8cdbe6707a3..bd49fab1de1 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -162,7 +162,7 @@ unsigned int em_solidoffs=0, em_wireoffs=0, em_vertoffs=0; /* set in drawobject. static char *selbuf= NULL; /* opengl doesn't support concave... */ -static void draw_triangulated(short mcords[][2], short tot) +static void draw_triangulated(int mcords[][2], short tot) { ListBase lb={NULL, NULL}; DispList *dl; @@ -256,7 +256,7 @@ void EM_free_backbuf(void) - grab again and compare returns 'OK' */ -int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) +int EM_mask_init_backbuf_border(ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) { unsigned int *dr, *drm; struct ImBuf *buf, *bufmask; @@ -290,7 +290,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s draw_triangulated(mcords, tot); glBegin(GL_LINE_LOOP); /* for zero sized masks, lines */ - for(a=0; a<tot; a++) glVertex2s(mcords[a][0], mcords[a][1]); + for(a=0; a<tot; a++) glVertex2iv(mcords[a]); glEnd(); glFinish(); /* to be sure readpixels sees mask */ @@ -358,7 +358,7 @@ int EM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) static void findnearestvert__doClosest(void *userData, EditVert *eve, int x, int y, int index) { - struct { short mval[2], pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } *data = userData; + struct { int mval[2]; short pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } *data = userData; if (data->pass==0) { if (index<=data->lastIndex) @@ -426,7 +426,7 @@ EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict) } else { - struct { short mval[2], pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } data; + struct { int mval[2]; short pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } data; static int lastSelectedIndex=0; static EditVert *lastSelected=NULL; @@ -549,7 +549,7 @@ EditEdge *findnearestedge(ViewContext *vc, int *dist) static void findnearestface__getDistance(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct { short mval[2]; int dist; EditFace *toFace; } *data = userData; + struct { int mval[2]; int dist; EditFace *toFace; } *data = userData; if (efa==data->toFace) { int temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); @@ -560,7 +560,7 @@ static void findnearestface__getDistance(void *userData, EditFace *efa, int x, i } static void findnearestface__doClosest(void *userData, EditFace *efa, int x, int y, int index) { - struct { short mval[2], pass; int dist, lastIndex, closestIndex; EditFace *closest; } *data = userData; + struct { int mval[2]; short pass; int dist, lastIndex, closestIndex; EditFace *closest; } *data = userData; if (data->pass==0) { if (index<=data->lastIndex) @@ -588,7 +588,7 @@ static EditFace *findnearestface(ViewContext *vc, int *dist) EditFace *efa = BLI_findlink(&vc->em->faces, index-1); if (efa) { - struct { short mval[2]; int dist; EditFace *toFace; } data; + struct { int mval[2]; int dist; EditFace *toFace; } data; data.mval[0] = vc->mval[0]; data.mval[1] = vc->mval[1]; @@ -607,7 +607,7 @@ static EditFace *findnearestface(ViewContext *vc, int *dist) return NULL; } else { - struct { short mval[2], pass; int dist, lastIndex, closestIndex; EditFace *closest; } data; + struct { int mval[2]; short pass; int dist, lastIndex, closestIndex; EditFace *closest; } data; static int lastSelectedIndex=0; static EditFace *lastSelected=NULL; @@ -2061,7 +2061,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** loop select (non modal) ************** */ -static void mouse_mesh_loop(bContext *C, const short mval[2], short extend, short ring) +static void mouse_mesh_loop(bContext *C, const int mval[2], short extend, short ring) { ViewContext vc; EditMesh *em; @@ -2149,7 +2149,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* ******************* mesh shortest path select, uses prev-selected edge ****************** */ /* since you want to create paths with multiple selects, it doesn't have extend option */ -static void mouse_mesh_shortest_path(bContext *C, const short mval[2]) +static void mouse_mesh_shortest_path(bContext *C, const int mval[2]) { ViewContext vc; EditMesh *em; @@ -2282,7 +2282,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* here actual select happens */ /* gets called via generic mouse select operator */ -int mouse_mesh(bContext *C, const short mval[2], short extend) +int mouse_mesh(bContext *C, const int mval[2], short extend) { ViewContext vc; EditVert *eve; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a78029da079..11e7d64c667 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4011,7 +4011,7 @@ useless: LinkNode *fuv_link; short event, draw=1; - short mval[2], mvalo[2]; + int mval[2], mvalo[2]; char str[128]; float labda = 0.0f; @@ -4416,7 +4416,7 @@ useless: percp = -1; while(draw) { /* For the % calculation */ - short mval[2]; + int mval[2]; float rc[2]; float v2[2], v3[2]; EditVert *centerVert, *upVert, *downVert; @@ -4867,7 +4867,7 @@ void mesh_set_face_flags(EditMesh *em, short mode) /********************** Rip Operator *************************/ /* helper to find edge for edge_rip */ -static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, const short mval[2]) +static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, const int mval[2]) { float vec1[3], vec2[3], mvalf[2]; @@ -4910,7 +4910,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) EditEdge *eed, *seed= NULL; EditFace *efa, *sefa= NULL; float projectMat[4][4], vec[3], dist, mindist; - short doit= 1, *mval= event->mval; + short doit= 1; + int *mval= event->mval; /* select flush... vertices are important */ EM_selectmode_set(em); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index b67f9d6de29..b007e30422d 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -455,7 +455,7 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ -int mouse_mball(bContext *C, const short mval[2], int extend) +int mouse_mball(bContext *C, const int mval[2], int extend) { static MetaElem *startelem=NULL; Object *obedit= CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index eb04a2743e3..91980ddf228 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -607,7 +607,7 @@ static void spot_interactive(Object *ob, int mode) Lamp *la= ob->data; float transfac, dx, dy, ratio, origval; int keep_running= 1, center2d[2]; - short mval[2], mvalo[2]; + int mval[2], mvalo[2]; // getmouseco_areawin(mval); // getmouseco_areawin(mvalo); @@ -1689,6 +1689,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Flat"; + ot->description= "Display faces 'smooth' (using vertext normals)"; ot->idname= "OBJECT_OT_shade_flat"; /* api callbacks */ @@ -1703,6 +1704,7 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Smooth"; + ot->description= "Display faces 'flat'"; ot->idname= "OBJECT_OT_shade_smooth"; /* api callbacks */ @@ -2053,6 +2055,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) { /* identifiers */ ot->name= "New Game Property"; + ot->description= "Create a new property available to the game engine"; ot->idname= "OBJECT_OT_game_property_new"; /* api callbacks */ @@ -2090,6 +2093,7 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Game Property"; + ot->description= "Remove game property"; ot->idname= "OBJECT_OT_game_property_remove"; /* api callbacks */ diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 198c8cab7fa..14ce223db5e 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -305,7 +305,7 @@ void LATTICE_OT_make_regular(wmOperatorType *ot) static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y) { - struct { BPoint *bp; short dist, select, mval[2]; } *data = userData; + struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData; float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); if((bp->f1 & SELECT)==data->select) @@ -318,12 +318,12 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in } } -static BPoint *findnearestLattvert(ViewContext *vc, const short mval[2], int sel) +static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) { /* sel==1: selected gets a disadvantage */ /* in nurb and bezt or bp the nearest is written */ /* return 0 1 2: handlepunt */ - struct { BPoint *bp; short dist, select, mval[2]; } data = {NULL}; + struct { BPoint *bp; short dist, select; int mval[2]; } data = {NULL}; data.dist = 100; data.select = sel; @@ -336,7 +336,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, const short mval[2], int sel return data.bp; } -int mouse_lattice(bContext *C, const short mval[2], int extend) +int mouse_lattice(bContext *C, const int mval[2], int extend) { ViewContext vc; BPoint *bp= NULL; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index ff1b693d0e1..d5bf894ac8c 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -204,17 +204,28 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob ob->dt = OB_TEXTURE; } else if(md->type == eModifierType_Multires) { + int ok= 1; Mesh *me= ob->data; + ModifierData *tmpmd; - if(me->edit_mesh) { - EditMesh *em= me->edit_mesh; - /* CustomData_external_remove is used here only to mark layer as non-external - for further free-ing, so zero element count looks safer than em->totface */ - CustomData_external_remove(&em->fdata, &me->id, CD_MDISPS, 0); - EM_free_data_layer(em, &em->fdata, CD_MDISPS); - } else { - CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); - CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + /* ensure MDISPS CustomData layer is't used by another multires modifiers */ + for(tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next) + if(tmpmd!=md && tmpmd->type == eModifierType_Multires) { + ok= 0; + break; + } + + if(ok) { + if(me->edit_mesh) { + EditMesh *em= me->edit_mesh; + /* CustomData_external_remove is used here only to mark layer as non-external + for further free-ing, so zero element count looks safer than em->totface */ + CustomData_external_remove(&em->fdata, &me->id, CD_MDISPS, 0); + EM_free_data_layer(em, &em->fdata, CD_MDISPS); + } else { + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + } } } @@ -971,6 +982,7 @@ static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, wmE void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) { ot->name= "Delete Higher Levels"; + ot->description= "Deletes the higher resolution mesh, potential loss of detail"; ot->idname= "OBJECT_OT_multires_higher_levels_delete"; ot->poll= multires_poll; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index bce16ceeed2..f7c6ff99bde 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -515,6 +515,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo mul_m4_v3(mat, bezt->vec[2]); bezt->radius *= scale; } + calchandlesNurb(nu); } else { a= nu->pntsu*nu->pntsv; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 1c9f9e60e14..f4f66c17459 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -338,7 +338,7 @@ typedef struct PEData { DerivedMesh *dm; PTCacheEdit *edit; - const short *mval; + const int *mval; rcti *rect; float rad; float dist; @@ -439,9 +439,9 @@ static int key_test_depth(PEData *data, float co[3]) static int key_inside_circle(PEData *data, float rad, float co[3], float *distance) { float dx, dy, dist; - short sco[2]; + int sco[2]; - project_short(data->vc.ar, co, sco); + project_int(data->vc.ar, co, sco); if(sco[0] == IS_CLIPPED) return 0; @@ -465,9 +465,9 @@ static int key_inside_circle(PEData *data, float rad, float co[3], float *distan static int key_inside_rect(PEData *data, float co[3]) { - short sco[2]; + int sco[2]; - project_short(data->vc.ar, co,sco); + project_int(data->vc.ar, co,sco); if(sco[0] == IS_CLIPPED) return 0; @@ -1369,7 +1369,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /************************ pick select operator ************************/ -int PE_mouse_particles(bContext *C, const short mval[2], int extend) +int PE_mouse_particles(bContext *C, const int mval[2], int extend) { PEData data; Scene *scene= CTX_data_scene(C); @@ -1484,7 +1484,7 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) static int select_linked_exec(bContext *C, wmOperator *op) { PEData data; - short mval[2]; + int mval[2]; int location[2]; RNA_int_get_array(op->ptr, "location", location); @@ -1574,7 +1574,7 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend) /************************ circle select operator ************************/ -int PE_circle_select(bContext *C, int selecting, const short mval[2], float rad) +int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -1599,7 +1599,7 @@ int PE_circle_select(bContext *C, int selecting, const short mval[2], float rad) /************************ lasso select operator ************************/ -int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, short select) +int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, short select) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -1610,7 +1610,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); POINT_P; KEY_K; float co[3], mat[4][4]= MAT4_UNITY; - short vertco[2]; + int vertco[2]; PEData data; @@ -1631,7 +1631,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s LOOP_KEYS { VECCOPY(co, key->co); mul_m4_v3(mat, co); - project_short(ar, co, vertco); + project_int(ar, co, vertco); if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { if(select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; @@ -1649,7 +1649,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s VECCOPY(co, key->co); mul_m4_v3(mat, co); - project_short(ar, co,vertco); + project_int(ar, co,vertco); if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { if(select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; @@ -2521,80 +2521,6 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL); } -/********************* radial control operator *********************/ - -static int brush_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - ParticleBrushData *brush; - int mode = RNA_enum_get(op->ptr, "mode"); - float original_value=1.0f; - - if(pset->brushtype < 0) - return OPERATOR_CANCELLED; - - brush= &pset->brush[pset->brushtype]; - - toggle_particle_cursor(C, 0); - - if(mode == WM_RADIALCONTROL_SIZE) - original_value = brush->size; - else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = brush->strength; - - RNA_float_set(op->ptr, "initial_value", original_value); - - return WM_radial_control_invoke(C, op, event); -} - -static int brush_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - - if(ret != OPERATOR_RUNNING_MODAL) - toggle_particle_cursor(C, 1); - - return ret; -} - -static int brush_radial_control_exec(bContext *C, wmOperator *op) -{ - ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - ParticleBrushData *brush; - int mode = RNA_enum_get(op->ptr, "mode"); - float new_value = RNA_float_get(op->ptr, "new_value"); - - if(pset->brushtype < 0) - return OPERATOR_CANCELLED; - - brush= &pset->brush[pset->brushtype]; - - if(mode == WM_RADIALCONTROL_SIZE) - brush->size= new_value; - else if(mode == WM_RADIALCONTROL_STRENGTH) - brush->strength= new_value; - - WM_event_add_notifier(C, NC_WINDOW, NULL); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_brush_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Brush Radial Control"; - ot->idname= "PARTICLE_OT_brush_radial_control"; - - ot->invoke= brush_radial_control_invoke; - ot->modal= brush_radial_control_modal; - ot->exec= brush_radial_control_exec; - ot->poll= PE_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /*************************** delete operator **************************/ enum { DEL_PARTICLE, DEL_KEY }; @@ -2845,7 +2771,7 @@ static void brush_cut(PEData *data, int pa_index) float rad2, cut_time= 1.0; float x0, x1, v0, v1, o0, o1, xo0, xo1, d, dv; int k, cut, keys= (int)pow(2.0, (double)pset->draw_step); - short vertco[2]; + int vertco[2]; /* blunt scissors */ if(BLI_frand() > data->cutfac) return; @@ -2858,7 +2784,7 @@ static void brush_cut(PEData *data, int pa_index) cut=0; - project_short_noclip(ar, key->co, vertco); + project_int_noclip(ar, key->co, vertco); x0= (float)vertco[0]; x1= (float)vertco[1]; @@ -2876,7 +2802,7 @@ static void brush_cut(PEData *data, int pa_index) else { /* calculate path time closest to root that was inside the circle */ for(k=1, key++; k<=keys; k++, key++) { - project_short_noclip(ar, key->co, vertco); + project_int_noclip(ar, key->co, vertco); if(key_test_depth(data, key->co) == 0) { x0= (float)vertco[0]; @@ -3540,7 +3466,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) ParticleBrushData *brush= &pset->brush[pset->brushtype]; ARegion *ar= CTX_wm_region(C); float vec[3], mousef[2]; - short mval[2], mvalo[2]; + int mval[2], mvalo[2]; int flip, mouse[2], dx, dy, removed= 0, added=0, selected= 0; int lock_root = pset->flag & PE_LOCK_FIRST; diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index d447da3f8c4..71f1128baf0 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -60,7 +60,6 @@ void PARTICLE_OT_delete(struct wmOperatorType *ot); void PARTICLE_OT_mirror(struct wmOperatorType *ot); void PARTICLE_OT_brush_edit(struct wmOperatorType *ot); -void PARTICLE_OT_brush_radial_control(struct wmOperatorType *ot); void PARTICLE_OT_particle_edit_toggle(struct wmOperatorType *ot); void PARTICLE_OT_edited_clear(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 02b2fad7a00..56bd8b97532 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -66,7 +66,6 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_mirror); WM_operatortype_append(PARTICLE_OT_brush_edit); - WM_operatortype_append(PARTICLE_OT_brush_radial_control); WM_operatortype_append(PARTICLE_OT_particle_edit_toggle); WM_operatortype_append(PARTICLE_OT_edited_clear); @@ -91,6 +90,7 @@ static void operatortypes_particle(void) static void keymap_particle(wmKeyConfig *keyconf) { + wmKeyMapItem *kmi; wmKeyMap *keymap; keymap= WM_keymap_find(keyconf, "Particle", 0, 0); @@ -110,10 +110,19 @@ static void keymap_particle(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0); + RNA_boolean_set(kmi->ptr, "release_confirm", 1); + WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); + + /* size radial control */ + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size"); + + /* size radial control */ + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength"); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index df6cdb577a2..797ead3cd90 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -156,6 +156,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake All Physics"; + ot->description= "Bake all physics"; ot->idname= "PTCACHE_OT_bake_all"; /* api callbacks */ @@ -171,6 +172,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Free All Physics Bakes"; + ot->name= "Free all physics bakes"; ot->idname= "PTCACHE_OT_free_bake_all"; /* api callbacks */ @@ -268,6 +270,7 @@ void PTCACHE_OT_bake(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake Physics"; + ot->description= "Bake physics"; ot->idname= "PTCACHE_OT_bake"; /* api callbacks */ @@ -283,6 +286,7 @@ void PTCACHE_OT_free_bake(wmOperatorType *ot) { /* identifiers */ ot->name= "Free Physics Bake"; + ot->description= "Free physics bake"; ot->idname= "PTCACHE_OT_free_bake"; /* api callbacks */ @@ -296,6 +300,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake From Cache"; + ot->description= "Bake from cache"; ot->idname= "PTCACHE_OT_bake_from_cache"; /* api callbacks */ @@ -364,7 +369,8 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) void PTCACHE_OT_add(wmOperatorType *ot) { /* identifiers */ - ot->name= "Add new cache"; + ot->name= "Add New Cache"; + ot->description= "Add new cache"; ot->idname= "PTCACHE_OT_add"; /* api callbacks */ @@ -377,7 +383,8 @@ void PTCACHE_OT_add(wmOperatorType *ot) void PTCACHE_OT_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Delete current cache"; + ot->name= "Delete Current Cache"; + ot->description= "Delete current cache"; ot->idname= "PTCACHE_OT_remove"; /* api callbacks */ diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index cb67026ffbd..032737c400e 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -32,7 +32,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc - ${GLEW_INCLUDE_PATH} + ${GLEW_INCLUDE_PATH} ../../freestyle ) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e2d7147d21f..02fae52219b 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -110,7 +110,7 @@ int ED_operator_screenactive(bContext *C) } /* XXX added this to prevent anim state to change during renders */ -int ED_operator_screenactive_norender(bContext *C) +static int ED_operator_screenactive_norender(bContext *C) { if(G.rendering) return 0; if(CTX_wm_window(C)==NULL) return 0; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 29bcb191b46..db575907b49 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -440,6 +440,8 @@ static void image_undo_restore(bContext *C, ListBase *lb) GPU_free_image(ima); /* force OpenGL reload */ if(ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ + if(ibuf->mipmap[0]) + ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ } @@ -5066,56 +5068,6 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) } } -/* ************ image paint radial control *************/ -static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - float zoom; - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - get_imapaint_zoom(C, &zoom, &zoom); - toggle_paint_cursor(C, 0); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), zoom); - return WM_radial_control_invoke(C, op, event); -} - -static int paint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 1); - return ret; -} - -static int paint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint); - float zoom; - int ret; - char str[64]; - get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, brush, 1.0f / zoom); - WM_radial_control_string(op, str, sizeof(str)); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -void PAINT_OT_image_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Image Paint Radial Control"; - ot->idname= "PAINT_OT_image_paint_radial_control"; - - ot->invoke= paint_radial_control_invoke; - ot->modal= paint_radial_control_modal; - ot->exec= paint_radial_control_exec; - ot->poll= image_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /************************ grab clone operator ************************/ typedef struct GrabClone { @@ -5332,7 +5284,7 @@ static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event) View3D *v3d= CTX_wm_view3d(C); ARegion *ar= CTX_wm_region(C); float location[3]; - short mval[2]; + int mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; @@ -5443,28 +5395,6 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/************* texture paint radial control *************/ - -static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 1); - return WM_radial_control_invoke(C, op, event); -} - -static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint); - int ret = brush_radial_control_exec(op, brush, 1); - char str[64]; - WM_radial_control_string(op, str, sizeof(str)); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - static int texture_paint_poll(bContext *C) { if(texture_paint_toggle_poll(C)) @@ -5479,23 +5409,6 @@ int image_texture_paint_poll(bContext *C) return (texture_paint_poll(C) || image_paint_poll(C)); } -void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Texture Paint Radial Control"; - ot->idname= "PAINT_OT_texture_paint_radial_control"; - - ot->invoke= texture_paint_radial_control_invoke; - ot->modal= paint_radial_control_modal; - ot->exec= texture_paint_radial_control_exec; - ot->poll= texture_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - - int facemask_paint_poll(bContext *C) { return paint_facesel_test(CTX_data_active_object(C)); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 48fca04ac87..ba7235a3161 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -81,12 +81,10 @@ void vpaint_fill(struct Object *ob, unsigned int paintcol); void wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight); void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); -void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); void PAINT_OT_weight_set(struct wmOperatorType *ot); void PAINT_OT_weight_from_bones(struct wmOperatorType *ot); -void PAINT_OT_vertex_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_vertex_paint(struct wmOperatorType *ot); @@ -96,12 +94,10 @@ unsigned int vpaint_get_current_col(struct VPaint *vp); int image_texture_paint_poll(struct bContext *C); void PAINT_OT_image_paint(struct wmOperatorType *ot); -void PAINT_OT_image_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_grab_clone(struct wmOperatorType *ot); void PAINT_OT_sample_color(struct wmOperatorType *ot); void PAINT_OT_clone_cursor_set(struct wmOperatorType *ot); void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot); -void PAINT_OT_texture_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_project_image(struct wmOperatorType *ot); void PAINT_OT_image_from_view(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 9a1de939067..e4a21b1f1a7 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -23,7 +23,10 @@ * \ingroup edsculpt */ +#include "MEM_guardedalloc.h" +#include <stdlib.h> +#include "BLI_string.h" #include "BLI_utildefines.h" #include "DNA_object_types.h" @@ -355,9 +358,7 @@ void ED_operatortypes_paint(void) /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); - WM_operatortype_append(PAINT_OT_texture_paint_radial_control); WM_operatortype_append(PAINT_OT_image_paint); - WM_operatortype_append(PAINT_OT_image_paint_radial_control); WM_operatortype_append(PAINT_OT_sample_color); WM_operatortype_append(PAINT_OT_grab_clone); WM_operatortype_append(PAINT_OT_clone_cursor_set); @@ -366,13 +367,11 @@ void ED_operatortypes_paint(void) /* weight */ WM_operatortype_append(PAINT_OT_weight_paint_toggle); - WM_operatortype_append(PAINT_OT_weight_paint_radial_control); WM_operatortype_append(PAINT_OT_weight_paint); WM_operatortype_append(PAINT_OT_weight_set); WM_operatortype_append(PAINT_OT_weight_from_bones); /* vertex */ - WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); WM_operatortype_append(PAINT_OT_vertex_paint_toggle); WM_operatortype_append(PAINT_OT_vertex_paint); WM_operatortype_append(PAINT_OT_vertex_color_set); @@ -464,6 +463,59 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111.... } +typedef enum { + RC_COLOR = 1, + RC_ROTATION = 2, + RC_ZOOM = 4, +} RCFlags; + +static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path, + const char *output_name, const char *input_name) +{ + char *path; + + path = BLI_sprintfN("%s.%s", brush_path, input_name); + RNA_string_set(ptr, output_name, path); + MEM_freeN(path); +} + +static void set_brush_rc_props(PointerRNA *ptr, const char *paint, + const char *prop, RCFlags flags) +{ + char *brush_path; + + brush_path = BLI_sprintfN("tool_settings.%s.brush", paint); + + set_brush_rc_path(ptr, brush_path, "data_path", prop); + set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add"); + set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle"); + RNA_string_set(ptr, "image_id", brush_path); + + if(flags & RC_COLOR) + set_brush_rc_path(ptr, brush_path, "fill_color_path", "color"); + if(flags & RC_ZOOM) + RNA_string_set(ptr, "zoom_path", "space_data.zoom"); + + MEM_freeN(brush_path); +} + +static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint, + RCFlags flags) +{ + wmKeyMapItem *kmi; + + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + set_brush_rc_props(kmi->ptr, paint, "size", flags); + + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); + set_brush_rc_props(kmi->ptr, paint, "strength", flags); + + if(flags & RC_ROTATION) { + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); + set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags); + } +} + void ED_keymap_paint(wmKeyConfig *keyconf) { wmKeyMap *keymap; @@ -474,10 +526,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0); keymap->poll= sculpt_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH); @@ -496,6 +544,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "sculpt"); ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION); RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW); RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH); @@ -521,8 +570,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); keymap->poll= vertex_paint_mode_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); @@ -531,6 +578,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "vertex_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask"); @@ -539,9 +587,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); keymap->poll= weight_paint_mode_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, @@ -549,6 +594,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "weight_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask"); @@ -559,12 +605,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); @@ -572,6 +612,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "image_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask"); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 19c726616da..f4fc004f413 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -736,10 +736,10 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], fl Brush *brush = paint_brush(&vp->paint); float fac, fac_2, size, dx, dy; float alpha; - short vertco[2]; + int vertco[2]; const int radius= brush_size(brush); - project_short_noclip(vc->ar, vert_nor, vertco); + project_int_noclip(vc->ar, vert_nor, vertco); dx= mval[0]-vertco[0]; dy= mval[1]-vertco[1]; @@ -868,7 +868,7 @@ static void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int mo Object *ob= OBACT; Mesh *me= get_mesh(ob); int index; - short mval[2] = {0, 0}, sco[2]; + int mval[2] = {0, 0}, sco[2]; int vgroup= ob->actdef-1; if (!me) return; @@ -953,20 +953,20 @@ static void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int mo else { /* calc 3 or 4 corner weights */ dm->getVertCo(dm, mface->v1, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w1= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); dm->getVertCo(dm, mface->v2, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w2= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); dm->getVertCo(dm, mface->v3, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w3= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); if(mface->v4) { dm->getVertCo(dm, mface->v4, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w4= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); } else w4= 1.0e10; @@ -1147,110 +1147,6 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) } -/* ************ paint radial controls *************/ - -static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - RNA_float_set_array(op->ptr, "color", col); - - return WM_radial_control_invoke(C, op, event); -} - -static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, vertex_paint_poll); - return ret; -} - -static int vpaint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - RNA_float_set_array(op->ptr, "color", col); - - return WM_radial_control_invoke(C, op, event); -} - -static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, weight_paint_poll); - return ret; -} - -static int wpaint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Weight Paint Radial Control"; - ot->idname= "PAINT_OT_weight_paint_radial_control"; - - ot->invoke= wpaint_radial_control_invoke; - ot->modal= wpaint_radial_control_modal; - ot->exec= wpaint_radial_control_exec; - ot->poll= weight_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - -void PAINT_OT_vertex_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Vertex Paint Radial Control"; - ot->idname= "PAINT_OT_vertex_paint_radial_control"; - - ot->invoke= vpaint_radial_control_invoke; - ot->modal= vpaint_radial_control_modal; - ot->exec= vpaint_radial_control_exec; - ot->poll= vertex_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /* ************ weight paint operator ********** */ struct WPaintData { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7156b49c026..09e46119dbe 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2816,65 +2816,6 @@ static const char *sculpt_tool_name(Sculpt *sd) } } -/**** Radial control ****/ -static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4], tex_col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - if((brush->flag & BRUSH_DIR_IN) && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) - copy_v3_v3(col, brush->sub_col); - else - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - - copy_v3_v3(tex_col, U.sculpt_paint_overlay_col); - tex_col[3]= (brush->texture_overlay_alpha / 100.0f); - - RNA_float_set_array(op->ptr, "color", col); - RNA_float_set_array(op->ptr, "texture_color", tex_col); - - return WM_radial_control_invoke(C, op, event); -} - -static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, sculpt_poll); - return ret; -} - -static int sculpt_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -static void SCULPT_OT_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Sculpt Radial Control"; - ot->idname= "SCULPT_OT_radial_control"; - - ot->invoke= sculpt_radial_control_invoke; - ot->modal= sculpt_radial_control_modal; - ot->exec= sculpt_radial_control_exec; - ot->poll= sculpt_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /**** Operator for applying a stroke (various attributes including mouse path) using the current brush. ****/ @@ -3346,18 +3287,23 @@ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss) sculpt_update_tex(sd, ss); } -static int sculpt_brush_stroke_init(bContext *C, ReportList *UNUSED(reports)) +static int sculpt_brush_stroke_init(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; SculptSession *ss = CTX_data_active_object(C)->sculpt; Brush *brush = paint_brush(&sd->paint); + int mode= RNA_enum_get(op->ptr, "mode"); + int is_smooth= 0; view3d_operator_needs_opengl(C); sculpt_brush_init_tex(sd, ss); - sculpt_update_mesh_elements(scene, sd, ob, brush->sculpt_tool == SCULPT_TOOL_SMOOTH); + is_smooth|= mode == BRUSH_STROKE_SMOOTH; + is_smooth|= brush->sculpt_tool == SCULPT_TOOL_SMOOTH; + + sculpt_update_mesh_elements(scene, sd, ob, is_smooth); return 1; } @@ -3573,7 +3519,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even struct PaintStroke *stroke; int ignore_background_click; - if(!sculpt_brush_stroke_init(C, op->reports)) + if(!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; stroke = paint_stroke_new(C, sculpt_stroke_get_location, @@ -3602,7 +3548,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { - if(!sculpt_brush_stroke_init(C, op->reports)) + if(!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, @@ -3758,7 +3704,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) void ED_operatortypes_sculpt(void) { - WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); WM_operatortype_append(SCULPT_OT_set_persistent_base); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index bee872dbe60..6637e7004d5 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -858,9 +858,9 @@ static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent /* determine which side of the current frame mouse is on */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL); if (x < CFRA) - RNA_int_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT); + RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT); else - RNA_int_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); + RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); } /* perform selection */ diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index b097ad0f55e..9b65589ef4c 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -59,6 +59,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_library.h" +#include "BKE_icons.h" #include "BKE_main.h" #include "BKE_report.h" #include "BLO_readfile.h" @@ -433,7 +434,7 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir) // check if already exists if(previous_folder && previous_folder->foldername){ - if(! strcmp(previous_folder->foldername, dir)){ + if(BLI_path_cmp(previous_folder->foldername, dir)==0){ return; } } @@ -999,7 +1000,7 @@ static int groupname_to_code(char *group) return BKE_idcode_from_name(buf); } - + void filelist_from_library(struct FileList* filelist) { LinkNode *l, *names, *previews; @@ -1070,9 +1071,9 @@ void filelist_from_library(struct FileList* filelist) PreviewImage *img= l->link; if (img) { - unsigned int w = img->w[PREVIEW_MIPMAP_LARGE]; - unsigned int h = img->h[PREVIEW_MIPMAP_LARGE]; - unsigned int *rect = img->rect[PREVIEW_MIPMAP_LARGE]; + unsigned int w = img->w[ICON_SIZE_PREVIEW]; + unsigned int h = img->h[ICON_SIZE_PREVIEW]; + unsigned int *rect = img->rect[ICON_SIZE_PREVIEW]; /* first allocate imbuf for copying preview into it */ if (w > 0 && h > 0 && rect) { @@ -1086,7 +1087,7 @@ void filelist_from_library(struct FileList* filelist) } BLI_linklist_free(names, free); - if (previews) BLI_linklist_free(previews, (void(*)(void*)) MEM_freeN); + if (previews) BLI_linklist_free(previews, BKE_previewimg_freefunc); filelist_sort(filelist, FILE_SORT_ALPHA); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 6c713d6e469..47b3a71a9ea 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -818,7 +818,7 @@ static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEve ARegion *ar= ac.ar; View2D *v2d= &ar->v2d; - short mval[2]; + int mval[2]; float x; /* get mouse coordinates (in region coordinates) */ diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index b23ab624faa..286f1f3178b 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -38,7 +38,6 @@ set(SRC image_buttons.c image_draw.c image_ops.c - image_render.c space_image.c image_intern.h @@ -60,9 +59,4 @@ if(WITH_IMAGE_CINEON) add_definitions(-DWITH_CINEON) endif() -if(WITH_LCMS) - set(INC ${INC} ${LCMS_INCLUDE_DIR}) - add_definitions(-DWITH_LCMS) -endif() - blender_add_lib(bf_editor_space_image "${SRC}" "${INC}") diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index e84afcdaab1..27696e35701 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -9,9 +9,6 @@ incs += ' ../../render/extern/include ../../makesrna ../../blenloader' defs = [] -if env['WITH_BF_LCMS']: - defs.append('WITH_LCMS') - incs += ' ' + env['BF_LCMS_INC'] if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') if env['WITH_BF_OPENJPEG']: diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index c48078118a7..7e881e7e62f 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -98,19 +98,6 @@ /* proto */ -static void do_image_panel_events(bContext *C, void *UNUSED(arg), int event) -{ - SpaceImage *sima= CTX_wm_space_image(C); - - switch(event) { - case B_REDR: - break; - } - - /* all events now */ - WM_event_add_notifier(C, NC_IMAGE, sima->image); -} - static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, char *str) { int ofs= 0; @@ -281,7 +268,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) rcti *disprect= &G.scene->r.disprect; int winx= (G.scene->r.size*G.scene->r.xsch)/100; int winy= (G.scene->r.size*G.scene->r.ysch)/100; - short mval[2]; + int mval[2]; if(G.scene->r.mode & R_BORDER) { winx*= (G.scene->r.border.xmax - G.scene->r.border.xmin); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 0f361b43de6..112359726ea 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -58,10 +58,6 @@ #include "BKE_image.h" #include "BKE_paint.h" -#ifdef WITH_LCMS -#include "BKE_colortools.h" -#endif - #include "BIF_gl.h" #include "BIF_glutil.h" @@ -452,20 +448,6 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl // glColorMask(1, 1, 1, 1); } -#ifdef WITH_LCMS -static int sima_draw_colorcorrected_pixels(float x1, float y1, ImBuf *ibuf) -{ - colorcorrection_do_ibuf(ibuf, "MONOSCNR.ICM"); /* path is hardcoded here, find some place better */ - - if(ibuf->crect) { - glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->crect); - return 1; - } - - return 0; -} -#endif - static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti) { /* zbuffer values are signed, so we need to shift color range */ @@ -544,17 +526,6 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image else if(ibuf->channels==1) sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float); } -#ifdef WITH_LCMS - else if(sima->flag & SI_COLOR_CORRECTION) { - image_verify_buffer_float(ima, ibuf, color_manage); - - if(sima_draw_colorcorrected_pixels(x, y, ibuf)==0) { - unsigned char col1[3]= {100, 0, 100}, col2[3]= {160, 0, 160}; /* pink says 'warning' in blender land */ - sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2); - } - - } -#endif else { if(sima->flag & SI_USE_ALPHA) { unsigned char col1[3]= {100, 100, 100}, col2[3]= {160, 160, 160}; @@ -702,7 +673,7 @@ static void draw_image_view_tool(Scene *scene) { ToolSettings *settings= scene->toolsettings; Brush *brush= settings->imapaint.brush; - short mval[2]; + int mval[2]; float radius; int draw= 0; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 17244a5251c..c4d52e3b836 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -802,6 +802,7 @@ void IMAGE_OT_open(wmOperatorType *ot) { /* identifiers */ ot->name= "Open Image"; + ot->description= "Open image"; ot->idname= "IMAGE_OT_open"; /* api callbacks */ @@ -1345,6 +1346,7 @@ void IMAGE_OT_new(wmOperatorType *ot) /* identifiers */ ot->name= "New Image"; + ot->description= "Create a new image"; ot->idname= "IMAGE_OT_new"; /* api callbacks */ diff --git a/source/blender/editors/space_image/image_render.c b/source/blender/editors/space_image/image_render.c deleted file mode 100644 index 04b65af618e..00000000000 --- a/source/blender/editors/space_image/image_render.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2009 - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_image/image_render.c - * \ingroup spimage - */ - - -#include <stdlib.h> -#include <stdio.h> - -#include "BLI_utildefines.h" - -#include "DNA_screen_types.h" -#include "DNA_space_types.h" - -#include "BKE_context.h" -#include "BKE_image.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - - -#include "RE_pipeline.h" - - -#define HEADER_HEIGHT 18 - -/* *********************** render callbacks ***************** */ - -/* set on initialize render, only one render output to imagewindow can exist, so the global isnt dangerous yet :) */ -static ScrArea *image_area= NULL; - -/* can get as well the full picture, as the parts while rendering */ -/* XXX will be obsolete, here for reference now */ -static void imagewindow_progress(SpaceImage *sima, RenderResult *rr, volatile rcti *renrect) -{ - float x1, y1, *rectf= NULL; - unsigned int *rect32= NULL; - int ymin, ymax, xmin, xmax; - - /* if renrect argument, we only display scanlines */ - if(renrect) { - /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */ - if(rr->renlay==NULL || renrect->ymax>=rr->recty) - return; - - /* xmin here is first subrect x coord, xmax defines subrect width */ - xmin = renrect->xmin; - xmax = renrect->xmax - xmin; - if (xmax<2) return; - - ymin= renrect->ymin; - ymax= renrect->ymax - ymin; - if(ymax<2) - return; - renrect->ymin= renrect->ymax; - } - else { - xmin = ymin = 0; - xmax = rr->rectx - 2*rr->crop; - ymax = rr->recty - 2*rr->crop; - } - - /* image window cruft */ - - /* find current float rect for display, first case is after composit... still weak */ - if(rr->rectf) - rectf= rr->rectf; - else { - if(rr->rect32) - rect32= (unsigned int *)rr->rect32; - else { - if(rr->renlay==NULL || rr->renlay->rectf==NULL) return; - rectf= rr->renlay->rectf; - } - } - if(rectf) { - /* if scanline updates... */ - rectf+= 4*(rr->rectx*ymin + xmin); - - /* when rendering more pixels than needed, we crop away cruft */ - if(rr->crop) - rectf+= 4*(rr->crop*rr->rectx + rr->crop); - } - - /* tilerect defines drawing offset from (0,0) */ - /* however, tilerect (xmin, ymin) is first pixel */ - x1 = sima->centx + (rr->tilerect.xmin + rr->crop + xmin)*sima->zoom; - y1 = sima->centy + (rr->tilerect.ymin + rr->crop + ymin)*sima->zoom; - - /* needed for gla draw */ - // XXX { rcti rct= ar->winrct; rct.ymax-= HEADER_HEIGHT; glaDefine2DArea(&rct);} - - glPixelZoom(sima->zoom, sima->zoom); - - if(rect32) - glaDrawPixelsSafe(x1, y1, xmax, ymax, rr->rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect32); - else - glaDrawPixelsSafe_to32(x1, y1, xmax, ymax, rr->rectx, rectf, 0); - - glPixelZoom(1.0, 1.0); - -} - - -/* coming from BIF_toggle_render_display() */ -static void imagewindow_toggle_render(bContext *C) -{ - bScreen *sc= CTX_wm_screen(C); - ScrArea *sa; - - /* check if any imagewindow is showing temporal render output */ - for(sa=sc->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_IMAGE) { - SpaceImage *sima= sa->spacedata.first; - - if(sima->image && sima->image->type==IMA_TYPE_R_RESULT) - if(sima->flag & (SI_PREVSPACE|SI_FULLWINDOW)) - break; - } - } - - if(sa) { - // XXX addqueue(sa->win, ESCKEY, 1); /* also returns from fullscreen */ - } - else { -// sa= imagewindow_set_render_display(C); - // XXX scrarea_queue_headredraw(sa); - // XXX scrarea_queue_winredraw(sa); - } -} - -/* NOTE: called while render, so no malloc allowed! */ -static void imagewindow_renderinfo_cb(void *UNUSED(handle), RenderStats *UNUSED(rs)) -{ - if(image_area) { - // XXX BIF_make_render_text(rs); - - // XXX sima_draw_render_info(sima, ar); - - /* no screen_swapbuffers, prevent any other window to draw */ - // XXX myswapbuffers(); - } -} - -static void ED_space_image_render_callbacks(bContext *C, Render *re) -{ - -// RE_display_init_cb(re, C, imagewindow_init_display_cb); -// RE_display_draw_cb(re, C, imagewindow_progress_display_cb); -// RE_display_clear_cb(re, C, imagewindow_clear_display_cb); - RE_stats_draw_cb(re, C, imagewindow_renderinfo_cb); -} - diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 67f02ce4f8e..937b683e880 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -230,7 +230,7 @@ static int borderselect_exec(bContext *C, wmOperator *op) rcti rect; //rctf rectf, rq; short selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); - //short mval[2]; + //int mval[2]; rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.ymin= RNA_int_get(op->ptr, "ymin"); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index d75c1aa7dd3..188042ad1d1 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -612,7 +612,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even bAnimContext ac; Scene *scene; ARegion *ar; - View2D *v2d; + // View2D *v2d; /*UNUSED*/ short selectmode; int mval[2]; @@ -623,7 +623,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even /* get useful pointers from animation context data */ scene= ac.scene; ar= ac.ar; - v2d= &ar->v2d; + // v2d= &ar->v2d; /* get mouse coordinates (in region coordinates) */ mval[0]= (event->x - ar->winrct.xmin); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 01f32b49888..19a9bfb224b 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1010,7 +1010,7 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct) /* **************************** */ typedef struct NodeViewMove { - short mvalo[2]; + int mvalo[2]; int xmin, ymin, xmax, ymax; } NodeViewMove; @@ -1615,7 +1615,7 @@ static int node_mouse_groupheader(SpaceNode *snode) { bNode *gnode; float mx=0, my=0; -// XXX short mval[2]; +// XXX int mval[2]; gnode= node_tree_get_editgroup(snode->nodetree); if(gnode==NULL) return 0; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 78368d91378..6bda47e5c8f 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -70,7 +70,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) /* ****** Click Select ****** */ -static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const short mval[2], short extend) +static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2], short extend) { bNode *node; float mx, my; @@ -102,7 +102,7 @@ static int node_select_exec(bContext *C, wmOperator *op) { SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; short extend; bNode *node= NULL; @@ -125,7 +125,7 @@ static int node_select_exec(bContext *C, wmOperator *op) static int node_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; @@ -199,7 +199,7 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event /* this allows border select on empty space, but drag-translate on nodes */ SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; float mx, my; mval[0]= event->x - ar->winrct.xmin; diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 1ae36b077af..9665a152970 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -158,7 +158,7 @@ static int do_header_hidden_node(bNode *node, float mx, float my) return 0; } -static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, const short mval[2]) +static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, const int mval[2]) { bNode *node; float mx, my; @@ -189,7 +189,7 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op) { SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); @@ -202,7 +202,7 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op) static int node_toggle_visibility_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 2ef8fb12965..ad0d0048388 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -120,7 +120,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w ARegion *ar= CTX_wm_region(C); View2D *v2d= UI_view2d_fromcontext(C); - short mval[2]; + int mval[2]; float mval_v2d[2]; @@ -633,12 +633,13 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load.", path); return OPERATOR_CANCELLED; } - } - else if (seq->type==SEQ_COLOR) { + } else if (seq->type == SEQ_COLOR) { SolidColorVars *colvars= (SolidColorVars *)seq->effectdata; RNA_float_get_array(op->ptr, "color", colvars->col); seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */ + } else if (seq->type == SEQ_ADJUSTMENT) { + seq->blend_mode= SEQ_CROSS; } // XXX, this conflicts with giving a channel with invoke, perhaps we should have an active channel diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2f95e8fa64c..f351d52db07 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -126,6 +126,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_OVERDROP: case SEQ_GLOW: case SEQ_MULTICAM: + case SEQ_ADJUSTMENT: UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col); /* slightly offset hue to distinguish different effects */ @@ -137,6 +138,8 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ if (seq->type == SEQ_OVERDROP) rgb_byte_set_hue_float_offset(col,0.24); if (seq->type == SEQ_GLOW) rgb_byte_set_hue_float_offset(col,0.28); if (seq->type == SEQ_TRANSFORM) rgb_byte_set_hue_float_offset(col,0.36); + if (seq->type == SEQ_MULTICAM) rgb_byte_set_hue_float_offset(col,0.32); + if (seq->type == SEQ_ADJUSTMENT) rgb_byte_set_hue_float_offset(col,0.40); break; case SEQ_COLOR: @@ -476,7 +479,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float if(name[0]=='\0') name= give_seqname(seq); - if(seq->type == SEQ_META) { + if(seq->type == SEQ_META || seq->type == SEQ_ADJUSTMENT) { sprintf(str, "%d | %s", seq->len, name); } else if(seq->type == SEQ_SCENE) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 92fae3d4820..880f285c3e3 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -100,6 +100,7 @@ EnumPropertyItem sequencer_prop_effect_types[] = { {SEQ_COLOR, "COLOR", 0, "Color", "Color effect strip type"}, {SEQ_SPEED, "SPEED", 0, "Speed", "Color effect strip type"}, {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, + {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, {0, NULL, 0, NULL, NULL} }; @@ -191,7 +192,7 @@ void boundbox_seq(Scene *scene, rctf *rect) static int mouse_frame_side(View2D *v2d, short mouse_x, int frame ) { - short mval[2]; + int mval[2]; float mouseloc[2]; mval[0]= mouse_x; @@ -284,7 +285,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i } -Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const short mval[2]) +Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2]) { Sequence *seq; Editing *ed= seq_give_editing(scene, FALSE); @@ -406,6 +407,7 @@ int event_to_efftype(int event) if(event==15) return SEQ_TRANSFORM; if(event==16) return SEQ_COLOR; if(event==17) return SEQ_SPEED; + if(event==18) return SEQ_ADJUSTMENT; return 0; } @@ -517,7 +519,8 @@ static void change_sequence(Scene *scene) "|Glow%x14" "|Transform%x15" "|Color Generator%x16" - "|Speed Control%x17"); + "|Speed Control%x17" + "|Adjustment Layer%x18"); if(event > 0) { if(event==1) { SWAP(Sequence *,last_seq->seq1,last_seq->seq2); @@ -703,15 +706,9 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de while(seq) { seqn= seq->next; if((seq->flag & flag) || deleteall) { - if(seq->type==SEQ_SOUND && seq->sound) { - ((ID *)seq->sound)->us--; /* TODO, could be moved into seq_free_sequence() */ - } - BLI_remlink(lb, seq); if(seq==last_seq) seq_active_set(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); - /* if(seq->ipo) seq->ipo->id.us--; */ - /* XXX, remove fcurve */ seq_free_sequence(scene, seq); } seq= seqn; @@ -1084,7 +1081,7 @@ static int seq_get_snaplimit(View2D *v2d) /* fake mouse coords to get the snap value a bit lazy but its only done once pre transform */ float xmouse, ymouse, x; - short mval[2] = {24, 0}; /* 24 screen px snap */ + int mval[2] = {24, 0}; /* 24 screen px snap */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse); x = xmouse; @@ -1706,11 +1703,6 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) if (nothingSelected) return OPERATOR_FINISHED; - /* free imbufs of all dependent strips */ - for(seq=ed->seqbasep->first; seq; seq=seq->next) - if(seq->flag & SELECT) - update_changed_seq_and_deps(scene, seq, 1, 0); - /* for effects, try to find a replacement input */ for(seq=ed->seqbasep->first; seq; seq=seq->next) if((seq->type & SEQ_EFFECT) && !(seq->flag & SELECT)) diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 9a4796ced5e..209b39662aa 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -61,7 +61,7 @@ void seq_reset_imageofs(struct SpaceSeq *sseq); struct View2D; void seq_rectf(struct Sequence *seq, struct rctf *rectf); void boundbox_seq(struct Scene *scene, struct rctf *rect); -struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, const short mval[2]); +struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, const int mval[2]); struct Sequence *find_neighboring_sequence(struct Scene *scene, struct Sequence *test, int lr, int sel); void deselect_all_seq(struct Scene *scene); void recurs_sel_seq(struct Sequence *seqm); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index b2d6ab6f8ca..2cae2d17a33 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -307,7 +307,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) short left_right= RNA_boolean_get(op->ptr, "left_right"); short linked_time= RNA_boolean_get(op->ptr, "linked_time"); - short mval[2]; + int mval[2]; Sequence *seq,*neighbor, *act_orig; int hand,sel_side; @@ -489,7 +489,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) /* marker transform */ #if 0 // XXX probably need to redo this differently for 2.5 if (marker) { - short mval[2], xo, yo; + int mval[2], xo, yo; // getmouseco_areawin(mval); xo= mval[0]; yo= mval[1]; @@ -656,7 +656,7 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEv View2D *v2d= UI_view2d_fromcontext(C); short extend= RNA_boolean_get(op->ptr, "extend"); - short mval[2]; + int mval[2]; Sequence *mouse_seq; int selected, hand; @@ -837,7 +837,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) rcti rect; rctf rectf, rq; short selecting = (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); - short mval[2]; + int mval[2]; if(ed==NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index e87719084ce..635e922cd65 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2109,7 +2109,7 @@ static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event) SpaceText *st= CTX_wm_space_text(C); ARegion *ar= CTX_wm_region(C); TextScroll *tsc= op->customdata; - short mval[2]= {event->x, event->y}; + int mval[2]= {event->x, event->y}; short txtdelta[2] = {0, 0}; text_update_character_width(st); @@ -2283,7 +2283,7 @@ static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) SpaceText *st= CTX_wm_space_text(C); ARegion *ar= CTX_wm_region(C); TextScroll *tsc; - const short *mval= event->mval; + const int *mval= event->mval; int zone= -1; if(RNA_property_is_set(op->ptr, "lines")) @@ -2694,7 +2694,7 @@ static int line_number_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *even SpaceText *st= CTX_wm_space_text(C); Text *text= CTX_data_edit_text(C); ARegion *ar= CTX_wm_region(C); - const short *mval= event->mval; + const int *mval= event->mval; double time; static int jump_to= 0; static double last_jump= 0; diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c index bd8710ec120..6e6f131655b 100644 --- a/source/blender/editors/space_text/text_python.c +++ b/source/blender/editors/space_text/text_python.c @@ -54,7 +54,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) TextLine *tmp; int l, x, y, w, h, i; int tgti, *top; - short mval[2] = {0, 0}; + int mval[2] = {0, 0}; if(!st || !st->text) return 0; if(!texttool_text_is_active(st->text)) return 0; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index d062ca8e25f..f070bae4e54 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -366,7 +366,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O } else { /* draw with lights in the scene otherwise */ - Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, get_view3d_ortho(v3d, rv3d)); + Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); } obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a3a139181d5..e88ee7dd69a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -46,6 +46,7 @@ #include "DNA_scene_types.h" #include "DNA_smoke_types.h" #include "DNA_world_types.h" +#include "DNA_armature_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -76,6 +77,9 @@ #include "smoke_API.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + #include "BIF_gl.h" #include "BIF_glutil.h" @@ -515,6 +519,96 @@ void drawaxes(float size, char drawtype) } } + +/* Function to draw an Image on a empty Object */ +static void draw_empty_image(Object *ob) +{ + Image *ima = (Image*)ob->data; + ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; + + float scale, ofs_x, ofs_y, sca_x, sca_y; + int ima_x, ima_y; + + if(ibuf && (ibuf->rect == NULL) && (ibuf->rect_float != NULL)) { + IMB_rect_from_float(ibuf); + } + + /* Get the buffer dimensions so we can fallback to fake ones */ + if(ibuf && ibuf->rect) { + ima_x= ibuf->x; + ima_y= ibuf->y; + } + else { + ima_x= 1; + ima_y= 1; + } + + /* Get the image aspect even if the buffer is invalid */ + if(ima) { + if(ima->aspx > ima->aspy) { + sca_x= 1.0f; + sca_y= ima->aspy / ima->aspx; + } + else if(ima->aspx < ima->aspy) { + sca_x= ima->aspx / ima->aspy; + sca_y= 1.0f; + } + else { + sca_x= 1.0f; + sca_y= 1.0f; + } + } + else { + sca_x= 1.0f; + sca_y= 1.0f; + } + + /* Calculate the scale center based on objects origin */ + ofs_x= ob->ima_ofs[0] * ima_x; + ofs_y= ob->ima_ofs[1] * ima_y; + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + /* Make sure we are drawing at the origin */ + glTranslatef(0.0f, 0.0f, 0.0f); + + /* Calculate Image scale */ + scale= (ob->empty_drawsize / (float)MAX2(ima_x * sca_x, ima_y * sca_y)); + + /* Set the object scale */ + glScalef(scale * sca_x, scale * sca_y, 1.0f); + + if(ibuf && ibuf->rect) { + /* Setup GL params */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + /* Use the object color and alpha */ + glColor4fv(ob->col); + + /* Draw the Image on the screen */ + glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_UNSIGNED_BYTE, ibuf->rect); + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + + glDisable(GL_BLEND); + } + + UI_ThemeColor((ob->flag & SELECT) ? TH_SELECT : TH_WIRE); + + /* Calculate the outline vertex positions */ + glBegin(GL_LINE_LOOP); + glVertex2f(ofs_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y + ima_y); + glVertex2f(ofs_x, ofs_y + ima_y); + glEnd(); + + /* Reset GL settings */ + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); +} + void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]) { float vec[3], vx[3], vy[3]; @@ -572,7 +666,7 @@ typedef struct ViewCachedString { unsigned char ub[4]; int pack; } col; - short mval[2]; + short sco[2]; short xoffs; short flag; int str_len, pad; @@ -614,8 +708,8 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa for(vos= strings->first; vos; vos= vos->next) { if(mat && !(vos->flag & V3D_CACHE_TEXT_WORLDSPACE)) mul_m4_v3(mat, vos->vec); - view3d_project_short_clip(ar, vos->vec, vos->mval, 0); - if(vos->mval[0]!=IS_CLIPPED) + view3d_project_short_clip(ar, vos->vec, vos->sco, 0); + if(vos->sco[0]!=IS_CLIPPED) tot++; } @@ -655,7 +749,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa continue; } #endif - if(vos->mval[0]!=IS_CLIPPED) { + if(vos->sco[0]!=IS_CLIPPED) { const char *str= (char *)(vos+1); if(col_pack_prev != vos->col.pack) { @@ -663,10 +757,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa col_pack_prev= vos->col.pack; } if(vos->flag & V3D_CACHE_TEXT_ASCII) { - BLF_draw_default_ascii((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); + BLF_draw_default_ascii((float)vos->sco[0]+vos->xoffs, (float)vos->sco[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); } else { - BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); + BLF_draw_default((float)vos->sco[0]+vos->xoffs, (float)vos->sco[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); } } } @@ -5954,8 +6048,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) break; } case OB_EMPTY: - if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) - drawaxes(ob->empty_drawsize, ob->empty_drawtype); + if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if (ob->empty_drawtype == OB_EMPTY_IMAGE) { + draw_empty_image(ob); + } + else { + drawaxes(ob->empty_drawsize, ob->empty_drawtype); + } + } break; case OB_LAMP: if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { @@ -6564,7 +6664,12 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object draw_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline); break; case OB_EMPTY: - drawaxes(ob->empty_drawsize, ob->empty_drawtype); + if (ob->empty_drawtype == OB_EMPTY_IMAGE) { + draw_empty_image(ob); + } + else { + drawaxes(ob->empty_drawsize, ob->empty_drawtype); + } break; } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e967e8ed2e7..4ef02243cd5 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -564,13 +564,13 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) { - short mx,my,co[2]; + int mx, my, co[2]; int flag; /* we dont want the clipping for cursor */ flag= v3d->flag; v3d->flag= 0; - project_short(ar, give_cursor(scene, v3d), co); + project_int(ar, give_cursor(scene, v3d), co); v3d->flag= flag; mx = co[0]; @@ -763,7 +763,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d) /* draw info beside axes in bottom left-corner: * framenum, object name, bone name (if available), marker name (if available) */ -static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) +static void draw_selected_name(Scene *scene, Object *ob) { char info[256], *markern; short offset=30; @@ -832,7 +832,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), v3d->keyflags)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -921,6 +921,77 @@ void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, Vi } } +static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac) +{ + float x3, y3, x4, y4; + + x3= x1 + fac * (x2-x1); + y3= y1 + fac * (y2-y1); + x4= x1 + (1.0f - fac) * (x2-x1); + y4= y1 + (1.0f - fac) * (y2-y1); + + glBegin(GL_LINES); + glVertex2f(x1, y3); + glVertex2f(x2, y3); + + glVertex2f(x1, y4); + glVertex2f(x2, y4); + + glVertex2f(x3, y1); + glVertex2f(x3, y2); + + glVertex2f(x4, y1); + glVertex2f(x4, y2); + glEnd(); +} + +/* harmonious triangle */ +static void drawviewborder_triangle(float x1, float x2, float y1, float y2, const char golden, const char dir) +{ + float ofs; + float w= x2 - x1; + float h= y2 - y1; + + glBegin(GL_LINES); + if(w > h) { + if(golden) { + ofs = w * (1.0f-(1.0f/1.61803399)); + } + else { + ofs = h * (h / w); + } + if(dir == 'B') SWAP(float, y1, y2); + + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x2, y1); + glVertex2f(x1 + (w - ofs), y2); + + glVertex2f(x1, y2); + glVertex2f(x1 + ofs, y1); + } + else { + if(golden) { + ofs = h * (1.0f-(1.0f/1.61803399)); + } + else { + ofs = w * (w / h); + } + if(dir == 'B') SWAP(float, x1, x2); + + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x2, y1); + glVertex2f(x1, y1 + ofs); + + glVertex2f(x1, y2); + glVertex2f(x2, y1 + (h - ofs)); + } + glEnd(); +} + static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { float fac, a; @@ -944,10 +1015,14 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) y2= viewborder.ymax; /* apply offsets so the real 3D camera shows through */ - x1i= (int)(x1 - 1.0f); - y1i= (int)(y1 - 1.0f); - x2i= (int)(x2 + 1.0f); - y2i= (int)(y2 + 1.0f); + + /* note: quite un-scientific but without this bit extra + * 0.0001 on the lower left the 2D border sometimes + * obscures the 3D camera border */ + x1i= (int)(x1 - 1.0001f); + y1i= (int)(y1 - 1.0001f); + x2i= (int)(x2 + (1.0f-0.0001f)); + y2i= (int)(y2 + (1.0f-0.0001f)); /* passepartout, specified in camera edit buttons */ if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) { @@ -995,21 +1070,80 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) } /* safety border */ - if (ca && (ca->flag & CAM_SHOWTITLESAFE)) { - fac= 0.1; - - a= fac*(x2-x1); - x1+= a; - x2-= a; - - a= fac*(y2-y1); - y1+= a; - y2-= a; - - UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - - uiSetRoundBox(15); - uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + if(ca) { + if (ca->dtx & CAM_DTX_CENTER) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + x3= x1+ 0.5f*(x2-x1); + y3= y1+ 0.5f*(y2-y1); + + glBegin(GL_LINES); + glVertex2f(x1, y3); + glVertex2f(x2, y3); + + glVertex2f(x3, y1); + glVertex2f(x3, y2); + glEnd(); + } + + if (ca->dtx & CAM_DTX_CENTER_DIAG) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + glBegin(GL_LINES); + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x1, y2); + glVertex2f(x2, y1); + glEnd(); + } + + if (ca->dtx & CAM_DTX_THIRDS) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f); + } + + if (ca->dtx & CAM_DTX_GOLDEN) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399)); + } + + if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 0, 'A'); + } + + if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 0, 'B'); + } + + if (ca->dtx & CAM_DTX_HARMONY_TRI_A) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 1, 'A'); + } + + if (ca->dtx & CAM_DTX_HARMONY_TRI_B) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 1, 'B'); + } + + if (ca->flag & CAM_SHOWTITLESAFE) { + fac= 0.1; + + a= fac*(x2-x1); + x1+= a; + x2-= a; + + a= fac*(y2-y1); + y1+= a; + y2-= a; + + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + uiSetRoundBox(15); + uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + } } setlinestyle(0); @@ -1172,7 +1306,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, } /* smart function to sample a rect spiralling outside, nice for backbuf selection */ -unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const short mval[2], int size, +unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) { @@ -2362,7 +2496,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) // needs to be done always, gridview is adjusted in drawgrid() now rv3d->gridview= v3d->grid; - if(rv3d->view==0 || rv3d->persp != RV3D_ORTHO) { + if((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { drawfloor(scene, v3d, &grid_unit); } @@ -2534,7 +2668,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) ob= OBACT; if(U.uiflag & USER_DRAWVIEWINFO) - draw_selected_name(scene, ob, v3d); + draw_selected_name(scene, ob); /* XXX here was the blockhandlers for floating panels */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 30bfc355480..2bd2e4e497f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -40,6 +40,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_camera_types.h" +#include "DNA_lamp_types.h" #include "MEM_guardedalloc.h" @@ -55,6 +56,7 @@ #include "BKE_paint.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ #include "BIF_gl.h" @@ -79,6 +81,23 @@ /* ********************** view3d_edit: view manipulations ********************* */ +void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) +{ + if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && (rv3d->persp==RV3D_CAMOB)) { + ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + } +} + +void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) +{ + if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && (rv3d->persp==RV3D_CAMOB)) { + ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); + DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); + WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); + } +} + + /* ********************* box view support ***************** */ static void view3d_boxview_clip(ScrArea *sa) @@ -277,6 +296,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, short do_clip) typedef struct ViewOpsData { ScrArea *sa; ARegion *ar; + View3D *v3d; RegionView3D *rv3d; /* needed for continuous zoom */ @@ -331,7 +351,6 @@ static void calctrackballvec(rcti *rect, int mx, int my, float *vec) static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) { static float lastofs[3] = {0,0,0}; - View3D *v3d; RegionView3D *rv3d; ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data"); @@ -339,8 +358,13 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) op->customdata= vod; vod->sa= CTX_wm_area(C); vod->ar= CTX_wm_region(C); - v3d= vod->sa->spacedata.first; + vod->v3d= vod->sa->spacedata.first; vod->rv3d= rv3d= vod->ar->regiondata; + + /* set the view from the camera, if view locking is enabled. + * we may want to make this optional but for now its needed always */ + ED_view3d_camera_lock_init(vod->v3d, vod->rv3d); + vod->dist0= rv3d->dist; copy_qt_qt(vod->oldquat, rv3d->viewquat); vod->origx= vod->oldx= event->x; @@ -358,8 +382,8 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) view3d_operator_needs_opengl(C); /* needed for zbuf drawing */ - if((vod->use_dyn_ofs=view_autodist(CTX_data_scene(C), vod->ar, v3d, event->mval, vod->dyn_ofs))) { - if (rv3d->persp==RV3D_PERSP) { + if((vod->use_dyn_ofs=view_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) { + if (rv3d->is_persp) { float my_origin[3]; /* original G.vd->ofs */ float my_pivot[3]; /* view */ float dvec[3]; @@ -390,17 +414,15 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) } negate_v3(vod->dyn_ofs); copy_v3_v3(vod->ofs, rv3d->ofs); - } else { - vod->ofs[0] = vod->ofs[1] = vod->ofs[2] = 0.0f; } } /* for dolly */ - window_to_3d_vector(vod->ar, vod->mousevec, (vod->oldx - vod->ar->winrct.xmin)-(vod->ar->winx)/2, (vod->oldy - vod->ar->winrct.ymin)-(vod->ar->winy)/2); + window_to_3d_vector(vod->ar, vod->mousevec, vod->oldx - vod->ar->winrct.xmin, vod->oldy - vod->ar->winrct.ymin); /* lookup, we dont pass on v3d to prevent confusement */ - vod->grid= v3d->grid; - vod->far= v3d->far; + vod->grid= vod->v3d->grid; + vod->far= vod->v3d->far; calctrackballvec(&vod->ar->winrct, event->x, event->y, vod->trackvec); @@ -546,7 +568,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) { RegionView3D *rv3d= vod->rv3d; - rv3d->view= 0; /* need to reset everytime because of view snapping */ + rv3d->view= RV3D_VIEW_USER; /* need to reset everytime because of view snapping */ if (U.flag & USER_TRACKBALL) { float phi, si, q1[4], dvec[3], newvec[3]; @@ -711,6 +733,8 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) /* avoid precision loss over time */ normalize_qt(rv3d->viewquat); + ED_view3d_camera_lock_sync(vod->v3d, rv3d); + ED_region_tag_redraw(vod->ar); } @@ -782,18 +806,18 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) if(rv3d->persp != RV3D_PERSP) { if (U.uiflag & USER_AUTOPERSP) { - rv3d->persp= RV3D_PERSP; + if(!((rv3d->persp==RV3D_CAMOB) && (vod->v3d->flag2 & V3D_LOCK_CAMERA))) { + rv3d->persp= RV3D_PERSP; + } } else if(rv3d->persp==RV3D_CAMOB) { /* changed since 2.4x, use the camera view */ - View3D *v3d = vod->sa->spacedata.first; - - if(v3d->camera) { - view3d_apply_ob(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + if(vod->v3d->camera) { + ED_view3d_from_object(vod->v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } - if(rv3d->persp==RV3D_CAMOB) { + if(!(vod->v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->persp= rv3d->lpersp; } } @@ -894,7 +918,7 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) static void viewmove_apply(ViewOpsData *vod, int x, int y) { - if(vod->rv3d->persp==RV3D_CAMOB) { + if((vod->rv3d->persp==RV3D_CAMOB) && !(vod->v3d->flag2 & V3D_LOCK_CAMERA)) { float zoomfac= ((float)M_SQRT2 + (float)vod->rv3d->camzoom / 50.0f); zoomfac= (zoomfac * zoomfac) * 0.5f; @@ -917,6 +941,8 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) vod->oldx= x; vod->oldy= y; + ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); + ED_region_tag_redraw(vod->ar); } @@ -966,11 +992,13 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ViewOpsData *vod; + /* makes op->customdata */ viewops_data_create(C, op, event); + vod= op->customdata; if (event->type == MOUSEPAN) { - ViewOpsData *vod= op->customdata; viewmove_apply(vod, event->prevx, event->prevy); request_depth_update(vod->rv3d); @@ -1159,6 +1187,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, if(vod->rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(vod->sa, vod->ar); + ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); + ED_region_tag_redraw(vod->ar); } @@ -1237,7 +1267,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if(delta < 0) { /* this min and max is also in viewmove() */ - if(rv3d->persp==RV3D_CAMOB) { + if((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->camzoom-= 10; if(rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN; } @@ -1246,7 +1276,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) } } else { - if(rv3d->persp==RV3D_CAMOB) { + if((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->camzoom+= 10; if(rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX; } @@ -1259,6 +1289,9 @@ static int viewzoom_exec(bContext *C, wmOperator *op) view3d_boxview_sync(sa, ar); request_depth_update(rv3d); + + ED_view3d_camera_lock_sync(v3d, rv3d); + ED_region_tag_redraw(ar); viewops_data_free(C, op); @@ -1269,6 +1302,12 @@ static int viewzoom_exec(bContext *C, wmOperator *op) /* viewdolly_invoke() copied this function, changes here may apply there */ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ViewOpsData *vod; + + /* makes op->customdata */ + viewops_data_create(C, op, event); + vod= op->customdata; + /* if one or the other zoom position aren't set, set from event */ if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { @@ -1277,18 +1316,9 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) } if(RNA_property_is_set(op->ptr, "delta")) { - /* makes op->customdata */ - viewops_data_create(C, op, event); viewzoom_exec(C, op); } else { - ViewOpsData *vod; - - /* makes op->customdata */ - viewops_data_create(C, op, event); - - vod= op->customdata; - if (event->type == MOUSEZOOM) { /* Bypass Zoom invert flag for track pads (pass FALSE always) */ @@ -1349,7 +1379,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) static void view_dolly_mouseloc(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac) { RegionView3D *rv3d= ar->regiondata; - madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, 1.0 - dfac); + madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0 - dfac)); } static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_invert) @@ -1379,6 +1409,8 @@ static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_inv if(vod->rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(vod->sa, vod->ar); + ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); + ED_region_tag_redraw(vod->ar); } @@ -1444,7 +1476,8 @@ static int viewdolly_exec(bContext *C, wmOperator *op) else { sa= CTX_wm_area(C); ar= CTX_wm_region(C); - normalize_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); + negate_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); + normalize_v3(mousevec); } /* v3d= sa->spacedata.first; */ /* UNUSED */ @@ -1475,7 +1508,13 @@ static int viewdolly_exec(bContext *C, wmOperator *op) /* copied from viewzoom_invoke(), changes here may apply there */ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ +{ + ViewOpsData *vod; + + /* makes op->customdata */ + viewops_data_create(C, op, event); + vod= op->customdata; + /* if one or the other zoom position aren't set, set from event */ if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { @@ -1484,21 +1523,13 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) } if(RNA_property_is_set(op->ptr, "delta")) { - /* makes op->customdata */ - viewops_data_create(C, op, event); viewdolly_exec(C, op); } else { - ViewOpsData *vod; - - /* makes op->customdata */ - viewops_data_create(C, op, event); - - vod= op->customdata; - /* overwrite the mouse vector with the view direction (zoom into the center) */ if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) == 0) { - normalize_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]); + negate_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]); + normalize_v3(vod->mousevec); } if (event->type == MOUSEZOOM) { @@ -1534,10 +1565,17 @@ static int viewdolly_poll(bContext *C) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if (rv3d && rv3d->persp == RV3D_PERSP) { - return 1; + if(rv3d) { + if (rv3d->persp == RV3D_PERSP) { + return 1; + } + else { + View3D *v3d= CTX_wm_view3d(C); + if ((rv3d->persp == RV3D_CAMOB) && (v3d->flag2 & V3D_LOCK_CAMERA)) { + return 1; + } + } } - return 0; } @@ -1572,6 +1610,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in Scene *scene= CTX_data_scene(C); Base *base; float *curs; + const short skip_camera= ((rv3d->persp==RV3D_CAMOB) && (v3d->flag2 & V3D_LOCK_CAMERA)); int center= RNA_boolean_get(op->ptr, "center"); @@ -1592,6 +1631,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in for(base= scene->base.first; base; base= base->next) { if(BASE_VISIBLE(v3d, base)) { onedone= 1; + + if(skip_camera && base->object == v3d->camera) { + continue; + } + minmax_object(base->object, min, max); } } @@ -1627,7 +1671,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in new_dist*= size; } - if (rv3d->persp==RV3D_CAMOB) { + if ((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->persp= RV3D_PERSP; smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } @@ -1671,6 +1715,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca Object *obedit= CTX_data_edit_object(C); float size, min[3], max[3], afm[3]; int ok=0, ok_dist=1; + const short skip_camera= ((rv3d->persp==RV3D_CAMOB) && (v3d->flag2 & V3D_LOCK_CAMERA)); /* SMOOTHVIEW */ float new_ofs[3]; @@ -1724,17 +1769,20 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca ok= PE_minmax(scene, min, max); } else { - Base *base= FIRSTBASE; - while(base) { + Base *base; + for(base= FIRSTBASE; base; base = base->next) { if(TESTBASE(v3d, base)) { + if(skip_camera && base->object == v3d->camera) { + continue; + } + /* account for duplis */ if (minmax_object_duplis(scene, base->object, min, max)==0) minmax_object(base->object, min, max); /* use if duplis not found */ ok= 1; } - base= base->next; } } @@ -1770,7 +1818,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca new_dist*= size; } - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp==RV3D_CAMOB && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->persp= RV3D_PERSP; smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } @@ -1838,10 +1886,23 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot) static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */ { + ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); + Scene *scene= CTX_data_scene(C); + float xfac, yfac; + float size[2]; rv3d->camdx= rv3d->camdy= 0.0f; + view3d_viewborder_size_get(scene, ar, size); + + /* 4px is just a little room from the edge of the area */ + xfac= (float)ar->winx / (float)(size[0] + 4); + yfac= (float)ar->winy / (float)(size[1] + 4); + + rv3d->camzoom= (sqrtf(4.0f * MIN2(xfac, yfac)) - (float)M_SQRT2) * 50.0f; + rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; @@ -2053,10 +2114,11 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, wmEvent *event) { + View3D *v3d= CTX_wm_view3d(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); /* if in camera view do not exec the operator so we do not conflict with set render border*/ - if (rv3d->persp != RV3D_CAMOB) + if ((rv3d->persp != RV3D_CAMOB) || (v3d->flag2 & V3D_LOCK_CAMERA)) return WM_border_select_invoke(C, op, event); else return OPERATOR_PASS_THROUGH; @@ -2169,7 +2231,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float q1, float invert_qt(obact_quat); mul_qt_qtqt(new_quat, new_quat, obact_quat); - rv3d->view= view= 0; + rv3d->view= view= RV3D_VIEW_USER; } } @@ -2361,6 +2423,7 @@ static EnumPropertyItem prop_view_orbit_items[] = { static int vieworbit_exec(bContext *C, wmOperator *op) { + View3D *v3d= CTX_wm_view3d(C); ARegion *ar= ED_view3d_context_region_unlock(C); RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ float phi, q1[4], new_quat[4]; @@ -2369,8 +2432,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) orbitdir = RNA_enum_get(op->ptr, "type"); if(rv3d->viewlock==0) { - - if(rv3d->persp != RV3D_CAMOB) { + if((rv3d->persp != RV3D_CAMOB) || (v3d->flag2 & V3D_LOCK_CAMERA)) { if(orbitdir == V3D_VIEW_STEPLEFT || orbitdir == V3D_VIEW_STEPRIGHT) { float si; /* z-axis */ @@ -2381,7 +2443,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) q1[1]= q1[2]= 0.0; q1[3]= si; mul_qt_qtqt(new_quat, rv3d->viewquat, q1); - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; } else if(orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) { /* horizontal axis */ @@ -2393,7 +2455,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) q1[0]= (float)cos(phi); mul_v3_fl(q1+1, sin(phi)); mul_qt_qtqt(new_quat, rv3d->viewquat, q1); - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; } smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, new_quat, NULL, NULL); @@ -2733,7 +2795,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3]; - short mx, my, mval[2]; + int mx, my, mval[2]; // short ctrl= 0; // XXX int flip; fp= give_cursor(scene, v3d); @@ -2744,7 +2806,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve mx= event->x - ar->winrct.xmin; my= event->y - ar->winrct.ymin; - project_short_noclip(ar, fp, mval); + project_int_noclip(ar, fp, mval); flip= initgrabz(rv3d, fp[0], fp[1], fp[2]); /* reset the depth based on the view offset */ @@ -2752,7 +2814,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve negate_v3_v3(fp, rv3d->ofs); /* re initialize */ - project_short_noclip(ar, fp, mval); + project_int_noclip(ar, fp, mval); flip= initgrabz(rv3d, fp[0], fp[1], fp[2]); } @@ -2760,7 +2822,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve short depth_used = 0; if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ - short mval_depth[2]; + int mval_depth[2]; mval_depth[0]= mx; mval_depth[1]= my; view3d_operator_needs_opengl(C); @@ -2891,7 +2953,7 @@ void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) /* ************************* below the line! *********************** */ -static float view_autodist_depth_margin(ARegion *ar, const short mval[2], int margin) +static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int margin) { ViewDepths depth_temp= {0}; rcti rect; @@ -2919,7 +2981,7 @@ static float view_autodist_depth_margin(ARegion *ar, const short mval[2], int ma } /* XXX todo Zooms in on a border drawn by the user */ -int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const short mval[2], float mouse_worldloc[3] ) //, float *autodist ) +int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist ) { bglMats mats; /* ZBuffer depth vars */ float depth_close= FLT_MAX; @@ -2962,7 +3024,7 @@ int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, flo } // no 4x4 sampling, run view_autodist_init first -int view_autodist_simple(ARegion *ar, const short mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist ) +int view_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist ) { bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; @@ -2990,7 +3052,7 @@ int view_autodist_simple(ARegion *ar, const short mval[2], float mouse_worldloc[ return 1; } -int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, float *depth) +int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth) { *depth= view_autodist_depth_margin(ar, mval, margin); @@ -3000,11 +3062,11 @@ int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, flo static int depth_segment_cb(int x, int y, void *userData) { struct { struct ARegion *ar; int margin; float depth; } *data = userData; - short mval[2]; + int mval[2]; float depth; - mval[0]= (short)x; - mval[1]= (short)y; + mval[0]= x; + mval[1]= y; depth= view_autodist_depth_margin(data->ar, mval, data->margin); @@ -3017,7 +3079,7 @@ static int depth_segment_cb(int x, int y, void *userData) } } -int view_autodist_depth_segment(struct ARegion *ar, const short mval_sta[2], const short mval_end[2], int margin, float *depth) +int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth) { struct { struct ARegion *ar; int margin; float depth; } data = {NULL}; int p1[2]; @@ -3446,3 +3508,62 @@ void view3d_persp_mat4(RegionView3D *rv3d, float mat[][4]) mul_v3_v3fl(dvec, mat[2], -rv3d->dist); sub_v3_v3v3(mat[3], dvec, rv3d->ofs); } + + +/* Gets the view trasnformation from a camera +* currently dosnt take camzoom into account +* +* The dist is not modified for this function, if NULL its assimed zero +* */ +void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) +{ + /* Offset */ + if (ofs) + negate_v3_v3(ofs, mat[3]); + + /* Quat */ + if (quat) { + float imat[4][4]; + invert_m4_m4(imat, mat); + mat4_to_quat(quat, imat); + } + + if (dist) { + float nmat[3][3]; + float vec[3]; + + vec[0]= 0.0f; + vec[1]= 0.0f; + vec[2]= -(*dist); + + copy_m3_m4(nmat, mat); + normalize_m3(nmat); + + mul_m3_v3(nmat, vec);; + sub_v3_v3(ofs, vec); + } +} + + +/* object -> view */ +void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens) +{ + ED_view3d_from_m4(ob->obmat, ofs, quat, dist); + + if (lens) { + get_object_clip_range(ob, lens, NULL, NULL); + } +} + +/* view -> object */ +void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist) +{ + float mat4[4][4]; + float dvec[3]= {0.0f, 0.0f, dist}; + float iviewquat[4]= {-quat[0], quat[1], quat[2], quat[3]}; + + quat_to_mat4(mat4, iviewquat); + mul_mat3_m4_v3(mat4, dvec); + sub_v3_v3v3(mat4[3], dvec, ofs); + object_apply_mat4(ob, mat4, TRUE, TRUE); +} diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 32deee50fb2..e37361fbc54 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -158,7 +158,7 @@ typedef struct FlyInfo { short state; short use_precision; short redraw; - short mval[2]; + int mval[2]; /* fly state state */ float speed; /* the speed the view is moving per redraw */ diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index aad9c1dd3ff..fce23df3810 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -522,9 +522,9 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) block= uiLayoutGetBlock(row); if(v3d->twflag & V3D_USE_MANIPULATOR) { - uiDefIconButBitS(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode"); - uiDefIconButBitS(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode"); - uiDefIconButBitS(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode"); + uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode"); + uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode"); + uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode"); } if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) { @@ -532,7 +532,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } str_menu = BIF_menustringTransformOrientation(C, "Orientation"); - uiDefButS(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); + uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); MEM_freeN((void *)str_menu); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f51a780787e..c4999b961f0 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -93,15 +93,15 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit= CTX_data_edit_object(C); } -int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const short mval[2], const short do_fallback) +int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int mval[2], const short do_fallback) { float dvec[3]; - short mval_cpy[2]; + int mval_cpy[2]; mval_cpy[0]= mval[0]; mval_cpy[1]= mval[1]; - project_short_noclip(vc->ar, fp, mval_cpy); + project_int_noclip(vc->ar, fp, mval_cpy); initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); @@ -274,12 +274,12 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) #define MOVES_GESTURE 50 #define MOVES_LASSO 500 -int lasso_inside(short mcords[][2], short moves, short sx, short sy) +int lasso_inside(int mcords[][2], short moves, int sx, int sy) { /* we do the angle rule, define that all added angles should be about zero or 2*PI */ float angletot=0.0, len, dot, ang, cross, fp1[2], fp2[2]; int a; - short *p1, *p2; + int *p1, *p2; if(sx==IS_CLIPPED) return 0; @@ -322,9 +322,9 @@ int lasso_inside(short mcords[][2], short moves, short sx, short sy) } /* edge version for lasso select. we assume boundbox check was done */ -int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1) +int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int y1) { - short v1[2], v2[2]; + int v1[2], v2[2]; int a; if(x0==IS_CLIPPED || x1==IS_CLIPPED) @@ -339,9 +339,9 @@ int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, in /* no points in lasso, so we have to intersect with lasso edge */ - if( isect_line_line_v2_short(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; + if( isect_line_line_v2_int(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; for(a=0; a<moves-1; a++) { - if( isect_line_line_v2_short(mcords[a], mcords[a+1], v1, v2) > 0) return 1; + if( isect_line_line_v2_int(mcords[a], mcords[a+1], v1, v2) > 0) return 1; } return 0; @@ -351,11 +351,11 @@ int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, in /* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK */ -static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2], short moves, short select) +static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], short moves, short select) { bPoseChannel *pchan; float vec[3]; - short sco1[2], sco2[2]; + int sco1[2], sco2[2]; bArmature *arm= ob->data; if(ob->type!=OB_ARMATURE || ob->pose==NULL) return; @@ -363,9 +363,9 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2], for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) { mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); - project_short(vc->ar, vec, sco1); + project_int(vc->ar, vec, sco1); mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); - project_short(vc->ar, vec, sco2); + project_int(vc->ar, vec, sco2); if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { if(select) pchan->bone->flag |= BONE_SELECTED; @@ -386,7 +386,7 @@ static void object_deselect_all_visible(Scene *scene, View3D *v3d) } } -static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { Base *base; @@ -409,7 +409,7 @@ static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short mo } } -static void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves) +static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves) { short a; @@ -426,7 +426,7 @@ static void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves) static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { eve->f = data->select?(eve->f|1):(eve->f&~1); @@ -434,7 +434,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, in } static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; if (EM_check_backbuf(em_solidoffs+index)) { if (data->pass==0) { @@ -453,16 +453,16 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, in } static void do_lasso_select_mesh__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { EM_select_face_fgon(data->vc.em, efa, data->select); } } -static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } data; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } data; ToolSettings *ts= vc->scene->toolsettings; rcti rect; int bbsel; @@ -528,7 +528,7 @@ static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves #if 0 /* this is an exception in that its the only lasso that dosnt use the 3d view (uses space image view) */ -static void do_lasso_select_mesh_uv(short mcords[][2], short moves, short select) +static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) { EditFace *efa; MTFace *tf; @@ -585,7 +585,7 @@ static void do_lasso_select_mesh_uv(short mcords[][2], short moves, short select static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } *data = userData; + struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } *data = userData; Object *obedit= data->vc->obedit; Curve *cu= (Curve*)obedit->data; @@ -612,9 +612,9 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP } } -static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } data; + struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } data; /* set vc->editnurb */ data.vc = vc; @@ -631,15 +631,15 @@ static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short move static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, int y) { - struct { short (*mcords)[2]; short moves; short select; } *data = userData; + struct { int (*mcords)[2]; short moves; short select; } *data = userData; if (lasso_inside(data->mcords, data->moves, x, y)) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); } } -static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { short (*mcords)[2]; short moves; short select; } data; + struct { int (*mcords)[2]; short moves; short select; } data; /* set editdata in vc */ data.mcords = mcords; @@ -653,7 +653,7 @@ static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short mo lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data); } -static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { bArmature *arm= vc->obedit->data; EditBone *ebone; @@ -705,7 +705,7 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m -static void do_lasso_select_meta(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { MetaBall *mb = (MetaBall*)vc->obedit->data; MetaElem *ml; @@ -730,7 +730,7 @@ static void do_lasso_select_meta(ViewContext *vc, short mcords[][2], short moves } } -static void do_lasso_select_paintface(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { Object *ob= vc->obact; Mesh *me= ob?ob->data:NULL; @@ -755,7 +755,7 @@ static void do_lasso_select_paintface(ViewContext *vc, short mcords[][2], short } #if 0 -static void do_lasso_select_node(short mcords[][2], short moves, short select) +static void do_lasso_select_node(int mcords[][2], short moves, short select) { SpaceNode *snode = sa->spacedata.first; @@ -785,7 +785,7 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select) } #endif -static void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void view3d_lasso_select(bContext *C, ViewContext *vc, int mcords[][2], short moves, short extend, short select) { Object *ob = CTX_data_active_object(C); @@ -834,14 +834,14 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) { ViewContext vc; int i= 0; - short mcords[1024][2]; + int mcords[1024][2]; RNA_BEGIN(op->ptr, itemptr, "path") { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); - mcords[i][0]= (short)loc[0]; - mcords[i][1]= (short)loc[1]; + mcords[i][0]= (int)loc[0]; + mcords[i][1]= (int)loc[1]; i++; if(i>=1024) break; } @@ -953,7 +953,7 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b } } -static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, const short mval[2], short extend) +static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], short extend) { short baseCount = 0; short ok; @@ -1039,7 +1039,7 @@ static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffe /* we want a select buffer with bones, if there are... */ /* so check three selection levels and compare */ -static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, const short mval[2]) +static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, const int mval[2]) { rcti rect; int offs; @@ -1096,12 +1096,12 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff } /* returns basact */ -static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const short mval[2], Base *startbase, int has_bones) +static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], Base *startbase, int has_bones) { Scene *scene= vc->scene; View3D *v3d= vc->v3d; Base *base, *basact= NULL; - static short lastmval[2]={-100, -100}; + static int lastmval[2]={-100, -100}; int a, donearest= 0; /* define if we use solid nearest select or not */ @@ -1189,7 +1189,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int } /* mval comes from event->mval, only use within region handlers */ -Base *ED_view3d_give_base_under_cursor(bContext *C, const short mval[2]) +Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) { ViewContext vc; Base *basact= NULL; @@ -1214,7 +1214,7 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const short mval[2]) } /* mval is region coords */ -static int mouse_select(bContext *C, const short mval[2], short extend, short obcenter, short enumerate) +static int mouse_select(bContext *C, const int mval[2], short extend, short obcenter, short enumerate) { ViewContext vc; ARegion *ar= CTX_wm_region(C); @@ -1905,7 +1905,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -1915,7 +1915,7 @@ static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y } static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index)) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; if (edge_inside_circle(data->mval[0], data->mval[1], (short) data->radius, x0, y0, x1, y1)) { EM_select_edge(eed, data->select); @@ -1923,7 +1923,7 @@ static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int } static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -1932,11 +1932,11 @@ static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y } } -static void mesh_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { ToolSettings *ts= vc->scene->toolsettings; int bbsel; - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -1977,7 +1977,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const short mval[2], EM_selectmode_flush(vc->em); } -static void paint_facesel_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void paint_facesel_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { Object *ob= vc->obact; Mesh *me = ob?ob->data:NULL; @@ -1995,7 +1995,7 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, const short static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); Object *obedit= data->vc->obedit; @@ -2024,9 +2024,9 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint } } } -static void nurbscurve_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; /* set vc-> edit data */ @@ -2043,7 +2043,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const short mv static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2051,9 +2051,9 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); } } -static void lattice_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void lattice_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; /* set vc-> edit data */ @@ -2070,7 +2070,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const short mval[ // NOTE: pose-bone case is copied from editbone case... static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2083,9 +2083,9 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int } return 0; } -static void pose_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; int change= FALSE; @@ -2130,7 +2130,7 @@ static void pose_circle_select(ViewContext *vc, int select, const short mval[2], static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2151,7 +2151,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int } return 0; } -static void armature_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { struct {ViewContext *vc; short select, mval[2]; float radius; } data; bArmature *arm= vc->obedit->data; @@ -2210,7 +2210,7 @@ static void armature_circle_select(ViewContext *vc, int select, const short mval /** Callbacks for circle selection in Editmode */ -static void obedit_circle_select(ViewContext *vc, short select, const short mval[2], float rad) +static void obedit_circle_select(ViewContext *vc, short select, const int mval[2], float rad) { switch(vc->obedit->type) { case OB_MESH: @@ -2251,7 +2251,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT|OB_MODE_POSE))) ) { ViewContext vc; - short mval[2]; + int mval[2]; view3d_operator_needs_opengl(C); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index a3d42aa5579..b4d2fc22143 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -70,6 +70,7 @@ #include "view3d_intern.h" +extern float originmat[3][3]; /* XXX object.c */ /* ************************************************** */ /* ********************* old transform stuff ******** */ @@ -451,7 +452,6 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) { - extern float originmat[3][3]; /* XXX object.c */ Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); @@ -588,7 +588,6 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) { - extern float originmat[3][3]; /* XXX object.c */ Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b46c7236170..6e2e1898fb4 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -32,9 +32,9 @@ #include "DNA_camera_types.h" -#include "DNA_lamp_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "DNA_lamp_types.h" #include "MEM_guardedalloc.h" @@ -105,7 +105,7 @@ float *give_cursor(Scene *scene, View3D *v3d) /* Gets the lens and clipping values from a camera of lamp type object */ -static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, float *clipend) +void get_object_clip_range(Object *ob, float *lens, float *clipsta, float *clipend) { if(ob->type==OB_LAMP ) { Lamp *la = ob->data; @@ -129,51 +129,6 @@ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, f } } - -/* Gets the view trasnformation from a camera -* currently dosnt take camzoom into account -* -* The dist is not modified for this function, if NULL its assimed zero -* */ -void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist) -{ - /* Offset */ - if (ofs) - negate_v3_v3(ofs, mat[3]); - - /* Quat */ - if (quat) { - float imat[4][4]; - invert_m4_m4(imat, mat); - mat4_to_quat(quat, imat); - } - - if (dist) { - float nmat[3][3]; - float vec[3]; - - vec[0]= 0.0f; - vec[1]= 0.0f; - vec[2]= -(*dist); - - copy_m3_m4(nmat, mat); - normalize_m3(nmat); - - mul_m3_v3(nmat, vec);; - sub_v3_v3(ofs, vec); - } -} - -void view3d_apply_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens) -{ - view3d_apply_mat4(ob->obmat, ofs, quat, dist); - - if (lens) { - object_lens_clip_settings(ob, lens, NULL, NULL); - } -} - - /* ****************** smooth view operator ****************** */ /* This operator is one of the 'timer refresh' ones like animation playback */ @@ -206,7 +161,19 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec sms.new_dist= rv3d->dist; sms.new_lens= v3d->lens; sms.to_camera= 0; - + + /* note on camera locking, this is a little confusing but works ok. + * we may be changing the view 'as if' there is no active camera, but infact + * there is an active camera which is locked to the view. + * + * In the case where smooth view is moving _to_ a camera we dont want that + * camera to be moved or changed, so only when the camera is not being set should + * we allow camera option locking to initialize the view settings from the camera. + */ + if(camera == NULL && oldcamera == NULL) { + ED_view3d_camera_lock_init(v3d, rv3d); + } + /* store the options we want to end with */ if(ofs) copy_v3_v3(sms.new_ofs, ofs); if(quat) copy_qt_qt(sms.new_quat, quat); @@ -214,7 +181,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec if(lens) sms.new_lens= *lens; if (camera) { - view3d_apply_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); + ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); sms.to_camera= 1; /* restore view3d values in end */ } @@ -239,7 +206,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* original values */ if (oldcamera) { sms.orig_dist= rv3d->dist; // below function does weird stuff with it... - view3d_apply_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); + ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { copy_v3_v3(sms.orig_ofs, rv3d->ofs); @@ -251,7 +218,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec if((rv3d->viewlock & RV3D_LOCKED)==0) { /* use existing if exists, means multiple calls to smooth view wont loose the original 'view' setting */ sms.orig_view= rv3d->sms ? rv3d->sms->orig_view : rv3d->view; - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; } sms.time_allowed= (double)U.smooth_viewtx / 1000.0; @@ -341,6 +308,8 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent copy_qt_qt(rv3d->viewquat, sms->new_quat); rv3d->dist = sms->new_dist; v3d->lens = sms->new_lens; + + ED_view3d_camera_lock_sync(v3d, rv3d); } if((rv3d->viewlock & RV3D_LOCKED)==0) { @@ -370,6 +339,8 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent rv3d->dist = sms->new_dist * step + sms->orig_dist*step_inv; v3d->lens = sms->new_lens * step + sms->orig_lens*step_inv; + + ED_view3d_camera_lock_sync(v3d, rv3d); } if(rv3d->viewlock & RV3D_BOXVIEW) @@ -396,25 +367,6 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) /* ****************** change view operators ****************** */ -static void setcameratoview3d(RegionView3D *rv3d, Object *ob) -{ - float dvec[3]; - float mat3[3][3]; - - mul_v3_v3fl(dvec, rv3d->viewinv[2], rv3d->dist); - sub_v3_v3v3(ob->loc, dvec, rv3d->ofs); - rv3d->viewquat[0]= -rv3d->viewquat[0]; - - // quat_to_eul( ob->rot,rv3d->viewquat); // in 2.4x for xyz eulers only - quat_to_mat3(mat3, rv3d->viewquat); - object_mat3_to_rot(ob, mat3, 0); - - rv3d->viewquat[0]= -rv3d->viewquat[0]; - - ob->recalc= OB_RECALC_OB; -} - - static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); @@ -426,7 +378,7 @@ static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op)) rv3d->lpersp= rv3d->persp; } - setcameratoview3d(rv3d, v3d->camera); + ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; @@ -555,7 +507,7 @@ void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float float vec[4]; int a; - if(!get_view3d_ortho(v3d, rv3d)) { + if(rv3d->is_persp) { vec[0]= 2.0f * mval[0] / ar->winx - 1; vec[1]= 2.0f * mval[1] / ar->winy - 1; vec[2]= -1.0f; @@ -646,26 +598,42 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z) return flip; } -/* always call initgrabz */ -void window_to_3d(ARegion *ar, float out[3], short mx, short my) +void window_to_3d(ARegion *ar, float out[3], const float depth_pt[3], const int mx, const int my) { RegionView3D *rv3d= ar->regiondata; - float dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2); - float dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2); - - float fz= rv3d->persmat[0][3]*out[0]+ rv3d->persmat[1][3]*out[1]+ rv3d->persmat[2][3]*out[2]+ rv3d->persmat[3][3]; - fz= fz/rv3d->zfac; - - out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0]; - out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1]; - out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2]; - + float line_sta[3]; + float line_end[3]; + + if(rv3d->is_persp) { + float mousevec[3]; + float view_z[3]; + float pt_mid[3]; + + window_to_3d_vector(ar, mousevec, mx, my); + + copy_v3_v3(line_sta, rv3d->viewinv[3]); + normalize_v3_v3(view_z, rv3d->viewinv[2]); + add_v3_v3v3(line_end, line_sta, view_z); + closest_to_line_v3(pt_mid, depth_pt, line_sta, line_end); + mul_v3_fl(mousevec, shell_angle_to_dist(angle_normalized_v3v3(view_z, mousevec)) * len_v3v3(line_sta, pt_mid)); + add_v3_v3v3(out, line_sta, mousevec); + } + else { + const float dx= (2.0f * (float)mx / (float)ar->winx) - 1.0f; + const float dy= (2.0f * (float)my / (float)ar->winy) - 1.0f; + line_sta[0]= (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0]; + line_sta[1]= (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1]; + line_sta[2]= (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2]; + + add_v3_v3v3(line_end, line_sta, rv3d->viewinv[2]); + closest_to_line_v3(out, depth_pt, line_sta, line_end); + } } /* always call initgrabz */ /* only to detect delta motion */ -void window_to_3d_delta(ARegion *ar, float out[3], short mx, short my) +void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my) { RegionView3D *rv3d= ar->regiondata; float dx, dy; @@ -681,22 +649,27 @@ void window_to_3d_delta(ARegion *ar, float out[3], short mx, short my) /* doesn't rely on initgrabz */ /* for perspective view, get the vector direction to * the mouse cursor as a normalized vector */ -void window_to_3d_vector(ARegion *ar, float out[3], short mx, short my) +void window_to_3d_vector(ARegion *ar, float out[3], const int mx, const int my) { RegionView3D *rv3d= ar->regiondata; - float dx, dy; - float viewvec[3]; - dx= 2.0f*mx/ar->winx; - dy= 2.0f*my/ar->winy; + if(rv3d->is_persp) { + float dx, dy; + float viewvec[3]; - /* normalize here so vecs are proportional to eachother */ - normalize_v3_v3(viewvec, rv3d->viewinv[2]); + dx= (2.0f * mx / ar->winx) - 1.0f; + dy= (2.0f * my / ar->winy) - 1.0f; - out[0]= viewvec[0] - (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); - out[1]= viewvec[1] - (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); - out[2]= viewvec[2] - (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); + /* normalize here so vecs are proportional to eachother */ + normalize_v3_v3(viewvec, rv3d->viewinv[2]); + out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy) - viewvec[0]; + out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy) - viewvec[1]; + out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy) - viewvec[2]; + } + else { + copy_v3_v3(out, rv3d->viewinv[2]); + } normalize_v3(out); } @@ -938,29 +911,6 @@ void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) } } -int get_view3d_ortho(View3D *v3d, RegionView3D *rv3d) -{ - Camera *cam; - - if(rv3d->persp==RV3D_CAMOB) { - if(v3d->camera && v3d->camera->type==OB_CAMERA) { - cam= v3d->camera->data; - - if(cam && cam->type==CAM_ORTHO) - return 1; - else - return 0; - } - else - return 0; - } - - if(rv3d->persp==RV3D_ORTHO) - return 1; - - return 0; -} - /* copies logic of get_view3d_viewplane(), keep in sync */ int get_view3d_cliprange(View3D *v3d, RegionView3D *rv3d, float *clipsta, float *clipend) { @@ -1130,6 +1080,8 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick int orth; orth= get_view3d_viewplane(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); + rv3d->is_persp= !orth; + // printf("%d %d %f %f %f %f %f %f\n", winx, winy, viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax, clipsta, clipend); x1= viewplane.xmin; y1= viewplane.ymin; @@ -1164,7 +1116,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short float bmat[4][4]; float tmat[3][3]; - rv3d->view= 0; /* dont show the grid */ + rv3d->view= RV3D_VIEW_USER; /* dont show the grid */ copy_m4_m4(bmat, ob->obmat); normalize_m4(bmat); @@ -1188,7 +1140,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->persp=RV3D_PERSP; rv3d->dist= 0.0; - view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ @@ -1917,7 +1869,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f cross_v3_v3v3(axis, alignaxis, norm); axis_angle_to_quat( new_quat,axis, -angle); - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; if (rv3d->persp==RV3D_CAMOB && v3d->camera) { /* switch out of camera view */ @@ -1928,7 +1880,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f copy_v3_v3(orig_ofs, rv3d->ofs); rv3d->persp= RV3D_PERSP; rv3d->dist= 0.0; - view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX } else { if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; /* switch out of camera mode */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b7095df1599..96c78f4b632 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -120,7 +120,7 @@ void setTransformViewMatrices(TransInfo *t) calculateCenter2D(t); } -void convertViewVec(TransInfo *t, float *vec, short dx, short dy) +void convertViewVec(TransInfo *t, float *vec, int dx, int dy) { if (t->spacetype==SPACE_VIEW3D) { if (t->ar->regiontype == RGN_TYPE_WINDOW) @@ -780,7 +780,7 @@ int transformEvent(TransInfo *t, wmEvent *event) case SPACEKEY: if ((t->spacetype==SPACE_VIEW3D) && event->alt) { #if 0 // TRANSFORM_FIX_ME - short mval[2]; + int mval[2]; getmouseco_sc(mval); BIF_selectOrientation(); @@ -1267,7 +1267,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) setlinestyle(3); glBegin(GL_LINE_STRIP); - glVertex2sv(t->mval); + glVertex2iv(t->mval); glVertex2fv(cent); glEnd(); @@ -1312,7 +1312,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) setlinestyle(3); glBegin(GL_LINE_STRIP); - glVertex2sv(t->mval); + glVertex2iv(t->mval); glVertex2fv(cent); glEnd(); @@ -2286,7 +2286,7 @@ int handleEventWarp(TransInfo *t, wmEvent *event) return status; } -int Warp(TransInfo *t, const short UNUSED(mval[2])) +int Warp(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3]; @@ -2434,7 +2434,7 @@ int handleEventShear(TransInfo *t, wmEvent *event) } -int Shear(TransInfo *t, const short UNUSED(mval[2])) +int Shear(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3]; @@ -2700,7 +2700,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { constraintTransLim(t, td); } -int Resize(TransInfo *t, const short mval[2]) +int Resize(TransInfo *t, const int mval[2]) { TransData *td; float size[3], mat[3][3]; @@ -2805,7 +2805,7 @@ void initToSphere(TransInfo *t) t->val /= (float)t->total; } -int ToSphere(TransInfo *t, const short UNUSED(mval[2])) +int ToSphere(TransInfo *t, const int UNUSED(mval[2])) { float vec[3]; float ratio, radius; @@ -3152,7 +3152,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) } } -int Rotation(TransInfo *t, const short UNUSED(mval[2])) +int Rotation(TransInfo *t, const int UNUSED(mval[2])) { char str[128], *spos= str; @@ -3260,7 +3260,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a } } -int Trackball(TransInfo *t, const short UNUSED(mval[2])) +int Trackball(TransInfo *t, const int UNUSED(mval[2])) { char str[128], *spos= str; float axis1[3], axis2[3]; @@ -3490,7 +3490,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) { } /* uses t->vec to store actual translation in */ -int Translation(TransInfo *t, const short UNUSED(mval[2])) +int Translation(TransInfo *t, const int UNUSED(mval[2])) { char str[250]; @@ -3557,7 +3557,7 @@ void initShrinkFatten(TransInfo *t) -int ShrinkFatten(TransInfo *t, const short UNUSED(mval[2])) +int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { float vec[3]; float distance; @@ -3632,7 +3632,7 @@ void initTilt(TransInfo *t) -int Tilt(TransInfo *t, const short UNUSED(mval[2])) +int Tilt(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -3704,7 +3704,7 @@ void initCurveShrinkFatten(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -int CurveShrinkFatten(TransInfo *t, const short UNUSED(mval[2])) +int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -3772,7 +3772,7 @@ void initPushPull(TransInfo *t) } -int PushPull(TransInfo *t, const short UNUSED(mval[2])) +int PushPull(TransInfo *t, const int UNUSED(mval[2])) { float vec[3], axis[3]; float distance; @@ -3905,7 +3905,7 @@ int handleEventBevel(TransInfo *t, wmEvent *event) return 0; } -int Bevel(TransInfo *t, const short UNUSED(mval[2])) +int Bevel(TransInfo *t, const int UNUSED(mval[2])) { float distance,d; int i; @@ -3973,7 +3973,7 @@ void initBevelWeight(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BevelWeight(TransInfo *t, const short UNUSED(mval[2])) +int BevelWeight(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float weight; @@ -4046,7 +4046,7 @@ void initCrease(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int Crease(TransInfo *t, const short UNUSED(mval[2])) +int Crease(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float crease; @@ -4165,7 +4165,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) td->loc[1]= oldy; } -int BoneSize(TransInfo *t, const short mval[2]) +int BoneSize(TransInfo *t, const int mval[2]) { TransData *td = t->data; float size[3], mat[3][3]; @@ -4241,7 +4241,7 @@ void initBoneEnvelope(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BoneEnvelope(TransInfo *t, const short UNUSED(mval[2])) +int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -4672,10 +4672,10 @@ static int createSlideVerts(TransInfo *t) #undef EDGE_SLIDE_MIN - sld->start[0] = (short) start[0]; - sld->start[1] = (short) start[1]; - sld->end[0] = (short) end[0]; - sld->end[1] = (short) end[1]; + sld->start[0] = (int) start[0]; + sld->start[1] = (int) start[1]; + sld->end[0] = (int) end[0]; + sld->end[1] = (int) end[1]; if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) { int maxnum = 0; @@ -4975,7 +4975,7 @@ int doEdgeSlide(TransInfo *t, float perc) return 1; } -int EdgeSlide(TransInfo *t, const short UNUSED(mval[2])) +int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[50]; float final; @@ -5034,7 +5034,7 @@ void initBoneRoll(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BoneRoll(TransInfo *t, const short UNUSED(mval[2])) +int BoneRoll(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -5095,7 +5095,7 @@ void initBakeTime(TransInfo *t) t->num.increment = t->snap[1]; } -int BakeTime(TransInfo *t, const short mval[2]) +int BakeTime(TransInfo *t, const int mval[2]) { TransData *td = t->data; float time; @@ -5170,7 +5170,7 @@ void initMirror(TransInfo *t) } } -int Mirror(TransInfo *t, const short UNUSED(mval[2])) +int Mirror(TransInfo *t, const int UNUSED(mval[2])) { TransData *td; float size[3], mat[3][3]; @@ -5247,7 +5247,7 @@ void initAlign(TransInfo *t) initMouseInputMode(t, &t->mouse, INPUT_NONE); } -int Align(TransInfo *t, const short UNUSED(mval[2])) +int Align(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float center[3]; @@ -5350,7 +5350,7 @@ static void applySeqSlide(TransInfo *t, float val[2]) { } } -int SeqSlide(TransInfo *t, const short UNUSED(mval[2])) +int SeqSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[200]; @@ -5640,7 +5640,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval)) } } -int TimeTranslate(TransInfo *t, const short mval[2]) +int TimeTranslate(TransInfo *t, const int mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -5770,7 +5770,7 @@ static void applyTimeSlide(TransInfo *t, float sval) } } -int TimeSlide(TransInfo *t, const short mval[2]) +int TimeSlide(TransInfo *t, const int mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -5895,7 +5895,7 @@ static void applyTimeScale(TransInfo *t) { } } -int TimeScale(TransInfo *t, const short UNUSED(mval[2])) +int TimeScale(TransInfo *t, const int UNUSED(mval[2])) { char str[200]; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b94f2cc525a..b55435fd0cf 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -119,7 +119,7 @@ typedef struct TransCon { float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */ float center[3]; /* transformation center to define where to draw the view widget ALWAYS in global space. Unlike the transformation center */ - short imval[2]; /* initial mouse value for visual calculation */ + int imval[2]; /* initial mouse value for visual calculation */ /* the one in TransInfo is not garanty to stay the same (Rotates change it) */ int mode; /* Mode flags of the Constraint */ void (*drawExtra)(struct TransInfo *); @@ -217,7 +217,7 @@ typedef struct SlideData { struct GHash *vhash, **uvhash; struct EditVert *nearest; struct LinkNode *edgelist, *vertlist; - short start[2], end[2]; + int start[2], end[2]; } SlideData; typedef struct TransData { @@ -242,12 +242,12 @@ typedef struct TransData { } TransData; typedef struct MouseInput { - void (*apply)(struct TransInfo *, struct MouseInput *, const short [2], float [3]); + void (*apply)(struct TransInfo *, struct MouseInput *, const int [2], float [3]); void (*post)(struct TransInfo *, float [3]); - short imval[2]; /* initial mouse position */ + int imval[2]; /* initial mouse position */ char precision; - short precision_mval[2]; /* mouse position when precision key was pressed */ + int precision_mval[2]; /* mouse position when precision key was pressed */ int center[2]; float factor; void *data; /* additional data, if needed by the particular function */ @@ -261,7 +261,7 @@ typedef struct TransInfo { int options; /* current context/options for transform */ float val; /* init value for some transformations (and rotation angle) */ float fac; /* factor for distance based transform */ - int (*transform)(struct TransInfo *, const short *); + int (*transform)(struct TransInfo *, const int *); /* transform function pointer */ int (*handleEvent)(struct TransInfo *, struct wmEvent *); /* event handler function pointer RETURN 1 if redraw is needed */ @@ -279,7 +279,7 @@ typedef struct TransInfo { char proptext[20]; /* proportional falloff text */ float center[3]; /* center of transformation */ int center2d[2]; /* center in screen coordinates */ - short imval[2]; /* initial mouse position */ + int imval[2]; /* initial mouse position */ short event_type; /* event->type used to invoke transform */ short idx_max; /* maximum index on the input vector */ float snap[3]; /* Snapping Gears */ @@ -328,7 +328,7 @@ typedef struct TransInfo { struct Scene *scene; struct ToolSettings *settings; struct wmTimer *animtimer; - short mval[2]; /* current mouse position */ + int mval[2]; /* current mouse position */ struct Object *obedit; void *draw_handle_apply; void *draw_handle_view; @@ -458,7 +458,7 @@ void transformApply(struct bContext *C, TransInfo *t); int transformEnd(struct bContext *C, TransInfo *t); void setTransformViewMatrices(TransInfo *t); -void convertViewVec(TransInfo *t, float *vec, short dx, short dy); +void convertViewVec(TransInfo *t, float *vec, int dx, int dy); void projectIntView(TransInfo *t, float *vec, int *adr); void projectFloatView(TransInfo *t, float *vec, float *adr); @@ -467,81 +467,81 @@ void removeAspectRatio(TransInfo *t, float *vec); void initWarp(TransInfo *t); int handleEventWarp(TransInfo *t, struct wmEvent *event); -int Warp(TransInfo *t, const short mval[2]); +int Warp(TransInfo *t, const int mval[2]); void initShear(TransInfo *t); int handleEventShear(TransInfo *t, struct wmEvent *event); -int Shear(TransInfo *t, const short mval[2]); +int Shear(TransInfo *t, const int mval[2]); void initResize(TransInfo *t); -int Resize(TransInfo *t, const short mval[2]); +int Resize(TransInfo *t, const int mval[2]); void initTranslation(TransInfo *t); -int Translation(TransInfo *t, const short mval[2]); +int Translation(TransInfo *t, const int mval[2]); void initToSphere(TransInfo *t); -int ToSphere(TransInfo *t, const short mval[2]); +int ToSphere(TransInfo *t, const int mval[2]); void initRotation(TransInfo *t); -int Rotation(TransInfo *t, const short mval[2]); +int Rotation(TransInfo *t, const int mval[2]); void initShrinkFatten(TransInfo *t); -int ShrinkFatten(TransInfo *t, const short mval[2]); +int ShrinkFatten(TransInfo *t, const int mval[2]); void initTilt(TransInfo *t); -int Tilt(TransInfo *t, const short mval[2]); +int Tilt(TransInfo *t, const int mval[2]); void initCurveShrinkFatten(TransInfo *t); -int CurveShrinkFatten(TransInfo *t, const short mval[2]); +int CurveShrinkFatten(TransInfo *t, const int mval[2]); void initTrackball(TransInfo *t); -int Trackball(TransInfo *t, const short mval[2]); +int Trackball(TransInfo *t, const int mval[2]); void initPushPull(TransInfo *t); -int PushPull(TransInfo *t, const short mval[2]); +int PushPull(TransInfo *t, const int mval[2]); void initBevel(TransInfo *t); int handleEventBevel(TransInfo *t, struct wmEvent *event); -int Bevel(TransInfo *t, const short mval[2]); +int Bevel(TransInfo *t, const int mval[2]); void initBevelWeight(TransInfo *t); -int BevelWeight(TransInfo *t, const short mval[2]); +int BevelWeight(TransInfo *t, const int mval[2]); void initCrease(TransInfo *t); -int Crease(TransInfo *t, const short mval[2]); +int Crease(TransInfo *t, const int mval[2]); void initBoneSize(TransInfo *t); -int BoneSize(TransInfo *t, const short mval[2]); +int BoneSize(TransInfo *t, const int mval[2]); void initBoneEnvelope(TransInfo *t); -int BoneEnvelope(TransInfo *t, const short mval[2]); +int BoneEnvelope(TransInfo *t, const int mval[2]); void initBoneRoll(TransInfo *t); -int BoneRoll(TransInfo *t, const short mval[2]); +int BoneRoll(TransInfo *t, const int mval[2]); void initEdgeSlide(TransInfo *t); -int EdgeSlide(TransInfo *t, const short mval[2]); +int EdgeSlide(TransInfo *t, const int mval[2]); void initTimeTranslate(TransInfo *t); -int TimeTranslate(TransInfo *t, const short mval[2]); +int TimeTranslate(TransInfo *t, const int mval[2]); void initTimeSlide(TransInfo *t); -int TimeSlide(TransInfo *t, const short mval[2]); +int TimeSlide(TransInfo *t, const int mval[2]); void initTimeScale(TransInfo *t); -int TimeScale(TransInfo *t, const short mval[2]); +int TimeScale(TransInfo *t, const int mval[2]); void initBakeTime(TransInfo *t); -int BakeTime(TransInfo *t, const short mval[2]); +int BakeTime(TransInfo *t, const int mval[2]); void initMirror(TransInfo *t); -int Mirror(TransInfo *t, const short mval[2]); +int Mirror(TransInfo *t, const int mval[2]); void initAlign(TransInfo *t); -int Align(TransInfo *t, const short mval[2]); +int Align(TransInfo *t, const int mval[2]); void initSeqSlide(TransInfo *t); -int SeqSlide(TransInfo *t, const short mval[2]); +int SeqSlide(TransInfo *t, const int mval[2]); void drawPropCircle(const struct bContext *C, TransInfo *t); @@ -645,12 +645,12 @@ typedef enum { INPUT_CUSTOM_RATIO } MouseInputMode; -void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], short mval[2]); +void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], int mval[2]); void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode); int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, struct wmEvent *event); -void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, short mval[2], float output[3]); +void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, int mval[2], float output[3]); -void setCustomPoints(TransInfo *t, MouseInput *mi, short start[2], short end[2]); +void setCustomPoints(TransInfo *t, MouseInput *mi, int start[2], int end[2]); void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3])); /*********************** Generics ********************************/ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 16a943baabe..0ca0812f050 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -665,7 +665,7 @@ void drawConstraint(TransInfo *t) char col2[3] = {255,255,255}; int depth_test_enabled; - convertViewVec(t, vec, (short)(t->mval[0] - t->con.imval[0]), (short)(t->mval[1] - t->con.imval[1])); + convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1])); add_v3_v3(vec, tc->center); drawLine(t, tc->center, tc->mtx[0], 'X', 0); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index fc57bad35b4..8d37b7aeabb 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5323,7 +5323,7 @@ void createTransData(bContext *C, TransInfo *t) sort_trans_data_dist(t); } - if (t->ar->regiontype == RGN_TYPE_WINDOW) + if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) { View3D *v3d = t->view; RegionView3D *rv3d = CTX_wm_region_view3d(C); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8c7a39e5dff..67e04bbd34e 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1039,9 +1039,14 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } else { - // XXX for now, get View2D from the active region - t->view = &ar->v2d; - // XXX for now, the center point is the midpoint of the data + if(ar) { + // XXX for now, get View2D from the active region + t->view = &ar->v2d; + // XXX for now, the center point is the midpoint of the data + } + else { + t->view= NULL; + } t->around = V3D_CENTER; } diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index b6c4deffe0a..7a16e25302c 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -43,25 +43,25 @@ /* ************************** INPUT FROM MOUSE *************************** */ -static void InputVector(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) +static void InputVector(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float vec[3], dvec[3]; if(mi->precision) { /* calculate the main translation and the precise one separate */ - convertViewVec(t, dvec, (short)(mval[0] - mi->precision_mval[0]), (short)(mval[1] - mi->precision_mval[1])); + convertViewVec(t, dvec, (mval[0] - mi->precision_mval[0]), (mval[1] - mi->precision_mval[1])); mul_v3_fl(dvec, 0.1f); - convertViewVec(t, vec, (short)(mi->precision_mval[0] - t->imval[0]), (short)(mi->precision_mval[1] - t->imval[1])); + convertViewVec(t, vec, (mi->precision_mval[0] - t->imval[0]), (mi->precision_mval[1] - t->imval[1])); add_v3_v3v3(output, vec, dvec); } else { - convertViewVec(t, output, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1])); + convertViewVec(t, output, (mval[0] - t->imval[0]), (mval[1] - t->imval[1])); } } -static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { float ratio, precise_ratio, dx, dy; if(mi->precision) @@ -87,7 +87,7 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2 output[0] = ratio; } -static void InputSpringFlip(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) +static void InputSpringFlip(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { InputSpring(t, mi, mval, output); @@ -100,7 +100,7 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, const short mval[2], f } } -static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { if(mi->precision) @@ -118,7 +118,7 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const short mva output[1] *= mi->factor; } -static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float x, pad; pad = t->ar->winx / 10; @@ -135,7 +135,7 @@ static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const short mval[ output[0] = (x - pad) / (t->ar->winx - 2 * pad); } -static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float vec[3]; InputVector(t, mi, mval, vec); @@ -144,7 +144,7 @@ static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const short mv output[0] = dot_v3v3(t->viewinv[0], vec) * 2.0f; } -static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float y, pad; pad = t->ar->winy / 10; @@ -160,7 +160,7 @@ static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const short mval[2] output[0] = (y - pad) / (t->ar->winy - 2 * pad); } -static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float vec[3]; InputVector(t, mi, mval, vec); @@ -169,12 +169,12 @@ static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const short mval output[0] = dot_v3v3(t->viewinv[1], vec) * 2.0f; } -void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, short start[2], short end[2]) +void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, int start[2], int end[2]) { - short *data; + int *data; if (mi->data == NULL) { - mi->data = MEM_callocN(sizeof(short) * 4, "custom points"); + mi->data = MEM_callocN(sizeof(int) * 4, "custom points"); } data = mi->data; @@ -185,12 +185,12 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, short start[2], short data[3] = end[1]; } -static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { float length; float distance; - short *data = mi->data; - short dx, dy; + int *data = mi->data; + int dx, dy; if (data) { dx = data[2] - data[0]; @@ -200,14 +200,14 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short m if (mi->precision) { /* deal with Shift key by adding motion / 10 to motion before shift press */ - short mdx, mdy; + int mdx, mdy; mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2]; mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3]; distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; } else { - short mdx, mdy; + int mdx, mdy; mdx = mval[0] - data[2]; mdy = mval[1] - data[3]; @@ -218,7 +218,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short m } } -static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { double dx2 = mval[0] - mi->center[0]; double dy2 = mval[1] - mi->center[1]; @@ -279,7 +279,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2] output[0] = *angle; } -void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, int center[2], short mval[2]) +void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, int center[2], int mval[2]) { mi->factor = 0; mi->precision = 0; @@ -372,7 +372,7 @@ void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]) mi->post = post; } -void applyMouseInput(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) +void applyMouseInput(TransInfo *t, MouseInput *mi, int mval[2], float output[3]) { if (mi->apply != NULL) { diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 2fa094c6b8b..1933b11b308 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1487,7 +1487,7 @@ void BIF_draw_manipulator(const bContext *C) } } -static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const short mval[2], float hotspot) +static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot) { View3D *v3d= sa->spacedata.first; RegionView3D *rv3d= ar->regiondata; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4edaabb9508..7bdf6c909d9 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -514,7 +514,7 @@ void TRANSFORM_OT_translate(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); @@ -534,7 +534,7 @@ void TRANSFORM_OT_resize(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); @@ -555,7 +555,7 @@ void TRANSFORM_OT_trackball(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "angle", "", -FLT_MAX, FLT_MAX); @@ -575,7 +575,7 @@ void TRANSFORM_OT_rotate(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2); @@ -618,7 +618,7 @@ void TRANSFORM_OT_warp(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", 0, 1); @@ -639,7 +639,7 @@ void TRANSFORM_OT_shear(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX); @@ -660,7 +660,7 @@ void TRANSFORM_OT_push_pull(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX); @@ -701,7 +701,7 @@ void TRANSFORM_OT_tosphere(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1); @@ -721,7 +721,7 @@ void TRANSFORM_OT_mirror(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL); } @@ -801,7 +801,7 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); RNA_def_property_flag(prop, PROP_HIDDEN); diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 60f551afa6e..9ac44f482a1 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -260,7 +260,7 @@ int ED_undo_valid(const bContext *C, const char *undoname) static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op)) { /* "last operator" should disappear, later we can tie ths with undo stack nicer */ - WM_operator_stack_clear(C); + WM_operator_stack_clear(CTX_wm_manager(C)); return ed_undo_step(C, 1, NULL); } diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index 9ecfb07d535..1a82668236d 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -37,7 +37,6 @@ /* internal exports only */ /* editmode_undo.c */ -void undo_editmode_clear(void); void undo_editmode_name(bContext *C, const char *undoname); int undo_editmode_valid(const char *undoname); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index eee7a3d7f69..20d7ea21d5c 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -419,7 +419,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float return sel; } -int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3]) +static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3]) { EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); EditFace *efa; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index e1eab55b434..1b8acb013ea 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -893,6 +893,7 @@ void UV_OT_unwrap(wmOperatorType *ot) /* identifiers */ ot->name= "Unwrap"; + ot->description= "Unwrap the mesh of the object being edited"; ot->idname= "UV_OT_unwrap"; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; |