Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/effect.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "BLI_noise.h" | #include "BLI_noise.h" | ||||
| #include "BLI_rand.h" | #include "BLI_rand.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| #include "PIL_time.h" | #include "PIL_time.h" | ||||
| #include "BKE_anim.h" /* needed for where_on_path */ | #include "BKE_anim.h" /* needed for where_on_path */ | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_collision.h" | #include "BKE_collision.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_displist.h" | #include "BKE_displist.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_cdderivedmesh.h" | #include "BKE_cdderivedmesh.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_smoke.h" | #include "BKE_smoke.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "RE_render_ext.h" | #include "RE_render_ext.h" | ||||
| #include "RE_shader_ext.h" | #include "RE_shader_ext.h" | ||||
| /* fluid sim particle import */ | /* fluid sim particle import */ | ||||
| #ifdef WITH_MOD_FLUID | #ifdef WITH_MOD_FLUID | ||||
| #include "LBM_fluidsim.h" | #include "LBM_fluidsim.h" | ||||
| #include <zlib.h> | #include <zlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #endif // WITH_MOD_FLUID | #endif // WITH_MOD_FLUID | ||||
| EffectorWeights *BKE_add_effector_weights(Group *group) | EffectorWeights *BKE_add_effector_weights(Collection *collection) | ||||
| { | { | ||||
| EffectorWeights *weights = MEM_callocN(sizeof(EffectorWeights), "EffectorWeights"); | EffectorWeights *weights = MEM_callocN(sizeof(EffectorWeights), "EffectorWeights"); | ||||
| int i; | int i; | ||||
| for (i=0; i<NUM_PFIELD_TYPES; i++) | for (i=0; i<NUM_PFIELD_TYPES; i++) | ||||
| weights->weight[i] = 1.0f; | weights->weight[i] = 1.0f; | ||||
| weights->global_gravity = 1.0f; | weights->global_gravity = 1.0f; | ||||
| weights->group = group; | weights->group = collection; | ||||
| return weights; | return weights; | ||||
| } | } | ||||
| PartDeflect *object_add_collision_fields(int type) | PartDeflect *object_add_collision_fields(int type) | ||||
| { | { | ||||
| PartDeflect *pd; | PartDeflect *pd; | ||||
| pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect"); | pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect"); | ||||
| ▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | static void add_particles_to_effectors(ListBase **effectors, struct Depsgraph *depsgraph, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation) | ||||
| } | } | ||||
| } | } | ||||
| /* returns ListBase handle with objects taking part in the effecting */ | /* returns ListBase handle with objects taking part in the effecting */ | ||||
| ListBase *pdInitEffectors( | ListBase *pdInitEffectors( | ||||
| struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, ParticleSystem *psys_src, | struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, ParticleSystem *psys_src, | ||||
| EffectorWeights *weights, bool for_simulation) | EffectorWeights *weights, bool for_simulation) | ||||
| { | { | ||||
| ViewLayer *view_layer; | Base *base = BKE_collection_or_layer_objects(depsgraph, scene, NULL, weights->group); | ||||
| Base *base; | |||||
| ListBase *effectors = NULL; | ListBase *effectors = NULL; | ||||
| if (weights->group) { | for (; base; base = base->next) { | ||||
| view_layer = weights->group->view_layer; | |||||
| } | |||||
| /* TODO(mai): the check for view_layer shouldnt be needed, remove when render engine api is updated for this */ | |||||
| else if (depsgraph && DEG_get_evaluated_view_layer(depsgraph)) { | |||||
| view_layer = DEG_get_evaluated_view_layer(depsgraph); | |||||
| } | |||||
| else { | |||||
| /* depsgraph is NULL during deg build */ | |||||
| view_layer = BKE_view_layer_context_active_PLACEHOLDER(scene); | |||||
| } | |||||
| for (base = FIRSTBASE(view_layer); base; base = base->next) { | |||||
| if ((base->flag & BASE_VISIBLED) == 0) { | if ((base->flag & BASE_VISIBLED) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (base->object->pd && base->object->pd->forcefield) { | if (base->object->pd && base->object->pd->forcefield) { | ||||
| add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation); | add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 976 Lines • Show Last 20 Lines | |||||