style cleanup: mainly sculpt/whitespace

This commit is contained in:
2012-05-11 08:05:47 +00:00
parent dabc22826d
commit ce17c35240
25 changed files with 1249 additions and 1199 deletions

View File

@@ -66,25 +66,25 @@ typedef enum {
} MultiresFlags; } MultiresFlags;
struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm, struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
struct MultiresModifierData *mmd, struct MultiresModifierData *mmd,
struct Object *ob, struct Object *ob,
MultiresFlags flags); MultiresFlags flags);
struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
struct ModifierData *lastmd); struct ModifierData *lastmd);
struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, int use_first); struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, int use_first);
struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob); struct Object *ob);
void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob);
void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob,
int updateblock, int simple); int updateblock, int simple);
int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd, int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *dst, struct Object *src); struct Object *dst, struct Object *src);
int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd, int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct DerivedMesh *srcdm); struct Object *ob, struct DerivedMesh *srcdm);
int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd, int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct ModifierData *md); struct Object *ob, struct ModifierData *md);
void multires_stitch_grids(struct Object *); void multires_stitch_grids(struct Object *);

View File

@@ -67,11 +67,11 @@ int paint_vertsel_test(struct Object *ob);
/* partial visibility */ /* partial visibility */
int paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert); int paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert);
int paint_is_grid_face_hidden(const unsigned int *grid_hidden, int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
int gridsize, int x, int y); int gridsize, int x, int y);
/* paint masks */ /* paint masks */
float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level, float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level,
unsigned x, unsigned y); unsigned x, unsigned y);
/* Session data (mode-specific) */ /* Session data (mode-specific) */

View File

@@ -64,10 +64,10 @@ typedef enum {
} SubsurfFlags; } SubsurfFlags;
struct DerivedMesh *subsurf_make_derived_from_derived( struct DerivedMesh *subsurf_make_derived_from_derived(
struct DerivedMesh *dm, struct DerivedMesh *dm,
struct SubsurfModifierData *smd, struct SubsurfModifierData *smd,
float (*vertCos)[3], float (*vertCos)[3],
SubsurfFlags flags); SubsurfFlags flags);
void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]); void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]);
@@ -79,13 +79,13 @@ int ccg_gridsize(int level);
int ccg_factor(int low_level, int high_level); int ccg_factor(int low_level, int high_level);
void subsurf_copy_grid_hidden(struct DerivedMesh *dm, void subsurf_copy_grid_hidden(struct DerivedMesh *dm,
const struct MPoly *mpoly, const struct MPoly *mpoly,
struct MVert *mvert, struct MVert *mvert,
const struct MDisps *mdisps); const struct MDisps *mdisps);
void subsurf_copy_grid_paint_mask(struct DerivedMesh *dm, void subsurf_copy_grid_paint_mask(struct DerivedMesh *dm,
const struct MPoly *mpoly, float *paint_mask, const struct MPoly *mpoly, float *paint_mask,
const struct GridPaintMask *grid_paint_mask); const struct GridPaintMask *grid_paint_mask);
typedef enum MultiresModifiedFlags { typedef enum MultiresModifiedFlags {
/* indicates the grids have been sculpted on, so MDisps /* indicates the grids have been sculpted on, so MDisps
@@ -104,10 +104,10 @@ typedef struct CCGDerivedMesh {
int freeSS; int freeSS;
int drawInteriorEdges, useSubsurfUv; int drawInteriorEdges, useSubsurfUv;
struct {int startVert; struct CCGVert *vert;} *vertMap; struct {int startVert; struct CCGVert *vert; } *vertMap;
struct {int startVert; int startEdge; struct CCGEdge *edge;} *edgeMap; struct {int startVert; int startEdge; struct CCGEdge *edge; } *edgeMap;
struct {int startVert; int startEdge; struct {int startVert; int startEdge;
int startFace; struct CCGFace *face;} *faceMap; int startFace; struct CCGFace *face; } *faceMap;
short *edgeFlags; short *edgeFlags;
struct DMFlagMat *faceFlags; struct DMFlagMat *faceFlags;

View File

@@ -245,7 +245,7 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
return cddm->mvert == me->mvert || ob->sculpt->kb; return cddm->mvert == me->mvert || ob->sculpt->kb;
} }
static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
{ {
CDDerivedMesh *cddm = (CDDerivedMesh *) dm; CDDerivedMesh *cddm = (CDDerivedMesh *) dm;

View File

@@ -97,10 +97,10 @@ void multires_customdata_delete(Mesh *me)
CustomData_external_remove(&me->ldata, &me->id, CustomData_external_remove(&me->ldata, &me->id,
CD_MDISPS, me->totloop); CD_MDISPS, me->totloop);
CustomData_free_layer_active(&me->ldata, CD_MDISPS, CustomData_free_layer_active(&me->ldata, CD_MDISPS,
me->totloop); me->totloop);
CustomData_free_layer_active(&me->ldata, CD_GRID_PAINT_MASK, CustomData_free_layer_active(&me->ldata, CD_GRID_PAINT_MASK,
me->totloop); me->totloop);
} }
} }
@@ -108,7 +108,7 @@ void multires_customdata_delete(Mesh *me)
static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
int lo_level, int lo_level,
int hi_level, int hi_level,
/* assumed to be at hi_level (or /* assumed to be at hi_level (or
* null) */ * null) */
BLI_bitmap prev_hidden) BLI_bitmap prev_hidden)
@@ -585,8 +585,8 @@ static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA,
for (j = 0, y = 0; y < keyB->grid_size; y++) for (j = 0, y = 0; y < keyB->grid_size; y++)
for (x = 0; x < keyB->grid_size; x++, j++) for (x = 0; x < keyB->grid_size; x++, j++)
memcpy(CCG_elem_offset_co(keyA, gridA, y * skip * keyA->grid_size + x * skip), memcpy(CCG_elem_offset_co(keyA, gridA, y * skip * keyA->grid_size + x * skip),
CCG_elem_offset_co(keyB, gridB, j), CCG_elem_offset_co(keyB, gridB, j),
sizeof(float) * keyA->num_layers); sizeof(float) * keyA->num_layers);
} }
else { else {
skip = (keyB->grid_size - 1) / (keyA->grid_size - 1); skip = (keyB->grid_size - 1) / (keyA->grid_size - 1);
@@ -594,8 +594,8 @@ static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA,
for (j = 0, y = 0; y < keyA->grid_size; y++) for (j = 0, y = 0; y < keyA->grid_size; y++)
for (x = 0; x < keyA->grid_size; x++, j++) for (x = 0; x < keyA->grid_size; x++, j++)
memcpy(CCG_elem_offset_co(keyA, gridA, j), memcpy(CCG_elem_offset_co(keyA, gridA, j),
CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x*skip), CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x * skip),
sizeof(float) * keyA->num_layers); sizeof(float) * keyA->num_layers);
} }
} }
@@ -606,13 +606,13 @@ static void multires_grid_paint_mask_downsample(GridPaintMask *gpm, int level)
if (level < gpm->level) { if (level < gpm->level) {
int gridsize = ccg_gridsize(level); int gridsize = ccg_gridsize(level);
float *data = MEM_callocN(sizeof(float) * gridsize * gridsize, float *data = MEM_callocN(sizeof(float) * gridsize * gridsize,
"multires_grid_paint_mask_downsample"); "multires_grid_paint_mask_downsample");
int x, y; int x, y;
for (y = 0; y < gridsize; y++) { for (y = 0; y < gridsize; y++) {
for (x = 0; x < gridsize; x++) { for (x = 0; x < gridsize; x++) {
data[y * gridsize + x] = data[y * gridsize + x] =
paint_grid_paint_mask(gpm, level, x, y); paint_grid_paint_mask(gpm, level, x, y);
} }
} }
@@ -905,7 +905,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
cddm = CDDM_from_mesh(me, NULL); cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH); DM_set_only_copy(cddm, CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE); highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE);
ss = ((CCGDerivedMesh*)highdm)->ss; ss = ((CCGDerivedMesh *)highdm)->ss;
/* create multires DM from original mesh at low level */ /* create multires DM from original mesh at low level */
lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, TRUE); lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, TRUE);
@@ -924,7 +924,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
for (i = 0; i < numGrids; ++i) { for (i = 0; i < numGrids; ++i) {
/* backup subsurf grids */ /* backup subsurf grids */
subGridData[i] = MEM_callocN(highGridKey.elem_size * highGridSize * highGridSize, "subGridData"); subGridData[i] = MEM_callocN(highGridKey.elem_size * highGridSize * highGridSize, "subGridData");
memcpy(subGridData[i], highGridData[i], highGridKey.elem_size*highGridSize * highGridSize); memcpy(subGridData[i], highGridData[i], highGridKey.elem_size * highGridSize * highGridSize);
/* overwrite with current displaced grids */ /* overwrite with current displaced grids */
multires_copy_dm_grid(highGridData[i], lowGridData[i], &highGridKey, &lowGridKey); multires_copy_dm_grid(highGridData[i], lowGridData[i], &highGridKey, &lowGridKey);
@@ -1022,7 +1022,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
gridData = dm->getGridData(dm); gridData = dm->getGridData(dm);
gridOffset = dm->getGridOffset(dm); gridOffset = dm->getGridOffset(dm);
dm->getGridKey(dm, &key); dm->getGridKey(dm, &key);
subGridData = (oldGridData) ? oldGridData: gridData; subGridData = (oldGridData) ? oldGridData : gridData;
dGridSize = multires_side_tot[totlvl]; dGridSize = multires_side_tot[totlvl];
dSkip = (dGridSize - 1) / (gridSize - 1); dSkip = (dGridSize - 1) / (gridSize - 1);
@@ -1069,7 +1069,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
float *co = CCG_grid_elem_co(&key, grid, x, y); float *co = CCG_grid_elem_co(&key, grid, x, y);
float *sco = CCG_grid_elem_co(&key, subgrid, x, y); float *sco = CCG_grid_elem_co(&key, subgrid, x, y);
float *no = CCG_grid_elem_no(&key, subgrid, x, y); float *no = CCG_grid_elem_no(&key, subgrid, x, y);
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
float mat[3][3], tx[3], ty[3], disp[3], d[3], mask; float mat[3][3], tx[3], ty[3], disp[3], d[3], mask;
/* construct tangent space matrix */ /* construct tangent space matrix */
@@ -1110,21 +1110,21 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
if (gpm) { if (gpm) {
switch (op) { switch (op) {
case APPLY_DISPLACEMENTS: case APPLY_DISPLACEMENTS:
/* Copy mask from gpm to DM */ /* Copy mask from gpm to DM */
*CCG_grid_elem_mask(&key, grid, x, y) = *CCG_grid_elem_mask(&key, grid, x, y) =
paint_grid_paint_mask(gpm, key.level, x, y); paint_grid_paint_mask(gpm, key.level, x, y);
break; break;
case CALC_DISPLACEMENTS: case CALC_DISPLACEMENTS:
/* Copy mask from DM to gpm */ /* Copy mask from DM to gpm */
mask = *CCG_grid_elem_mask(&key, grid, x, y); mask = *CCG_grid_elem_mask(&key, grid, x, y);
gpm->data[y * gridSize + x] = CLAMPIS(mask, 0, 1); gpm->data[y * gridSize + x] = CLAMPIS(mask, 0, 1);
break; break;
case ADD_DISPLACEMENTS: case ADD_DISPLACEMENTS:
/* Add mask displacement to gpm */ /* Add mask displacement to gpm */
gpm->data[y * gridSize + x] += gpm->data[y * gridSize + x] +=
*CCG_grid_elem_mask(&key, grid, x, y); *CCG_grid_elem_mask(&key, grid, x, y);
break; break;
} }
} }
} }
@@ -1171,7 +1171,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
DM_set_only_copy(cddm, CD_MASK_BAREMESH); DM_set_only_copy(cddm, CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE); highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE);
ss = ((CCGDerivedMesh*)highdm)->ss; ss = ((CCGDerivedMesh *)highdm)->ss;
/* create multires DM from original mesh and displacements */ /* create multires DM from original mesh and displacements */
lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, TRUE); lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, TRUE);
@@ -1189,19 +1189,19 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
BLI_assert(highGridKey.elem_size == lowGridKey.elem_size); BLI_assert(highGridKey.elem_size == lowGridKey.elem_size);
subGridData = MEM_callocN(sizeof(CCGElem*)*numGrids, "subGridData*"); subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*");
diffGrid = MEM_callocN(lowGridKey.elem_size*lowGridSize*lowGridSize, "diff"); diffGrid = MEM_callocN(lowGridKey.elem_size * lowGridSize * lowGridSize, "diff");
for (i = 0; i < numGrids; ++i) { for (i = 0; i < numGrids; ++i) {
/* backup subsurf grids */ /* backup subsurf grids */
subGridData[i] = MEM_callocN(highGridKey.elem_size*highGridSize*highGridSize, "subGridData"); subGridData[i] = MEM_callocN(highGridKey.elem_size * highGridSize * highGridSize, "subGridData");
memcpy(subGridData[i], highGridData[i], highGridKey.elem_size*highGridSize*highGridSize); memcpy(subGridData[i], highGridData[i], highGridKey.elem_size * highGridSize * highGridSize);
/* write difference of subsurf and displaced low level into high subsurf */ /* write difference of subsurf and displaced low level into high subsurf */
for (j = 0; j < lowGridSize*lowGridSize; ++j) { for (j = 0; j < lowGridSize * lowGridSize; ++j) {
sub_v4_v4v4(CCG_elem_offset_co(&lowGridKey, diffGrid, j), sub_v4_v4v4(CCG_elem_offset_co(&lowGridKey, diffGrid, j),
CCG_elem_offset_co(&lowGridKey, gridData[i], j), CCG_elem_offset_co(&lowGridKey, gridData[i], j),
CCG_elem_offset_co(&lowGridKey, lowGridData[i], j)); CCG_elem_offset_co(&lowGridKey, lowGridData[i], j));
} }
multires_copy_dm_grid(highGridData[i], diffGrid, &highGridKey, &lowGridKey); multires_copy_dm_grid(highGridData[i], diffGrid, &highGridKey, &lowGridKey);
@@ -1297,18 +1297,18 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, FALSE); ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, FALSE);
subsurf = subsurf_dm_create_local(ob, dm, totlvl, subsurf = subsurf_dm_create_local(ob, dm, totlvl,
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0); mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0);
numGrids = subsurf->getNumGrids(subsurf); numGrids = subsurf->getNumGrids(subsurf);
gridSize = subsurf->getGridSize(subsurf); gridSize = subsurf->getGridSize(subsurf);
gridData = subsurf->getGridData(subsurf); gridData = subsurf->getGridData(subsurf);
subsurf->getGridKey(subsurf, &key); subsurf->getGridKey(subsurf, &key);
subGridData = MEM_callocN(sizeof(CCGElem*)*numGrids, "subGridData*"); subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*");
for (i = 0; i < numGrids; i++) { for (i = 0; i < numGrids; i++) {
subGridData[i] = MEM_callocN(key.elem_size*gridSize*gridSize, "subGridData"); subGridData[i] = MEM_callocN(key.elem_size * gridSize * gridSize, "subGridData");
memcpy(subGridData[i], gridData[i], key.elem_size*gridSize*gridSize); memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize);
} }
/*numGrids = ccgdm->dm->getNumGrids((DerivedMesh*)ccgdm);*/ /*UNUSED*/ /*numGrids = ccgdm->dm->getNumGrids((DerivedMesh*)ccgdm);*/ /*UNUSED*/
@@ -1344,7 +1344,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
for (y = 0; y < gridSize; y++) { for (y = 0; y < gridSize; y++) {
for (x = 0; x < gridSize; x++) { for (x = 0; x < gridSize; x++) {
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
float *no = CCG_grid_elem_no(&key, subgrid, x, y); float *no = CCG_grid_elem_no(&key, subgrid, x, y);
float *co = CCG_grid_elem_co(&key, subgrid, x, y); float *co = CCG_grid_elem_co(&key, subgrid, x, y);
float mat[3][3], tx[3], ty[3], dco[3]; float mat[3][3], tx[3], ty[3], dco[3];
@@ -1422,9 +1422,9 @@ void multires_stitch_grids(Object *ob)
} }
DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm,
MultiresModifierData *mmd, MultiresModifierData *mmd,
Object *ob, Object *ob,
MultiresFlags flags) MultiresFlags flags)
{ {
Mesh *me = ob->data; Mesh *me = ob->data;
DerivedMesh *result; DerivedMesh *result;
@@ -1438,9 +1438,9 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm,
return dm; return dm;
result = subsurf_dm_create_local(ob, dm, lvl, result = subsurf_dm_create_local(ob, dm, lvl,
mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges,
mmd->flags & eMultiresModifierFlag_PlainUv, mmd->flags & eMultiresModifierFlag_PlainUv,
flags & MULTIRES_ALLOC_PAINT_MASK); flags & MULTIRES_ALLOC_PAINT_MASK);
if (!(flags & MULTIRES_USE_LOCAL_MMD)) { if (!(flags & MULTIRES_USE_LOCAL_MMD)) {
ccgdm = (CCGDerivedMesh *)result; ccgdm = (CCGDerivedMesh *)result;
@@ -1458,11 +1458,11 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm,
gridData = result->getGridData(result); gridData = result->getGridData(result);
result->getGridKey(result, &key); result->getGridKey(result, &key);
subGridData = MEM_callocN(sizeof(CCGElem*)*numGrids, "subGridData*"); subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*");
for (i = 0; i < numGrids; i++) { for (i = 0; i < numGrids; i++) {
subGridData[i] = MEM_callocN(key.elem_size*gridSize*gridSize, "subGridData"); subGridData[i] = MEM_callocN(key.elem_size * gridSize * gridSize, "subGridData");
memcpy(subGridData[i], gridData[i], key.elem_size*gridSize*gridSize); memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize);
} }
multires_set_tot_mdisps(me, mmd->totlvl); multires_set_tot_mdisps(me, mmd->totlvl);
@@ -1483,7 +1483,7 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm,
} }
/**** Old Multires code **** /**** Old Multires code ****
***************************/ ***************************/
/* Adapted from sculptmode.c */ /* Adapted from sculptmode.c */
void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v) void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v)
@@ -2144,7 +2144,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL; DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
CCGElem **gridData, **subGridData; CCGElem **gridData, **subGridData;
CCGKey key; CCGKey key;
Mesh *me = (Mesh*)ob->data; Mesh *me = (Mesh *)ob->data;
MPoly *mpoly = me->mpoly; MPoly *mpoly = me->mpoly;
/* MLoop *mloop = me->mloop; */ /* UNUSED */ /* MLoop *mloop = me->mloop; */ /* UNUSED */
MDisps *mdisps; MDisps *mdisps;
@@ -2207,7 +2207,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
float *co = CCG_grid_elem_co(&key, grid, x, y); float *co = CCG_grid_elem_co(&key, grid, x, y);
float *sco = CCG_grid_elem_co(&key, subgrid, x, y); float *sco = CCG_grid_elem_co(&key, subgrid, x, y);
float *no = CCG_grid_elem_no(&key, grid, x, y); float *no = CCG_grid_elem_no(&key, grid, x, y);
float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; float *data = dispgrid[dGridSize * y * dSkip + x * dSkip];
float mat[3][3], tx[3], ty[3], disp[3]; float mat[3][3], tx[3], ty[3], disp[3];
/* construct tangent space matrix */ /* construct tangent space matrix */

View File

