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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_paint.h4
-rw-r--r--source/blender/editors/include/ED_sculpt.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c25
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c35
4 files changed, 54 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index acf39d83370..bd31a62abf9 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -103,6 +103,10 @@ typedef struct SculptSession {
struct SculptStroke *stroke;
struct StrokeCache *cache;
+
+ /* last paint/sculpt stroke location */
+ int last_stroke_valid;
+ float last_stroke[3];
} SculptSession;
void free_sculptsession(struct Object *ob);
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index 9cb32c31f5b..2df699255be 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -42,6 +42,8 @@ void ED_operatortypes_sculpt(void);
void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar,
struct RegionView3D *rv3d, struct Object *ob);
void ED_sculpt_force_update(struct bContext *C);
+float *ED_sculpt_get_last_stroke(struct Object *ob);
+int ED_sculpt_minmax(struct bContext *C, float *min, float *max);
/* paint_ops.c */
void ED_operatortypes_paint(void);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8d2dfc8dbfa..51fe73bb527 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -101,6 +101,26 @@ void ED_sculpt_force_update(bContext *C)
multires_force_update(ob);
}
+float *ED_sculpt_get_last_stroke(struct Object *ob)
+{
+ return (ob && ob->sculpt && ob->sculpt->last_stroke_valid) ? ob->sculpt->last_stroke : NULL;
+}
+
+int ED_sculpt_minmax(bContext *C, float *min, float *max)
+{
+ Object *ob= CTX_data_active_object(C);
+
+ if (ob && ob->sculpt && ob->sculpt->last_stroke_valid) {
+ copy_v3_v3(min, ob->sculpt->last_stroke);
+ copy_v3_v3(max, ob->sculpt->last_stroke);
+
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
/* Sculpt mode handles multires differently from regular meshes, but only if
* it's the last modifier on the stack and it is not on the first level */
struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
@@ -3482,6 +3502,11 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke))
}
}
+ /* update last stroke position */
+ ob->sculpt->last_stroke_valid= 1;
+ copy_v3_v3(ob->sculpt->last_stroke, ss->cache->true_location);
+ mul_m4_v3(ob->obmat, ob->sculpt->last_stroke);
+
sculpt_cache_free(ss->cache);
ss->cache = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 2f66fdf8cd4..44fee7d663d 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -73,6 +73,7 @@
#include "ED_transform.h"
#include "ED_mesh.h"
#include "ED_view3d.h"
+#include "ED_sculpt.h"
#include "PIL_time.h" /* smoothview */
@@ -2199,6 +2200,10 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
ok = PE_minmax(scene, min, max);
}
+ else if (ob && (ob->mode & OB_MODE_SCULPT)) {
+ ok = ED_sculpt_minmax(C, min, max);
+ ok_dist = 0; /* don't zoom */
+ }
else {
Base *base;
for (base = FIRSTBASE; base; base = base->next) {
@@ -2222,18 +2227,24 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
sub_v3_v3v3(afm, max, min);
size = MAX3(afm[0], afm[1], afm[2]);
- if (!rv3d->is_persp) {
- if (size < 0.0001f) { /* if its a sinble point. don't even re-scale */
- ok_dist = 0;
- }
- else {
- /* perspective should be a bit farther away to look nice */
- size *= 0.7f;
+ if (ok_dist) {
+ /* fix up zoom distance if needed */
+
+ if (rv3d->is_persp) {
+ if (size <= v3d->near * 1.5f) {
+ /* do not zoom closer than the near clipping plane */
+ size = v3d->near * 1.5f;
+ }
}
- }
- else {
- if (size <= v3d->near * 1.5f) {
- size = v3d->near * 1.5f;
+ else /* ortho */ {
+ if (size < 0.0001f) {
+ /* bounding box was a single point so do not zoom */
+ ok_dist = 0;
+ }
+ else {
+ /* adjust zoom so it looks nicer */
+ size *= 0.7f;
+ }
}
}
@@ -2251,7 +2262,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op))
if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) {
rv3d->persp = RV3D_PERSP;
- smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
+ smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
}
else {
smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);