[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46218] trunk/blender/source/blender: Patch [#30255] Center Last Stroke

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu May 3 05:51:32 CEST 2012


Revision: 46218
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46218
Author:   jwilkins
Date:     2012-05-03 03:51:30 +0000 (Thu, 03 May 2012)
Log Message:
-----------
Patch [#30255] Center Last Stroke

Enables the NUMPERIOD view centering operator to work in sculpt mode.  Hitting NUMPERIOD while in sculpt mode will center the view on the end of the last sculpting stroke made by the user.

This is useful for quickly refocusing on the current work area without fussing with the view controls.

It does not zoom into the stroke (slide only).

It does nothing if there have been no strokes.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_paint.h
    trunk/blender/source/blender/editors/include/ED_sculpt.h
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c

Modified: trunk/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_paint.h	2012-05-03 03:02:48 UTC (rev 46217)
+++ trunk/blender/source/blender/blenkernel/BKE_paint.h	2012-05-03 03:51:30 UTC (rev 46218)
@@ -103,6 +103,10 @@
 
 	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);

Modified: trunk/blender/source/blender/editors/include/ED_sculpt.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_sculpt.h	2012-05-03 03:02:48 UTC (rev 46217)
+++ trunk/blender/source/blender/editors/include/ED_sculpt.h	2012-05-03 03:51:30 UTC (rev 46218)
@@ -42,6 +42,8 @@
 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);

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2012-05-03 03:02:48 UTC (rev 46217)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2012-05-03 03:51:30 UTC (rev 46218)
@@ -101,6 +101,26 @@
 		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 @@
 			}
 		}
 
+		/* 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;
 

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2012-05-03 03:02:48 UTC (rev 46217)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2012-05-03 03:51:30 UTC (rev 46218)
@@ -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 @@
 	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,20 +2227,26 @@
 	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;
+	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 {
-			/* perspective should be a bit farther away to look nice */
-			size *= 0.7f;
+		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;
+			}
 		}
 	}
-	else {
-		if (size <= v3d->near * 1.5f) {
-			size = v3d->near * 1.5f;
-		}
-	}
 
 	add_v3_v3v3(new_ofs, min, max);
 	mul_v3_fl(new_ofs, -0.5f);
@@ -2251,7 +2262,7 @@
 
 	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);




More information about the Bf-blender-cvs mailing list