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.
This commit is contained in:
parent
b25c208d5b
commit
94b0193196
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user