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>2010-01-01 18:57:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-01 18:57:17 +0300
commit11e529f4f77e6eae519f7b2b91055cf8b2d459ba (patch)
tree4eb9e112af5c04c9ae0ee4791f5a34a8199957b3 /source/blender/editors/gpencil
parent4ab4d2dd20791101215b39609bf174762e42e58d (diff)
made the array interpolation function from last commit into a generic function
/* given an array with some invalid values this function interpolates valid values * replacing the invalid ones */ int interp_sparse_array(float *array, int list_size, float skipval)
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c54
1 files changed, 1 insertions, 53 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 86ca69f6cf6..905f8c482e9 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -537,59 +537,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
depth_arr[i] = 0.9999f;
}
else if(interp_depth) {
- /* found invalid depths, interpolate */
- float valid_last= FLT_MAX;
- int valid_ofs= 0;
-
- float *depth_arr_up= MEM_callocN(sizeof(float) * gpd->sbuffer_size, "depth_points_up");
- float *depth_arr_down= MEM_callocN(sizeof(float) * gpd->sbuffer_size, "depth_points_down");
-
- int *depth_tot_up= MEM_callocN(sizeof(int) * gpd->sbuffer_size, "depth_tot_up");
- int *depth_tot_down= MEM_callocN(sizeof(int) * gpd->sbuffer_size, "depth_tot_down");
-
- for (i=0; i < gpd->sbuffer_size; i++) {
- if(depth_arr[i] == FLT_MAX) {
- depth_arr_up[i]= valid_last;
- depth_tot_up[i]= ++valid_ofs;
- }
- else {
- valid_last= depth_arr[i];
- valid_ofs= 0;
- }
- }
-
- valid_last= FLT_MAX;
- valid_ofs= 0;
-
- for (i=gpd->sbuffer_size-1; i >= 0; i--) {
- if(depth_arr[i] == FLT_MAX) {
- depth_arr_down[i]= valid_last;
- depth_tot_down[i]= ++valid_ofs;
- }
- else {
- valid_last= depth_arr[i];
- valid_ofs= 0;
- }
- }
-
- /* now blend */
- for (i=0; i < gpd->sbuffer_size; i++) {
- if(depth_arr[i] == FLT_MAX) {
- if(depth_arr_up[i] != FLT_MAX && depth_arr_down[i] != FLT_MAX) {
- depth_arr[i]= ((depth_arr_up[i] * depth_tot_down[i]) + (depth_arr_down[i] * depth_tot_up[i])) / (float)(depth_tot_down[i] + depth_tot_up[i]);
- } else if (depth_arr_up[i] != FLT_MAX) {
- depth_arr[i]= depth_arr_up[i];
- } else if (depth_arr_down[i] != FLT_MAX) {
- depth_arr[i]= depth_arr_down[i];
- }
- }
- }
-
- MEM_freeN(depth_arr_up);
- MEM_freeN(depth_arr_down);
-
- MEM_freeN(depth_tot_up);
- MEM_freeN(depth_tot_down);
+ interp_sparse_array(depth_arr, gpd->sbuffer_size, FLT_MAX);
}
}