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:
authorCampbell Barton <ideasman42@gmail.com>2012-02-03 03:58:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-03 03:58:46 +0400
commit07919930300e6055c5452ec2b54150e70babd5fe (patch)
treecaac3f3b994c52d61a3492ef783c1d567fdd1a9a /source/blender/modifiers/intern/MOD_fluidsim_util.c
parent4e44b149275a3542a3ff7385455a95b7c2856346 (diff)
Minor Speedup: avoid for() loop over all faces in fluidsim by passing an example face to the mesh read function (also avoid a lot of int -> short/char conversions).
Diffstat (limited to 'source/blender/modifiers/intern/MOD_fluidsim_util.c')
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 38909a2671a..0cdb2c8b057 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -152,9 +152,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
void fluidsim_free(FluidsimModifierData *fluidmd)
{
-#ifdef WITH_MOD_FLUID
- if(fluidmd)
- {
+ if(fluidmd) {
if(fluidmd->fss->meshVelocities)
{
MEM_freeN(fluidmd->fss->meshVelocities);
@@ -162,16 +160,13 @@ void fluidsim_free(FluidsimModifierData *fluidmd)
}
MEM_freeN(fluidmd->fss);
}
-#else
- (void)fluidmd; /* unused */
-#endif
return;
}
#ifdef WITH_MOD_FLUID
/* read .bobj.gz file into a fluidsimDerivedMesh struct */
-static DerivedMesh *fluidsim_read_obj(const char *filename)
+static DerivedMesh *fluidsim_read_obj(const char *filename, const MFace *mf_example)
{
int wri = 0,i;
int gotBytes;
@@ -183,6 +178,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename)
short *normals, *no_s;
float no[3];
+ const short mf_mat_nr = mf_example->mat_nr;
+ const char mf_flag = mf_example->flag;
+
// ------------------------------------------------
// get numverts + numfaces first
// ------------------------------------------------
@@ -287,6 +285,10 @@ static DerivedMesh *fluidsim_read_obj(const char *filename)
gotBytes = gzread(gzf, face, sizeof(int) * 3);
+ /* initialize from existing face */
+ mf->mat_nr = mf_mat_nr;
+ mf->flag = mf_flag;
+
// check if 3rd vertex has index 0 (not allowed in blender)
if(face[2])
{
@@ -452,8 +454,8 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
FluidsimSettings *fss = fluidmd->fss;
DerivedMesh *dm = NULL;
MFace *mface;
- int numfaces;
- int mat_nr, flag, i;
+ MFace mf_example = {0};
+
if(!useRenderParams) {
displaymode = fss->guiDisplayMode;
@@ -481,7 +483,15 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
BLI_path_abs(targetFile, modifier_path_relbase(ob));
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no
- dm = fluidsim_read_obj(targetFile);
+ // assign material + flags to new dm
+ // if there's no faces in original dm, keep materials and flags unchanged
+ mface = orgdm->getFaceArray(orgdm);
+ if (mface) {
+ mf_example = *mface;
+ }
+ /* else leave NULL'd */
+
+ dm = fluidsim_read_obj(targetFile, &mf_example);
if(!dm)
{
@@ -502,23 +512,6 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
return NULL;
}
- // assign material + flags to new dm
- // if there's no faces in original dm, keep materials and flags unchanged
- mface = orgdm->getFaceArray(orgdm);
-
- if(mface) {
- mat_nr = mface[0].mat_nr;
- flag = mface[0].flag;
-
- mface = dm->getFaceArray(dm);
- numfaces = dm->getNumFaces(dm);
- for(i=0; i<numfaces; i++)
- {
- mface[i].mat_nr = mat_nr;
- mface[i].flag = flag;
- }
- }
-
// load vertex velocities, if they exist...
// TODO? use generate flag as loading flag as well?
// warning, needs original .bobj.gz mesh loading filename