[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46098] branches/soc-2011-tomato: Tomato: initial commit of mask editing tools into SVN

Sergey Sharybin sergey.vfx at gmail.com
Mon Apr 30 09:43:21 CEST 2012


Revision: 46098
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46098
Author:   nazgul
Date:     2012-04-30 07:43:21 +0000 (Mon, 30 Apr 2012)
Log Message:
-----------
Tomato: initial commit of mask editing tools into SVN

- Added new dtaablock called Mask which might be re-used in any area.
  Currently editing of masks happens in clip editor and they might be used in
  compositor nodes only.
- Added new mode to clip clip editor to interact with masks.
  Implemented basic tools to create shapes, splines and points. Also implemented
  idea of UW points for feather which means feather points are have got U
  coordinate along spline (which is measured from 0 to 1) and W is it's weight
  meaning distance from main spline.
- Spline points might be parented to movie tracks.
  Interface for this isn't best yet.
- Rasterisaztion of masks happens in compositor node (Input -> Mask)
  Input image of this ode is used as reference for mask resolution.
  Currently all splines of all shapes are rasterizing independently which
  means shapes with holes are not supported.
  Also feather rasterization is not implemented.

  Rasterized was implemented by Pete Larbell, thanks!

Do not consider this is something finished, there's still lots of things to
be done (especially from interface and usability points of view).

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/CMakeLists.txt
    branches/soc-2011-tomato/intern/SConscript
    branches/soc-2011-tomato/release/scripts/modules/bpy_extras/keyconfig_utils.py
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_context.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_library.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_main.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
    branches/soc-2011-tomato/source/blender/blenkernel/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/blenkernel/intern/context.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/idcode.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/library.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/scene.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/writefile.c
    branches/soc-2011-tomato/source/blender/editors/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/editors/SConscript
    branches/soc-2011-tomato/source/blender/editors/include/ED_clip.h
    branches/soc-2011-tomato/source/blender/editors/include/ED_screen.h
    branches/soc-2011-tomato/source/blender/editors/include/ED_transform.h
    branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
    branches/soc-2011-tomato/source/blender/editors/screen/screen_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_api/spacetypes.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
    branches/soc-2011-tomato/source/blender/editors/space_node/space_node.c
    branches/soc-2011-tomato/source/blender/editors/transform/transform.c
    branches/soc-2011-tomato/source/blender/editors/transform/transform.h
    branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c
    branches/soc-2011-tomato/source/blender/editors/transform/transform_generics.c
    branches/soc-2011-tomato/source/blender/editors/transform/transform_ops.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_ID.h
    branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
    branches/soc-2011-tomato/source/blender/makesdna/intern/makesdna.c
    branches/soc-2011-tomato/source/blender/makesrna/RNA_access.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/makesrna/intern/makesrna.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_ID.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_internal.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_main.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_main_api.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
    branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/nodes/NOD_composite.h
    branches/soc-2011-tomato/source/blender/nodes/composite/node_composite_tree.c
    branches/soc-2011-tomato/source/blender/windowmanager/WM_types.h
    branches/soc-2011-tomato/source/blenderplayer/CMakeLists.txt
    branches/soc-2011-tomato/source/blenderplayer/bad_level_call_stubs/stubs.c
    branches/soc-2011-tomato/source/creator/CMakeLists.txt

Added Paths:
-----------
    branches/soc-2011-tomato/intern/raskter/
    branches/soc-2011-tomato/intern/raskter/CMakeLists.txt
    branches/soc-2011-tomato/intern/raskter/SConscript
    branches/soc-2011-tomato/intern/raskter/raskter.c
    branches/soc-2011-tomato/intern/raskter/raskter.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
    branches/soc-2011-tomato/source/blender/editors/include/ED_mask.h
    branches/soc-2011-tomato/source/blender/editors/mask/
    branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/editors/mask/SConscript
    branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
    branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
    branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
    branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_mask_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_mask.c
    branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_mask.c

Modified: branches/soc-2011-tomato/intern/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/intern/CMakeLists.txt	2012-04-30 07:43:04 UTC (rev 46097)
+++ branches/soc-2011-tomato/intern/CMakeLists.txt	2012-04-30 07:43:21 UTC (rev 46098)
@@ -31,6 +31,7 @@
 add_subdirectory(iksolver)
 add_subdirectory(opennl)
 add_subdirectory(mikktspace)
+add_subdirectory(raskter)
 
 if(WITH_AUDASPACE)
 	add_subdirectory(audaspace)