@@ -60,19 +60,19 @@ Paint *paint_get_active(Scene *sce)
if (sce->basact && sce->basact->object) { if (sce->basact && sce->basact->object) {
switch (sce->basact->object->mode) { switch (sce->basact->object->mode) {
case OB_MODE_SCULPT: case OB_MODE_SCULPT:
return &ts->sculpt->paint; return &ts->sculpt->paint;
case OB_MODE_VERTEX_PAINT: case OB_MODE_VERTEX_PAINT:
return &ts->vpaint->paint; return &ts->vpaint->paint;
case OB_MODE_WEIGHT_PAINT: case OB_MODE_WEIGHT_PAINT:
return &ts->wpaint->paint; return &ts->wpaint->paint;
case OB_MODE_TEXTURE_PAINT: case OB_MODE_TEXTURE_PAINT:
return &ts->imapaint.paint;
case OB_MODE_EDIT:
if (ts->use_uv_sculpt)
return &ts->uvsculpt->paint;
else
return &ts->imapaint.paint; return &ts->imapaint.paint;
case OB_MODE_EDIT:
if (ts->use_uv_sculpt)
return &ts->uvsculpt->paint;
else
return &ts->imapaint.paint;
} }
} }
@@ -93,7 +93,7 @@ void paint_brush_set(Paint *p, Brush *br)
if (p) { if (p) {
id_us_min((ID *)p->brush); id_us_min((ID *)p->brush);
id_us_plus((ID *)br); id_us_plus((ID *)br);
p->brush= br; p->brush = br;
} }
} }
@@ -104,7 +104,7 @@ int paint_facesel_test(Object *ob)
(ob->type == OB_MESH) && (ob->type == OB_MESH) &&
(ob->data != NULL) && (ob->data != NULL) &&
(((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) &&
(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))
); );
} }
@@ -126,7 +126,7 @@ void paint_init(Paint *p, const char col[3])
/* If there's no brush, create one */ /* If there's no brush, create one */
brush = paint_brush(p); brush = paint_brush(p);
if (brush == NULL) if (brush == NULL)
brush= BKE_brush_add("Brush"); brush = BKE_brush_add("Brush");
paint_brush_set(p, brush); paint_brush_set(p, brush);
memcpy(p->paint_cursor_col, col, 3); memcpy(p->paint_cursor_col, col, 3);
@@ -146,7 +146,7 @@ void free_paint(Paint *paint)
* with paint_brush_set() */ * with paint_brush_set() */
void copy_paint(Paint *src, Paint *tar) void copy_paint(Paint *src, Paint *tar)
{ {
tar->brush= src->brush; tar->brush = src->brush;
id_us_plus((ID *)tar->brush); id_us_plus((ID *)tar->brush);
} }
@@ -155,29 +155,29 @@ void copy_paint(Paint *src, Paint *tar)
int paint_is_face_hidden(const MFace *f, const MVert *mvert) int paint_is_face_hidden(const MFace *f, const MVert *mvert)
{ {
return ((mvert[f->v1].flag & ME_HIDE) || return ((mvert[f->v1].flag & ME_HIDE) ||
(mvert[f->v2].flag & ME_HIDE) || (mvert[f->v2].flag & ME_HIDE) ||
(mvert[f->v3].flag & ME_HIDE) || (mvert[f->v3].flag & ME_HIDE) ||
(f->v4 && (mvert[f->v4].flag & ME_HIDE))); (f->v4 && (mvert[f->v4].flag & ME_HIDE)));
} }
/* returns non-zero if any of the corners of the grid /* returns non-zero if any of the corners of the grid
* face whose inner corner is at (x,y) are hidden, * face whose inner corner is at (x,y) are hidden,
* zero otherwise */ * zero otherwise */
int paint_is_grid_face_hidden(const unsigned int *grid_hidden, int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
int gridsize, int x, int y) int gridsize, int x, int y)
{ {
/* skip face if any of its corners are hidden */ /* skip face if any of its corners are hidden */
return (BLI_BITMAP_GET(grid_hidden, y * gridsize + x) || return (BLI_BITMAP_GET(grid_hidden, y * gridsize + x) ||
BLI_BITMAP_GET(grid_hidden, y * gridsize + x+1) || BLI_BITMAP_GET(grid_hidden, y * gridsize + x + 1) ||
BLI_BITMAP_GET(grid_hidden, (y+1) * gridsize + x+1) || BLI_BITMAP_GET(grid_hidden, (y + 1) * gridsize + x + 1) ||
BLI_BITMAP_GET(grid_hidden, (y+1) * gridsize + x)); BLI_BITMAP_GET(grid_hidden, (y + 1) * gridsize + x));
} }
float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level, float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level,
unsigned x, unsigned y) unsigned x, unsigned y)
{ {
int factor = ccg_factor(level, gpm->level); int factor = ccg_factor(level, gpm->level);
int gridsize = ccg_gridsize(gpm->level); int gridsize = ccg_gridsize(gpm->level);
return gpm->data[(y*factor) * gridsize + (x*factor)]; return gpm->data[(y * factor) * gridsize + (x * factor)];
} }

View File

@@ -57,7 +57,7 @@
#include "BKE_tessmesh.h" #include "BKE_tessmesh.h"
/* Util macros */ /* Util macros */
#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n")) #define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
/* Benchmark macros */ /* Benchmark macros */
#if !defined(_WIN32) && 0 #if !defined(_WIN32) && 0
@@ -79,17 +79,17 @@
#else #else
#define BENCH(a) (a) #define BENCH(a) (a)
#endif #endif
typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *co, float *normal); typedef void (*Shrinkwrap_ForeachVertexCallback)(DerivedMesh *target, float *co, float *normal);
/* get derived mesh */ /* get derived mesh */
//TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not? //TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not?
DerivedMesh *object_get_derived_final(Object *ob) DerivedMesh *object_get_derived_final(Object *ob)
{ {
Mesh *me= ob->data; Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh; BMEditMesh *em = me->edit_btmesh;
if (em) { if (em) {
@@ -111,12 +111,12 @@ void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float
void space_transform_apply(const SpaceTransform *data, float *co) void space_transform_apply(const SpaceTransform *data, float *co)
{ {
mul_v3_m4v3(co, ((SpaceTransform*)data)->local2target, co); mul_v3_m4v3(co, ((SpaceTransform *)data)->local2target, co);
} }
void space_transform_invert(const SpaceTransform *data, float *co) void space_transform_invert(const SpaceTransform *data, float *co)
{ {
mul_v3_m4v3(co, ((SpaceTransform*)data)->target2local, co); mul_v3_m4v3(co, ((SpaceTransform *)data)->target2local, co);
} }
static void space_transform_apply_normal(const SpaceTransform *data, float *no) static void space_transform_apply_normal(const SpaceTransform *data, float *no)
@@ -127,7 +127,7 @@ static void space_transform_apply_normal(const SpaceTransform *data, float *no)
static void space_transform_invert_normal(const SpaceTransform *data, float *no) static void space_transform_invert_normal(const SpaceTransform *data, float *no)
{ {
mul_mat3_m4_v3(((SpaceTransform*)data)->target2local, no); mul_mat3_m4_v3(((SpaceTransform *)data)->target2local, no);
normalize_v3(no); // TODO: could we just determine de scale value from the matrix? normalize_v3(no); // TODO: could we just determine de scale value from the matrix?
} }
@@ -142,7 +142,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
int i; int i;
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest; BVHTreeNearest nearest = NULL_BVHTreeNearest;
BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6)); BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6));
@@ -157,7 +157,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
#ifndef __APPLE__ #ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static) #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static)
#endif #endif
for (i = 0; i<calc->numVerts; ++i) { for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i]; float *co = calc->vertexCos[i];
float tmp_co[3]; float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
@@ -190,13 +190,13 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
if (nearest.index != -1) { if (nearest.index != -1) {
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
float dist = sasqrt(nearest.dist); float dist = sasqrt(nearest.dist);
if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist; if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist) / dist;
//Convert the coordinates back to mesh coordinates //Convert the coordinates back to mesh coordinates
copy_v3_v3(tmp_co, nearest.co); copy_v3_v3(tmp_co, nearest.co);
space_transform_invert(&calc->local2target, tmp_co); space_transform_invert(&calc->local2target, tmp_co);
interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation
} }
} }
@@ -230,7 +230,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
space_transform_apply_normal(transf, tmp_no); space_transform_apply_normal(transf, tmp_no);
no = tmp_no; no = tmp_no;
hit_tmp.dist *= mat4_to_scale(((SpaceTransform*)transf)->local2target); hit_tmp.dist *= mat4_to_scale(((SpaceTransform *)transf)->local2target);
} }
else { else {
co = vert; co = vert;
@@ -247,12 +247,12 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
space_transform_invert_normal(transf, hit_tmp.no); space_transform_invert_normal(transf, hit_tmp.no);
} }
if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE|MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) { if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) {
/* apply backface */ /* apply backface */
const float dot= dot_v3v3(dir, hit_tmp.no); const float dot = dot_v3v3(dir, hit_tmp.no);
if ( ((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) ||
((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f) ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f))
) { {
return FALSE; /* Ignore hit */ return FALSE; /* Ignore hit */
} }
} }
@@ -275,16 +275,16 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
int i; int i;
//Options about projection direction //Options about projection direction
const char use_normal = calc->smd->shrinkOpts; const char use_normal = calc->smd->shrinkOpts;
float proj_axis[3] = {0.0f, 0.0f, 0.0f}; float proj_axis[3] = {0.0f, 0.0f, 0.0f};
//Raycast and tree stuff //Raycast and tree stuff
BVHTreeRayHit hit; BVHTreeRayHit hit;
BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
//auxiliary target //auxiliary target
DerivedMesh *auxMesh = NULL; DerivedMesh *auxMesh = NULL;
BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh;
SpaceTransform local2aux; SpaceTransform local2aux;
//If the user doesn't allows to project in any direction of projection axis //If the user doesn't allows to project in any direction of projection axis
@@ -326,7 +326,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
#ifndef __APPLE__ #ifndef __APPLE__
#pragma omp parallel for private(i,hit) schedule(static) #pragma omp parallel for private(i,hit) schedule(static)
#endif #endif
for (i = 0; i<calc->numVerts; ++i) { for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i]; float *co = calc->vertexCos[i];
float tmp_co[3], tmp_no[3]; float tmp_co[3], tmp_no[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
@@ -399,10 +399,10 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
int i; int i;
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
BVHTreeNearest nearest = NULL_BVHTreeNearest; BVHTreeNearest nearest = NULL_BVHTreeNearest;
//Create a bvh-tree of the given target //Create a bvh-tree of the given target
BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6)); BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6));
if (treeData.tree == NULL) { if (treeData.tree == NULL) {
OUT_OF_MEMORY(); OUT_OF_MEMORY();
return; return;
@@ -417,7 +417,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
#ifndef __APPLE__ #ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static) #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
#endif #endif
for (i = 0; i<calc->numVerts; ++i) { for (i = 0; i < calc->numVerts; ++i) {
float *co = calc->vertexCos[i]; float *co = calc->vertexCos[i];
float tmp_co[3]; float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
@@ -452,16 +452,16 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
} }
else { else {
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
float dist = sasqrt( nearest.dist ); float dist = sasqrt(nearest.dist);
if (dist > FLT_EPSILON) if (dist > FLT_EPSILON)
interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist); //linear interpolation
else else
copy_v3_v3(tmp_co, nearest.co); copy_v3_v3(tmp_co, nearest.co);
} }
//Convert the coordinates back to mesh coordinates //Convert the coordinates back to mesh coordinates
space_transform_invert(&calc->local2target, tmp_co); space_transform_invert(&calc->local2target, tmp_co);
interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation
} }
} }
@@ -472,7 +472,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts)
{ {
DerivedMesh *ss_mesh = NULL; DerivedMesh *ss_mesh = NULL;
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData; ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
//remove loop dependencies on derived meshs (TODO should this be done elsewhere?) //remove loop dependencies on derived meshs (TODO should this be done elsewhere?)
@@ -519,9 +519,9 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
//Using vertexs positions/normals as if a subsurface was applied //Using vertexs positions/normals as if a subsurface was applied
if (smd->subsurfLevels) { if (smd->subsurfLevels) {
SubsurfModifierData ssmd= {{NULL}}; SubsurfModifierData ssmd = {{NULL}};
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
ssmd.levels = smd->subsurfLevels; //levels ssmd.levels = smd->subsurfLevels; //levels
ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0); ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0);
@@ -545,15 +545,15 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
switch (smd->shrinkType) { switch (smd->shrinkType) {
case MOD_SHRINKWRAP_NEAREST_SURFACE: case MOD_SHRINKWRAP_NEAREST_SURFACE:
BENCH(shrinkwrap_calc_nearest_surface_point(&calc)); BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
break; break;
case MOD_SHRINKWRAP_PROJECT: case MOD_SHRINKWRAP_PROJECT:
BENCH(shrinkwrap_calc_normal_projection(&calc)); BENCH(shrinkwrap_calc_normal_projection(&calc));
break; break;
case MOD_SHRINKWRAP_NEAREST_VERTEX: case MOD_SHRINKWRAP_NEAREST_VERTEX:
BENCH(shrinkwrap_calc_nearest_vertex(&calc)); BENCH(shrinkwrap_calc_nearest_vertex(&calc));
break; break;
} }
} }

View File

@@ -117,7 +117,7 @@ typedef enum {
} CCGFlags; } CCGFlags;
static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels,
int numLayers, CCGFlags flags) int numLayers, CCGFlags flags)
{ {
CCGMeshIFC ifc; CCGMeshIFC ifc;
CCGSubSurf *ccgSS; CCGSubSurf *ccgSS;
@@ -152,9 +152,9 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels,
ifc.numLayers = numLayers; ifc.numLayers = numLayers;
ifc.vertDataSize = sizeof(float) * numLayers; ifc.vertDataSize = sizeof(float) * numLayers;
normalOffset += sizeof(float) * numLayers; normalOffset += sizeof(float) * numLayers;
if(flags & CCG_CALC_NORMALS) if (flags & CCG_CALC_NORMALS)
ifc.vertDataSize += sizeof(float) * 3; ifc.vertDataSize += sizeof(float) * 3;
if(flags & CCG_ALLOC_MASK) if (flags & CCG_ALLOC_MASK)
ifc.vertDataSize += sizeof(float); ifc.vertDataSize += sizeof(float);
if (useArena) { if (useArena) {
@@ -652,12 +652,12 @@ static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f)
static void minmax_v3_v3v3(const float vec[3], float min[3], float max[3]) static void minmax_v3_v3v3(const float vec[3], float min[3], float max[3])
{ {
if(min[0] > vec[0]) min[0]= vec[0]; if (min[0] > vec[0]) min[0] = vec[0];
if(min[1] > vec[1]) min[1]= vec[1]; if (min[1] > vec[1]) min[1] = vec[1];
if(min[2] > vec[2]) min[2]= vec[2]; if (min[2] > vec[2]) min[2] = vec[2];
if(max[0] < vec[0]) max[0]= vec[0]; if (max[0] < vec[0]) max[0] = vec[0];
if(max[1] < vec[1]) max[1]= vec[1]; if (max[1] < vec[1]) max[1] = vec[1];
if(max[2] < vec[2]) max[2]= vec[2]; if (max[2] < vec[2]) max[2] = vec[2];
} }
static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
@@ -687,7 +687,7 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
CCGEdge *e = ccgEdgeIterator_getCurrent(ei); CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
for (i=0; i < edgeSize; i++) for (i = 0; i < edgeSize; i++)
minmax_v3_v3v3(CCG_elem_offset_co(&key, edgeData, i), min_r, max_r); minmax_v3_v3v3(CCG_elem_offset_co(&key, edgeData, i), min_r, max_r);
} }
@@ -1050,10 +1050,10 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
/* Translate GridPaintMask into vertex paint masks. Assumes vertices /* Translate GridPaintMask into vertex paint masks. Assumes vertices
are in the order output by ccgDM_copyFinalVertArray. */ are in the order output by ccgDM_copyFinalVertArray. */
void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly, void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly,
float *paint_mask, float *paint_mask,
const GridPaintMask *grid_paint_mask) const GridPaintMask *grid_paint_mask)
{ {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
CCGSubSurf *ss = ccgdm->ss; CCGSubSurf *ss = ccgdm->ss;
int level = ccgSubSurf_getSubdivisionLevels(ss); int level = ccgSubSurf_getSubdivisionLevels(ss);
int gridSize = ccgSubSurf_getGridSize(ss); int gridSize = ccgSubSurf_getGridSize(ss);
@@ -1061,24 +1061,24 @@ void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly,
int totface = ccgSubSurf_getNumFaces(ss); int totface = ccgSubSurf_getNumFaces(ss);
int i, j, x, y, factor, gpm_gridsize; int i, j, x, y, factor, gpm_gridsize;
for(i = 0; i < totface; i++) { for (i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face; CCGFace *f = ccgdm->faceMap[i].face;
const MPoly *p = &mpoly[i]; const MPoly *p = &mpoly[i];
for(j = 0; j < p->totloop; j++) { for (j = 0; j < p->totloop; j++) {
const GridPaintMask *gpm = &grid_paint_mask[p->loopstart + j]; const GridPaintMask *gpm = &grid_paint_mask[p->loopstart + j];
if(!gpm->data) if (!gpm->data)
continue; continue;
factor = ccg_factor(level, gpm->level); factor = ccg_factor(level, gpm->level);
gpm_gridsize = ccg_gridsize(gpm->level); gpm_gridsize = ccg_gridsize(gpm->level);
for(y = 0; y < gridSize; y++) { for (y = 0; y < gridSize; y++) {
for(x = 0; x < gridSize; x++) { for (x = 0; x < gridSize; x++) {
int vndx, offset; int vndx, offset;
vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize); vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize);
offset = y*factor * gpm_gridsize + x*factor; offset = y * factor * gpm_gridsize + x * factor;
paint_mask[vndx] = gpm->data[offset]; paint_mask[vndx] = gpm->data[offset];
} }
} }
@@ -1857,7 +1857,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
continue; continue;
} }
glShadeModel(drawSmooth ? GL_SMOOTH: GL_FLAT); glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
for (S = 0; S < numVerts; S++) { for (S = 0; S < numVerts; S++) {
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
CCGElem *vda, *vdb; CCGElem *vda, *vdb;
@@ -2011,7 +2011,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
} }
/* draw face*/ /* draw face*/
glShadeModel(drawSmooth ? GL_SMOOTH: GL_FLAT); glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
for (S = 0; S < numVerts; S++) { for (S = 0; S < numVerts; S++) {
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
CCGElem *vda, *vdb; CCGElem *vda, *vdb;
@@ -2053,8 +2053,8 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
} }
else { else {
glBegin(GL_QUADS); glBegin(GL_QUADS);
for (y=0; y < gridFaces; y++) { for (y = 0; y < gridFaces; y++) {
for (x=0; x < gridFaces; x++) { for (x = 0; x < gridFaces; x++) {
float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0); float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0);
float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0); float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0);
float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1); float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1);
@@ -2156,7 +2156,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
for (y = 0; y < gridFaces; y++) { for (y = 0; y < gridFaces; y++) {
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for (x=0; x<gridFaces; x++) { for (x = 0; x < gridFaces; x++) {
a = CCG_grid_elem(&key, faceGridData, x, y + 0); a = CCG_grid_elem(&key, faceGridData, x, y + 0);
b = CCG_grid_elem(&key, faceGridData, x, y + 1); b = CCG_grid_elem(&key, faceGridData, x, y + 1);
@@ -2196,7 +2196,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
} }
} }
else { else {
glShadeModel((cp)? GL_SMOOTH: GL_FLAT); glShadeModel((cp) ? GL_SMOOTH : GL_FLAT);
glBegin(GL_QUADS); glBegin(GL_QUADS);
for (y = 0; y < gridFaces; y++) { for (y = 0; y < gridFaces; y++) {
for (x = 0; x < gridFaces; x++) { for (x = 0; x < gridFaces; x++) {
@@ -2346,7 +2346,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
* normals are already used to change shading */ * normals are already used to change shading */
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
for (S=0; S<numVerts; S++) { for (S = 0; S < numVerts; S++) {
CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
if (drawSmooth) { if (drawSmooth) {
for (y = 0; y < gridFaces; y++) { for (y = 0; y < gridFaces; y++) {
@@ -2507,7 +2507,7 @@ static void ccgDM_foreachMappedFaceCenter(
int index = ccgDM_getFaceMapIndex(ss, f); int index = ccgDM_getFaceMapIndex(ss, f);
if (index != -1) { if (index != -1) {
/* Face center data normal isn't updated atm. */ /* Face center data normal isn't updated atm. */
CCGElem *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0); CCGElem *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0);
func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd)); func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd));
@@ -2914,7 +2914,7 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm)
static void ccgDM_getGridKey(DerivedMesh *dm, CCGKey *key) static void ccgDM_getGridKey(DerivedMesh *dm, CCGKey *key)
{ {
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
CCG_key_top_level(key, ccgdm->ss); CCG_key_top_level(key, ccgdm->ss);
} }
@@ -3005,14 +3005,14 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new(); ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new();
BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
numGrids, &key, (void **) ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden); numGrids, &key, (void **) ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
} }
else if(ob->type == OB_MESH) { else if (ob->type == OB_MESH) {
Mesh *me= ob->data; Mesh *me = ob->data;
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new();
BLI_assert(!(me->mface == NULL && me->mpoly != NULL)); /* BMESH ONLY complain if mpoly is valid but not mface */ BLI_assert(!(me->mface == NULL && me->mpoly != NULL)); /* BMESH ONLY complain if mpoly is valid but not mface */
BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
me->totface, me->totvert, &me->vdata); me->totface, me->totvert, &me->vdata);
} }
return ccgdm->pbvh; return ccgdm->pbvh;

View File

@@ -52,17 +52,17 @@ typedef struct {
typedef int (*BLI_pbvh_SearchCallback)(PBVHNode *node, void *data); typedef int (*BLI_pbvh_SearchCallback)(PBVHNode *node, void *data);
typedef void (*BLI_pbvh_HitCallback)(PBVHNode *node, void *data); typedef void (*BLI_pbvh_HitCallback)(PBVHNode *node, void *data);
typedef void (*BLI_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float* tmin); typedef void (*BLI_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float *tmin);
/* Building */ /* Building */
PBVH *BLI_pbvh_new(void); PBVH *BLI_pbvh_new(void);
void BLI_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts, void BLI_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts,
int totface, int totvert, struct CustomData *vdata); int totface, int totvert, struct CustomData *vdata);
void BLI_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems, void BLI_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems,
struct DMGridAdjacency *gridadj, int totgrid, struct DMGridAdjacency *gridadj, int totgrid,
struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats, struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats,
unsigned int **grid_hidden); unsigned int **grid_hidden);
void BLI_pbvh_free(PBVH *bvh); void BLI_pbvh_free(PBVH *bvh);
/* Hierarchical Search in the BVH, two methods: /* Hierarchical Search in the BVH, two methods:
@@ -70,28 +70,28 @@ void BLI_pbvh_free(PBVH *bvh);
* - gather nodes in an array (easy to multithread) */ * - gather nodes in an array (easy to multithread) */
void BLI_pbvh_search_callback(PBVH *bvh, void BLI_pbvh_search_callback(PBVH *bvh,
BLI_pbvh_SearchCallback scb, void *search_data, BLI_pbvh_SearchCallback scb, void *search_data,
BLI_pbvh_HitCallback hcb, void *hit_data); BLI_pbvh_HitCallback hcb, void *hit_data);
void BLI_pbvh_search_gather(PBVH *bvh, void BLI_pbvh_search_gather(PBVH *bvh,
BLI_pbvh_SearchCallback scb, void *search_data, BLI_pbvh_SearchCallback scb, void *search_data,
PBVHNode ***array, int *tot); PBVHNode ***array, int *tot);
/* Raycast /* Raycast
* the hit callback is called for all leaf nodes intersecting the ray; * the hit callback is called for all leaf nodes intersecting the ray;
* it's up to the callback to find the primitive within the leaves that is * it's up to the callback to find the primitive within the leaves that is
* hit first */ * hit first */
void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, void BLI_pbvh_raycast(PBVH * bvh, BLI_pbvh_HitOccludedCallback cb, void *data,
float ray_start[3], float ray_normal[3], int original); float ray_start[3], float ray_normal[3], int original);
int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], int BLI_pbvh_node_raycast(PBVH * bvh, PBVHNode * node, float (*origco)[3],
float ray_start[3], float ray_normal[3], float *dist); float ray_start[3], float ray_normal[3], float *dist);
/* Drawing */ /* Drawing */
void BLI_pbvh_node_draw(PBVHNode *node, void *data); void BLI_pbvh_node_draw(PBVHNode *node, void *data);
void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
int (*setMaterial)(int, void *attribs)); int (*setMaterial)(int, void *attribs));
/* PBVH Access */ /* PBVH Access */
typedef enum { typedef enum {
@@ -127,17 +127,17 @@ void BLI_pbvh_node_mark_rebuild_draw(PBVHNode *node);
void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden); void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
struct CCGElem ***grid_elems, struct DMGridAdjacency **gridadj); struct CCGElem ***grid_elems, struct DMGridAdjacency **gridadj);
void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node,
int *uniquevert, int *totvert); int *uniquevert, int *totvert);
void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node,
int **vert_indices, struct MVert **verts); int **vert_indices, struct MVert **verts);
void BLI_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]); void BLI_pbvh_node_get_BB(PBVHNode * node, float bb_min[3], float bb_max[3]);
void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]); void BLI_pbvh_node_get_original_BB(PBVHNode * node, float bb_min[3], float bb_max[3]);
float BLI_pbvh_node_get_tmin(PBVHNode* node); float BLI_pbvh_node_get_tmin(PBVHNode *node);
/* test if AABB is at least partially inside the planes' volume */ /* test if AABB is at least partially inside the planes' volume */
int BLI_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data); int BLI_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data);
@@ -147,10 +147,10 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data);
/* Update Normals/Bounding Box/Draw Buffers/Redraw and clear flags */ /* Update Normals/Bounding Box/Draw Buffers/Redraw and clear flags */
void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]); void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]); void BLI_pbvh_redraw_BB(PBVH * bvh, float bb_min[3], float bb_max[3]);
void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface); void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface);
void BLI_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems, void BLI_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems,
struct DMGridAdjacency *gridadj, void **gridfaces); struct DMGridAdjacency *gridadj, void **gridfaces);
/* vertex deformer */ /* vertex deformer */
float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3]; float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3];
@@ -166,8 +166,8 @@ int BLI_pbvh_isDeformed(struct PBVH *pbvh);
/* note: PBVH_ITER_ALL does not skip hidden vertices, /* note: PBVH_ITER_ALL does not skip hidden vertices,
* PBVH_ITER_UNIQUE does */ * PBVH_ITER_UNIQUE does */
#define PBVH_ITER_ALL 0 #define PBVH_ITER_ALL 0
#define PBVH_ITER_UNIQUE 1 #define PBVH_ITER_UNIQUE 1
typedef struct PBVHVertexIter { typedef struct PBVHVertexIter {
/* iteration */ /* iteration */
@@ -207,44 +207,44 @@ typedef struct PBVHVertexIter {
#endif #endif
void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
PBVHVertexIter *vi, int mode); PBVHVertexIter *vi, int mode);
#define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \ #define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \
pbvh_vertex_iter_init(bvh, node, &vi, mode); \ pbvh_vertex_iter_init(bvh, node, &vi, mode); \
\ \
for(vi.i=0, vi.g=0; vi.g<vi.totgrid; vi.g++) { \ for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
if(vi.grids) { \ if (vi.grids) { \
vi.width= vi.gridsize; \ vi.width = vi.gridsize; \
vi.height= vi.gridsize; \ vi.height = vi.gridsize; \
vi.grid= vi.grids[vi.grid_indices[vi.g]]; \ vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
if(mode == PBVH_ITER_UNIQUE) \ if (mode == PBVH_ITER_UNIQUE) \
vi.gh= vi.grid_hidden[vi.grid_indices[vi.g]]; \ vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
} \ } \
else { \ else { \
vi.width= vi.totvert; \ vi.width = vi.totvert; \
vi.height= 1; \ vi.height = 1; \
} \ } \
\ \
for(vi.gy=0; vi.gy<vi.height; vi.gy++) { \ for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
for(vi.gx=0; vi.gx<vi.width; vi.gx++, vi.i++) { \ for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
if(vi.grid) { \ if (vi.grid) { \
vi.co= CCG_elem_co(vi.key, vi.grid); \ vi.co = CCG_elem_co(vi.key, vi.grid); \
vi.fno= CCG_elem_no(vi.key, vi.grid); \ vi.fno = CCG_elem_no(vi.key, vi.grid); \
vi.mask= CCG_elem_mask(vi.key, vi.grid); \ vi.mask = CCG_elem_mask(vi.key, vi.grid); \
vi.grid= CCG_elem_next(vi.key, vi.grid); \ vi.grid = CCG_elem_next(vi.key, vi.grid); \
if(vi.gh) { \ if (vi.gh) { \
if(BLI_BITMAP_GET(vi.gh, vi.gy * vi.gridsize + vi.gx)) \ if (BLI_BITMAP_GET(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
continue; \ continue; \
} \ } \
} \ } \
else { \ else { \
vi.mvert= &vi.mverts[vi.vert_indices[vi.gx]]; \ vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \
if(mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \ if (mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \
continue; \ continue; \
vi.co= vi.mvert->co; \ vi.co = vi.mvert->co; \
vi.no= vi.mvert->no; \ vi.no = vi.mvert->no; \
if(vi.vmask) \ if (vi.vmask) \
vi.mask= &vi.vmask[vi.vert_indices[vi.gx]]; \ vi.mask = &vi.vmask[vi.vert_indices[vi.gx]]; \
} \ } \
#define BLI_pbvh_vertex_iter_end \ #define BLI_pbvh_vertex_iter_end \
@@ -252,10 +252,10 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
} \ } \
} }
void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* proxy_count); void BLI_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count);
void BLI_pbvh_node_free_proxies(PBVHNode* node); void BLI_pbvh_node_free_proxies(PBVHNode *node);
PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node); PBVHProxyNode *BLI_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node);
void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** nodes, int* totnode); void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode);
//void BLI_pbvh_node_BB_reset(PBVHNode* node); //void BLI_pbvh_node_BB_reset(PBVHNode* node);
//void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]); //void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]);

