diff options
Diffstat (limited to 'source/blender/editors')
24 files changed, 436 insertions, 182 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 8c699c840dc..a21c394a81e 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -496,7 +496,7 @@ void ANIM_flush_setting_anim_channels (bAnimContext *ac, ListBase *anim_data, bA break; /* store this level as the 'old' level now */ - prevLevel= level; // XXX: prevLevel is unused + // prevLevel= level; // XXX: prevLevel is unused } } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index fe6aed77462..45b715c406a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2205,12 +2205,12 @@ size_t ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_m /* only filter data if there's somewhere to put it */ if (data && anim_data) { - Object *obact= (ac) ? ac->obact : NULL; /* firstly filter the data */ switch (datatype) { case ANIMCONT_ACTION: /* 'Action Editor' */ { + Object *obact= ac->obact; SpaceAction *saction = (SpaceAction *)ac->sl; bDopeSheet *ads = (saction)? &saction->ads : NULL; diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 476cf2ac109..0562f400700 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -201,7 +201,7 @@ void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); /* Projection */ #define IS_CLIPPED 12000 -void ED_view3d_calc_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, struct rcti *rect); +void ED_view3d_calc_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); void project_short(struct ARegion *ar, const float vec[3], short adr[2]); void project_short_noclip(struct ARegion *ar, const float vec[3], short adr[2]); @@ -215,7 +215,7 @@ void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); -void ED_view3d_project_float(struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); +void ED_view3d_project_float(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift); void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]); @@ -257,7 +257,7 @@ 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 int mval[2], const short do_fallback); -void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); +void view3d_get_transformation(const 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); @@ -286,8 +286,8 @@ 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); -unsigned int ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); -unsigned int ED_viewedit_datamask(struct bScreen *screen); +uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); +uint64_t ED_viewedit_datamask(struct bScreen *screen); /* camera lock functions */ int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 63e41082449..4948073f9c6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -904,7 +904,9 @@ void uiEndBlock(const bContext *C, uiBlock *block) /* handle pending stuff */ if(block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL); ui_block_do_align(block); - if((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) ui_menu_block_set_keyaccels(block); /* could use a different flag to check */ + if((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) { + ui_menu_block_set_keyaccels(block); /* could use a different flag to check */ + } if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block); /* after keymaps! */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 9853c9c049b..fca1591c2ea 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -681,7 +681,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) static int modifier_can_delete(ModifierData *md) { - // fluid particle modifier can't be deleted here + /* fluid particle modifier can't be deleted here */ if(md->type == eModifierType_ParticleSystem) if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) return 0; @@ -689,14 +689,16 @@ static int modifier_can_delete(ModifierData *md) return 1; } -// Check wheter Modifier is a simulation or not, this is used for switching to the physics/particles context tab +/* Check wheter Modifier is a simulation or not, this is used for switching to the physics/particles context tab */ static int modifier_is_simulation(ModifierData *md) { - // Physic Tab - if(ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint)) { + /* Physic Tab */ + if (ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, + eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint)) + { return 1; } - // Particle Tab + /* Particle Tab */ else if (md->type == eModifierType_ParticleSystem) { return 2; } @@ -705,7 +707,8 @@ static int modifier_is_simulation(ModifierData *md) } } -static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex) +static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, + ModifierData *md, int index, int cageIndex, int lastCageIndex) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); PointerRNA ptr; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index c2c482b0a2c..57d46de9cb7 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -177,7 +177,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */ switch (type) { - /* 'standard view' - optimum setup for 'standard' view behaviour, that should be used new views as basis for their + /* 'standard view' - optimum setup for 'standard' view behaviour, + * that should be used new views as basis for their * own unique View2D settings, which should be used instead of this in most cases... */ case V2D_COMMONVIEW_STANDARD: diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 1477469ca85..f617971967c 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -922,7 +922,10 @@ void make_editMesh(Scene *scene, Object *ob) for(a=0; a<me->totselect; a++, mselect++){ /*check if recorded selection is still valid, if so copy into editmesh*/ - if( (mselect->type == EDITVERT && me->mvert[mselect->index].flag & SELECT) || (mselect->type == EDITEDGE && me->medge[mselect->index].flag & SELECT) || (mselect->type == EDITFACE && me->mface[mselect->index].flag & ME_FACE_SEL) ){ + if ( (mselect->type == EDITVERT && me->mvert[mselect->index].flag & SELECT) || + (mselect->type == EDITEDGE && me->medge[mselect->index].flag & SELECT) || + (mselect->type == EDITFACE && me->mface[mselect->index].flag & ME_FACE_SEL) ) + { ese = MEM_callocN(sizeof(EditSelection), "Edit Selection"); ese->type = mselect->type; if(ese->type == EDITVERT) ese->data = EM_get_vert_for_index(mselect->index); else diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index f3722e81246..b94b60fc279 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1080,8 +1080,8 @@ int *mesh_get_x_mirror_faces(Object *ob, EditMesh *em) /* make sure v4 is not 0 if a quad */ if(mf->v4 && mirrormf.v4==0) { - SWAP(int, mirrormf.v1, mirrormf.v3); - SWAP(int, mirrormf.v2, mirrormf.v4); + SWAP(unsigned int, mirrormf.v1, mirrormf.v3); + SWAP(unsigned int, mirrormf.v2, mirrormf.v4); } hashmf= BLI_ghash_lookup(fhash, &mirrormf); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1c34df5393a..ffdfea7fde5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1666,6 +1666,47 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } +static int region_scale_get_maxsize(RegionMoveData *rmd) +{ + int maxsize= 0; + + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + return rmd->sa->winx - UI_UNIT_X; + } + + if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { + /* this calculation seems overly verbose + * can someone explain why this method is necessary? - campbell */ + maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); + } + + return maxsize; +} + +static void region_scale_validate_size(RegionMoveData *rmd) +{ + if((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { + short *size, maxsize= -1; + + + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) + size= &rmd->ar->sizex; + else + size= &rmd->ar->sizey; + + maxsize= region_scale_get_maxsize(rmd); + + if(*size > maxsize && maxsize > 0) + *size= maxsize; + } +} + +static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) +{ + ED_region_toggle_hidden(C, rmd->ar); + region_scale_validate_size(rmd); +} + static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) { RegionMoveData *rmd= op->customdata; @@ -1685,35 +1726,31 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(rmd->ar->sizex < UI_UNIT_X) { rmd->ar->sizex= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else if(rmd->ar->flag & RGN_FLAG_HIDDEN) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else { - int maxsize=0; + int maxsize= region_scale_get_maxsize(rmd); delta= event->y - rmd->origy; if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; rmd->ar->sizey= rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); - if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { - /* this calculation seems overly verbose - * can someone explain why this method is necessary? - campbell */ - maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); - } - /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if(rmd->ar->sizey < UI_UNIT_Y/4 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) { + if(rmd->ar->sizey < UI_UNIT_Y/4) { rmd->ar->sizey= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } + else if(maxsize > 0 && (rmd->ar->sizey > maxsize)) + rmd->ar->sizey= maxsize; else if(rmd->ar->flag & RGN_FLAG_HIDDEN) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); @@ -1725,10 +1762,14 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if(rmd->ar->flag & RGN_FLAG_HIDDEN) { - ED_region_toggle_hidden(C, rmd->ar); - ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + region_scale_toggle_hidden(C, rmd); + } + else if(rmd->ar->flag & RGN_FLAG_TOO_SMALL) { + region_scale_validate_size(rmd); } + + ED_area_tag_redraw(rmd->sa); + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } MEM_freeN(op->customdata); op->customdata = NULL; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 3aefe5f9ea3..8a4cb8aa78b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1816,7 +1816,9 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s return 1; */ - if((bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) || (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]) ) { + if ( (bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) || + (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]) ) + { return 1; } @@ -2816,7 +2818,11 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke p4[0] = bucket_bounds.xmax; p4[1] = bucket_bounds.ymin; if (mf->v4) { - if( isect_point_quad_v2(p1, v1, v2, v3, v4) || isect_point_quad_v2(p2, v1, v2, v3, v4) || isect_point_quad_v2(p3, v1, v2, v3, v4) || isect_point_quad_v2(p4, v1, v2, v3, v4) || + if ( isect_point_quad_v2(p1, v1, v2, v3, v4) || + isect_point_quad_v2(p2, v1, v2, v3, v4) || + isect_point_quad_v2(p3, v1, v2, v3, v4) || + isect_point_quad_v2(p4, v1, v2, v3, v4) || + /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3) || isect_line_line_v2(p1, p2, v3, v4)) || (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3) || isect_line_line_v2(p2, p3, v3, v4)) || @@ -2827,7 +2833,10 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke } } else { - if( isect_point_tri_v2(p1, v1, v2, v3) || isect_point_tri_v2(p2, v1, v2, v3) || isect_point_tri_v2(p3, v1, v2, v3) || isect_point_tri_v2(p4, v1, v2, v3) || + if ( isect_point_tri_v2(p1, v1, v2, v3) || + isect_point_tri_v2(p2, v1, v2, v3) || + isect_point_tri_v2(p3, v1, v2, v3) || + isect_point_tri_v2(p4, v1, v2, v3) || /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */ (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) || (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) || diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 3b001a8fcdc..a5e68f9a244 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -41,6 +41,7 @@ struct Mesh; struct Object; struct PaintStroke; struct PointerRNA; +struct rcti; struct Scene; struct VPaint; struct ViewContext; @@ -104,6 +105,26 @@ void PAINT_OT_image_from_view(struct wmOperatorType *ot); /* paint_utils.c */ + +/* Convert the object-space axis-aligned bounding box (expressed as + its minimum and maximum corners) into a screen-space rectangle, + returns zero if the result is empty */ +int paint_convert_bb_to_rect(struct rcti *rect, + const float bb_min[3], + const float bb_max[3], + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob); + +/* Get four planes in object-space that describe the projection of + screen_rect from screen into object-space (essentially converting a + 2D screens-space bounding box into four 3D planes) */ +void paint_calc_redraw_planes(float planes[4][4], + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob, + const struct rcti *screen_rect); + void projectf(struct bglMats *mats, const float v[3], float p[2]); float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius); float paint_get_tex_pixel(struct Brush* br, float u, float v); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 0e65383861b..7cff37e8814 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -123,19 +123,19 @@ static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc) { MTex* mtex = &brush->mtex; - return - (mtex->tex && - mtex->ofs[0] == snap->ofs[0] && - mtex->ofs[1] == snap->ofs[1] && - mtex->ofs[2] == snap->ofs[2] && - mtex->size[0] == snap->size[0] && - mtex->size[1] == snap->size[1] && - mtex->size[2] == snap->size[2] && - mtex->rot == snap->rot) && - ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && brush_size(brush) <= snap->brush_size) || (brush_size(brush) == snap->brush_size)) && // make brush smaller shouldn't cause a resample - mtex->brush_map_mode == snap->brush_map_mode && - vc->ar->winx == snap->winx && - vc->ar->winy == snap->winy; + return ( (mtex->tex) && + equals_v3v3(mtex->ofs, snap->ofs) && + equals_v3v3(mtex->size, snap->size) && + mtex->rot == snap->rot + ) && + + /* make brush smaller shouldn't cause a resample */ + ( (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && (brush_size(brush) <= snap->brush_size)) || + (brush_size(brush) == snap->brush_size)) && + + (mtex->brush_map_mode == snap->brush_map_mode) && + (vc->ar->winx == snap->winx) && + (vc->ar->winy == snap->winy); } static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc) @@ -869,7 +869,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) MEM_freeN(stroke); return OPERATOR_FINISHED; } - else if(first || ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) || (event->type == TIMER && (event->customdata == stroke->timer))) { + else if( (first) || + (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) || + (event->type == TIMER && (event->customdata == stroke->timer)) ) + { if(stroke->stroke_started) { if(paint_smooth_stroke(stroke, mouse, event)) { if(paint_space_stroke_enabled(stroke->brush)) { @@ -887,7 +890,8 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) } } - /* we want the stroke to have the first daub at the start location instead of waiting till we have moved the space distance */ + /* we want the stroke to have the first daub at the start location + * instead of waiting till we have moved the space distance */ if(first && stroke->stroke_started && paint_space_stroke_enabled(stroke->brush) && diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index ed2956ff054..fdacc2d15f5 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -67,6 +67,78 @@ #include "paint_intern.h" +/* Convert the object-space axis-aligned bounding box (expressed as + its minimum and maximum corners) into a screen-space rectangle, + returns zero if the result is empty */ +int paint_convert_bb_to_rect(rcti *rect, + const float bb_min[3], + const float bb_max[3], + const ARegion *ar, + RegionView3D *rv3d, + Object *ob) +{ + float projection_mat[4][4]; + int i, j, k; + + rect->xmin = rect->ymin = INT_MAX; + rect->xmax = rect->ymax = INT_MIN; + + /* return zero if the bounding box has non-positive volume */ + if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) + return 0; + + ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat); + + for(i = 0; i < 2; ++i) { + for(j = 0; j < 2; ++j) { + for(k = 0; k < 2; ++k) { + float vec[3], proj[2]; + vec[0] = i ? bb_min[0] : bb_max[0]; + vec[1] = j ? bb_min[1] : bb_max[1]; + vec[2] = k ? bb_min[2] : bb_max[2]; + /* convert corner to screen space */ + ED_view3d_project_float(ar, vec, proj, + projection_mat); + /* expand 2D rectangle */ + rect->xmin = MIN2(rect->xmin, proj[0]); + rect->xmax = MAX2(rect->xmax, proj[0]); + rect->ymin = MIN2(rect->ymin, proj[1]); + rect->ymax = MAX2(rect->ymax, proj[1]); + } + } + } + + /* return false if the rectangle has non-positive area */ + return rect->xmin < rect->xmax && rect->ymin < rect->ymax; +} + +/* Get four planes in object-space that describe the projection of + screen_rect from screen into object-space (essentially converting a + 2D screens-space bounding box into four 3D planes) */ +void paint_calc_redraw_planes(float planes[4][4], + const ARegion *ar, + RegionView3D *rv3d, + Object *ob, + const rcti *screen_rect) +{ + BoundBox bb; + bglMats mats; + rcti rect; + + memset(&bb, 0, sizeof(BoundBox)); + view3d_get_transformation(ar, rv3d, ob, &mats); + + /* use some extra space just in case */ + rect = *screen_rect; + rect.xmin -= 2; + rect.xmax += 2; + rect.ymin -= 2; + rect.ymax += 2; + + ED_view3d_calc_clipping(&bb, planes, &mats, &rect); + mul_m4_fl(planes, -1.0f); +} + /* convert a point in model coordinates to 2D screen coordinates */ /* TODO: can be deleted once all calls are replaced with view3d_project_float() */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 272475194ee..9fb992d969c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -248,90 +248,51 @@ typedef struct StrokeCache { /* Get a screen-space rectangle of the modified area */ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, - Object *ob, rcti *rect) + Object *ob, rcti *rect) { + SculptSession *ss; PBVH *pbvh= ob->sculpt->pbvh; - float bb_min[3], bb_max[3], pmat[4][4]; - int i, j, k; - - ED_view3d_ob_project_mat_get(rv3d, ob, pmat); + float bb_min[3], bb_max[3]; if(!pbvh) return 0; BLI_pbvh_redraw_BB(pbvh, bb_min, bb_max); - rect->xmin = rect->ymin = INT_MAX; - rect->xmax = rect->ymax = INT_MIN; - - if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) + /* convert 3D bounding box to screen space */ + if(!paint_convert_bb_to_rect(rect, + bb_min, + bb_max, + ar, + rv3d, + ob)) { return 0; - - for(i = 0; i < 2; ++i) { - for(j = 0; j < 2; ++j) { - for(k = 0; k < 2; ++k) { - float vec[3], proj[2]; - vec[0] = i ? bb_min[0] : bb_max[0]; - vec[1] = j ? bb_min[1] : bb_max[1]; - vec[2] = k ? bb_min[2] : bb_max[2]; - ED_view3d_project_float(ar, vec, proj, pmat); - rect->xmin = MIN2(rect->xmin, proj[0]); - rect->xmax = MAX2(rect->xmax, proj[0]); - rect->ymin = MIN2(rect->ymin, proj[1]); - rect->ymax = MAX2(rect->ymax, proj[1]); - } - } } - - if (rect->xmin < rect->xmax && rect->ymin < rect->ymax) { - /* expand redraw rect with redraw rect from previous step to prevent - partial-redraw issues caused by fast strokes. This is needed here (not in sculpt_flush_update) - as it was before because redraw rectangle should be the same in both of - optimized PBVH draw function and 3d view redraw (if not -- some mesh parts could - disapper from screen (sergey) */ - SculptSession *ss = ob->sculpt; - if (ss->cache) { - if (!BLI_rcti_is_empty(&ss->cache->previous_r)) - BLI_union_rcti(rect, &ss->cache->previous_r); - } - - return 1; + /* expand redraw rect with redraw rect from previous step to + prevent partial-redraw issues caused by fast strokes. This is + needed here (not in sculpt_flush_update) as it was before + because redraw rectangle should be the same in both of + optimized PBVH draw function and 3d view redraw (if not -- some + mesh parts could disapper from screen (sergey) */ + ss = ob->sculpt; + if(ss->cache) { + if(!BLI_rcti_is_empty(&ss->cache->previous_r)) + BLI_union_rcti(rect, &ss->cache->previous_r); } - return 0; + return 1; } void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, RegionView3D *rv3d, Object *ob) { PBVH *pbvh= ob->sculpt->pbvh; - BoundBox bb; - bglMats mats; rcti rect; - memset(&bb, 0, sizeof(BoundBox)); - - view3d_get_transformation(ar, rv3d, ob, &mats); - sculpt_get_redraw_rect(ar, rv3d,ob, &rect); - -#if 1 - /* use some extra space just in case */ - rect.xmin -= 2; - rect.xmax += 2; - rect.ymin -= 2; - rect.ymax += 2; -#else - /* it was doing this before, allows to redraw a smaller - part of the screen but also gives artifaces .. */ - rect.xmin += 2; - rect.xmax -= 2; - rect.ymin += 2; - rect.ymax -= 2; -#endif + sculpt_get_redraw_rect(ar, rv3d, ob, &rect); - ED_view3d_calc_clipping(&bb, planes, &mats, &rect); - mul_m4_fl(planes, -1.0f); + paint_calc_redraw_planes(planes, ar, rv3d, ob, &rect); /* clear redraw flag from nodes */ if(pbvh) @@ -592,7 +553,12 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) float pen_flip = cache->pen_flip ? -1 : 1; float invert = cache->invert ? -1 : 1; float accum = integrate_overlap(brush); - float overlap = (brush->flag & BRUSH_SPACE_ATTEN && brush->flag & BRUSH_SPACE && !(brush->flag & BRUSH_ANCHORED)) && (brush->spacing < 100) ? 1.0f/accum : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter + /* spacing is integer percentage of radius, divide by 50 to get + normalized diameter */ + float overlap = (brush->flag & BRUSH_SPACE_ATTEN && + brush->flag & BRUSH_SPACE && + !(brush->flag & BRUSH_ANCHORED) && + (brush->spacing < 100)) ? 1.0f/accum : 1; float flip = dir * invert * pen_flip; switch(brush->sculpt_tool){ @@ -1716,7 +1682,9 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to /* this calculates flatten center and area normal together, amortizing the memory bandwidth and loop overhead to calculate both at the same time */ -static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float an[3], float fc[3]) +static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, + PBVHNode **nodes, int totnode, + float an[3], float fc[3]) { SculptSession *ss = ob->sculpt; int n; @@ -2588,7 +2556,9 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) /* Flip all the editdata across the axis/axes specified by symm. Used to calculate multiple modifications to the mesh when symmetry is enabled. */ -static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, const char axis, const float angle, const float UNUSED(feather)) +static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, + const char axis, const float angle, + const float UNUSED(feather)) { (void)sd; /* unused */ @@ -2620,7 +2590,9 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, mul_m4_v3(cache->symm_rot_mat, cache->grab_delta_symmetry); } -static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, const char symm, const int axis, const float feather) +static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, + const char symm, const int axis, + const float feather) { SculptSession *ss = ob->sculpt; int i; @@ -2954,7 +2926,10 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio cache->original = 1; } - if(ELEM8(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_ROTATE)) + if(ELEM8(brush->sculpt_tool, + SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, + SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, + SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_ROTATE)) if(!(brush->flag & BRUSH_ACCUMULATE)) cache->original = 1; @@ -3038,7 +3013,9 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) } /* Initialize the stroke cache variants from operator properties */ -static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, struct PaintStroke *stroke, PointerRNA *ptr) +static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, + struct PaintStroke *stroke, + PointerRNA *ptr) { SculptSession *ss = ob->sculpt; StrokeCache *cache = ss->cache; @@ -3095,7 +3072,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st cache->radius_squared = cache->radius*cache->radius; - if(!(brush->flag & BRUSH_ANCHORED || ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { + if(!(brush->flag & BRUSH_ANCHORED || + ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, + SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { copy_v2_v2(cache->tex_mouse, cache->mouse); if ( (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) && @@ -3137,7 +3116,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st if (!hit) copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); - cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius); + cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), + cache->true_location, + cache->pixel_radius); cache->radius_squared = cache->radius*cache->radius; copy_v3_v3(sd->anchored_location, cache->true_location); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 30a7abd3c0b..9b1bd1d7b31 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -221,12 +221,17 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) { /* can't rename rna datablocks entries */ - if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) - ; - else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + /* do nothing */; + } + else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, + TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + { BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); - else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) + } + else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); + } else if(tselem->id->lib) { // XXX error_libdata(); } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index e728267f45f..bf570c929cc 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -823,8 +823,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX) + if ( !ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + !(soops->flag & SO_HIDE_RESTRICTCOLS) && + (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) + { return OPERATOR_CANCELLED; + } for(te= soops->tree.first; te; te= te->next) { if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 7827569bd30..79c08c8dea9 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2656,8 +2656,7 @@ static void draw_em_fancy_edges(Scene *scene, View3D *v3d, } } -static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, - Object *ob, EditMesh *em, UnitSettings *unit) +static void draw_em_measure_stats(View3D *v3d, Object *ob, EditMesh *em, UnitSettings *unit) { Mesh *me= ob->data; EditEdge *eed; @@ -2680,11 +2679,6 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, else if (grid < 1.0f) conv_float= "%.4g"; else if (grid < 10.0f) conv_float= "%.3g"; else conv_float= "%.2g"; - - if(v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT)==0) - glDisable(GL_DEPTH_TEST); - - if(v3d->zbuf) bglPolygonOffset(rv3d->dist, 5.0f); if(me->drawflag & ME_DRAWEXTRA_EDGELEN) { UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); @@ -2803,23 +2797,43 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, } } } +} - /* useful for debugging index vs shape key index */ -#if 0 - { - EditVert *eve; - int j; - UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); - for(eve= em->verts.first, j= 0; eve; eve= eve->next, j++) { - sprintf(val, "%d:%d", j, eve->keyindex); - view3d_cached_text_draw_add(eve->co, val, 0, V3D_CACHE_TEXT_ASCII, col); +static void draw_em_indices(EditMesh *em) +{ + EditEdge *e; + EditFace *f; + EditVert *v; + int i; + char val[32]; + float pos[3]; + unsigned char col[4]; + + /* For now, reuse appropriate theme colors from stats text colors */ + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); + for (v = em->verts.first, i = 0; v; v = v->next, i++) { + if (v->f & SELECT) { + sprintf(val, "%d", i); + view3d_cached_text_draw_add(v->co, val, 0, V3D_CACHE_TEXT_ASCII, col); + } + } + + UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col); + for (e = em->edges.first, i = 0; e; e = e->next, i++) { + if (e->f & SELECT) { + sprintf(val, "%d", i); + mid_v3_v3v3(pos, e->v1->co, e->v2->co); + view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col); } } -#endif - if(v3d->zbuf) { - glEnable(GL_DEPTH_TEST); - bglPolygonOffset(rv3d->dist, 0.0f); + UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); + for (f = em->faces.first, i = 0; f; f = f->next, i++) { + if (f->f & SELECT) { + sprintf(val, "%d", i); + view3d_cached_text_draw_add(f->cent, val, 0, V3D_CACHE_TEXT_ASCII, col); + } } } @@ -2996,7 +3010,12 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, if ( (me->drawflag & (ME_DRAWEXTRA_EDGELEN|ME_DRAWEXTRA_FACEAREA|ME_DRAWEXTRA_FACEANG)) && !(v3d->flag2 & V3D_RENDER_OVERRIDE)) { - draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit); + draw_em_measure_stats(v3d, ob, em, &scene->unit); + } + + if ((G.f & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) && + !(v3d->flag2 & V3D_RENDER_OVERRIDE)) { + draw_em_indices(em); } } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 0c9ea3c6a2a..315da0423d1 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -276,7 +276,7 @@ static int modeselect_addmode(char *str, const char *title, int id, int icon) static char *view3d_modeselect_pup(Scene *scene) { Object *ob= OBACT; - static char string[256]; + static char string[512]; const char *title= IFACE_("Mode: %t"); char *str = string; @@ -316,7 +316,10 @@ static char *view3d_modeselect_pup(Scene *scene) str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT); } - if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) { + if ( ob->particlesystem.first || + modifiers_findByType(ob, eModifierType_Cloth) || + modifiers_findByType(ob, eModifierType_Softbody)) + { str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } (void)str; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index fb309f6de25..551eb3cd6b5 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -135,7 +135,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m /* * ob == NULL if you want global matrices * */ -void view3d_get_transformation(ARegion *ar, RegionView3D *rv3d, Object *ob, bglMats *mats) +void view3d_get_transformation(const ARegion *ar, RegionView3D *rv3d, Object *ob, bglMats *mats) { float cpy[4][4]; int i, j; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 4d98afc4c10..aa444125287 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -512,7 +512,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) /* ********************************** */ -void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, rcti *rect) +void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect) { float modelview[4][4]; double xs, ys, p[3]; @@ -760,7 +760,7 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, #endif /* use view3d_get_object_project_mat to get projecting mat */ -void ED_view3d_project_float(ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) +void ED_view3d_project_float(const ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) { float vec4[4]; @@ -1727,7 +1727,11 @@ static int game_engine_exec(bContext *C, wmOperator *op) game_set_commmandline_options(&startscene->gm); - if(rv3d->persp==RV3D_CAMOB && startscene->gm.framing.type == SCE_GAMEFRAMING_BARS && startscene->gm.stereoflag != STEREO_DOME) { /* Letterbox */ + if((rv3d->persp == RV3D_CAMOB) && + (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) && + (startscene->gm.stereoflag != STEREO_DOME)) + { + /* Letterbox */ rctf cam_framef; ED_view3d_calc_camera_border(startscene, ar, CTX_wm_view3d(C), rv3d, &cam_framef, FALSE); cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 8e6e5d08266..30337551fe5 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -585,6 +585,9 @@ int transformEvent(TransInfo *t, wmEvent *event) } applyMouseInput(t, &t->mouse, t->mval, t->values); + + // Snapping mouse move events + t->redraw |= handleSnapping(t, event); } /* handle modal keymap first */ @@ -1027,7 +1030,7 @@ int transformEvent(TransInfo *t, wmEvent *event) // Numerical input events t->redraw |= handleNumInput(&(t->num), event); - // Snapping events + // Snapping key events t->redraw |= handleSnapping(t, event); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index fcc285d52f0..2233aeda92e 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -65,15 +65,6 @@ struct wmTimer; struct ARegion; struct ReportList; -/* - The ctrl value has different meaning: - 0 : No value has been typed - - otherwise, |value| - 1 is where the cursor is located after the period - Positive : number is positive - Negative : number is negative -*/ - typedef struct TransSnapPoint { struct TransSnapPoint *next,*prev; float co[3]; @@ -94,6 +85,7 @@ typedef struct TransSnap { float snapNormal[3]; float snapTangent[3]; ListBase points; + TransSnapPoint *selectedPoint; float dist; // Distance from snapPoint to snapTarget double last; void (*applySnap)(struct TransInfo *, float *); @@ -618,6 +610,7 @@ int validSnappingNormal(TransInfo *t); void getSnapPoint(TransInfo *t, float vec[3]); void addSnapPoint(TransInfo *t); +int updateSelectedSnapPoint(TransInfo *t); void removeSnapPoint(TransInfo *t); /********************** Mouse Input ******************************/ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5ff7053da33..bc7514b4c9a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1548,8 +1548,10 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles * but for now just dont change handle types */ - if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0) - testhandlesNurb(nu); /* sets the handles based on their selection, do this after the data is copied to the TransData */ + if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0) { + /* sets the handles based on their selection, do this after the data is copied to the TransData */ + testhandlesNurb(nu); + } } else { TransData *head, *tail; @@ -3448,7 +3450,10 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) * then check if we're using auto-handles. * - If so, change them auto-handles to aligned handles so that handles get affected too */ - if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { + if ( ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && + ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) && + ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) + { if (hdata && (sel1) && (sel3)) { bezt->h1= HD_ALIGN; bezt->h2= HD_ALIGN; @@ -4144,7 +4149,10 @@ static void createTransSeqData(bContext *C, TransInfo *t) int i; for(i=0; i<3; i++) { seq_user= *((&seq->seq1) + i); - if (seq_user && (seq_user->flag & SELECT) && !(seq_user->flag & SEQ_LOCK) && !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) { + if ( seq_user && (seq_user->flag & SELECT) && + !(seq_user->flag & SEQ_LOCK) && + !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) + { seq->flag |= SELECT; } } @@ -4444,7 +4452,8 @@ static int count_proportional_objects(TransInfo *t) /* mark all children */ for (base= scene->base.first; base; base= base->next) { /* all base not already selected or marked that is editable */ - if ((base->object->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && BASE_EDITABLE_BGMODE(v3d, scene, base)) + if ( (base->object->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && + (BASE_EDITABLE_BGMODE(v3d, scene, base))) { mark_children(base->object); } @@ -4455,7 +4464,8 @@ static int count_proportional_objects(TransInfo *t) Object *ob= base->object; /* if base is not selected, not a parent of selection or not a child of selection and it is editable */ - if ((ob->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && BASE_EDITABLE_BGMODE(v3d, scene, base)) + if ( (ob->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && + (BASE_EDITABLE_BGMODE(v3d, scene, base))) { /* used for flush, depgraph will change recalcs if needed :) */ @@ -4531,7 +4541,9 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, if (adt && adt->action) { for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) { fcu->flag &= ~FCURVE_SELECTED; - insert_keyframe(reports, id, adt->action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, id, adt->action, + (fcu->grp ? fcu->grp->name : NULL), + fcu->rna_path, fcu->array_index, cfra, flag); } } } @@ -5049,8 +5061,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - else if(t->scene->basact && (ob = t->scene->basact->object) && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, ob)) { - ; + else if ( (t->scene->basact) && + (ob = t->scene->basact->object) && + (ob->mode & OB_MODE_PARTICLE_EDIT) && + PE_get_current(t->scene, ob)) + { + /* do nothing */ ; } else { /* Objects */ int i, recalcObPaths=0; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 4635411dcdf..ed3e949c8a0 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -141,11 +141,16 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (validSnap(t) && activeSnap(t)) { - unsigned char col[4]; + unsigned char col[4], selectedCol[4], activeCol[4]; UI_GetThemeColor3ubv(TH_TRANSFORM, col); col[3]= 128; - glColor4ubv(col); + UI_GetThemeColor3ubv(TH_SELECT, selectedCol); + selectedCol[3]= 128; + + UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); + activeCol[3]= 192; + if (t->spacetype == SPACE_VIEW3D) { TransSnapPoint *p; View3D *v3d = CTX_wm_view3d(C); @@ -160,16 +165,26 @@ void drawSnapping(const struct bContext *C, TransInfo *t) invert_m4_m4(imat, rv3d->viewmat); for (p = t->tsnap.points.first; p; p = p->next) { - drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size, imat); + if (p == t->tsnap.selectedPoint) { + glColor4ubv(selectedCol); + } else { + glColor4ubv(col); + } + + drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat); } if (t->tsnap.status & POINT_INIT) { + glColor4ubv(activeCol); + drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat); } /* draw normal if needed */ if (usingSnappingNormal(t) && validSnappingNormal(t)) { + glColor4ubv(activeCol); + glBegin(GL_LINES); glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); glVertex3f( t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], @@ -219,7 +234,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) } } -int handleSnapping(TransInfo *UNUSED(t), wmEvent *UNUSED(event)) +int handleSnapping(TransInfo *t, wmEvent *event) { int status = 0; @@ -232,6 +247,10 @@ int handleSnapping(TransInfo *UNUSED(t), wmEvent *UNUSED(event)) status = 1; } #endif + if (event->type == MOUSEMOVE) + { + status |= updateSelectedSnapPoint(t); + } return status; } @@ -541,6 +560,8 @@ void addSnapPoint(TransInfo *t) if (t->tsnap.status & POINT_INIT) { TransSnapPoint *p = MEM_callocN(sizeof(TransSnapPoint), "SnapPoint"); + t->tsnap.selectedPoint = p; + copy_v3_v3(p->co, t->tsnap.snapPoint); BLI_addtail(&t->tsnap.points, p); @@ -549,13 +570,55 @@ void addSnapPoint(TransInfo *t) } } +int updateSelectedSnapPoint(TransInfo *t) +{ + int status = 0; + if (t->tsnap.status & MULTI_POINTS) { + TransSnapPoint *p, *closest_p = NULL; + int closest_dist = 0; + int screen_loc[2]; + + for( p = t->tsnap.points.first; p; p = p->next ) { + int dx, dy; + int dist; + + project_int(t->ar, p->co, screen_loc); + + dx = t->mval[0] - screen_loc[0]; + dy = t->mval[1] - screen_loc[1]; + + dist = dx * dx + dy * dy; + + if (dist < 100 && (closest_p == NULL || closest_dist > dist)) { + closest_p = p; + closest_dist = dist; + } + } + + if (closest_p) { + status = t->tsnap.selectedPoint == closest_p ? 0 : 1; + t->tsnap.selectedPoint = closest_p; + } + } + + return status; +} + void removeSnapPoint(TransInfo *t) { if (t->tsnap.status & MULTI_POINTS) { - BLI_freelinkN(&t->tsnap.points, t->tsnap.points.last); + updateSelectedSnapPoint(t); + + if (t->tsnap.selectedPoint) { + BLI_freelinkN(&t->tsnap.points, t->tsnap.selectedPoint); + + if (t->tsnap.points.first == NULL) { + t->tsnap.status &= ~MULTI_POINTS; + } + + t->tsnap.selectedPoint = NULL; + } - if (t->tsnap.points.first == NULL) - t->tsnap.status &= ~MULTI_POINTS; } } @@ -680,7 +743,7 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3]) static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) { - float d1[3], d2[3], center[3]; + float d1[3], d2[3], center[3], len_d1; copy_v3_v3(center, t->center); if(t->flag & (T_EDIT|T_POSE)) { @@ -696,7 +759,9 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) mul_m3_v3(t->con.pmtx, d2); } - return len_v3(d2) / len_v3(d1); + len_d1 = len_v3(d1); + + return len_d1 != 0.0f ? len_v3(d2) / len_d1 : 1; } /********************** CALC **************************/ @@ -1622,7 +1687,12 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c } for ( base = FIRSTBASE; base != NULL; base = base->next ) { - if ( BASE_VISIBLE(v3d, base) && (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) ) { + if ( (BASE_VISIBLE(v3d, base)) && + (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 && + + ( (mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || + (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) ) + { Object *ob = base->object; if (ob->transflag & OB_DUPLI) |