diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_multires.h | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_subsurf.h | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 106 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 50 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 72 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 66 |
8 files changed, 171 insertions, 171 deletions
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; i<calc->numVerts; ++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; i<calc->numVerts; ++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; i<calc->numVerts; ++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; x<gridFaces; x++) { + for (x = 0; x < gridFaces; x++) { a = CCG_grid_elem(&key, faceGridData, x, y + 0); b = CCG_grid_elem(&key, faceGridData, x, y + 1); @@ -2196,7 +2196,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, } } else { - glShadeModel((cp)? GL_SMOOTH: GL_FLAT); + glShadeModel((cp) ? GL_SMOOTH : GL_FLAT); glBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { @@ -2346,7 +2346,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, * normals are already used to change shading */ glShadeModel(GL_SMOOTH); - for (S=0; S<numVerts; S++) { + for (S = 0; S < numVerts; S++) { CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); if (drawSmooth) { for (y = 0; y < gridFaces; y++) { @@ -2507,7 +2507,7 @@ static void ccgDM_foreachMappedFaceCenter( int index = ccgDM_getFaceMapIndex(ss, f); if (index != -1) { - /* Face center data normal isn't updated atm. */ + /* Face center data normal isn't updated atm. */ CCGElem *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0); func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd)); @@ -2914,7 +2914,7 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm) static void ccgDM_getGridKey(DerivedMesh *dm, CCGKey *key) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCG_key_top_level(key, ccgdm->ss); } @@ -3005,14 +3005,14 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new(); 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; |