diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-03-29 00:14:06 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-03-29 00:14:06 +0300 |
commit | 94b01931963a725b9a85a767d9bcaa25c2eb550a (patch) | |
tree | f9145a8d4c1e0b4b2590ae6ed7484306094a1981 /source/blender/render/intern | |
parent | b25c208d5bc7f77fd1176f94528d1dde8914111f (diff) |
Make point density sampling functions a bit easier for re-use
Still not ideal but getting closer. Main annoying thing so far is
dependency of Render structure for now. It is used to switch particles
to render mode and could probably also be eliminated.
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r-- | source/blender/render/intern/include/pointdensity.h | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 28 | ||||
-rw-r--r-- | source/blender/render/intern/source/render_texture.c | 2 |
3 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/render/intern/include/pointdensity.h b/source/blender/render/intern/include/pointdensity.h index e0c293e2473..1d1e808e8d3 100644 --- a/source/blender/render/intern/include/pointdensity.h +++ b/source/blender/render/intern/include/pointdensity.h @@ -37,10 +37,12 @@ * Make point density kd-trees for all point density textures in the scene */ +struct PointDensity; struct Render; struct TexResult; -void cache_pointdensity(struct Render *re, struct Tex *tex); +void free_pointdensity(struct PointDensity *pd); +void cache_pointdensity(struct Render *re, struct PointDensity *pd); void make_pointdensities(struct Render *re); void free_pointdensities(struct Render *re); int pointdensitytex(struct Tex *tex, const float texvec[3], struct TexResult *texres); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 9cda5aa97eb..320ab07dd29 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -233,13 +233,13 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa } -static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob) +static void pointdensity_cache_object(Scene *scene, PointDensity *pd, Object *ob) { int i; DerivedMesh *dm; MVert *mvert = NULL; - dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL); + dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL); mvert = dm->getVertArray(dm); /* local object space */ pd->totpoints = dm->getNumVerts(dm); @@ -274,12 +274,12 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob) dm->release(dm); } -void cache_pointdensity(Render *re, Tex *tex) -{ - PointDensity *pd = tex->pd; - if (!pd) +void cache_pointdensity(Render *re, PointDensity *pd) +{ + if (pd == NULL) { return; + } if (pd->point_tree) { BLI_bvhtree_free(pd->point_tree); @@ -304,15 +304,15 @@ void cache_pointdensity(Render *re, Tex *tex) else if (pd->source == TEX_PD_OBJECT) { Object *ob = pd->object; if (ob && ob->type == OB_MESH) - pointdensity_cache_object(re, pd, ob); + pointdensity_cache_object(re->scene, pd, ob); } } -static void free_pointdensity(Render *UNUSED(re), Tex *tex) +void free_pointdensity(PointDensity *pd) { - PointDensity *pd = tex->pd; - - if (!pd) return; + if (pd == NULL) { + return; + } if (pd->point_tree) { BLI_bvhtree_free(pd->point_tree); @@ -326,8 +326,6 @@ static void free_pointdensity(Render *UNUSED(re), Tex *tex) pd->totpoints = 0; } - - void make_pointdensities(Render *re) { Tex *tex; @@ -341,7 +339,7 @@ void make_pointdensities(Render *re) for (tex = re->main->tex.first; tex != NULL; tex = tex->id.next) { if (tex->id.us && tex->type == TEX_POINTDENSITY) { - cache_pointdensity(re, tex); + cache_pointdensity(re, tex->pd); } } @@ -358,7 +356,7 @@ void free_pointdensities(Render *re) for (tex = re->main->tex.first; tex != NULL; tex = tex->id.next) { if (tex->id.us && tex->type == TEX_POINTDENSITY) { - free_pointdensity(re, tex); + free_pointdensity(tex->pd); } } } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index df4553978a3..dc8c714bea5 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -3631,7 +3631,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) unit_m4(dummy_re.viewmat); unit_m4(dummy_re.winmat); dummy_re.winx = dummy_re.winy = 128; - cache_pointdensity(&dummy_re, tex); + cache_pointdensity(&dummy_re, tex->pd); } /* update image sequences and movies */ |