Modified: branches/soc-2011-tomato/intern/SConscript
===================================================================
--- branches/soc-2011-tomato/intern/SConscript	2012-04-30 07:43:04 UTC (rev 46097)
+++ branches/soc-2011-tomato/intern/SConscript	2012-04-30 07:43:21 UTC (rev 46098)
@@ -14,7 +14,8 @@
             'boolop/SConscript',
             'opennl/SConscript',
             'mikktspace/SConscript',
-            'smoke/SConscript'])
+            'smoke/SConscript',
+            'raskter/SConscript'])
 
 # NEW_CSG was intended for intern/csg, but
 # getting it to compile is difficult

Added: branches/soc-2011-tomato/intern/raskter/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/intern/raskter/CMakeLists.txt	                        (rev 0)
+++ branches/soc-2011-tomato/intern/raskter/CMakeLists.txt	2012-04-30 07:43:21 UTC (rev 46098)
@@ -0,0 +1,40 @@
+# ***** 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.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Peter Larabell
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+)
+
+set(INC_SYS
+	
+)
+
+set(SRC
+	raskter.c
+
+	raskter.h
+)
+
+blender_add_lib(bf_intern_raskter "${SRC}" "${INC}" "${INC_SYS}")

Added: branches/soc-2011-tomato/intern/raskter/SConscript
===================================================================
--- branches/soc-2011-tomato/intern/raskter/SConscript	                        (rev 0)
+++ branches/soc-2011-tomato/intern/raskter/SConscript	2012-04-30 07:43:21 UTC (rev 46098)
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+Import ('env')
+
+sources = ['raskter.c']
+
+incs = ''
+defs = ''
+
+env.BlenderLib ('bf_intern_raskter', sources, Split(incs), Split(defs), libtype=['intern'], priority=[100] )