File diff suppressed because it is too large Load Diff

View File

@@ -46,15 +46,15 @@ void ED_sculpt_force_update(struct bContext *C);
float *ED_sculpt_get_last_stroke(struct Object *ob); float *ED_sculpt_get_last_stroke(struct Object *ob);
int ED_sculpt_minmax(struct bContext *C, float *min, float *max); int ED_sculpt_minmax(struct bContext *C, float *min, float *max);
void ED_sculpt_mask_layers_ensure(struct Object *ob, void ED_sculpt_mask_layers_ensure(struct Object *ob,
struct MultiresModifierData *mmd); struct MultiresModifierData *mmd);
/* paint_ops.c */ /* paint_ops.c */
void ED_operatortypes_paint(void); void ED_operatortypes_paint(void);
void ED_keymap_paint(struct wmKeyConfig *keyconf); void ED_keymap_paint(struct wmKeyConfig *keyconf);
/* paint_undo.c */ /* paint_undo.c */
#define UNDO_PAINT_IMAGE 0 #define UNDO_PAINT_IMAGE 0
#define UNDO_PAINT_MESH 1 #define UNDO_PAINT_MESH 1
int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name); int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name);
void ED_undo_paint_free(void); void ED_undo_paint_free(void);

View File

@@ -486,7 +486,7 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float
x1 = x0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (x0 + 1); x1 = x0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (x0 + 1);
y0 = (int) crn_y; y0 = (int) crn_y;
y1 = y0 >= (key->grid_size - 1 ) ? (key->grid_size - 1) : (y0 + 1); y1 = y0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (y0 + 1);
u = crn_x - x0; u = crn_x - x0;
v = crn_y - y0; v = crn_y - y0;
@@ -1024,7 +1024,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
tmp_mmd.lvl = *lvl; tmp_mmd.lvl = *lvl;
tmp_mmd.sculptlvl = *lvl; tmp_mmd.sculptlvl = *lvl;
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob,
MULTIRES_USE_LOCAL_MMD); MULTIRES_USE_LOCAL_MMD);
cddm->release(cddm); cddm->release(cddm);
} }
@@ -1045,7 +1045,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
tmp_mmd.lvl = mmd->totlvl; tmp_mmd.lvl = mmd->totlvl;
tmp_mmd.sculptlvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl;
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob,
MULTIRES_USE_LOCAL_MMD); MULTIRES_USE_LOCAL_MMD);
cddm->release(cddm); cddm->release(cddm);
return dm; return dm;

View File

@@ -153,7 +153,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob);
/* ensure that grid paint mask layer is created */ /* ensure that grid paint mask layer is created */
ED_sculpt_mask_layers_ensure(ob, (MultiresModifierData*)new_md); ED_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md);
} }
} }
@@ -926,7 +926,8 @@ static int modifier_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev
static EnumPropertyItem modifier_apply_as_items[] = { static EnumPropertyItem modifier_apply_as_items[] = {
{MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"}, {MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"},
{MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, {MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
void OBJECT_OT_modifier_apply(wmOperatorType *ot) void OBJECT_OT_modifier_apply(wmOperatorType *ot)
{ {

View File

@@ -83,9 +83,9 @@ static int planes_contain_v3(float (*planes)[4], int totplane, const float p[3])
/* return true if the element should be hidden/shown */ /* return true if the element should be hidden/shown */
static int is_effected(PartialVisArea area, static int is_effected(PartialVisArea area,
float planes[4][4], float planes[4][4],
const float co[3], const float co[3],
const float mask) const float mask)
{ {
if (area == PARTIALVIS_ALL) if (area == PARTIALVIS_ALL)
return 1; return 1;
@@ -158,8 +158,8 @@ static void partialvis_update_grids(Object *ob,
/* get PBVH data */ /* get PBVH data */
BLI_pbvh_node_get_grids(pbvh, node, BLI_pbvh_node_get_grids(pbvh, node,
&grid_indices, &totgrid, NULL, NULL, &grid_indices, &totgrid, NULL, NULL,
&grids, NULL); &grids, NULL);
grid_hidden = BLI_pbvh_grid_hidden(pbvh); grid_hidden = BLI_pbvh_grid_hidden(pbvh);
BLI_pbvh_get_grid_key(pbvh, &key); BLI_pbvh_get_grid_key(pbvh, &key);
@@ -176,7 +176,7 @@ static void partialvis_update_grids(Object *ob,
case PARTIALVIS_HIDE: case PARTIALVIS_HIDE:
/* create grid flags data */ /* create grid flags data */
gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area, gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area,
"partialvis_update_grids"); "partialvis_update_grids");
break; break;
case PARTIALVIS_SHOW: case PARTIALVIS_SHOW:
/* entire grid is visible, nothing to show */ /* entire grid is visible, nothing to show */
@@ -203,7 +203,7 @@ static void partialvis_update_grids(Object *ob,
if (is_effected(area, planes, co, mask)) { if (is_effected(area, planes, co, mask)) {
/* set or clear the hide flag */ /* set or clear the hide flag */
BLI_BITMAP_MODIFY(gh, y * key.grid_size + x, BLI_BITMAP_MODIFY(gh, y * key.grid_size + x,
action == PARTIALVIS_HIDE); action == PARTIALVIS_HIDE);
any_changed = 1; any_changed = 1;
} }
@@ -368,14 +368,16 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
static EnumPropertyItem action_items[] = { static EnumPropertyItem action_items[] = {
{PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"}, {PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"},
{PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"}, {PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem area_items[] = { static EnumPropertyItem area_items[] = {
{PARTIALVIS_OUTSIDE, "OUTSIDE", 0, "Outside", "Hide or show vertices outside the selection"}, {PARTIALVIS_OUTSIDE, "OUTSIDE", 0, "Outside", "Hide or show vertices outside the selection"},
{PARTIALVIS_INSIDE, "INSIDE", 0, "Inside", "Hide or show vertices inside the selection"}, {PARTIALVIS_INSIDE, "INSIDE", 0, "Inside", "Hide or show vertices inside the selection"},
{PARTIALVIS_ALL, "ALL", 0, "All", "Hide or show all vertices"}, {PARTIALVIS_ALL, "ALL", 0, "All", "Hide or show all vertices"},
{PARTIALVIS_MASKED, "MASKED", 0, "Masked", "Hide or show vertices that are masked (minimum mask value of 0.5)"}, {PARTIALVIS_MASKED, "MASKED", 0, "Masked", "Hide or show vertices that are masked (minimum mask value of 0.5)"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
/* identifiers */ /* identifiers */
ot->name = "Hide/Show"; ot->name = "Hide/Show";

View File

@@ -57,8 +57,8 @@ typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke,
typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke);
struct PaintStroke *paint_stroke_new(struct bContext *C, struct PaintStroke *paint_stroke_new(struct bContext *C,
StrokeGetLocation get_location, StrokeTestStart test_start, StrokeGetLocation get_location, StrokeTestStart test_start,
StrokeUpdateStep update_step, StrokeDone done, int event_type); StrokeUpdateStep update_step, StrokeDone done, int event_type);
void paint_stroke_data_free(struct wmOperator *op); void paint_stroke_data_free(struct wmOperator *op);
int paint_space_stroke_enabled(struct Brush *br); int paint_space_stroke_enabled(struct Brush *br);
@@ -116,24 +116,24 @@ void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot);
* its minimum and maximum corners) into a screen-space rectangle, * its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty */ * returns zero if the result is empty */
int paint_convert_bb_to_rect(struct rcti *rect, int paint_convert_bb_to_rect(struct rcti *rect,
const float bb_min[3], const float bb_min[3],
const float bb_max[3], const float bb_max[3],
const struct ARegion *ar, const struct ARegion *ar,
struct RegionView3D *rv3d, struct RegionView3D *rv3d,
struct Object *ob); struct Object *ob);
/* Get four planes in object-space that describe the projection of /* Get four planes in object-space that describe the projection of
* screen_rect from screen into object-space (essentially converting a * screen_rect from screen into object-space (essentially converting a
* 2D screens-space bounding box into four 3D planes) */ * 2D screens-space bounding box into four 3D planes) */
void paint_calc_redraw_planes(float planes[4][4], void paint_calc_redraw_planes(float planes[4][4],
const struct ARegion *ar, const struct ARegion *ar,
struct RegionView3D *rv3d, struct RegionView3D *rv3d,
struct Object *ob, struct Object *ob,
const struct rcti *screen_rect); const struct rcti *screen_rect);
void projectf(struct bglMats *mats, const float v[3], float p[2]); void projectf(struct bglMats *mats, const float v[3], float p[2]);
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius); float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
float paint_get_tex_pixel(struct Brush* br, float u, float v); float paint_get_tex_pixel(struct Brush *br, float u, float v);
int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface); int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]); void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);

View File

@@ -235,19 +235,20 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c
static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode)
{ {
if(!brush_orig || brush_tool(brush_orig, tool_offset) != tool) { if (!brush_orig || brush_tool(brush_orig, tool_offset) != tool) {
Brush *br; Brush *br;
/* if the current brush is not using the desired tool, look /* if the current brush is not using the desired tool, look
for one that is */ for one that is */
br= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); br = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
/* store the previously-selected brush */ /* store the previously-selected brush */
if(br) if (br)
br->toggle_brush= brush_orig; br->toggle_brush = brush_orig;
return br; return br;
} }
else if(brush_orig->toggle_brush && else if (brush_orig->toggle_brush &&
BLI_findindex(bmain->brush.first, brush_orig->toggle_brush) != -1) { BLI_findindex(bmain->brush.first, brush_orig->toggle_brush) != -1)
{
/* if current brush is using the desired tool, try to toggle /* if current brush is using the desired tool, try to toggle
back to the previously selected brush (if it was set, and back to the previously selected brush (if it was set, and
if it still exists) */ if it still exists) */
@@ -258,22 +259,22 @@ static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool,
} }
static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
const size_t tool_offset, const int ob_mode, const size_t tool_offset, const int ob_mode,
const char *tool_name, int create_missing, const char *tool_name, int create_missing,
int toggle) int toggle)
{ {
struct Brush *brush, *brush_orig = paint_brush(paint); struct Brush *brush, *brush_orig = paint_brush(paint);
if(toggle) if (toggle)
brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode); brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode);
else else
brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
if(!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) { if (!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) {
brush = BKE_brush_add(tool_name); brush = BKE_brush_add(tool_name);
brush_tool_set(brush, tool_offset, tool); brush_tool_set(brush, tool_offset, tool);
brush->ob_mode= ob_mode; brush->ob_mode = ob_mode;
brush->toggle_brush= brush_orig; brush->toggle_brush = brush_orig;
} }
if (brush) { if (brush) {
@@ -315,30 +316,30 @@ static int brush_select_exec(bContext *C, wmOperator *op)
} }
} }
switch(paint_mode) { switch (paint_mode) {
case OB_MODE_SCULPT: case OB_MODE_SCULPT:
paint= &toolsettings->sculpt->paint; paint = &toolsettings->sculpt->paint;
tool_offset= offsetof(Brush, sculpt_tool); tool_offset = offsetof(Brush, sculpt_tool);
tool= RNA_enum_get(op->ptr, "sculpt_tool"); tool = RNA_enum_get(op->ptr, "sculpt_tool");
RNA_enum_name_from_value(brush_sculpt_tool_items, tool, &tool_name); RNA_enum_name_from_value(brush_sculpt_tool_items, tool, &tool_name);
break; break;
case OB_MODE_VERTEX_PAINT: case OB_MODE_VERTEX_PAINT:
paint= &toolsettings->vpaint->paint; paint = &toolsettings->vpaint->paint;
tool_offset= offsetof(Brush, vertexpaint_tool); tool_offset = offsetof(Brush, vertexpaint_tool);
tool= RNA_enum_get(op->ptr, "vertex_paint_tool"); tool = RNA_enum_get(op->ptr, "vertex_paint_tool");
RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name);
break; break;
case OB_MODE_WEIGHT_PAINT: case OB_MODE_WEIGHT_PAINT:
paint= &toolsettings->wpaint->paint; paint = &toolsettings->wpaint->paint;
/* vertexpaint_tool is used for weight paint mode */ /* vertexpaint_tool is used for weight paint mode */
tool_offset= offsetof(Brush, vertexpaint_tool); tool_offset = offsetof(Brush, vertexpaint_tool);
tool= RNA_enum_get(op->ptr, "weight_paint_tool"); tool = RNA_enum_get(op->ptr, "weight_paint_tool");
RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name);
break; break;
case OB_MODE_TEXTURE_PAINT: case OB_MODE_TEXTURE_PAINT:
paint= &toolsettings->imapaint.paint; paint = &toolsettings->imapaint.paint;
tool_offset= offsetof(Brush, imagepaint_tool); tool_offset = offsetof(Brush, imagepaint_tool);
tool= RNA_enum_get(op->ptr, "texture_paint_tool"); tool = RNA_enum_get(op->ptr, "texture_paint_tool");
RNA_enum_name_from_value(brush_image_tool_items, tool, &tool_name); RNA_enum_name_from_value(brush_image_tool_items, tool, &tool_name);
break; break;
default: default:
@@ -347,8 +348,8 @@ static int brush_select_exec(bContext *C, wmOperator *op)
} }
return brush_generic_tool_set(bmain, paint, tool, tool_offset, return brush_generic_tool_set(bmain, paint, tool, tool_offset,
paint_mode, tool_name, create_missing, paint_mode, tool_name, create_missing,
toggle); toggle);
} }
static void PAINT_OT_brush_select(wmOperatorType *ot) static void PAINT_OT_brush_select(wmOperatorType *ot)
@@ -635,12 +636,12 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
/* Clear mask */ /* Clear mask */
kmi= WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", MKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", MKEY, KM_PRESS, KM_ALT, 0);
RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_FLOOD_VALUE); RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_FLOOD_VALUE);
RNA_float_set(kmi->ptr, "value", 0); RNA_float_set(kmi->ptr, "value", 0);
/* Invert mask */ /* Invert mask */
kmi= WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT); RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT);
/* multires switch */ /* multires switch */
@@ -665,7 +666,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_FLATTEN, TKEY, KM_SHIFT); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_FLATTEN, TKEY, KM_SHIFT);
keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CLAY, CKEY, 0); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CLAY, CKEY, 0);
keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CREASE, CKEY, KM_SHIFT); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CREASE, CKEY, KM_SHIFT);
kmi= keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_MASK, MKEY, 0); kmi = keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_MASK, MKEY, 0);
RNA_boolean_set(kmi->ptr, "toggle", 1); RNA_boolean_set(kmi->ptr, "toggle", 1);
RNA_boolean_set(kmi->ptr, "create_missing", 1); RNA_boolean_set(kmi->ptr, "create_missing", 1);

