[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39063] branches/soc-2011-carrot: Dynamic Paint:
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Fri Aug 5 11:31:35 CEST 2011
Revision: 39063
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39063
Author: miikah
Date: 2011-08-05 09:31:35 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Dynamic Paint:
* Added a new "color spread" slider for "spread" effect to adjust how much colors get mixed.
* Improved smudge behavior on "wet" paint.
* Displace can now be set "incremental". This way it's added on top of previous displace.
* Added "displace clamp" setting. You can use it to limit maximum amount of displace.
* Fix: velocity data wasn't always initialized, this could lead to no effect at all or crash.
* Fix: Vertex color rendering near zero alpha values was still incorrect.
Modified Paths:
--------------
branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
branches/soc-2011-carrot/source/blender/makesdna/DNA_dynamicpaint_types.h
branches/soc-2011-carrot/source/blender/makesrna/intern/rna_dynamicpaint.c
branches/soc-2011-carrot/source/blender/render/intern/source/shadeinput.c
Modified: branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
===================================================================
--- branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-08-05 09:04:11 UTC (rev 39062)
+++ branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-08-05 09:31:35 UTC (rev 39063)
@@ -158,6 +158,7 @@
layout.prop(surface, "surface_type", expand=False)
layout.separator()
+ # dissolve
if (surface.surface_type == "PAINT"):
layout.label(text="Wetmap drying:")
split = layout.split(percentage=0.8)
@@ -176,6 +177,11 @@
split = sub.split(percentage=0.8)
split.prop(surface, "dissolve_speed", text="Time")
split.prop(surface, "use_dissolve_log", text="Slow")
+
+ # per type settings
+ if (surface.surface_type == "DISPLACE"):
+ layout.prop(surface, "disp_clamp")
+ layout.prop(surface, "incremental_disp")
if (surface.surface_type == "WAVE"):
layout.prop(surface, "wave_open_borders")
@@ -304,7 +310,11 @@
layout.prop(surface, "use_spread")
col = layout.column()
col.active = surface.use_spread
- col.prop(surface, "spread_speed")
+ split = col.split()
+ sub = split.column()
+ sub.prop(surface, "spread_speed")
+ sub = split.column()
+ sub.prop(surface, "color_spread_speed")
elif surface.effect_ui == "DRIP":
layout.prop(surface, "use_drip")
Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-08-05 09:04:11 UTC (rev 39062)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-08-05 09:31:35 UTC (rev 39063)
@@ -305,11 +305,13 @@
surface->output_name[0]='\0';
surface->output_name2[0]='\0';
surface->flags |= MOD_DPAINT_ANTIALIAS;
+ surface->disp_clamp = 1.0f;
}
else {
sprintf(surface->output_name, "dp_");
strcpy(surface->output_name2,surface->output_name);
surface->flags &= ~MOD_DPAINT_ANTIALIAS;
+ surface->disp_clamp = 0.0f;
}
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
@@ -894,7 +896,7 @@
surface->diss_speed = 300;
surface->dry_speed = 300;
- surface->disp_depth = 1.0f;
+ surface->disp_clamp = 0.0f;
surface->disp_type = MOD_DPAINT_DISP_DISPLACE;
surface->image_fileformat = MOD_DPAINT_IMGFORMAT_PNG;
@@ -911,6 +913,7 @@
}
surface->spread_speed = 1.0f;
+ surface->color_spread_speed = 1.0f;
surface->shrink_speed = 1.0f;
surface->wave_damping = 0.05f;
@@ -1263,87 +1266,40 @@
/***************************** Modifier processing ******************************/
-/* update cache frame range */
-void dynamicPaint_cacheUpdateFrames(DynamicPaintSurface *surface) {
- if (surface->pointcache) {
- surface->pointcache->startframe = surface->start_frame;
- surface->pointcache->endframe = surface->end_frame;
- }
-}
-
-/*
-* Updates derived mesh copy and processes dynamic paint step / caches.
-*/
-static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
+/* apply displacing vertex surface to the derived mesh */
+static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, DerivedMesh *result, int update_normals)
{
- if(pmd->canvas) {
- DynamicPaintCanvasSettings *canvas = pmd->canvas;
- DynamicPaintSurface *surface = canvas->surfaces.first;
+ PaintSurfaceData *sData = surface->data;
- /* update derived mesh copy */
- if (canvas->dm) canvas->dm->release(canvas->dm);
- canvas->dm = CDDM_copy(dm);
+ if (!sData || surface->format != MOD_DPAINT_SURFACE_F_VERTEX) return;
- /* in case image sequence baking, stop here */
- if (canvas->flags & MOD_DPAINT_BAKING) return;
+ /* displace paint */
+ if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
+ MVert *mvert = result->getVertArray(result);
+ int i;
+ float* value = (float*)sData->type_data;
- /* loop through surfaces */
- for (; surface; surface=surface->next) {
- int current_frame = (int)scene->r.cfra;
+ #pragma omp parallel for schedule(static)
+ for (i=0; i<sData->total_points; i++) {
+ float normal[3];
+ normal_short_to_float_v3(normal, mvert[i].no);
+ normalize_v3(normal);
- /* image sequences are handled by bake operator */
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) continue;
- if (!(surface->flags & MOD_DPAINT_ACTIVE)) continue;
-
- /* make sure surface is valid */
- dynamicPaint_checkSurfaceData(surface);
-
- /* limit frame range */
- CLAMP(current_frame, surface->start_frame, surface->end_frame);
-
- if (current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
- PointCache *cache = surface->pointcache;
- PTCacheID pid;
- surface->current_frame = current_frame;
-
- /* read point cache */
- BKE_ptcache_id_from_dynamicpaint(&pid, ob, surface);
- pid.cache->startframe = surface->start_frame;
- pid.cache->endframe = surface->end_frame;
- BKE_ptcache_id_time(&pid, scene, scene->r.cfra, NULL, NULL, NULL);
-
- /* reset non-baked cache at first frame */
- if((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED))
- {
- cache->flag |= PTCACHE_REDO_NEEDED;
- BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- cache->flag &= ~PTCACHE_REDO_NEEDED;
- }
-
- /* try to read from cache */
- if(BKE_ptcache_read(&pid, (float)scene->r.cfra)) {
- BKE_ptcache_validate(cache, (int)scene->r.cfra);
- }
- /* if read failed and we're on surface range do recalculate */
- else if ((int)scene->r.cfra == current_frame
- && !(cache->flag & PTCACHE_BAKED)) {
- /* calculate surface frame */
- canvas->flags |= MOD_DPAINT_BAKING;
- dynamicPaint_calculateFrame(surface, scene, ob, current_frame);
- canvas->flags &= ~MOD_DPAINT_BAKING;
-
- BKE_ptcache_validate(cache, surface->current_frame);
- BKE_ptcache_write(&pid, surface->current_frame);
- }
- }
+ mvert[i].co[0] -= normal[0]*value[i];
+ mvert[i].co[1] -= normal[1]*value[i];
+ mvert[i].co[2] -= normal[2]*value[i];
}
}
+ else return;
+
+ if (update_normals)
+ CDDM_calc_normals(result);
}
/*
* Apply canvas data to the object derived mesh
*/
-struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
+static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
{
DerivedMesh *result = CDDM_copy(dm);
@@ -1471,26 +1427,6 @@
}
}
}
- /* displace paint */
- else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
- MVert *mvert = result->getVertArray(result);
- int i;
- float* value = (float*)sData->type_data;
-
- #pragma omp parallel for schedule(static)
- for (i=0; i<sData->total_points; i++) {
- float normal[3];
- normal_short_to_float_v3(normal, mvert[i].no);
- normalize_v3(normal);
-
- mvert[i].co[0] -= normal[0]*value[i];
- mvert[i].co[1] -= normal[1]*value[i];
- mvert[i].co[2] -= normal[2]*value[i];
- }
-
- CDDM_calc_normals(result);
- }
-
/* vertex group paint */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
int defgrp_index = defgroup_name_index(ob, surface->output_name);
@@ -1584,9 +1520,10 @@
mvert[i].co[1] += normal[1]*wPoint[i].height;
mvert[i].co[2] += normal[2]*wPoint[i].height;
}
+ }
- CDDM_calc_normals(result);
- }
+ /* displace */
+ dynamicPaint_applySurfaceDisplace(surface, result, 1);
}
}
}
@@ -1600,6 +1537,94 @@
return result;
}
+/* update cache frame range */
+void dynamicPaint_cacheUpdateFrames(DynamicPaintSurface *surface)
+{
+ if (surface->pointcache) {
+ surface->pointcache->startframe = surface->start_frame;
+ surface->pointcache->endframe = surface->end_frame;
+ }
+}
+
+void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm)
+{
+ if (canvas->dm) canvas->dm->release(canvas->dm);
+ canvas->dm = CDDM_copy(dm);
+}
+
+/*
+* Updates derived mesh copy and processes dynamic paint step / caches.
+*/
+static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
+{
+ if(pmd->canvas) {
+ DynamicPaintCanvasSettings *canvas = pmd->canvas;
+ DynamicPaintSurface *surface = canvas->surfaces.first;
+
+ /* update derived mesh copy */
+ canvas_copyDerivedMesh(canvas, dm);
+
+ /* in case image sequence baking, stop here */
+ if (canvas->flags & MOD_DPAINT_BAKING) return;
+
+ /* loop through surfaces */
+ for (; surface; surface=surface->next) {
+ int current_frame = (int)scene->r.cfra;
+
+ /* image sequences are handled by bake operator */
+ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) continue;
+ if (!(surface->flags & MOD_DPAINT_ACTIVE)) continue;
+
+ /* make sure surface is valid */
+ dynamicPaint_checkSurfaceData(surface);
+
+ /* limit frame range */
+ CLAMP(current_frame, surface->start_frame, surface->end_frame);
+
+ if (current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
+ PointCache *cache = surface->pointcache;
+ PTCacheID pid;
+ surface->current_frame = current_frame;
+
+ /* read point cache */
+ BKE_ptcache_id_from_dynamicpaint(&pid, ob, surface);
+ pid.cache->startframe = surface->start_frame;
+ pid.cache->endframe = surface->end_frame;
+ BKE_ptcache_id_time(&pid, scene, scene->r.cfra, NULL, NULL, NULL);
+
+ /* reset non-baked cache at first frame */
+ if((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED))
+ {
+ cache->flag |= PTCACHE_REDO_NEEDED;
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+ cache->flag &= ~PTCACHE_REDO_NEEDED;
+ }
+
+ /* try to read from cache */
+ if(BKE_ptcache_read(&pid, (float)scene->r.cfra)) {
+ BKE_ptcache_validate(cache, (int)scene->r.cfra);
+ }
+ /* if read failed and we're on surface range do recalculate */
+ else if ((int)scene->r.cfra == current_frame
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list