Revision: 48944
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48944
Author:   campbellbarton
Date:     2012-07-15 16:16:34 +0000 (Sun, 15 Jul 2012)
Log Message:
-----------
moving mask rasterizer file, this breaks building, will fix next commit

Added Paths:
-----------
    trunk/blender/source/blender/maskraster/maskraster.c

Removed Paths:
-------------
    trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c

Deleted: trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c     
2012-07-15 16:11:27 UTC (rev 48943)
+++ trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c     
2012-07-15 16:16:34 UTC (rev 48944)
@@ -1,1032 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2012 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation,
- *                 Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenkernel/intern/mask_rasterize.c
- *  \ingroup bke
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_vec_types.h"
-#include "DNA_mask_types.h"
-#include "DNA_scene_types.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_scanfill.h"
-#include "BLI_memarena.h"
-
-#include "BLI_math.h"
-#include "BLI_rect.h"
-#include "BLI_listbase.h"
-#include "BLI_linklist.h"
-
-#include "BKE_mask.h"
-
-#ifndef USE_RASKTER
-
-#define SPLINE_RESOL_CAP 32
-#define SPLINE_RESOL 32
-#define BUCKET_PIXELS_PER_CELL 8
-
-#define SF_EDGE_IS_BOUNDARY 0xff
-#define SF_KEYINDEX_TEMP_ID ((unsigned int) -1)
-
-#define TRI_TERMINATOR_ID   ((unsigned int) -1)
-#define TRI_VERT            ((unsigned int) -1)
-
-
-/* --------------------------------------------------------------------- */
-/* local structs for mask rasterizeing                                   */
-/* --------------------------------------------------------------------- */
-
-/**
- * A single #MaskRasterHandle contains multile #MaskRasterLayer's,
- * each #MaskRasterLayer does its own lookup which contributes to
- * the final pixel with its own blending mode and the final pixel
- * is blended between these.
- */
-
-/* internal use only */
-typedef struct MaskRasterLayer {
-       /* geometry */
-       unsigned int   face_tot;
-       unsigned int (*face_array)[4];  /* access coords tri/quad */
-       float        (*face_coords)[3]; /* xy, z 0-1 (1.0 == filled) */
-
-
-       /* 2d bounds (to quickly skip bucket lookup) */
-       rctf bounds;
-
-
-       /* buckets */
-       unsigned int **buckets_face;
-       /* cache divide and subtract */
-       float buckets_xy_scalar[2]; /* (1.0 / (buckets_width + FLT_EPSILON)) * 
buckets_x */
-       unsigned int buckets_x;
-       unsigned int buckets_y;
-
-
-       /* copied direct from #MaskLayer.--- */
-       /* blending options */
-       float  alpha;
-       char   blend;
-       char   blend_flag;
-       char   falloff;
-
-} MaskRasterLayer;
-
-typedef struct MaskRasterSplineInfo {
-       unsigned int vertex_offset;
-       unsigned int vertex_total;
-       unsigned int is_cyclic;
-} MaskRasterSplineInfo;
-
-/**
- * opaque local struct for mask pixel lookup, each MaskLayer needs one of these
- */
-struct MaskRasterHandle {
-       MaskRasterLayer *layers;
-       unsigned int     layers_tot;
-
-       /* 2d bounds (to quickly skip bucket lookup) */
-       rctf bounds;
-};
-
-/* --------------------------------------------------------------------- */
-/* alloc / free functions                                                */
-/* --------------------------------------------------------------------- */
-
-MaskRasterHandle *BLI_maskrasterize_handle_new(void)
-{
-       MaskRasterHandle *mr_handle;
-
-       mr_handle = MEM_callocN(sizeof(MaskRasterHandle), 
STRINGIFY(MaskRasterHandle));
-
-       return mr_handle;
-}
-
-void BLI_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
-{
-       const unsigned int layers_tot = mr_handle->layers_tot;
-       unsigned int i;
-       MaskRasterLayer *layer = mr_handle->layers;
-
-       /* raycast vars */
-       for (i = 0; i < layers_tot; i++, layer++) {
-
-               if (layer->face_array) {
-                       MEM_freeN(layer->face_array);
-               }
-
-               if (layer->face_coords) {
-                       MEM_freeN(layer->face_coords);
-               }
-
-               if (layer->buckets_face) {
-                       const unsigned int   bucket_tot = layer->buckets_x * 
layer->buckets_y;
-                       unsigned int bucket_index;
-                       for (bucket_index = 0; bucket_index < bucket_tot; 
bucket_index++) {
-                               unsigned int *face_index = 
layer->buckets_face[bucket_index];
-                               if (face_index) {
-                                       MEM_freeN(face_index);
-                               }
-                       }
-
-                       MEM_freeN(layer->buckets_face);
-               }
-       }
-
-       MEM_freeN(mr_handle->layers);
-       MEM_freeN(mr_handle);
-}
-
-
-void maskrasterize_spline_differentiate_point_outset(float 
(*diff_feather_points)[2], float (*diff_points)[2],
-                                                     const unsigned int 
tot_diff_point, const float ofs,
-                                                     const short do_test)
-{
-       unsigned int k_prev = tot_diff_point - 2;
-       unsigned int k_curr = tot_diff_point - 1;
-       unsigned int k_next = 0;
-
-       unsigned int k;
-
-       float d_prev[2];
-       float d_next[2];
-       float d[2];
-
-       const float *co_prev;
-       const float *co_curr;
-       const float *co_next;
-
-       const float ofs_squared = ofs * ofs;
-
-       co_prev = diff_points[k_prev];
-       co_curr = diff_points[k_curr];
-       co_next = diff_points[k_next];
-
-       /* precalc */
-       sub_v2_v2v2(d_prev, co_prev, co_curr);
-       normalize_v2(d_prev);
-
-       for (k = 0; k < tot_diff_point; k++) {
-
-               /* co_prev = diff_points[k_prev]; */ /* precalc */
-               co_curr = diff_points[k_curr];
-               co_next = diff_points[k_next];
-
-               /* sub_v2_v2v2(d_prev, co_prev, co_curr); */ /* precalc */
-               sub_v2_v2v2(d_next, co_curr, co_next);
-
-               /* normalize_v2(d_prev); */ /* precalc */
-               normalize_v2(d_next);
-
-               if ((do_test == FALSE) ||
-                   (len_squared_v2v2(diff_feather_points[k], diff_points[k]) < 
ofs_squared))
-               {
-
-                       add_v2_v2v2(d, d_prev, d_next);
-
-                       normalize_v2(d);
-
-                       diff_feather_points[k][0] = diff_points[k][0] + ( d[1] 
* ofs);
-                       diff_feather_points[k][1] = diff_points[k][1] + (-d[0] 
* ofs);
-               }
-
-               /* use next iter */
-               copy_v2_v2(d_prev, d_next);
-
-               /* k_prev = k_curr; */ /* precalc */
-               k_curr = k_next;
-               k_next++;
-       }
-}
-
-/* this function is not exact, sometimes it retuns false positives,
- * the main point of it is to clear out _almost_ all bucket/face 
non-intersections,
- * returning TRUE in corner cases is ok but missing an intersection is NOT.
- *
- * method used
- * - check if the center of the buckets bounding box is intersecting the face
- * - if not get the max radius to a corner of the bucket and see how close we
- *   are to any of the triangle edges.
- */
-static int layer_bucket_isect_test(MaskRasterLayer *layer, unsigned int 
face_index,
-                                   const unsigned int bucket_x, const unsigned 
int bucket_y,
-                                   const float bucket_size_x, const float 
bucket_size_y,
-                                   const float bucket_max_rad_squared)
-{
-       unsigned int *face = layer->face_array[face_index];
-       float (*cos)[3] = layer->face_coords;
-
-       const float xmin = layer->bounds.xmin + (bucket_size_x * bucket_x);
-       const float ymin = layer->bounds.ymin + (bucket_size_y * bucket_y);
-       const float xmax = xmin + bucket_size_x;
-       const float ymax = ymin + bucket_size_y;
-
-       const float cent[2] = {(xmin + xmax) * 0.5f,
-                              (ymin + ymax) * 0.5f};
-
-       if (face[3] == TRI_VERT) {
-               const float *v1 = cos[face[0]];
-               const float *v2 = cos[face[1]];
-               const float *v3 = cos[face[2]];
-
-               if (isect_point_tri_v2(cent, v1, v2, v3)) {
-                       return TRUE;
-               }
-               else {
-                       if ((dist_squared_to_line_segment_v2(cent, v1, v2) < 
bucket_max_rad_squared) ||
-                               (dist_squared_to_line_segment_v2(cent, v2, v3) 
< bucket_max_rad_squared) ||
-                               (dist_squared_to_line_segment_v2(cent, v3, v1) 
< bucket_max_rad_squared))
-                       {
-                               return TRUE;
-                       }
-                       else {
-                               // printf("skip tri\n");
-                               return FALSE;
-                       }
-               }
-
-       }
-       else {
-               const float *v1 = cos[face[0]];
-               const float *v2 = cos[face[1]];
-               const float *v3 = cos[face[2]];
-               const float *v4 = cos[face[3]];
-
-               if (isect_point_tri_v2(cent, v1, v2, v3)) {
-                       return TRUE;
-               }
-               else if (isect_point_tri_v2(cent, v1, v3, v4)) {
-                       return TRUE;
-               }
-               else {
-                       if ((dist_squared_to_line_segment_v2(cent, v1, v2) < 
bucket_max_rad_squared) ||
-                           (dist_squared_to_line_segment_v2(cent, v2, v3) < 
bucket_max_rad_squared) ||
-                           (dist_squared_to_line_segment_v2(cent, v3, v4) < 
bucket_max_rad_squared) ||
-                           (dist_squared_to_line_segment_v2(cent, v4, v1) < 
bucket_max_rad_squared))
-                       {
-                               return TRUE;
-                       }
-                       else {
-                               // printf("skip quad\n");
-                               return FALSE;
-                       }
-               }
-       }
-}
-
-static void layer_bucket_init_dummy(MaskRasterLayer *layer)
-{
-       layer->buckets_x = 0;
-       layer->buckets_y = 0;
-
-       layer->buckets_xy_scalar[0] = 0.0f;
-       layer->buckets_xy_scalar[1] = 0.0f;
-
-       layer->buckets_face = NULL;
-}
-
-static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
-{
-       MemArena *arena = BLI_memarena_new(1 << 16, __func__);
-
-       const float bucket_dim_x = layer->bounds.xmax - layer->bounds.xmin;
-       const float bucket_dim_y = layer->bounds.ymax - layer->bounds.ymin;
-
-       layer->buckets_x = (bucket_dim_x / pixel_size) / 
(float)BUCKET_PIXELS_PER_CELL;
-       layer->buckets_y = (bucket_dim_y / pixel_size) / 
(float)BUCKET_PIXELS_PER_CELL;
-
-//             printf("bucket size %ux%u\n", layer->buckets_x, 
layer->buckets_y);
-
-       CLAMP(layer->buckets_x, 8, 512);
-       CLAMP(layer->buckets_y, 8, 512);
-
-       layer->buckets_xy_scalar[0] = (1.0f / (bucket_dim_x + FLT_EPSILON)) * 
layer->buckets_x;
-       layer->buckets_xy_scalar[1] = (1.0f / (bucket_dim_y + FLT_EPSILON)) * 
layer->buckets_y;
-
-       {
-               /* width and height of each bucket */
-               const float bucket_size_x = (bucket_dim_x + FLT_EPSILON) / 
layer->buckets_x;
-               const float bucket_size_y = (bucket_dim_y + FLT_EPSILON) / 
layer->buckets_y;
-               const float bucket_max_rad = (maxf(bucket_size_x, 
bucket_size_y) * M_SQRT2) + FLT_EPSILON;
-               const float bucket_max_rad_squared = bucket_max_rad * 
bucket_max_rad;
-
-               unsigned int *face = &layer->face_array[0][0];
-               float (*cos)[3] = layer->face_coords;
-

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to