[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21199] branches/blender2.5/blender/source /blender/editors/sculpt_paint/sculpt.c: 2.5/Sculpt:

Nicholas Bishop nicholasbishop at gmail.com
Sat Jun 27 19:10:19 CEST 2009


Revision: 21199
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21199
Author:   nicholasbishop
Date:     2009-06-27 19:10:19 +0200 (Sat, 27 Jun 2009)

Log Message:
-----------
2.5/Sculpt:

Removed a bunch of old code that was #ifdef'd out. Mostly relates to partial visibility and partial redraw. Both of these are important features, but need better design updated for 2.5.

Also removed the old (huge/ugly!) sculpt() function that is now handled by the stroke operator code.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-06-27 16:35:42 UTC (rev 21198)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-06-27 17:10:19 UTC (rev 21199)
@@ -738,37 +738,6 @@
 	}
 }
 
-/* Clears the depth buffer in each modified area. */
-#if 0
-static void sculpt_clear_damaged_areas(SculptSession *ss)
-{
-	RectNode *rn= NULL;
-
-	for(rn = ss->damaged_rects.first; rn; rn = rn->next) {
-		rcti clp = rn->r;
-		rcti *win = NULL; /*XXX: &curarea->winrct; */
-		
-		clp.xmin += win->xmin;
-		clp.xmax += win->xmin;
-		clp.ymin += win->ymin;
-		clp.ymax += win->ymin;
-		
-		if(clp.xmin < win->xmax && clp.xmax > win->xmin &&
-		   clp.ymin < win->ymax && clp.ymax > win->ymin) {
-			if(clp.xmin < win->xmin) clp.xmin = win->xmin;
-			if(clp.ymin < win->ymin) clp.ymin = win->ymin;
-			if(clp.xmax > win->xmax) clp.xmax = win->xmax;
-			if(clp.ymax > win->ymax) clp.ymax = win->ymax;
-
-			glScissor(clp.xmin + 1, clp.ymin + 1,
-				  clp.xmax - clp.xmin - 2,
-				  clp.ymax - clp.ymin - 2);
-		}
-		
-		glClear(GL_DEPTH_BUFFER_BIT);
-	}
-}
-#endif
 static void do_brush_action(Sculpt *sd, StrokeCache *cache)
 {
 	SculptSession *ss = sd->session;
@@ -987,25 +956,6 @@
 	}
 }
 
-void sculptmode_selectbrush_menu(void)
-{
-	/* XXX: I guess menus belong elsewhere too?
-
-	Sculpt *sd= sculpt_data();
-	int val;
-	
-	pupmenu_set_active(sd->brush_type);
-	
-	val= pupmenu("Select Brush%t|Draw|Smooth|Pinch|Inflate|Grab|Layer|Flatten");
-
-	if(val>0) {
-		sd->brush_type= val;
-
-		allqueue(REDRAWVIEW3D, 1);
-		allqueue(REDRAWBUTSEDIT, 1);
-	}*/
-}
-
 static void sculptmode_update_all_projverts(SculptSession *ss)
 {
 	unsigned i;
@@ -1084,89 +1034,6 @@
 	}
 }
 
