[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15887] branches/soc-2008-nicholasbishop/ source/blender: Fixed the pageup/ pagedown sculptmode shortcut keys for switching multires levels.

Nicholas Bishop nicholasbishop at gmail.com
Wed Jul 30 23:32:13 CEST 2008


Revision: 15887
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15887
Author:   nicholasbishop
Date:     2008-07-30 23:31:52 +0200 (Wed, 30 Jul 2008)

Log Message:
-----------
Fixed the pageup/pagedown sculptmode shortcut keys for switching multires levels.

Modified Paths:
--------------
    branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h
    branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c
    branches/soc-2008-nicholasbishop/source/blender/src/space.c

Modified: branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h
===================================================================
--- branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h	2008-07-30 20:45:04 UTC (rev 15886)
+++ branches/soc-2008-nicholasbishop/source/blender/blenkernel/BKE_multires.h	2008-07-30 21:31:52 UTC (rev 15887)
@@ -128,6 +128,7 @@
 struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, struct DerivedMesh*,
 						    struct Mesh *, int, int);
 
+int multiresModifier_switch_level(struct Object *ob, const int);
 void multiresModifier_join(struct Object *ob);
 void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob);
 void multiresModifier_setLevel(void *mmd_v, void *ob_v);

Modified: branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c	2008-07-30 20:45:04 UTC (rev 15886)
+++ branches/soc-2008-nicholasbishop/source/blender/blenkernel/intern/multires.c	2008-07-30 21:31:52 UTC (rev 15887)
@@ -51,6 +51,7 @@
 #include "BKE_global.h"
 #include "BKE_modifier.h"
 #include "BKE_multires.h"
+#include "BKE_object.h"
 #include "BKE_subsurf.h"
 
 #include "blendef.h"
@@ -816,6 +817,28 @@
 static const int multires_tri_tot[]  = {3, 7, 19, 61, 217, 817,  3169, 12481, 49537, 197377, 787969,  3148801, 12589057};
 static const int multires_side_tot[] = {2, 3, 5,  9,  17,  33,   65,   129,   257,   513,    1025,    2049,    4097};
 
+int multiresModifier_switch_level(Object *ob, const int distance)
+{
+	ModifierData *md = NULL;
+	MultiresModifierData *mmd = NULL;
+
+	for(md = ob->modifiers.first; md; md = md->next) {
+		if(md->type == eModifierType_Multires)
+			mmd = (MultiresModifierData*)md;
+	}
+
+	if(mmd) {
+		mmd->lvl += distance;
+		if(mmd->lvl < 1) mmd->lvl = 1;
+		else if(mmd->lvl > mmd->totlvl) mmd->lvl = mmd->totlvl;
+		DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+		object_handle_update(ob);
+		return 1;
+	}
+	else
+		return 0;
+}
+
 void multiresModifier_join(Object *ob)
 {
 	Base *base = NULL;

Modified: branches/soc-2008-nicholasbishop/source/blender/src/space.c
===================================================================
--- branches/soc-2008-nicholasbishop/source/blender/src/space.c	2008-07-30 20:45:04 UTC (rev 15886)
+++ branches/soc-2008-nicholasbishop/source/blender/src/space.c	2008-07-30 21:31:52 UTC (rev 15887)
@@ -1388,7 +1388,7 @@
 			SculptData *sd= sculpt_data();
 			SculptSession *ss= sculpt_session();
 			BrushData *br= sculptmode_brush();
-			Mesh *me= get_mesh(OBACT);
+			Object *ob = OBACT;
 			char update_prop= 0;
 			
 			if(U.flag & USER_NONUMPAD) {
@@ -1528,16 +1528,11 @@
 				break;
 			/* Multires */
 			case PAGEUPKEY:
-				if(me && me->mr) {
-					me->mr->newlvl= ((Mesh*)ob->data)->mr->current+1;
-					multires_set_level_cb(ob, ob->data);
-				}
-				break;
 			case PAGEDOWNKEY:
-				if(me && me->mr) {
-					me->mr->newlvl= ((Mesh*)ob->data)->mr->current-1;
-					multires_set_level_cb(ob, ob->data);
-				}
+				if(multiresModifier_switch_level(ob, (event == PAGEUPKEY ? 1 : -1)))
+					BIF_undo_push("Multires switch level");
+				allqueue(REDRAWBUTSEDIT, 0);
+				allqueue(REDRAWVIEW3D, 0);
 				break;
 			/* Partial Visibility */
 			case HKEY:





More information about the Bf-blender-cvs mailing list