Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-06-21 12:49:43 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-06-21 13:09:45 +0300
commit7070e4c15e6c57da2bd46534e654ed5f9a1e6600 (patch)
tree221ceb5195fd6d98d4485db40e78d16a379107c5 /source/blender/modifiers
parent964e319a39abfe3808fded71dcacd296401ec04d (diff)
Revert "Particle system: Move runtime data to runtime field"
This reverts commit 36faf739a71624b6ca10cec7233779f9eeace0bd. Somewhat annoying but this change had some unforeseen consequences, which lead to an actual bug. Since this change was not sufficient to get original report fixed is easier to simply revert for now. Fixes T65842: Hair disappears when clicking on particle system name
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c2
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c6
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c100
3 files changed, 56 insertions, 52 deletions
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 9b1586f4982..4ed787810a8 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -1125,7 +1125,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (psys->part == NULL || psys->particles == NULL) {
return mesh;
}
- if (BKE_particle_modifier_mesh_final_get(psmd) == NULL) {
+ if (psmd->mesh_final == NULL) {
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 651feb836cc..71913378277 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -415,11 +415,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
ChildParticle *cpa = psys->child + (p - psys->totpart);
pa = psys->particles + (between ? cpa->pa[0] : cpa->parent);
}
- psys_mat_hair_to_global(sim.ob,
- BKE_particle_modifier_mesh_final_get(sim.psmd),
- sim.psys->part->from,
- pa,
- hairmat);
+ psys_mat_hair_to_global(sim.ob, sim.psmd->mesh_final, sim.psys->part->from, pa, hairmat);
copy_m3_m4(mat, hairmat);
/* to quaternion */
mat3_to_quat(frame, mat);
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 02d477b1bde..5d7b380a751 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -23,8 +23,6 @@
#include <stddef.h>
-#include "MEM_guardedalloc.h"
-
#include "BLI_utildefines.h"
#include "DNA_material_types.h"
@@ -44,27 +42,24 @@ static void initData(ModifierData *md)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
psmd->psys = NULL;
+ psmd->mesh_final = NULL;
+ psmd->mesh_original = NULL;
+ psmd->totdmvert = psmd->totdmedge = psmd->totdmface = 0;
}
-
-static void freeRuntimeData(void *runtime_data_v)
-{
- if (runtime_data_v == NULL) {
- return;
- }
- ParticleSystemModifierDataRuntime *runtime_data = runtime_data_v;
- if (runtime_data->mesh_final) {
- BKE_id_free(NULL, runtime_data->mesh_final);
- }
- if (runtime_data->mesh_original) {
- BKE_id_free(NULL, runtime_data->mesh_original);
- }
- MEM_freeN(runtime_data);
-}
-
static void freeData(ModifierData *md)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
- freeRuntimeData(md->runtime);
+
+ if (psmd->mesh_final) {
+ BKE_id_free(NULL, psmd->mesh_final);
+ psmd->mesh_final = NULL;
+ if (psmd->mesh_original) {
+ BKE_id_free(NULL, psmd->mesh_original);
+ psmd->mesh_original = NULL;
+ }
+ }
+ psmd->totdmvert = psmd->totdmedge = psmd->totdmface = 0;
+
/* ED_object_modifier_remove may have freed this first before calling
* modifier_free (which calls this function) */
if (psmd->psys) {
@@ -72,6 +67,20 @@ static void freeData(ModifierData *md)
}
}
+static void copyData(const ModifierData *md, ModifierData *target, const int flag)
+{
+#if 0
+ const ParticleSystemModifierData *psmd = (const ParticleSystemModifierData *)md;
+#endif
+ ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *)target;
+
+ modifier_copyData_generic(md, target, flag);
+
+ tpsmd->mesh_final = NULL;
+ tpsmd->mesh_original = NULL;
+ tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0;
+}
+
static void requiredDataMask(Object *UNUSED(ob),
ModifierData *md,
CustomData_MeshMasks *r_cddata_masks)
@@ -111,16 +120,14 @@ static void deformVerts(ModifierData *md,
}
}
- ParticleSystemModifierDataRuntime *runtime = BKE_particle_modifier_runtime_ensure(psmd);
-
/* clear old dm */
- bool had_mesh_final = (runtime->mesh_final != NULL);
- if (runtime->mesh_final) {
- BKE_id_free(NULL, runtime->mesh_final);
- runtime->mesh_final = NULL;
- if (runtime->mesh_original) {
- BKE_id_free(NULL, runtime->mesh_original);
- runtime->mesh_original = NULL;
+ bool had_mesh_final = (psmd->mesh_final != NULL);
+ if (psmd->mesh_final) {
+ BKE_id_free(NULL, psmd->mesh_final);
+ psmd->mesh_final = NULL;
+ if (psmd->mesh_original) {
+ BKE_id_free(NULL, psmd->mesh_original);
+ psmd->mesh_original = NULL;
}
}
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
@@ -136,13 +143,13 @@ static void deformVerts(ModifierData *md,
}
/* make new mesh */
- runtime->mesh_final = BKE_mesh_copy_for_eval(mesh_src, false);
- BKE_mesh_apply_vert_coords(runtime->mesh_final, vertexCos);
- BKE_mesh_calc_normals(runtime->mesh_final);
+ psmd->mesh_final = BKE_mesh_copy_for_eval(mesh_src, false);
+ BKE_mesh_apply_vert_coords(psmd->mesh_final, vertexCos);
+ BKE_mesh_calc_normals(psmd->mesh_final);
- BKE_mesh_tessface_ensure(runtime->mesh_final);
+ BKE_mesh_tessface_ensure(psmd->mesh_final);
- if (!runtime->mesh_final->runtime.deformed_only) {
+ if (!psmd->mesh_final->runtime.deformed_only) {
/* Get the original mesh from the object, this is what the particles
* are attached to so in case of non-deform modifiers we need to remap
* them to the final mesh (typically subdivision surfaces). */
@@ -153,7 +160,7 @@ static void deformVerts(ModifierData *md,
if (em) {
/* In edit mode get directly from the edit mesh. */
- runtime->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
+ psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
/* Otherwise get regular mesh. */
@@ -168,13 +175,13 @@ static void deformVerts(ModifierData *md,
/* Make a persistent copy of the mesh. We don't actually need
* all this data, just some topology for remapping. Could be
* optimized once. */
- runtime->mesh_original = BKE_mesh_copy_for_eval(mesh_original, false);
+ psmd->mesh_original = BKE_mesh_copy_for_eval(mesh_original, false);
}
- BKE_mesh_tessface_ensure(runtime->mesh_original);
+ BKE_mesh_tessface_ensure(psmd->mesh_original);
}
- if (mesh_src != runtime->mesh_final && mesh_src != mesh) {
+ if (mesh_src != psmd->mesh_final && mesh_src != mesh) {
BKE_id_free(NULL, mesh_src);
}
@@ -182,13 +189,13 @@ static void deformVerts(ModifierData *md,
* This is an unreliable check for the topology check, but allows some
* handy configuration like emitting particles from inside particle
* instance. */
- if (had_mesh_final && (runtime->mesh_final->totvert != runtime->totdmvert ||
- runtime->mesh_final->totedge != runtime->totdmedge ||
- runtime->mesh_final->totface != runtime->totdmface)) {
+ if (had_mesh_final && (psmd->mesh_final->totvert != psmd->totdmvert ||
+ psmd->mesh_final->totedge != psmd->totdmedge ||
+ psmd->mesh_final->totface != psmd->totdmface)) {
psys->recalc |= ID_RECALC_PSYS_RESET;
- runtime->totdmvert = runtime->mesh_final->totvert;
- runtime->totdmedge = runtime->mesh_final->totedge;
- runtime->totdmface = runtime->mesh_final->totface;
+ psmd->totdmvert = psmd->mesh_final->totvert;
+ psmd->totdmedge = psmd->mesh_final->totedge;
+ psmd->totdmface = psmd->mesh_final->totface;
}
if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) {
@@ -238,11 +245,12 @@ ModifierTypeInfo modifierType_ParticleSystem = {
/* structSize */ sizeof(ParticleSystemModifierData),
/* type */ eModifierTypeType_OnlyDeform,
/* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping |
- eModifierTypeFlag_UsesPointCache, /* |
+ eModifierTypeFlag_UsesPointCache /* |
eModifierTypeFlag_SupportsEditmode |
eModifierTypeFlag_EnableInEditmode */
+ ,
- /* copyData */ modifier_copyData_generic,
+ /* copyData */ copyData,
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
@@ -260,5 +268,5 @@ ModifierTypeInfo modifierType_ParticleSystem = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
- /* freeRuntimeData */ freeRuntimeData,
+ /* freeRuntimeData */ NULL,
};