diff options
author | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2013-01-29 16:32:43 +0400 |
---|---|---|
committer | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2013-01-29 16:32:43 +0400 |
commit | 6d2f104884f706b0358a9f6393e32cdc0430adac (patch) | |
tree | 885b900707b6eea4e04048a9c1a06a6d04d37242 /source/blender/makesrna | |
parent | 1a750e00e72c06fc3acf883c436dc147d0626e52 (diff) |
Cycles Hair: Addition of render settings and static BVH strand width scaling
Addition of a RNA function to toggle between the hair settings and rebuild the cache. This enables the usage of the render step, child number and full display percentage with f12 rendering.
A scaling to the strand radius has also been added for the static bvh. This only matches up with dynamic for uniform scaling.
A very small fix is included for multiple uvs/vertex colours when using child particles.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index bd3e4e6862d..a872ace6ae3 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -299,6 +299,7 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o int path_nbr = 0; int totpart; int max_k = 0; + int step_nbr = 0; if (particlesystem == NULL) return; @@ -306,14 +307,21 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o part = particlesystem->part; pars = particlesystem->particles; + if(particlesystem->renderdata) { + step_nbr = part->ren_step; + totchild = particlesystem->totchild; + } + else { + step_nbr = part->draw_step; + totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f); + } + if (part == NULL || pars == NULL || !psys_check_enabled(object, particlesystem)) return; if (part->ren_as == PART_DRAW_OB || part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_NOT) return; - totchild = particlesystem->totchild * part->disp / 100; - /* can happen for disconnected/global hair */ if (part->type == PART_HAIR && !particlesystem->childcache) totchild = 0; @@ -324,7 +332,7 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o return; if (part->ren_as == PART_DRAW_PATH && particlesystem->pathcache) - path_nbr = (int)pow(2.0, part->draw_step); + path_nbr = (int)pow(2.0, step_nbr); if (particle_no < totpart) { @@ -373,7 +381,10 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Par part = particlesystem->part; + if(particlesystem->renderdata) totchild = particlesystem->totchild; + else + totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f); /* can happen for disconnected/global hair */ if (part->type == PART_HAIR && !particlesystem->childcache) @@ -419,7 +430,7 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Par if (n_uv && ELEM(PART_FROM_FACE, PART_FROM_FACE, PART_FROM_VOLUME)) { if (cpa->num != DMCACHE_NOTFOUND) { MFace *mface = modifier->dm->getTessFaceData(modifier->dm, cpa->num, CD_MFACE); - MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, 0); + MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, uv_no); mtface += cpa->num; psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, n_uv); @@ -441,7 +452,7 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Par if (n_uv && ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) { if (num != DMCACHE_NOTFOUND) { MFace *mface = modifier->dm->getTessFaceData(modifier->dm, num, CD_MFACE); - MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, 0); + MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, uv_no); mtface += num; psys_interpolate_uvs(mtface, mface->v4, parent->fuv, n_uv); @@ -470,7 +481,10 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P part = particlesystem->part; + if(particlesystem->renderdata) totchild = particlesystem->totchild; + else + totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f); /* can happen for disconnected/global hair */ if (part->type == PART_HAIR && !particlesystem->childcache) @@ -520,7 +534,7 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P if (n_mcol && ELEM(PART_FROM_FACE, PART_FROM_FACE, PART_FROM_VOLUME)) { if (cpa->num != DMCACHE_NOTFOUND) { MFace *mface = modifier->dm->getTessFaceData(modifier->dm, cpa->num, CD_MFACE); - MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, 0); + MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, vcol_no); mc += cpa->num * 4; psys_interpolate_mcol(mc, mface->v4, cpa->fuv, &mcol); @@ -546,7 +560,7 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P if (n_mcol && ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) { if (num != DMCACHE_NOTFOUND) { MFace *mface = modifier->dm->getTessFaceData(modifier->dm, num, CD_MFACE); - MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, 0); + MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, vcol_no); mc += num * 4; psys_interpolate_mcol(mc, mface->v4, parent->fuv, &mcol); @@ -564,6 +578,22 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P } } +static void rna_ParticleSystem_ToggleRender(ParticleSystem *particlesystem, Scene *scene, Object *object) +{ + ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem); + float mat[4][4]; + + unit_m4(mat); + + if (particlesystem->renderdata) + psys_render_restore(object, particlesystem); + else { + psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f); + psmd->flag &= ~eParticleSystemFlag_psys_updated; + particle_system_update(scene, object, particlesystem); + } +} + static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag) { if (ptr->type == &RNA_ParticleSystem) { @@ -3345,6 +3375,12 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_ParticleSystem_path"); + /* Toggle Render settings */ + func = RNA_def_function(srna, "ToggleRender", "rna_ParticleSystem_ToggleRender"); + RNA_def_function_ui_description(func, "Toggle render settings"); + prop = RNA_def_pointer(func, "scene", "Scene", "", "Scene"); + prop = RNA_def_pointer(func, "object", "Object", "", "Object"); + /* extract cached hair location data */ func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair"); RNA_def_function_ui_description(func, "Obtain cache hair data"); |