View File

@@ -124,7 +124,7 @@ int ED_sculpt_minmax(bContext *C, float *min, float *max)
/* Sculpt mode handles multires differently from regular meshes, but only if /* Sculpt mode handles multires differently from regular meshes, but only if
* it's the last modifier on the stack and it is not on the first level */ * it's the last modifier on the stack and it is not on the first level */
struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
{ {
Mesh *me = (Mesh *)ob->data; Mesh *me = (Mesh *)ob->data;
ModifierData *md; ModifierData *md;
@@ -291,7 +291,8 @@ static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss)
if (unode) { if (unode) {
PBVHVertexIter vd; PBVHVertexIter vd;
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (unode->type == SCULPT_UNDO_COORDS) { if (unode->type == SCULPT_UNDO_COORDS) {
copy_v3_v3(vd.co, unode->co[vd.i]); copy_v3_v3(vd.co, unode->co[vd.i]);
if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]);
@@ -649,10 +650,10 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
case SCULPT_TOOL_MASK: case SCULPT_TOOL_MASK:
overlap = (1 + overlap) / 2; overlap = (1 + overlap) / 2;
switch ((BrushMaskTool)brush->mask_tool) { switch ((BrushMaskTool)brush->mask_tool) {
case BRUSH_MASK_DRAW: case BRUSH_MASK_DRAW:
return alpha * flip * pressure * overlap * feather; return alpha * flip * pressure * overlap * feather;
case BRUSH_MASK_SMOOTH: case BRUSH_MASK_SMOOTH:
return alpha * pressure * feather; return alpha * pressure * feather;
} }
case SCULPT_TOOL_CREASE: case SCULPT_TOOL_CREASE:
@@ -713,11 +714,11 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
/* Return a multiplier for brush strength on a particular vertex. */ /* Return a multiplier for brush strength on a particular vertex. */
static float tex_strength(SculptSession *ss, Brush *br, float point[3], static float tex_strength(SculptSession *ss, Brush *br, float point[3],
const float len, const float len,
const float sculpt_normal[3], const float sculpt_normal[3],
const short vno[3], const short vno[3],
const float fno[3], const float fno[3],
const float mask) const float mask)
{ {
MTex *mtex = &br->mtex; MTex *mtex = &br->mtex;
float avg = 1; float avg = 1;
@@ -901,7 +902,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
if (ss->cache->original) { if (ss->cache->original) {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
float fno[3]; float fno[3];
@@ -912,7 +914,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
BLI_pbvh_vertex_iter_end; BLI_pbvh_vertex_iter_end;
} }
else { else {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, vd.co)) { if (sculpt_brush_test_fast(&test, vd.co)) {
if (vd.no) { if (vd.no) {
float fno[3]; float fno[3];
@@ -1072,11 +1075,12 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, vd.fno, ss->cache->view_normal, vd.no, vd.fno,
smooth_mask ? 0 : *vd.mask); smooth_mask ? 0 : *vd.mask);
if (smooth_mask) { if (smooth_mask) {
float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask;
val *= fade * bstrength; val *= fade * bstrength;
@@ -1103,7 +1107,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
} }
static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
float bstrength, int smooth_mask) float bstrength, int smooth_mask)
{ {
Brush *brush = paint_brush(&sd->paint); Brush *brush = paint_brush(&sd->paint);
SculptBrushTest test; SculptBrushTest test;
@@ -1120,18 +1124,18 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
CLAMP(bstrength, 0.0f, 1.0f); CLAMP(bstrength, 0.0f, 1.0f);
BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid, BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid,
NULL, &gridsize, &griddata, &gridadj); NULL, &gridsize, &griddata, &gridadj);
BLI_pbvh_get_grid_key(ss->pbvh, &key); BLI_pbvh_get_grid_key(ss->pbvh, &key);
#pragma omp critical #pragma omp critical
{ {
if (smooth_mask) { if (smooth_mask) {
tmpgrid_mask = MEM_mallocN(sizeof(float)*gridsize*gridsize, "tmpgrid_mask"); tmpgrid_mask = MEM_mallocN(sizeof(float) * gridsize * gridsize, "tmpgrid_mask");
tmprow_mask = MEM_mallocN(sizeof(float)*gridsize, "tmprow_mask"); tmprow_mask = MEM_mallocN(sizeof(float) * gridsize, "tmprow_mask");
} }
else { else {
tmpgrid_co = MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid_co"); tmpgrid_co = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid_co");
tmprow_co = MEM_mallocN(sizeof(float)*3*gridsize, "tmprow_co"); tmprow_co = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow_co");
} }
} }
@@ -1140,20 +1144,20 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
adj = &gridadj[grid_indices[i]]; adj = &gridadj[grid_indices[i]];
if (smooth_mask) if (smooth_mask)
memset(tmpgrid_mask, 0, sizeof(float)*gridsize*gridsize); memset(tmpgrid_mask, 0, sizeof(float) * gridsize * gridsize);
else else
memset(tmpgrid_co, 0, sizeof(float)*3*gridsize*gridsize); memset(tmpgrid_co, 0, sizeof(float) * 3 * gridsize * gridsize);
for (y = 0; y < gridsize - 1; y++) { for (y = 0; y < gridsize - 1; y++) {
v1 = y*gridsize; v1 = y * gridsize;
if (smooth_mask) { if (smooth_mask) {
tmprow_mask[0] = (*CCG_elem_offset_mask(&key, data, v1) + tmprow_mask[0] = (*CCG_elem_offset_mask(&key, data, v1) +
*CCG_elem_offset_mask(&key, data, v1 + gridsize)); *CCG_elem_offset_mask(&key, data, v1 + gridsize));
} }
else { else {
add_v3_v3v3(tmprow_co[0], add_v3_v3v3(tmprow_co[0],
CCG_elem_offset_co(&key, data, v1), CCG_elem_offset_co(&key, data, v1),
CCG_elem_offset_co(&key, data, v1 + gridsize)); CCG_elem_offset_co(&key, data, v1 + gridsize));
} }
for (x = 0; x < gridsize - 1; x++) { for (x = 0; x < gridsize - 1; x++) {
@@ -1166,7 +1170,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
float tmp; float tmp;
tmprow_mask[x + 1] = (*CCG_elem_offset_mask(&key, data, v2) + tmprow_mask[x + 1] = (*CCG_elem_offset_mask(&key, data, v2) +
*CCG_elem_offset_mask(&key, data, v4)); *CCG_elem_offset_mask(&key, data, v4));
tmp = tmprow_mask[x + 1] + tmprow_mask[x]; tmp = tmprow_mask[x + 1] + tmprow_mask[x];
tmpgrid_mask[v1] += tmp; tmpgrid_mask[v1] += tmp;
@@ -1178,8 +1182,8 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
float tmp[3]; float tmp[3];
add_v3_v3v3(tmprow_co[x + 1], add_v3_v3v3(tmprow_co[x + 1],
CCG_elem_offset_co(&key, data, v2), CCG_elem_offset_co(&key, data, v2),
CCG_elem_offset_co(&key, data, v4)); CCG_elem_offset_co(&key, data, v4));
add_v3_v3v3(tmp, tmprow_co[x + 1], tmprow_co[x]); add_v3_v3v3(tmp, tmprow_co[x + 1], tmprow_co[x]);
add_v3_v3(tmpgrid_co[v1], tmp); add_v3_v3(tmpgrid_co[v1], tmp);
@@ -1210,16 +1214,16 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
if (y == gridsize - 1 && adj->index[1] == -1) if (y == gridsize - 1 && adj->index[1] == -1)
continue; continue;
index = x + y*gridsize; index = x + y * gridsize;
co = CCG_elem_offset_co(&key, data, index); co = CCG_elem_offset_co(&key, data, index);
fno = CCG_elem_offset_no(&key, data, index); fno = CCG_elem_offset_no(&key, data, index);
mask = CCG_elem_offset_mask(&key, data, index); mask = CCG_elem_offset_mask(&key, data, index);
if (sculpt_brush_test(&test, co)) { if (sculpt_brush_test(&test, co)) {
const float strength_mask = (smooth_mask ? 0 : *mask); const float strength_mask = (smooth_mask ? 0 : *mask);
const float fade = bstrength*tex_strength(ss, brush, co, test.dist, const float fade = bstrength * tex_strength(ss, brush, co, test.dist,
ss->cache->view_normal, ss->cache->view_normal,
NULL, fno, strength_mask); NULL, fno, strength_mask);
float n = 1.0f / 16.0f; float n = 1.0f / 16.0f;
if (x == 0 || x == gridsize - 1) if (x == 0 || x == gridsize - 1)
@@ -1229,12 +1233,12 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
n *= 2; n *= 2;
if (smooth_mask) { if (smooth_mask) {
*mask += ((tmpgrid_mask[x + y*gridsize] * n) - *mask) * fade; *mask += ((tmpgrid_mask[x + y * gridsize] * n) - *mask) * fade;
} }
else { else {
float *avg, val[3]; float *avg, val[3];
avg = tmpgrid_co[x + y*gridsize]; avg = tmpgrid_co[x + y * gridsize];
mul_v3_fl(avg, n); mul_v3_fl(avg, n);
@@ -1264,7 +1268,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
} }
static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode,
float bstrength, int smooth_mask) float bstrength, int smooth_mask)
{ {
SculptSession *ss = ob->sculpt; SculptSession *ss = ob->sculpt;
const int max_iterations = 4; const int max_iterations = 4;
@@ -1282,11 +1286,11 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode,
for (n = 0; n < totnode; n++) { for (n = 0; n < totnode; n++) {
if (ss->multires) { if (ss->multires) {
do_multires_smooth_brush(sd, ss, nodes[n], do_multires_smooth_brush(sd, ss, nodes[n],
iteration != count ? 1.0f : last, smooth_mask); iteration != count ? 1.0f : last, smooth_mask);
} }
else if (ss->pmap) { else if (ss->pmap) {
do_mesh_smooth_brush(sd, ss, nodes[n], do_mesh_smooth_brush(sd, ss, nodes[n],
iteration != count ? 1.0f : last, smooth_mask); iteration != count ? 1.0f : last, smooth_mask);
} }
} }
@@ -1316,12 +1320,13 @@ static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int tot
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
float fade = tex_strength(ss, brush, vd.co, test.dist, float fade = tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, vd.fno, 0); ss->cache->view_normal, vd.no, vd.fno, 0);
(*vd.mask) += fade*bstrength; (*vd.mask) += fade * bstrength;
CLAMP(*vd.mask, 0, 1); CLAMP(*vd.mask, 0, 1);
if (vd.mvert) if (vd.mvert)
@@ -1338,12 +1343,12 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
Brush *brush = paint_brush(&sd->paint); Brush *brush = paint_brush(&sd->paint);
switch ((BrushMaskTool)brush->mask_tool) { switch ((BrushMaskTool)brush->mask_tool) {
case BRUSH_MASK_DRAW: case BRUSH_MASK_DRAW:
do_mask_brush_draw(sd, ob, nodes, totnode); do_mask_brush_draw(sd, ob, nodes, totnode);
break; break;
case BRUSH_MASK_SMOOTH: case BRUSH_MASK_SMOOTH:
smooth(sd, ob, nodes, totnode, ss->cache->bstrength, TRUE); smooth(sd, ob, nodes, totnode, ss->cache->bstrength, TRUE);
break; break;
} }
} }
@@ -1373,11 +1378,12 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
/* offset vertex */ /* offset vertex */
float fade = tex_strength(ss, brush, vd.co, test.dist, float fade = tex_strength(ss, brush, vd.co, test.dist,
area_normal, vd.no, vd.fno, *vd.mask); area_normal, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], offset, fade); mul_v3_v3fl(proxy[vd.i], offset, fade);
@@ -1429,7 +1435,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
/* offset vertex */ /* offset vertex */
const float fade = tex_strength(ss, brush, vd.co, test.dist, const float fade = tex_strength(ss, brush, vd.co, test.dist,
@@ -1471,11 +1478,12 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, ss->cache->view_normal, vd.no,
vd.fno, *vd.mask); vd.fno, *vd.mask);
float val[3]; float val[3];
sub_v3_v3v3(val, test.location, vd.co); sub_v3_v3v3(val, test.location, vd.co);
@@ -1536,8 +1544,8 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{ {
if (sculpt_brush_test(&test, origco[vd.i])) { if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
an, origno[vd.i], NULL, *vd.mask); an, origno[vd.i], NULL, *vd.mask);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade); mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -1576,10 +1584,11 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], cono, fade); mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1626,10 +1635,11 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade); mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -1675,10 +1685,11 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, origco[vd.i])) { if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
an, origno[vd.i], NULL, *vd.mask); an, origno[vd.i], NULL, *vd.mask);
mul_v3_v3fl(proxy[vd.i], cono, fade); mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1729,10 +1740,11 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, origco[vd.i])) { if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
an, origno[vd.i], NULL, *vd.mask); an, origno[vd.i], NULL, *vd.mask);
mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]); mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]);
sub_v3_v3(proxy[vd.i], origco[vd.i]); sub_v3_v3(proxy[vd.i], origco[vd.i]);
@@ -1782,10 +1794,11 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, origco[vd.i])) { if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
area_normal, vd.no, vd.fno, *vd.mask); area_normal, vd.no, vd.fno, *vd.mask);
float *disp = &layer_disp[vd.i]; float *disp = &layer_disp[vd.i];
float val[3]; float val[3];
@@ -1834,10 +1847,11 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test(&test, vd.co)) { if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, vd.fno, *vd.mask); ss->cache->view_normal, vd.no, vd.fno, *vd.mask);
float val[3]; float val[3];
if (vd.fno) copy_v3_v3(val, vd.fno); if (vd.fno) copy_v3_v3(val, vd.fno);
@@ -1877,7 +1891,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
if (ss->cache->original) { if (ss->cache->original) {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
add_v3_v3(private_fc, unode->co[vd.i]); add_v3_v3(private_fc, unode->co[vd.i]);
private_count++; private_count++;
@@ -1886,7 +1901,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
BLI_pbvh_vertex_iter_end; BLI_pbvh_vertex_iter_end;
} }
else { else {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, vd.co)) { if (sculpt_brush_test_fast(&test, vd.co)) {
add_v3_v3(private_fc, vd.co); add_v3_v3(private_fc, vd.co);
private_count++; private_count++;
@@ -1942,7 +1958,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
if (ss->cache->original) { if (ss->cache->original) {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
/* for area normal */ /* for area normal */
float fno[3]; float fno[3];
@@ -1958,7 +1975,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
BLI_pbvh_vertex_iter_end; BLI_pbvh_vertex_iter_end;
} }
else { else {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, vd.co)) { if (sculpt_brush_test_fast(&test, vd.co)) {
/* for area normal */ /* for area normal */
if (vd.no) { if (vd.no) {
@@ -2088,7 +2106,7 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3
static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) static int plane_trim(StrokeCache *cache, Brush *brush, float val[3])
{ {
return (!(brush->flag & BRUSH_PLANE_TRIM) || return (!(brush->flag & BRUSH_PLANE_TRIM) ||
((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared))); ((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared)));
} }
static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip) static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip)
@@ -2162,7 +2180,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_sq(&test, vd.co)) { if (sculpt_brush_test_sq(&test, vd.co)) {
float intr[3]; float intr[3];
float val[3]; float val[3];
@@ -2172,8 +2191,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
sub_v3_v3v3(val, intr, vd.co); sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) { if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist), const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist),
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade); mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2233,7 +2252,8 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_sq(&test, vd.co)) { if (sculpt_brush_test_sq(&test, vd.co)) {
if (plane_point_side_flip(vd.co, an, fc, flip)) { if (plane_point_side_flip(vd.co, an, fc, flip)) {
float intr[3]; float intr[3];
@@ -2244,9 +2264,9 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sub_v3_v3v3(val, intr, vd.co); sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) { if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, const float fade = bstrength * tex_strength(ss, brush, vd.co,
sqrt(test.dist), sqrt(test.dist),
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade); mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2334,7 +2354,8 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_cube(&test, vd.co, mat)) { if (sculpt_brush_test_cube(&test, vd.co, mat)) {
if (plane_point_side_flip(vd.co, sn, fc, flip)) { if (plane_point_side_flip(vd.co, sn, fc, flip)) {
float intr[3]; float intr[3];
@@ -2345,9 +2366,9 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
sub_v3_v3v3(val, intr, vd.co); sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) { if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, const float fade = bstrength * tex_strength(ss, brush, vd.co,
ss->cache->radius*test.dist, ss->cache->radius * test.dist,
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade); mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2397,7 +2418,8 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_sq(&test, vd.co)) { if (sculpt_brush_test_sq(&test, vd.co)) {
if (plane_point_side(vd.co, an, fc)) { if (plane_point_side(vd.co, an, fc)) {
float intr[3]; float intr[3];
@@ -2408,9 +2430,9 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sub_v3_v3v3(val, intr, vd.co); sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) { if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, const float fade = bstrength * tex_strength(ss, brush, vd.co,
sqrt(test.dist), sqrt(test.dist),
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade); mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2460,7 +2482,8 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
sculpt_brush_test_init(ss, &test); sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_sq(&test, vd.co)) { if (sculpt_brush_test_sq(&test, vd.co)) {
if (!plane_point_side(vd.co, an, fc)) { if (!plane_point_side(vd.co, an, fc)) {
float intr[3]; float intr[3];
@@ -2471,9 +2494,9 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
sub_v3_v3v3(val, intr, vd.co); sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) { if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, const float fade = bstrength * tex_strength(ss, brush, vd.co,
sqrt(test.dist), sqrt(test.dist),
an, vd.no, vd.fno, *vd.mask); an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade); mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2532,8 +2555,8 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
copy_v3_v3(mvert->co, vertCos[a]); copy_v3_v3(mvert->co, vertCos[a]);
BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop,
me->mpoly, me->totloop, me->totpoly, me->mpoly, me->totloop, me->totpoly,
NULL, NULL, 0, NULL, NULL); NULL, NULL, 0, NULL, NULL);
} }
/* apply new coords on active key block */ /* apply new coords on active key block */
@@ -2552,10 +2575,10 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush)
data.sd = sd; data.sd = sd;
data.radius_squared = ss->cache->radius_squared; data.radius_squared = ss->cache->radius_squared;
data.original = ELEM4(brush->sculpt_tool, data.original = ELEM4(brush->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_GRAB,
SCULPT_TOOL_ROTATE, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_THUMB, SCULPT_TOOL_THUMB,
SCULPT_TOOL_LAYER); SCULPT_TOOL_LAYER);
BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode);
/* Only act if some verts are inside the brush area */ /* Only act if some verts are inside the brush area */
@@ -2627,7 +2650,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush)
} }
if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) && if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) &&
brush->autosmooth_factor > 0) { brush->autosmooth_factor > 0) {
if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) {
smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure), FALSE); smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure), FALSE);
} }
@@ -2685,7 +2708,8 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
float val[3]; float val[3];
int p; int p;
@@ -2755,7 +2779,8 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
for (n = 0; n < totnode; n++) { for (n = 0; n < totnode; n++) {
PBVHVertexIter vd; PBVHVertexIter vd;
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
sculpt_flush_pbvhvert_deform(ob, &vd); sculpt_flush_pbvhvert_deform(ob, &vd);
if (vertCos) { if (vertCos) {
@@ -2799,8 +2824,8 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
* XXX However, a different approach appears to be needed */ * XXX However, a different approach appears to be needed */
#if 0 #if 0
if (sd->flags & SCULPT_SYMMETRY_FEATHER) { if (sd->flags & SCULPT_SYMMETRY_FEATHER) {
float frac = 1.0f/max_overlap_count(sd); float frac = 1.0f / max_overlap_count(sd);
float reduce = (feather-frac)/(1-frac); float reduce = (feather - frac) / (1 - frac);
printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce); printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce);
@@ -3060,7 +3085,7 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
ss->cache->clip_tolerance[i]) ss->cache->clip_tolerance[i])
{ {
ss->cache->clip_tolerance[i] = ss->cache->clip_tolerance[i] =
mmd->tolerance; mmd->tolerance;
} }
} }
} }
@@ -3122,7 +3147,7 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
Brush *br; Brush *br;
BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2,
sizeof(cache->saved_active_brush_name)); sizeof(cache->saved_active_brush_name));
br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth"); br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth");
if (br) { if (br) {
@@ -3315,8 +3340,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
if (cache->first_time) { if (cache->first_time) {
if (!BKE_brush_use_locked_size(scene, brush)) { if (!BKE_brush_use_locked_size(scene, brush)) {
cache->initial_radius = paint_calc_object_space_radius(cache->vc, cache->initial_radius = paint_calc_object_space_radius(cache->vc,
cache->true_location, cache->true_location,
BKE_brush_size_get(scene, brush)); BKE_brush_size_get(scene, brush));
BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius); BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius);
} }
else { else {
@@ -3544,7 +3569,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
is_smooth |= mode == BRUSH_STROKE_SMOOTH; is_smooth |= mode == BRUSH_STROKE_SMOOTH;
is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH; is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;
is_smooth |= ((brush->sculpt_tool == SCULPT_TOOL_MASK) && is_smooth |= ((brush->sculpt_tool == SCULPT_TOOL_MASK) &&
(brush->mask_tool == BRUSH_MASK_SMOOTH)); (brush->mask_tool == BRUSH_MASK_SMOOTH));
sculpt_update_mesh_elements(scene, sd, ob, is_smooth); sculpt_update_mesh_elements(scene, sd, ob, is_smooth);
@@ -3893,14 +3918,14 @@ void ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
int i, j; int i, j;
gmask = CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK, gmask = CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK,
CD_CALLOC, NULL, me->totloop); CD_CALLOC, NULL, me->totloop);
for (i = 0; i < me->totloop; i++) { for (i = 0; i < me->totloop; i++) {
GridPaintMask *gpm = &gmask[i]; GridPaintMask *gpm = &gmask[i];
gpm->level = level; gpm->level = level;
gpm->data = MEM_callocN(sizeof(float) * gridarea, gpm->data = MEM_callocN(sizeof(float) * gridarea,
"GridPaintMask.data"); "GridPaintMask.data");
} }
/* if vertices already have mask, copy into multires data */ /* if vertices already have mask, copy into multires data */
@@ -3925,9 +3950,9 @@ void ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
gpm->data[0] = avg; gpm->data[0] = avg;
gpm->data[1] = (paint_mask[l->v] + gpm->data[1] = (paint_mask[l->v] +
paint_mask[next->v]) * 0.5f; paint_mask[next->v]) * 0.5f;
gpm->data[2] = (paint_mask[l->v] + gpm->data[2] = (paint_mask[l->v] +
paint_mask[prev->v]) * 0.5f; paint_mask[prev->v]) * 0.5f;
gpm->data[3] = paint_mask[l->v]; gpm->data[3] = paint_mask[l->v];
} }
} }
@@ -3937,7 +3962,7 @@ void ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
/* create vertex paint mask layer if there isn't one already */ /* create vertex paint mask layer if there isn't one already */
if (!paint_mask) { if (!paint_mask) {
CustomData_add_layer(&me->vdata, CD_PAINT_MASK, CustomData_add_layer(&me->vdata, CD_PAINT_MASK,
CD_CALLOC, NULL, me->totvert); CD_CALLOC, NULL, me->totvert);
} }
} }

