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:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-03-14 07:10:18 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-03-14 07:10:18 +0400
commit99f72dfbfcb004418ae3c701f3badfd36996e6e5 (patch)
tree15fb556342a58a1a947bd087c11d39f7afa4f95b /source/blender/blenkernel
parentf80fa544281afb22815ca083d0badd3a9979d17d (diff)
Add 'level' field to struct MDisps, companion to 'totdisp'.
Gets initialized when loading old files and updated at the same places totdisp is updated. Saves having to do log+sqrt to extract level from totdisp.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/customdata.c3
-rw-r--r--source/blender/blenkernel/intern/mesh.c1
-rw-r--r--source/blender/blenkernel/intern/multires.c6
3 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 233d0202540..2520c9b666e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -485,10 +485,12 @@ static void layerCopy_mdisps(const void *source, void *dest, int count)
if(s[i].disps) {
d[i].disps = MEM_dupallocN(s[i].disps);
d[i].totdisp = s[i].totdisp;
+ d[i].level = s[i].level;
}
else {
d[i].disps = NULL;
d[i].totdisp = 0;
+ d[i].level = 0;
}
}
@@ -504,6 +506,7 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size))
MEM_freeN(d[i].disps);
d[i].disps = NULL;
d[i].totdisp = 0;
+ d[i].level = 0;
}
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 054cbe0021b..6600099fff7 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1877,6 +1877,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex,
for (i=0; i<tot; i++, disps += side*side, ld++) {
ld->totdisp = side*side;
+ ld->level = (int)(logf(side - 1.0f) / M_LN2) + 1;
if (ld->disps)
MEM_freeN(ld->disps);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 7d50ec6d13a..b708f33537f 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -320,6 +320,7 @@ static void multires_set_tot_mdisps(Mesh *me, int lvl)
if (mdisps) {
for (i = 0; i < me->totloop; i++, mdisps++) {
mdisps->totdisp = multires_grid_tot[lvl];
+ mdisps->level = lvl;
}
}
}
@@ -338,6 +339,7 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
mdisps[i].disps = disps;
mdisps[i].totdisp = totdisp;
+ mdisps[i].level = lvl;
}
}
@@ -426,6 +428,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
MEM_freeN(mdisp->disps);
mdisp->disps = disps;
mdisp->totdisp = totdisp;
+ mdisp->level = lvl;
}
}
}
@@ -999,6 +1002,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to)
/* when adding new faces in edit mode, need to allocate disps */
if (!mdisp->disps) {
mdisp->totdisp = gridSize*gridSize;
+ mdisp->level = totlvl;
mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space");
}
@@ -1224,6 +1228,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
MEM_freeN(mdisp->disps);
mdisp->totdisp= newtotdisp;
+ mdisp->level= newlvl;
mdisp->disps= disps;
}
@@ -1252,6 +1257,7 @@ void multires_load_old_250(Mesh *me)
for (j=0; j < mf->v4 ? 4 : 3; j++, k++) {
mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion");
mdisps2[k].totdisp = totdisp;
+ mdisps2[k].level = mdisps[i].level;
memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp);
}