[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22802] branches/blender2.5/blender/source /blender: 2.5 - Grease Pencil Version 2 (Crude rebirth)

Joshua Leung aligorith at gmail.com
Wed Aug 26 14:01:15 CEST 2009


Revision: 22802
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22802
Author:   aligorith
Date:     2009-08-26 14:01:15 +0200 (Wed, 26 Aug 2009)

Log Message:
-----------
2.5 - Grease Pencil Version 2 (Crude rebirth)

This commit is the start of the new Grease Pencil implementation. I've just ported the old code to make it work with operators, and to store its data in Grease-Pencil datablocks.

However, this is currently still really buggy, with only the barebones of the drawing/creation tools restored (no UI panels, no options). To use (not recommended), use D+S+move_mouse (and click when finished) for now. There are some rather serious event handling errors going on here... 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_edit.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_intern.h
    branches/blender2.5/blender/source/blender/editors/include/ED_gpencil.h
    branches/blender2.5/blender/source/blender/editors/space_api/spacetypes.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_draw.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_ops.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-26 10:35:42 UTC (rev 22801)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-26 12:01:15 UTC (rev 22802)
@@ -4042,6 +4042,7 @@
 			sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
 			sce->set= newlibadr(fd, sce->id.lib, sce->set);
 			sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima);
+			sce->gpd= newlibadr_us(fd, sce->id.lib, sce->gpd);
 			
 			link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
 			link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
@@ -10547,6 +10548,9 @@
 
 	if(sce->r.dometext)
 		expand_doit(fd, mainvar, sce->gm.dome.warptext);
+		
+	if(sce->gpd)
+		expand_doit(fd, mainvar, sce->gpd);
 }
 
 static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-26 10:35:42 UTC (rev 22801)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-26 12:01:15 UTC (rev 22802)
@@ -933,7 +933,7 @@
 	
 	/* check that we have grease-pencil stuff to draw */
 	if (ELEM(NULL, sa, ibuf)) return;
-	gpd= gpencil_data_getactive(sa);
+	gpd= gpencil_data_getactive(C);
 	if (gpd == NULL) return;
 	
 	/* calculate rect */
@@ -1007,7 +1007,7 @@
 	
 	/* check that we have grease-pencil stuff to draw */
 	if (sa == NULL) return;
-	gpd= gpencil_data_getactive(sa);
+	gpd= gpencil_data_getactive(C);
 	if (gpd == NULL) return;
 	
 	/* draw it! */
@@ -1020,14 +1020,13 @@
  */
 void draw_gpencil_3dview (bContext *C, short only3d)
 {
-	ScrArea *sa= CTX_wm_area(C);
 	ARegion *ar= CTX_wm_region(C);
 	Scene *scene= CTX_data_scene(C);
 	bGPdata *gpd;
 	int dflag = 0;
 	
 	/* check that we have grease-pencil stuff to draw */
-	gpd= gpencil_data_getactive(sa);
+	gpd= gpencil_data_getactive(C);
 	if (gpd == NULL) return;
 	
 	/* draw it! */
@@ -1047,7 +1046,7 @@
 	
 	/* assume gpencil data comes from v3d */
 	if (v3d == NULL) return;
-	gpd= v3d->gpd;
+	gpd= gpencil_data_getactive(C);
 	if (gpd == NULL) return;
 	
 	/* pass 1: draw 3d-strokes ------------ > */

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_edit.c	2009-08-26 10:35:42 UTC (rev 22801)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_edit.c	2009-08-26 12:01:15 UTC (rev 22802)
@@ -25,6 +25,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
  
+#if 0 // XXX COMPILE GUARDS FOR OLD CODE
+ 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -1697,3 +1699,4 @@
 }
 
 /* ************************************************** */
+#endif // XXX COMPILE GUARDS FOR OLD CODE

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_intern.h	2009-08-26 10:35:42 UTC (rev 22801)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_intern.h	2009-08-26 12:01:15 UTC (rev 22802)
@@ -29,8 +29,20 @@
 #define ED_GPENCIL_INTERN_H
 
 /* internal exports only */
+
+
+/* ***************************************************** */
+/* Operator Defines */
+
+struct wmOperatorType;
+
+/* drawing ---------- */
+
+void GPENCIL_OT_draw(struct wmOperatorType *ot);
+
+
 /******************************************************* */
-/* FILTERED ACTION DATA - TYPES */
+/* FILTERED ACTION DATA - TYPES  ---> XXX DEPRECEATED OLD ANIM SYSTEM CODE! */
 
 /* XXX - TODO: replace this with the modern bAnimListElem... */
 /* This struct defines a structure used for quick access */

