style cleanup: mainly sculpt/whitespace
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -594,7 +594,7 @@ 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),
|
||||
CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x * skip),
|
||||
sizeof(float) * keyA->num_layers);
|
||||
}
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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,16 +1189,16 @@ 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));
|
||||
@@ -1304,11 +1304,11 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
|
||||
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];
|
||||
@@ -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 */
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
@@ -168,9 +168,9 @@ int paint_is_grid_face_hidden(const unsigned int *grid_hidden,
|
||||
{
|
||||
/* 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,
|
||||
@@ -179,5 +179,5 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level,
|
||||
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)];
|
||||
}
|
||||
|
@@ -83,13 +83,13 @@
|
||||
|
||||
#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?
|
||||
}
|
||||
|
||||
@@ -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,7 +190,7 @@ 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);
|
||||
@@ -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 */
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
|
||||
|
||||
//Raycast and tree stuff
|
||||
BVHTreeRayHit hit;
|
||||
BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh;
|
||||
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
|
||||
|
||||
//auxiliary target
|
||||
DerivedMesh *auxMesh = NULL;
|
||||
@@ -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);
|
||||
@@ -402,7 +402,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
|
||||
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,9 +452,9 @@ 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);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
|
||||
|
||||
//Using vertexs positions/normals as if a subsurface was applied
|
||||
if (smd->subsurfLevels) {
|
||||
SubsurfModifierData ssmd= {{NULL}};
|
||||
SubsurfModifierData ssmd = {{NULL}};
|
||||
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
|
||||
ssmd.levels = smd->subsurfLevels; //levels
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,7 @@ void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly,
|
||||
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++) {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -3007,9 +3007,9 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
|
||||
BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
|
||||
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);
|
||||
|
@@ -52,7 +52,7 @@ 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 */
|
||||
|
||||
@@ -82,9 +82,9 @@ void BLI_pbvh_search_gather(PBVH *bvh,
|
||||
* 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],
|
||||
int BLI_pbvh_node_raycast(PBVH * bvh, PBVHNode * node, float (*origco)[3],
|
||||
float ray_start[3], float ray_normal[3], float *dist);
|
||||
|
||||
/* Drawing */
|
||||
@@ -134,10 +134,10 @@ void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node,
|
||||
void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node,
|
||||
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,7 +147,7 @@ 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);
|
||||
@@ -212,39 +212,39 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
|
||||
#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.g<vi.totgrid; vi.g++) { \
|
||||
if(vi.grids) { \
|
||||
vi.width= vi.gridsize; \
|
||||
vi.height= vi.gridsize; \
|
||||
vi.grid= vi.grids[vi.grid_indices[vi.g]]; \
|
||||
if(mode == PBVH_ITER_UNIQUE) \
|
||||
vi.gh= vi.grid_hidden[vi.grid_indices[vi.g]]; \
|
||||
for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
|
||||
if (vi.grids) { \
|
||||
vi.width = vi.gridsize; \
|
||||
vi.height = vi.gridsize; \
|
||||
vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
|
||||
if (mode == PBVH_ITER_UNIQUE) \
|
||||
vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
|
||||
} \
|
||||
else { \
|
||||
vi.width= vi.totvert; \
|
||||
vi.height= 1; \
|
||||
vi.width = vi.totvert; \
|
||||
vi.height = 1; \
|
||||
} \
|
||||
\
|
||||
for(vi.gy=0; vi.gy<vi.height; vi.gy++) { \
|
||||
for(vi.gx=0; vi.gx<vi.width; vi.gx++, vi.i++) { \
|
||||
if(vi.grid) { \
|
||||
vi.co= CCG_elem_co(vi.key, vi.grid); \
|
||||
vi.fno= CCG_elem_no(vi.key, vi.grid); \
|
||||
vi.mask= CCG_elem_mask(vi.key, vi.grid); \
|
||||
vi.grid= CCG_elem_next(vi.key, vi.grid); \
|
||||
if(vi.gh) { \
|
||||
if(BLI_BITMAP_GET(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
|
||||
for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
|
||||
for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
|
||||
if (vi.grid) { \
|
||||
vi.co = CCG_elem_co(vi.key, vi.grid); \
|
||||
vi.fno = CCG_elem_no(vi.key, vi.grid); \
|
||||
vi.mask = CCG_elem_mask(vi.key, vi.grid); \
|
||||
vi.grid = CCG_elem_next(vi.key, vi.grid); \
|
||||
if (vi.gh) { \
|
||||
if (BLI_BITMAP_GET(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
|
||||
continue; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
vi.mvert= &vi.mverts[vi.vert_indices[vi.gx]]; \
|
||||
if(mode == PBVH_ITER_UNIQUE && vi.mvert->flag & 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]);
|
||||
|
@@ -118,7 +118,7 @@ struct PBVHNode {
|
||||
float tmin;
|
||||
|
||||
int proxy_count;
|
||||
PBVHProxyNode* proxies;
|
||||
PBVHProxyNode *proxies;
|
||||
};
|
||||
|
||||
struct PBVH {
|
||||
@@ -244,7 +244,8 @@ 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;
|
||||
@@ -256,7 +257,7 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node)
|
||||
&bvh->nodes[node->children_offset + 1].vb);
|
||||
}
|
||||
|
||||
node->vb= vb;
|
||||
node->vb = vb;
|
||||
}
|
||||
|
||||
//void BLI_pbvh_node_BB_reset(PBVHNode* node)
|
||||
@@ -286,10 +287,10 @@ static int grid_materials_match(const DMFlagMat *f1, const DMFlagMat *f2)
|
||||
static int partition_indices(int *prim_indices, int lo, int hi, int axis,
|
||||
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))
|
||||
@@ -383,9 +384,9 @@ 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,
|
||||
node->face_vert_indices = MEM_callocN(sizeof(int) * 4 * totface,
|
||||
"bvh node face vert indices");
|
||||
|
||||
for (i = 0; i < totface; ++i) {
|
||||
@@ -393,7 +394,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
|
||||
int sides = f->v4 ? 4 : 3;
|
||||
|
||||
for (j = 0; j < sides; ++j) {
|
||||
node->face_vert_indices[i][j]=
|
||||
node->face_vert_indices[i][j] =
|
||||
map_insert_vert(bvh, map, &node->face_verts,
|
||||
&node->uniq_verts, (&f->v1)[j]);
|
||||
}
|
||||
@@ -425,7 +426,7 @@ 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->face_vert_indices[i][j] +
|
||||
node->uniq_verts - 1;
|
||||
}
|
||||
@@ -461,7 +462,7 @@ static void update_vb(PBVH *bvh, PBVHNode *node, BBC *prim_bbc,
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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,14 +783,14 @@ 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)
|
||||
@@ -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,11 +823,11 @@ 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 */
|
||||
|
||||
@@ -835,8 +836,8 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -848,27 +849,27 @@ void BLI_pbvh_search_gather(PBVH *bvh,
|
||||
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,11 +878,11 @@ 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,
|
||||
@@ -893,7 +894,7 @@ void BLI_pbvh_search_callback(PBVH *bvh,
|
||||
|
||||
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,7 +952,7 @@ 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;
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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,19 +1029,19 @@ 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,
|
||||
@@ -1050,7 +1051,7 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes,
|
||||
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;
|
||||
}
|
||||
@@ -1113,14 +1114,14 @@ static void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes,
|
||||
/* 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,7 +1135,7 @@ 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);
|
||||
@@ -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;
|
||||
@@ -1225,10 +1226,10 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3])
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@@ -1361,13 +1362,13 @@ void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *to
|
||||
|
||||
switch (bvh->type) {
|
||||
case PBVH_GRIDS:
|
||||
tot= node->totprim * bvh->gridkey.grid_area;
|
||||
if (totvert) *totvert= tot;
|
||||
if (uniquevert) *uniquevert= tot;
|
||||
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;
|
||||
if (totvert) *totvert = node->uniq_verts + node->face_verts;
|
||||
if (uniquevert) *uniquevert = node->uniq_verts;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1376,20 +1377,20 @@ void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int
|
||||
{
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
@@ -1513,7 +1514,7 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
|
||||
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;
|
||||
@@ -1521,8 +1522,8 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
|
||||
switch (bvh->type) {
|
||||
case PBVH_FACES:
|
||||
vert = bvh->verts;
|
||||
faces= node->prim_indices;
|
||||
totface= node->totprim;
|
||||
faces = node->prim_indices;
|
||||
totface = node->totprim;
|
||||
|
||||
for (i = 0; i < totface; ++i) {
|
||||
const MFace *f = bvh->faces + faces[i];
|
||||
@@ -1537,7 +1538,7 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
|
||||
origco[face_verts[0]],
|
||||
origco[face_verts[1]],
|
||||
origco[face_verts[2]],
|
||||
f->v4? origco[face_verts[3]]: NULL,
|
||||
f->v4 ? origco[face_verts[3]] : NULL,
|
||||
dist);
|
||||
}
|
||||
else {
|
||||
@@ -1552,18 +1553,18 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
|
||||
}
|
||||
break;
|
||||
case PBVH_GRIDS:
|
||||
totgrid= node->totprim;
|
||||
gridsize= bvh->gridkey.grid_size;
|
||||
totgrid = node->totprim;
|
||||
gridsize = bvh->gridkey.grid_size;
|
||||
|
||||
for (i = 0; i < totgrid; ++i) {
|
||||
CCGElem *grid= bvh->grids[node->prim_indices[i]];
|
||||
CCGElem *grid = bvh->grids[node->prim_indices[i]];
|
||||
if (!grid)
|
||||
continue;
|
||||
|
||||
gh= bvh->grid_hidden[node->prim_indices[i]];
|
||||
gh = bvh->grid_hidden[node->prim_indices[i]];
|
||||
|
||||
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) {
|
||||
/* check if grid face is hidden */
|
||||
if (gh) {
|
||||
if (paint_is_grid_face_hidden(gh, gridsize, x, y))
|
||||
@@ -1572,25 +1573,25 @@ int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3],
|
||||
|
||||
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],
|
||||
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),
|
||||
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;
|
||||
origco += gridsize * gridsize;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1685,7 +1686,7 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
|
||||
BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals|PBVH_UpdateDrawBuffers),
|
||||
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);
|
||||
@@ -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; a<pbvh->totvert; 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,74 +1785,74 @@ 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,
|
||||
@@ -1862,33 +1863,33 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
|
||||
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);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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";
|
||||
|
@@ -133,7 +133,7 @@ void paint_calc_redraw_planes(float planes[4][4],
|
||||
|
||||
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]);
|
||||
|
||||
|
@@ -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) */
|
||||
@@ -264,16 +265,16 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
|
||||
{
|
||||
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:
|
||||
@@ -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);
|
||||
|
||||
|
@@ -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]);
|
||||
@@ -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,9 +1075,10 @@ 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,
|
||||
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) {
|
||||
@@ -1126,12 +1130,12 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
|
||||
#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,12 +1144,12 @@ 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));
|
||||
@@ -1210,14 +1214,14 @@ 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,
|
||||
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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
(*vd.mask) += fade*bstrength;
|
||||
(*vd.mask) += fade * bstrength;
|
||||
CLAMP(*vd.mask, 0, 1);
|
||||
|
||||
if (vd.mvert)
|
||||
@@ -1373,7 +1378,8 @@ 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,
|
||||
@@ -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,9 +1478,10 @@ 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,
|
||||
float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
|
||||
ss->cache->view_normal, vd.no,
|
||||
vd.fno, *vd.mask);
|
||||
float val[3];
|
||||
@@ -1536,7 +1544,7 @@ 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,
|
||||
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,9 +1584,10 @@ 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,
|
||||
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,9 +1635,10 @@ 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,
|
||||
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,9 +1685,10 @@ 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,
|
||||
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,9 +1740,10 @@ 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,
|
||||
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]);
|
||||
@@ -1782,9 +1794,10 @@ 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,
|
||||
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,9 +1847,10 @@ 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,
|
||||
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];
|
||||
|
||||
@@ -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) {
|
||||
@@ -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,7 +2191,7 @@ 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),
|
||||
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,7 +2264,7 @@ 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,
|
||||
const float fade = bstrength * tex_strength(ss, brush, vd.co,
|
||||
sqrt(test.dist),
|
||||
an, vd.no, vd.fno, *vd.mask);
|
||||
|
||||
@@ -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,8 +2366,8 @@ 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,
|
||||
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,7 +2430,7 @@ 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,
|
||||
const float fade = bstrength * tex_strength(ss, brush, vd.co,
|
||||
sqrt(test.dist),
|
||||
an, vd.no, vd.fno, *vd.mask);
|
||||
|
||||
@@ -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,7 +2494,7 @@ 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,
|
||||
const float fade = bstrength * tex_strength(ss, brush, vd.co,
|
||||
sqrt(test.dist),
|
||||
an, vd.no, vd.fno, *vd.mask);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
@@ -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; i<unode->totvert; 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; j<unode->totgrid; j++) {
|
||||
grid= grids[unode->grids[j]];
|
||||
for (j = 0; j < unode->totgrid; j++) {
|
||||
grid = grids[unode->grids[j]];
|
||||
|
||||
for(i=0; i<gridsize*gridsize; i++, mask++)
|
||||
for (i = 0; i < gridsize * gridsize; i++, mask++)
|
||||
SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask);
|
||||
}
|
||||
}
|
||||
@@ -294,18 +294,18 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(unode->type) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
@@ -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";
|
||||
|
@@ -105,7 +105,7 @@ 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,
|
||||
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];
|
||||
@@ -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;
|
||||
|
||||
@@ -494,7 +494,7 @@ 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,
|
||||
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 */
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -885,15 +885,15 @@ 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);
|
||||
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;
|
||||
return sizeof(float) * 3 * dm->drawObject->tot_triangle_point;
|
||||
case GPU_BUFFER_COLOR:
|
||||
return sizeof(char)*3*dm->drawObject->tot_triangle_point;
|
||||
return sizeof(char) * 3 * dm->drawObject->tot_triangle_point;
|
||||
case GPU_BUFFER_UV:
|
||||
return sizeof(float)*2*dm->drawObject->tot_triangle_point;
|
||||
return sizeof(float) * 2 * dm->drawObject->tot_triangle_point;
|
||||
case GPU_BUFFER_EDGE:
|
||||
return sizeof(int)*2*dm->drawObject->totedge;
|
||||
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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda
|
||||
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);
|
||||
offset += data[i].size * GPU_typesize(data[i].type);
|
||||
|
||||
attribData[i].index = data[i].index;
|
||||
attribData[i].size = data[i].size;
|
||||
@@ -1122,7 +1122,7 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda
|
||||
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);
|
||||
offset += data[i].size * GPU_typesize(data[i].type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1171,7 +1171,7 @@ 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,
|
||||
sizeof(char) * 3 * dm->drawObject->tot_triangle_point,
|
||||
GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1255,8 +1255,8 @@ void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start,
|
||||
{
|
||||
glDrawElements(mode, count, GL_UNSIGNED_INT,
|
||||
(useVBOs ?
|
||||
(void*)(start * sizeof(unsigned int)) :
|
||||
((int*)elements->pointer) + start));
|
||||
(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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -1510,14 +1510,14 @@ 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));
|
||||
|
||||
@@ -1535,9 +1535,9 @@ 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];
|
||||
@@ -1548,7 +1548,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids,
|
||||
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],
|
||||
@@ -1585,7 +1585,7 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden,
|
||||
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++;
|
||||
}
|
||||
@@ -1631,22 +1631,22 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden,
|
||||
if (grid_hidden) \
|
||||
gh = grid_hidden[(grid_indices)[i]]; \
|
||||
\
|
||||
for (j = 0; j < gridsize-1; ++j) { \
|
||||
for (k = 0; k < gridsize-1; ++k) { \
|
||||
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); \
|
||||
} \
|
||||
@@ -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);
|
||||
|
||||
@@ -1714,14 +1714,14 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
|
||||
{
|
||||
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++) {
|
||||
@@ -1799,7 +1799,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth)
|
||||
fmask = (buffers->vmask[fv[0]] +
|
||||
buffers->vmask[fv[1]] +
|
||||
buffers->vmask[fv[2]]);
|
||||
if(f->v4)
|
||||
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 */
|
||||
@@ -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,15 +1888,15 @@ 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,
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
}
|
||||
|
@@ -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 */
|
||||
|
@@ -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,7 +108,7 @@ 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);
|
||||
@@ -112,19 +116,19 @@ static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_auto_smooth_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -134,32 +138,32 @@ static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_normal_weight_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -169,7 +173,7 @@ static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return !ELEM4(br->sculpt_tool, SCULPT_TOOL_INFLATE,
|
||||
SCULPT_TOOL_MASK, SCULPT_TOOL_PINCH,
|
||||
SCULPT_TOOL_SMOOTH);
|
||||
@@ -177,7 +181,7 @@ static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return ELEM10(br->sculpt_tool,
|
||||
SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
|
||||
SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL,
|
||||
@@ -187,7 +191,7 @@ static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return (!(br->flag & BRUSH_ANCHORED) &&
|
||||
!(br->flag & BRUSH_RESTORE_MESH) &&
|
||||
!ELEM4(br->sculpt_tool,
|
||||
@@ -197,7 +201,7 @@ static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return ((br->flag & BRUSH_SPACE) &&
|
||||
!ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
|
||||
SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK));
|
||||
@@ -205,7 +209,7 @@ static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return (!(br->flag & BRUSH_ANCHORED) &&
|
||||
!ELEM4(br->sculpt_tool,
|
||||
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
|
||||
@@ -214,7 +218,7 @@ static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr)
|
||||
|
||||
static int rna_SculptCapabilities_has_strength_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *br = (Brush*)ptr->data;
|
||||
Brush *br = (Brush *)ptr->data;
|
||||
return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
|
||||
}
|
||||
|
||||
@@ -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,12 +286,12 @@ 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,
|
||||
@@ -297,7 +301,7 @@ static void rna_Brush_set_size(PointerRNA *ptr, int 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:
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
@@ -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,7 +120,7 @@ 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,
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user