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-07-05 12:08:05 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-07-05 12:30:38 +0300
commitf4ce6d02cde816c3c681702d97a75617b8e9a598 (patch)
treee9699aabbc3cd84abc3b3330fb27612ef83c95ef /source/blender/modifiers/intern/MOD_fluidsim_util.c
parent99a6d616e85f8a06dfd3d825f8e3cd350e35f61e (diff)
Fluidsim: ported from DerivedMesh to Mesh
Also removed a bunch of unnecessary #include statements from fluidsim.c.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_fluidsim_util.c')
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index ed5d08a95d4..963296f80f6 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -47,8 +47,8 @@
#include "BLI_utildefines.h"
#include "BKE_fluidsim.h" /* ensure definitions here match */
-#include "BKE_cdderivedmesh.h"
#include "BKE_main.h"
+#include "BKE_mesh.h"
#ifdef WITH_MOD_FLUID
# include "BKE_global.h"
#endif
@@ -165,13 +165,13 @@ void fluidsim_free(FluidsimModifierData *fluidmd)
#ifdef WITH_MOD_FLUID
/* read .bobj.gz file into a fluidsimDerivedMesh struct */
-static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example)
+static Mesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example)
{
int wri = 0, i;
int gotBytes;
gzFile gzf;
int numverts = 0, numfaces = 0;
- DerivedMesh *dm = NULL;
+ Mesh *mesh = NULL;
MPoly *mp;
MLoop *ml;
MVert *mv;
@@ -220,9 +220,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
return NULL;
}
- dm = CDDM_new(numverts, 0, 0, numfaces * 3, numfaces);
+ mesh = BKE_mesh_new_nomain(numverts, 0, 0, numfaces * 3, numfaces);
- if (!dm) {
+ if (!mesh) {
gzclose(gzf);
return NULL;
}
@@ -231,7 +231,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
gotBytes = gzread(gzf, &wri, sizeof(wri));
/* read vertex position from file */
- mv = CDDM_get_verts(dm);
+ mv = mesh->mvert;
for (i = 0; i < numverts; i++, mv++)
gotBytes = gzread(gzf, mv->co, sizeof(float) * 3);
@@ -239,16 +239,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
/* should be the same as numverts */
gotBytes = gzread(gzf, &wri, sizeof(wri));
if (wri != numverts) {
- if (dm)
- dm->release(dm);
+ if (mesh)
+ BKE_id_free(NULL, mesh);
gzclose(gzf);
return NULL;
}
normals = MEM_calloc_arrayN(numverts, 3 * sizeof(short), "fluid_tmp_normals");
if (!normals) {
- if (dm)
- dm->release(dm);
+ if (mesh)
+ BKE_id_free(NULL, mesh);
gzclose(gzf);
return NULL;
}
@@ -264,16 +264,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
if (wri != numfaces) {
printf("Fluidsim: error in reading data from file.\n");
- if (dm)
- dm->release(dm);
+ if (mesh)
+ BKE_id_free(NULL, mesh);
gzclose(gzf);
MEM_freeN(normals);
return NULL;
}
/* read triangles from file */
- mp = CDDM_get_polys(dm);
- ml = CDDM_get_loops(dm);
+ mp = mesh->mpoly;
+ ml = mesh->mloop;
for (i = 0; i < numfaces; i++, mp++, ml += 3) {
int face[3];
@@ -294,13 +294,12 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
gzclose(gzf);
- CDDM_calc_edges(dm);
-
- CDDM_apply_vert_normals(dm, (short (*)[3])normals);
+ BKE_mesh_calc_edges(mesh, false, false);
+ BKE_mesh_apply_vert_normals(mesh, (short (*)[3])normals);
MEM_freeN(normals);
// CDDM_calc_normals(result);
- return dm;
+ return mesh;
}
@@ -370,14 +369,14 @@ void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value)
/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */
-static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename)
+static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, Mesh *mesh, char *filename)
{
int wri, i, j;
float wrf;
gzFile gzf;
FluidsimSettings *fss = fluidmd->fss;
int len = strlen(filename);
- int totvert = dm->getNumVerts(dm);
+ int totvert = mesh->totvert;
FluidVertexVelocity *velarray = NULL;
/* mesh and vverts have to be valid from loading... */
@@ -391,7 +390,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
if (fss->domainNovecgen > 0) return;
- fss->meshVelocities = MEM_calloc_arrayN(dm->getNumVerts(dm), sizeof(FluidVertexVelocity), "Fluidsim_velocities");
+ fss->meshVelocities = MEM_calloc_arrayN(mesh->totvert, sizeof(FluidVertexVelocity), "Fluidsim_velocities");
fss->totvert = totvert;
velarray = fss->meshVelocities;
@@ -426,8 +425,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
gzclose(gzf);
}
-static DerivedMesh *fluidsim_read_cache(
- Object *ob, DerivedMesh *orgdm,
+static Mesh *fluidsim_read_cache(
+ Object *ob, Mesh *orgmesh,
FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
@@ -436,7 +435,7 @@ static DerivedMesh *fluidsim_read_cache(
char targetFile[FILE_MAX];
FluidsimSettings *fss = fluidmd->fss;
- DerivedMesh *dm = NULL;
+ Mesh *newmesh = NULL;
MPoly *mpoly;
MPoly mp_example = {0};
@@ -467,15 +466,15 @@ static DerivedMesh *fluidsim_read_cache(
/* assign material + flags to new dm
* if there's no faces in original dm, keep materials and flags unchanged */
- mpoly = orgdm->getPolyArray(orgdm);
+ mpoly = orgmesh->mpoly;
if (mpoly) {
mp_example = *mpoly;
}
/* else leave NULL'd */
- dm = fluidsim_read_obj(targetFile, &mp_example);
+ newmesh = fluidsim_read_obj(targetFile, &mp_example);
- if (!dm) {
+ if (!newmesh) {
/* switch, abort background rendering when fluidsim mesh is missing */
const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp
@@ -498,7 +497,7 @@ static DerivedMesh *fluidsim_read_cache(
* TODO? use generate flag as loading flag as well?
* warning, needs original .bobj.gz mesh loading filename */
if (displaymode == OB_FSDOM_FINAL) {
- fluidsim_read_vel_cache(fluidmd, dm, targetFile);
+ fluidsim_read_vel_cache(fluidmd, newmesh, targetFile);
}
else {
if (fss->meshVelocities)
@@ -507,21 +506,21 @@ static DerivedMesh *fluidsim_read_cache(
fss->meshVelocities = NULL;
}
- return dm;
+ return newmesh;
}
#endif // WITH_MOD_FLUID
-DerivedMesh *fluidsimModifier_do(
+Mesh *fluidsimModifier_do(
FluidsimModifierData *fluidmd,
const ModifierEvalContext *ctx,
- DerivedMesh *dm)
+ Mesh *mesh)
{
#ifdef WITH_MOD_FLUID
Object *ob = ctx->object;
Depsgraph *depsgraph = ctx->depsgraph;
const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0;
// const bool isFinalCalc = (ctx->flag & MOD_APPLY_USECACHE) != 0;
- DerivedMesh *result = NULL;
+ Mesh *result = NULL;
int framenr;
FluidsimSettings *fss = NULL;
@@ -529,11 +528,11 @@ DerivedMesh *fluidsimModifier_do(
/* only handle fluidsim domains */
if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
- return dm;
+ return mesh;
/* sanity check */
if (!fluidmd || !fluidmd->fss)
- return dm;
+ return mesh;
fss = fluidmd->fss;
@@ -548,10 +547,10 @@ DerivedMesh *fluidsimModifier_do(
/* try to read from cache */
/* if the frame is there, fine, otherwise don't do anything */
- if ((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
+ if ((result = fluidsim_read_cache(ob, mesh, fluidmd, framenr, useRenderParams)))
return result;
- return dm;
+ return mesh;
#else
/* unused */
(void)fluidmd;