-/* XXX: lots of drawing code (partial redraw), has to go elsewhere */
-#if 0
-void sculptmode_draw_wires(SculptSession *ss, int only_damaged)
-{
-	Mesh *me = get_mesh(OBACT);
-	int i;
-
-	bglPolygonOffset(1.0);
-	glDepthMask(0);
-	BIF_ThemeColor((OBACT==OBACT)?TH_ACTIVE:TH_SELECT);
-
-	for(i=0; i<me->totedge; i++) {
-		MEdge *med= &me->medge[i];
-
-		if((!only_damaged || (ss->projverts[med->v1].inside || ss->projverts[med->v2].inside)) &&
-		   (med->flag & ME_EDGEDRAW)) {
-			glDrawElements(GL_LINES, 2, GL_UNSIGNED_INT, &med->v1);
-		}
-	}
-
-	glDepthMask(1);
-	bglPolygonOffset(0.0);
-}
-
-void sculptmode_draw_mesh(int only_damaged) 
-{
-	int i, j, dt, drawCurrentMat = 1, matnr= -1;
-	SculptSession *ss = sculpt_session();
-
-	sculpt_update_mesh_elements(ss, OBACT);
-
-	persp(PERSP_VIEW);
-	mymultmatrix(OBACT->obmat);
-	glEnable(GL_DEPTH_TEST);
-	glEnable(GL_LIGHTING);
-	/* XXX: GPU_set_object_materials(G.scene, OBACT, 0, NULL); */
-	glEnable(GL_CULL_FACE);
-
-	glShadeModel(GL_SMOOTH);
-
-	glVertexPointer(3, GL_FLOAT, sizeof(MVert), &cache->mvert[0].co);
-	glNormalPointer(GL_SHORT, sizeof(MVert), &cache->mvert[0].no);
-
-	dt= MIN2(G.vd->drawtype, OBACT->dt);
-	if(dt==OB_WIRE)
-		glColorMask(0,0,0,0);
-
-	for(i=0; i<ss->totface; ++i) {
-		MFace *f= &ss->mface[i];
-		char inside= 0;
-		int new_matnr= f->mat_nr + 1;
-		
-		if(new_matnr != matnr)
-			drawCurrentMat= GPU_enable_material(matnr = new_matnr, NULL);
-		
-		/* If only_damaged!=0, only draw faces that are partially
-		   inside the area(s) modified by the brush */
-		if(only_damaged) {
-			for(j=0; j<(f->v4?4:3); ++j) {
-				if(ss->projverts[*((&f->v1)+j)].inside) {
-					inside= 1;
-					break;
-				}
-			}
-		}
-		else
-			inside= 1;
-			
-		if(inside && drawCurrentMat)
-			glDrawElements(f->v4?GL_QUADS:GL_TRIANGLES, f->v4?4:3, GL_UNSIGNED_INT, &f->v1);
-	}
-
-	glDisable(GL_CULL_FACE);
-	glDisable(GL_LIGHTING);
-	glColorMask(1,1,1,1);
-
-	if(dt==OB_WIRE || (OBACT->dtx & OB_DRAWWIRE))
-		sculptmode_draw_wires(ss, only_damaged);
-
-	glDisable(GL_DEPTH_TEST);
-}
-#endif
-
 static int sculpt_mode_poll(bContext *C)
 {
 	return G.f & G_SCULPTMODE;
@@ -1718,454 +1585,3 @@
 	WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
 	WM_operatortype_append(SCULPT_OT_brush_curve_preset);
 }
