[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37179] branches/soc-2011-onion: Revision: 29779
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Jun 4 18:04:31 CEST 2011
Revision: 37179
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37179
Author: jwilkins
Date: 2011-06-04 16:04:31 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Revision: 29779
Author: nicholasbishop
Date: 4:12:32 PM, Monday, June 28, 2010
Message:
Multires+mask bugfixes:
* Crash when changing modes from sculptmode
* Crash when adding multires modifier on a mesh that already has paintmask layers
* Smooth brush eating holes in a mesh without a paintmask layer
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.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-29585,29596,29662-29663
/trunk/blender:36833-37054
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29585,29596,29662-29663,29779
/trunk/blender:36833-37054
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c 2011-06-04 15:58:25 UTC (rev 37178)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c 2011-06-04 16:04:31 UTC (rev 37179)
@@ -321,7 +321,7 @@
}
}
-static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl)
+static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, GridKey *gridkey, int lvl)
{
int i;
@@ -334,6 +334,7 @@
for(i = 0; i < me->totface; ++i) {
int nvert = (me->mface[i].v4)? 4: 3;
int totelem = multires_grid_tot[lvl]*nvert;
+ int pmask_totlayer;
CustomData old, *cd = cd_facegrids + i;
/* Resize all existing layers */
@@ -342,6 +343,16 @@
CustomData_copy(&old, cd, ~0, CD_CALLOC, totelem);
CustomData_free(&old, 0);
CustomData_set_num_grid_elements(cd, totelem);
+
+ /* If multires modifier is added after mask layers were
+ created, update the grids to have those layers as well */
+ if(gridkey) {
+ pmask_totlayer = CustomData_number_of_layers(cd, CD_PAINTMASK);
+ while(pmask_totlayer < gridkey->mask) {
+ CustomData_add_layer(cd, CD_PAINTMASK, CD_CALLOC, NULL, totelem);
+ ++pmask_totlayer;
+ }
+ }
}
/* This will be replaced when we do CD_DISPS */
@@ -707,7 +718,7 @@
ccgSubSurf_updateLevels(ss, lvl, NULL, 0);
/* reallocate displacements */
- multires_reallocate_mdisps(me, mdisps, totlvl);
+ multires_reallocate_mdisps(me, mdisps, NULL, totlvl);
/* compute displacements */
multiresModifier_disp_run(highdm, me, CALC_DISPS, subGridData, totlvl);
@@ -720,7 +731,7 @@
}
else {
/* only reallocate, nothing to upsample */
- multires_reallocate_mdisps(me, mdisps, totlvl);
+ multires_reallocate_mdisps(me, mdisps, NULL, totlvl);
}
multires_set_tot_level(ob, mmd, totlvl);
@@ -814,16 +825,21 @@
MDisps *mdisp = &mdisps[i];
int S, x, y, j, gIndex = gridOffset[i];
- /* when adding new faces in edit mode, need to allocate disps */
- if(!mdisp->disps)
+ /* when adding new faces in edit mode, need to allocate disps;
+ may need to allocate paintmask storage after adding multires as well */
+ if(!mdisp->disps ||
+ (gridkey->mask &&
+ (!stored_grids ||
+ CustomData_number_of_layers(&stored_grids[i], CD_PAINTMASK) != gridkey->mask)))
#pragma omp critical
{
- multires_reallocate_mdisps(me, mdisps, totlvl);
+ multires_reallocate_mdisps(me, mdisps, gridkey, totlvl);
}
/* Check masks */
- assert(stored_grids);
- assert(CustomData_number_of_layers(&stored_grids[i], CD_PAINTMASK) == gridkey->mask);
+ assert(gridkey->mask == 0 || stored_grids);
+ if(stored_grids)
+ assert(CustomData_number_of_layers(&stored_grids[i], CD_PAINTMASK) == gridkey->mask);
for(S = 0; S < numVerts; ++S, ++gIndex) {
DMGridData *grid = gridData[gIndex];
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-04 15:58:25 UTC (rev 37178)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c 2011-06-04 16:04:31 UTC (rev 37179)
@@ -1313,7 +1313,9 @@
fno= GRIDELEM_NO_AT(data, index, gridkey);
if(sculpt_brush_test(&test, co)) {
- const float fade = bstrength*tex_strength(ss, brush, co, *GRIDELEM_MASK_AT(data, x + y*gridsize, gridkey), test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, ss->cache->view_normal, origno[k]);
+ float mask = (gridkey->mask ?
+ *GRIDELEM_MASK_AT(data, x + y*gridsize, gridkey) : 0);
+ float fade = bstrength*tex_strength(ss, brush, co, mask, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, ss->cache->view_normal, origno[k]);
float *avg, val[3];
float n;
More information about the Bf-blender-cvs
mailing list