2010-04-11 22:12:30 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Daniel Dunbar
|
|
|
|
* Ton Roosendaal,
|
|
|
|
* Ben Batt,
|
|
|
|
* Brecht Van Lommel,
|
|
|
|
* Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
*/
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-02-25 13:57:17 +00:00
|
|
|
/** \file blender/modifiers/intern/MOD_particlesystem.c
|
|
|
|
* \ingroup modifiers
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-03-09 01:25:59 +00:00
|
|
|
#include <stddef.h>
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
#include "DNA_material_types.h"
|
2016-01-06 21:22:01 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
#include "BKE_cdderivedmesh.h"
|
|
|
|
#include "BKE_modifier.h"
|
|
|
|
#include "BKE_particle.h"
|
|
|
|
|
|
|
|
#include "MOD_util.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void initData(ModifierData *md)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
|
|
|
|
psmd->psys = NULL;
|
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
2016-01-04 12:19:45 +01:00
|
|
|
psmd->dm_final = NULL;
|
|
|
|
psmd->dm_deformed = NULL;
|
2012-05-06 13:38:33 +00:00
|
|
|
psmd->totdmvert = psmd->totdmedge = psmd->totdmface = 0;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
static void freeData(ModifierData *md)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
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
2016-01-04 12:19:45 +01:00
|
|
|
if (psmd->dm_final) {
|
2016-01-06 21:22:01 +01:00
|
|
|
psmd->dm_final->needsFree = true;
|
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
2016-01-04 12:19:45 +01:00
|
|
|
psmd->dm_final->release(psmd->dm_final);
|
|
|
|
psmd->dm_final = NULL;
|
|
|
|
if (psmd->dm_deformed) {
|
2016-01-06 21:22:01 +01:00
|
|
|
psmd->dm_deformed->needsFree = true;
|
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
2016-01-04 12:19:45 +01:00
|
|
|
psmd->dm_deformed->release(psmd->dm_deformed);
|
|
|
|
psmd->dm_deformed = NULL;
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ED_object_modifier_remove may have freed this first before calling
|
|
|
|
* modifier_free (which calls this function) */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (psmd->psys)
|
2010-04-11 22:12:30 +00:00
|
|
|
psmd->psys->flag |= PSYS_DELETE;
|
|
|
|
}
|
|
|
|
static void copyData(ModifierData *md, ModifierData *target)
|
|
|
|
{
|
2013-12-22 04:35:52 +11:00
|
|
|
#if 0
|
2012-05-06 13:38:33 +00:00
|
|
|
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
|
2013-12-22 04:35:52 +11:00
|
|
|
#endif
|
2012-05-06 13:38:33 +00:00
|
|
|
ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *) target;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2013-12-22 04:35:52 +11:00
|
|
|
modifier_copyData_generic(md, target);
|
|
|
|
|
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
2016-01-04 12:19:45 +01:00
|
|
|
tpsmd->dm_final = NULL;
|
|
|
|
tpsmd->dm_deformed = NULL;
|
2010-04-11 22:12:30 +00:00
|
|
|
tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0;
|
|
|
|
}
|
|
|
|
|
2011-02-16 17:31:04 +00:00
|
|
|
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
|
2015-01-15 18:15:52 +01:00
|
|
|
return psys_emitter_customdata_mask(psmd->psys);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* saves the current emitter state for a particle system and calculates particles */
|
2010-10-14 06:29:17 +00:00
|
|
|
static void deformVerts(ModifierData *md, Object *ob,
|
2012-05-06 13:38:33 +00:00
|
|
|
DerivedMesh *derivedData,
|
|
|
|
float (*vertexCos)[3],
|
|
|
|
int UNUSED(numVerts),
|
2016-06-23 07:53:49 +10:00
|
|
|
ModifierApplyFlag flag)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
|
|
|
DerivedMesh *dm = derivedData;
|
2012-05-06 13:38:33 +00:00
|
|
|
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
|
|
|
|
ParticleSystem *psys = NULL;
|
2016-01-06 21:22:01 +01:00
|
|
|
bool needsFree = false;
|
2012-10-19 03:07:58 +00:00
|
|
|
/* float cfra = BKE_scene_frame_get(md->scene); */ /* UNUSED */
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (ob->particlesystem.first)
|
2012-05-06 13:38:33 +00:00
|
|
|
psys = psmd->psys;
|
2010-04-11 22:12:30 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2016-06-23 07:53:49 +10:00
|
|
|
if (!psys_check_enabled(ob, psys, (flag & MOD_APPLY_RENDER) != 0))
|
2010-04-11 22:12:30 +00:00
|
|
|
return;
|
|
|
|
|
2012-05-06 13:38:33 +00:00
|
|
|
if (dm == NULL) {
|
2013-07-16 08:24:53 +00:00
|
|
|
dm = get_dm(ob, NULL, NULL, vertexCos, false, true);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (!dm)
|
2010-04-11 22:12:30 +00:00
|
|
|
return;
|
|
|
|
|
2016-01-06 21:22:01 +01:00
|
|
|
needsFree = true;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clear old dm */
|
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
2016-01-04 12:19:45 +01:00
|
|
|
if (psmd->dm_final) {
|
2016-01-06 21:22:01 +01:00
|
|
|
psmd->dm_final->needsFree = true;
|
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
2016-01-04 12:19:45 +01:00
|
|
|
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;
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
|
2011-01-07 17:27:27 +00:00
|
|
|
/* in file read dm just wasn't saved in file so no need to reset everything */
|
|
|
|
psmd->flag &= ~eParticleSystemFlag_file_loaded;
|
|
|
|
}
|
2010-10-30 10:19:30 +00:00
|
|
|
else {
|
|
|
|
/* no dm before, so recalc particles fully */
|
|
|
|
psys->recalc |= PSYS_RECALC_RESET;
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/* make new dm */
|
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
2016-01-04 12:19:45 +01:00
|
|
|
psmd->dm_final = CDDM_copy(dm);
|
|
|
|
CDDM_apply_vert_coords(psmd->dm_final, vertexCos);
|
|
|
|
CDDM_calc_normals(psmd->dm_final);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (needsFree) {
|
2016-01-06 21:22:01 +01:00
|
|
|
dm->needsFree = true;
|
2010-04-11 22:12:30 +00:00
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* protect dm */
|
2016-01-06 21:22:01 +01:00
|
|
|
psmd->dm_final->needsFree = false;
|
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
2016-01-04 12:19:45 +01:00
|
|
|
|
|
|
|
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. :| */
|
2016-01-06 21:22:01 +01:00
|
|
|
if (ob->derivedDeform) {
|
|
|
|
psmd->dm_deformed = CDDM_copy(ob->derivedDeform);
|
2016-01-06 20:28:21 +01:00
|
|
|
}
|
2016-01-06 21:22:01 +01:00
|
|
|
else { /* Can happen in some cases, e.g. when rendering from Edit mode... */
|
|
|
|
psmd->dm_deformed = CDDM_from_mesh((Mesh *)ob->data);
|
2016-01-06 20:20:50 +01:00
|
|
|
}
|
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
2016-01-04 12:19:45 +01:00
|
|
|
DM_ensure_tessface(psmd->dm_deformed);
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/* report change in mesh structure */
|
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
2016-01-04 12:19:45 +01:00
|
|
|
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)
|
2012-05-06 13:38:33 +00:00
|
|
|
{
|
2010-04-11 22:12:30 +00:00
|
|
|
psys->recalc |= PSYS_RECALC_RESET;
|
|
|
|
|
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
2016-01-04 12:19:45 +01:00
|
|
|
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);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2012-10-18 15:54:24 +00:00
|
|
|
if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {
|
2012-10-16 14:55:36 +00:00
|
|
|
psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
2016-06-23 07:53:49 +10:00
|
|
|
particle_system_update(md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
|
2012-10-16 14:55:36 +00:00
|
|
|
psmd->flag |= eParticleSystemFlag_psys_updated;
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* disabled particles in editmode for now, until support for proper derivedmesh
|
|
|
|
* updates is coded */
|
|
|
|
#if 0
|
|
|
|
static void deformVertsEM(
|
2012-08-23 16:17:47 +00:00
|
|
|
ModifierData *md, Object *ob, EditMesh *editData,
|
|
|
|
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
|
|
|
DerivedMesh *dm = derivedData;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (!derivedData) dm = CDDM_from_editmesh(editData, ob->data);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
deformVerts(md, ob, dm, vertexCos, numVerts);
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (!derivedData) dm->release(dm);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
ModifierTypeInfo modifierType_ParticleSystem = {
|
|
|
|
/* name */ "ParticleSystem",
|
|
|
|
/* structName */ "ParticleSystemModifierData",
|
|
|
|
/* structSize */ sizeof(ParticleSystemModifierData),
|
|
|
|
/* type */ eModifierTypeType_OnlyDeform,
|
2012-05-06 13:38:33 +00:00
|
|
|
/* flags */ eModifierTypeFlag_AcceptsMesh |
|
|
|
|
eModifierTypeFlag_SupportsMapping |
|
|
|
|
eModifierTypeFlag_UsesPointCache /* |
|
|
|
|
eModifierTypeFlag_SupportsEditmode |
|
|
|
|
eModifierTypeFlag_EnableInEditmode */,
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/* copyData */ copyData,
|
|
|
|
/* deformVerts */ deformVerts,
|
2012-05-01 20:08:23 +00:00
|
|
|
/* deformVertsEM */ NULL,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* deformMatrices */ NULL,
|
|
|
|
/* deformMatricesEM */ NULL,
|
|
|
|
/* applyModifier */ NULL,
|
|
|
|
/* applyModifierEM */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* initData */ initData,
|
|
|
|
/* requiredDataMask */ requiredDataMask,
|
|
|
|
/* freeData */ freeData,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* isDisabled */ NULL,
|
|
|
|
/* updateDepgraph */ NULL,
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* updateDepsgraph */ NULL,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* dependsOnTime */ NULL,
|
|
|
|
/* dependsOnNormals */ NULL,
|
|
|
|
/* foreachObjectLink */ NULL,
|
|
|
|
/* foreachIDLink */ NULL,
|
2011-08-12 18:11:22 +00:00
|
|
|
/* foreachTexLink */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|