View File

@@ -78,8 +78,8 @@ typedef struct SculptUndoNode {
SculptUndoType type; SculptUndoType type;
char idname[MAX_ID_NAME]; /* name instead of pointer*/ char idname[MAX_ID_NAME]; /* name instead of pointer*/
void *node; /* only during push, not valid afterwards! */ void *node; /* only during push, not valid afterwards! */
float (*co)[3]; float (*co)[3];
float (*orig_co)[3]; float (*orig_co)[3];
@@ -88,15 +88,15 @@ typedef struct SculptUndoNode {
int totvert; int totvert;
/* non-multires */ /* non-multires */
int maxvert; /* to verify if totvert it still the same */ int maxvert; /* to verify if totvert it still the same */
int *index; /* to restore into right location */ int *index; /* to restore into right location */
BLI_bitmap vert_hidden; BLI_bitmap vert_hidden;
/* multires */ /* multires */
int maxgrid; /* same for grid */ int maxgrid; /* same for grid */
int gridsize; /* same for grid */ int gridsize; /* same for grid */
int totgrid; /* to restore into right location */ int totgrid; /* to restore into right location */
int *grids; /* to restore into right location */ int *grids; /* to restore into right location */
BLI_bitmap *grid_hidden; BLI_bitmap *grid_hidden;
/* layer brush */ /* layer brush */

View File

@@ -78,9 +78,9 @@ static void update_cb(PBVHNode *node, void *rebuild)
} }
static void sculpt_undo_restore_deformed(const SculptSession *ss, static void sculpt_undo_restore_deformed(const SculptSession *ss,
SculptUndoNode *unode, SculptUndoNode *unode,
int uindex, int oindex, int uindex, int oindex,
float coord[3]) float coord[3])
{ {
if (unode->orig_co) { if (unode->orig_co) {
swap_v3_v3(coord, unode->orig_co[uindex]); swap_v3_v3(coord, unode->orig_co[uindex]);
@@ -171,7 +171,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
for (j = 0; j < unode->totgrid; j++) { for (j = 0; j < unode->totgrid; j++) {
grid = grids[unode->grids[j]]; grid = grids[unode->grids[j]];
for (i = 0; i < gridsize*gridsize; i++, co++) for (i = 0; i < gridsize * gridsize; i++, co++)
swap_v3_v3(CCG_elem_offset_co(&key, grid, i), co[0]); swap_v3_v3(CCG_elem_offset_co(&key, grid, i), co[0]);
} }
} }
@@ -219,40 +219,40 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm,
static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode *unode) static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode *unode)
{ {
Object *ob= CTX_data_active_object(C); Object *ob = CTX_data_active_object(C);
SculptSession *ss= ob->sculpt; SculptSession *ss = ob->sculpt;
MVert *mvert; MVert *mvert;
float *vmask; float *vmask;
int *index, i, j; int *index, i, j;
if(unode->maxvert) { if (unode->maxvert) {
/* regular mesh restore */ /* regular mesh restore */
index= unode->index; index = unode->index;
mvert= ss->mvert; mvert = ss->mvert;
vmask= ss->vmask; vmask = ss->vmask;
for(i=0; i<unode->totvert; i++) { for (i = 0; i < unode->totvert; i++) {
SWAP(float, vmask[index[i]], unode->mask[i]); SWAP(float, vmask[index[i]], unode->mask[i]);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
} }
} }
else if(unode->maxgrid && dm->getGridData) { else if (unode->maxgrid && dm->getGridData) {
/* multires restore */ /* multires restore */
CCGElem **grids, *grid; CCGElem **grids, *grid;
CCGKey key; CCGKey key;
float *mask; float *mask;
int gridsize; int gridsize;
grids= dm->getGridData(dm); grids = dm->getGridData(dm);
gridsize= dm->getGridSize(dm); gridsize = dm->getGridSize(dm);
dm->getGridKey(dm, &key); dm->getGridKey(dm, &key);
mask = unode->mask; mask = unode->mask;
for(j=0; j<unode->totgrid; j++) { for (j = 0; j < unode->totgrid; j++) {
grid= grids[unode->grids[j]]; grid = grids[unode->grids[j]];
for(i=0; i<gridsize*gridsize; i++, mask++) for (i = 0; i < gridsize * gridsize; i++, mask++)
SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask); SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask);
} }
} }
@@ -294,18 +294,18 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
continue; continue;
} }
switch(unode->type) { switch (unode->type) {
case SCULPT_UNDO_COORDS: case SCULPT_UNDO_COORDS:
if (sculpt_undo_restore_coords(C, dm, unode)) if (sculpt_undo_restore_coords(C, dm, unode))
update= 1; update = 1;
break; break;
case SCULPT_UNDO_HIDDEN: case SCULPT_UNDO_HIDDEN:
if (sculpt_undo_restore_hidden(C, dm, unode)) if (sculpt_undo_restore_hidden(C, dm, unode))
rebuild= 1; rebuild = 1;
break; break;
case SCULPT_UNDO_MASK: case SCULPT_UNDO_MASK:
if(sculpt_undo_restore_mask(C, dm, unode)) if (sculpt_undo_restore_mask(C, dm, unode))
update= 1; update = 1;
break; break;
} }
} }
@@ -371,7 +371,7 @@ static void sculpt_undo_free(ListBase *lb)
} }
MEM_freeN(unode->grid_hidden); MEM_freeN(unode->grid_hidden);
} }
if(unode->mask) if (unode->mask)
MEM_freeN(unode->mask); MEM_freeN(unode->mask);
} }
} }
@@ -441,9 +441,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node,
unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co"); unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co");
unode->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no"); unode->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no");
undo_paint_push_count_alloc(UNDO_PAINT_MESH, undo_paint_push_count_alloc(UNDO_PAINT_MESH,
(sizeof(float) * 3 + (sizeof(float) * 3 +
sizeof(short) * 3 + sizeof(short) * 3 +
sizeof(int)) * allvert); sizeof(int)) * allvert);
break; break;
case SCULPT_UNDO_HIDDEN: case SCULPT_UNDO_HIDDEN:
if (maxgrid) if (maxgrid)
@@ -453,8 +453,8 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node,
break; break;
case SCULPT_UNDO_MASK: case SCULPT_UNDO_MASK:
unode->mask= MEM_mapallocN(sizeof(float)*allvert, "SculptUndoNode.mask"); unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask");
undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * sizeof(int))*allvert); undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * sizeof(int)) * allvert);
break; break;
} }
@@ -484,7 +484,8 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
SculptSession *ss = ob->sculpt; SculptSession *ss = ob->sculpt;
PBVHVertexIter vd; PBVHVertexIter vd;
BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) { BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL)
{
copy_v3_v3(unode->co[vd.i], vd.co); copy_v3_v3(unode->co[vd.i], vd.co);
if (vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); if (vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no);
else normal_float_to_short_v3(unode->no[vd.i], vd.fno); else normal_float_to_short_v3(unode->no[vd.i], vd.fno);
@@ -522,7 +523,8 @@ static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode)
SculptSession *ss = ob->sculpt; SculptSession *ss = ob->sculpt;
PBVHVertexIter vd; PBVHVertexIter vd;
BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) { BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL)
{
unode->mask[vd.i] = *vd.mask; unode->mask[vd.i] = *vd.mask;
} }
BLI_pbvh_vertex_iter_end; BLI_pbvh_vertex_iter_end;

View File

