[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37288] branches/soc-2011-onion: == Pivot Last ==

Jason Wilkins Jason.A.Wilkins at gmail.com
Tue Jun 7 07:07:59 CEST 2011


Revision: 37288
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37288
Author:   jwilkins
Date:     2011-06-07 05:07:59 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
== Pivot Last == 
Added userpref to allow the end of the last paint or sculpt stroke to be used as the center of viewport rotation.

Enable this feature in the user preferences window on the interface tab.

Issues:
* Should probably not update the last stroke under certain conditions like using the grab brush_alpha
* Should probably disable when not in a sculpt or paint mode

The first issue will be addressed once I come up with a better way to organize what I mean by 'certain conditions'.  Currently there are dozens of 'certain conditions' scattered thru out the sculpt/paint code and it is getting unmanagable.

The second issue just requires more research.

Modified Paths:
--------------
    branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py
    branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
    branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_edit.c
    branches/soc-2011-onion/source/blender/makesdna/DNA_userdef_types.h
    branches/soc-2011-onion/source/blender/makesrna/intern/rna_userdef.c

Property Changed:
----------------
    branches/soc-2011-onion/


Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693,30696,30699
/trunk/blender:36833-37206
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693,30696,30699,30742
/trunk/blender:36833-37206

Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_userpref.py	2011-06-07 05:07:59 UTC (rev 37288)
@@ -198,6 +198,7 @@
         col.prop(view, "use_mouse_auto_depth")
         col.prop(view, "use_zoom_to_mouse")
         col.prop(view, "use_rotate_around_active")
+        col.prop(view, "use_rotate_around_last_stroke")
         col.prop(view, "use_global_pivot")
         col.prop(view, "use_camera_lock_parent")
 

Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h	2011-06-07 05:07:59 UTC (rev 37288)
@@ -109,6 +109,10 @@
 
 	/* previous redraw rect */
 	rcti previous_r;
+
+	/* last paint/sculpt stroke location */
+	int last_stroke_valid;
+	float last_stroke[3];
 } PaintSession;
 
 void create_paintsession(struct Object *ob);

Modified: branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h	2011-06-07 05:07:59 UTC (rev 37288)
@@ -66,4 +66,6 @@
 void ED_draw_on_surface_cursor(float modelview[16], float projection[16], float col[3], float alpha, float size[3], int viewport[4], float location[3], float inner_radius, float outer_radius, int brush_size);
 void ED_draw_fixed_overlay_on_surface(float modelview[16], float projection[16], float size[3], int viewport[4], float location[3], float outer_radius, struct Sculpt *sd, struct Brush *brush, struct ViewContext *vc, float t, float b, float l, float r, float angle);
 
+float *ED_paint_get_last_stroke(struct Object *ob);
+
 #endif

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c	2011-06-07 05:07:59 UTC (rev 37288)
@@ -574,3 +574,8 @@
 	if(pbvh)
 		BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL);
 }
+
+float *ED_paint_get_last_stroke(struct Object *ob)
+{
+	return (ob && ob->paint && ob->paint->last_stroke_valid) ? ob->paint->last_stroke : NULL;
+}

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-06-07 05:07:59 UTC (rev 37288)
@@ -4111,6 +4111,11 @@
 				paint_brush_set(p, brush);
 		}
 
+		/* update last stroke position */
+		ob->paint->last_stroke_valid= 1;
+		copy_v3_v3(ob->paint->last_stroke, ss->cache->true_location);
+		mul_m4_v3(ob->obmat, ob->paint->last_stroke);
+
 		sculpt_cache_free(ss->cache);
 		ss->cache = NULL;
 

Modified: branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_edit.c	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_edit.c	2011-06-07 05:07:59 UTC (rev 37288)
@@ -74,6 +74,7 @@
 #include "ED_transform.h"
 #include "ED_mesh.h"
 #include "ED_view3d.h"
+#include "ED_sculpt.h"
 
 
 #include "PIL_time.h" /* smoothview */
@@ -392,6 +393,7 @@
 	static float lastofs[3] = {0,0,0};
 	RegionView3D *rv3d;
 	ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data");
+	float* last_stroke;
 
 	/* store data */
 	op->customdata= vod;
@@ -409,13 +411,34 @@
 	vod->origx= vod->oldx= event->x;
 	vod->origy= vod->oldy= event->y;
 	vod->origkey= event->type; /* the key that triggered the operator.  */
-	vod->use_dyn_ofs= (U.uiflag & USER_ORBIT_SELECTION) ? 1:0;
+
+	/* dynamic offset is triggered by either
+	   rotating around active object or around last paint stroke */
+
+	vod->use_dyn_ofs= 0;
+
+	last_stroke= ED_paint_get_last_stroke(CTX_data_active_object(C));
+
+	if ((U.uiflag & USER_ORBIT_LAST_STROKE && last_stroke != NULL) ||
+	    (U.uiflag & USER_ORBIT_SELECTION))
+	{
+		vod->use_dyn_ofs= 1;
+	}
+
+	/* setup offset */
+
 	copy_v3_v3(vod->ofs, rv3d->ofs);
 
 	if (vod->use_dyn_ofs) {
-		/* If there's no selection, lastofs is unmodified and last value since static */
-		calculateTransformCenter(C, V3D_CENTROID, lastofs);
-		negate_v3_v3(vod->dyn_ofs, lastofs);
+		if (last_stroke) {
+			/* last stroke takes priority over active object center */
+			negate_v3_v3(vod->dyn_ofs, last_stroke);
+		}
+		else {
+			/* If there's no selection, lastofs is unmodified and last value since static */
+			calculateTransformCenter(C, V3D_CENTROID, lastofs);
+			negate_v3_v3(vod->dyn_ofs, lastofs);
+		}
 	}
 	else if (U.uiflag & USER_ORBIT_ZBUF) {
 

Modified: branches/soc-2011-onion/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- branches/soc-2011-onion/source/blender/makesdna/DNA_userdef_types.h	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/makesdna/DNA_userdef_types.h	2011-06-07 05:07:59 UTC (rev 37288)
@@ -482,6 +482,7 @@
 #define USER_SPLASH_DISABLE		(1 << 27)
 #define USER_HIDE_RECENT		(1 << 28)
 #define USER_SHOW_THUMBNAILS	(1 << 29)
+#define USER_ORBIT_LAST_STROKE	(1 << 30)
 
 /* Auto-Keying mode */
 	/* AUTOKEY_ON is a bitflag */

Modified: branches/soc-2011-onion/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- branches/soc-2011-onion/source/blender/makesrna/intern/rna_userdef.c	2011-06-07 04:14:15 UTC (rev 37287)
+++ branches/soc-2011-onion/source/blender/makesrna/intern/rna_userdef.c	2011-06-07 05:07:59 UTC (rev 37288)
@@ -2073,6 +2073,10 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ORBIT_SELECTION);
 	RNA_def_property_ui_text(prop, "Rotate Around Selection", "Use selection as the pivot point");
 	
+	prop= RNA_def_property(srna, "use_rotate_around_last_stroke", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ORBIT_LAST_STROKE);
+	RNA_def_property_ui_text(prop, "Rotate Around Last Paint or Sculpt Stroke", "Use end of last paint or sculpt stroke as the pivot point");
+	
 	/* mini axis */
 	prop= RNA_def_property(srna, "show_mini_axis", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_ROTVIEWICON);




More information about the Bf-blender-cvs mailing list