[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36399] trunk/blender: =trunk=
Joseph Eagar
joeedh at gmail.com
Sun May 1 05:57:54 CEST 2011
Revision: 36399
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36399
Author: joeedh
Date: 2011-05-01 03:57:53 +0000 (Sun, 01 May 2011)
Log Message:
-----------
=trunk=
Made some improvements to the point density texture. Added support
for tweaking the falloff with a custom curve. Also coded new
falloff types based on the age or velocity of particles.
Also added a test break check to the volumetric shade cache code,
to avoid nasty hangups from the preview render (on render, exit,
etc).
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
trunk/blender/source/blender/blenkernel/intern/texture.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/blenloader/intern/writefile.c
trunk/blender/source/blender/makesdna/DNA_texture_types.h
trunk/blender/source/blender/makesrna/intern/rna_texture.c
trunk/blender/source/blender/render/intern/include/render_types.h
trunk/blender/source/blender/render/intern/source/pointdensity.c
trunk/blender/source/blender/render/intern/source/volume_precache.c
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_texture.py 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_texture.py 2011-05-01 03:57:53 UTC (rev 36399)
@@ -721,6 +721,15 @@
col.prop(pd, "falloff", text="")
if pd.falloff == 'SOFT':
col.prop(pd, "falloff_soft")
+ if pd.falloff == "PARTICLE_VELOCITY":
+ col.prop(pd, "falloff_speed_scale")
+
+ col.prop(pd, "use_falloff_curve")
+
+ if pd.use_falloff_curve:
+ col = layout.column()
+ col.label(text="Falloff Curve")
+ col.template_curve_mapping(pd, "falloff_curve", brush=False)
class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel):
Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c 2011-05-01 03:57:53 UTC (rev 36399)
@@ -73,8 +73,8 @@
#include "BKE_icons.h"
#include "BKE_node.h"
#include "BKE_animsys.h"
+#include "BKE_colortools.h"
-
/* ------------------------------------------------------------------------- */
/* All support for plugin textures: */
@@ -1367,6 +1367,13 @@
pd->object = NULL;
pd->psys = 0;
pd->psys_cache_space= TEX_PD_WORLDSPACE;
+ pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
+
+ pd->falloff_curve->preset = CURVE_PRESET_LINE;
+ pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+ curvemap_reset(pd->falloff_curve->cm, &pd->falloff_curve->clipr, pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
+ curvemapping_changed(pd->falloff_curve, 0);
+
return pd;
}
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2011-05-01 03:57:53 UTC (rev 36399)
@@ -2963,6 +2963,21 @@
if(tex->pd) {
tex->pd->point_tree = NULL;
tex->pd->coba= newdataadr(fd, tex->pd->coba);
+ tex->pd->falloff_curve= newdataadr(fd, tex->pd->falloff_curve);
+
+ /*hack to avoid a do_versions patch*/
+ if (tex->pd->falloff_speed_scale == 0.0)
+ tex->pd->falloff_speed_scale = 100.0;
+
+ if (!tex->pd->falloff_curve) {
+ tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
+
+ tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
+ tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+ curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
+ curvemapping_changed(tex->pd->falloff_curve, 0);
+ } else
+ direct_link_curvemapping(fd, tex->pd->falloff_curve);
}
tex->vd= newdataadr(fd, tex->vd);
Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c 2011-05-01 03:57:53 UTC (rev 36399)
@@ -1698,6 +1698,7 @@
if(tex->type == TEX_POINTDENSITY && tex->pd) {
writestruct(wd, DATA, "PointDensity", 1, tex->pd);
if(tex->pd->coba) writestruct(wd, DATA, "ColorBand", 1, tex->pd->coba);
+ if(tex->pd->falloff_curve) write_curvemapping(wd, tex->pd->falloff_curve);
}
if(tex->type == TEX_VOXELDATA && tex->vd) writestruct(wd, DATA, "VoxelData", 1, tex->vd);
Modified: trunk/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_texture_types.h 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/makesdna/DNA_texture_types.h 2011-05-01 03:57:53 UTC (rev 36399)
@@ -52,6 +52,7 @@
struct Image;
struct PreviewImage;
struct ImBuf;
+struct CurveMapping;
typedef struct MTex {
@@ -181,9 +182,10 @@
short pdpad3[3];
float noise_fac;
- float speed_scale;
+ float speed_scale, falloff_speed_scale, pdpad2;
struct ColorBand *coba; /* for time -> color */
+ struct CurveMapping *falloff_curve; /* falloff density curve */
} PointDensity;
typedef struct VoxelData {
@@ -517,6 +519,8 @@
#define TEX_PD_FALLOFF_SOFT 2
#define TEX_PD_FALLOFF_CONSTANT 3
#define TEX_PD_FALLOFF_ROOT 4
+#define TEX_PD_FALLOFF_PARTICLE_AGE 5
+#define TEX_PD_FALLOFF_PARTICLE_VEL 6
/* psys_cache_space */
#define TEX_PD_OBJECTLOC 0
@@ -524,9 +528,9 @@
#define TEX_PD_WORLDSPACE 2
/* flag */
-#define TEX_PD_TURBULENCE 1
+#define TEX_PD_TURBULENCE 1
+#define TEX_PD_FALLOFF_CURVE 2
-
/* noise_influence */
#define TEX_PD_NOISE_STATIC 0
#define TEX_PD_NOISE_VEL 1
Modified: trunk/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture.c 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture.c 2011-05-01 03:57:53 UTC (rev 36399)
@@ -1427,6 +1427,8 @@
{TEX_PD_FALLOFF_SOFT, "SOFT", 0, "Soft", ""},
{TEX_PD_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", "Density is constant within lookup radius"},
{TEX_PD_FALLOFF_ROOT, "ROOT", 0, "Root", ""},
+ {TEX_PD_FALLOFF_PARTICLE_AGE, "PARTICLE_AGE", 0, "Particle Age", ""},
+ {TEX_PD_FALLOFF_PARTICLE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem color_source_items[] = {
@@ -1509,12 +1511,30 @@
RNA_def_property_ui_text(prop, "Scale", "Multiplier to bring particle speed within an acceptable range");
RNA_def_property_update(prop, 0, "rna_Texture_update");
+ prop= RNA_def_property(srna, "falloff_speed_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "falloff_speed_scale");
+ RNA_def_property_range(prop, 0.001, 100.0);
+ RNA_def_property_ui_text(prop, "Velocity Scale", "Multiplier to bring particle speed within an acceptable range");
+ RNA_def_property_update(prop, 0, "rna_Texture_update");
+
+
prop= RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "coba");
RNA_def_property_struct_type(prop, "ColorRamp");
RNA_def_property_ui_text(prop, "Color Ramp", "");
RNA_def_property_update(prop, 0, "rna_Texture_update");
+
+ prop= RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "falloff_curve");
+ RNA_def_property_struct_type(prop, "CurveMapping");
+ RNA_def_property_ui_text(prop, "Falloff Curve", "");
+ RNA_def_property_update(prop, 0, "rna_Texture_update");
+ prop= RNA_def_property(srna, "use_falloff_curve", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_FALLOFF_CURVE);
+ RNA_def_property_ui_text(prop, "Falloff Curve", "Use a custom falloff curve");
+ RNA_def_property_update(prop, 0, "rna_Texture_update");
+
/* Turbulence */
prop= RNA_def_property(srna, "use_turbulence", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_TURBULENCE);
Modified: trunk/blender/source/blender/render/intern/include/render_types.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/render_types.h 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/render/intern/include/render_types.h 2011-05-01 03:57:53 UTC (rev 36399)
@@ -486,6 +486,7 @@
float bbmin[3];
float voxel[3];
int working, done;
+ struct Render *re;
} VolPrecachePart;
typedef struct VolumePrecache
Modified: trunk/blender/source/blender/render/intern/source/pointdensity.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pointdensity.c 2011-05-01 00:23:08 UTC (rev 36398)
+++ trunk/blender/source/blender/render/intern/source/pointdensity.c 2011-05-01 03:57:53 UTC (rev 36399)
@@ -47,6 +47,7 @@
#include "BKE_particle.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
+#include "BKE_colortools.h"
#include "DNA_meshdata_types.h"
#include "DNA_texture_types.h"
@@ -69,9 +70,9 @@
int pd_bitflag = 0;
if (pd->source == TEX_PD_PSYS) {
- if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED))
+ if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED))
pd_bitflag |= POINT_DATA_VEL;
- if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE))
+ if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE) || (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE))
pd_bitflag |= POINT_DATA_LIFE;
}
@@ -180,6 +181,7 @@
}
pd->point_data[offset + i] = pa_time;
+
}
}
}
@@ -331,6 +333,8 @@
float *age;
int point_data_used;
int offset;
+ struct CurveMapping *density_curve;
+ float velscale;
} PointDensityRangeData;
static void accum_density(void *userdata, int index, float squared_dist)
@@ -339,6 +343,15 @@
const float dist = (pdr->squared_radius - squared_dist) / pdr->squared_radius * 0.5f;
float density = 0.0f;
+ if (pdr->point_data_used & POINT_DATA_VEL) {
+ pdr->vec[0] += pdr->point_data[index*3 + 0]; //* density;
+ pdr->vec[1] += pdr->point_data[index*3 + 1]; //* density;
+ pdr->vec[2] += pdr->point_data[index*3 + 2]; //* density;
+ }
+ if (pdr->point_data_used & POINT_DATA_LIFE) {
+ *pdr->age += pdr->point_data[pdr->offset + index]; // * density;
+ }
+
if (pdr->falloff_type == TEX_PD_FALLOFF_STD)
density = dist;
else if (pdr->falloff_type == TEX_PD_FALLOFF_SMOOTH)
@@ -349,21 +362,21 @@
density = pdr->squared_radius;
else if (pdr->falloff_type == TEX_PD_FALLOFF_ROOT)
density = sqrt(dist);
+ else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list