Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/effect.c
| Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd) | ||||
| EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache"); | EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache"); | ||||
| eff->scene = scene; | eff->scene = scene; | ||||
| eff->ob = ob; | eff->ob = ob; | ||||
| eff->psys = psys; | eff->psys = psys; | ||||
| eff->pd = pd; | eff->pd = pd; | ||||
| eff->frame = -1; | eff->frame = -1; | ||||
| return eff; | return eff; | ||||
| } | } | ||||
| static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src) | static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation) | ||||
| { | { | ||||
| EffectorCache *eff = NULL; | EffectorCache *eff = NULL; | ||||
| if ( ob == ob_src || weights->weight[ob->pd->forcefield] == 0.0f ) | if ( ob == ob_src ) | ||||
| return; | |||||
| if (for_simulation) { | |||||
| if (weights->weight[ob->pd->forcefield] == 0.0f ) | |||||
| return; | return; | ||||
| if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal ) | if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal ) | ||||
| return; | return; | ||||
| } | |||||
| if (*effectors == NULL) | if (*effectors == NULL) | ||||
| *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); | *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); | ||||
| eff = new_effector_cache(scene, ob, NULL, ob->pd); | eff = new_effector_cache(scene, ob, NULL, ob->pd); | ||||
| /* make sure imat is up to date */ | /* make sure imat is up to date */ | ||||
| invert_m4_m4(ob->imat, ob->obmat); | invert_m4_m4(ob->imat, ob->obmat); | ||||
| BLI_addtail(*effectors, eff); | BLI_addtail(*effectors, eff); | ||||
| } | } | ||||
| static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src) | static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation) | ||||
| { | { | ||||
| ParticleSettings *part= psys->part; | ParticleSettings *part= psys->part; | ||||
| if ( !psys_check_enabled(ob, psys, G.is_rendering) ) | if ( !psys_check_enabled(ob, psys, G.is_rendering) ) | ||||
| return; | return; | ||||
| if ( psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0) | if ( psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0) | ||||
| return; | return; | ||||
| if ( part->pd && part->pd->forcefield && weights->weight[part->pd->forcefield] != 0.0f) { | if ( part->pd && part->pd->forcefield && (!for_simulation || weights->weight[part->pd->forcefield] != 0.0f)) { | ||||
| if (*effectors == NULL) | if (*effectors == NULL) | ||||
| *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); | *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); | ||||
| BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd)); | BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd)); | ||||
| } | } | ||||
| if (part->pd2 && part->pd2->forcefield && weights->weight[part->pd2->forcefield] != 0.0f) { | if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) { | ||||
| if (*effectors == NULL) | if (*effectors == NULL) | ||||
| *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); | *effectors = MEM_callocN(sizeof(ListBase), "effectors list"); | ||||
| BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2)); | BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2)); | ||||
| } | } | ||||
| } | } | ||||
| /* returns ListBase handle with objects taking part in the effecting */ | /* returns ListBase handle with objects taking part in the effecting */ | ||||
| ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src, | ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src, | ||||
| EffectorWeights *weights, bool precalc) | EffectorWeights *weights, bool for_simulation) | ||||
| { | { | ||||
| Base *base; | Base *base; | ||||
| unsigned int layer= ob_src->lay; | unsigned int layer= ob_src->lay; | ||||
| ListBase *effectors = NULL; | ListBase *effectors = NULL; | ||||
| if (weights->group) { | if (weights->group) { | ||||
| GroupObject *go; | GroupObject *go; | ||||
| for (go= weights->group->gobject.first; go; go= go->next) { | for (go= weights->group->gobject.first; go; go= go->next) { | ||||
| if ( (go->ob->lay & layer) ) { | if ( (go->ob->lay & layer) ) { | ||||
| if ( go->ob->pd && go->ob->pd->forcefield ) | if ( go->ob->pd && go->ob->pd->forcefield ) | ||||
| add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src); | add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src, for_simulation); | ||||
| if ( go->ob->particlesystem.first ) { | if ( go->ob->particlesystem.first ) { | ||||
| ParticleSystem *psys= go->ob->particlesystem.first; | ParticleSystem *psys= go->ob->particlesystem.first; | ||||
| for ( ; psys; psys=psys->next ) | for ( ; psys; psys=psys->next ) | ||||
| add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src); | add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src, for_simulation); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (base = scene->base.first; base; base= base->next) { | for (base = scene->base.first; base; base= base->next) { | ||||
| if ( (base->lay & layer) ) { | if ( (base->lay & layer) ) { | ||||
| if ( base->object->pd && base->object->pd->forcefield ) | if ( base->object->pd && base->object->pd->forcefield ) | ||||
| add_object_to_effectors(&effectors, scene, weights, base->object, ob_src); | add_object_to_effectors(&effectors, scene, weights, base->object, ob_src, for_simulation); | ||||
| if ( base->object->particlesystem.first ) { | if ( base->object->particlesystem.first ) { | ||||
| ParticleSystem *psys= base->object->particlesystem.first; | ParticleSystem *psys= base->object->particlesystem.first; | ||||
| for ( ; psys; psys=psys->next ) | for ( ; psys; psys=psys->next ) | ||||
| add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src); | add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src, for_simulation); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (precalc) | if (for_simulation) | ||||
| pdPrecalculateEffectors(effectors); | pdPrecalculateEffectors(effectors); | ||||
| return effectors; | return effectors; | ||||
| } | } | ||||
| void pdEndEffectors(ListBase **effectors) | void pdEndEffectors(ListBase **effectors) | ||||
| { | { | ||||
| if (*effectors) { | if (*effectors) { | ||||
| ▲ Show 20 Lines • Show All 935 Lines • Show Last 20 Lines | |||||