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...
This commit is contained in:
Joshua Leung 2009-08-26 12:01:15 +00:00
parent adcb21b1f4
commit 043ad7bc8e
11 changed files with 1415 additions and 12 deletions

@ -4042,6 +4042,7 @@ static void lib_link_scene(FileData *fd, Main *main)
sce->world= newlibadr_us(fd, sce->id.lib, sce->world); sce->world= newlibadr_us(fd, sce->id.lib, sce->world);
sce->set= newlibadr(fd, sce->id.lib, sce->set); sce->set= newlibadr(fd, sce->id.lib, sce->set);
sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima); 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->sculpt->paint);
link_paint(fd, sce, &sce->toolsettings->vpaint->paint); link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
@ -10547,6 +10548,9 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
if(sce->r.dometext) if(sce->r.dometext)
expand_doit(fd, mainvar, sce->gm.dome.warptext); 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) static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)

@ -933,7 +933,7 @@ void draw_gpencil_2dimage (bContext *C, ImBuf *ibuf)
/* check that we have grease-pencil stuff to draw */ /* check that we have grease-pencil stuff to draw */
if (ELEM(NULL, sa, ibuf)) return; if (ELEM(NULL, sa, ibuf)) return;
gpd= gpencil_data_getactive(sa); gpd= gpencil_data_getactive(C);
if (gpd == NULL) return; if (gpd == NULL) return;
/* calculate rect */ /* calculate rect */
@ -1007,7 +1007,7 @@ void draw_gpencil_2dview (bContext *C, short onlyv2d)
/* check that we have grease-pencil stuff to draw */ /* check that we have grease-pencil stuff to draw */
if (sa == NULL) return; if (sa == NULL) return;
gpd= gpencil_data_getactive(sa); gpd= gpencil_data_getactive(C);
if (gpd == NULL) return; if (gpd == NULL) return;
/* draw it! */ /* draw it! */
@ -1020,14 +1020,13 @@ void draw_gpencil_2dview (bContext *C, short onlyv2d)
*/ */
void draw_gpencil_3dview (bContext *C, short only3d) void draw_gpencil_3dview (bContext *C, short only3d)
{ {
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C); ARegion *ar= CTX_wm_region(C);
Scene *scene= CTX_data_scene(C); Scene *scene= CTX_data_scene(C);
bGPdata *gpd; bGPdata *gpd;
int dflag = 0; int dflag = 0;
/* check that we have grease-pencil stuff to draw */ /* check that we have grease-pencil stuff to draw */
gpd= gpencil_data_getactive(sa); gpd= gpencil_data_getactive(C);
if (gpd == NULL) return; if (gpd == NULL) return;
/* draw it! */ /* draw it! */
@ -1047,7 +1046,7 @@ void draw_gpencil_oglrender (bContext *C)
/* assume gpencil data comes from v3d */ /* assume gpencil data comes from v3d */
if (v3d == NULL) return; if (v3d == NULL) return;
gpd= v3d->gpd; gpd= gpencil_data_getactive(C);
if (gpd == NULL) return; if (gpd == NULL) return;
/* pass 1: draw 3d-strokes ------------ > */ /* pass 1: draw 3d-strokes ------------ > */

@ -25,6 +25,8 @@
* ***** END GPL LICENSE BLOCK ***** * ***** END GPL LICENSE BLOCK *****
*/ */
#if 0 // XXX COMPILE GUARDS FOR OLD CODE
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -1697,3 +1699,4 @@ short gpencil_do_paint (bContext *C)
} }
/* ************************************************** */ /* ************************************************** */
#endif // XXX COMPILE GUARDS FOR OLD CODE

@ -29,8 +29,20 @@
#define ED_GPENCIL_INTERN_H #define ED_GPENCIL_INTERN_H
/* internal exports only */ /* 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... */ /* XXX - TODO: replace this with the modern bAnimListElem... */
/* This struct defines a structure used for quick access */ /* This struct defines a structure used for quick access */

@ -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);
}
/* ****************************************** */

File diff suppressed because it is too large Load Diff

