From ce17c35240a332038090628cda34d00a9996215d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 11 May 2012 08:05:47 +0000 Subject: style cleanup: mainly sculpt/whitespace --- source/blender/blenkernel/BKE_multires.h | 18 +- source/blender/blenkernel/BKE_paint.h | 4 +- source/blender/blenkernel/BKE_subsurf.h | 24 +- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/multires.c | 106 ++-- source/blender/blenkernel/intern/paint.c | 50 +- source/blender/blenkernel/intern/shrinkwrap.c | 72 +-- source/blender/blenkernel/intern/subsurf_ccg.c | 66 +- source/blender/blenlib/BLI_pbvh.h | 106 ++-- source/blender/blenlib/intern/pbvh.c | 703 +++++++++++---------- source/blender/editors/include/ED_sculpt.h | 6 +- source/blender/editors/object/object_bake.c | 6 +- source/blender/editors/object/object_modifier.c | 5 +- source/blender/editors/sculpt_paint/paint_hide.c | 20 +- source/blender/editors/sculpt_paint/paint_intern.h | 24 +- source/blender/editors/sculpt_paint/paint_ops.c | 63 +- source/blender/editors/sculpt_paint/sculpt.c | 269 ++++---- .../blender/editors/sculpt_paint/sculpt_intern.h | 16 +- source/blender/editors/sculpt_paint/sculpt_undo.c | 62 +- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 7 +- source/blender/gpu/intern/gpu_buffers.c | 488 +++++++------- source/blender/makesdna/DNA_brush_types.h | 114 ++-- source/blender/makesrna/intern/rna_brush.c | 201 +++--- source/blender/modifiers/intern/MOD_multires.c | 12 +- source/blender/modifiers/intern/MOD_subsurf.c | 10 +- 25 files changed, 1252 insertions(+), 1202 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 396f849def1..1ff53291044 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -66,25 +66,25 @@ typedef enum { } MultiresFlags; struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm, - struct MultiresModifierData *mmd, - struct Object *ob, - MultiresFlags flags); + struct MultiresModifierData *mmd, + struct Object *ob, + MultiresFlags flags); 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 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_base_apply(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, - struct Object *dst, struct Object *src); + struct Object *dst, struct Object *src); 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, - struct Object *ob, struct ModifierData *md); + struct Object *ob, struct ModifierData *md); void multires_stitch_grids(struct Object *); diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index bfefd9dc3b8..b32b7145ff4 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -67,11 +67,11 @@ int paint_vertsel_test(struct Object *ob); /* partial visibility */ 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 gridsize, int x, int y); + int gridsize, int x, int y); /* paint masks */ float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level, - unsigned x, unsigned y); + unsigned x, unsigned y); /* Session data (mode-specific) */ diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 9bb815c3e7d..ea824a9998d 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -64,10 +64,10 @@ typedef enum { } SubsurfFlags; struct DerivedMesh *subsurf_make_derived_from_derived( - struct DerivedMesh *dm, - struct SubsurfModifierData *smd, - float (*vertCos)[3], - SubsurfFlags flags); + struct DerivedMesh *dm, + struct SubsurfModifierData *smd, + float (*vertCos)[3], + SubsurfFlags flags); 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); void subsurf_copy_grid_hidden(struct DerivedMesh *dm, - const struct MPoly *mpoly, - struct MVert *mvert, - const struct MDisps *mdisps); + const struct MPoly *mpoly, + struct MVert *mvert, + const struct MDisps *mdisps); void subsurf_copy_grid_paint_mask(struct DerivedMesh *dm, - const struct MPoly *mpoly, float *paint_mask, - const struct GridPaintMask *grid_paint_mask); + const struct MPoly *mpoly, float *paint_mask, + const struct GridPaintMask *grid_paint_mask); typedef enum MultiresModifiedFlags { /* indicates the grids have been sculpted on, so MDisps @@ -104,10 +104,10 @@ typedef struct CCGDerivedMesh { int freeSS; int drawInteriorEdges, useSubsurfUv; - struct {int startVert; struct CCGVert *vert;} *vertMap; - struct {int startVert; int startEdge; struct CCGEdge *edge;} *edgeMap; + struct {int startVert; struct CCGVert *vert; } *vertMap; + struct {int startVert; int startEdge; struct CCGEdge *edge; } *edgeMap; struct {int startVert; int startEdge; - int startFace; struct CCGFace *face;} *faceMap; + int startFace; struct CCGFace *face; } *faceMap; short *edgeFlags; struct DMFlagMat *faceFlags; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index eca66059b51..3ef2ce56cd6 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -245,7 +245,7 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm) 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; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index bd23e92fe9e..724d80afdd9 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -97,10 +97,10 @@ void multires_customdata_delete(Mesh *me) CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); CustomData_free_layer_active(&me->ldata, CD_MDISPS, - me->totloop); + me->totloop); 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, int lo_level, int hi_level, - + /* assumed to be at hi_level (or * null) */ 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 (x = 0; x < keyB->grid_size; x++, j++) memcpy(CCG_elem_offset_co(keyA, gridA, y * skip * keyA->grid_size + x * skip), - CCG_elem_offset_co(keyB, gridB, j), - sizeof(float) * keyA->num_layers); + CCG_elem_offset_co(keyB, gridB, j), + sizeof(float) * keyA->num_layers); } else { 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 (x = 0; x < keyA->grid_size; x++, j++) memcpy(CCG_elem_offset_co(keyA, gridA, j), - CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x*skip), - sizeof(float) * keyA->num_layers); + CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x * skip), + sizeof(float) * keyA->num_layers); } } @@ -606,13 +606,13 @@ static void multires_grid_paint_mask_downsample(GridPaintMask *gpm, int level) if (level < gpm->level) { int gridsize = ccg_gridsize(level); float *data = MEM_callocN(sizeof(float) * gridsize * gridsize, - "multires_grid_paint_mask_downsample"); + "multires_grid_paint_mask_downsample"); int x, y; for (y = 0; y < gridsize; y++) { for (x = 0; x < 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); DM_set_only_copy(cddm, CD_MASK_BAREMESH); 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 */ 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) { /* backup subsurf grids */ 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 */ 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); gridOffset = dm->getGridOffset(dm); dm->getGridKey(dm, &key); - subGridData = (oldGridData) ? oldGridData: gridData; + subGridData = (oldGridData) ? oldGridData : gridData; dGridSize = multires_side_tot[totlvl]; 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 *sco = CCG_grid_elem_co(&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; /* construct tangent space matrix */ @@ -1110,21 +1110,21 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm if (gpm) { switch (op) { - case APPLY_DISPLACEMENTS: - /* Copy mask from gpm to DM */ - *CCG_grid_elem_mask(&key, grid, x, y) = - paint_grid_paint_mask(gpm, key.level, x, y); - break; - case CALC_DISPLACEMENTS: - /* Copy mask from DM to gpm */ - mask = *CCG_grid_elem_mask(&key, grid, x, y); - gpm->data[y * gridSize + x] = CLAMPIS(mask, 0, 1); - break; - case ADD_DISPLACEMENTS: - /* Add mask displacement to gpm */ - gpm->data[y * gridSize + x] += - *CCG_grid_elem_mask(&key, grid, x, y); - break; + case APPLY_DISPLACEMENTS: + /* Copy mask from gpm to DM */ + *CCG_grid_elem_mask(&key, grid, x, y) = + paint_grid_paint_mask(gpm, key.level, x, y); + break; + case CALC_DISPLACEMENTS: + /* Copy mask from DM to gpm */ + mask = *CCG_grid_elem_mask(&key, grid, x, y); + gpm->data[y * gridSize + x] = CLAMPIS(mask, 0, 1); + break; + case ADD_DISPLACEMENTS: + /* Add mask displacement to gpm */ + gpm->data[y * gridSize + x] += + *CCG_grid_elem_mask(&key, grid, x, y); + break; } } } @@ -1171,7 +1171,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) DM_set_only_copy(cddm, CD_MASK_BAREMESH); 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 */ 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); - subGridData = MEM_callocN(sizeof(CCGElem*)*numGrids, "subGridData*"); - diffGrid = MEM_callocN(lowGridKey.elem_size*lowGridSize*lowGridSize, "diff"); + subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*"); + diffGrid = MEM_callocN(lowGridKey.elem_size * lowGridSize * lowGridSize, "diff"); for (i = 0; i < numGrids; ++i) { /* backup subsurf grids */ - subGridData[i] = MEM_callocN(highGridKey.elem_size*highGridSize*highGridSize, "subGridData"); - memcpy(subGridData[i], highGridData[i], highGridKey.elem_size*highGridSize*highGridSize); + subGridData[i] = MEM_callocN(highGridKey.elem_size * highGridSize * highGridSize, "subGridData"); + memcpy(subGridData[i], highGridData[i], highGridKey.elem_size * highGridSize * highGridSize); /* 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), - CCG_elem_offset_co(&lowGridKey, gridData[i], j), - CCG_elem_offset_co(&lowGridKey, lowGridData[i], j)); + CCG_elem_offset_co(&lowGridKey, gridData[i], j), + CCG_elem_offset_co(&lowGridKey, lowGridData[i], j)); } 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); 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); gridSize = subsurf->getGridSize(subsurf); gridData = subsurf->getGridData(subsurf); subsurf->getGridKey(subsurf, &key); - subGridData = MEM_callocN(sizeof(CCGElem*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; i++) { - subGridData[i] = MEM_callocN(key.elem_size*gridSize*gridSize, "subGridData"); - memcpy(subGridData[i], gridData[i], key.elem_size*gridSize*gridSize); + subGridData[i] = MEM_callocN(key.elem_size * gridSize * gridSize, "subGridData"); + memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize); } /*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 (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 *co = CCG_grid_elem_co(&key, subgrid, x, y); 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, - MultiresModifierData *mmd, - Object *ob, - MultiresFlags flags) + MultiresModifierData *mmd, + Object *ob, + MultiresFlags flags) { Mesh *me = ob->data; DerivedMesh *result; @@ -1438,9 +1438,9 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, return dm; result = subsurf_dm_create_local(ob, dm, lvl, - mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, - mmd->flags & eMultiresModifierFlag_PlainUv, - flags & MULTIRES_ALLOC_PAINT_MASK); + mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, + mmd->flags & eMultiresModifierFlag_PlainUv, + flags & MULTIRES_ALLOC_PAINT_MASK); if (!(flags & MULTIRES_USE_LOCAL_MMD)) { ccgdm = (CCGDerivedMesh *)result; @@ -1458,11 +1458,11 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, gridData = result->getGridData(result); result->getGridKey(result, &key); - subGridData = MEM_callocN(sizeof(CCGElem*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; i++) { - subGridData[i] = MEM_callocN(key.elem_size*gridSize*gridSize, "subGridData"); - memcpy(subGridData[i], gridData[i], key.elem_size*gridSize*gridSize); + subGridData[i] = MEM_callocN(key.elem_size * gridSize * gridSize, "subGridData"); + memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize); } multires_set_tot_mdisps(me, mmd->totlvl); @@ -1483,7 +1483,7 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, } /**** Old Multires code **** - ***************************/ +***************************/ /* Adapted from sculptmode.c */ 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; CCGElem **gridData, **subGridData; CCGKey key; - Mesh *me = (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; MPoly *mpoly = me->mpoly; /* MLoop *mloop = me->mloop; */ /* UNUSED */ 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 *sco = CCG_grid_elem_co(&key, subgrid, 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]; /* construct tangent space matrix */ diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 9001605d684..c7f904755d9 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -60,19 +60,19 @@ Paint *paint_get_active(Scene *sce) if (sce->basact && sce->basact->object) { switch (sce->basact->object->mode) { - case OB_MODE_SCULPT: - return &ts->sculpt->paint; - case OB_MODE_VERTEX_PAINT: - return &ts->vpaint->paint; - case OB_MODE_WEIGHT_PAINT: - return &ts->wpaint->paint; - case OB_MODE_TEXTURE_PAINT: - return &ts->imapaint.paint; - case OB_MODE_EDIT: - if (ts->use_uv_sculpt) - return &ts->uvsculpt->paint; - else + case OB_MODE_SCULPT: + return &ts->sculpt->paint; + case OB_MODE_VERTEX_PAINT: + return &ts->vpaint->paint; + case OB_MODE_WEIGHT_PAINT: + return &ts->wpaint->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; } } @@ -93,7 +93,7 @@ void paint_brush_set(Paint *p, Brush *br) if (p) { id_us_min((ID *)p->brush); 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->data != NULL) && (((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 */ brush = paint_brush(p); if (brush == NULL) - brush= BKE_brush_add("Brush"); + brush = BKE_brush_add("Brush"); paint_brush_set(p, brush); memcpy(p->paint_cursor_col, col, 3); @@ -146,7 +146,7 @@ void free_paint(Paint *paint) * with paint_brush_set() */ void copy_paint(Paint *src, Paint *tar) { - tar->brush= src->brush; + tar->brush = src->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) { return ((mvert[f->v1].flag & ME_HIDE) || - (mvert[f->v2].flag & ME_HIDE) || - (mvert[f->v3].flag & ME_HIDE) || - (f->v4 && (mvert[f->v4].flag & ME_HIDE))); + (mvert[f->v2].flag & ME_HIDE) || + (mvert[f->v3].flag & ME_HIDE) || + (f->v4 && (mvert[f->v4].flag & ME_HIDE))); } /* returns non-zero if any of the corners of the grid * face whose inner corner is at (x,y) are hidden, * zero otherwise */ 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 */ return (BLI_BITMAP_GET(grid_hidden, y * gridsize + x) || - 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)); + 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)); } 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 gridsize = ccg_gridsize(gpm->level); - return gpm->data[(y*factor) * gridsize + (x*factor)]; + return gpm->data[(y * factor) * gridsize + (x * factor)]; } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 67c60d61b66..6c1c18c7cf8 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -57,7 +57,7 @@ #include "BKE_tessmesh.h" /* 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 */ #if !defined(_WIN32) && 0 @@ -79,17 +79,17 @@ #else -#define BENCH(a) (a) +#define BENCH(a) (a) #endif -typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *co, float *normal); +typedef void (*Shrinkwrap_ForeachVertexCallback)(DerivedMesh *target, float *co, float *normal); /* get derived mesh */ //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) { - Mesh *me= ob->data; + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; 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) { - 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) { - 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) @@ -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) { - 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? } @@ -142,7 +142,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) int i; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; - BVHTreeNearest nearest = NULL_BVHTreeNearest; + BVHTreeNearest nearest = NULL_BVHTreeNearest; 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__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static) #endif - for (i = 0; inumVerts; ++i) { + for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; 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) { //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position 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 copy_v3_v3(tmp_co, nearest.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); no = tmp_no; - hit_tmp.dist *= mat4_to_scale(((SpaceTransform*)transf)->local2target); + hit_tmp.dist *= mat4_to_scale(((SpaceTransform *)transf)->local2target); } else { 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); } - 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 */ - const float dot= dot_v3v3(dir, hit_tmp.no); - if ( ((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || - ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f) - ) { + const float dot = dot_v3v3(dir, hit_tmp.no); + if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || + ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)) + { return FALSE; /* Ignore hit */ } } @@ -275,16 +275,16 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) int i; //Options about projection direction - const char use_normal = calc->smd->shrinkOpts; - float proj_axis[3] = {0.0f, 0.0f, 0.0f}; + const char use_normal = calc->smd->shrinkOpts; + float proj_axis[3] = {0.0f, 0.0f, 0.0f}; //Raycast and tree stuff BVHTreeRayHit hit; - BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh; + BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; //auxiliary target - DerivedMesh *auxMesh = NULL; - BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; + DerivedMesh *auxMesh = NULL; + BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; SpaceTransform local2aux; //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__ #pragma omp parallel for private(i,hit) schedule(static) #endif - for (i = 0; inumVerts; ++i) { + for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3], tmp_no[3]; 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; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; - BVHTreeNearest nearest = NULL_BVHTreeNearest; + BVHTreeNearest nearest = NULL_BVHTreeNearest; //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) { OUT_OF_MEMORY(); return; @@ -417,7 +417,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static) #endif - for (i = 0; inumVerts; ++i) { + for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; 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 { //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) - 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 copy_v3_v3(tmp_co, nearest.co); } //Convert the coordinates back to mesh coordinates 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) { - DerivedMesh *ss_mesh = NULL; + DerivedMesh *ss_mesh = NULL; ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData; //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 if (smd->subsurfLevels) { - SubsurfModifierData ssmd= {{NULL}}; - ssmd.subdivType = ME_CC_SUBSURF; //catmull clark - ssmd.levels = smd->subsurfLevels; //levels + SubsurfModifierData ssmd = {{NULL}}; + ssmd.subdivType = ME_CC_SUBSURF; //catmull clark + 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); @@ -545,15 +545,15 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM switch (smd->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: BENCH(shrinkwrap_calc_nearest_surface_point(&calc)); - break; + break; case MOD_SHRINKWRAP_PROJECT: BENCH(shrinkwrap_calc_normal_projection(&calc)); - break; + break; case MOD_SHRINKWRAP_NEAREST_VERTEX: BENCH(shrinkwrap_calc_nearest_vertex(&calc)); - break; + break; } } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 3d5bc6051c5..26971368aea 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -117,7 +117,7 @@ typedef enum { } CCGFlags; static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, - int numLayers, CCGFlags flags) + int numLayers, CCGFlags flags) { CCGMeshIFC ifc; CCGSubSurf *ccgSS; @@ -152,9 +152,9 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, ifc.numLayers = numLayers; ifc.vertDataSize = sizeof(float) * numLayers; normalOffset += sizeof(float) * numLayers; - if(flags & CCG_CALC_NORMALS) + if (flags & CCG_CALC_NORMALS) ifc.vertDataSize += sizeof(float) * 3; - if(flags & CCG_ALLOC_MASK) + if (flags & CCG_ALLOC_MASK) ifc.vertDataSize += sizeof(float); 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]) { - if(min[0] > vec[0]) min[0]= vec[0]; - if(min[1] > vec[1]) min[1]= vec[1]; - if(min[2] > vec[2]) min[2]= vec[2]; - if(max[0] < vec[0]) max[0]= vec[0]; - if(max[1] < vec[1]) max[1]= vec[1]; - if(max[2] < vec[2]) max[2]= vec[2]; + if (min[0] > vec[0]) min[0] = vec[0]; + if (min[1] > vec[1]) min[1] = vec[1]; + if (min[2] > vec[2]) min[2] = vec[2]; + if (max[0] < vec[0]) max[0] = vec[0]; + if (max[1] < vec[1]) max[1] = vec[1]; + if (max[2] < vec[2]) max[2] = vec[2]; } 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); 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); } @@ -1050,10 +1050,10 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, /* Translate GridPaintMask into vertex paint masks. Assumes vertices are in the order output by ccgDM_copyFinalVertArray. */ void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly, - float *paint_mask, - const GridPaintMask *grid_paint_mask) + float *paint_mask, + const GridPaintMask *grid_paint_mask) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCGSubSurf *ss = ccgdm->ss; int level = ccgSubSurf_getSubdivisionLevels(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 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; 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]; - if(!gpm->data) + if (!gpm->data) continue; factor = ccg_factor(level, gpm->level); gpm_gridsize = ccg_gridsize(gpm->level); - for(y = 0; y < gridSize; y++) { - for(x = 0; x < gridSize; x++) { + for (y = 0; y < gridSize; y++) { + for (x = 0; x < gridSize; x++) { int vndx, offset; 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]; } } @@ -1857,7 +1857,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, continue; } - glShadeModel(drawSmooth ? GL_SMOOTH: GL_FLAT); + glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT); for (S = 0; S < numVerts; S++) { CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); CCGElem *vda, *vdb; @@ -2011,7 +2011,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * } /* draw face*/ - glShadeModel(drawSmooth ? GL_SMOOTH: GL_FLAT); + glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT); for (S = 0; S < numVerts; S++) { CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); CCGElem *vda, *vdb; @@ -2053,8 +2053,8 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * } else { glBegin(GL_QUADS); - for (y=0; y < gridFaces; y++) { - for (x=0; x < gridFaces; x++) { + for (y = 0; y < gridFaces; y++) { + for (x = 0; x < gridFaces; x++) { float *aco = CCG_grid_elem_co(&key, faceGridData, x, 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); @@ -2156,7 +2156,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, glShadeModel(GL_SMOOTH); for (y = 0; y < gridFaces; y++) { glBegin(GL_QUAD_STRIP); - for (x=0; xss); } @@ -3005,14 +3005,14 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new(); 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) { - Mesh *me= ob->data; - ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); + else if (ob->type == OB_MESH) { + Mesh *me = ob->data; + 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_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, - me->totface, me->totvert, &me->vdata); + me->totface, me->totvert, &me->vdata); } return ccgdm->pbvh; diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index 92ad2a04224..8806721c044 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -52,17 +52,17 @@ typedef struct { typedef int (*BLI_pbvh_SearchCallback)(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 */ PBVH *BLI_pbvh_new(void); 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, - struct DMGridAdjacency *gridadj, int totgrid, - struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats, - unsigned int **grid_hidden); + struct DMGridAdjacency *gridadj, int totgrid, + struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats, + unsigned int **grid_hidden); void BLI_pbvh_free(PBVH *bvh); /* 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) */ void BLI_pbvh_search_callback(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - BLI_pbvh_HitCallback hcb, void *hit_data); + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitCallback hcb, void *hit_data); void BLI_pbvh_search_gather(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - PBVHNode ***array, int *tot); + BLI_pbvh_SearchCallback scb, void *search_data, + PBVHNode ***array, int *tot); /* Raycast * 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 * 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); -int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], - float ray_start[3], float ray_normal[3], float *dist); +int BLI_pbvh_node_raycast(PBVH * bvh, PBVHNode * node, float (*origco)[3], + float ray_start[3], float ray_normal[3], float *dist); /* Drawing */ void BLI_pbvh_node_draw(PBVHNode *node, void *data); 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 */ 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_get_grids(PBVH *bvh, PBVHNode *node, - int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, - struct CCGElem ***grid_elems, struct DMGridAdjacency **gridadj); + int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, + struct CCGElem ***grid_elems, struct DMGridAdjacency **gridadj); 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, - 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_original_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]); -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 */ 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 */ 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_grids_update(PBVH *bvh, struct CCGElem **grid_elems, - struct DMGridAdjacency *gridadj, void **gridfaces); + struct DMGridAdjacency *gridadj, void **gridfaces); /* vertex deformer */ 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, * PBVH_ITER_UNIQUE does */ -#define PBVH_ITER_ALL 0 -#define PBVH_ITER_UNIQUE 1 +#define PBVH_ITER_ALL 0 +#define PBVH_ITER_UNIQUE 1 typedef struct PBVHVertexIter { /* iteration */ @@ -207,44 +207,44 @@ typedef struct PBVHVertexIter { #endif 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) \ pbvh_vertex_iter_init(bvh, node, &vi, mode); \ \ - for(vi.i=0, vi.g=0; vi.gflag & ME_HIDE) \ + vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \ + if (mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \ continue; \ - vi.co= vi.mvert->co; \ - vi.no= vi.mvert->no; \ - if(vi.vmask) \ - vi.mask= &vi.vmask[vi.vert_indices[vi.gx]]; \ + vi.co = vi.mvert->co; \ + vi.no = vi.mvert->no; \ + if (vi.vmask) \ + vi.mask = &vi.vmask[vi.vert_indices[vi.gx]]; \ } \ #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_free_proxies(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_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count); +void BLI_pbvh_node_free_proxies(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_node_BB_reset(PBVHNode* node); //void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]); diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 759e93c9b40..d80f90ec41a 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -118,7 +118,7 @@ struct PBVHNode { float tmin; int proxy_count; - PBVHProxyNode* proxies; + PBVHProxyNode *proxies; }; struct PBVH { @@ -159,7 +159,7 @@ struct PBVH { int deformed; }; -#define STACK_FIXED_DEPTH 100 +#define STACK_FIXED_DEPTH 100 typedef struct PBVHStack { PBVHNode *node; @@ -244,19 +244,20 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node) if (node->flag & PBVH_Leaf) { PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(bvh, node, vd, PBVH_ITER_ALL) { + BLI_pbvh_vertex_iter_begin(bvh, node, vd, PBVH_ITER_ALL) + { BB_expand(&vb, vd.co); } BLI_pbvh_vertex_iter_end; } else { BB_expand_with_bb(&vb, - &bvh->nodes[node->children_offset].vb); + &bvh->nodes[node->children_offset].vb); BB_expand_with_bb(&vb, - &bvh->nodes[node->children_offset + 1].vb); + &bvh->nodes[node->children_offset + 1].vb); } - node->vb= vb; + node->vb = vb; } //void BLI_pbvh_node_BB_reset(PBVHNode* node) @@ -272,24 +273,24 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node) static int face_materials_match(const MFace *f1, const MFace *f2) { return ((f1->flag & ME_SMOOTH) == (f2->flag & ME_SMOOTH) && - (f1->mat_nr == f2->mat_nr)); + (f1->mat_nr == f2->mat_nr)); } static int grid_materials_match(const DMFlagMat *f1, const DMFlagMat *f2) { return ((f1->flag & ME_SMOOTH) == (f2->flag & ME_SMOOTH) && - (f1->mat_nr == f2->mat_nr)); + (f1->mat_nr == f2->mat_nr)); } /* Adapted from BLI_kdopbvh.c */ /* Returns the index of the first element on the right of the partition */ static int partition_indices(int *prim_indices, int lo, int hi, int axis, - float mid, BBC *prim_bbc) + float mid, BBC *prim_bbc) { - int i=lo, j=hi; - for (;;) { - for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++); - for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--); + int i = lo, j = hi; + for (;; ) { + for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) ; + for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) ; if (!(i < j)) return i; @@ -306,21 +307,21 @@ static int partition_indices_material(PBVH *bvh, int lo, int hi) const DMFlagMat *flagmats = bvh->grid_flag_mats; const int *indices = bvh->prim_indices; const void *first; - int i=lo, j=hi; + int i = lo, j = hi; if (bvh->faces) first = &faces[bvh->prim_indices[lo]]; else first = &flagmats[bvh->prim_indices[lo]]; - for (;;) { + for (;; ) { if (bvh->faces) { - for (; face_materials_match(first, &faces[indices[i]]); i++); - for (; !face_materials_match(first, &faces[indices[j]]); j--); + for (; face_materials_match(first, &faces[indices[i]]); i++) ; + for (; !face_materials_match(first, &faces[indices[j]]); j--) ; } else { - for (; grid_materials_match(first, &flagmats[indices[i]]); i++); - for (; !grid_materials_match(first, &flagmats[indices[j]]); j--); + for (; grid_materials_match(first, &flagmats[indices[i]]); i++) ; + for (; !grid_materials_match(first, &flagmats[indices[j]]); j--) ; } if (!(i < j)) @@ -339,7 +340,7 @@ static void grow_nodes(PBVH *bvh, int totnode) if (bvh->node_mem_count < totnode) bvh->node_mem_count = totnode; bvh->nodes = MEM_callocN(sizeof(PBVHNode) * bvh->node_mem_count, - "bvh nodes"); + "bvh nodes"); memcpy(bvh->nodes, prev, bvh->totnode * sizeof(PBVHNode)); MEM_freeN(prev); } @@ -350,8 +351,8 @@ static void grow_nodes(PBVH *bvh, int totnode) /* Add a vertex to the map, with a positive value for unique vertices and * a negative value for additional vertices */ static int map_insert_vert(PBVH *bvh, GHash *map, - unsigned int *face_verts, - unsigned int *uniq_verts, int vertex) + unsigned int *face_verts, + unsigned int *uniq_verts, int vertex) { void *value, *key = SET_INT_IN_POINTER(vertex); @@ -383,30 +384,30 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "build_mesh_leaf_node gh"); node->uniq_verts = node->face_verts = 0; - totface= node->totprim; + totface = node->totprim; - node->face_vert_indices = MEM_callocN(sizeof(int) * 4*totface, - "bvh node face vert indices"); + node->face_vert_indices = MEM_callocN(sizeof(int) * 4 * totface, + "bvh node face vert indices"); for (i = 0; i < totface; ++i) { MFace *f = bvh->faces + node->prim_indices[i]; int sides = f->v4 ? 4 : 3; for (j = 0; j < sides; ++j) { - node->face_vert_indices[i][j]= - map_insert_vert(bvh, map, &node->face_verts, - &node->uniq_verts, (&f->v1)[j]); + node->face_vert_indices[i][j] = + map_insert_vert(bvh, map, &node->face_verts, + &node->uniq_verts, (&f->v1)[j]); } } node->vert_indices = MEM_callocN(sizeof(int) * - (node->uniq_verts + node->face_verts), - "bvh node vert indices"); + (node->uniq_verts + node->face_verts), + "bvh node vert indices"); /* Build the vertex list, unique verts first */ for (iter = BLI_ghashIterator_new(map), i = 0; - !BLI_ghashIterator_isDone(iter); - BLI_ghashIterator_step(iter), ++i) { + !BLI_ghashIterator_isDone(iter); + BLI_ghashIterator_step(iter), ++i) { void *value = BLI_ghashIterator_getValue(iter); int ndx = GET_INT_FROM_POINTER(value); @@ -414,7 +415,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) ndx = -ndx + node->uniq_verts - 1; node->vert_indices[ndx] = - GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(iter)); + GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(iter)); } BLI_ghashIterator_free(iter); @@ -425,18 +426,18 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) for (j = 0; j < sides; ++j) { if (node->face_vert_indices[i][j] < 0) - node->face_vert_indices[i][j]= - -node->face_vert_indices[i][j] + - node->uniq_verts - 1; + node->face_vert_indices[i][j] = + -node->face_vert_indices[i][j] + + node->uniq_verts - 1; } } if (!G.background) { node->draw_buffers = - GPU_build_mesh_buffers(node->face_vert_indices, - bvh->faces, bvh->verts, - node->prim_indices, - node->totprim); + GPU_build_mesh_buffers(node->face_vert_indices, + bvh->faces, bvh->verts, + node->prim_indices, + node->totprim); } node->flag |= PBVH_UpdateDrawBuffers; @@ -448,26 +449,26 @@ static void build_grids_leaf_node(PBVH *bvh, PBVHNode *node) { if (!G.background) { node->draw_buffers = - GPU_build_grid_buffers(node->prim_indices, - node->totprim, bvh->grid_hidden, bvh->gridkey.grid_size); + GPU_build_grid_buffers(node->prim_indices, + node->totprim, bvh->grid_hidden, bvh->gridkey.grid_size); } node->flag |= PBVH_UpdateDrawBuffers; } static void update_vb(PBVH *bvh, PBVHNode *node, BBC *prim_bbc, - int offset, int count) + int offset, int count) { int i; BB_reset(&node->vb); for (i = offset + count - 1; i >= offset; --i) { - BB_expand_with_bb(&node->vb, (BB*)(&prim_bbc[bvh->prim_indices[i]])); + BB_expand_with_bb(&node->vb, (BB *)(&prim_bbc[bvh->prim_indices[i]])); } node->orig_vb = node->vb; } static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc, - int offset, int count) + int offset, int count) { bvh->nodes[node_index].flag |= PBVH_Leaf; @@ -527,7 +528,7 @@ int leaf_needs_material_split(PBVH *bvh, int offset, int count) */ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, - int offset, int count) + int offset, int count) { int i, axis, end, below_leaf_limit; BB cb_backing; @@ -560,10 +561,10 @@ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, /* Partition primitives along that axis */ end = partition_indices(bvh->prim_indices, - offset, offset + count - 1, - axis, - (cb->bmax[axis] + cb->bmin[axis]) * 0.5f, - prim_bbc); + offset, offset + count - 1, + axis, + (cb->bmax[axis] + cb->bmin[axis]) * 0.5f, + prim_bbc); } else { /* Partition primitives by material */ @@ -572,9 +573,9 @@ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, /* Build children */ build_sub(bvh, bvh->nodes[node_index].children_offset, NULL, - prim_bbc, offset, end - offset); + prim_bbc, offset, end - offset); build_sub(bvh, bvh->nodes[node_index].children_offset + 1, NULL, - prim_bbc, end, offset + count - end); + prim_bbc, end, offset + count - end); } static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim) @@ -586,15 +587,15 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim) if (bvh->nodes) MEM_freeN(bvh->nodes); if (bvh->prim_indices) MEM_freeN(bvh->prim_indices); bvh->prim_indices = MEM_callocN(sizeof(int) * totprim, - "bvh prim indices"); + "bvh prim indices"); for (i = 0; i < totprim; ++i) bvh->prim_indices[i] = i; bvh->totnode = 0; if (bvh->node_mem_count < 100) { bvh->node_mem_count = 100; bvh->nodes = MEM_callocN(sizeof(PBVHNode) * - bvh->node_mem_count, - "bvh initial nodes"); + bvh->node_mem_count, + "bvh initial nodes"); } } @@ -627,10 +628,10 @@ void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int const int sides = f->v4 ? 4 : 3; BBC *bbc = prim_bbc + i; - BB_reset((BB*)bbc); + BB_reset((BB *)bbc); for (j = 0; j < sides; ++j) - BB_expand((BB*)bbc, verts[(&f->v1)[j]].co); + BB_expand((BB *)bbc, verts[(&f->v1)[j]].co); BBC_update_centroid(bbc); @@ -646,7 +647,7 @@ void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int /* Do a full rebuild with on Grids data structure */ void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, - int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap *grid_hidden) + int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap *grid_hidden) { BBC *prim_bbc = NULL; BB cb; @@ -654,14 +655,14 @@ void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, int i, j; bvh->type = PBVH_GRIDS; - bvh->grids= grids; - bvh->gridadj= gridadj; - bvh->gridfaces= gridfaces; - bvh->grid_flag_mats= flagmats; - bvh->totgrid= totgrid; + bvh->grids = grids; + bvh->gridadj = gridadj; + bvh->gridfaces = gridfaces; + bvh->grid_flag_mats = flagmats; + bvh->totgrid = totgrid; bvh->gridkey = *key; - bvh->grid_hidden= grid_hidden; - bvh->leaf_limit = MAX2(LEAF_LIMIT/((gridsize-1)*(gridsize-1)), 1); + bvh->grid_hidden = grid_hidden; + bvh->leaf_limit = MAX2(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1); BB_reset(&cb); @@ -669,13 +670,13 @@ void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, prim_bbc = MEM_mallocN(sizeof(BBC) * totgrid, "prim_bbc"); for (i = 0; i < totgrid; ++i) { - CCGElem *grid= grids[i]; + CCGElem *grid = grids[i]; BBC *bbc = prim_bbc + i; - BB_reset((BB*)bbc); + BB_reset((BB *)bbc); - for (j = 0; j < gridsize*gridsize; ++j) - BB_expand((BB*)bbc, CCG_elem_offset_co(key, grid, j)); + for (j = 0; j < gridsize * gridsize; ++j) + BB_expand((BB *)bbc, CCG_elem_offset_co(key, grid, j)); BBC_update_centroid(bbc); @@ -701,7 +702,7 @@ void BLI_pbvh_free(PBVH *bvh) int i; for (i = 0; i < bvh->totnode; ++i) { - node= &bvh->nodes[i]; + node = &bvh->nodes[i]; if (node->flag & PBVH_Leaf) { if (node->draw_buffers) @@ -734,16 +735,16 @@ void BLI_pbvh_free(PBVH *bvh) static void pbvh_iter_begin(PBVHIter *iter, PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data) { - iter->bvh= bvh; - iter->scb= scb; - iter->search_data= search_data; + iter->bvh = bvh; + iter->scb = scb; + iter->search_data = search_data; - iter->stack= iter->stackfixed; - iter->stackspace= STACK_FIXED_DEPTH; + iter->stack = iter->stackfixed; + iter->stackspace = STACK_FIXED_DEPTH; - iter->stack[0].node= bvh->nodes; - iter->stack[0].revisiting= 0; - iter->stacksize= 1; + iter->stack[0].node = bvh->nodes; + iter->stack[0].revisiting = 0; + iter->stacksize = 1; } static void pbvh_iter_end(PBVHIter *iter) @@ -758,16 +759,16 @@ static void pbvh_stack_push(PBVHIter *iter, PBVHNode *node, int revisiting) PBVHStack *newstack; iter->stackspace *= 2; - newstack= MEM_callocN(sizeof(PBVHStack)*iter->stackspace, "PBVHStack"); - memcpy(newstack, iter->stack, sizeof(PBVHStack)*iter->stacksize); + newstack = MEM_callocN(sizeof(PBVHStack) * iter->stackspace, "PBVHStack"); + memcpy(newstack, iter->stack, sizeof(PBVHStack) * iter->stacksize); if (iter->stackspace > STACK_FIXED_DEPTH) MEM_freeN(iter->stack); - iter->stack= newstack; + iter->stack = newstack; } - iter->stack[iter->stacksize].node= node; - iter->stack[iter->stacksize].revisiting= revisiting; + iter->stack[iter->stacksize].node = node; + iter->stack[iter->stacksize].revisiting = revisiting; iter->stacksize++; } @@ -782,21 +783,21 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) while (iter->stacksize) { /* pop node */ iter->stacksize--; - node= iter->stack[iter->stacksize].node; + node = iter->stack[iter->stacksize].node; /* on a mesh with no faces this can happen * can remove this check if we know meshes have at least 1 face */ - if (node==NULL) + if (node == NULL) return NULL; - revisiting= iter->stack[iter->stacksize].revisiting; + revisiting = iter->stack[iter->stacksize].revisiting; /* revisiting node already checked */ if (revisiting) return node; if (iter->scb && !iter->scb(node, iter->search_data)) - continue; /* don't traverse, outside of search zone */ + continue; /* don't traverse, outside of search zone */ if (node->flag & PBVH_Leaf) { /* immediately hit leaf node */ @@ -807,8 +808,8 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) pbvh_stack_push(iter, node, 1); /* push two child nodes on the stack */ - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset + 1, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset, 0); } } @@ -822,21 +823,21 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter) while (iter->stacksize) { /* pop node */ iter->stacksize--; - node= iter->stack[iter->stacksize].node; + node = iter->stack[iter->stacksize].node; /* on a mesh with no faces this can happen * can remove this check if we know meshes have at least 1 face */ - if (node==NULL) return NULL; + if (node == NULL) return NULL; - if (iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ + if (iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ if (node->flag & PBVH_Leaf) { /* immediately hit leaf node */ return node; } else { - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset + 1, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset, 0); } } @@ -844,31 +845,31 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter) } void BLI_pbvh_search_gather(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - PBVHNode ***r_array, int *r_tot) + BLI_pbvh_SearchCallback scb, void *search_data, + PBVHNode ***r_array, int *r_tot) { PBVHIter iter; - PBVHNode **array= NULL, **newarray, *node; - int tot= 0, space= 0; + PBVHNode **array = NULL, **newarray, *node; + int tot = 0, space = 0; pbvh_iter_begin(&iter, bvh, scb, search_data); - while ((node=pbvh_iter_next(&iter))) { + while ((node = pbvh_iter_next(&iter))) { if (node->flag & PBVH_Leaf) { if (tot == space) { /* resize array if needed */ - space= (tot == 0)? 32: space*2; - newarray= MEM_callocN(sizeof(PBVHNode)*space, "PBVHNodeSearch"); + space = (tot == 0) ? 32 : space * 2; + newarray = MEM_callocN(sizeof(PBVHNode) * space, "PBVHNodeSearch"); if (array) { - memcpy(newarray, array, sizeof(PBVHNode)*tot); + memcpy(newarray, array, sizeof(PBVHNode) * tot); MEM_freeN(array); } - array= newarray; + array = newarray; } - array[tot]= node; + array[tot] = node; tot++; } } @@ -877,23 +878,23 @@ void BLI_pbvh_search_gather(PBVH *bvh, if (tot == 0 && array) { MEM_freeN(array); - array= NULL; + array = NULL; } - *r_array= array; - *r_tot= tot; + *r_array = array; + *r_tot = tot; } void BLI_pbvh_search_callback(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - BLI_pbvh_HitCallback hcb, void *hit_data) + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitCallback hcb, void *hit_data) { PBVHIter iter; PBVHNode *node; pbvh_iter_begin(&iter, bvh, scb, search_data); - while ((node=pbvh_iter_next(&iter))) + while ((node = pbvh_iter_next(&iter))) if (node->flag & PBVH_Leaf) hcb(node, hit_data); @@ -901,13 +902,13 @@ void BLI_pbvh_search_callback(PBVH *bvh, } typedef struct node_tree { - PBVHNode* data; + PBVHNode *data; - struct node_tree* left; - struct node_tree* right; + struct node_tree *left; + struct node_tree *right; } node_tree; -static void node_tree_insert(node_tree* tree, node_tree* new_node) +static void node_tree_insert(node_tree *tree, node_tree *new_node) { if (new_node->data->tmin < tree->data->tmin) { if (tree->left) { @@ -927,7 +928,7 @@ static void node_tree_insert(node_tree* tree, node_tree* new_node) } } -static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, void* hit_data, float* tmin) +static void traverse_tree(node_tree *tree, BLI_pbvh_HitOccludedCallback hcb, void *hit_data, float *tmin) { if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin); @@ -936,7 +937,7 @@ static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, voi if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin); } -static void free_tree(node_tree* tree) +static void free_tree(node_tree *tree) { if (tree->left) { free_tree(tree->left); @@ -951,14 +952,14 @@ static void free_tree(node_tree* tree) free(tree); } -float BLI_pbvh_node_get_tmin(PBVHNode* node) +float BLI_pbvh_node_get_tmin(PBVHNode *node) { return node->tmin; } static void BLI_pbvh_search_callback_occluded(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - BLI_pbvh_HitOccludedCallback hcb, void *hit_data) + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitOccludedCallback hcb, void *hit_data) { PBVHIter iter; PBVHNode *node; @@ -966,9 +967,9 @@ static void BLI_pbvh_search_callback_occluded(PBVH *bvh, pbvh_iter_begin(&iter, bvh, scb, search_data); - while ((node=pbvh_iter_next_occluded(&iter))) { + while ((node = pbvh_iter_next_occluded(&iter))) { if (node->flag & PBVH_Leaf) { - node_tree* new_node = malloc(sizeof(node_tree)); + node_tree *new_node = malloc(sizeof(node_tree)); new_node->data = node; @@ -995,7 +996,7 @@ static void BLI_pbvh_search_callback_occluded(PBVH *bvh, static int update_search_cb(PBVHNode *node, void *data_v) { - int flag= GET_INT_FROM_POINTER(data_v); + int flag = GET_INT_FROM_POINTER(data_v); if (node->flag & PBVH_Leaf) return (node->flag & flag); @@ -1004,7 +1005,7 @@ static int update_search_cb(PBVHNode *node, void *data_v) } static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, - int totnode, float (*face_nors)[3]) + int totnode, float (*face_nors)[3]) { float (*vnor)[3]; int n; @@ -1014,7 +1015,7 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, /* could be per node to save some memory, but also means * we have to store for each vertex which node it is in */ - vnor= MEM_callocN(sizeof(float)*3*bvh->totvert, "bvh temp vnors"); + vnor = MEM_callocN(sizeof(float) * 3 * bvh->totvert, "bvh temp vnors"); /* subtle assumptions: * - We know that for all edited vertices, the nodes with faces @@ -1028,29 +1029,29 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, #pragma omp parallel for private(n) schedule(static) for (n = 0; n < totnode; n++) { - PBVHNode *node= nodes[n]; + PBVHNode *node = nodes[n]; if ((node->flag & PBVH_UpdateNormals)) { int i, j, totface, *faces; - faces= node->prim_indices; - totface= node->totprim; + faces = node->prim_indices; + totface = node->totprim; for (i = 0; i < totface; ++i) { - MFace *f= bvh->faces + faces[i]; + MFace *f = bvh->faces + faces[i]; float fn[3]; unsigned int *fv = &f->v1; - int sides= (f->v4)? 4: 3; + int sides = (f->v4) ? 4 : 3; if (f->v4) normal_quad_v3(fn, bvh->verts[f->v1].co, bvh->verts[f->v2].co, - bvh->verts[f->v3].co, bvh->verts[f->v4].co); + bvh->verts[f->v3].co, bvh->verts[f->v4].co); else normal_tri_v3(fn, bvh->verts[f->v1].co, bvh->verts[f->v2].co, - bvh->verts[f->v3].co); + bvh->verts[f->v3].co); for (j = 0; j < sides; ++j) { - int v= fv[j]; + int v = fv[j]; if (bvh->verts[v].flag & ME_VERT_PBVH_UPDATE) { /* this seems like it could be very slow but profile @@ -1072,17 +1073,17 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, #pragma omp parallel for private(n) schedule(static) for (n = 0; n < totnode; n++) { - PBVHNode *node= nodes[n]; + PBVHNode *node = nodes[n]; if (node->flag & PBVH_UpdateNormals) { int i, *verts, totvert; - verts= node->vert_indices; - totvert= node->uniq_verts; + verts = node->vert_indices; + totvert = node->uniq_verts; for (i = 0; i < totvert; ++i) { const int v = verts[i]; - MVert *mvert= &bvh->verts[v]; + MVert *mvert = &bvh->verts[v]; if (mvert->flag & ME_VERT_PBVH_UPDATE) { float no[3]; @@ -1090,9 +1091,9 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, copy_v3_v3(no, vnor[v]); normalize_v3(no); - mvert->no[0] = (short)(no[0]*32767.0f); - mvert->no[1] = (short)(no[1]*32767.0f); - mvert->no[2] = (short)(no[2]*32767.0f); + mvert->no[0] = (short)(no[0] * 32767.0f); + mvert->no[1] = (short)(no[1] * 32767.0f); + mvert->no[2] = (short)(no[2] * 32767.0f); mvert->flag &= ~ME_VERT_PBVH_UPDATE; } @@ -1106,21 +1107,21 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, } static void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, - int totnode, int flag) + int totnode, int flag) { int n; /* update BB, redraw flag */ #pragma omp parallel for private(n) schedule(static) for (n = 0; n < totnode; n++) { - PBVHNode *node= nodes[n]; + PBVHNode *node = nodes[n]; if ((flag & PBVH_UpdateBB) && (node->flag & PBVH_UpdateBB)) /* don't clear flag yet, leave it for flushing later */ update_node_vb(bvh, node); if ((flag & PBVH_UpdateOriginalBB) && (node->flag & PBVH_UpdateOriginalBB)) - node->orig_vb= node->vb; + node->orig_vb = node->vb; if ((flag & PBVH_UpdateRedraw) && (node->flag & PBVH_UpdateRedraw)) node->flag &= ~PBVH_UpdateRedraw; @@ -1134,21 +1135,21 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) /* can't be done in parallel with OpenGL */ for (n = 0; n < totnode; n++) { - node= nodes[n]; + node = nodes[n]; if (node->flag & PBVH_RebuildDrawBuffers) { GPU_free_buffers(node->draw_buffers); if (bvh->grids) { node->draw_buffers = - GPU_build_grid_buffers(node->prim_indices, - node->totprim, bvh->grid_hidden, bvh->gridkey.grid_size); + GPU_build_grid_buffers(node->prim_indices, + node->totprim, bvh->grid_hidden, bvh->gridkey.grid_size); } else { node->draw_buffers = - GPU_build_mesh_buffers(node->face_vert_indices, - bvh->faces, bvh->verts, - node->prim_indices, - node->totprim); + GPU_build_mesh_buffers(node->face_vert_indices, + bvh->faces, bvh->verts, + node->prim_indices, + node->totprim); } node->flag &= ~PBVH_RebuildDrawBuffers; @@ -1156,23 +1157,23 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) if (node->flag & PBVH_UpdateDrawBuffers) { switch (bvh->type) { - case PBVH_GRIDS: - GPU_update_grid_buffers(node->draw_buffers, - bvh->grids, - bvh->grid_flag_mats, - node->prim_indices, - node->totprim, - &bvh->gridkey); - break; - case PBVH_FACES: - GPU_update_mesh_buffers(node->draw_buffers, - bvh->verts, - node->vert_indices, - node->uniq_verts + - node->face_verts, - CustomData_get_layer(bvh->vdata, - CD_PAINT_MASK)); - break; + case PBVH_GRIDS: + GPU_update_grid_buffers(node->draw_buffers, + bvh->grids, + bvh->grid_flag_mats, + node->prim_indices, + node->totprim, + &bvh->gridkey); + break; + case PBVH_FACES: + GPU_update_mesh_buffers(node->draw_buffers, + bvh->verts, + node->vert_indices, + node->uniq_verts + + node->face_verts, + CustomData_get_layer(bvh->vdata, + CD_PAINT_MASK)); + break; } node->flag &= ~PBVH_UpdateDrawBuffers; @@ -1182,7 +1183,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag) { - int update= 0; + int update = 0; /* difficult to multithread well, we just do single threaded recursive */ if (node->flag & PBVH_Leaf) { @@ -1205,7 +1206,7 @@ static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag) if (update & PBVH_UpdateBB) update_node_vb(bvh, node); if (update & PBVH_UpdateOriginalBB) - node->orig_vb= node->vb; + node->orig_vb = node->vb; } return update; @@ -1220,15 +1221,15 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3]) return; BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag), - &nodes, &totnode); + &nodes, &totnode); if (flag & PBVH_UpdateNormals) pbvh_update_normals(bvh, nodes, totnode, face_nors); - if (flag & (PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw)) + if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw)) pbvh_update_BB_redraw(bvh, nodes, totnode, flag); - if (flag & (PBVH_UpdateBB|PBVH_UpdateOriginalBB)) + if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB)) pbvh_flush_bb(bvh, bvh->nodes, flag); if (nodes) MEM_freeN(nodes); @@ -1244,7 +1245,7 @@ void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]) pbvh_iter_begin(&iter, bvh, NULL, NULL); - while ((node=pbvh_iter_next(&iter))) + while ((node = pbvh_iter_next(&iter))) if (node->flag & PBVH_UpdateRedraw) BB_expand_with_bb(&bb, &node->vb); @@ -1268,10 +1269,10 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot pbvh_iter_begin(&iter, bvh, NULL, NULL); - while ((node=pbvh_iter_next(&iter))) { + while ((node = pbvh_iter_next(&iter))) { if (node->flag & PBVH_UpdateNormals) { for (i = 0; i < node->totprim; ++i) { - face= bvh->gridfaces[node->prim_indices[i]]; + face = bvh->gridfaces[node->prim_indices[i]]; if (!BLI_ghash_lookup(map, face)) BLI_ghash_insert(map, face, face); } @@ -1283,29 +1284,29 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot pbvh_iter_end(&iter); - tot= BLI_ghash_size(map); + tot = BLI_ghash_size(map); if (tot == 0) { - *totface= 0; - *gridfaces= NULL; + *totface = 0; + *gridfaces = NULL; BLI_ghash_free(map, NULL, NULL); return; } - faces= MEM_callocN(sizeof(void*)*tot, "PBVH Grid Faces"); + faces = MEM_callocN(sizeof(void *) * tot, "PBVH Grid Faces"); for (hiter = BLI_ghashIterator_new(map), i = 0; - !BLI_ghashIterator_isDone(hiter); - BLI_ghashIterator_step(hiter), ++i) + !BLI_ghashIterator_isDone(hiter); + BLI_ghashIterator_step(hiter), ++i) { - faces[i]= BLI_ghashIterator_getKey(hiter); + faces[i] = BLI_ghashIterator_getKey(hiter); } BLI_ghashIterator_free(hiter); BLI_ghash_free(map, NULL, NULL); - *totface= tot; - *gridfaces= faces; + *totface = tot; + *gridfaces = faces; } /***************************** PBVH Access ***********************************/ @@ -1331,12 +1332,12 @@ void BLI_pbvh_get_grid_key(const PBVH *bvh, CCGKey *key) void BLI_pbvh_node_mark_update(PBVHNode *node) { - node->flag |= PBVH_UpdateNormals|PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw; + node->flag |= PBVH_UpdateNormals | PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; } void BLI_pbvh_node_mark_rebuild_draw(PBVHNode *node) { - node->flag |= PBVH_RebuildDrawBuffers|PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw; + node->flag |= PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; } void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden) @@ -1351,8 +1352,8 @@ void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden) void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, MVert **verts) { - if (vert_indices) *vert_indices= node->vert_indices; - if (verts) *verts= bvh->verts; + if (vert_indices) *vert_indices = node->vert_indices; + if (verts) *verts = bvh->verts; } void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *totvert) @@ -1360,37 +1361,37 @@ void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *to int tot; switch (bvh->type) { - case PBVH_GRIDS: - tot= node->totprim * bvh->gridkey.grid_area; - if (totvert) *totvert= tot; - if (uniquevert) *uniquevert= tot; - break; - case PBVH_FACES: - if (totvert) *totvert= node->uniq_verts + node->face_verts; - if (uniquevert) *uniquevert= node->uniq_verts; - break; + case PBVH_GRIDS: + tot = node->totprim * bvh->gridkey.grid_area; + if (totvert) *totvert = tot; + if (uniquevert) *uniquevert = tot; + break; + case PBVH_FACES: + if (totvert) *totvert = node->uniq_verts + node->face_verts; + if (uniquevert) *uniquevert = node->uniq_verts; + break; } } void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, CCGElem ***griddata, DMGridAdjacency **gridadj) { switch (bvh->type) { - case PBVH_GRIDS: - if (grid_indices) *grid_indices= node->prim_indices; - if (totgrid) *totgrid= node->totprim; - if (maxgrid) *maxgrid= bvh->totgrid; - if (gridsize) *gridsize= bvh->gridkey.grid_size; - if (griddata) *griddata= bvh->grids; - if (gridadj) *gridadj= bvh->gridadj; - break; - case PBVH_FACES: - if (grid_indices) *grid_indices= NULL; - if (totgrid) *totgrid= 0; - if (maxgrid) *maxgrid= 0; - if (gridsize) *gridsize= 0; - if (griddata) *griddata= NULL; - if (gridadj) *gridadj= NULL; - break; + case PBVH_GRIDS: + if (grid_indices) *grid_indices = node->prim_indices; + if (totgrid) *totgrid = node->totprim; + if (maxgrid) *maxgrid = bvh->totgrid; + if (gridsize) *gridsize = bvh->gridkey.grid_size; + if (griddata) *griddata = bvh->grids; + if (gridadj) *gridadj = bvh->gridadj; + break; + case PBVH_FACES: + if (grid_indices) *grid_indices = NULL; + if (totgrid) *totgrid = 0; + if (maxgrid) *maxgrid = 0; + if (gridsize) *gridsize = 0; + if (griddata) *griddata = NULL; + if (gridadj) *gridadj = NULL; + break; } } @@ -1406,7 +1407,7 @@ void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max copy_v3_v3(bb_max, node->orig_vb.bmax); } -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) { if (node->proxy_count > 0) { if (proxies) *proxies = node->proxies; @@ -1441,10 +1442,10 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) BLI_pbvh_node_get_BB(node, bbox[0], bbox[1]); tmin = (bbox[ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; - tmax = (bbox[1-ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; + tmax = (bbox[1 - ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; tymin = (bbox[ray->sign[1]][1] - ray->start[1]) * ray->inv_dir[1]; - tymax = (bbox[1-ray->sign[1]][1] - ray->start[1]) * ray->inv_dir[1]; + tymax = (bbox[1 - ray->sign[1]][1] - ray->start[1]) * ray->inv_dir[1]; if ((tmin > tymax) || (tymin > tmax)) return 0; @@ -1456,7 +1457,7 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) tmax = tymax; tzmin = (bbox[ray->sign[2]][2] - ray->start[2]) * ray->inv_dir[2]; - tzmax = (bbox[1-ray->sign[2]][2] - ray->start[2]) * ray->inv_dir[2]; + tzmax = (bbox[1 - ray->sign[2]][2] - ray->start[2]) * ray->inv_dir[2]; if ((tmin > tzmax) || (tzmin > tmax)) return 0; @@ -1474,7 +1475,7 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) } 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) { RaycastData rcd; @@ -1491,13 +1492,13 @@ void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, } static int ray_face_intersection(float ray_start[3], float ray_normal[3], - float *t0, float *t1, float *t2, float *t3, - float *fdist) + float *t0, float *t1, float *t2, float *t3, + float *fdist) { float dist; if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) || - (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) + (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) { *fdist = dist; return 1; @@ -1508,91 +1509,91 @@ static int ray_face_intersection(float ray_start[3], float ray_normal[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) { MVert *vert; BLI_bitmap gh; int *faces, totface, gridsize, totgrid; - int i, x, y, hit= 0; + int i, x, y, hit = 0; if (node->flag & PBVH_FullyHidden) return 0; switch (bvh->type) { - case PBVH_FACES: - vert = bvh->verts; - faces= node->prim_indices; - totface= node->totprim; - - for (i = 0; i < totface; ++i) { - const MFace *f = bvh->faces + faces[i]; - int *face_verts = node->face_vert_indices[i]; - - if (paint_is_face_hidden(f, vert)) - continue; - - if (origco) { - /* intersect with backuped original coordinates */ - hit |= ray_face_intersection(ray_start, ray_normal, - origco[face_verts[0]], - origco[face_verts[1]], - origco[face_verts[2]], - f->v4? origco[face_verts[3]]: NULL, - dist); - } - else { - /* intersect with current coordinates */ - hit |= ray_face_intersection(ray_start, ray_normal, - vert[f->v1].co, - vert[f->v2].co, - vert[f->v3].co, - f->v4 ? vert[f->v4].co : NULL, - dist); - } - } - break; - case PBVH_GRIDS: - totgrid= node->totprim; - gridsize= bvh->gridkey.grid_size; - - for (i = 0; i < totgrid; ++i) { - CCGElem *grid= bvh->grids[node->prim_indices[i]]; - if (!grid) - continue; - - gh= bvh->grid_hidden[node->prim_indices[i]]; - - for (y = 0; y < gridsize-1; ++y) { - for (x = 0; x < gridsize-1; ++x) { - /* check if grid face is hidden */ - if (gh) { - if (paint_is_grid_face_hidden(gh, gridsize, x, y)) - continue; - } + case PBVH_FACES: + vert = bvh->verts; + faces = node->prim_indices; + totface = node->totprim; - if (origco) { - hit |= ray_face_intersection(ray_start, ray_normal, - origco[y*gridsize + x], - origco[y*gridsize + x+1], - origco[(y+1)*gridsize + x+1], - origco[(y+1)*gridsize + x], - dist); - } - else { - hit |= ray_face_intersection(ray_start, ray_normal, - CCG_grid_elem_co(&bvh->gridkey, grid, x, y), - CCG_grid_elem_co(&bvh->gridkey, grid, x+1, y), - CCG_grid_elem_co(&bvh->gridkey, grid, x+1, y+1), - CCG_grid_elem_co(&bvh->gridkey, grid, x, y+1), - dist); - } + for (i = 0; i < totface; ++i) { + const MFace *f = bvh->faces + faces[i]; + int *face_verts = node->face_vert_indices[i]; + + if (paint_is_face_hidden(f, vert)) + continue; + + if (origco) { + /* intersect with backuped original coordinates */ + hit |= ray_face_intersection(ray_start, ray_normal, + origco[face_verts[0]], + origco[face_verts[1]], + origco[face_verts[2]], + f->v4 ? origco[face_verts[3]] : NULL, + dist); + } + else { + /* intersect with current coordinates */ + hit |= ray_face_intersection(ray_start, ray_normal, + vert[f->v1].co, + vert[f->v2].co, + vert[f->v3].co, + f->v4 ? vert[f->v4].co : NULL, + dist); } } + break; + case PBVH_GRIDS: + totgrid = node->totprim; + gridsize = bvh->gridkey.grid_size; + + for (i = 0; i < totgrid; ++i) { + CCGElem *grid = bvh->grids[node->prim_indices[i]]; + if (!grid) + continue; + + gh = bvh->grid_hidden[node->prim_indices[i]]; + + for (y = 0; y < gridsize - 1; ++y) { + for (x = 0; x < gridsize - 1; ++x) { + /* check if grid face is hidden */ + if (gh) { + if (paint_is_grid_face_hidden(gh, gridsize, x, y)) + continue; + } + + if (origco) { + hit |= ray_face_intersection(ray_start, ray_normal, + origco[y * gridsize + x], + origco[y * gridsize + x + 1], + origco[(y + 1) * gridsize + x + 1], + origco[(y + 1) * gridsize + x], + dist); + } + else { + hit |= ray_face_intersection(ray_start, ray_normal, + CCG_grid_elem_co(&bvh->gridkey, grid, x, y), + CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y), + CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1), + CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1), + dist); + } + } + } - if (origco) - origco += gridsize*gridsize; - } - break; + if (origco) + origco += gridsize * gridsize; + } + break; } return hit; @@ -1635,8 +1636,8 @@ typedef enum { * (ok, not a real frustum), false otherwise. */ static PlaneAABBIsect test_planes_aabb(const float bb_min[3], - const float bb_max[3], - const float (*planes)[4]) + const float bb_max[3], + const float (*planes)[4]) { float vmin[3], vmax[3]; PlaneAABBIsect ret = ISECT_INSIDE; @@ -1680,13 +1681,13 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) } void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], - DMSetMaterial setMaterial) + DMSetMaterial setMaterial) { PBVHNode **nodes; int totnode; - BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals|PBVH_UpdateDrawBuffers), - &nodes, &totnode); + BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), + &nodes, &totnode); pbvh_update_normals(bvh, nodes, totnode, face_nors); pbvh_update_draw_buffers(bvh, nodes, totnode); @@ -1695,7 +1696,7 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], if (planes) { BLI_pbvh_search_callback(bvh, BLI_pbvh_node_planes_contain_AABB, - planes, BLI_pbvh_node_draw, setMaterial); + planes, BLI_pbvh_node_draw, setMaterial); } else { BLI_pbvh_search_callback(bvh, NULL, NULL, BLI_pbvh_node_draw, setMaterial); @@ -1704,24 +1705,24 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], void BLI_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces) { - bvh->grids= grids; - bvh->gridadj= gridadj; - bvh->gridfaces= gridfaces; + bvh->grids = grids; + bvh->gridadj = gridadj; + bvh->gridfaces = gridfaces; } -float (*BLI_pbvh_get_vertCos(PBVH *pbvh))[3] +float (*BLI_pbvh_get_vertCos(PBVH * pbvh))[3] { int a; - float (*vertCos)[3]= NULL; + float (*vertCos)[3] = NULL; if (pbvh->verts) { float *co; - MVert *mvert= pbvh->verts; + MVert *mvert = pbvh->verts; - vertCos= MEM_callocN(3*pbvh->totvert*sizeof(float), "BLI_pbvh_get_vertCoords"); - co= (float*)vertCos; + vertCos = MEM_callocN(3 * pbvh->totvert * sizeof(float), "BLI_pbvh_get_vertCoords"); + co = (float *)vertCos; - for (a= 0; atotvert; a++, mvert++, co+= 3) { + for (a = 0; a < pbvh->totvert; a++, mvert++, co += 3) { copy_v3_v3(co, mvert->co); } } @@ -1739,17 +1740,17 @@ void BLI_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3]) /* original data and applying new coords to this arrays would lead to */ /* unneeded deformation -- duplicate verts/faces to avoid this */ - pbvh->verts= MEM_dupallocN(pbvh->verts); - pbvh->faces= MEM_dupallocN(pbvh->faces); + pbvh->verts = MEM_dupallocN(pbvh->verts); + pbvh->faces = MEM_dupallocN(pbvh->faces); - pbvh->deformed= 1; + pbvh->deformed = 1; } } if (pbvh->verts) { - MVert *mvert= pbvh->verts; + MVert *mvert = pbvh->verts; /* copy new verts coords */ - for (a= 0; a < pbvh->totvert; ++a, ++mvert) { + for (a = 0; a < pbvh->totvert; ++a, ++mvert) { copy_v3_v3(mvert->co, vertCos[a]); mvert->flag |= ME_VERT_PBVH_UPDATE; } @@ -1757,7 +1758,7 @@ void BLI_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3]) /* coordinates are new -- normals should also be updated */ BKE_mesh_calc_normals_tessface(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL); - for (a= 0; a < pbvh->totnode; ++a) + for (a = 0; a < pbvh->totnode; ++a) BLI_pbvh_node_mark_update(&pbvh->nodes[a]); BLI_pbvh_update(pbvh, PBVH_UpdateBB, NULL); @@ -1772,7 +1773,7 @@ int BLI_pbvh_isDeformed(PBVH *pbvh) } /* Proxies */ -PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node) +PBVHProxyNode *BLI_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node) { int index, totverts; @@ -1784,111 +1785,111 @@ PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node) node->proxy_count++; if (node->proxies) - node->proxies= MEM_reallocN(node->proxies, node->proxy_count*sizeof(PBVHProxyNode)); + node->proxies = MEM_reallocN(node->proxies, node->proxy_count * sizeof(PBVHProxyNode)); else - node->proxies= MEM_mallocN(sizeof(PBVHProxyNode), "PBVHNodeProxy"); + node->proxies = MEM_mallocN(sizeof(PBVHProxyNode), "PBVHNodeProxy"); if (bvh->grids) - totverts = node->totprim*bvh->gridkey.grid_area; + totverts = node->totprim * bvh->gridkey.grid_area; else totverts = node->uniq_verts; - node->proxies[index].co= MEM_callocN(sizeof(float[3])*totverts, "PBVHNodeProxy.co"); + node->proxies[index].co = MEM_callocN(sizeof(float[3]) * totverts, "PBVHNodeProxy.co"); } return node->proxies + index; } -void BLI_pbvh_node_free_proxies(PBVHNode* node) +void BLI_pbvh_node_free_proxies(PBVHNode *node) { #pragma omp critical { int p; - for (p= 0; p < node->proxy_count; p++) { + for (p = 0; p < node->proxy_count; p++) { MEM_freeN(node->proxies[p].co); - node->proxies[p].co= 0; + node->proxies[p].co = 0; } MEM_freeN(node->proxies); node->proxies = 0; - node->proxy_count= 0; + node->proxy_count = 0; } } -void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** r_array, int* r_tot) +void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot) { - PBVHNode **array= NULL, **newarray, *node; - int tot= 0, space= 0; + PBVHNode **array = NULL, **newarray, *node; + int tot = 0, space = 0; int n; - for (n= 0; n < pbvh->totnode; n++) { + for (n = 0; n < pbvh->totnode; n++) { node = pbvh->nodes + n; if (node->proxy_count > 0) { if (tot == space) { /* resize array if needed */ - space= (tot == 0)? 32: space*2; - newarray= MEM_callocN(sizeof(PBVHNode)*space, "BLI_pbvh_gather_proxies"); + space = (tot == 0) ? 32 : space * 2; + newarray = MEM_callocN(sizeof(PBVHNode) * space, "BLI_pbvh_gather_proxies"); if (array) { - memcpy(newarray, array, sizeof(PBVHNode)*tot); + memcpy(newarray, array, sizeof(PBVHNode) * tot); MEM_freeN(array); } - array= newarray; + array = newarray; } - array[tot]= node; + array[tot] = node; tot++; } } if (tot == 0 && array) { MEM_freeN(array); - array= NULL; + array = NULL; } - *r_array= array; - *r_tot= tot; + *r_array = array; + *r_tot = tot; } void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, - PBVHVertexIter *vi, int mode) + PBVHVertexIter *vi, int mode) { struct CCGElem **grids; struct MVert *verts; int *grid_indices, *vert_indices; int totgrid, gridsize, uniq_verts, totvert; - vi->grid= 0; - vi->no= 0; - vi->fno= 0; - vi->mvert= 0; + vi->grid = 0; + vi->no = 0; + vi->fno = 0; + vi->mvert = 0; BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL); BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); vi->key = &bvh->gridkey; - vi->grids= grids; - vi->grid_indices= grid_indices; - vi->totgrid= (grids)? totgrid: 1; - vi->gridsize= gridsize; + vi->grids = grids; + vi->grid_indices = grid_indices; + vi->totgrid = (grids) ? totgrid : 1; + vi->gridsize = gridsize; if (mode == PBVH_ITER_ALL) vi->totvert = totvert; else - vi->totvert= uniq_verts; - vi->vert_indices= vert_indices; - vi->mverts= verts; + vi->totvert = uniq_verts; + vi->vert_indices = vert_indices; + vi->mverts = verts; - vi->gh= NULL; + vi->gh = NULL; if (vi->grids && mode == PBVH_ITER_UNIQUE) - vi->grid_hidden= bvh->grid_hidden; + vi->grid_hidden = bvh->grid_hidden; - vi->mask= NULL; - if(!vi->grids) - vi->vmask= CustomData_get_layer(bvh->vdata, CD_PAINT_MASK); + vi->mask = NULL; + if (!vi->grids) + vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK); } diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index d35fc8f4636..e8593e9b60d 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -46,15 +46,15 @@ void ED_sculpt_force_update(struct bContext *C); float *ED_sculpt_get_last_stroke(struct Object *ob); int ED_sculpt_minmax(struct bContext *C, float *min, float *max); void ED_sculpt_mask_layers_ensure(struct Object *ob, - struct MultiresModifierData *mmd); + struct MultiresModifierData *mmd); /* paint_ops.c */ void ED_operatortypes_paint(void); void ED_keymap_paint(struct wmKeyConfig *keyconf); /* paint_undo.c */ -#define UNDO_PAINT_IMAGE 0 -#define UNDO_PAINT_MESH 1 +#define UNDO_PAINT_IMAGE 0 +#define UNDO_PAINT_MESH 1 int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name); void ED_undo_paint_free(void); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index c6155b54aec..cea9a0aae6b 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -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); 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; 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.sculptlvl = *lvl; dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, - MULTIRES_USE_LOCAL_MMD); + MULTIRES_USE_LOCAL_MMD); 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.sculptlvl = mmd->totlvl; dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, - MULTIRES_USE_LOCAL_MMD); + MULTIRES_USE_LOCAL_MMD); cddm->release(cddm); return dm; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7e9201a708d..191677989b9 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -153,7 +153,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); /* 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[] = { {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"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; void OBJECT_OT_modifier_apply(wmOperatorType *ot) { diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index fd25bba2cec..87bc89f810c 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -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 */ static int is_effected(PartialVisArea area, - float planes[4][4], - const float co[3], - const float mask) + float planes[4][4], + const float co[3], + const float mask) { if (area == PARTIALVIS_ALL) return 1; @@ -158,8 +158,8 @@ static void partialvis_update_grids(Object *ob, /* get PBVH data */ BLI_pbvh_node_get_grids(pbvh, node, - &grid_indices, &totgrid, NULL, NULL, - &grids, NULL); + &grid_indices, &totgrid, NULL, NULL, + &grids, NULL); grid_hidden = BLI_pbvh_grid_hidden(pbvh); BLI_pbvh_get_grid_key(pbvh, &key); @@ -176,7 +176,7 @@ static void partialvis_update_grids(Object *ob, case PARTIALVIS_HIDE: /* create grid flags data */ gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area, - "partialvis_update_grids"); + "partialvis_update_grids"); break; case PARTIALVIS_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)) { /* set or clear the hide flag */ BLI_BITMAP_MODIFY(gh, y * key.grid_size + x, - action == PARTIALVIS_HIDE); + action == PARTIALVIS_HIDE); any_changed = 1; } @@ -368,14 +368,16 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) static EnumPropertyItem action_items[] = { {PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"}, {PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem area_items[] = { {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_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)"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Hide/Show"; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index cf6c6c626d0..a97563b258f 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -57,8 +57,8 @@ typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, - StrokeGetLocation get_location, StrokeTestStart test_start, - StrokeUpdateStep update_step, StrokeDone done, int event_type); + StrokeGetLocation get_location, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done, int event_type); void paint_stroke_data_free(struct wmOperator *op); 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, * returns zero if the result is empty */ int paint_convert_bb_to_rect(struct rcti *rect, - const float bb_min[3], - const float bb_max[3], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob); + const float bb_min[3], + const float bb_max[3], + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob); /* Get four planes in object-space that describe the projection of * screen_rect from screen into object-space (essentially converting a * 2D screens-space bounding box into four 3D planes) */ void paint_calc_redraw_planes(float planes[4][4], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob, - const struct rcti *screen_rect); + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob, + const struct rcti *screen_rect); 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_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); void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index b1711817ead..f8ed20430e7 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -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) { - if(!brush_orig || brush_tool(brush_orig, tool_offset) != tool) { + if (!brush_orig || brush_tool(brush_orig, tool_offset) != tool) { Brush *br; /* if the current brush is not using the desired tool, look 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 */ - if(br) - br->toggle_brush= brush_orig; + if (br) + br->toggle_brush = brush_orig; return br; } - else if(brush_orig->toggle_brush && - BLI_findindex(bmain->brush.first, brush_orig->toggle_brush) != -1) { + else if (brush_orig->toggle_brush && + BLI_findindex(bmain->brush.first, brush_orig->toggle_brush) != -1) + { /* if current brush is using the desired tool, try to toggle back to the previously selected brush (if it was set, and 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, - const size_t tool_offset, const int ob_mode, - const char *tool_name, int create_missing, - int toggle) + const size_t tool_offset, const int ob_mode, + const char *tool_name, int create_missing, + int toggle) { struct Brush *brush, *brush_orig = paint_brush(paint); - if(toggle) + if (toggle) brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode); else 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_tool_set(brush, tool_offset, tool); - brush->ob_mode= ob_mode; - brush->toggle_brush= brush_orig; + brush->ob_mode = ob_mode; + brush->toggle_brush = brush_orig; } 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: - paint= &toolsettings->sculpt->paint; - tool_offset= offsetof(Brush, sculpt_tool); - tool= RNA_enum_get(op->ptr, "sculpt_tool"); + paint = &toolsettings->sculpt->paint; + tool_offset = offsetof(Brush, sculpt_tool); + tool = RNA_enum_get(op->ptr, "sculpt_tool"); RNA_enum_name_from_value(brush_sculpt_tool_items, tool, &tool_name); break; case OB_MODE_VERTEX_PAINT: - paint= &toolsettings->vpaint->paint; - tool_offset= offsetof(Brush, vertexpaint_tool); - tool= RNA_enum_get(op->ptr, "vertex_paint_tool"); + paint = &toolsettings->vpaint->paint; + tool_offset = offsetof(Brush, vertexpaint_tool); + tool = RNA_enum_get(op->ptr, "vertex_paint_tool"); RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); break; case OB_MODE_WEIGHT_PAINT: - paint= &toolsettings->wpaint->paint; + paint = &toolsettings->wpaint->paint; /* vertexpaint_tool is used for weight paint mode */ - tool_offset= offsetof(Brush, vertexpaint_tool); - tool= RNA_enum_get(op->ptr, "weight_paint_tool"); + tool_offset = offsetof(Brush, vertexpaint_tool); + tool = RNA_enum_get(op->ptr, "weight_paint_tool"); RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); break; case OB_MODE_TEXTURE_PAINT: - paint= &toolsettings->imapaint.paint; - tool_offset= offsetof(Brush, imagepaint_tool); - tool= RNA_enum_get(op->ptr, "texture_paint_tool"); + paint = &toolsettings->imapaint.paint; + tool_offset = offsetof(Brush, imagepaint_tool); + tool = RNA_enum_get(op->ptr, "texture_paint_tool"); RNA_enum_name_from_value(brush_image_tool_items, tool, &tool_name); break; default: @@ -347,8 +348,8 @@ static int brush_select_exec(bContext *C, wmOperator *op) } return brush_generic_tool_set(bmain, paint, tool, tool_offset, - paint_mode, tool_name, create_missing, - toggle); + paint_mode, tool_name, create_missing, + toggle); } 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); /* 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_float_set(kmi->ptr, "value", 0); /* 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); /* 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_CLAY, CKEY, 0); 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, "create_missing", 1); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index b43217a9b8f..2d3a7680963 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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 * 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; ModifierData *md; @@ -291,7 +291,8 @@ static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss) if (unode) { 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) { copy_v3_v3(vd.co, unode->co[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: overlap = (1 + overlap) / 2; switch ((BrushMaskTool)brush->mask_tool) { - case BRUSH_MASK_DRAW: - return alpha * flip * pressure * overlap * feather; - case BRUSH_MASK_SMOOTH: - return alpha * pressure * feather; + case BRUSH_MASK_DRAW: + return alpha * flip * pressure * overlap * feather; + case BRUSH_MASK_SMOOTH: + return alpha * pressure * feather; } 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. */ static float tex_strength(SculptSession *ss, Brush *br, float point[3], - const float len, - const float sculpt_normal[3], - const short vno[3], - const float fno[3], - const float mask) + const float len, + const float sculpt_normal[3], + const short vno[3], + const float fno[3], + const float mask) { MTex *mtex = &br->mtex; 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); 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])) { 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; } 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 (vd.no) { 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); - 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)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno, - smooth_mask ? 0 : *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno, + smooth_mask ? 0 : *vd.mask); if (smooth_mask) { float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; 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, - float bstrength, int smooth_mask) + float bstrength, int smooth_mask) { Brush *brush = paint_brush(&sd->paint); SculptBrushTest test; @@ -1120,18 +1124,18 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no CLAMP(bstrength, 0.0f, 1.0f); 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); #pragma omp critical { if (smooth_mask) { - tmpgrid_mask = MEM_mallocN(sizeof(float)*gridsize*gridsize, "tmpgrid_mask"); - tmprow_mask = MEM_mallocN(sizeof(float)*gridsize, "tmprow_mask"); + tmpgrid_mask = MEM_mallocN(sizeof(float) * gridsize * gridsize, "tmpgrid_mask"); + tmprow_mask = MEM_mallocN(sizeof(float) * gridsize, "tmprow_mask"); } else { - tmpgrid_co = MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid_co"); - tmprow_co = MEM_mallocN(sizeof(float)*3*gridsize, "tmprow_co"); + tmpgrid_co = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid_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]]; if (smooth_mask) - memset(tmpgrid_mask, 0, sizeof(float)*gridsize*gridsize); + memset(tmpgrid_mask, 0, sizeof(float) * gridsize * gridsize); 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++) { - v1 = y*gridsize; + v1 = y * gridsize; if (smooth_mask) { 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 { add_v3_v3v3(tmprow_co[0], - CCG_elem_offset_co(&key, data, v1), - CCG_elem_offset_co(&key, data, v1 + gridsize)); + CCG_elem_offset_co(&key, data, v1), + CCG_elem_offset_co(&key, data, v1 + gridsize)); } 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; 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]; tmpgrid_mask[v1] += tmp; @@ -1178,8 +1182,8 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no float tmp[3]; add_v3_v3v3(tmprow_co[x + 1], - CCG_elem_offset_co(&key, data, v2), - CCG_elem_offset_co(&key, data, v4)); + CCG_elem_offset_co(&key, data, v2), + CCG_elem_offset_co(&key, data, v4)); add_v3_v3v3(tmp, tmprow_co[x + 1], tmprow_co[x]); 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) continue; - index = x + y*gridsize; + index = x + y * gridsize; co = CCG_elem_offset_co(&key, data, index); fno = CCG_elem_offset_no(&key, data, index); mask = CCG_elem_offset_mask(&key, data, index); if (sculpt_brush_test(&test, co)) { const float strength_mask = (smooth_mask ? 0 : *mask); - const float fade = bstrength*tex_strength(ss, brush, co, test.dist, - ss->cache->view_normal, - NULL, fno, strength_mask); + const float fade = bstrength * tex_strength(ss, brush, co, test.dist, + ss->cache->view_normal, + NULL, fno, strength_mask); float n = 1.0f / 16.0f; if (x == 0 || x == gridsize - 1) @@ -1229,12 +1233,12 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no n *= 2; if (smooth_mask) { - *mask += ((tmpgrid_mask[x + y*gridsize] * n) - *mask) * fade; + *mask += ((tmpgrid_mask[x + y * gridsize] * n) - *mask) * fade; } else { float *avg, val[3]; - avg = tmpgrid_co[x + y*gridsize]; + avg = tmpgrid_co[x + y * gridsize]; 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, - float bstrength, int smooth_mask) + float bstrength, int smooth_mask) { SculptSession *ss = ob->sculpt; 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++) { if (ss->multires) { 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) { 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); - 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)) { 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); 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); switch ((BrushMaskTool)brush->mask_tool) { - case BRUSH_MASK_DRAW: - do_mask_brush_draw(sd, ob, nodes, totnode); - break; - case BRUSH_MASK_SMOOTH: - smooth(sd, ob, nodes, totnode, ss->cache->bstrength, TRUE); - break; + case BRUSH_MASK_DRAW: + do_mask_brush_draw(sd, ob, nodes, totnode); + break; + case BRUSH_MASK_SMOOTH: + smooth(sd, ob, nodes, totnode, ss->cache->bstrength, TRUE); + break; } } @@ -1373,11 +1378,12 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) 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)) { /* offset vertex */ 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); @@ -1429,7 +1435,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod 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)) { /* offset vertex */ 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); - 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)) { - float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, - vd.fno, *vd.mask); + float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, + vd.fno, *vd.mask); float val[3]; 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) { if (sculpt_brush_test(&test, origco[vd.i])) { - const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, + an, origno[vd.i], NULL, *vd.mask); 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); - 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)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, + an, vd.no, vd.fno, *vd.mask); 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); - 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)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, + an, vd.no, vd.fno, *vd.mask); 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); - 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])) { - const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, + an, origno[vd.i], NULL, *vd.mask); 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); - 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])) { - const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, + an, origno[vd.i], NULL, *vd.mask); mul_v3_m4v3(proxy[vd.i], m, 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); - 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])) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, + area_normal, vd.no, vd.fno, *vd.mask); float *disp = &layer_disp[vd.i]; 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); - 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)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno, *vd.mask); float val[3]; 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); 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])) { add_v3_v3(private_fc, unode->co[vd.i]); private_count++; @@ -1886,7 +1901,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to BLI_pbvh_vertex_iter_end; } 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)) { add_v3_v3(private_fc, vd.co); private_count++; @@ -1942,7 +1958,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, sculpt_brush_test_init(ss, &test); 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])) { /* for area normal */ float fno[3]; @@ -1958,7 +1975,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, BLI_pbvh_vertex_iter_end; } 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)) { /* for area normal */ 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]) { 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) @@ -2162,7 +2180,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno 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)) { float intr[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); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), + an, vd.no, vd.fno, *vd.mask); 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); - 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 (plane_point_side_flip(vd.co, an, fc, flip)) { 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); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, - sqrt(test.dist), - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, + sqrt(test.dist), + an, vd.no, vd.fno, *vd.mask); 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); - 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 (plane_point_side_flip(vd.co, sn, fc, flip)) { 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); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, - ss->cache->radius*test.dist, - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, + ss->cache->radius * test.dist, + an, vd.no, vd.fno, *vd.mask); 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); - 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 (plane_point_side(vd.co, an, fc)) { 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); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, - sqrt(test.dist), - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, + sqrt(test.dist), + an, vd.no, vd.fno, *vd.mask); 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); - 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 (!plane_point_side(vd.co, an, fc)) { 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); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength*tex_strength(ss, brush, vd.co, - sqrt(test.dist), - an, vd.no, vd.fno, *vd.mask); + const float fade = bstrength * tex_strength(ss, brush, vd.co, + sqrt(test.dist), + an, vd.no, vd.fno, *vd.mask); 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]); BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, - me->mpoly, me->totloop, me->totpoly, - NULL, NULL, 0, NULL, NULL); + me->mpoly, me->totloop, me->totpoly, + NULL, NULL, 0, NULL, NULL); } /* 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.radius_squared = ss->cache->radius_squared; data.original = ELEM4(brush->sculpt_tool, - SCULPT_TOOL_GRAB, - SCULPT_TOOL_ROTATE, - SCULPT_TOOL_THUMB, - SCULPT_TOOL_LAYER); + SCULPT_TOOL_GRAB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_LAYER); BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); /* 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) && - brush->autosmooth_factor > 0) { + brush->autosmooth_factor > 0) { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { 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_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]; int p; @@ -2755,7 +2779,8 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) for (n = 0; n < totnode; n++) { 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); 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 */ #if 0 if (sd->flags & SCULPT_SYMMETRY_FEATHER) { - float frac = 1.0f/max_overlap_count(sd); - float reduce = (feather-frac)/(1-frac); + float frac = 1.0f / max_overlap_count(sd); + float reduce = (feather - frac) / (1 - frac); 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] = - mmd->tolerance; + mmd->tolerance; } } } @@ -3122,7 +3147,7 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio Brush *br; 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"); if (br) { @@ -3315,8 +3340,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, if (cache->first_time) { if (!BKE_brush_use_locked_size(scene, brush)) { cache->initial_radius = paint_calc_object_space_radius(cache->vc, - cache->true_location, - BKE_brush_size_get(scene, brush)); + cache->true_location, + BKE_brush_size_get(scene, brush)); BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius); } else { @@ -3544,7 +3569,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op) is_smooth |= mode == BRUSH_STROKE_SMOOTH; is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH; 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); @@ -3893,14 +3918,14 @@ void ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) int i, j; 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++) { GridPaintMask *gpm = &gmask[i]; gpm->level = level; gpm->data = MEM_callocN(sizeof(float) * gridarea, - "GridPaintMask.data"); + "GridPaintMask.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[1] = (paint_mask[l->v] + - paint_mask[next->v]) * 0.5f; + paint_mask[next->v]) * 0.5f; 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]; } } @@ -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 */ if (!paint_mask) { CustomData_add_layer(&me->vdata, CD_PAINT_MASK, - CD_CALLOC, NULL, me->totvert); + CD_CALLOC, NULL, me->totvert); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index b67206df6c8..f4467dc22fc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -78,8 +78,8 @@ typedef struct SculptUndoNode { SculptUndoType type; - char idname[MAX_ID_NAME]; /* name instead of pointer*/ - void *node; /* only during push, not valid afterwards! */ + char idname[MAX_ID_NAME]; /* name instead of pointer*/ + void *node; /* only during push, not valid afterwards! */ float (*co)[3]; float (*orig_co)[3]; @@ -88,15 +88,15 @@ typedef struct SculptUndoNode { int totvert; /* non-multires */ - int maxvert; /* to verify if totvert it still the same */ - int *index; /* to restore into right location */ + int maxvert; /* to verify if totvert it still the same */ + int *index; /* to restore into right location */ BLI_bitmap vert_hidden; /* multires */ - int maxgrid; /* same for grid */ - int gridsize; /* same for grid */ - int totgrid; /* to restore into right location */ - int *grids; /* to restore into right location */ + int maxgrid; /* same for grid */ + int gridsize; /* same for grid */ + int totgrid; /* to restore into right location */ + int *grids; /* to restore into right location */ BLI_bitmap *grid_hidden; /* layer brush */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 1ab93f1ce7b..d233c45a230 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -78,9 +78,9 @@ static void update_cb(PBVHNode *node, void *rebuild) } static void sculpt_undo_restore_deformed(const SculptSession *ss, - SculptUndoNode *unode, - int uindex, int oindex, - float coord[3]) + SculptUndoNode *unode, + int uindex, int oindex, + float coord[3]) { if (unode->orig_co) { 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++) { 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]); } } @@ -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) { - Object *ob= CTX_data_active_object(C); - SculptSession *ss= ob->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; MVert *mvert; float *vmask; int *index, i, j; - if(unode->maxvert) { + if (unode->maxvert) { /* regular mesh restore */ - index= unode->index; - mvert= ss->mvert; - vmask= ss->vmask; + index = unode->index; + mvert = ss->mvert; + vmask = ss->vmask; - for(i=0; itotvert; i++) { + for (i = 0; i < unode->totvert; i++) { SWAP(float, vmask[index[i]], unode->mask[i]); mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; } } - else if(unode->maxgrid && dm->getGridData) { + else if (unode->maxgrid && dm->getGridData) { /* multires restore */ CCGElem **grids, *grid; CCGKey key; float *mask; int gridsize; - grids= dm->getGridData(dm); - gridsize= dm->getGridSize(dm); + grids = dm->getGridData(dm); + gridsize = dm->getGridSize(dm); dm->getGridKey(dm, &key); mask = unode->mask; - for(j=0; jtotgrid; j++) { - grid= grids[unode->grids[j]]; + for (j = 0; j < unode->totgrid; j++) { + grid = grids[unode->grids[j]]; - for(i=0; itype) { + switch (unode->type) { case SCULPT_UNDO_COORDS: if (sculpt_undo_restore_coords(C, dm, unode)) - update= 1; + update = 1; break; case SCULPT_UNDO_HIDDEN: if (sculpt_undo_restore_hidden(C, dm, unode)) - rebuild= 1; + rebuild = 1; break; case SCULPT_UNDO_MASK: - if(sculpt_undo_restore_mask(C, dm, unode)) - update= 1; + if (sculpt_undo_restore_mask(C, dm, unode)) + update = 1; break; } } @@ -371,7 +371,7 @@ static void sculpt_undo_free(ListBase *lb) } MEM_freeN(unode->grid_hidden); } - if(unode->mask) + if (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->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no"); undo_paint_push_count_alloc(UNDO_PAINT_MESH, - (sizeof(float) * 3 + - sizeof(short) * 3 + - sizeof(int)) * allvert); + (sizeof(float) * 3 + + sizeof(short) * 3 + + sizeof(int)) * allvert); break; case SCULPT_UNDO_HIDDEN: if (maxgrid) @@ -453,8 +453,8 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, break; case SCULPT_UNDO_MASK: - unode->mask= MEM_mapallocN(sizeof(float)*allvert, "SculptUndoNode.mask"); - undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * sizeof(int))*allvert); + unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask"); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * sizeof(int)) * allvert); break; } @@ -484,7 +484,8 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode) SculptSession *ss = ob->sculpt; 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); 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); @@ -522,7 +523,8 @@ static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode) SculptSession *ss = ob->sculpt; 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; } BLI_pbvh_vertex_iter_end; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 159e2fc3fe6..7c05d08a774 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -402,7 +402,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0); derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, - NULL, SUBSURF_IN_EDIT_MODE); + NULL, SUBSURF_IN_EDIT_MODE); 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."); /* 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->uv_subsurf_level = subsurf_level; @@ -1210,7 +1210,8 @@ void UV_OT_unwrap(wmOperatorType *ot) static EnumPropertyItem method_items[] = { {0, "ANGLE_BASED", 0, "Angle Based", ""}, {1, "CONFORMAL", 0, "Conformal", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Unwrap"; diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index d527dfdfdb2..1e1043f1ee7 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -105,8 +105,8 @@ static GPUBufferPool *gpu_buffer_pool_new(void) pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer"); pool->maxsize = MAX_FREE_GPU_BUFFERS; - pool->buffers = MEM_callocN(sizeof(GPUBuffer*)*pool->maxsize, - "GPUBuffer.buffers"); + pool->buffers = MEM_callocN(sizeof(GPUBuffer *) * pool->maxsize, + "GPUBuffer.buffers"); 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' */ 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 */ if (pool->totbuf > 0) @@ -289,13 +289,13 @@ void GPU_buffer_free(GPUBuffer *buffer) if (pool->maxsize == pool->totbuf) { pool->maxsize += MAX_FREE_GPU_BUFFERS; pool->buffers = MEM_reallocN(pool->buffers, - sizeof(GPUBuffer*) * pool->maxsize); + sizeof(GPUBuffer *) * pool->maxsize); } } /* shift pool entries up by one */ 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 */ 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 (lnk->point_index != -1) { /* get last link */ - for (; lnk->next; lnk = lnk->next); + for (; lnk->next; lnk = lnk->next) ; /* add a new link from the pool */ 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 * triangle */ static void gpu_drawobject_add_triangle(GPUDrawObject *gdo, - int base_point_index, - int face_index, - int v1, int v2, int v3) + int base_point_index, + int face_index, + int v1, int v2, int v3) { int i, v[3] = {v1, v2, v3}; 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 */ 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, - "GPUDrawObject.vert_points_mem"); + "GPUDrawObject.vert_points_mem"); gdo->vert_points_usage = 0; /* 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 */ 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; /* add second triangle for quads */ if (f->v4) { 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; } } @@ -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 * data being initialized here */ -GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) +GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm) { GPUDrawObject *gdo; MFace *mface; @@ -400,11 +400,11 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) int i, curmat, curpoint, totface; mface = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); /* get the number of points used by each material, treating * 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++) 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 */ gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial, - "GPUDrawObject.materials"); + "GPUDrawObject.materials"); /* initialize the materials array */ 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->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); @@ -494,8 +494,8 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, if (dm->drawObject->legacy) return NULL; - cur_index_per_mat = MEM_mallocN(sizeof(int)*object->totmaterial, - "GPU_buffer_setup.cur_index_per_mat"); + cur_index_per_mat = MEM_mallocN(sizeof(int) * object->totmaterial, + "GPU_buffer_setup.cur_index_per_mat"); for (i = 0; i < object->totmaterial; i++) { /* for each material, the current index to copy data to */ 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 */ GPU_buffer_free(buffer); gpu_buffer_pool_delete_last(pool); - buffer= NULL; + buffer = NULL; /* try freeing an entry from the pool * 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); f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); for (i = 0; i < totface; i++, f++) { start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ copy_v3_v3(&varray[start], mvert[f->v1].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 + 3], mvert[f->v2].co); + copy_v3_v3(&varray[start + 6], mvert[f->v3].co); index[mat_orig_to_new[f->mat_nr]] += 9; if (f->v4) { /* v3 v4 v1 */ - 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+15], mvert[f->v1].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 + 15], mvert[f->v1].co); index[mat_orig_to_new[f->mat_nr]] += 9; } } /* 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++) { if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) { 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; float f_no[3]; - float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); + float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); MVert *mvert = dm->getVertArray(dm); MFace *f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); for (i = 0; i < totface; i++, f++) { 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) { /* copy vertex normal */ 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+6], mvert[f->v3].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); if (f->v4) { - 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+15], mvert[f->v1].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 + 15], mvert[f->v1].no); } } else if (nors) { /* copy cached face normal */ - copy_v3_v3(&varray[start], &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], &nors[i * 3]); + copy_v3_v3(&varray[start + 3], &nors[i * 3]); + copy_v3_v3(&varray[start + 6], &nors[i * 3]); if (f->v4) { - copy_v3_v3(&varray[start+9], &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 + 9], &nors[i * 3]); + copy_v3_v3(&varray[start + 12], &nors[i * 3]); + copy_v3_v3(&varray[start + 15], &nors[i * 3]); } } 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); copy_v3_v3(&varray[start], f_no); - copy_v3_v3(&varray[start+3], f_no); - copy_v3_v3(&varray[start+6], f_no); + copy_v3_v3(&varray[start + 3], f_no); + copy_v3_v3(&varray[start + 6], f_no); if (f->v4) { - copy_v3_v3(&varray[start+9], f_no); - copy_v3_v3(&varray[start+12], f_no); - copy_v3_v3(&varray[start+15], f_no); + copy_v3_v3(&varray[start + 9], f_no); + copy_v3_v3(&varray[start + 12], 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 */ copy_v2_v2(&varray[start], mtface[i].uv[0]); - 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 + 2], mtface[i].uv[1]); + copy_v2_v2(&varray[start + 4], mtface[i].uv[2]); index[mat_orig_to_new[f->mat_nr]] += 6; if (f->v4) { /* v3 v4 v1 */ - 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+10], mtface[i].uv[0]); + 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 + 10], mtface[i].uv[0]); 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; MFace *f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); - for (i=0; i < totface; i++, f++) { + totface = dm->getNumTessFaces(dm); + for (i = 0; i < totface; i++, f++) { int start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ - 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+6], &mcol[i*12+6]); + 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 + 6], &mcol[i * 12 + 6]); index[mat_orig_to_new[f->mat_nr]] += 9; if (f->v4) { /* v3 v4 v1 */ - 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+15], &mcol[i*12]); + 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 + 15], &mcol[i * 12]); 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; MFace *f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); - for (i=0; i < totface; i++, f++) { + totface = dm->getNumTessFaces(dm); + for (i = 0; i < totface; i++, f++) { int start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ - copy_mcol_uc3(&varray[start], &mcol[i*16]); - 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], &mcol[i * 16]); + copy_mcol_uc3(&varray[start + 3], &mcol[i * 16 + 4]); + copy_mcol_uc3(&varray[start + 6], &mcol[i * 16 + 8]); index[mat_orig_to_new[f->mat_nr]] += 9; if (f->v4) { /* v3 v4 v1 */ - 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+15], &mcol[i*16]); + 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 + 15], &mcol[i * 16]); 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); for (i = 0; i < totedge; i++, medge++) { - 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] = dm->drawObject->vert_points[medge->v1].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)) { MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); - int i, j=0; + int i, j = 0; if (!tf) return; @@ -792,23 +792,23 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i dm->getTessFace(dm, i, &mf); 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+6], tf->uv[2]); + copy_v2_v2(&varray[j + 4], tf->uv[1]); + copy_v2_v2(&varray[j + 6], tf->uv[2]); if (!mf.v4) { - copy_v2_v2(&varray[j+8], tf->uv[2]); - copy_v2_v2(&varray[j+10], tf->uv[0]); - j+=12; + copy_v2_v2(&varray[j + 8], tf->uv[2]); + copy_v2_v2(&varray[j + 10], tf->uv[0]); + j += 12; } else { - copy_v2_v2(&varray[j+8], tf->uv[2]); - copy_v2_v2(&varray[j+10], tf->uv[3]); + copy_v2_v2(&varray[j + 8], tf->uv[2]); + copy_v2_v2(&varray[j + 10], tf->uv[3]); - copy_v2_v2(&varray[j+12], tf->uv[3]); - copy_v2_v2(&varray[j+14], tf->uv[0]); - j+=16; + copy_v2_v2(&varray[j + 12], tf->uv[3]); + copy_v2_v2(&varray[j + 14], tf->uv[0]); + j += 16; } } } @@ -863,20 +863,20 @@ const GPUBufferTypeSettings gpu_buffer_type_settings[] = { static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type) { switch (type) { - case GPU_BUFFER_VERTEX: - return &gdo->points; - case GPU_BUFFER_NORMAL: - return &gdo->normals; - case GPU_BUFFER_COLOR: - return &gdo->colors; - case GPU_BUFFER_UV: - return &gdo->uv; - case GPU_BUFFER_EDGE: - return &gdo->edges; - case GPU_BUFFER_UVEDGE: - return &gdo->uvedges; - default: - return NULL; + case GPU_BUFFER_VERTEX: + return &gdo->points; + case GPU_BUFFER_NORMAL: + return &gdo->normals; + case GPU_BUFFER_COLOR: + return &gdo->colors; + case GPU_BUFFER_UV: + return &gdo->uv; + case GPU_BUFFER_EDGE: + return &gdo->edges; + case GPU_BUFFER_UVEDGE: + return &gdo->uvedges; + default: + 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) { switch (type) { - case GPU_BUFFER_VERTEX: - return sizeof(float)*3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); - case GPU_BUFFER_NORMAL: - return sizeof(float)*3*dm->drawObject->tot_triangle_point; - case GPU_BUFFER_COLOR: - return sizeof(char)*3*dm->drawObject->tot_triangle_point; - case GPU_BUFFER_UV: - return sizeof(float)*2*dm->drawObject->tot_triangle_point; - case GPU_BUFFER_EDGE: - return sizeof(int)*2*dm->drawObject->totedge; - case GPU_BUFFER_UVEDGE: - /* each face gets 3 points, 3 edges per triangle, and - * each edge has its own, non-shared coords, so each - * tri corner needs minimum of 4 floats, quads used - * less so here we can over allocate and assume all - * tris. */ - return sizeof(float) * 4 * dm->drawObject->tot_triangle_point; - default: - return -1; + case GPU_BUFFER_VERTEX: + return sizeof(float) * 3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); + case GPU_BUFFER_NORMAL: + return sizeof(float) * 3 * dm->drawObject->tot_triangle_point; + case GPU_BUFFER_COLOR: + return sizeof(char) * 3 * dm->drawObject->tot_triangle_point; + case GPU_BUFFER_UV: + return sizeof(float) * 2 * dm->drawObject->tot_triangle_point; + case GPU_BUFFER_EDGE: + return sizeof(int) * 2 * dm->drawObject->totedge; + case GPU_BUFFER_UVEDGE: + /* each face gets 3 points, 3 edges per triangle, and + * each edge has its own, non-shared coords, so each + * tri corner needs minimum of 4 floats, quads used + * less so here we can over allocate and assume all + * tris. */ + return sizeof(float) * 4 * dm->drawObject->tot_triangle_point; + default: + return -1; } } @@ -1061,18 +1061,18 @@ void GPU_uvedge_setup(DerivedMesh *dm) static int GPU_typesize(int type) { switch (type) { - case GL_FLOAT: - return sizeof(float); - case GL_INT: - return sizeof(int); - case GL_UNSIGNED_INT: - return sizeof(unsigned int); - case GL_BYTE: - return sizeof(char); - case GL_UNSIGNED_BYTE: - return sizeof(unsigned char); - default: - return 0; + case GL_FLOAT: + return sizeof(float); + case GL_INT: + return sizeof(int); + case GL_UNSIGNED_INT: + return sizeof(unsigned int); + case GL_BYTE: + return sizeof(char); + case GL_UNSIGNED_BYTE: + return sizeof(unsigned char); + default: + return 0; } } @@ -1083,7 +1083,7 @@ int GPU_attrib_element_size(GPUAttrib data[], int numdata) for (i = 0; i < numdata; i++) { int typesize = GPU_typesize(data[i].type); if (typesize != 0) - elementsize += typesize*data[i].size; + elementsize += typesize * data[i].size; } return elementsize; } @@ -1108,8 +1108,8 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda for (i = 0; i < numdata; i++) { glEnableVertexAttribArrayARB(data[i].index); glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, - GL_FALSE, elementsize, (void *)offset); - offset += data[i].size*GPU_typesize(data[i].type); + GL_FALSE, elementsize, (void *)offset); + offset += data[i].size * GPU_typesize(data[i].type); attribData[i].index = data[i].index; 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++) { glEnableVertexAttribArrayARB(data[i].index); glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, - GL_FALSE, elementsize, (char *)buffer->pointer + offset); - offset += data[i].size*GPU_typesize(data[i].type); + GL_FALSE, elementsize, (char *)buffer->pointer + offset); + 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); dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3, - sizeof(char)*3*dm->drawObject->tot_triangle_point, - GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3); + sizeof(char) * 3 * dm->drawObject->tot_triangle_point, + GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3); } void GPU_color_switch(int mode) @@ -1193,7 +1193,7 @@ void GPU_color_switch(int mode) * code, 0 otherwise */ int GPU_buffer_legacy(DerivedMesh *dm) { - int test= (U.gameflags & USER_DISABLE_VBO); + int test = (U.gameflags & USER_DISABLE_VBO); if (test) 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) { glDrawElements(mode, count, GL_UNSIGNED_INT, - (useVBOs ? - (void*)(start * sizeof(unsigned int)) : - ((int*)elements->pointer) + start)); + (useVBOs ? + (void *)(start * sizeof(unsigned int)) : + ((int *)elements->pointer) + start)); } @@ -1308,14 +1308,14 @@ static void gpu_colors_enable(VBO_State vbo_state) { glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); - if(vbo_state == VBO_ENABLED) + if (vbo_state == VBO_ENABLED) glEnableClientState(GL_COLOR_ARRAY); } static void gpu_colors_disable(VBO_State vbo_state) { glDisable(GL_COLOR_MATERIAL); - if(vbo_state == VBO_ENABLED) + if (vbo_state == VBO_ENABLED) 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, - CCGElem *a, CCGElem *b, - CCGElem *c, CCGElem *d) + CCGElem *a, CCGElem *b, + CCGElem *c, CCGElem *d) { return gpu_color_from_mask((*CCG_elem_mask(key, a) + - *CCG_elem_mask(key, b) + - *CCG_elem_mask(key, c) + - *CCG_elem_mask(key, d)) * 0.25f); + *CCG_elem_mask(key, b) + + *CCG_elem_mask(key, c) + + *CCG_elem_mask(key, d)) * 0.25f); } static void gpu_color_from_mask_quad_copy(const CCGKey *key, - CCGElem *a, CCGElem *b, - CCGElem *c, CCGElem *d, - unsigned char out[3]) + CCGElem *a, CCGElem *b, + CCGElem *c, CCGElem *d, + unsigned char out[3]) { unsigned char color = - gpu_color_from_mask((*CCG_elem_mask(key, a) + - *CCG_elem_mask(key, b) + - *CCG_elem_mask(key, c) + - *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; + gpu_color_from_mask((*CCG_elem_mask(key, a) + + *CCG_elem_mask(key, b) + + *CCG_elem_mask(key, c) + + *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; out[0] = 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, - CCGElem *a, CCGElem *b, - CCGElem *c, CCGElem *d) + CCGElem *a, CCGElem *b, + CCGElem *c, CCGElem *d) { float color = gpu_color_from_mask_quad(key, a, b, c, d); glColor3f(color, color, color); } 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; int i; @@ -1399,7 +1399,7 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, copy_v3_v3(out->co, v->co); memcpy(out->no, v->no, sizeof(short) * 3); gpu_color_from_mask_copy(vmask[vert_indices[i]], - out->color); + out->color); } 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], - MFace *mface, MVert *mvert, - int *face_indices, - int totface) + MFace *mface, MVert *mvert, + int *face_indices, + int totface) { GPU_Buffers *buffers; 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)) continue; - v[0]= 0; - v[1]= 1; - v[2]= 2; + v[0] = 0; + v[1] = 1; + v[2] = 2; for (j = 0; j < (f->v4 ? 2 : 1); ++j) { 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, - const DMFlagMat *grid_flag_mats, int *grid_indices, - int totgrid, const CCGKey *key) + const DMFlagMat *grid_flag_mats, int *grid_indices, + int totgrid, const CCGKey *key) { VertexBufferFormat *vert_data; int i, j, k, x, y; @@ -1510,19 +1510,19 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, if (vert_data) { for (i = 0; i < totgrid; ++i) { 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 (x = 0; x < key->grid_size; x++) { CCGElem *elem = CCG_grid_elem(key, grid, x, y); copy_v3_v3(vd->co, CCG_elem_co(key, elem)); - if(smooth) { + if (smooth) { 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), - vd->color); + vd->color); } 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 (k = 0; k < key->grid_size - 1; k++) { CCGElem *elems[4] = { - 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), + 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), CCG_grid_elem(key, grid, k, j) }; float fno[3]; normal_quad_v3(fno, - CCG_elem_co(key, elems[0]), - CCG_elem_co(key, elems[1]), - CCG_elem_co(key, elems[2]), - CCG_elem_co(key, elems[3])); + CCG_elem_co(key, elems[0]), + CCG_elem_co(key, elems[1]), + CCG_elem_co(key, elems[2]), + 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); gpu_color_from_mask_quad_copy(key, - elems[0], - elems[1], - elems[2], - elems[3], - vd->color); + elems[0], + elems[1], + elems[2], + elems[3], + 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. */ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, - int *grid_indices, int totgrid, - int gridsize) + int *grid_indices, int totgrid, + int gridsize) { - int gridarea = (gridsize-1) * (gridsize-1); + int gridarea = (gridsize - 1) * (gridsize - 1); int i, x, y, totquad; /* 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) { /* grid hidden are present, have to check each element */ - for (y = 0; y < gridsize-1; y++) { - for (x = 0; x < gridsize-1; x++) { + for (y = 0; y < gridsize - 1; y++) { + for (x = 0; x < gridsize - 1; x++) { if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) totquad++; } @@ -1619,40 +1619,40 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, int i, j, k; \ \ glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ - sizeof(type_) * (tot_quad_) * 4, NULL, \ - GL_STATIC_DRAW_ARB); \ + sizeof(type_) * (tot_quad_) * 4, NULL, \ + GL_STATIC_DRAW_ARB); \ \ /* Fill the quad buffer */ \ quad_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ - GL_WRITE_ONLY_ARB); \ + GL_WRITE_ONLY_ARB); \ if (quad_data) { \ - for (i = 0; i < totgrid; ++i) { \ - BLI_bitmap gh = NULL; \ - if (grid_hidden) \ - gh = grid_hidden[(grid_indices)[i]]; \ + for (i = 0; i < totgrid; ++i) { \ + BLI_bitmap gh = NULL; \ + if (grid_hidden) \ + gh = grid_hidden[(grid_indices)[i]]; \ \ - for (j = 0; j < gridsize-1; ++j) { \ - for (k = 0; k < gridsize-1; ++k) { \ - /* Skip hidden grid face */ \ - if (gh && \ - paint_is_grid_face_hidden(gh, \ - gridsize, k, j)) \ - continue; \ + for (j = 0; j < gridsize - 1; ++j) { \ + for (k = 0; k < gridsize - 1; ++k) { \ + /* Skip hidden grid face */ \ + if (gh && \ + paint_is_grid_face_hidden(gh, \ + gridsize, k, j)) \ + continue; \ \ - *(quad_data++)= offset + j*gridsize + k+1; \ - *(quad_data++)= offset + j*gridsize + k; \ - *(quad_data++)= offset + (j+1)*gridsize + k; \ - *(quad_data++)= offset + (j+1)*gridsize + k+1; \ + *(quad_data++) = offset + j * gridsize + k + 1; \ + *(quad_data++) = offset + j * gridsize + k; \ + *(quad_data++) = offset + (j + 1) * gridsize + k; \ + *(quad_data++) = offset + (j + 1) * gridsize + k + 1; \ } \ } \ \ - offset += gridsize*gridsize; \ + offset += gridsize * gridsize; \ } \ glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); \ } \ else { \ - glDeleteBuffersARB(1, &(buffer_)); \ - (buffer_) = 0; \ + glDeleteBuffersARB(1, &(buffer_)); \ + (buffer_) = 0; \ } \ } /* end FILL_QUAD_BUFFER */ @@ -1687,7 +1687,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to /* Build new VBO */ glGenBuffersARB(1, &buffer); if (buffer) { - *totquad= (gridsize-1)*(gridsize-1); + *totquad = (gridsize - 1) * (gridsize - 1); 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, - BLI_bitmap *grid_hidden, int gridsize) + BLI_bitmap *grid_hidden, int gridsize) { GPU_Buffers *buffers; 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->grid_hidden = grid_hidden; buffers->totgrid = totgrid; /* 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) { 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 */ glGenBuffersARB(1, &buffers->index_buf); if (buffers->index_buf) { - buffers->tot_quad= totquad; + buffers->tot_quad = totquad; 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)) continue; - glBegin((f->v4)? GL_QUADS: GL_TRIANGLES); + glBegin((f->v4) ? GL_QUADS : GL_TRIANGLES); if (smooth) { 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 */ if (f->v4) { 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 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 */ fmask = (buffers->vmask[fv[0]] + - buffers->vmask[fv[1]] + - buffers->vmask[fv[2]]); - if(f->v4) + buffers->vmask[fv[1]] + + buffers->vmask[fv[2]]); + if (f->v4) fmask = (fmask + buffers->vmask[fv[3]]) * 0.25; else fmask /= 3.0f; @@ -1832,13 +1832,13 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) if (gh) { glBegin(GL_QUADS); - for (y = 0; y < gridsize-1; y++) { - for (x = 0; x < gridsize-1; x++) { + for (y = 0; y < gridsize - 1; y++) { + for (x = 0; x < gridsize - 1; x++) { CCGElem *e[4] = { - 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 + 1), + CCG_grid_elem(key, grid, x + 1, 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 */ @@ -1855,10 +1855,10 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) else { float fno[3]; normal_quad_v3(fno, - CCG_elem_co(key, e[0]), - CCG_elem_co(key, e[1]), - CCG_elem_co(key, e[2]), - CCG_elem_co(key, e[3])); + CCG_elem_co(key, e[0]), + CCG_elem_co(key, e[1]), + CCG_elem_co(key, e[2]), + CCG_elem_co(key, e[3])); glNormal3fv(fno); 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(); } else if (smooth) { - for (y = 0; y < gridsize-1; y++) { + for (y = 0; y < gridsize - 1; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridsize; x++) { 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)); glNormal3fv(CCG_elem_no(key, a)); @@ -1888,22 +1888,22 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) } } else { - for (y = 0; y < gridsize-1; y++) { + for (y = 0; y < gridsize - 1; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridsize; x++) { 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) { - CCGElem *c = CCG_grid_elem(key, grid, x-1, y); - CCGElem *d = CCG_grid_elem(key, grid, x-1, y+1); + CCGElem *c = CCG_grid_elem(key, grid, x - 1, y); + CCGElem *d = CCG_grid_elem(key, grid, x - 1, y + 1); float fno[3]; normal_quad_v3(fno, - CCG_elem_co(key, d), - CCG_elem_co(key, b), - CCG_elem_co(key, a), - CCG_elem_co(key, c)); + CCG_elem_co(key, d), + CCG_elem_co(key, b), + CCG_elem_co(key, a), + CCG_elem_co(key, c)); glNormal3fv(fno); 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; smooth = f->flag & ME_SMOOTH; - glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); + glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); } else if (buffers->totgrid) { 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; smooth = f->flag & ME_SMOOTH; - glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); + glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); } 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; for (i = 0; i < last; i++) { glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), - offset + offsetof(VertexBufferFormat, co)); + offset + offsetof(VertexBufferFormat, co)); glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), - offset + offsetof(VertexBufferFormat, no)); + offset + offsetof(VertexBufferFormat, no)); 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); @@ -1967,11 +1967,11 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) } else { glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), - (void*)offsetof(VertexBufferFormat, co)); + (void *)offsetof(VertexBufferFormat, co)); glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), - (void*)offsetof(VertexBufferFormat, no)); + (void *)offsetof(VertexBufferFormat, no)); 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); } diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index d3b7381cdb5..0cef9aa03b7 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -45,16 +45,16 @@ struct MTex; struct Image; typedef struct BrushClone { - struct Image *image; /* image for clone tool */ - float offset[2]; /* offset of clone image from canvas */ - float alpha, pad; /* transparency for drawing of clone image */ + struct Image *image; /* image for clone tool */ + float offset[2]; /* offset of clone image from canvas */ + float alpha, pad; /* transparency for drawing of clone image */ } BrushClone; typedef struct Brush { ID id; struct BrushClone clone; - struct CurveMapping *curve; /* falloff curve */ + struct CurveMapping *curve; /* falloff curve */ struct MTex mtex; struct Brush *toggle_brush; @@ -65,38 +65,38 @@ typedef struct Brush { float normal_weight; - short blend; /* blend mode */ - short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */ - float weight; /* brush weight */ - int size; /* brush diameter */ - int flag; /* general purpose flag */ - float jitter; /* jitter the position of the brush */ - int spacing; /* spacing of paint operations */ - 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 rate; /* paint operations / second (airbrush) */ + short blend; /* blend mode */ + short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */ + float weight; /* brush weight */ + int size; /* brush diameter */ + int flag; /* general purpose flag */ + float jitter; /* jitter the position of the brush */ + int spacing; /* spacing of paint operations */ + 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 rate; /* paint operations / second (airbrush) */ - float rgb[3]; /* color */ - float alpha; /* opacity */ + float rgb[3]; /* color */ + 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 vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */ - char imagepaint_tool; /* active image paint tool */ - char mask_tool; /* enum BrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */ + char sculpt_tool; /* active sculpt tool */ + char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */ + char imagepaint_tool; /* active image paint tool */ + char mask_tool; /* enum BrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */ float autosmooth_factor; float crease_pinch_factor; 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; - int texture_overlay_alpha; + int texture_overlay_alpha; float unprojected_radius; @@ -106,38 +106,38 @@ typedef struct Brush { /* Brush.flag */ typedef enum BrushFlags { - BRUSH_AIRBRUSH = (1<<0), - BRUSH_TORUS = (1<<1), - BRUSH_ALPHA_PRESSURE = (1<<2), - BRUSH_SIZE_PRESSURE = (1<<3), - BRUSH_JITTER_PRESSURE = (1<<4), - BRUSH_SPACING_PRESSURE = (1<<5), - BRUSH_FIXED_TEX = (1<<6), - BRUSH_RAKE = (1<<7), - BRUSH_ANCHORED = (1<<8), - BRUSH_DIR_IN = (1<<9), - BRUSH_SPACE = (1<<10), - BRUSH_SMOOTH_STROKE = (1<<11), - BRUSH_PERSISTENT = (1<<12), - BRUSH_ACCUMULATE = (1<<13), - BRUSH_LOCK_ALPHA = (1<<14), - BRUSH_ORIGINAL_NORMAL = (1<<15), - BRUSH_OFFSET_PRESSURE = (1<<16), - BRUSH_SPACE_ATTEN = (1<<18), - BRUSH_ADAPTIVE_SPACE = (1<<19), - BRUSH_LOCK_SIZE = (1<<20), - BRUSH_TEXTURE_OVERLAY = (1<<21), - BRUSH_EDGE_TO_EDGE = (1<<22), - BRUSH_RESTORE_MESH = (1<<23), - BRUSH_INVERSE_SMOOTH_PRESSURE = (1<<24), - BRUSH_RANDOM_ROTATION = (1<<25), - BRUSH_PLANE_TRIM = (1<<26), - BRUSH_FRONTFACE = (1<<27), - BRUSH_CUSTOM_ICON = (1<<28), + BRUSH_AIRBRUSH = (1 << 0), + BRUSH_TORUS = (1 << 1), + BRUSH_ALPHA_PRESSURE = (1 << 2), + BRUSH_SIZE_PRESSURE = (1 << 3), + BRUSH_JITTER_PRESSURE = (1 << 4), + BRUSH_SPACING_PRESSURE = (1 << 5), + BRUSH_FIXED_TEX = (1 << 6), + BRUSH_RAKE = (1 << 7), + BRUSH_ANCHORED = (1 << 8), + BRUSH_DIR_IN = (1 << 9), + BRUSH_SPACE = (1 << 10), + BRUSH_SMOOTH_STROKE = (1 << 11), + BRUSH_PERSISTENT = (1 << 12), + BRUSH_ACCUMULATE = (1 << 13), + BRUSH_LOCK_ALPHA = (1 << 14), + BRUSH_ORIGINAL_NORMAL = (1 << 15), + BRUSH_OFFSET_PRESSURE = (1 << 16), + BRUSH_SPACE_ATTEN = (1 << 18), + BRUSH_ADAPTIVE_SPACE = (1 << 19), + BRUSH_LOCK_SIZE = (1 << 20), + BRUSH_TEXTURE_OVERLAY = (1 << 21), + BRUSH_EDGE_TO_EDGE = (1 << 22), + BRUSH_RESTORE_MESH = (1 << 23), + BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24), + BRUSH_RANDOM_ROTATION = (1 << 25), + BRUSH_PLANE_TRIM = (1 << 26), + BRUSH_FRONTFACE = (1 << 27), + BRUSH_CUSTOM_ICON = (1 << 28), /* temporary flag which sets up automatically for correct brush * drawing when inverted modal operator is running */ - BRUSH_INVERTED = (1<<29) + BRUSH_INVERTED = (1 << 29) } BrushFlags; /* Brush.sculpt_tool */ @@ -167,10 +167,10 @@ typedef enum BrushSculptTool { } BrushSculptTool; /* ImagePaintSettings.tool */ -#define PAINT_TOOL_DRAW 0 -#define PAINT_TOOL_SOFTEN 1 -#define PAINT_TOOL_SMEAR 2 -#define PAINT_TOOL_CLONE 3 +#define PAINT_TOOL_DRAW 0 +#define PAINT_TOOL_SOFTEN 1 +#define PAINT_TOOL_SMEAR 2 +#define PAINT_TOOL_CLONE 3 /* direction that the brush displaces along */ enum { diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 6ff51f7e864..893dd7a9707 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -46,7 +46,8 @@ static EnumPropertyItem prop_direction_items[] = { {0, "ADD", 0, "Add", "Add 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[] = { {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_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""}, {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; 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_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"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem brush_image_tool_items[] = { {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""}, {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""}, {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""}, {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; #ifdef RNA_RUNTIME @@ -104,117 +108,117 @@ EnumPropertyItem brush_image_tool_items[] = { static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ELEM6(br->sculpt_tool, - SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, - SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER); + SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, + SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER); } 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); } 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; } static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && - !(br->flag & BRUSH_RESTORE_MESH) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !(br->flag & BRUSH_RESTORE_MESH) && + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } 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); } 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; } 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); } 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, - 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) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) && - !(br->flag & BRUSH_ANCHORED) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !(br->flag & BRUSH_ANCHORED) && + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } 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, - SCULPT_TOOL_MASK, SCULPT_TOOL_PINCH, - SCULPT_TOOL_SMOOTH); + SCULPT_TOOL_MASK, SCULPT_TOOL_PINCH, + SCULPT_TOOL_SMOOTH); } 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, - SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, - SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL, - SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, - SCULPT_TOOL_SCRAPE); + SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, + SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL, + SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, + SCULPT_TOOL_SCRAPE); } 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) && - !(br->flag & BRUSH_RESTORE_MESH) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !(br->flag & BRUSH_RESTORE_MESH) && + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } 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) && - !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); + !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); } static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } 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); } @@ -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) { - Brush *br = (Brush*)ptr->data; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); + Brush *br = (Brush *)ptr->data; + WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ } 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_update(bmain, scene, 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_update(bmain, scene, 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_update(bmain, scene, 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) { 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)); } - 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) { - Brush* brush = ptr->data; + Brush *brush = ptr->data; /* scale unprojected radius so it stays consistent with brush size */ BKE_brush_scale_unprojected_radius(&brush->unprojected_radius, - value, brush->size); + value, brush->size); brush->size = 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 */ 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)) { static EnumPropertyItem prop_default_items[] = { - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem prop_flatten_contrast_items[] = { {0, "FLATTEN", 0, "Flatten", "Add 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[] = { {0, "FILL", 0, "Fill", "Add 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[] = { {0, "SCRAPE", 0, "Scrape", "Add 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[] = { {0, "PINCH", 0, "Pinch", "Add 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[] = { {0, "INFLATE", 0, "Inflate", "Add 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) { case SCULPT_TOOL_DRAW: @@ -347,12 +357,12 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerR case SCULPT_TOOL_MASK: switch ((BrushMaskTool)me->mask_tool) { - case BRUSH_MASK_DRAW: - return prop_direction_items; - break; - case BRUSH_MASK_SMOOTH: - return prop_default_items; - break; + case BRUSH_MASK_DRAW: + return prop_direction_items; + break; + case BRUSH_MASK_SMOOTH: + return prop_default_items; + break; } 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_TILED, "TILED", 0, "Tiled", ""}, {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); 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); 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_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_nested(brna, srna, "Brush"); RNA_def_struct_ui_text(srna, "Sculpt Capabilities", - "Read-only indications of which brush operations " - "are supported by the current sculpt tool"); - -#define BRUSH_CAPABILITY(prop_name_, ui_name_) \ - prop = RNA_def_property(srna, #prop_name_, \ - PROP_BOOLEAN, PROP_NONE); \ - RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ - RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_" \ - #prop_name_ "_get", NULL); \ + "Read-only indications of which brush operations " + "are supported by the current sculpt tool"); + +#define BRUSH_CAPABILITY(prop_name_, ui_name_) \ + prop = RNA_def_property(srna, #prop_name_, \ + PROP_BOOLEAN, PROP_NONE); \ + RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ + RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_" \ + #prop_name_ "_get", NULL); \ RNA_def_property_ui_text(prop, ui_name_, NULL) 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_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase 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[] = { {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_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)"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem texture_angle_source_items[] = { {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_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[] = { {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"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem brush_sculpt_plane_items[] = { {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_Y, "Y", 0, "Y 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[] = { {BRUSH_MASK_DRAW, "DRAW", 0, "Draw", ""}, {BRUSH_MASK_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "Brush", "ID"); 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_items(prop, brush_image_tool_items); 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); 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_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_ui_text(prop, "Mask Tool", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); @@ -557,7 +574,7 @@ static void rna_def_brush(BlenderRNA *brna) /* number values */ 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_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_text(prop, "Radius", "Radius of the brush in pixels"); 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); 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_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches"); 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_flag(prop, PROP_EDITABLE); 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); RNA_def_property_float_sdna(prop, NULL, "clone.alpha"); 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_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); RNA_def_property_float_sdna(prop, NULL, "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_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) */ prop = RNA_def_property(srna, "sculpt_capabilities", PROP_POINTER, PROP_NONE); diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index ae5ac9ac718..472836e3716 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -95,7 +95,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, if (result == dm) return dm; - if(useRenderParams || !(flag & MOD_APPLY_USECACHE)) { + if (useRenderParams || !(flag & MOD_APPLY_USECACHE)) { DerivedMesh *cddm; cddm = CDDM_copy(result); @@ -120,14 +120,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, cddm->getPolyArray(cddm), cddm->getNumPolys(cddm)); } - if(grid_paint_mask) { + if (grid_paint_mask) { float *paint_mask = CustomData_add_layer(&cddm->vertData, - CD_PAINT_MASK, - CD_CALLOC, NULL, - cddm->getNumVerts(cddm)); + CD_PAINT_MASK, + CD_CALLOC, NULL, + cddm->getNumVerts(cddm)); subsurf_copy_grid_paint_mask(result, me->mpoly, - paint_mask, grid_paint_mask); + paint_mask, grid_paint_mask); } } diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 683dbc38ee5..e97f4191e6f 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -99,11 +99,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, const int useRenderParams = flag & MOD_APPLY_RENDER; const int isFinalCalc = flag & MOD_APPLY_USECACHE; - if(useRenderParams) + if (useRenderParams) subsurf_flags |= SUBSURF_USE_RENDER_PARAMS; - if(isFinalCalc) + if (isFinalCalc) subsurf_flags |= SUBSURF_IS_FINAL_CALC; - if(ob->flag & OB_MODE_EDIT) + if (ob->flag & OB_MODE_EDIT) subsurf_flags |= SUBSURF_IN_EDIT_MODE; 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; result = subsurf_make_derived_from_derived(derivedData, smd, - NULL, (SUBSURF_FOR_EDIT_MODE | - SUBSURF_IN_EDIT_MODE)); + NULL, (SUBSURF_FOR_EDIT_MODE | + SUBSURF_IN_EDIT_MODE)); return result; } -- cgit v1.2.3