[Bf-blender-cvs] [f292199] temp_display_optimization: Merge branch 'master' into temp_display_optimization

Antony Riakiotakis noreply at git.blender.org
Tue Jul 14 16:04:02 CEST 2015


Commit: f2921994032f4ffa840884a9483e13aa7998c59d
Author: Antony Riakiotakis
Date:   Tue Jul 14 15:58:39 2015 +0200
Branches: temp_display_optimization
https://developer.blender.org/rBf2921994032f4ffa840884a9483e13aa7998c59d

Merge branch 'master' into temp_display_optimization

Conflicts:
	source/blender/blenkernel/intern/cdderivedmesh.c
	source/blender/blenkernel/intern/subsurf_ccg.c

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/cdderivedmesh.c
index ad83fd3,37c3376..4752332
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@@ -471,15 -471,14 +471,15 @@@ static void cdDM_drawFacesTex_common(De
  {
  	CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
  	const MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
- 	MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
+ 	MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
  	MCol *mcol;
 -	int i;
 -	int colType, startFace = 0;
 +	int i, orig;
 +	int colType, start_element;
  	bool use_tface = (uvflag & DM_DRAW_USE_ACTIVE_UV) != 0;
 -	int tottri;
 +	int totpoly;
  	int next_actualFace;
 -	
 +	int mat_index;
 +	int tot_element;
  
  	/* double lookup */
  	const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
@@@ -527,76 -525,76 +527,84 @@@
  	if (mcol) {
  		GPU_color_setup(dm, colType);
  	}
 -	
 -	tottri = dm->drawObject->tot_triangle_point / 3;
 -	next_actualFace = dm->drawObject->triangle_to_mface[0];
 -	
 +		
  	glShadeModel(GL_SMOOTH);
  	/* lastFlag = 0; */ /* UNUSED */
 -	for (i = 0; i < tottri; i++) {
 -		int actualFace = next_actualFace;
 -		DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
 -		int flush = 0;
 -		
 -		if (i != tottri - 1)
 -			next_actualFace = dm->drawObject->triangle_to_mface[i + 1];
 -
 -		if (drawParams) {
 -			MTexPoly *tp = NULL;
 -			if (use_tface && mtexpoly && index_mf_to_mpoly) {
 -				int actualFace_poly = index_mf_to_mpoly[actualFace];
 -				if (actualFace_poly != ORIGINDEX_NONE) {
 -					tp = &mtexpoly[actualFace_poly];
 +	for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) {
 +		GPUBufferMaterial *bufmat = dm->drawObject->materials + mat_index;
 +		next_actualFace = bufmat->polys[0];
 +		totpoly = bufmat->totpolys;
 +
 +		tot_element = 0;
 +		start_element = bufmat->start;
 +
 +		for (i = 0; i < totpoly; i++) {
 +			int actualFace = bufmat->polys[i];
 +			DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
 +			int flush = 0;
 +
 +			if (i != totpoly - 1)
 +				next_actualFace = bufmat->polys[i + 1];
 +
 +			if (drawParams) {
- 				draw_option = drawParams(use_tface && tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr);
++				MTexPoly *tp = NULL;
++				if (use_tface && mtexpoly && index_mf_to_mpoly) {
++					int actualFace_poly = index_mf_to_mpoly[actualFace];
++					if (actualFace_poly != ORIGINDEX_NONE) {
++						tp = &mtexpoly[actualFace_poly];
++					}
+ 				}
 -			}
+ 
 -			draw_option = drawParams(tp, (mcol != NULL), mf[actualFace].mat_nr);
 -		}
 -		else {
 -			if (index_mf_to_mpoly) {
 -				const int orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace);
 -				if (orig == ORIGINDEX_NONE) {
 -					/* XXX, this is not really correct
 -							 * it will draw the previous faces context for this one when we don't know its settings.
 -							 * but better then skipping it altogether. - campbell */
 -					draw_option = DM_DRAW_OPTION_NORMAL;
++				draw_option = drawParams(tp, (mcol != NULL), mf[actualFace].mat_nr);
 +			}
 +			else {
 +				if (index_mf_to_mpoly) {
 +					orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace);
 +					if (orig == ORIGINDEX_NONE) {
 +						/* XXX, this is not really correct
 +						 * it will draw the previous faces context for this one when we don't know its settings.
 +						 * but better then skipping it altogether. - campbell */
 +						draw_option = DM_DRAW_OPTION_NORMAL;
 +					}
 +					else if (drawParamsMapped) {
 +						draw_option = drawParamsMapped(userData, orig, mf[actualFace].mat_nr);
 +					}
  				}
  				else if (drawParamsMapped) {
 -					draw_option = drawParamsMapped(userData, orig, mf[actualFace].mat_nr);
 +					draw_option = drawParamsMapped(userData, actualFace, mf[actualFace].mat_nr);
  				}
  			}
 -			else if (drawParamsMapped) {
 -				draw_option = drawParamsMapped(userData, actualFace, mf[actualFace].mat_nr);
 +
 +			/* flush buffer if current triangle isn't drawable or it's last triangle */
 +			flush = (draw_option == DM_DRAW_OPTION_SKIP) || (i == totpoly - 1);
 +
 +			if (!flush && compareDrawOptions) {
 +				/* also compare draw options and flush buffer if they're different
 +				 * need for face selection highlight in edit mode */
 +				flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
  			}
 -		}
 -		
 -		/* flush buffer if current triangle isn't drawable or it's last triangle */
 -		flush = (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1);
 -		
 -		if (!flush && compareDrawOptions) {
 -			/* also compare draw options and flush buffer if they're different
 -					 * need for face selection highlight in edit mode */
 -			flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
 -		}
 -		
 -		if (flush) {
 -			int first = startFace * 3;
 -			/* Add one to the length if we're drawing at the end of the array */
 -			int count = (i - startFace + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3;
 -			
 -			if (count) {
 -				if (mcol && draw_option != DM_DRAW_OPTION_NO_MCOL)
 -					GPU_color_switch(1);
 -				else
 -					GPU_color_switch(0);
 -				
 -				glDrawArrays(GL_TRIANGLES, first, count);
 +
 +			if (flush) {
 +				if (draw_option != DM_DRAW_OPTION_SKIP)
 +					tot_element += mf[actualFace].v4 ? 6 : 3;
 +
 +				if (tot_element) {
 +					if (mcol && draw_option != DM_DRAW_OPTION_NO_MCOL)
 +						GPU_color_switch(1);
 +					else
 +						GPU_color_switch(0);
 +
 +					GPU_buffer_draw_elements(dm->drawObject->triangles, GL_TRIANGLES, start_element, tot_element);
 +				}
 +
 +				start_element = tot_element;
 +			}
 +			else {
 +				tot_element += mf[actualFace].v4 ? 6 : 3;
  			}
 -			
 -			startFace = i + 1;
  		}
  	}
 -	
 +
  	GPU_buffer_unbind();
  	glShadeModel(GL_FLAT);
  	
diff --cc source/blender/blenkernel/intern/subsurf_ccg.c
index a687425,cc68022..733cb15
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@@ -2636,84 -2253,207 +2636,90 @@@ static void ccgDM_drawFacesTex_common(D
  		mcol = dm->getTessFaceDataArray(dm, colType);
  	}
  
 -	totface = ccgSubSurf_getNumFaces(ss);
 -
 -	if (flag & DM_DRAW_USE_TEXPAINT_UV) {
 -		int stencil = CustomData_get_stencil_layer(&dm->faceData, CD_MTFACE);
 -		tf_stencil_base = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, stencil);
 +	GPU_vertex_setup(dm);
 +	GPU_normal_setup(dm);
 +	GPU_triangle_setup(dm);
 +	if (flag & DM_DRAW_USE_TEXPAINT_UV)
 +		GPU_texpaint_uv_setup(dm);
 +	else
 +		GPU_uv_setup(dm);
 +	if (mcol) {
 +		GPU_color_setup(dm, colType);
  	}
  
 -	for (i = 0; i < totface; i++) {
 -		CCGFace *f = ccgdm->faceMap[i].face;
 -		int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
 -		int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
 -		int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
 -		unsigned char *cp = NULL;
 -		short (*ln)[4][3] = NULL;
 -		int mat_nr;
 +	next_actualFace = 0;
  
 -		if (faceFlags) {
 -			drawSmooth = (lnors || (faceFlags[origIndex].flag & ME_SMOOTH));
 -			mat_nr = faceFlags[origIndex].mat_nr;
 -		}
 -		else {
 -			drawSmooth = 1;
 -			mat_nr = 0;
 -		}
 +	glShadeModel(GL_SMOOTH);
 +	/* lastFlag = 0; */ /* UNUSED */
 +	for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) {
 +		GPUBufferMaterial *bufmat = dm->drawObject->materials + mat_index;
 +		next_actualFace = bufmat->polys[0];
 +		totpoly = bufmat->totpolys;
  
 -		/* texture painting, handle the correct uv layer here */
 -		if (flag & DM_DRAW_USE_TEXPAINT_UV) {
 -			if (mat_nr != mat_nr_cache) {
 -				tf_base = DM_paint_uvlayer_active_get(dm, mat_nr);
 +		tot_element = 0;
 +		start_element = bufmat->start;
  
 -				mat_nr_cache = mat_nr;
 +		for (i = 0; i < totpoly; i++) {
 +			int polyindex = bufmat->polys[i];
 +			CCGFace *f = ccgdm->faceMap[polyindex].face;
 +			int numVerts = ccgSubSurf_getFaceNumVerts(f);
 +			int index = ccgDM_getFaceMapIndex(ss, f);
 +			int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
 +			int mat_nr;
 +			int facequads = numVerts * gridFaces * gridFaces;
 +			int actualFace = ccgdm->faceMap[polyindex].startFace;
 +
 +			if (i != totpoly - 1) {
 +				polyindex = bufmat->polys[i + 1];
 +				next_actualFace = ccgdm->faceMap[polyindex].startFace;
  			}
  
 -			tf = tf_base ? tf_base + gridOffset : NULL;
 -			tf_stencil = tf_stencil_base ? tf_stencil_base + gridOffset : NULL;
 -			gridOffset += gridFaces * gridFaces * numVerts;
 -		}
 -
 -		if (drawParams) {
 -			MTexPoly tpoly;
 -			if (tf) {
 -				ME_MTEXFACE_CPY(&tpoly, tf);
 +			if (faceFlags) {
 +				mat_nr = faceFlags[origIndex].mat_nr;
 +			}
 +			else {
 +				mat_nr = 0;
  			}
 -			draw_option = drawParams(tf ? &tpoly : NULL, (mcol != NULL), mat_nr);
 -		}
 -		else if (index != ORIGINDEX_NONE)
 -			draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index, mat_nr) : DM_DRAW_OPTION_NORMAL;
 -		else
 -			draw_option = GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
 -
 -		if (lnors) {
 -			ln = lnors;
 -			lnors += gridFaces * gridFaces * numVerts;
 -		}
 -
 -		if (draw_option == DM_DRAW_OPTION_SKIP) {
 -			if (tf) tf += gridFaces * gridFaces * numVerts;
 -			if (mcol) mcol += gridFaces * gridFaces * numVerts * 4;
 -			continue;
 -		}
 -
 -		/* flag 1 == use vertex colors */
 -		if (mcol) {
 -			if (draw_option != DM_DRAW_OPTION_NO_MCOL)
 -				cp = (unsigned char *)mcol;
 -			mcol += gridFaces * gridFaces * numVerts * 4;
 -		}
 -
 -		for (S = 0; S < numVerts; S++) {
 -			CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
 -			CCGElem *a, *b;
 -
 -			if (ln) {
 -				glShadeModel(GL_SMOOTH);
 -				glBegin(GL_QUADS);
 -				for (y = 0; y < gridFaces; y++) {
 -					for (x = 0; x < gridFaces; x++) {
 -						float *a_co = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
 -						float *b_co = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
 -						float *c_co = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
 -						float *d_co = CCG_grid_elem_co(&key, faceGridData, x, y + 1);
 -
 -						if (tf) glTexCoord2fv(tf->uv[1]);
 -						if (tf_stencil) glMultiT

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list