@ -41,7 +41,7 @@ struct bGPDframe;
struct bGPdata; struct bGPdata;
struct uiBlock; struct uiBlock;
struct ImBuf; struct ImBuf;
struct wmWindowManager;
/* ------------- Grease-Pencil Helpers -------------- */ /* ------------- Grease-Pencil Helpers -------------- */
@ -52,9 +52,19 @@ typedef struct tGPspoint {
float pressure; /* pressure of tablet at this point */ float pressure; /* pressure of tablet at this point */
} tGPspoint; } tGPspoint;
/* ----------- Grease Pencil New Tools ------------- */
struct bGPdata *gpencil_data_getactive(struct bContext *C);
/* ----------- Grease Pencil Operators ------------- */
void gpencil_common_keymap(struct wmWindowManager *wm, ListBase *keymap);
void ED_operatortypes_gpencil(void);
/* ------------ Grease-Pencil Depreceated Stuff ------------------ */ /* ------------ Grease-Pencil Depreceated Stuff ------------------ */
struct bGPdata *gpencil_data_getactive(struct ScrArea *sa); //struct bGPdata *gpencil_data_getactive(struct ScrArea *sa);
short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd); short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd);
struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd); struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd);

@ -42,6 +42,7 @@
#include "ED_anim_api.h" #include "ED_anim_api.h"
#include "ED_armature.h" #include "ED_armature.h"
#include "ED_curve.h" #include "ED_curve.h"
#include "ED_gpencil.h"
#include "ED_markers.h" #include "ED_markers.h"
#include "ED_mesh.h" #include "ED_mesh.h"
#include "ED_object.h" #include "ED_object.h"
@ -83,7 +84,7 @@ void ED_spacetypes_init(void)
/* register operator types for screen and all spaces */ /* register operator types for screen and all spaces */
ED_operatortypes_screen(); ED_operatortypes_screen();
ED_operatortypes_anim(); ED_operatortypes_anim();
ED_operatortypes_animchannels(); // XXX have this as part of anim() ones instead? ED_operatortypes_animchannels();
ED_operatortypes_object(); ED_operatortypes_object();
ED_operatortypes_mesh(); ED_operatortypes_mesh();
ED_operatortypes_sculpt(); ED_operatortypes_sculpt();
@ -97,6 +98,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_fluid(); ED_operatortypes_fluid();
ED_operatortypes_metaball(); ED_operatortypes_metaball();
ED_operatortypes_boids(); ED_operatortypes_boids();
ED_operatortypes_gpencil();
ui_view2d_operatortypes(); ui_view2d_operatortypes();

@ -78,6 +78,7 @@
#include "ED_armature.h" #include "ED_armature.h"
#include "ED_keyframing.h" #include "ED_keyframing.h"
#include "ED_gpencil.h"
#include "ED_mesh.h" #include "ED_mesh.h"
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_space_api.h" #include "ED_space_api.h"
@ -2082,8 +2083,8 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
} }
/* draw grease-pencil stuff */ /* draw grease-pencil stuff */
// if (v3d->flag2 & V3D_DISPGP) //if (v3d->flag2 & V3D_DISPGP)
// draw_gpencil_3dview(ar, 1); draw_gpencil_3dview(C, 1);
BDR_drawSketch(C); BDR_drawSketch(C);

@ -52,6 +52,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "ED_gpencil.h"
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_transform.h" #include "ED_transform.h"
@ -131,7 +132,10 @@ void view3d_keymap(wmWindowManager *wm)
WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, 0, 0);
km = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0); km = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(km->ptr, "snap", 1); RNA_boolean_set(km->ptr, "snap", 1);
/* grease pencil */
gpencil_common_keymap(wm, keymap); // XXX
WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, 0, 0); /* manipulator always on left mouse, not on action mouse*/ WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, 0, 0); /* manipulator always on left mouse, not on action mouse*/
WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);

@ -48,6 +48,7 @@ struct bNodeTree;
struct AnimData; struct AnimData;
struct Editing; struct Editing;
struct SceneStats; struct SceneStats;
struct bGPdata;
typedef struct Base { typedef struct Base {
struct Base *next, *prev; struct Base *next, *prev;
@ -718,6 +719,9 @@ typedef struct Scene {
/* Units */ /* Units */
struct UnitSettings unit; struct UnitSettings unit;
/* Grease Pencil */
struct bGPdata *gpd;
} Scene; } Scene;