Added: branches/soc-2011-tomato/intern/raskter/raskter.c
===================================================================
--- branches/soc-2011-tomato/intern/raskter/raskter.c	                        (rev 0)
+++ branches/soc-2011-tomato/intern/raskter/raskter.c	2012-04-30 07:43:21 UTC (rev 46098)
@@ -0,0 +1,367 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Peter Larabell.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+/** \file raskter.c
+ *  \ingroup RASKTER
+ */
+
+#include <malloc.h>
+#include "raskter.h"
+
+#define R_XCHG(a,b)	t=a;a=b;b=t;
+
+struct e_status {
+	int x;
+	int ybeg;
+	int xshift;
+	int xdir;
+	int drift;
+	int drift_inc;
+	int drift_dec;
+	int num;
+	struct e_status *e_next;
+};
+
+struct r_buffer_stats {
+	float *buf;
+	int sizex;
+	int sizey;
+};
+
+static struct e_status *all_edges, *possible_edges;
+static struct r_buffer_stats rb;
+/*
+ * Sort all the edges of the input polygon by Y, then by X, of the "first" vertex encountered.
+ * This will ensure we can scan convert the entire poly in one pass.
+ *
+ * Really the poly should be clipped to the frame buffer's dimensions here for speed of drawing
+ * just the poly. Since the DEM code could end up being coupled with this, we'll keep it separate
+ * for now.
+ */
+static void preprocess_all_edges(struct poly_vert * verts, int num_verts, struct e_status * open_edge) {
+	int i;
+	int xbeg;
+	int ybeg;
+	int xend;
+	int yend;
+	int dx;
+	int dy;
+	int t;
+	int xdist;
+	struct e_status *e_new;
+	struct e_status *next_edge;
+	struct e_status **next_edge_ref;
+	struct poly_vert *v;
+	// set up pointers
+	v = verts;
+	all_edges = NULL;
+	// loop all verts
+	for(i = 0; i < num_verts; i++) {
+		xbeg = v[i].x;
+		ybeg = v[i].y;
+		// determine starts and ends of edges, linking last vertex to first vertex
+		if(i == 0) {
+			xend = v[num_verts-1].x;
+			yend = v[num_verts-1].y;
+		} else {
+			xend = v[i-1].x;
+			yend = v[i-1].y;
+		}
+		// make sure our edges are facing the correct direction
+		if(ybeg > yend) {
+			R_XCHG(xbeg, xend);
+			R_XCHG(ybeg, yend);
+		}
+		// create the edge and determine it's slope (for incremental line drawing)
+		if((dy = yend - ybeg) != 0) {
+			e_new = open_edge++;
+			e_new->xdir = ((dx = xend - xbeg) > 0) ? 1 : -1;
+			xdist = (dx > 0) ? dx : -dx;
+			e_new->x = xbeg;
+			e_new->ybeg = ybeg;
+			e_new->num = dy;
+			e_new->drift_dec = dy;
+			if(dx >= 0) {
+				e_new->drift = 0;
+			} else {
+				e_new->drift = -dy + 1;
+			}
+			// calculate deltas for drawing
+			if(dy >= xdist) {
+				e_new->drift_inc = xdist;
+				e_new->xshift = 0;
+			} else {
+				e_new->drift_inc = xdist % dy;
+				e_new->xshift = (xdist / dy) * e_new->xdir;
+			}
+			next_edge_ref = &all_edges;
+			// link in all the edges, in sorted order
+			for(;;) {
+				next_edge = *next_edge_ref;
+				if((next_edge == NULL) || (next_edge->ybeg > ybeg) || ((next_edge->ybeg == ybeg) && (next_edge->x >= xbeg))) {
+					e_new->e_next = next_edge;
+					*next_edge_ref = e_new;
+					break;
+				}
+				next_edge_ref = &next_edge->e_next;
+			}
+		}
+	}
+}
+
+/*
+ * This function clips drawing to the frame buffer. That clipping will likely be moved into the preprocessor
+ * for speed, but waiting on final design choices for curve-data before eliminating data the DEM code will need
+ * if it ends up being coupled with this function.
+ */
+int rast_scan_fill(struct poly_vert * verts, int num_verts) {
+	int x_curr;					// current pixel position in X
+	int y_curr;					// current scan line being drawn
+	int yp;						// y-pixel's position in frame buffer
+	int swixd = 0;				// whether or not edges switched position in X
+	float *cpxl;				// pixel pointers...
+	float *mpxl;
+	float *spxl;
+	struct e_status *e_curr;	// edge pointers...
+	struct e_status *e_temp;
+	struct e_status *edgbuf;
+	struct e_status **edgec;
+
+
+	/*
+	  If the number of verts specified to render as a polygon is less than 3,
+	  return immediately. Obviously we cant render a poly with sides < 3. The
+	  return for this we set to 1, simply so it can be distinguished from the
+	  next place we could return, which is a failure to allocate memory.
+	 */
+	if(num_verts < 3) {
+		return(1);
+	}
+
+	/*
+	  Try to allocate an edge buffer in memory. needs to be the size of the edge tracking data
+	  multiplied by the number of edges, which is always equal to the number of verts in
+	  a 2D polygon. Here we return 0 to indicate a memory allocation failure, as opposed to a 1 for
+	  the preceeding error, which was a rasterization request on a 2D poly with less than
+	  3 sides.
+	 */
+	if((edgbuf = (struct e_status *)(malloc(sizeof(struct e_status) * num_verts))) == NULL) {
+		return(0);
+	}
+
+	/*
+	  Do some preprocessing on all edges. This constructs a table structure in memory of all
+	  the edge properties and can "flip" some edges so sorting works correctly.
+	 */
+	preprocess_all_edges(verts, num_verts, edgbuf);
+
+	/*
+	  Set the pointer for tracking the edges currently in processing to NULL to make sure
+	  we don't get some crazy value after initialization.
+	 */
+	possible_edges = NULL;
+
+	/*
+	  Loop through all scan lines to be drawn. Since we sorted by Y values during
+	  preprocess_all_edges(), we can already exact values for the lowest and
+	  highest Y values we could possibly need by induction. The preprocessing sorted
+	  out edges by Y position, we can cycle the current edge being processed once
+	  it runs out of Y pixels. When we have no more edges, meaning the current edge
+	  is NULL after setting the "current" edge to be the previous current edge's
+	  "next" edge in the Y sorted edge connection chain, we can stop looping Y values,
+	  since we can't possibly have more scan lines if we ran out of edges. :)
+
+	  TODO: This clips Y to the frame buffer, which should be done in the preprocessor, but for now is done here.
+			Will get changed once DEM code gets in.
+	 */
+	for(y_curr = (all_edges->ybeg > 0 ? all_edges->ybeg : 0); ((all_edges != NULL) || (possible_edges != NULL)) && (y_curr < rb.sizey); y_curr++) {
+
+		/*
+		  Link any edges that start on the current scan line into the list of
+		  edges currently needed to draw at least this, if not several, scan lines.
+		 */
+
+		/*
+		  Set the current edge to the beginning of the list of edges to be rasterized
+		  into this scan line.
+
+		  We could have lots of edge here, so iterate over all the edges needed. The
+		  preprocess_all_edges() function sorted edges by X within each chunk of Y sorting
+		  so we safely cycle edges to thier own "next" edges in order.
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list