-
-void sculpt(Sculpt *sd)
-{
-#if 0
-	SculptSession *ss= sd->session;
-	Object *ob= NULL; /*XXX */
-	Mesh *me;
-	MultiresModifierData *mmd = NULL;
-	/* lastSigMouse is for the rake, to store the last place the mouse movement was significant */
-	short mouse[2], mvalo[2], lastSigMouse[2],firsttime=1, mousebut;
-	short modifier_calculations= 0;
-	BrushAction *a = MEM_callocN(sizeof(BrushAction), "brush action");
-	short spacing= 32000;
-	int scissor_box[4];
-	float offsetRot;
-	int smooth_stroke = 0, i;
-	int anchored, rake = 0 /* XXX: rake = ? */;
-
-	/* XXX: checking that sculpting is allowed
-	if(!(G.f & G_SCULPTMODE) || G.obedit || !ob || ob->id.lib || !get_mesh(ob) || (get_mesh(ob)->totface == 0))
-		return;
-	if(!(ob->lay & G.vd->lay))
-		error("Active object is not in this layer");
-	if(ob_get_keyblock(ob)) {
-		if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
-			error("Cannot sculpt on unlocked shape key");
-			return;
-		}
-	}*/
-	
-	anchored = sd->brush->flag & BRUSH_ANCHORED;
-	smooth_stroke = (sd->flags & SCULPT_INPUT_SMOOTH) && (sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) && !anchored;
-
-	if(smooth_stroke)
-		sculpt_stroke_new(256);
-
-	ss->damaged_rects.first = ss->damaged_rects.last = NULL;
-	ss->damaged_verts.first = ss->damaged_verts.last = NULL;
-	ss->vertexcosnos = NULL;
-
-	mmd = sculpt_multires_active(ob);
-
-	/* Check that vertex users are up-to-date */
-	if(ob != active_ob || !ss->vertex_users || ss->vertex_users_size != cache->totvert) {
-		sculpt_vertexusers_free(ss);
-		calc_vertex_users(ss);
-		if(ss->projverts)
-			MEM_freeN(ss->projverts);
-		ss->projverts = NULL;
-		active_ob= ob;
-	}
-		
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glEnableClientState(GL_NORMAL_ARRAY);
-
-	/*XXX:
-	persp(PERSP_VIEW);
-	getmouseco_areawin(mvalo);*/
-
-	/* Init texture
-	   FIXME: Shouldn't be doing this every time! */
-	if(sd->tex_mode!=SCULPTREPT_3D)
-		sculptmode_update_tex(sd);
-
-	/*XXX: getmouseco_areawin(mouse); */
-	mvalo[0]= mouse[0];
-	mvalo[1]= mouse[1];
-	lastSigMouse[0]=mouse[0];
-	lastSigMouse[1]=mouse[1];
-	mousebut = 0; /* XXX: L_MOUSE; */
-
-	/* If modifier_calculations is true, then extra time must be spent
-	   updating the mesh. This takes a *lot* longer, so it's worth
-	   skipping if the modifier stack is empty. */
-	modifier_calculations= sculpt_modifiers_active(ob);
-
-	if(modifier_calculations)
-		ss->vertexcosnos= mesh_get_mapped_verts_nors(NULL, ob); /* XXX: scene = ? */
-	sculptmode_update_all_projverts(ss);
-
-	/* Capture original copy */
-	if(sd->flags & SCULPT_DRAW_FAST)
-		glAccum(GL_LOAD, 1);
-
-	/* Get original scissor box */
-	glGetIntegerv(GL_SCISSOR_BOX, scissor_box);
-	
-	/* For raking, get the original angle*/
-	offsetRot=sculpt_tex_angle(sd);
-
-	me = get_mesh(ob);
-
-	while (/*XXX:get_mbut() & mousebut*/0) {
-		/* XXX: getmouseco_areawin(mouse); */
-		/* If rake, and the mouse has moved over 10 pixels (euclidean) (prevents jitter) then get the new angle */
-		if (rake && (pow(lastSigMouse[0]-mouse[0],2)+pow(lastSigMouse[1]-mouse[1],2))>100){
-			/*Nasty looking, but just orig + new angle really*/
-			set_tex_angle(sd, offsetRot+180.+to_deg(atan2((float)(mouse[1]-lastSigMouse[1]),(float)(mouse[0]-lastSigMouse[0]))));
-			lastSigMouse[0]=mouse[0];
-			lastSigMouse[1]=mouse[1];
-		}
-		
-		if(firsttime || mouse[0]!=mvalo[0] || mouse[1]!=mvalo[1] ||
-		   sd->brush->flag & BRUSH_AIRBRUSH) {
-			a->firsttime = firsttime;
-			firsttime= 0;
-
-			if(smooth_stroke)
-				sculpt_stroke_add_point(ss->stroke, mouse[0], mouse[1]);
-
-			spacing+= sqrt(pow(mvalo[0]-mouse[0],2)+pow(mvalo[1]-mouse[1],2));
-
-			if(modifier_calculations && !ss->vertexcosnos)
-				ss->vertexcosnos= mesh_get_mapped_verts_nors(NULL, ob); /*XXX scene = ? */
-
-			if(sd->brush->sculpt_tool != SCULPT_TOOL_GRAB) {
-				if(anchored) {
- 					/* Restore the mesh before continuing with anchored stroke */
- 					/*if(a->mesh_store) {
- 						for(i = 0; i < cache->totvert; ++i) {
- 							VecCopyf(cache->mvert[i].co, &a->mesh_store[i].x);
-							cache->mvert[i].no[0] = a->orig_norms[i][0];
-							cache->mvert[i].no[1] = a->orig_norms[i][1];
-							cache->mvert[i].no[2] = a->orig_norms[i][2];
-						}
-						}*/
-					
-  					//do_symmetrical_brush_actions(sd, a, mouse, NULL);
-  				}
-				else {
-					if(smooth_stroke) {
-						sculpt_stroke_apply(sd, ss->stroke);
-					}
-					else if(sd->spacing==0 || spacing>sd->spacing) {
-						//do_symmetrical_brush_actions(sd, a, mouse, NULL);
-						spacing= 0;
-					}
-				}
-			}
-			else {
-				//do_symmetrical_brush_actions(sd, a, mouse, mvalo);
-				//unproject(ss, sd->pivot, mouse[0], mouse[1], a->depth);
-			}
-
-			if((!ss->multires && modifier_calculations) || ob_get_keyblock(ob)) {
-				/* XXX: DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); */ }
-
-			if(modifier_calculations || sd->brush->sculpt_tool == SCULPT_TOOL_GRAB || !(sd->flags & SCULPT_DRAW_FAST)) {
-				calc_damaged_verts(ss, a);
-				/*XXX: scrarea_do_windraw(curarea);
-				screen_swapbuffers(); */
-			} else { /* Optimized drawing */
-				calc_damaged_verts(ss, a);
-
-				/* Draw the stored image to the screen */
-				glAccum(GL_RETURN, 1);
-
-				sculpt_clear_damaged_areas(ss);
-				
-				/* Draw all the polygons that are inside the modified area(s) */
-				glScissor(scissor_box[0], scissor_box[1], scissor_box[2], scissor_box[3]);
-				/* XXX: sculptmode_draw_mesh(1); */
-				glAccum(GL_LOAD, 1);
-
-				projverts_clear_inside(ss);
-
-				/* XXX: persp(PERSP_WIN); */
-				glDisable(GL_DEPTH_TEST);
-				
-				/* Draw cursor */
-				if(sd->flags & SCULPT_TOOL_DRAW)
-					fdrawXORcirc((float)mouse[0],(float)mouse[1],sd->brush->size);
-				/* XXX: if(smooth_stroke)
-				   sculpt_stroke_draw();
-				
-				myswapbuffers(); */
-			}
-
-			BLI_freelistN(&ss->damaged_rects);
-			ss->damaged_rects.first = ss->damaged_rects.last = NULL;
-	
-			mvalo[0]= mouse[0];
-			mvalo[1]= mouse[1];
-
-			if(ss->vertexcosnos) {
-				MEM_freeN(ss->vertexcosnos);
-				ss->vertexcosnos= NULL;
-			}
-
-		}
-		else { /*XXX:BIF_wait_for_statechange();*/ }
-	}
-
-	/* Set the rotation of the brush back to what it was before any rake */
-	set_tex_angle(sd, offsetRot);
-	
-	if(smooth_stroke) {
-		sculpt_stroke_apply_all(sd, ss->stroke);
-		calc_damaged_verts(ss, a);
-		BLI_freelistN(&ss->damaged_rects);
-	}
-
-	//if(a->layer_disps) MEM_freeN(a->layer_disps);
-	//if(a->mesh_store) MEM_freeN(a->mesh_store);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list