Added: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_ops.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_ops.c	2009-08-26 12:01:15 UTC (rev 22802)
@@ -0,0 +1,68 @@
+/**
+ * $Id: gpencil_ops.c 21617 2009-07-16 04:45:52Z aligorith $
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung
+ * This is a new part of Blender
+ *
+ * Contributor(s): Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include "BLI_blenlib.h"
+
+#include "DNA_windowmanager_types.h" 
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "gpencil_intern.h"
+
+/* ****************************************** */
+/* Generic Editing Keymap */
+
+void gpencil_common_keymap(wmWindowManager *wm, ListBase *keymap)
+{
+	wmKeymapItem *km;
+	
+	/* if no keymap provided, use default */
+	if (keymap == NULL)
+		keymap= WM_keymap_listbase(wm, "Grease Pencil Generic", 0, 0);
+	
+	/* Draw */
+	WM_keymap_add_item(keymap, "GPENCIL_OT_draw", SKEY, KM_PRESS, 0, DKEY);
+}
+
+/* ****************************************** */
+
+void ED_operatortypes_gpencil (void)
+{
+	/* Drawing ----------------------- */
+	WM_operatortype_append(GPENCIL_OT_draw);
+}
+
+/* ****************************************** */


Property changes on: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_ops.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c	2009-08-26 12:01:15 UTC (rev 22802)
@@ -0,0 +1,1296 @@
+/* Grease Pencil  - version 2
+ * By Joshua Leung
+ */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "BKE_gpencil.h"
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_report.h"
+#include "BKE_utildefines.h"
+
+#include "DNA_gpencil_types.h"
+#include "DNA_action_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_view2d_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "UI_view2d.h"
+
+#include "ED_armature.h"
+#include "ED_gpencil.h"
+#include "ED_sequencer.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "gpencil_intern.h"
+
+/* ******************************************* */
+/* Context Wrangling... */
+
+/* Get the active Grease Pencil datablock */
+// TODO: move this to a gpencil_utils.c? 
+bGPdata *gpencil_data_getactive (bContext *C)
+{
+	Scene *scene= CTX_data_scene(C);
+	ScrArea *sa= CTX_wm_area(C);
+	
+	/* if there's an active area, check if the particular editor may
+	 * have defined any special Grease Pencil context for editing...
+	 */
+	if (sa) {
+		switch (sa->spacetype) {
+			case SPACE_VIEW3D: /* 3D-View */
+			{
+				Object *ob= CTX_data_active_object(C);
+				
+				/* just in case... */
+				if (ob) {
+					/* depending on the mode of the object, we may be able to get some GP data 
+					 * from different elements - i.e. bones...
+					 */
+					if (ob->mode & OB_MODE_POSE) {
+						//bPoseChannel *pchan= CTX_data_active_pchan(C);
+						
+						/* if posechannel has GP data, use that... */
+						//if (pchan && pchan->gpd)
+						//	return pchan->gpd;
+					}
+					
+					/* still here, so check if active Object has GP data */
+					//if (ob->gpd)
+					//	return ob->gpd;
+				}
+			}
+				break;
+			
+			case SPACE_NODE: /* Nodes Editor */
+			{
+				//SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
+				
+				/* return the GP data for the active node block/node */
+			}
+				break;
+				
+			case SPACE_SEQ: /* Sequencer */
+			{
+				//SpaceSeq *sseq= (SpaceSeq *)CTX_wm_space_data(C);
+				
+				/* return the GP data for the active strips/image/etc. */
+			}
+				break;
+		}
+	}
+	
+	/* just fall back on the scene's GP data */
+	return (scene) ? scene->gpd : NULL;
+}
+
+
+/* check if context is suitable for drawing */
+static int gpencil_draw_poll (bContext *C)
+{
+	// TODO: must check context for Grease Pencil data...
+	return 1;
+}
+
+/* ******************************************* */
+/* 'Globals' and Defines */
+
+/* Temporary 'Stroke' Operation data */
+typedef struct tGPsdata {
+	Scene *scene;       /* current scene from context */
+	ScrArea *sa;		/* area where painting originated */
+	ARegion *ar;        /* region where painting originated */
+	View2D *v2d;		/* needed for GP_STROKE_2DSPACE */
+	
+#if 0 // XXX review this 2d image stuff...
+	ImBuf *ibuf;		/* needed for GP_STROKE_2DIMAGE */
+	struct IBufViewSettings {
+		int offsx, offsy;			/* offsets */
+		int sizex, sizey;			/* dimensions to use as scale-factor */
+	} im2d_settings;	/* needed for GP_STROKE_2DIMAGE */
+#endif
+	
+	bGPdata *gpd;		/* gp-datablock layer comes from */
+	bGPDlayer *gpl;		/* layer we're working on */
+	bGPDframe *gpf;		/* frame we're working on */
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list