@@ -402,7 +402,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0); initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0);
derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd,
NULL, SUBSURF_IN_EDIT_MODE); NULL, SUBSURF_IN_EDIT_MODE);
initialDerived->release(initialDerived); initialDerived->release(initialDerived);
@@ -1182,7 +1182,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh."); BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh.");
/* remember last method for live unwrap */ /* remember last method for live unwrap */
if(RNA_struct_property_is_set(op->ptr, "method")) if (RNA_struct_property_is_set(op->ptr, "method"))
scene->toolsettings->unwrapper = method; scene->toolsettings->unwrapper = method;
scene->toolsettings->uv_subsurf_level = subsurf_level; scene->toolsettings->uv_subsurf_level = subsurf_level;
@@ -1210,7 +1210,8 @@ void UV_OT_unwrap(wmOperatorType *ot)
static EnumPropertyItem method_items[] = { static EnumPropertyItem method_items[] = {
{0, "ANGLE_BASED", 0, "Angle Based", ""}, {0, "ANGLE_BASED", 0, "Angle Based", ""},
{1, "CONFORMAL", 0, "Conformal", ""}, {1, "CONFORMAL", 0, "Conformal", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
/* identifiers */ /* identifiers */
ot->name = "Unwrap"; ot->name = "Unwrap";

View File

@@ -105,8 +105,8 @@ static GPUBufferPool *gpu_buffer_pool_new(void)
pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer"); pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer");
pool->maxsize = MAX_FREE_GPU_BUFFERS; pool->maxsize = MAX_FREE_GPU_BUFFERS;
pool->buffers = MEM_callocN(sizeof(GPUBuffer*)*pool->maxsize, pool->buffers = MEM_callocN(sizeof(GPUBuffer *) * pool->maxsize,
"GPUBuffer.buffers"); "GPUBuffer.buffers");
return pool; return pool;
} }
@@ -121,7 +121,7 @@ static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index)
/* shift entries down, overwriting the buffer at `index' */ /* shift entries down, overwriting the buffer at `index' */
for (i = index; i < pool->totbuf - 1; i++) for (i = index; i < pool->totbuf - 1; i++)
pool->buffers[i] = pool->buffers[i+1]; pool->buffers[i] = pool->buffers[i + 1];
/* clear the last entry */ /* clear the last entry */
if (pool->totbuf > 0) if (pool->totbuf > 0)
@@ -289,13 +289,13 @@ void GPU_buffer_free(GPUBuffer *buffer)
if (pool->maxsize == pool->totbuf) { if (pool->maxsize == pool->totbuf) {
pool->maxsize += MAX_FREE_GPU_BUFFERS; pool->maxsize += MAX_FREE_GPU_BUFFERS;
pool->buffers = MEM_reallocN(pool->buffers, pool->buffers = MEM_reallocN(pool->buffers,
sizeof(GPUBuffer*) * pool->maxsize); sizeof(GPUBuffer *) * pool->maxsize);
} }
} }
/* shift pool entries up by one */ /* shift pool entries up by one */
for (i = pool->totbuf; i > 0; i--) for (i = pool->totbuf; i > 0; i--)
pool->buffers[i] = pool->buffers[i-1]; pool->buffers[i] = pool->buffers[i - 1];
/* insert the buffer into the beginning of the pool */ /* insert the buffer into the beginning of the pool */
pool->buffers[0] = buffer; pool->buffers[0] = buffer;
@@ -319,7 +319,7 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in
/* if first link is in use, add a new link at the end */ /* if first link is in use, add a new link at the end */
if (lnk->point_index != -1) { if (lnk->point_index != -1) {
/* get last link */ /* get last link */
for (; lnk->next; lnk = lnk->next); for (; lnk->next; lnk = lnk->next) ;
/* add a new link from the pool */ /* add a new link from the pool */
lnk = lnk->next = &gdo->vert_points_mem[gdo->vert_points_usage]; lnk = lnk->next = &gdo->vert_points_mem[gdo->vert_points_usage];
@@ -332,9 +332,9 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in
/* update the vert_points and triangle_to_mface fields with a new /* update the vert_points and triangle_to_mface fields with a new
* triangle */ * triangle */
static void gpu_drawobject_add_triangle(GPUDrawObject *gdo, static void gpu_drawobject_add_triangle(GPUDrawObject *gdo,
int base_point_index, int base_point_index,
int face_index, int face_index,
int v1, int v2, int v3) int v1, int v2, int v3)
{ {
int i, v[3] = {v1, v2, v3}; int i, v[3] = {v1, v2, v3};
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
@@ -351,9 +351,9 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
/* allocate the array and space for links */ /* allocate the array and space for links */
gdo->vert_points = MEM_callocN(sizeof(GPUVertPointLink) * gdo->totvert, gdo->vert_points = MEM_callocN(sizeof(GPUVertPointLink) * gdo->totvert,
"GPUDrawObject.vert_points"); "GPUDrawObject.vert_points");
gdo->vert_points_mem = MEM_callocN(sizeof(GPUVertPointLink) * gdo->tot_triangle_point, gdo->vert_points_mem = MEM_callocN(sizeof(GPUVertPointLink) * gdo->tot_triangle_point,
"GPUDrawObject.vert_points_mem"); "GPUDrawObject.vert_points_mem");
gdo->vert_points_usage = 0; gdo->vert_points_usage = 0;
/* build a map from the original material indices to the new /* build a map from the original material indices to the new
@@ -370,13 +370,13 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
/* add triangle */ /* add triangle */
gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint,
i, f->v1, f->v2, f->v3); i, f->v1, f->v2, f->v3);
mat->totpoint += 3; mat->totpoint += 3;
/* add second triangle for quads */ /* add second triangle for quads */
if (f->v4) { if (f->v4) {
gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint,
i, f->v3, f->v4, f->v1); i, f->v3, f->v4, f->v1);
mat->totpoint += 3; mat->totpoint += 3;
} }
} }
@@ -392,7 +392,7 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
/* see GPUDrawObject's structure definition for a description of the /* see GPUDrawObject's structure definition for a description of the
* data being initialized here */ * data being initialized here */
GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm)
{ {
GPUDrawObject *gdo; GPUDrawObject *gdo;
MFace *mface; MFace *mface;
@@ -400,11 +400,11 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm )
int i, curmat, curpoint, totface; int i, curmat, curpoint, totface;
mface = dm->getTessFaceArray(dm); mface = dm->getTessFaceArray(dm);
totface= dm->getNumTessFaces(dm); totface = dm->getNumTessFaces(dm);
/* get the number of points used by each material, treating /* get the number of points used by each material, treating
* each quad as two triangles */ * each quad as two triangles */
memset(points_per_mat, 0, sizeof(int)*MAX_MATERIALS); memset(points_per_mat, 0, sizeof(int) * MAX_MATERIALS);
for (i = 0; i < totface; i++) for (i = 0; i < totface; i++)
points_per_mat[mface[i].mat_nr] += mface[i].v4 ? 6 : 3; points_per_mat[mface[i].mat_nr] += mface[i].v4 ? 6 : 3;
@@ -421,7 +421,7 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm )
/* allocate an array of materials used by this DerivedMesh */ /* allocate an array of materials used by this DerivedMesh */
gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial, gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial,
"GPUDrawObject.materials"); "GPUDrawObject.materials");
/* initialize the materials array */ /* initialize the materials array */
for (i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) { for (i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) {
@@ -439,7 +439,7 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm )
gdo->tot_triangle_point = curpoint; gdo->tot_triangle_point = curpoint;
gdo->triangle_to_mface = MEM_mallocN(sizeof(int) * (gdo->tot_triangle_point / 3), gdo->triangle_to_mface = MEM_mallocN(sizeof(int) * (gdo->tot_triangle_point / 3),
"GPUDrawObject.triangle_to_mface"); "GPUDrawObject.triangle_to_mface");
gpu_drawobject_init_vert_points(gdo, mface, totface); gpu_drawobject_init_vert_points(gdo, mface, totface);
@@ -494,8 +494,8 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
if (dm->drawObject->legacy) if (dm->drawObject->legacy)
return NULL; return NULL;
cur_index_per_mat = MEM_mallocN(sizeof(int)*object->totmaterial, cur_index_per_mat = MEM_mallocN(sizeof(int) * object->totmaterial,
"GPU_buffer_setup.cur_index_per_mat"); "GPU_buffer_setup.cur_index_per_mat");
for (i = 0; i < object->totmaterial; i++) { for (i = 0; i < object->totmaterial; i++) {
/* for each material, the current index to copy data to */ /* for each material, the current index to copy data to */
cur_index_per_mat[i] = object->materials[i].start * vector_size; cur_index_per_mat[i] = object->materials[i].start * vector_size;
@@ -519,7 +519,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
/* failed to map the buffer; delete it */ /* failed to map the buffer; delete it */
GPU_buffer_free(buffer); GPU_buffer_free(buffer);
gpu_buffer_pool_delete_last(pool); gpu_buffer_pool_delete_last(pool);
buffer= NULL; buffer = NULL;
/* try freeing an entry from the pool /* try freeing an entry from the pool
* and reallocating the buffer */ * and reallocating the buffer */
@@ -579,31 +579,31 @@ static void GPU_buffer_copy_vertex(DerivedMesh *dm, float *varray, int *index, i
mvert = dm->getVertArray(dm); mvert = dm->getVertArray(dm);
f = dm->getTessFaceArray(dm); f = dm->getTessFaceArray(dm);
totface= dm->getNumTessFaces(dm); totface = dm->getNumTessFaces(dm);
for (i = 0; i < totface; i++, f++) { for (i = 0; i < totface; i++, f++) {
start = index[mat_orig_to_new[f->mat_nr]]; start = index[mat_orig_to_new[f->mat_nr]];
/* v1 v2 v3 */ /* v1 v2 v3 */
copy_v3_v3(&varray[start], mvert[f->v1].co); copy_v3_v3(&varray[start], mvert[f->v1].co);
copy_v3_v3(&varray[start+3], mvert[f->v2].co); copy_v3_v3(&varray[start + 3], mvert[f->v2].co);
copy_v3_v3(&varray[start+6], mvert[f->v3].co); copy_v3_v3(&varray[start + 6], mvert[f->v3].co);
index[mat_orig_to_new[f->mat_nr]] += 9; index[mat_orig_to_new[f->mat_nr]] += 9;
if (f->v4) { if (f->v4) {
/* v3 v4 v1 */ /* v3 v4 v1 */
copy_v3_v3(&varray[start+9], mvert[f->v3].co); copy_v3_v3(&varray[start + 9], mvert[f->v3].co);
copy_v3_v3(&varray[start+12], mvert[f->v4].co); copy_v3_v3(&varray[start + 12], mvert[f->v4].co);
copy_v3_v3(&varray[start+15], mvert[f->v1].co); copy_v3_v3(&varray[start + 15], mvert[f->v1].co);
index[mat_orig_to_new[f->mat_nr]] += 9; index[mat_orig_to_new[f->mat_nr]] += 9;
} }
} }
/* copy loose points */ /* copy loose points */
j = dm->drawObject->tot_triangle_point*3; j = dm->drawObject->tot_triangle_point * 3;
for (i = 0; i < dm->drawObject->totvert; i++) { for (i = 0; i < dm->drawObject->totvert; i++) {
if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) { if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) {
copy_v3_v3(&varray[j], mvert[i].co); copy_v3_v3(&varray[j], mvert[i].co);
j+=3; j += 3;
} }
} }
} }
@@ -614,11 +614,11 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
int start; int start;
float f_no[3]; float f_no[3];
float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
MVert *mvert = dm->getVertArray(dm); MVert *mvert = dm->getVertArray(dm);
MFace *f = dm->getTessFaceArray(dm); MFace *f = dm->getTessFaceArray(dm);
totface= dm->getNumTessFaces(dm); totface = dm->getNumTessFaces(dm);
for (i = 0; i < totface; i++, f++) { for (i = 0; i < totface; i++, f++) {
const int smoothnormal = (f->flag & ME_SMOOTH); const int smoothnormal = (f->flag & ME_SMOOTH);
@@ -628,25 +628,25 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
if (smoothnormal) { if (smoothnormal) {
/* copy vertex normal */ /* copy vertex normal */
normal_short_to_float_v3(&varray[start], mvert[f->v1].no); normal_short_to_float_v3(&varray[start], mvert[f->v1].no);
normal_short_to_float_v3(&varray[start+3], mvert[f->v2].no); normal_short_to_float_v3(&varray[start + 3], mvert[f->v2].no);
normal_short_to_float_v3(&varray[start+6], mvert[f->v3].no); normal_short_to_float_v3(&varray[start + 6], mvert[f->v3].no);
if (f->v4) { if (f->v4) {
normal_short_to_float_v3(&varray[start+9], mvert[f->v3].no); normal_short_to_float_v3(&varray[start + 9], mvert[f->v3].no);
normal_short_to_float_v3(&varray[start+12], mvert[f->v4].no); normal_short_to_float_v3(&varray[start + 12], mvert[f->v4].no);
normal_short_to_float_v3(&varray[start+15], mvert[f->v1].no); normal_short_to_float_v3(&varray[start + 15], mvert[f->v1].no);
} }
} }
else if (nors) { else if (nors) {
/* copy cached face normal */ /* copy cached face normal */
copy_v3_v3(&varray[start], &nors[i*3]); copy_v3_v3(&varray[start], &nors[i * 3]);
copy_v3_v3(&varray[start+3], &nors[i*3]); copy_v3_v3(&varray[start + 3], &nors[i * 3]);
copy_v3_v3(&varray[start+6], &nors[i*3]); copy_v3_v3(&varray[start + 6], &nors[i * 3]);
if (f->v4) { if (f->v4) {
copy_v3_v3(&varray[start+9], &nors[i*3]); copy_v3_v3(&varray[start + 9], &nors[i * 3]);
copy_v3_v3(&varray[start+12], &nors[i*3]); copy_v3_v3(&varray[start + 12], &nors[i * 3]);
copy_v3_v3(&varray[start+15], &nors[i*3]); copy_v3_v3(&varray[start + 15], &nors[i * 3]);
} }
} }
else { else {
@@ -657,13 +657,13 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
normal_tri_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co); normal_tri_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co);
copy_v3_v3(&varray[start], f_no); copy_v3_v3(&varray[start], f_no);
copy_v3_v3(&varray[start+3], f_no); copy_v3_v3(&varray[start + 3], f_no);
copy_v3_v3(&varray[start+6], f_no); copy_v3_v3(&varray[start + 6], f_no);
if (f->v4) { if (f->v4) {
copy_v3_v3(&varray[start+9], f_no); copy_v3_v3(&varray[start + 9], f_no);
copy_v3_v3(&varray[start+12], f_no); copy_v3_v3(&varray[start + 12], f_no);
copy_v3_v3(&varray[start+15], f_no); copy_v3_v3(&varray[start + 15], f_no);
} }
} }
} }
@@ -687,15 +687,15 @@ static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int *
/* v1 v2 v3 */ /* v1 v2 v3 */
copy_v2_v2(&varray[start], mtface[i].uv[0]); copy_v2_v2(&varray[start], mtface[i].uv[0]);
copy_v2_v2(&varray[start+2], mtface[i].uv[1]); copy_v2_v2(&varray[start + 2], mtface[i].uv[1]);
copy_v2_v2(&varray[start+4], mtface[i].uv[2]); copy_v2_v2(&varray[start + 4], mtface[i].uv[2]);
index[mat_orig_to_new[f->mat_nr]] += 6; index[mat_orig_to_new[f->mat_nr]] += 6;
if (f->v4) { if (f->v4) {
/* v3 v4 v1 */ /* v3 v4 v1 */
copy_v2_v2(&varray[start+6], mtface[i].uv[2]); copy_v2_v2(&varray[start + 6], mtface[i].uv[2]);
copy_v2_v2(&varray[start+8], mtface[i].uv[3]); copy_v2_v2(&varray[start + 8], mtface[i].uv[3]);
copy_v2_v2(&varray[start+10], mtface[i].uv[0]); copy_v2_v2(&varray[start + 10], mtface[i].uv[0]);
index[mat_orig_to_new[f->mat_nr]] += 6; index[mat_orig_to_new[f->mat_nr]] += 6;
} }
} }
@@ -709,21 +709,21 @@ static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index,
char *mcol = (char *)user; char *mcol = (char *)user;
MFace *f = dm->getTessFaceArray(dm); MFace *f = dm->getTessFaceArray(dm);
totface= dm->getNumTessFaces(dm); totface = dm->getNumTessFaces(dm);
for (i=0; i < totface; i++, f++) { for (i = 0; i < totface; i++, f++) {
int start = index[mat_orig_to_new[f->mat_nr]]; int start = index[mat_orig_to_new[f->mat_nr]];
/* v1 v2 v3 */ /* v1 v2 v3 */
copy_v3_v3_char(&varray[start], &mcol[i*12]); copy_v3_v3_char(&varray[start], &mcol[i * 12]);
copy_v3_v3_char(&varray[start+3], &mcol[i*12+3]); copy_v3_v3_char(&varray[start + 3], &mcol[i * 12 + 3]);
copy_v3_v3_char(&varray[start+6], &mcol[i*12+6]); copy_v3_v3_char(&varray[start + 6], &mcol[i * 12 + 6]);
index[mat_orig_to_new[f->mat_nr]] += 9; index[mat_orig_to_new[f->mat_nr]] += 9;
if (f->v4) { if (f->v4) {
/* v3 v4 v1 */ /* v3 v4 v1 */
copy_v3_v3_char(&varray[start+9], &mcol[i*12+6]); copy_v3_v3_char(&varray[start + 9], &mcol[i * 12 + 6]);
copy_v3_v3_char(&varray[start+12], &mcol[i*12+9]); copy_v3_v3_char(&varray[start + 12], &mcol[i * 12 + 9]);
copy_v3_v3_char(&varray[start+15], &mcol[i*12]); copy_v3_v3_char(&varray[start + 15], &mcol[i * 12]);
index[mat_orig_to_new[f->mat_nr]] += 9; index[mat_orig_to_new[f->mat_nr]] += 9;
} }
} }
@@ -744,21 +744,21 @@ static void GPU_buffer_copy_mcol(DerivedMesh *dm, float *varray_, int *index, in
unsigned char *mcol = (unsigned char *)user; unsigned char *mcol = (unsigned char *)user;
MFace *f = dm->getTessFaceArray(dm); MFace *f = dm->getTessFaceArray(dm);
totface= dm->getNumTessFaces(dm); totface = dm->getNumTessFaces(dm);
for (i=0; i < totface; i++, f++) { for (i = 0; i < totface; i++, f++) {
int start = index[mat_orig_to_new[f->mat_nr]]; int start = index[mat_orig_to_new[f->mat_nr]];
/* v1 v2 v3 */ /* v1 v2 v3 */
copy_mcol_uc3(&varray[start], &mcol[i*16]); copy_mcol_uc3(&varray[start], &mcol[i * 16]);
copy_mcol_uc3(&varray[start+3], &mcol[i*16+4]); copy_mcol_uc3(&varray[start + 3], &mcol[i * 16 + 4]);
copy_mcol_uc3(&varray[start+6], &mcol[i*16+8]); copy_mcol_uc3(&varray[start + 6], &mcol[i * 16 + 8]);
index[mat_orig_to_new[f->mat_nr]] += 9; index[mat_orig_to_new[f->mat_nr]] += 9;
if (f->v4) { if (f->v4) {
/* v3 v4 v1 */ /* v3 v4 v1 */
copy_mcol_uc3(&varray[start+9], &mcol[i*16+8]); copy_mcol_uc3(&varray[start + 9], &mcol[i * 16 + 8]);
copy_mcol_uc3(&varray[start+12], &mcol[i*16+12]); copy_mcol_uc3(&varray[start + 12], &mcol[i * 16 + 12]);
copy_mcol_uc3(&varray[start+15], &mcol[i*16]); copy_mcol_uc3(&varray[start + 15], &mcol[i * 16]);
index[mat_orig_to_new[f->mat_nr]] += 9; index[mat_orig_to_new[f->mat_nr]] += 9;
} }
} }
@@ -774,15 +774,15 @@ static void GPU_buffer_copy_edge(DerivedMesh *dm, float *varray_, int *UNUSED(in
totedge = dm->getNumEdges(dm); totedge = dm->getNumEdges(dm);
for (i = 0; i < totedge; i++, medge++) { for (i = 0; i < totedge; i++, medge++) {
varray[i*2] = dm->drawObject->vert_points[medge->v1].point_index; varray[i * 2] = dm->drawObject->vert_points[medge->v1].point_index;
varray[i*2+1] = dm->drawObject->vert_points[medge->v2].point_index; varray[i * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index;
} }
} }
static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(index), int *UNUSED(mat_orig_to_new), void *UNUSED(user)) static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(index), int *UNUSED(mat_orig_to_new), void *UNUSED(user))
{ {
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
int i, j=0; int i, j = 0;
if (!tf) if (!tf)
return; return;
@@ -792,23 +792,23 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i
dm->getTessFace(dm, i, &mf); dm->getTessFace(dm, i, &mf);
copy_v2_v2(&varray[j], tf->uv[0]); copy_v2_v2(&varray[j], tf->uv[0]);
copy_v2_v2(&varray[j+2], tf->uv[1]); copy_v2_v2(&varray[j + 2], tf->uv[1]);
copy_v2_v2(&varray[j+4], tf->uv[1]); copy_v2_v2(&varray[j + 4], tf->uv[1]);
copy_v2_v2(&varray[j+6], tf->uv[2]); copy_v2_v2(&varray[j + 6], tf->uv[2]);
if (!mf.v4) { if (!mf.v4) {
copy_v2_v2(&varray[j+8], tf->uv[2]); copy_v2_v2(&varray[j + 8], tf->uv[2]);
copy_v2_v2(&varray[j+10], tf->uv[0]); copy_v2_v2(&varray[j + 10], tf->uv[0]);
j+=12; j += 12;
} }
else { else {
copy_v2_v2(&varray[j+8], tf->uv[2]); copy_v2_v2(&varray[j + 8], tf->uv[2]);
copy_v2_v2(&varray[j+10], tf->uv[3]); copy_v2_v2(&varray[j + 10], tf->uv[3]);
copy_v2_v2(&varray[j+12], tf->uv[3]); copy_v2_v2(&varray[j + 12], tf->uv[3]);
copy_v2_v2(&varray[j+14], tf->uv[0]); copy_v2_v2(&varray[j + 14], tf->uv[0]);
j+=16; j += 16;
} }
} }
} }
@@ -863,20 +863,20 @@ const GPUBufferTypeSettings gpu_buffer_type_settings[] = {
static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type) static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type)
{ {
switch (type) { switch (type) {
case GPU_BUFFER_VERTEX: case GPU_BUFFER_VERTEX:
return &gdo->points; return &gdo->points;
case GPU_BUFFER_NORMAL: case GPU_BUFFER_NORMAL:
return &gdo->normals; return &gdo->normals;
case GPU_BUFFER_COLOR: case GPU_BUFFER_COLOR:
return &gdo->colors; return &gdo->colors;
case GPU_BUFFER_UV: case GPU_BUFFER_UV:
return &gdo->uv; return &gdo->uv;
case GPU_BUFFER_EDGE: case GPU_BUFFER_EDGE:
return &gdo->edges; return &gdo->edges;
case GPU_BUFFER_UVEDGE: case GPU_BUFFER_UVEDGE:
return &gdo->uvedges; return &gdo->uvedges;
default: default:
return NULL; return NULL;
} }
} }
@@ -884,25 +884,25 @@ static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBuffer
static int gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type) static int gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type)
{ {
switch (type) { switch (type) {
case GPU_BUFFER_VERTEX: case GPU_BUFFER_VERTEX:
return sizeof(float)*3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); return sizeof(float) * 3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point);
case GPU_BUFFER_NORMAL: case GPU_BUFFER_NORMAL:
return sizeof(float)*3*dm->drawObject->tot_triangle_point; return sizeof(float) * 3 * dm->drawObject->tot_triangle_point;
case GPU_BUFFER_COLOR: case GPU_BUFFER_COLOR:
return sizeof(char)*3*dm->drawObject->tot_triangle_point; return sizeof(char) * 3 * dm->drawObject->tot_triangle_point;
case GPU_BUFFER_UV: case GPU_BUFFER_UV:
return sizeof(float)*2*dm->drawObject->tot_triangle_point; return sizeof(float) * 2 * dm->drawObject->tot_triangle_point;
case GPU_BUFFER_EDGE: case GPU_BUFFER_EDGE:
return sizeof(int)*2*dm->drawObject->totedge; return sizeof(int) * 2 * dm->drawObject->totedge;
case GPU_BUFFER_UVEDGE: case GPU_BUFFER_UVEDGE:
/* each face gets 3 points, 3 edges per triangle, and /* each face gets 3 points, 3 edges per triangle, and
* each edge has its own, non-shared coords, so each * each edge has its own, non-shared coords, so each
* tri corner needs minimum of 4 floats, quads used * tri corner needs minimum of 4 floats, quads used
* less so here we can over allocate and assume all * less so here we can over allocate and assume all
* tris. */ * tris. */
return sizeof(float) * 4 * dm->drawObject->tot_triangle_point; return sizeof(float) * 4 * dm->drawObject->tot_triangle_point;
default: default:
return -1; return -1;
} }
} }
@@ -1061,18 +1061,18 @@ void GPU_uvedge_setup(DerivedMesh *dm)
static int GPU_typesize(int type) static int GPU_typesize(int type)
{ {
switch (type) { switch (type) {
case GL_FLOAT: case GL_FLOAT:
return sizeof(float); return sizeof(float);
case GL_INT: case GL_INT:
return sizeof(int); return sizeof(int);
case GL_UNSIGNED_INT: case GL_UNSIGNED_INT:
return sizeof(unsigned int); return sizeof(unsigned int);
case GL_BYTE: case GL_BYTE:
return sizeof(char); return sizeof(char);
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
return sizeof(unsigned char); return sizeof(unsigned char);
default: default:
return 0; return 0;
} }
} }
@@ -1083,7 +1083,7 @@ int GPU_attrib_element_size(GPUAttrib data[], int numdata)
for (i = 0; i < numdata; i++) { for (i = 0; i < numdata; i++) {
int typesize = GPU_typesize(data[i].type); int typesize = GPU_typesize(data[i].type);
if (typesize != 0) if (typesize != 0)
elementsize += typesize*data[i].size; elementsize += typesize * data[i].size;
} }
return elementsize; return elementsize;
} }
@@ -1108,8 +1108,8 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda
for (i = 0; i < numdata; i++) { for (i = 0; i < numdata; i++) {
glEnableVertexAttribArrayARB(data[i].index); glEnableVertexAttribArrayARB(data[i].index);
glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type,
GL_FALSE, elementsize, (void *)offset); GL_FALSE, elementsize, (void *)offset);
offset += data[i].size*GPU_typesize(data[i].type); offset += data[i].size * GPU_typesize(data[i].type);
attribData[i].index = data[i].index; attribData[i].index = data[i].index;
attribData[i].size = data[i].size; attribData[i].size = data[i].size;
@@ -1121,8 +1121,8 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda
for (i = 0; i < numdata; i++) { for (i = 0; i < numdata; i++) {
glEnableVertexAttribArrayARB(data[i].index); glEnableVertexAttribArrayARB(data[i].index);
glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type,
GL_FALSE, elementsize, (char *)buffer->pointer + offset); GL_FALSE, elementsize, (char *)buffer->pointer + offset);
offset += data[i].size*GPU_typesize(data[i].type); offset += data[i].size * GPU_typesize(data[i].type);
} }
} }
} }
@@ -1171,8 +1171,8 @@ void GPU_color3_upload(DerivedMesh *dm, unsigned char *data)
GPU_buffer_free(dm->drawObject->colors); GPU_buffer_free(dm->drawObject->colors);
dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3, dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3,
sizeof(char)*3*dm->drawObject->tot_triangle_point, sizeof(char) * 3 * dm->drawObject->tot_triangle_point,
GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3); GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3);
} }
void GPU_color_switch(int mode) void GPU_color_switch(int mode)
@@ -1193,7 +1193,7 @@ void GPU_color_switch(int mode)
* code, 0 otherwise */ * code, 0 otherwise */
int GPU_buffer_legacy(DerivedMesh *dm) int GPU_buffer_legacy(DerivedMesh *dm)
{ {
int test= (U.gameflags & USER_DISABLE_VBO); int test = (U.gameflags & USER_DISABLE_VBO);
if (test) if (test)
return 1; return 1;
@@ -1254,9 +1254,9 @@ void GPU_buffer_unlock(GPUBuffer *buffer)
void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count) void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count)
{ {
glDrawElements(mode, count, GL_UNSIGNED_INT, glDrawElements(mode, count, GL_UNSIGNED_INT,
(useVBOs ? (useVBOs ?
(void*)(start * sizeof(unsigned int)) : (void *)(start * sizeof(unsigned int)) :
((int*)elements->pointer) + start)); ((int *)elements->pointer) + start));
} }
@@ -1308,14 +1308,14 @@ static void gpu_colors_enable(VBO_State vbo_state)
{ {
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
if(vbo_state == VBO_ENABLED) if (vbo_state == VBO_ENABLED)
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
} }
static void gpu_colors_disable(VBO_State vbo_state) static void gpu_colors_disable(VBO_State vbo_state)
{ {
glDisable(GL_COLOR_MATERIAL); glDisable(GL_COLOR_MATERIAL);
if(vbo_state == VBO_ENABLED) if (vbo_state == VBO_ENABLED)
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
} }
@@ -1342,25 +1342,25 @@ static void gpu_color_from_mask_set(float mask)
} }
static float gpu_color_from_mask_quad(const CCGKey *key, static float gpu_color_from_mask_quad(const CCGKey *key,
CCGElem *a, CCGElem *b, CCGElem *a, CCGElem *b,
CCGElem *c, CCGElem *d) CCGElem *c, CCGElem *d)
{ {
return gpu_color_from_mask((*CCG_elem_mask(key, a) + return gpu_color_from_mask((*CCG_elem_mask(key, a) +
*CCG_elem_mask(key, b) + *CCG_elem_mask(key, b) +
*CCG_elem_mask(key, c) + *CCG_elem_mask(key, c) +
*CCG_elem_mask(key, d)) * 0.25f); *CCG_elem_mask(key, d)) * 0.25f);
} }
static void gpu_color_from_mask_quad_copy(const CCGKey *key, static void gpu_color_from_mask_quad_copy(const CCGKey *key,
CCGElem *a, CCGElem *b, CCGElem *a, CCGElem *b,
CCGElem *c, CCGElem *d, CCGElem *c, CCGElem *d,
unsigned char out[3]) unsigned char out[3])
{ {
unsigned char color = unsigned char color =
gpu_color_from_mask((*CCG_elem_mask(key, a) + gpu_color_from_mask((*CCG_elem_mask(key, a) +
*CCG_elem_mask(key, b) + *CCG_elem_mask(key, b) +
*CCG_elem_mask(key, c) + *CCG_elem_mask(key, c) +
*CCG_elem_mask(key, d)) * 0.25f) * 255.0f; *CCG_elem_mask(key, d)) * 0.25f) * 255.0f;
out[0] = color; out[0] = color;
out[1] = color; out[1] = color;
@@ -1368,15 +1368,15 @@ static void gpu_color_from_mask_quad_copy(const CCGKey *key,
} }
static void gpu_color_from_mask_quad_set(const CCGKey *key, static void gpu_color_from_mask_quad_set(const CCGKey *key,
CCGElem *a, CCGElem *b, CCGElem *a, CCGElem *b,
CCGElem *c, CCGElem *d) CCGElem *c, CCGElem *d)
{ {
float color = gpu_color_from_mask_quad(key, a, b, c, d); float color = gpu_color_from_mask_quad(key, a, b, c, d);
glColor3f(color, color, color); glColor3f(color, color, color);
} }
void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
int *vert_indices, int totvert, const float *vmask) int *vert_indices, int totvert, const float *vmask)
{ {
VertexBufferFormat *vert_data; VertexBufferFormat *vert_data;
int i; int i;
@@ -1399,7 +1399,7 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
copy_v3_v3(out->co, v->co); copy_v3_v3(out->co, v->co);
memcpy(out->no, v->no, sizeof(short) * 3); memcpy(out->no, v->no, sizeof(short) * 3);
gpu_color_from_mask_copy(vmask[vert_indices[i]], gpu_color_from_mask_copy(vmask[vert_indices[i]],
out->color); out->color);
} }
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
@@ -1416,9 +1416,9 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
} }
GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
MFace *mface, MVert *mvert, MFace *mface, MVert *mvert,
int *face_indices, int *face_indices,
int totface) int totface)
{ {
GPU_Buffers *buffers; GPU_Buffers *buffers;
unsigned short *tri_data; unsigned short *tri_data;
@@ -1454,9 +1454,9 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
if (paint_is_face_hidden(f, mvert)) if (paint_is_face_hidden(f, mvert))
continue; continue;
v[0]= 0; v[0] = 0;
v[1]= 1; v[1] = 1;
v[2]= 2; v[2] = 2;
for (j = 0; j < (f->v4 ? 2 : 1); ++j) { for (j = 0; j < (f->v4 ? 2 : 1); ++j) {
for (k = 0; k < 3; ++k) { for (k = 0; k < 3; ++k) {
@@ -1491,8 +1491,8 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
} }
void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
const DMFlagMat *grid_flag_mats, int *grid_indices, const DMFlagMat *grid_flag_mats, int *grid_indices,
int totgrid, const CCGKey *key) int totgrid, const CCGKey *key)
{ {
VertexBufferFormat *vert_data; VertexBufferFormat *vert_data;
int i, j, k, x, y; int i, j, k, x, y;
@@ -1510,19 +1510,19 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
if (vert_data) { if (vert_data) {
for (i = 0; i < totgrid; ++i) { for (i = 0; i < totgrid; ++i) {
VertexBufferFormat *vd = vert_data; VertexBufferFormat *vd = vert_data;
CCGElem *grid= grids[grid_indices[i]]; CCGElem *grid = grids[grid_indices[i]];
for (y = 0; y < key->grid_size; y++) { for (y = 0; y < key->grid_size; y++) {
for (x = 0; x < key->grid_size; x++) { for (x = 0; x < key->grid_size; x++) {
CCGElem *elem = CCG_grid_elem(key, grid, x, y); CCGElem *elem = CCG_grid_elem(key, grid, x, y);
copy_v3_v3(vd->co, CCG_elem_co(key, elem)); copy_v3_v3(vd->co, CCG_elem_co(key, elem));
if(smooth) { if (smooth) {
normal_float_to_short_v3(vd->no, normal_float_to_short_v3(vd->no,
CCG_elem_no(key, elem)); CCG_elem_no(key, elem));
gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), gpu_color_from_mask_copy(*CCG_elem_mask(key, elem),
vd->color); vd->color);
} }
vd++; vd++;
} }
@@ -1535,27 +1535,27 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
for (j = 0; j < key->grid_size - 1; j++) { for (j = 0; j < key->grid_size - 1; j++) {
for (k = 0; k < key->grid_size - 1; k++) { for (k = 0; k < key->grid_size - 1; k++) {
CCGElem *elems[4] = { CCGElem *elems[4] = {
CCG_grid_elem(key, grid, k, j+1), CCG_grid_elem(key, grid, k, j + 1),
CCG_grid_elem(key, grid, k+1, j+1), CCG_grid_elem(key, grid, k + 1, j + 1),
CCG_grid_elem(key, grid, k+1, j), CCG_grid_elem(key, grid, k + 1, j),
CCG_grid_elem(key, grid, k, j) CCG_grid_elem(key, grid, k, j)
}; };
float fno[3]; float fno[3];
normal_quad_v3(fno, normal_quad_v3(fno,
CCG_elem_co(key, elems[0]), CCG_elem_co(key, elems[0]),
CCG_elem_co(key, elems[1]), CCG_elem_co(key, elems[1]),
CCG_elem_co(key, elems[2]), CCG_elem_co(key, elems[2]),
CCG_elem_co(key, elems[3])); CCG_elem_co(key, elems[3]));
vd = vert_data + (j+1) * key->grid_size + (k+1); vd = vert_data + (j + 1) * key->grid_size + (k + 1);
normal_float_to_short_v3(vd->no, fno); normal_float_to_short_v3(vd->no, fno);
gpu_color_from_mask_quad_copy(key, gpu_color_from_mask_quad_copy(key,
elems[0], elems[0],
elems[1], elems[1],
elems[2], elems[2],
elems[3], elems[3],
vd->color); vd->color);
} }
} }
} }
@@ -1582,10 +1582,10 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
/* Returns the number of visible quads in the nodes' grids. */ /* Returns the number of visible quads in the nodes' grids. */
static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, static int gpu_count_grid_quads(BLI_bitmap *grid_hidden,
int *grid_indices, int totgrid, int *grid_indices, int totgrid,
int gridsize) int gridsize)
{ {
int gridarea = (gridsize-1) * (gridsize-1); int gridarea = (gridsize - 1) * (gridsize - 1);
int i, x, y, totquad; int i, x, y, totquad;
/* grid hidden layer is present, so have to check each grid for /* grid hidden layer is present, so have to check each grid for
@@ -1596,8 +1596,8 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden,
if (gh) { if (gh) {
/* grid hidden are present, have to check each element */ /* grid hidden are present, have to check each element */
for (y = 0; y < gridsize-1; y++) { for (y = 0; y < gridsize - 1; y++) {
for (x = 0; x < gridsize-1; x++) { for (x = 0; x < gridsize - 1; x++) {
if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) if (!paint_is_grid_face_hidden(gh, gridsize, x, y))
totquad++; totquad++;
} }
@@ -1619,40 +1619,40 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden,
int i, j, k; \ int i, j, k; \
\ \
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \
sizeof(type_) * (tot_quad_) * 4, NULL, \ sizeof(type_) * (tot_quad_) * 4, NULL, \
GL_STATIC_DRAW_ARB); \ GL_STATIC_DRAW_ARB); \
\ \
/* Fill the quad buffer */ \ /* Fill the quad buffer */ \
quad_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ quad_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \
GL_WRITE_ONLY_ARB); \ GL_WRITE_ONLY_ARB); \
if (quad_data) { \ if (quad_data) { \
for (i = 0; i < totgrid; ++i) { \ for (i = 0; i < totgrid; ++i) { \
BLI_bitmap gh = NULL; \ BLI_bitmap gh = NULL; \
if (grid_hidden) \ if (grid_hidden) \
gh = grid_hidden[(grid_indices)[i]]; \ gh = grid_hidden[(grid_indices)[i]]; \
\ \
for (j = 0; j < gridsize-1; ++j) { \ for (j = 0; j < gridsize - 1; ++j) { \
for (k = 0; k < gridsize-1; ++k) { \ for (k = 0; k < gridsize - 1; ++k) { \
/* Skip hidden grid face */ \ /* Skip hidden grid face */ \
if (gh && \ if (gh && \
paint_is_grid_face_hidden(gh, \ paint_is_grid_face_hidden(gh, \
gridsize, k, j)) \ gridsize, k, j)) \
continue; \ continue; \
\ \
*(quad_data++)= offset + j*gridsize + k+1; \ *(quad_data++) = offset + j * gridsize + k + 1; \
*(quad_data++)= offset + j*gridsize + k; \ *(quad_data++) = offset + j * gridsize + k; \
*(quad_data++)= offset + (j+1)*gridsize + k; \ *(quad_data++) = offset + (j + 1) * gridsize + k; \
*(quad_data++)= offset + (j+1)*gridsize + k+1; \ *(quad_data++) = offset + (j + 1) * gridsize + k + 1; \
} \ } \
} \ } \
\ \
offset += gridsize*gridsize; \ offset += gridsize * gridsize; \
} \ } \
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); \ glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); \
} \ } \
else { \ else { \
glDeleteBuffersARB(1, &(buffer_)); \ glDeleteBuffersARB(1, &(buffer_)); \
(buffer_) = 0; \ (buffer_) = 0; \
} \ } \
} }
/* end FILL_QUAD_BUFFER */ /* end FILL_QUAD_BUFFER */
@@ -1687,7 +1687,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
/* Build new VBO */ /* Build new VBO */
glGenBuffersARB(1, &buffer); glGenBuffersARB(1, &buffer);
if (buffer) { if (buffer) {
*totquad= (gridsize-1)*(gridsize-1); *totquad = (gridsize - 1) * (gridsize - 1);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffer); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffer);
@@ -1710,18 +1710,18 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
} }
GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
BLI_bitmap *grid_hidden, int gridsize) BLI_bitmap *grid_hidden, int gridsize)
{ {
GPU_Buffers *buffers; GPU_Buffers *buffers;
int totquad; int totquad;
int fully_visible_totquad = (gridsize-1) * (gridsize-1) * totgrid; int fully_visible_totquad = (gridsize - 1) * (gridsize - 1) * totgrid;
buffers = MEM_callocN(sizeof(GPU_Buffers), "GPU_Buffers"); buffers = MEM_callocN(sizeof(GPU_Buffers), "GPU_Buffers");
buffers->grid_hidden = grid_hidden; buffers->grid_hidden = grid_hidden;
buffers->totgrid = totgrid; buffers->totgrid = totgrid;
/* Count the number of quads */ /* Count the number of quads */
totquad= gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize);
if (totquad == fully_visible_totquad) { if (totquad == fully_visible_totquad) {
buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad); buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad);
@@ -1731,7 +1731,7 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
/* Build new VBO */ /* Build new VBO */
glGenBuffersARB(1, &buffers->index_buf); glGenBuffersARB(1, &buffers->index_buf);
if (buffers->index_buf) { if (buffers->index_buf) {
buffers->tot_quad= totquad; buffers->tot_quad = totquad;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf);
@@ -1774,7 +1774,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
if (paint_is_face_hidden(f, buffers->mvert)) if (paint_is_face_hidden(f, buffers->mvert))
continue; continue;
glBegin((f->v4)? GL_QUADS: GL_TRIANGLES); glBegin((f->v4) ? GL_QUADS : GL_TRIANGLES);
if (smooth) { if (smooth) {
for (j = 0; j < S; j++) { for (j = 0; j < S; j++) {
@@ -1789,7 +1789,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
/* calculate face normal */ /* calculate face normal */
if (f->v4) { if (f->v4) {
normal_quad_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, normal_quad_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co,
mvert[fv[2]].co, mvert[fv[3]].co); mvert[fv[2]].co, mvert[fv[3]].co);
} }
else else
normal_tri_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, mvert[fv[2]].co); normal_tri_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, mvert[fv[2]].co);
@@ -1797,9 +1797,9 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
/* calculate face mask color */ /* calculate face mask color */
fmask = (buffers->vmask[fv[0]] + fmask = (buffers->vmask[fv[0]] +
buffers->vmask[fv[1]] + buffers->vmask[fv[1]] +
buffers->vmask[fv[2]]); buffers->vmask[fv[2]]);
if(f->v4) if (f->v4)
fmask = (fmask + buffers->vmask[fv[3]]) * 0.25; fmask = (fmask + buffers->vmask[fv[3]]) * 0.25;
else else
fmask /= 3.0f; fmask /= 3.0f;
@@ -1832,13 +1832,13 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
if (gh) { if (gh) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
for (y = 0; y < gridsize-1; y++) { for (y = 0; y < gridsize - 1; y++) {
for (x = 0; x < gridsize-1; x++) { for (x = 0; x < gridsize - 1; x++) {
CCGElem *e[4] = { CCGElem *e[4] = {
CCG_grid_elem(key, grid, x+1, y+1), CCG_grid_elem(key, grid, x + 1, y + 1),
CCG_grid_elem(key, grid, x+1, y), CCG_grid_elem(key, grid, x + 1, y),
CCG_grid_elem(key, grid, x, y), CCG_grid_elem(key, grid, x, y),
CCG_grid_elem(key, grid, x, y+1) CCG_grid_elem(key, grid, x, y + 1)
}; };
/* skip face if any of its corners are hidden */ /* skip face if any of its corners are hidden */
@@ -1855,10 +1855,10 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
else { else {
float fno[3]; float fno[3];
normal_quad_v3(fno, normal_quad_v3(fno,
CCG_elem_co(key, e[0]), CCG_elem_co(key, e[0]),
CCG_elem_co(key, e[1]), CCG_elem_co(key, e[1]),
CCG_elem_co(key, e[2]), CCG_elem_co(key, e[2]),
CCG_elem_co(key, e[3])); CCG_elem_co(key, e[3]));
glNormal3fv(fno); glNormal3fv(fno);
gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3]); gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3]);
@@ -1871,11 +1871,11 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
glEnd(); glEnd();
} }
else if (smooth) { else if (smooth) {
for (y = 0; y < gridsize-1; y++) { for (y = 0; y < gridsize - 1; y++) {
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for (x = 0; x < gridsize; x++) { for (x = 0; x < gridsize; x++) {
CCGElem *a = CCG_grid_elem(key, grid, x, y); CCGElem *a = CCG_grid_elem(key, grid, x, y);
CCGElem *b = CCG_grid_elem(key, grid, x, y+1); CCGElem *b = CCG_grid_elem(key, grid, x, y + 1);
gpu_color_from_mask_set(*CCG_elem_mask(key, a)); gpu_color_from_mask_set(*CCG_elem_mask(key, a));
glNormal3fv(CCG_elem_no(key, a)); glNormal3fv(CCG_elem_no(key, a));
@@ -1888,22 +1888,22 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth)
} }
} }
else { else {
for (y = 0; y < gridsize-1; y++) { for (y = 0; y < gridsize - 1; y++) {
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
for (x = 0; x < gridsize; x++) { for (x = 0; x < gridsize; x++) {
CCGElem *a = CCG_grid_elem(key, grid, x, y); CCGElem *a = CCG_grid_elem(key, grid, x, y);
CCGElem *b = CCG_grid_elem(key, grid, x, y+1); CCGElem *b = CCG_grid_elem(key, grid, x, y + 1);
if (x > 0) { if (x > 0) {
CCGElem *c = CCG_grid_elem(key, grid, x-1, y); CCGElem *c = CCG_grid_elem(key, grid, x - 1, y);
CCGElem *d = CCG_grid_elem(key, grid, x-1, y+1); CCGElem *d = CCG_grid_elem(key, grid, x - 1, y + 1);
float fno[3]; float fno[3];
normal_quad_v3(fno, normal_quad_v3(fno,
CCG_elem_co(key, d), CCG_elem_co(key, d),
CCG_elem_co(key, b), CCG_elem_co(key, b),
CCG_elem_co(key, a), CCG_elem_co(key, a),
CCG_elem_co(key, c)); CCG_elem_co(key, c));
glNormal3fv(fno); glNormal3fv(fno);
gpu_color_from_mask_quad_set(key, a, b, c, d); gpu_color_from_mask_quad_set(key, a, b, c, d);
@@ -1930,7 +1930,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
return; return;
smooth = f->flag & ME_SMOOTH; smooth = f->flag & ME_SMOOTH;
glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); glShadeModel(smooth ? GL_SMOOTH : GL_FLAT);
} }
else if (buffers->totgrid) { else if (buffers->totgrid) {
const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]];
@@ -1938,7 +1938,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
return; return;
smooth = f->flag & ME_SMOOTH; smooth = f->flag & ME_SMOOTH;
glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); glShadeModel(smooth ? GL_SMOOTH : GL_FLAT);
} }
if (buffers->vert_buf && buffers->index_buf) { if (buffers->vert_buf && buffers->index_buf) {
@@ -1954,11 +1954,11 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
int i, last = buffers->has_hidden ? 1 : buffers->totgrid; int i, last = buffers->has_hidden ? 1 : buffers->totgrid;
for (i = 0; i < last; i++) { for (i = 0; i < last; i++) {
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
offset + offsetof(VertexBufferFormat, co)); offset + offsetof(VertexBufferFormat, co));
glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
offset + offsetof(VertexBufferFormat, no)); offset + offsetof(VertexBufferFormat, no));
glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
offset + offsetof(VertexBufferFormat, color)); offset + offsetof(VertexBufferFormat, color));
glDrawElements(GL_QUADS, buffers->tot_quad * 4, buffers->index_type, 0); glDrawElements(GL_QUADS, buffers->tot_quad * 4, buffers->index_type, 0);
@@ -1967,11 +1967,11 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
} }
else { else {
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
(void*)offsetof(VertexBufferFormat, co)); (void *)offsetof(VertexBufferFormat, co));
glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
(void*)offsetof(VertexBufferFormat, no)); (void *)offsetof(VertexBufferFormat, no));
glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
(void*)offsetof(VertexBufferFormat, color)); (void *)offsetof(VertexBufferFormat, color));
glDrawElements(GL_TRIANGLES, buffers->tot_tri * 3, buffers->index_type, 0); glDrawElements(GL_TRIANGLES, buffers->tot_tri * 3, buffers->index_type, 0);
} }

