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:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-05-17 14:45:47 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-05-17 14:45:47 +0300
commit773a60d8f8d8372639856af398d7d27dd5fa7455 (patch)
treeafefff948a3edeea271dded2004396b2cff47e23 /source/blender/modifiers/intern/MOD_particleinstance.c
parentca1f1043d3164f859261a19d320b5102d628952e (diff)
Modifiers: ported Particle Instance DerivedMesh → Mesh
Diffstat (limited to 'source/blender/modifiers/intern/MOD_particleinstance.c')
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index c6eb2f73027..eee7f0c5561 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -33,6 +33,7 @@
*/
+#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "MEM_guardedalloc.h"
@@ -43,11 +44,11 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
-#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_library_query.h"
+#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -195,11 +196,11 @@ static void store_float_in_vcol(MLoopCol *vcol, float float_value)
vcol->a = 1.0f;
}
-static DerivedMesh *applyModifier(
+static Mesh *applyModifier(
ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *derivedData)
+ Mesh *mesh)
{
- DerivedMesh *dm = derivedData, *result;
+ Mesh *result;
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
ParticleSimulationData sim;
ParticleSystem *psys = NULL;
@@ -222,16 +223,16 @@ static DerivedMesh *applyModifier(
if (pimd->ob == ctx->object) {
pimd->ob = NULL;
- return derivedData;
+ return mesh;
}
if (pimd->ob) {
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
if (psys == NULL || psys->totpart == 0)
- return derivedData;
+ return mesh;
}
else {
- return derivedData;
+ return mesh;
}
part_start = use_parents ? 0 : psys->totpart;
@@ -243,7 +244,7 @@ static DerivedMesh *applyModifier(
part_end += psys->totchild;
if (part_end == 0)
- return derivedData;
+ return mesh;
sim.depsgraph = ctx->depsgraph;
sim.scene = md->scene;
@@ -285,10 +286,10 @@ static DerivedMesh *applyModifier(
break;
}
- totvert = dm->getNumVerts(dm);
- totpoly = dm->getNumPolys(dm);
- totloop = dm->getNumLoops(dm);
- totedge = dm->getNumEdges(dm);
+ totvert = mesh->totvert;
+ totpoly = mesh->totpoly;
+ totloop = mesh->totloop;
+ totedge = mesh->totedge;
/* count particles */
maxvert = 0;
@@ -311,22 +312,22 @@ static DerivedMesh *applyModifier(
if (psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) {
float min[3], max[3];
INIT_MINMAX(min, max);
- dm->getMinMax(dm, min, max);
+ BKE_mesh_minmax(mesh, min, max);
min_co = min[track];
max_co = max[track];
}
- result = CDDM_from_template(dm, maxvert, maxedge, 0, maxloop, maxpoly);
+ result = BKE_mesh_new_nomain_from_template(mesh, maxvert, maxedge, 0, maxloop, maxpoly);
- mvert = result->getVertArray(result);
- orig_mvert = dm->getVertArray(dm);
- mpoly = result->getPolyArray(result);
- orig_mpoly = dm->getPolyArray(dm);
- mloop = result->getLoopArray(result);
- orig_mloop = dm->getLoopArray(dm);
+ mvert = result->mvert;
+ orig_mvert = mesh->mvert;
+ mpoly = result->mpoly;
+ orig_mpoly = mesh->mpoly;
+ mloop = result->mloop;
+ orig_mloop = mesh->mloop;
- MLoopCol *mloopcols_index = CustomData_get_layer_named(&result->loopData, CD_MLOOPCOL, pimd->index_layer_name);
- MLoopCol *mloopcols_value = CustomData_get_layer_named(&result->loopData, CD_MLOOPCOL, pimd->value_layer_name);
+ MLoopCol *mloopcols_index = CustomData_get_layer_named(&result->ldata, CD_MLOOPCOL, pimd->index_layer_name);
+ MLoopCol *mloopcols_value = CustomData_get_layer_named(&result->ldata, CD_MLOOPCOL, pimd->value_layer_name);
int *vert_part_index = NULL;
float *vert_part_value = NULL;
if (mloopcols_index != NULL) {
@@ -353,7 +354,7 @@ static DerivedMesh *applyModifier(
MVert *mv = mvert + vindex;
inMV = orig_mvert + k;
- DM_copy_vert_data(dm, result, k, p_skip * totvert + k, 1);
+ CustomData_copy_data(&mesh->vdata, &result->vdata, k, p_skip * totvert + k, 1);
*mv = *inMV;
if (vert_part_index != NULL) {
@@ -467,8 +468,8 @@ static DerivedMesh *applyModifier(
}
/* create edges and adjust edge vertex indices*/
- DM_copy_edge_data(dm, result, 0, p_skip * totedge, totedge);
- MEdge *me = CDDM_get_edges(result) + p_skip * totedge;
+ CustomData_copy_data(&mesh->edata, &result->edata, 0, p_skip * totedge, totedge);
+ MEdge *me = &result->medge[p_skip * totedge];
for (k = 0; k < totedge; k++, me++) {
me->v1 += p_skip * totvert;
me->v2 += p_skip * totvert;
@@ -480,7 +481,7 @@ static DerivedMesh *applyModifier(
MPoly *inMP = orig_mpoly + k;
MPoly *mp = mpoly + p_skip * totpoly + k;
- DM_copy_poly_data(dm, result, k, p_skip * totpoly + k, 1);
+ CustomData_copy_data(&mesh->pdata, &result->pdata, k, p_skip * totpoly + k, 1);
*mp = *inMP;
mp->loopstart += p_skip * totloop;
@@ -489,7 +490,7 @@ static DerivedMesh *applyModifier(
MLoop *ml = mloop + mp->loopstart;
int j = mp->totloop;
- DM_copy_loop_data(dm, result, inMP->loopstart, mp->loopstart, j);
+ CustomData_copy_data(&mesh->ldata, &result->ldata, inMP->loopstart, mp->loopstart, j);
for (; j; j--, ml++, inML++) {
ml->v = inML->v + (p_skip * totvert);
ml->e = inML->e + (p_skip * totedge);
@@ -519,7 +520,7 @@ static DerivedMesh *applyModifier(
MEM_SAFE_FREE(vert_part_index);
MEM_SAFE_FREE(vert_part_value);
- result->dirty |= DM_DIRTY_NORMALS;
+ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
return result;
}
@@ -539,14 +540,14 @@ ModifierTypeInfo modifierType_ParticleInstance = {
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ applyModifier,
+ /* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,