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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-01-04 14:19:45 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-01-04 14:19:45 +0300
commitaad24468e2d32d46e2c3b3b4a37302a4f1f27ab6 (patch)
treebf3824be66c324d4cc30add16a677a17b9181db7 /source/blender/modifiers/intern/MOD_particlesystem.c
parente83b3e577e59770dcd43a0c9dbf9ff3dcfda4365 (diff)
Fix T47038: Particles in Particle Edit Mode get added in completely wrong location.
It also fixes another issue (crash) related to symmetric editing. Quite involved, we (try to!) fix complete broken logic of parts of particle code, which would use poly index as tessface one (or vice-versa). Issue most probably goes back to BMesh integration time... This patch mostly fixes particle editing mode: - Adding/removing particles when using generative modifiers (like subsurf) should now work. - Adding/removing particles with a non-tessellated mesh (i.e. one having ngons) should also mostly work. - X-axis-mirror-editing particles over ngons does not really work, not sure why currently. - All this in both 'modes' (with or without using modifier stack for particles). Tech side: - Store a deformed-only DM in particle modifier data. - Rename existing DM to make it clear it's a final one. - Use deformed-only DM's tessface2poly mapping to 'solve' poly/tessface mismatches. - Make (part of) mirror-editing code able to use a DM instead of raw mesh, so that we can mirror based on final DM when editing particles using modifier stack (mandatory, since there is no way currently to find orig tessface from an final DM tessface index). Note that this patch is not really nice and clean (current particles are beyond hope on this side anyway), it's more like some urgency bandage. Whole crap needs complete rewrite anyway, BMesh's polygons make it really hard to work with current system (and looptri would not help much here). Also, did not test everything possibly affected by those changes, so it needs some users' testing & validation too. Reviewers: psy-fi Subscribers: dfelinto, eyecandy Maniphest Tasks: T47038 Differential Revision: https://developer.blender.org/D1685
Diffstat (limited to 'source/blender/modifiers/intern/MOD_particlesystem.c')
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index de1b11eddd9..6b2b999d596 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -51,17 +51,23 @@ static void initData(ModifierData *md)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
psmd->psys = NULL;
- psmd->dm = NULL;
+ psmd->dm_final = NULL;
+ psmd->dm_deformed = NULL;
psmd->totdmvert = psmd->totdmedge = psmd->totdmface = 0;
}
static void freeData(ModifierData *md)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
- if (psmd->dm) {
- psmd->dm->needsFree = 1;
- psmd->dm->release(psmd->dm);
- psmd->dm = NULL;
+ if (psmd->dm_final) {
+ psmd->dm_final->needsFree = 1;
+ psmd->dm_final->release(psmd->dm_final);
+ psmd->dm_final = NULL;
+ if (psmd->dm_deformed) {
+ psmd->dm_deformed->needsFree = 1;
+ psmd->dm_deformed->release(psmd->dm_deformed);
+ psmd->dm_deformed = NULL;
+ }
}
/* ED_object_modifier_remove may have freed this first before calling
@@ -78,7 +84,8 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target);
- tpsmd->dm = NULL;
+ tpsmd->dm_final = NULL;
+ tpsmd->dm_deformed = NULL;
tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0;
}
@@ -119,9 +126,14 @@ static void deformVerts(ModifierData *md, Object *ob,
}
/* clear old dm */
- if (psmd->dm) {
- psmd->dm->needsFree = 1;
- psmd->dm->release(psmd->dm);
+ if (psmd->dm_final) {
+ psmd->dm_final->needsFree = 1;
+ psmd->dm_final->release(psmd->dm_final);
+ if (psmd->dm_deformed) {
+ psmd->dm_deformed->needsFree = 1;
+ psmd->dm_deformed->release(psmd->dm_deformed);
+ psmd->dm_deformed = NULL;
+ }
}
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
/* in file read dm just wasn't saved in file so no need to reset everything */
@@ -133,9 +145,9 @@ static void deformVerts(ModifierData *md, Object *ob,
}
/* make new dm */
- psmd->dm = CDDM_copy(dm);
- CDDM_apply_vert_coords(psmd->dm, vertexCos);
- CDDM_calc_normals(psmd->dm);
+ psmd->dm_final = CDDM_copy(dm);
+ CDDM_apply_vert_coords(psmd->dm_final, vertexCos);
+ CDDM_calc_normals(psmd->dm_final);
if (needsFree) {
dm->needsFree = 1;
@@ -143,19 +155,27 @@ static void deformVerts(ModifierData *md, Object *ob,
}
/* protect dm */
- psmd->dm->needsFree = 0;
+ psmd->dm_final->needsFree = 0;
+
+ DM_ensure_tessface(psmd->dm_final);
+
+ if (!psmd->dm_final->deformedOnly) {
+ /* XXX Think we can assume here that if current DM is not only-deformed, ob->deformedOnly has been set.
+ * This is awfully weak though. :| */
+ psmd->dm_deformed = CDDM_copy(ob->derivedDeform);
+ DM_ensure_tessface(psmd->dm_deformed);
+ }
/* report change in mesh structure */
- DM_ensure_tessface(psmd->dm);
- if (psmd->dm->getNumVerts(psmd->dm) != psmd->totdmvert ||
- psmd->dm->getNumEdges(psmd->dm) != psmd->totdmedge ||
- psmd->dm->getNumTessFaces(psmd->dm) != psmd->totdmface)
+ if (psmd->dm_final->getNumVerts(psmd->dm_final) != psmd->totdmvert ||
+ psmd->dm_final->getNumEdges(psmd->dm_final) != psmd->totdmedge ||
+ psmd->dm_final->getNumTessFaces(psmd->dm_final) != psmd->totdmface)
{
psys->recalc |= PSYS_RECALC_RESET;
- psmd->totdmvert = psmd->dm->getNumVerts(psmd->dm);
- psmd->totdmedge = psmd->dm->getNumEdges(psmd->dm);
- psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm);
+ psmd->totdmvert = psmd->dm_final->getNumVerts(psmd->dm_final);
+ psmd->totdmedge = psmd->dm_final->getNumEdges(psmd->dm_final);
+ psmd->totdmface = psmd->dm_final->getNumTessFaces(psmd->dm_final);
}
if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {