diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_dynamicpaint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/BME_Customdata.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/BME_mesh.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/dynamicpaint.c | 36 |
5 files changed, 35 insertions, 15 deletions
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h index a4a810ba177..75b3c5b4f24 100644 --- a/source/blender/blenkernel/BKE_dynamicpaint.h +++ b/source/blender/blenkernel/BKE_dynamicpaint.h @@ -46,6 +46,7 @@ typedef struct PaintWavePoint { float height; float velocity; + float brush_isect; short state; } PaintWavePoint; @@ -82,6 +83,7 @@ void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char* #define DPAINT_PAINT_NEW 2 /* PaintWavePoint state */ +#define DPAINT_WAVE_ISECT_CHANGED -1 #define DPAINT_WAVE_NONE 0 #define DPAINT_WAVE_OBSTACLE 1 #define DPAINT_WAVE_REFLECT_ONLY 2 diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c index 94307968933..424af08f943 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -87,7 +87,7 @@ void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc if(data->totlayer){ /*alloc memory*/ data->layers = MEM_callocN(sizeof(BME_CustomDataLayer)*data->totlayer, "BMesh Custom Data Layers"); - data->pool = BLI_mempool_create(data->totsize, initalloc, initalloc, 1); + data->pool = BLI_mempool_create(data->totsize, initalloc, initalloc, TRUE); /*initialize layer data*/ for(i=0; i < BME_CD_NUMTYPES; i++){ if(init->layout[i]){ diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index 89f9a6bc945..dcca2da5414 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -56,10 +56,10 @@ BME_Mesh *BME_make_mesh(int allocsize[4]) /*allocate the structure*/ BME_Mesh *bm = MEM_callocN(sizeof(BME_Mesh),"BMesh"); /*allocate the memory pools for the mesh elements*/ - bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0], 1, 0); - bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1], 1, 0); - bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2], 1, 0); - bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3], 1, 0); + bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0], TRUE, FALSE); + bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1], TRUE, FALSE); + bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2], TRUE, FALSE); + bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3], TRUE, FALSE); return bm; } /* diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f0b93212766..e2f8c68e75f 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2360,7 +2360,7 @@ void CustomData_bmesh_init_pool(CustomData *data, int allocsize) /* If there are no layers, no pool is needed just yet */ if (data->totlayer) { - data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, 1, 0); + data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, TRUE, FALSE); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index d43f114e2af..11fe79daa51 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -98,7 +98,8 @@ static int neighY[8] = {0,1,1, 1, 0,-1,-1,-1}; /* paint effect default movement per frame in global units */ #define EFF_MOVEMENT_PER_FRAME 0.05f /* initial wave time factor */ -#define WAVE_TIME_FAC 0.1 +#define WAVE_TIME_FAC (1.0f/24.f) +#define WAVE_INIT_SIZE 5.0f /* drying limits */ #define MIN_WETNESS 0.001f /* dissolve macro */ @@ -149,6 +150,7 @@ typedef struct PaintBakeData { int *s_num; /* num of realCoord samples */ Vec3f *realCoord; /* current pixel center world-space coordinates for each sample * ordered as (s_pos+s_num)*/ + Bounds3D mesh_bounds; /* adjacency info */ BakeNeighPoint *bNeighs; /* current global neighbour distances and directions, if required */ @@ -969,7 +971,7 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett surface->color_spread_speed = 1.0f; surface->shrink_speed = 1.0f; - surface->wave_damping = 0.05f; + surface->wave_damping = 0.04f; surface->wave_speed = 1.0f; surface->wave_timescale = 1.0f; surface->wave_spring = 0.20f; @@ -1037,6 +1039,7 @@ int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, stru brush->particle_radius = 0.2f; brush->particle_smooth = 0.05f; + brush->wave_type = MOD_DPAINT_WAVEB_CHANGE; brush->wave_factor = 1.0f; brush->wave_clamp = 0.0f; brush->smudge_strength = 0.3f; @@ -2070,7 +2073,6 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) PaintUVPoint *tempPoints = NULL; Vec3f *tempWeights = NULL; - /* MVert *mvert = NULL; */ /* UNUSED */ MFace *mface = NULL; MTFace *tface = NULL; Bounds2D *faceBB = NULL; @@ -2081,7 +2083,6 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) return setError(canvas, "Can't bake non-\"image sequence\" formats."); numOfFaces = dm->getNumFaces(dm); - /* mvert = dm->getVertArray(dm); */ /* UNUSED */ mface = dm->getTessFaceArray(dm); /* get uv layer */ @@ -2859,7 +2860,12 @@ static void dynamicPaint_mixPaintColors(DynamicPaintSurface *surface, int index, /* applies given brush intersection value for wave surface */ static void dynamicPaint_mixWaveHeight(PaintWavePoint *wPoint, DynamicPaintBrushSettings *brush, float isect_height) { + float isect_change = isect_height - wPoint->brush_isect; int hit = 0; + /* intersection marked regardless of brush type or hit */ + wPoint->brush_isect = isect_height; + wPoint->state = DPAINT_WAVE_ISECT_CHANGED; + isect_height *= brush->wave_factor; /* determine hit depending on wave_factor */ @@ -2878,6 +2884,10 @@ static void dynamicPaint_mixWaveHeight(PaintWavePoint *wPoint, DynamicPaintBrush wPoint->velocity = isect_height; else if (brush->wave_type == MOD_DPAINT_WAVEB_REFLECT) wPoint->state = DPAINT_WAVE_REFLECT_ONLY; + else if (brush->wave_type == MOD_DPAINT_WAVEB_CHANGE) { + if (isect_change < 0.0f) + wPoint->height += isect_change*brush->wave_factor; + } } } @@ -4292,6 +4302,9 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) float dt, min_dist, damp_factor; float wave_speed = surface->wave_speed; double average_dist = 0.0f; + Bounds3D *mb = &sData->bData->mesh_bounds; + float canvas_size = MAX3((mb->max[0]-mb->min[0]), (mb->max[1]-mb->min[1]), (mb->max[2]-mb->min[2])); + float wave_scale = WAVE_INIT_SIZE/canvas_size; /* allocate memory */ PaintWavePoint *prevPoint = MEM_mallocN(sData->total_points*sizeof(PaintWavePoint), "Temp previous points for wave simulation"); @@ -4307,11 +4320,11 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) average_dist += bNeighs[sData->adj_data->n_index[index]+i].dist; } } - average_dist /= sData->adj_data->total_targets; + average_dist *= wave_scale/sData->adj_data->total_targets; /* determine number of required steps */ steps = (int)ceil((WAVE_TIME_FAC*timescale*surface->wave_timescale) / (average_dist/wave_speed/3)); - CLAMP(steps, 1, 15); + CLAMP(steps, 1, 20); timescale /= steps; /* apply simulation values for final timescale */ @@ -4332,12 +4345,12 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) int numOfN = 0, numOfRN = 0; int i; - if (wPoint->state) continue; + if (wPoint->state > 0) continue; /* calculate force from surrounding points */ for (i=0; i<numOfNeighs; i++) { int n_index = sData->adj_data->n_index[index]+i; - float dist = bNeighs[n_index].dist; + float dist = bNeighs[n_index].dist*wave_scale; PaintWavePoint *tPoint = &prevPoint[sData->adj_data->n_target[n_index]]; if (!dist || tPoint->state>0) continue; @@ -4381,6 +4394,10 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) #pragma omp parallel for schedule(static) for (index = 0; index < sData->total_points; index++) { PaintWavePoint *wPoint = &((PaintWavePoint*)sData->type_data)[index]; + /* if there wasnt any brush intersection, clear isect height */ + if (wPoint->state == DPAINT_WAVE_NONE) { + wPoint->brush_isect = 0.0f; + } wPoint->state = DPAINT_WAVE_NONE; } @@ -4594,10 +4611,11 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc /* * Make a transformed copy of canvas derived mesh vertices to avoid recalculation. */ - #pragma omp parallel for schedule(static) + bData->mesh_bounds.valid = 0; for (index=0; index<canvasNumOfVerts; index++) { copy_v3_v3(canvas_verts[index].v, mvert[index].co); mul_m4_v3(ob->obmat, canvas_verts[index].v); + boundInsert(&bData->mesh_bounds, canvas_verts[index].v); } /* |