[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10912] trunk/blender/source/blender/src/ multires.c: == Multires ==
Nicholas Bishop
nicholasbishop at gmail.com
Mon Jun 11 01:01:37 CEST 2007
Revision: 10912
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10912
Author: nicholasbishop
Date: 2007-06-11 01:01:23 +0200 (Mon, 11 Jun 2007)
Log Message:
-----------
== Multires ==
* Removed two unused structs from multires
* Replaced one-line get_float function with a macro
* During add_level, move the freeing of temp data to after the update_level, so that this data isn't calculated twice
Modified Paths:
--------------
trunk/blender/source/blender/src/multires.c
Modified: trunk/blender/source/blender/src/multires.c
===================================================================
--- trunk/blender/source/blender/src/multires.c 2007-06-10 21:51:11 UTC (rev 10911)
+++ trunk/blender/source/blender/src/multires.c 2007-06-10 23:01:23 UTC (rev 10912)
@@ -151,15 +151,6 @@
return 0;
}
-typedef struct FloatNode {
- struct FloatNode *next, *prev;
- float value;
-} FloatNode;
-typedef struct FloatArrayNode {
- struct FloatArrayNode *next, *prev;
- float *value;
-} FloatArrayNode;
-
typedef struct MultiApplyData {
/* Smooth faces */
float *corner1, *corner2, *corner3, *corner4;
@@ -226,10 +217,7 @@
out[i]= func(data,i);
}
-float get_float(void *array, const unsigned i, const unsigned j, const char stride)
-{
- return ((float*)((char*)array+(i*stride)))[j];
-}
+#define GET_FLOAT(array, i, j, stride) (((float*)((char*)(array)+((i)*(stride))))[(j)])
void edge_face_neighbor_midpoints_accum(MultiApplyData *data, MultiresLevel *lvl,
void *array, const char stride, const MultiresEdge *e)
@@ -246,7 +234,7 @@
for(n2= neighbors2->first; n2; n2= n2->next) {
if(n1->Index == n2->Index) {
for(j=0; j<3; ++j)
- out[j]+= get_float(array,lvl->faces[n1->Index].mid,j,stride);
+ out[j]+= GET_FLOAT(array,lvl->faces[n1->Index].mid,j,stride);
++count;
}
}
@@ -266,7 +254,7 @@
for(n1= neighbors->first; n1; n1= n1->next) {
for(j=0; j<3; ++j)
- out[j]+= get_float(array,lvl->faces[n1->Index].mid,j,stride);
+ out[j]+= GET_FLOAT(array,lvl->faces[n1->Index].mid,j,stride);
++count;
}
for(j=0; j<3; ++j) out[j]/= count;
@@ -283,8 +271,8 @@
for(n1= neighbors->first; n1; n1= n1->next) {
for(j=0; j<3; ++j)
- out[j]+= (get_float(array,lvl->edges[n1->Index].v[0],j,stride) +
- get_float(array,lvl->edges[n1->Index].v[1],j,stride)) / 2;
+ out[j]+= (GET_FLOAT(array,lvl->edges[n1->Index].v[0],j,stride) +
+ GET_FLOAT(array,lvl->edges[n1->Index].v[1],j,stride)) / 2;
++count;
}
for(j=0; j<3; ++j) out[j]/= count;
@@ -305,7 +293,7 @@
if(lvl->edge_boundary_states[n1->Index]) {
for(j=0; j<3; ++j)
- out[j]+= get_float(array,end,j,stride);
+ out[j]+= GET_FLOAT(array,end,j,stride);
++count;
}
}
@@ -965,7 +953,6 @@
}
}
- multires_free_temp_data(lvl->prev);
MEM_freeN(oldverts);
/* Vertex Colors
@@ -997,6 +984,8 @@
}
multires_update_levels(me, 0);
+ multires_free_temp_data(lvl->prev);
+
me->mr->newlvl= me->mr->level_count;
me->mr->current= me->mr->newlvl;
/* Unless the render level has been set to something other than the
@@ -1375,7 +1364,7 @@
pr_lvl= BLI_findlink(&me->mr->levels,me->mr->current-1);
cr_lvl= pr_lvl->next;
while(cr_lvl) {
- multires_calc_temp_data(pr_lvl);
+ multires_calc_temp_data(pr_lvl);
/* Swap the old/new deltas */
swap_deltas= pr_deltas;
@@ -1560,6 +1549,9 @@
unsigned i, j, emax;
MultiresMapNode *indexnode= NULL;
+ if(lvl->map_mem)
+ return;
+
lvl->map_mem= MEM_mallocN(sizeof(MultiresMapNode)*(lvl->totedge*2 + lvl->totface*4), "map_mem");
indexnode= lvl->map_mem;
More information about the Bf-blender-cvs
mailing list