diff options
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b158633294e..674f264feb7 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -500,6 +500,7 @@ IDTypeInfo IDType_ID_PA = { .name_plural = "particles", .translation_context = BLT_I18NCONTEXT_ID_PARTICLESETTINGS, .flags = 0, + .asset_type_info = NULL, .init_data = particle_settings_init, .copy_data = particle_settings_copy_data, @@ -507,6 +508,7 @@ IDTypeInfo IDType_ID_PA = { .make_local = NULL, .foreach_id = particle_settings_foreach_id, .foreach_cache = NULL, + .foreach_path = NULL, .owner_get = NULL, .blend_write = particle_settings_blend_write, @@ -554,7 +556,6 @@ static void get_cpa_texture(Mesh *mesh, int event, float cfra); -/* few helpers for countall etc. */ int count_particles(ParticleSystem *psys) { ParticleSettings *part = psys->part; @@ -644,7 +645,7 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf /************************************************/ /* Getting stuff */ /************************************************/ -/* get object's active particle system safely */ + ParticleSystem *psys_get_current(Object *ob) { ParticleSystem *psys; @@ -912,9 +913,11 @@ int psys_uses_gravity(ParticleSimulationData *sim) return sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY && sim->psys->part && sim->psys->part->effector_weights->global_gravity != 0.0f; } + /************************************************/ /* Freeing stuff */ /************************************************/ + static void fluid_free_settings(SPHFluidSettings *fluid) { if (fluid) { @@ -1054,7 +1057,6 @@ void psys_free_pdd(ParticleSystem *psys) psys->pdd->partsize = 0; } } -/* free everything */ void psys_free(Object *ob, ParticleSystem *psys) { if (psys) { @@ -1202,6 +1204,7 @@ void psys_copy_particles(ParticleSystem *psys_dst, ParticleSystem *psys_src) /************************************************/ /* Interpolation */ /************************************************/ + static float interpolate_particle_value( float v1, float v2, float v3, float v4, const float w[4], int four) { @@ -1669,7 +1672,7 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach /************************************************/ /* Particles on a dm */ /************************************************/ -/* interpolate a location on a face based on face coordinates */ + void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, @@ -1901,18 +1904,6 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4 } } -/** - * Find the final derived mesh tessface for a particle, from its original tessface index. - * This is slow and can be optimized but only for many lookups. - * - * \param mesh_final: Final mesh, it may not have the same topology as original mesh. - * \param mesh_original: Original mesh, use for accessing #MPoly to #MFace mapping. - * \param findex_orig: The input tessface index. - * \param fw: Face weights (position of the particle inside the \a findex_orig tessface). - * \param poly_nodes: May be NULL, otherwise an array of linked list, - * one for each final \a mesh_final polygon, containing all its tessfaces indices. - * \return The \a mesh_final tessface index. - */ int psys_particle_dm_face_lookup(Mesh *mesh_final, Mesh *mesh_original, int findex_orig, @@ -2094,7 +2085,6 @@ static int psys_map_index_on_dm(Mesh *mesh, return 1; } -/* interprets particle data to get a point on a mesh in object space */ void psys_particle_on_dm(Mesh *mesh_final, int from, int index, @@ -2216,9 +2206,11 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) } return NULL; } + /************************************************/ /* Particles on a shape */ /************************************************/ + /* ready for future use */ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), @@ -2247,6 +2239,7 @@ static void psys_particle_on_shape(int UNUSED(distr), copy_v3_v3(orco, zerovec); } } + /************************************************/ /* Particles on emitter */ /************************************************/ @@ -2321,6 +2314,7 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, psys_particle_on_shape(from, index, fuv, vec, nor, utan, vtan, orco); } } + /************************************************/ /* Path Cache */ /************************************************/ @@ -3273,11 +3267,6 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, } } -/** - * Calculates paths ready for drawing/rendering - * - Useful for making use of opengl vertex arrays for super fast strand drawing. - * - Makes child strands possible and creates them too into the cache. - * - Cached path data is also used to determine cut position for the editmode tool. */ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_render_params) { PARTICLE_PSMD; @@ -3760,9 +3749,11 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, } } } + /************************************************/ /* Particle Key handling */ /************************************************/ + void copy_particle_key(ParticleKey *to, ParticleKey *from, int time) { if (time) { @@ -3922,6 +3913,7 @@ void psys_mat_hair_to_global( /************************************************/ /* ParticleSettings handling */ /************************************************/ + static ModifierData *object_add_or_copy_particle_system( Main *bmain, Scene *scene, Object *ob, const char *name, const ParticleSystem *psys_orig) { @@ -4458,9 +4450,11 @@ void psys_get_texture( CLAMP_WARP_PARTICLE_TEXTURE_POS(PAMAP_DAMP, ptex->damp); CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length); } + /************************************************/ /* Particle State */ /************************************************/ + float psys_get_timestep(ParticleSimulationData *sim) { return 0.04f * sim->psys->part->timetweak; @@ -4586,7 +4580,6 @@ static void get_child_modifier_parameters(ParticleSettings *part, ctx->mesh, cpa_from, cpa_num, cpa_fuv, ctx->vg_twist); } } -/* gets hair (or keyed) particles state at the "path time" specified in state->time */ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *state, @@ -4855,8 +4848,10 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, } } } -/* gets particle's state at a time, returns 1 if particle exists and can be seen and 0 if not */ -int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *state, int always) +bool psys_get_particle_state(ParticleSimulationData *sim, + int p, + ParticleKey *state, + const bool always) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; @@ -4871,12 +4866,12 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta if (p >= totpart) { if (!psys->totchild) { - return 0; + return false; } if (part->childtype == PART_CHILD_FACES) { if (!(psys->flag & PSYS_KEYED)) { - return 0; + return false; } cpa = psys->child + p - totpart; @@ -4886,7 +4881,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta if (!always) { if ((state->time < 0.0f && !(part->flag & PART_UNBORN)) || (state->time > 1.0f && !(part->flag & PART_DIED))) { - return 0; + return false; } } @@ -4894,7 +4889,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta (part->lifetime * psys_frand(psys, p + 24)); psys_get_particle_on_path(sim, p, state, 1); - return 1; + return true; } cpa = sim->psys->child + p - totpart; @@ -4908,7 +4903,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta if (!always) { if ((cfra < pa->time && (part->flag & PART_UNBORN) == 0) || (cfra >= pa->dietime && (part->flag & PART_DIED) == 0)) { - return 0; + return false; } } @@ -4918,7 +4913,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta if (sim->psys->flag & PSYS_KEYED) { state->time = -cfra; psys_get_particle_on_path(sim, p, state, 1); - return 1; + return true; } if (cpa) { @@ -5018,7 +5013,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } } - return 1; + return true; } void psys_get_dupli_texture(ParticleSystem *psys, |