View File

@@ -45,16 +45,16 @@ struct MTex;
struct Image; struct Image;
typedef struct BrushClone { typedef struct BrushClone {
struct Image *image; /* image for clone tool */ struct Image *image; /* image for clone tool */
float offset[2]; /* offset of clone image from canvas */ float offset[2]; /* offset of clone image from canvas */
float alpha, pad; /* transparency for drawing of clone image */ float alpha, pad; /* transparency for drawing of clone image */
} BrushClone; } BrushClone;
typedef struct Brush { typedef struct Brush {
ID id; ID id;
struct BrushClone clone; struct BrushClone clone;
struct CurveMapping *curve; /* falloff curve */ struct CurveMapping *curve; /* falloff curve */
struct MTex mtex; struct MTex mtex;
struct Brush *toggle_brush; struct Brush *toggle_brush;
@@ -65,38 +65,38 @@ typedef struct Brush {
float normal_weight; float normal_weight;
short blend; /* blend mode */ short blend; /* blend mode */
short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */ short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */
float weight; /* brush weight */ float weight; /* brush weight */
int size; /* brush diameter */ int size; /* brush diameter */
int flag; /* general purpose flag */ int flag; /* general purpose flag */
float jitter; /* jitter the position of the brush */ float jitter; /* jitter the position of the brush */
int spacing; /* spacing of paint operations */ int spacing; /* spacing of paint operations */
int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */
float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */
float rate; /* paint operations / second (airbrush) */ float rate; /* paint operations / second (airbrush) */
float rgb[3]; /* color */ float rgb[3]; /* color */
float alpha; /* opacity */ float alpha; /* opacity */
int sculpt_plane; /* the direction of movement for sculpt vertices */ int sculpt_plane; /* the direction of movement for sculpt vertices */
float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape) */ float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape) */
char sculpt_tool; /* active sculpt tool */ char sculpt_tool; /* active sculpt tool */
char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */ char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */
char imagepaint_tool; /* active image paint tool */ char imagepaint_tool; /* active image paint tool */
char mask_tool; /* enum BrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */ char mask_tool; /* enum BrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */
float autosmooth_factor; float autosmooth_factor;
float crease_pinch_factor; float crease_pinch_factor;
float plane_trim; float plane_trim;
float height; /* affectable height of brush (layer height for layer tool, i.e.) */ float height; /* affectable height of brush (layer height for layer tool, i.e.) */
float texture_sample_bias; float texture_sample_bias;
int texture_overlay_alpha; int texture_overlay_alpha;
float unprojected_radius; float unprojected_radius;
@@ -106,38 +106,38 @@ typedef struct Brush {
/* Brush.flag */ /* Brush.flag */
typedef enum BrushFlags { typedef enum BrushFlags {
BRUSH_AIRBRUSH = (1<<0), BRUSH_AIRBRUSH = (1 << 0),
BRUSH_TORUS = (1<<1), BRUSH_TORUS = (1 << 1),
BRUSH_ALPHA_PRESSURE = (1<<2), BRUSH_ALPHA_PRESSURE = (1 << 2),
BRUSH_SIZE_PRESSURE = (1<<3), BRUSH_SIZE_PRESSURE = (1 << 3),
BRUSH_JITTER_PRESSURE = (1<<4), BRUSH_JITTER_PRESSURE = (1 << 4),
BRUSH_SPACING_PRESSURE = (1<<5), BRUSH_SPACING_PRESSURE = (1 << 5),
BRUSH_FIXED_TEX = (1<<6), BRUSH_FIXED_TEX = (1 << 6),
BRUSH_RAKE = (1<<7), BRUSH_RAKE = (1 << 7),
BRUSH_ANCHORED = (1<<8), BRUSH_ANCHORED = (1 << 8),
BRUSH_DIR_IN = (1<<9), BRUSH_DIR_IN = (1 << 9),
BRUSH_SPACE = (1<<10), BRUSH_SPACE = (1 << 10),
BRUSH_SMOOTH_STROKE = (1<<11), BRUSH_SMOOTH_STROKE = (1 << 11),
BRUSH_PERSISTENT = (1<<12), BRUSH_PERSISTENT = (1 << 12),
BRUSH_ACCUMULATE = (1<<13), BRUSH_ACCUMULATE = (1 << 13),
BRUSH_LOCK_ALPHA = (1<<14), BRUSH_LOCK_ALPHA = (1 << 14),
BRUSH_ORIGINAL_NORMAL = (1<<15), BRUSH_ORIGINAL_NORMAL = (1 << 15),
BRUSH_OFFSET_PRESSURE = (1<<16), BRUSH_OFFSET_PRESSURE = (1 << 16),
BRUSH_SPACE_ATTEN = (1<<18), BRUSH_SPACE_ATTEN = (1 << 18),
BRUSH_ADAPTIVE_SPACE = (1<<19), BRUSH_ADAPTIVE_SPACE = (1 << 19),
BRUSH_LOCK_SIZE = (1<<20), BRUSH_LOCK_SIZE = (1 << 20),
BRUSH_TEXTURE_OVERLAY = (1<<21), BRUSH_TEXTURE_OVERLAY = (1 << 21),
BRUSH_EDGE_TO_EDGE = (1<<22), BRUSH_EDGE_TO_EDGE = (1 << 22),
BRUSH_RESTORE_MESH = (1<<23), BRUSH_RESTORE_MESH = (1 << 23),
BRUSH_INVERSE_SMOOTH_PRESSURE = (1<<24), BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24),
BRUSH_RANDOM_ROTATION = (1<<25), BRUSH_RANDOM_ROTATION = (1 << 25),
BRUSH_PLANE_TRIM = (1<<26), BRUSH_PLANE_TRIM = (1 << 26),
BRUSH_FRONTFACE = (1<<27), BRUSH_FRONTFACE = (1 << 27),
BRUSH_CUSTOM_ICON = (1<<28), BRUSH_CUSTOM_ICON = (1 << 28),
/* temporary flag which sets up automatically for correct brush /* temporary flag which sets up automatically for correct brush
* drawing when inverted modal operator is running */ * drawing when inverted modal operator is running */
BRUSH_INVERTED = (1<<29) BRUSH_INVERTED = (1 << 29)
} BrushFlags; } BrushFlags;
/* Brush.sculpt_tool */ /* Brush.sculpt_tool */
@@ -167,10 +167,10 @@ typedef enum BrushSculptTool {
} BrushSculptTool; } BrushSculptTool;
/* ImagePaintSettings.tool */ /* ImagePaintSettings.tool */
#define PAINT_TOOL_DRAW 0 #define PAINT_TOOL_DRAW 0
#define PAINT_TOOL_SOFTEN 1 #define PAINT_TOOL_SOFTEN 1
#define PAINT_TOOL_SMEAR 2 #define PAINT_TOOL_SMEAR 2
#define PAINT_TOOL_CLONE 3 #define PAINT_TOOL_CLONE 3
/* direction that the brush displaces along */ /* direction that the brush displaces along */
enum { enum {

View File

@@ -46,7 +46,8 @@
static EnumPropertyItem prop_direction_items[] = { static EnumPropertyItem prop_direction_items[] = {
{0, "ADD", 0, "Add", "Add effect of brush"}, {0, "ADD", 0, "Add", "Add effect of brush"},
{BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
EnumPropertyItem brush_sculpt_tool_items[] = { EnumPropertyItem brush_sculpt_tool_items[] = {
{SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""}, {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
@@ -67,7 +68,8 @@ EnumPropertyItem brush_sculpt_tool_items[] = {
{SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""}, {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
{SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""}, {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""},
{SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""}, {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
EnumPropertyItem brush_vertex_tool_items[] = { EnumPropertyItem brush_vertex_tool_items[] = {
@@ -78,14 +80,16 @@ EnumPropertyItem brush_vertex_tool_items[] = {
{PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"}, {PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
{PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"}, {PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
{PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"}, {PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
EnumPropertyItem brush_image_tool_items[] = { EnumPropertyItem brush_image_tool_items[] = {
{PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""}, {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""},
{PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""}, {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""},
{PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""}, {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""},
{PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""}, {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
#ifdef RNA_RUNTIME #ifdef RNA_RUNTIME
@@ -104,117 +108,117 @@ EnumPropertyItem brush_image_tool_items[] = {
static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ELEM6(br->sculpt_tool, return ELEM6(br->sculpt_tool,
SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE,
SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER); SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER);
} }
static int rna_SculptCapabilities_has_auto_smooth_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_auto_smooth_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH); return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
} }
static int rna_SculptCapabilities_has_height_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_height_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return br->sculpt_tool == SCULPT_TOOL_LAYER; return br->sculpt_tool == SCULPT_TOOL_LAYER;
} }
static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED) && return (!(br->flag & BRUSH_ANCHORED) &&
!(br->flag & BRUSH_RESTORE_MESH) && !(br->flag & BRUSH_RESTORE_MESH) &&
!ELEM4(br->sculpt_tool, !ELEM4(br->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
} }
static int rna_SculptCapabilities_has_normal_weight_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_normal_weight_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
} }
static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return br->sculpt_tool == SCULPT_TOOL_LAYER; return br->sculpt_tool == SCULPT_TOOL_LAYER;
} }
static int rna_SculptCapabilities_has_pinch_factor_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_pinch_factor_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE); return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE);
} }
static int rna_SculptCapabilities_has_plane_offset_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_plane_offset_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ELEM5(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, return ELEM5(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE); SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE);
} }
static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) && return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) &&
!(br->flag & BRUSH_ANCHORED) && !(br->flag & BRUSH_ANCHORED) &&
!ELEM4(br->sculpt_tool, !ELEM4(br->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
} }
static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return !ELEM4(br->sculpt_tool, SCULPT_TOOL_INFLATE, return !ELEM4(br->sculpt_tool, SCULPT_TOOL_INFLATE,
SCULPT_TOOL_MASK, SCULPT_TOOL_PINCH, SCULPT_TOOL_MASK, SCULPT_TOOL_PINCH,
SCULPT_TOOL_SMOOTH); SCULPT_TOOL_SMOOTH);
} }
static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ELEM10(br->sculpt_tool, return ELEM10(br->sculpt_tool,
SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL, SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL,
SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH,
SCULPT_TOOL_SCRAPE); SCULPT_TOOL_SCRAPE);
} }
static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED) && return (!(br->flag & BRUSH_ANCHORED) &&
!(br->flag & BRUSH_RESTORE_MESH) && !(br->flag & BRUSH_RESTORE_MESH) &&
!ELEM4(br->sculpt_tool, !ELEM4(br->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
} }
static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return ((br->flag & BRUSH_SPACE) && return ((br->flag & BRUSH_SPACE) &&
!ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK));
} }
static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return (!(br->flag & BRUSH_ANCHORED) && return (!(br->flag & BRUSH_ANCHORED) &&
!ELEM4(br->sculpt_tool, !ELEM4(br->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
} }
static int rna_SculptCapabilities_has_strength_get(PointerRNA *ptr) static int rna_SculptCapabilities_has_strength_get(PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
} }
@@ -240,35 +244,35 @@ static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type))
static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
/*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */
} }
static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "sculpt"); rna_Brush_reset_icon(br, "sculpt");
rna_Brush_update(bmain, scene, ptr); rna_Brush_update(bmain, scene, ptr);
} }
static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "vertex_paint"); rna_Brush_reset_icon(br, "vertex_paint");
rna_Brush_update(bmain, scene, ptr); rna_Brush_update(bmain, scene, ptr);
} }
static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
rna_Brush_reset_icon(br, "image_paint"); rna_Brush_reset_icon(br, "image_paint");
rna_Brush_update(bmain, scene, ptr); rna_Brush_update(bmain, scene, ptr);
} }
static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{ {
Brush *br = (Brush*)ptr->data; Brush *br = (Brush *)ptr->data;
if (br->icon_imbuf) { if (br->icon_imbuf) {
IMB_freeImBuf(br->icon_imbuf); IMB_freeImBuf(br->icon_imbuf);
@@ -282,22 +286,22 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi
BKE_icon_changed(BKE_icon_getid(&br->id)); BKE_icon_changed(BKE_icon_getid(&br->id));
} }
WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
} }
static void rna_Brush_set_size(PointerRNA *ptr, int value) static void rna_Brush_set_size(PointerRNA *ptr, int value)
{ {
Brush* brush = ptr->data; Brush *brush = ptr->data;
/* scale unprojected radius so it stays consistent with brush size */ /* scale unprojected radius so it stays consistent with brush size */
BKE_brush_scale_unprojected_radius(&brush->unprojected_radius, BKE_brush_scale_unprojected_radius(&brush->unprojected_radius,
value, brush->size); value, brush->size);
brush->size = value; brush->size = value;
} }
static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value) static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
{ {
Brush* brush = ptr->data; Brush *brush = ptr->data;
/* scale brush size so it stays consistent with unprojected_radius */ /* scale brush size so it stays consistent with unprojected_radius */
BKE_brush_scale_size(&brush->size, value, brush->unprojected_radius); BKE_brush_scale_size(&brush->size, value, brush->unprojected_radius);
@@ -308,34 +312,40 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerR
PropertyRNA *UNUSED(prop), int *UNUSED(free)) PropertyRNA *UNUSED(prop), int *UNUSED(free))
{ {
static EnumPropertyItem prop_default_items[] = { static EnumPropertyItem prop_default_items[] = {
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem prop_flatten_contrast_items[] = { static EnumPropertyItem prop_flatten_contrast_items[] = {
{0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, {0, "FLATTEN", 0, "Flatten", "Add effect of brush"},
{BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem prop_fill_deepen_items[] = { static EnumPropertyItem prop_fill_deepen_items[] = {
{0, "FILL", 0, "Fill", "Add effect of brush"}, {0, "FILL", 0, "Fill", "Add effect of brush"},
{BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"}, {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem prop_scrape_peaks_items[] = { static EnumPropertyItem prop_scrape_peaks_items[] = {
{0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, {0, "SCRAPE", 0, "Scrape", "Add effect of brush"},
{BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem prop_pinch_magnify_items[] = { static EnumPropertyItem prop_pinch_magnify_items[] = {
{0, "PINCH", 0, "Pinch", "Add effect of brush"}, {0, "PINCH", 0, "Pinch", "Add effect of brush"},
{BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem prop_inflate_deflate_items[] = { static EnumPropertyItem prop_inflate_deflate_items[] = {
{0, "INFLATE", 0, "Inflate", "Add effect of brush"}, {0, "INFLATE", 0, "Inflate", "Add effect of brush"},
{BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
Brush *me = (Brush*)(ptr->data); Brush *me = (Brush *)(ptr->data);
switch (me->sculpt_tool) { switch (me->sculpt_tool) {
case SCULPT_TOOL_DRAW: case SCULPT_TOOL_DRAW:
@@ -347,12 +357,12 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerR
case SCULPT_TOOL_MASK: case SCULPT_TOOL_MASK:
switch ((BrushMaskTool)me->mask_tool) { switch ((BrushMaskTool)me->mask_tool) {
case BRUSH_MASK_DRAW: case BRUSH_MASK_DRAW:
return prop_direction_items; return prop_direction_items;
break; break;
case BRUSH_MASK_SMOOTH: case BRUSH_MASK_SMOOTH:
return prop_default_items; return prop_default_items;
break; break;
} }
case SCULPT_TOOL_FLATTEN: case SCULPT_TOOL_FLATTEN:
@@ -386,7 +396,8 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
{MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""},
{MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
{MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot");
RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_sdna(srna, "MTex");
@@ -394,7 +405,7 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_float_sdna(prop, NULL, "rot");
RNA_def_property_range(prop, 0, M_PI*2); RNA_def_property_range(prop, 0, M_PI * 2);
RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation"); RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
@@ -414,15 +425,15 @@ static void rna_def_sculpt_capabilities(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "Brush"); RNA_def_struct_sdna(srna, "Brush");
RNA_def_struct_nested(brna, srna, "Brush"); RNA_def_struct_nested(brna, srna, "Brush");
RNA_def_struct_ui_text(srna, "Sculpt Capabilities", RNA_def_struct_ui_text(srna, "Sculpt Capabilities",
"Read-only indications of which brush operations " "Read-only indications of which brush operations "
"are supported by the current sculpt tool"); "are supported by the current sculpt tool");
#define BRUSH_CAPABILITY(prop_name_, ui_name_) \ #define BRUSH_CAPABILITY(prop_name_, ui_name_) \
prop = RNA_def_property(srna, #prop_name_, \ prop = RNA_def_property(srna, #prop_name_, \
PROP_BOOLEAN, PROP_NONE); \ PROP_BOOLEAN, PROP_NONE); \
RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ RNA_def_property_clear_flag(prop, PROP_EDITABLE); \
RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_" \ RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_" \
#prop_name_ "_get", NULL); \ #prop_name_ "_get", NULL); \
RNA_def_property_ui_text(prop, ui_name_, NULL) RNA_def_property_ui_text(prop, ui_name_, NULL)
BRUSH_CAPABILITY(has_accumulate, "Has Accumulate"); BRUSH_CAPABILITY(has_accumulate, "Has Accumulate");
@@ -458,7 +469,8 @@ static void rna_def_brush(BlenderRNA *brna)
{IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting"}, {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting"},
{IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"}, {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"},
{IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"}, {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem brush_stroke_method_items[] = { static EnumPropertyItem brush_stroke_method_items[] = {
{0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"}, {0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
@@ -466,18 +478,21 @@ static void rna_def_brush(BlenderRNA *brna)
{BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"}, {BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
{BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"}, {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"},
{BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"}, {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem texture_angle_source_items[] = { static EnumPropertyItem texture_angle_source_items[] = {
{0, "USER", 0, "User", "Rotate the brush texture by given angle"}, {0, "USER", 0, "User", "Rotate the brush texture by given angle"},
{BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"},
{BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", "Rotate the brush texture at random"}, {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", "Rotate the brush texture at random"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem texture_angle_source_no_random_items[] = { static EnumPropertyItem texture_angle_source_no_random_items[] = {
{0, "USER", 0, "User", "Rotate the brush texture by given angle"}, {0, "USER", 0, "User", "Rotate the brush texture by given angle"},
{BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem brush_sculpt_plane_items[] = { static EnumPropertyItem brush_sculpt_plane_items[] = {
{SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""}, {SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""},
@@ -485,12 +500,14 @@ static void rna_def_brush(BlenderRNA *brna)
{SCULPT_DISP_DIR_X, "X", 0, "X Plane", ""}, {SCULPT_DISP_DIR_X, "X", 0, "X Plane", ""},
{SCULPT_DISP_DIR_Y, "Y", 0, "Y Plane", ""}, {SCULPT_DISP_DIR_Y, "Y", 0, "Y Plane", ""},
{SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""}, {SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem brush_mask_tool_items[] = { static EnumPropertyItem brush_mask_tool_items[] = {
{BRUSH_MASK_DRAW, "DRAW", 0, "Draw", ""}, {BRUSH_MASK_DRAW, "DRAW", 0, "Draw", ""},
{BRUSH_MASK_SMOOTH, "SMOOTH", 0, "Smooth", ""}, {BRUSH_MASK_SMOOTH, "SMOOTH", 0, "Smooth", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
srna = RNA_def_struct(brna, "Brush", "ID"); srna = RNA_def_struct(brna, "Brush", "ID");
RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting");
@@ -517,7 +534,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool"); RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool");
RNA_def_property_enum_items(prop, brush_image_tool_items); RNA_def_property_enum_items(prop, brush_image_tool_items);
RNA_def_property_ui_text(prop, "Image Paint Tool", ""); RNA_def_property_ui_text(prop, "Image Paint Tool", "");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update");
prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
@@ -549,7 +566,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Sculpt Plane", ""); RNA_def_property_ui_text(prop, "Sculpt Plane", "");
RNA_def_property_update(prop, 0, "rna_Brush_update"); RNA_def_property_update(prop, 0, "rna_Brush_update");
prop= RNA_def_property(srna, "mask_tool", PROP_ENUM, PROP_NONE); prop = RNA_def_property(srna, "mask_tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_mask_tool_items); RNA_def_property_enum_items(prop, brush_mask_tool_items);
RNA_def_property_ui_text(prop, "Mask Tool", ""); RNA_def_property_ui_text(prop, "Mask Tool", "");
RNA_def_property_update(prop, 0, "rna_Brush_update"); RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -557,7 +574,7 @@ static void rna_def_brush(BlenderRNA *brna)
/* number values */ /* number values */
prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL); RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL);
RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10);
RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0);
RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
RNA_def_property_update(prop, 0, "rna_Brush_update"); RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -660,7 +677,7 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR); prop = RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor"); RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor");
RNA_def_property_float_default(prop, 2.0f/3.0f); RNA_def_property_float_default(prop, 2.0f / 3.0f);
RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches"); RNA_def_property_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches");
RNA_def_property_update(prop, 0, "rna_Brush_update"); RNA_def_property_update(prop, 0, "rna_Brush_update");
@@ -885,19 +902,19 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "clone.image"); RNA_def_property_pointer_sdna(prop, NULL, "clone.image");
RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool"); RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update");
prop = RNA_def_property(srna, "clone_alpha", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "clone_alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "clone.alpha"); RNA_def_property_float_sdna(prop, NULL, "clone.alpha");
RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Clone Alpha", "Opacity of clone image display"); RNA_def_property_ui_text(prop, "Clone Alpha", "Opacity of clone image display");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update");
prop = RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ); prop = RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "clone.offset"); RNA_def_property_float_sdna(prop, NULL, "clone.offset");
RNA_def_property_ui_text(prop, "Clone Offset", ""); RNA_def_property_ui_text(prop, "Clone Offset", "");
RNA_def_property_ui_range(prop, -1.0f, 1.0f, 10.0f, 3); RNA_def_property_ui_range(prop, -1.0f, 1.0f, 10.0f, 3);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update");
/* brush capabilities (mode-dependent) */ /* brush capabilities (mode-dependent) */
prop = RNA_def_property(srna, "sculpt_capabilities", PROP_POINTER, PROP_NONE); prop = RNA_def_property(srna, "sculpt_capabilities", PROP_POINTER, PROP_NONE);

View File

@@ -95,7 +95,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
if (result == dm) if (result == dm)
return dm; return dm;
if(useRenderParams || !(flag & MOD_APPLY_USECACHE)) { if (useRenderParams || !(flag & MOD_APPLY_USECACHE)) {
DerivedMesh *cddm; DerivedMesh *cddm;
cddm = CDDM_copy(result); cddm = CDDM_copy(result);
@@ -120,14 +120,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
cddm->getPolyArray(cddm), cddm->getPolyArray(cddm),
cddm->getNumPolys(cddm)); cddm->getNumPolys(cddm));
} }
if(grid_paint_mask) { if (grid_paint_mask) {
float *paint_mask = CustomData_add_layer(&cddm->vertData, float *paint_mask = CustomData_add_layer(&cddm->vertData,
CD_PAINT_MASK, CD_PAINT_MASK,
CD_CALLOC, NULL, CD_CALLOC, NULL,
cddm->getNumVerts(cddm)); cddm->getNumVerts(cddm));
subsurf_copy_grid_paint_mask(result, me->mpoly, subsurf_copy_grid_paint_mask(result, me->mpoly,
paint_mask, grid_paint_mask); paint_mask, grid_paint_mask);
} }
} }

View File

@@ -99,11 +99,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
const int useRenderParams = flag & MOD_APPLY_RENDER; const int useRenderParams = flag & MOD_APPLY_RENDER;
const int isFinalCalc = flag & MOD_APPLY_USECACHE; const int isFinalCalc = flag & MOD_APPLY_USECACHE;
if(useRenderParams) if (useRenderParams)
subsurf_flags |= SUBSURF_USE_RENDER_PARAMS; subsurf_flags |= SUBSURF_USE_RENDER_PARAMS;
if(isFinalCalc) if (isFinalCalc)
subsurf_flags |= SUBSURF_IS_FINAL_CALC; subsurf_flags |= SUBSURF_IS_FINAL_CALC;
if(ob->flag & OB_MODE_EDIT) if (ob->flag & OB_MODE_EDIT)
subsurf_flags |= SUBSURF_IN_EDIT_MODE; subsurf_flags |= SUBSURF_IN_EDIT_MODE;
result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags); result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags);
@@ -125,8 +125,8 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob),
DerivedMesh *result; DerivedMesh *result;
result = subsurf_make_derived_from_derived(derivedData, smd, result = subsurf_make_derived_from_derived(derivedData, smd,
NULL, (SUBSURF_FOR_EDIT_MODE | NULL, (SUBSURF_FOR_EDIT_MODE |
SUBSURF_IN_EDIT_MODE)); SUBSURF_IN_EDIT_MODE));
return result; return result;
} }