2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-04-20 10:20:18 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-04-20 10:20:18 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008, Blender Foundation
|
|
|
|
|
* This is a new part of Blender
|
|
|
|
|
*
|
2016-08-03 23:31:48 +02:00
|
|
|
* Contributor(s): Joshua Leung, Antonio Vazquez
|
2009-04-20 10:20:18 +00:00
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
2011-02-27 20:40:57 +00:00
|
|
|
|
|
|
|
|
/** \file blender/blenkernel/intern/gpencil.c
|
|
|
|
|
* \ingroup bke
|
|
|
|
|
*/
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2013-11-06 10:59:05 +00:00
|
|
|
#include "BLI_math_vector.h"
|
2017-01-16 17:33:34 +01:00
|
|
|
#include "BLI_string_utils.h"
|
2009-04-20 10:20:18 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
#include "DNA_gpencil_types.h"
|
2013-09-28 19:28:41 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2016-08-03 23:31:48 +02:00
|
|
|
#include "DNA_scene_types.h"
|
2009-04-20 10:20:18 +00:00
|
|
|
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
#include "BKE_animsys.h"
|
2009-04-20 10:20:18 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_gpencil.h"
|
2016-08-03 23:31:48 +02:00
|
|
|
#include "BKE_colortools.h"
|
2009-04-20 10:20:18 +00:00
|
|
|
#include "BKE_library.h"
|
2016-07-10 14:52:00 +02:00
|
|
|
#include "BKE_main.h"
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************** */
|
|
|
|
|
/* GENERAL STUFF */
|
|
|
|
|
|
|
|
|
|
/* --------- Memory Management ------------ */
|
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
/* free stroke, doesn't unlink from any listbase */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_free_stroke(bGPDstroke *gps)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
if (gps == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free stroke memory arrays, then stroke itself */
|
|
|
|
|
if (gps->points)
|
|
|
|
|
MEM_freeN(gps->points);
|
|
|
|
|
if (gps->triangles)
|
|
|
|
|
MEM_freeN(gps->triangles);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(gps);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* Free strokes belonging to a gp-frame */
|
2016-08-04 15:03:18 +02:00
|
|
|
bool BKE_gpencil_free_strokes(bGPDframe *gpf)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2016-08-03 23:31:48 +02:00
|
|
|
bGPDstroke *gps_next;
|
2014-02-08 06:07:10 +11:00
|
|
|
bool changed = (BLI_listbase_is_empty(&gpf->strokes) == false);
|
2013-12-03 09:22:29 +11:00
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* free strokes */
|
2016-08-03 23:31:48 +02:00
|
|
|
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps_next) {
|
|
|
|
|
gps_next = gps->next;
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_stroke(gps);
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
2016-08-03 23:31:48 +02:00
|
|
|
BLI_listbase_clear(&gpf->strokes);
|
2013-11-25 04:55:26 +01:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
return changed;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free all of a gp-layer's frames */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_free_frames(bGPDlayer *gpl)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2016-08-03 23:31:48 +02:00
|
|
|
bGPDframe *gpf_next;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (gpl == NULL) return;
|
|
|
|
|
|
|
|
|
|
/* free frames */
|
2016-08-03 23:31:48 +02:00
|
|
|
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf_next) {
|
|
|
|
|
gpf_next = gpf->next;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* free strokes and their associated memory */
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_strokes(gpf);
|
2009-04-20 10:20:18 +00:00
|
|
|
BLI_freelinkN(&gpl->frames, gpf);
|
|
|
|
|
}
|
2012-10-07 20:07:30 +00:00
|
|
|
gpl->actframe = NULL;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
/* Free all of a gp-colors */
|
|
|
|
|
static void free_gpencil_colors(bGPDpalette *palette)
|
|
|
|
|
{
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (palette == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free colors */
|
|
|
|
|
BLI_freelistN(&palette->colors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free all of the gp-palettes and colors */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_free_palettes(ListBase *list)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalette *palette_next;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (list == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete palettes */
|
|
|
|
|
for (bGPDpalette *palette = list->first; palette; palette = palette_next) {
|
|
|
|
|
palette_next = palette->next;
|
|
|
|
|
/* free palette colors */
|
|
|
|
|
free_gpencil_colors(palette);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(palette);
|
|
|
|
|
}
|
|
|
|
|
BLI_listbase_clear(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free all of the gp-brushes for a viewport (list should be &gpd->brushes or so) */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_free_brushes(ListBase *list)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDbrush *brush_next;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (list == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete brushes */
|
|
|
|
|
for (bGPDbrush *brush = list->first; brush; brush = brush_next) {
|
|
|
|
|
brush_next = brush->next;
|
|
|
|
|
/* free curves */
|
|
|
|
|
if (brush->cur_sensitivity) {
|
|
|
|
|
curvemapping_free(brush->cur_sensitivity);
|
|
|
|
|
}
|
|
|
|
|
if (brush->cur_strength) {
|
|
|
|
|
curvemapping_free(brush->cur_strength);
|
|
|
|
|
}
|
|
|
|
|
if (brush->cur_jitter) {
|
|
|
|
|
curvemapping_free(brush->cur_jitter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(brush);
|
|
|
|
|
}
|
|
|
|
|
BLI_listbase_clear(list);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* Free all of the gp-layers for a viewport (list should be &gpd->layers or so) */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_free_layers(ListBase *list)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2016-08-03 23:31:48 +02:00
|
|
|
bGPDlayer *gpl_next;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (list == NULL) return;
|
|
|
|
|
|
2012-08-17 14:43:20 +00:00
|
|
|
/* delete layers */
|
2016-08-03 23:31:48 +02:00
|
|
|
for (bGPDlayer *gpl = list->first; gpl; gpl = gpl_next) {
|
|
|
|
|
gpl_next = gpl->next;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* free layers and their data */
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_frames(gpl);
|
2009-04-20 10:20:18 +00:00
|
|
|
BLI_freelinkN(list, gpl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/** Free (or release) any data used by this grease pencil (does not free the gpencil itself). */
|
2016-08-03 23:31:48 +02:00
|
|
|
void BKE_gpencil_free(bGPdata *gpd, bool free_palettes)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
BKE_animdata_free(&gpd->id, false);
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* free layers */
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_layers(&gpd->layers);
|
2016-08-03 23:31:48 +02:00
|
|
|
|
|
|
|
|
/* free palettes */
|
|
|
|
|
if (free_palettes) {
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_palettes(&gpd->palettes);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------- Container Creation ---------- */
|
|
|
|
|
|
|
|
|
|
/* add a new gp-frame to the given layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDframe *BKE_gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2015-04-17 13:32:57 +12:00
|
|
|
bGPDframe *gpf = NULL, *gf = NULL;
|
2012-05-06 15:15:33 +00:00
|
|
|
short state = 0;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
/* error checking */
|
2015-04-17 12:27:27 +12:00
|
|
|
if (gpl == NULL)
|
2009-04-20 10:20:18 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* allocate memory for this frame */
|
2012-05-06 15:15:33 +00:00
|
|
|
gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
|
|
|
|
|
gpf->framenum = cframe;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* find appropriate place to add frame */
|
|
|
|
|
if (gpl->frames.first) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (gf = gpl->frames.first; gf; gf = gf->next) {
|
2009-04-20 10:20:18 +00:00
|
|
|
/* check if frame matches one that is supposed to be added */
|
|
|
|
|
if (gf->framenum == cframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
state = -1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if current frame has already exceeded the frame to add, add before */
|
|
|
|
|
if (gf->framenum > cframe) {
|
|
|
|
|
BLI_insertlinkbefore(&gpl->frames, gf, gpf);
|
2012-05-06 15:15:33 +00:00
|
|
|
state = 1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check whether frame was added successfully */
|
|
|
|
|
if (state == -1) {
|
2015-04-17 13:32:57 +12:00
|
|
|
printf("Error: Frame (%d) existed already for this layer. Using existing frame\n", cframe);
|
|
|
|
|
|
|
|
|
|
/* free the newly created one, and use the old one instead */
|
2009-04-20 10:20:18 +00:00
|
|
|
MEM_freeN(gpf);
|
2015-04-17 13:32:57 +12:00
|
|
|
|
|
|
|
|
/* return existing frame instead... */
|
|
|
|
|
BLI_assert(gf != NULL);
|
|
|
|
|
gpf = gf;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
else if (state == 0) {
|
|
|
|
|
/* add to end then! */
|
|
|
|
|
BLI_addtail(&gpl->frames, gpf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return frame */
|
|
|
|
|
return gpf;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
/* add a copy of the active gp-frame to the given layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
|
2015-12-13 21:03:13 +13:00
|
|
|
{
|
2016-08-03 23:31:48 +02:00
|
|
|
bGPDframe *new_frame;
|
2015-12-13 21:03:13 +13:00
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
|
|
/* Error checking/handling */
|
|
|
|
|
if (gpl == NULL) {
|
|
|
|
|
/* no layer */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (gpl->actframe == NULL) {
|
|
|
|
|
/* no active frame, so just create a new one from scratch */
|
2016-08-04 15:03:18 +02:00
|
|
|
return BKE_gpencil_frame_addnew(gpl, cframe);
|
2015-12-13 21:03:13 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a copy of the frame */
|
2016-08-04 15:03:18 +02:00
|
|
|
new_frame = BKE_gpencil_frame_duplicate(gpl->actframe);
|
2015-12-13 21:03:13 +13:00
|
|
|
|
|
|
|
|
/* Find frame to insert it before */
|
2016-08-03 23:31:48 +02:00
|
|
|
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
2015-12-13 21:03:13 +13:00
|
|
|
if (gpf->framenum > cframe) {
|
|
|
|
|
/* Add it here */
|
|
|
|
|
BLI_insertlinkbefore(&gpl->frames, gpf, new_frame);
|
|
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (gpf->framenum == cframe) {
|
|
|
|
|
/* This only happens when we're editing with framelock on...
|
|
|
|
|
* - Delete the new frame and don't do anything else here...
|
|
|
|
|
*/
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_strokes(new_frame);
|
2015-12-13 21:03:13 +13:00
|
|
|
MEM_freeN(new_frame);
|
|
|
|
|
new_frame = NULL;
|
|
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found == false) {
|
|
|
|
|
/* Add new frame to the end */
|
|
|
|
|
BLI_addtail(&gpl->frames, new_frame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ensure that frame is set up correctly, and return it */
|
|
|
|
|
if (new_frame) {
|
|
|
|
|
new_frame->framenum = cframe;
|
|
|
|
|
gpl->actframe = new_frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new_frame;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* add a new gp-layer and make it the active layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setactive)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl;
|
|
|
|
|
|
|
|
|
|
/* check that list is ok */
|
|
|
|
|
if (gpd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* allocate memory for frame and add to end of list */
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* add to datablock */
|
|
|
|
|
BLI_addtail(&gpd->layers, gpl);
|
|
|
|
|
|
|
|
|
|
/* set basic settings */
|
2013-11-06 10:59:05 +00:00
|
|
|
copy_v4_v4(gpl->color, U.gpencil_new_layer_col);
|
2016-08-03 23:31:48 +02:00
|
|
|
/* Since GPv2 thickness must be 0 */
|
|
|
|
|
gpl->thickness = 0;
|
|
|
|
|
|
|
|
|
|
gpl->opacity = 1.0f;
|
|
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
/* onion-skinning settings */
|
2016-02-09 00:14:45 +13:00
|
|
|
if (gpd->flag & GP_DATA_SHOW_ONIONSKINS)
|
|
|
|
|
gpl->flag |= GP_LAYER_ONIONSKIN;
|
|
|
|
|
|
2015-12-13 21:03:13 +13:00
|
|
|
gpl->flag |= (GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL);
|
|
|
|
|
|
|
|
|
|
ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */
|
|
|
|
|
ARRAY_SET_ITEMS(gpl->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */
|
|
|
|
|
|
2016-05-08 13:38:54 +12:00
|
|
|
/* high quality fill by default */
|
2016-04-29 01:10:33 +12:00
|
|
|
gpl->flag |= GP_LAYER_HQ_FILL;
|
2016-05-08 13:38:54 +12:00
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* auto-name */
|
2012-12-16 08:43:05 +00:00
|
|
|
BLI_strncpy(gpl->info, name, sizeof(gpl->info));
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* make this one the active one */
|
2012-10-05 19:51:11 +00:00
|
|
|
if (setactive)
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_layer_setactive(gpd, gpl);
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* return layer */
|
|
|
|
|
return gpl;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
/* add a new gp-palette and make it the active */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name, bool setactive)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalette *palette;
|
|
|
|
|
|
|
|
|
|
/* check that list is ok */
|
|
|
|
|
if (gpd == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* allocate memory and add to end of list */
|
|
|
|
|
palette = MEM_callocN(sizeof(bGPDpalette), "bGPDpalette");
|
|
|
|
|
|
|
|
|
|
/* add to datablock */
|
|
|
|
|
BLI_addtail(&gpd->palettes, palette);
|
|
|
|
|
|
|
|
|
|
/* set basic settings */
|
|
|
|
|
/* auto-name */
|
|
|
|
|
BLI_strncpy(palette->info, name, sizeof(palette->info));
|
|
|
|
|
BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), '.', offsetof(bGPDpalette, info),
|
|
|
|
|
sizeof(palette->info));
|
|
|
|
|
|
|
|
|
|
/* make this one the active one */
|
2016-11-28 02:28:12 +13:00
|
|
|
/* NOTE: Always make this active if there's nothing else yet (T50123) */
|
|
|
|
|
if ((setactive) || (gpd->palettes.first == gpd->palettes.last)) {
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_palette_setactive(gpd, palette);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return palette */
|
|
|
|
|
return palette;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create a set of default drawing brushes with predefined presets */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_brush_init_presets(ToolSettings *ts)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDbrush *brush;
|
|
|
|
|
/* Basic brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
brush = BKE_gpencil_brush_addnew(ts, "Basic", true);
|
2016-08-03 23:31:48 +02:00
|
|
|
brush->thickness = 3.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 1.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_STRENGTH;
|
|
|
|
|
brush->draw_strength = 1.0f;
|
|
|
|
|
brush->flag |= ~GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_random_press = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_angle = 0.0f;
|
|
|
|
|
brush->draw_angle_factor = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_smoothfac = 0.0f;
|
|
|
|
|
brush->draw_smoothlvl = 1;
|
|
|
|
|
brush->sublevel = 0;
|
|
|
|
|
brush->draw_random_sub = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* Pencil brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
brush = BKE_gpencil_brush_addnew(ts, "Pencil", false);
|
2016-08-03 23:31:48 +02:00
|
|
|
brush->thickness = 7.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 1.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_STRENGTH;
|
|
|
|
|
brush->draw_strength = 0.7f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_random_press = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_angle = 0.0f;
|
|
|
|
|
brush->draw_angle_factor = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_smoothfac = 1.0f;
|
|
|
|
|
brush->draw_smoothlvl = 2;
|
|
|
|
|
brush->sublevel = 2;
|
|
|
|
|
brush->draw_random_sub = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* Ink brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
brush = BKE_gpencil_brush_addnew(ts, "Ink", false);
|
2016-08-03 23:31:48 +02:00
|
|
|
brush->thickness = 7.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 1.6f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_STRENGTH;
|
|
|
|
|
brush->draw_strength = 1.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_random_press = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_angle = 0.0f;
|
|
|
|
|
brush->draw_angle_factor = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_smoothfac = 1.1f;
|
|
|
|
|
brush->draw_smoothlvl = 2;
|
|
|
|
|
brush->sublevel = 2;
|
|
|
|
|
brush->draw_random_sub = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* Ink Noise brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
brush = BKE_gpencil_brush_addnew(ts, "Ink noise", false);
|
2016-08-03 23:31:48 +02:00
|
|
|
brush->thickness = 6.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_RANDOM_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 1.611f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_STRENGTH;
|
|
|
|
|
brush->draw_strength = 1.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_random_press = 1.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_angle = 0.0f;
|
|
|
|
|
brush->draw_angle_factor = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_smoothfac = 1.1f;
|
|
|
|
|
brush->draw_smoothlvl = 2;
|
|
|
|
|
brush->sublevel = 2;
|
|
|
|
|
brush->draw_random_sub = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* Marker brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
brush = BKE_gpencil_brush_addnew(ts, "Marker", false);
|
2016-08-03 23:31:48 +02:00
|
|
|
brush->thickness = 10.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 2.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_STRENGTH;
|
|
|
|
|
brush->draw_strength = 1.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_random_press = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_angle = M_PI_4; /* 45 degrees */
|
|
|
|
|
brush->draw_angle_factor = 1.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_smoothfac = 1.0f;
|
|
|
|
|
brush->draw_smoothlvl = 2;
|
|
|
|
|
brush->sublevel = 2;
|
|
|
|
|
brush->draw_random_sub = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* Crayon brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
brush = BKE_gpencil_brush_addnew(ts, "Crayon", false);
|
2016-08-03 23:31:48 +02:00
|
|
|
brush->thickness = 10.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 3.0f;
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->flag &= ~GP_BRUSH_USE_RANDOM_STRENGTH;
|
|
|
|
|
brush->draw_strength = 0.140f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_random_press = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
brush->draw_angle = 0.0f;
|
|
|
|
|
brush->draw_angle_factor = 0.0f;
|
|
|
|
|
|
|
|
|
|
brush->draw_smoothfac = 0.0f;
|
|
|
|
|
brush->draw_smoothlvl = 1;
|
|
|
|
|
brush->sublevel = 2;
|
|
|
|
|
brush->draw_random_sub = 0.5f;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add a new gp-brush and make it the active */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDbrush *BKE_gpencil_brush_addnew(ToolSettings *ts, const char *name, bool setactive)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDbrush *brush;
|
|
|
|
|
|
|
|
|
|
/* check that list is ok */
|
|
|
|
|
if (ts == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* allocate memory and add to end of list */
|
|
|
|
|
brush = MEM_callocN(sizeof(bGPDbrush), "bGPDbrush");
|
|
|
|
|
|
|
|
|
|
/* add to datablock */
|
|
|
|
|
BLI_addtail(&ts->gp_brushes, brush);
|
|
|
|
|
|
|
|
|
|
/* set basic settings */
|
|
|
|
|
brush->thickness = 3;
|
|
|
|
|
brush->draw_smoothlvl = 1;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_PRESSURE;
|
|
|
|
|
brush->draw_sensitivity = 1.0f;
|
|
|
|
|
brush->draw_strength = 1.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
|
|
|
|
|
brush->draw_jitter = 0.0f;
|
|
|
|
|
brush->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
|
|
|
|
|
|
|
|
|
|
/* curves */
|
|
|
|
|
brush->cur_sensitivity = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
|
brush->cur_strength = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
|
brush->cur_jitter = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
|
|
/* auto-name */
|
|
|
|
|
BLI_strncpy(brush->info, name, sizeof(brush->info));
|
|
|
|
|
BLI_uniquename(&ts->gp_brushes, brush, DATA_("GP_Brush"), '.', offsetof(bGPDbrush, info), sizeof(brush->info));
|
|
|
|
|
|
|
|
|
|
/* make this one the active one */
|
|
|
|
|
if (setactive) {
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_brush_setactive(ts, brush);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return brush */
|
|
|
|
|
return brush;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add a new gp-palettecolor and make it the active */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const char *name, bool setactive)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalettecolor *palcolor;
|
|
|
|
|
|
|
|
|
|
/* check that list is ok */
|
|
|
|
|
if (palette == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* allocate memory and add to end of list */
|
|
|
|
|
palcolor = MEM_callocN(sizeof(bGPDpalettecolor), "bGPDpalettecolor");
|
|
|
|
|
|
|
|
|
|
/* add to datablock */
|
|
|
|
|
BLI_addtail(&palette->colors, palcolor);
|
|
|
|
|
|
|
|
|
|
/* set basic settings */
|
|
|
|
|
palcolor->flag |= PC_COLOR_HQ_FILL;
|
|
|
|
|
copy_v4_v4(palcolor->color, U.gpencil_new_layer_col);
|
|
|
|
|
ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
|
|
/* auto-name */
|
|
|
|
|
BLI_strncpy(palcolor->info, name, sizeof(palcolor->info));
|
|
|
|
|
BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
|
|
|
|
|
sizeof(palcolor->info));
|
|
|
|
|
|
|
|
|
|
/* make this one the active one */
|
|
|
|
|
if (setactive) {
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_palettecolor_setactive(palette, palcolor);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return palette color */
|
|
|
|
|
return palcolor;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* add a new gp-datablock */
|
2018-06-13 10:57:10 +02:00
|
|
|
bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
|
|
|
|
bGPdata *gpd;
|
|
|
|
|
|
|
|
|
|
/* allocate memory for a new block */
|
2018-06-13 10:57:10 +02:00
|
|
|
gpd = BKE_libblock_alloc(bmain, ID_GD, name, 0);
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* initial settings */
|
2012-05-06 15:15:33 +00:00
|
|
|
gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND);
|
2009-04-20 10:20:18 +00:00
|
|
|
|
2009-08-30 11:37:29 +00:00
|
|
|
/* for now, stick to view is also enabled by default
|
|
|
|
|
* since this is more useful...
|
|
|
|
|
*/
|
|
|
|
|
gpd->flag |= GP_DATA_VIEWALIGN;
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
return gpd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------- Data Duplication ---------- */
|
|
|
|
|
|
|
|
|
|
/* make a copy of a given gpencil frame */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2016-08-03 23:31:48 +02:00
|
|
|
bGPDstroke *gps_dst;
|
|
|
|
|
bGPDframe *gpf_dst;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* error checking */
|
2016-08-03 23:31:48 +02:00
|
|
|
if (gpf_src == NULL) {
|
2009-04-20 10:20:18 +00:00
|
|
|
return NULL;
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* make a copy of the source frame */
|
2016-08-03 23:31:48 +02:00
|
|
|
gpf_dst = MEM_dupallocN(gpf_src);
|
|
|
|
|
gpf_dst->prev = gpf_dst->next = NULL;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* copy strokes */
|
2016-08-03 23:31:48 +02:00
|
|
|
BLI_listbase_clear(&gpf_dst->strokes);
|
|
|
|
|
for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
|
2009-04-20 10:20:18 +00:00
|
|
|
/* make copy of source stroke, then adjust pointer to points too */
|
2016-08-03 23:31:48 +02:00
|
|
|
gps_dst = MEM_dupallocN(gps_src);
|
|
|
|
|
gps_dst->points = MEM_dupallocN(gps_src->points);
|
|
|
|
|
gps_dst->triangles = MEM_dupallocN(gps_src->triangles);
|
|
|
|
|
gps_dst->flag |= GP_STROKE_RECALC_CACHES;
|
|
|
|
|
BLI_addtail(&gpf_dst->strokes, gps_dst);
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return new frame */
|
2016-08-03 23:31:48 +02:00
|
|
|
return gpf_dst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make a copy of a given gpencil brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDbrush *BKE_gpencil_brush_duplicate(const bGPDbrush *brush_src)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDbrush *brush_dst;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (brush_src == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make a copy of source brush */
|
|
|
|
|
brush_dst = MEM_dupallocN(brush_src);
|
|
|
|
|
brush_dst->prev = brush_dst->next = NULL;
|
|
|
|
|
/* make a copy of curves */
|
|
|
|
|
brush_dst->cur_sensitivity = curvemapping_copy(brush_src->cur_sensitivity);
|
|
|
|
|
brush_dst->cur_strength = curvemapping_copy(brush_src->cur_strength);
|
|
|
|
|
brush_dst->cur_jitter = curvemapping_copy(brush_src->cur_jitter);
|
|
|
|
|
|
|
|
|
|
/* return new brush */
|
|
|
|
|
return brush_dst;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
/* make a copy of a given gpencil palette */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDpalette *BKE_gpencil_palette_duplicate(const bGPDpalette *palette_src)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalette *palette_dst;
|
|
|
|
|
const bGPDpalettecolor *palcolor_src;
|
|
|
|
|
bGPDpalettecolor *palcolord_dst;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (palette_src == NULL) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make a copy of source palette */
|
|
|
|
|
palette_dst = MEM_dupallocN(palette_src);
|
|
|
|
|
palette_dst->prev = palette_dst->next = NULL;
|
|
|
|
|
|
|
|
|
|
/* copy colors */
|
|
|
|
|
BLI_listbase_clear(&palette_dst->colors);
|
|
|
|
|
for (palcolor_src = palette_src->colors.first; palcolor_src; palcolor_src = palcolor_src->next) {
|
|
|
|
|
/* make a copy of source */
|
|
|
|
|
palcolord_dst = MEM_dupallocN(palcolor_src);
|
|
|
|
|
BLI_addtail(&palette_dst->colors, palcolord_dst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return new palette */
|
|
|
|
|
return palette_dst;
|
|
|
|
|
}
|
2009-04-20 10:20:18 +00:00
|
|
|
/* make a copy of a given gpencil layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2016-08-03 23:31:48 +02:00
|
|
|
const bGPDframe *gpf_src;
|
|
|
|
|
bGPDframe *gpf_dst;
|
|
|
|
|
bGPDlayer *gpl_dst;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* error checking */
|
2016-08-03 23:31:48 +02:00
|
|
|
if (gpl_src == NULL) {
|
2009-04-20 10:20:18 +00:00
|
|
|
return NULL;
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* make a copy of source layer */
|
2016-08-03 23:31:48 +02:00
|
|
|
gpl_dst = MEM_dupallocN(gpl_src);
|
|
|
|
|
gpl_dst->prev = gpl_dst->next = NULL;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* copy frames */
|
2016-08-03 23:31:48 +02:00
|
|
|
BLI_listbase_clear(&gpl_dst->frames);
|
|
|
|
|
for (gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) {
|
2009-04-20 10:20:18 +00:00
|
|
|
/* make a copy of source frame */
|
2016-08-04 15:03:18 +02:00
|
|
|
gpf_dst = BKE_gpencil_frame_duplicate(gpf_src);
|
2016-08-03 23:31:48 +02:00
|
|
|
BLI_addtail(&gpl_dst->frames, gpf_dst);
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* if source frame was the current layer's 'active' frame, reassign that too */
|
2016-08-03 23:31:48 +02:00
|
|
|
if (gpf_src == gpl_dst->actframe)
|
|
|
|
|
gpl_dst->actframe = gpf_dst;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return new layer */
|
2016-08-03 23:31:48 +02:00
|
|
|
return gpl_dst;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/**
|
|
|
|
|
* Only copy internal data of GreasePencil ID from source to already allocated/initialized destination.
|
|
|
|
|
* You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
|
|
|
|
|
*
|
|
|
|
|
* WARNING! This function will not handle ID user count!
|
|
|
|
|
*
|
|
|
|
|
* \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
|
|
|
|
|
*/
|
|
|
|
|
void BKE_gpencil_copy_data(Main *UNUSED(bmain), bGPdata *gpd_dst, const bGPdata *gpd_src, const int UNUSED(flag))
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/* copy layers */
|
|
|
|
|
BLI_listbase_clear(&gpd_dst->layers);
|
|
|
|
|
for (const bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
|
|
|
|
|
/* make a copy of source layer and its data */
|
|
|
|
|
bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src); /* TODO here too could add unused flags... */
|
|
|
|
|
BLI_addtail(&gpd_dst->layers, gpl_dst);
|
|
|
|
|
}
|
2016-08-03 23:31:48 +02:00
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/* copy palettes */
|
|
|
|
|
BLI_listbase_clear(&gpd_dst->palettes);
|
|
|
|
|
for (const bGPDpalette *palette_src = gpd_src->palettes.first; palette_src; palette_src = palette_src->next) {
|
|
|
|
|
bGPDpalette *palette_dst = BKE_gpencil_palette_duplicate(palette_src); /* TODO here too could add unused flags... */
|
|
|
|
|
BLI_addtail(&gpd_dst->palettes, palette_dst);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make a copy of a given gpencil datablock */
|
|
|
|
|
bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool internal_copy)
|
|
|
|
|
{
|
|
|
|
|
/* Yuck and super-uber-hyper yuck!!!
|
|
|
|
|
* Should be replaceable with a no-main copy (LIB_ID_COPY_NO_MAIN etc.), but not sure about it,
|
|
|
|
|
* so for now keep old code for that one. */
|
2014-11-22 18:03:37 +13:00
|
|
|
if (internal_copy) {
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
const bGPDlayer *gpl_src;
|
|
|
|
|
bGPDlayer *gpl_dst;
|
|
|
|
|
bGPdata *gpd_dst;
|
|
|
|
|
|
2014-11-22 18:03:37 +13:00
|
|
|
/* make a straight copy for undo buffers used during stroke drawing */
|
2016-08-03 23:31:48 +02:00
|
|
|
gpd_dst = MEM_dupallocN(gpd_src);
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
|
|
|
|
|
/* copy layers */
|
|
|
|
|
BLI_listbase_clear(&gpd_dst->layers);
|
|
|
|
|
for (gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
|
|
|
|
|
/* make a copy of source layer and its data */
|
|
|
|
|
gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
|
|
|
|
|
BLI_addtail(&gpd_dst->layers, gpl_dst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return new */
|
|
|
|
|
return gpd_dst;
|
2014-11-22 18:03:37 +13:00
|
|
|
}
|
|
|
|
|
else {
|
2018-06-15 17:21:07 +02:00
|
|
|
BLI_assert(bmain != NULL);
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
bGPdata *gpd_copy;
|
|
|
|
|
BKE_id_copy_ex(bmain, &gpd_src->id, (ID **)&gpd_copy, 0, false);
|
|
|
|
|
return gpd_copy;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-21 16:09:08 +02:00
|
|
|
void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const bool lib_local)
|
|
|
|
|
{
|
|
|
|
|
BKE_id_make_local_generic(bmain, &gpd->id, true, lib_local);
|
|
|
|
|
}
|
|
|
|
|
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
/* -------- GP-Stroke API --------- */
|
|
|
|
|
|
|
|
|
|
/* ensure selection status of stroke is in sync with its points */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
{
|
|
|
|
|
bGPDspoint *pt;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (gps == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* we'll stop when we find the first selected point,
|
|
|
|
|
* so initially, we must deselect
|
|
|
|
|
*/
|
|
|
|
|
gps->flag &= ~GP_STROKE_SELECT;
|
|
|
|
|
|
|
|
|
|
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
|
|
|
|
if (pt->flag & GP_SPOINT_SELECT) {
|
|
|
|
|
gps->flag |= GP_STROKE_SELECT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* -------- GP-Frame API ---------- */
|
|
|
|
|
|
|
|
|
|
/* delete the last stroke of the given frame */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
bGPDstroke *gps = (gpf) ? gpf->strokes.last : NULL;
|
2009-08-31 01:58:11 +00:00
|
|
|
int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */
|
2009-04-20 10:20:18 +00:00
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpf, gps))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* free the stroke and its data */
|
|
|
|
|
MEM_freeN(gps->points);
|
2016-04-29 01:10:33 +12:00
|
|
|
MEM_freeN(gps->triangles);
|
2009-04-20 10:20:18 +00:00
|
|
|
BLI_freelinkN(&gpf->strokes, gps);
|
|
|
|
|
|
|
|
|
|
/* if frame has no strokes after this, delete it */
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(&gpf->strokes)) {
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_layer_delframe(gpl, gpf);
|
|
|
|
|
BKE_gpencil_layer_getframe(gpl, cfra, 0);
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------- GP-Layer API ---------- */
|
|
|
|
|
|
2016-02-09 02:44:02 +13:00
|
|
|
/* Check if the given layer is able to be edited or not */
|
|
|
|
|
bool gpencil_layer_is_editable(const bGPDlayer *gpl)
|
|
|
|
|
{
|
|
|
|
|
/* Sanity check */
|
|
|
|
|
if (gpl == NULL)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* Layer must be: Visible + Editable */
|
|
|
|
|
if ((gpl->flag & (GP_LAYER_HIDE | GP_LAYER_LOCKED)) == 0) {
|
|
|
|
|
/* Opacity must be sufficiently high that it is still "visible"
|
|
|
|
|
* Otherwise, it's not really "visible" to the user, so no point editing...
|
|
|
|
|
*/
|
2016-08-03 23:31:48 +02:00
|
|
|
if (gpl->opacity > GPENCIL_ALPHA_OPACITY_THRESH) {
|
2016-02-09 02:44:02 +13:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Something failed */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look up the gp-frame on the requested frame number, but don't add a new one */
|
2012-06-08 22:07:57 +00:00
|
|
|
bGPDframe *BKE_gpencil_layer_find_frame(bGPDlayer *gpl, int cframe)
|
|
|
|
|
{
|
|
|
|
|
bGPDframe *gpf;
|
2016-02-09 02:44:02 +13:00
|
|
|
|
|
|
|
|
/* Search in reverse order, since this is often used for playback/adding,
|
|
|
|
|
* where it's less likely that we're interested in the earlier frames
|
|
|
|
|
*/
|
2012-06-08 22:07:57 +00:00
|
|
|
for (gpf = gpl->frames.last; gpf; gpf = gpf->prev) {
|
|
|
|
|
if (gpf->framenum == cframe) {
|
|
|
|
|
return gpf;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-09 02:44:02 +13:00
|
|
|
|
2012-06-08 22:07:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* get the appropriate gp-frame from a given layer
|
|
|
|
|
* - this sets the layer's actframe var (if allowed to)
|
|
|
|
|
* - extension beyond range (if first gp-frame is after all frame in interest and cannot add)
|
|
|
|
|
*/
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDframe *BKE_gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
|
|
|
|
bGPDframe *gpf = NULL;
|
|
|
|
|
short found = 0;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (gpl == NULL) return NULL;
|
|
|
|
|
|
|
|
|
|
/* check if there is already an active frame */
|
|
|
|
|
if (gpl->actframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
gpf = gpl->actframe;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
2010-01-08 01:39:41 +00:00
|
|
|
/* do not allow any changes to layer's active frame if layer is locked from changes
|
|
|
|
|
* or if the layer has been set to stay on the current frame
|
|
|
|
|
*/
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
if (gpl->flag & GP_LAYER_FRAMELOCK)
|
2009-04-20 10:20:18 +00:00
|
|
|
return gpf;
|
|
|
|
|
/* do not allow any changes to actframe if frame has painting tag attached to it */
|
|
|
|
|
if (gpf->flag & GP_FRAME_PAINT)
|
|
|
|
|
return gpf;
|
|
|
|
|
|
|
|
|
|
/* try to find matching frame */
|
|
|
|
|
if (gpf->framenum < cframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (; gpf; gpf = gpf->next) {
|
2009-04-20 10:20:18 +00:00
|
|
|
if (gpf->framenum == cframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
found = 1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if ((gpf->next) && (gpf->next->framenum > cframe)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
found = 1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the appropriate frame */
|
|
|
|
|
if (addnew) {
|
|
|
|
|
if ((found) && (gpf->framenum == cframe))
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpf;
|
2015-12-13 21:03:13 +13:00
|
|
|
else if (addnew == GP_GETFRAME_ADD_COPY)
|
2016-08-04 15:03:18 +02:00
|
|
|
gpl->actframe = BKE_gpencil_frame_addcopy(gpl, cframe);
|
2009-04-20 10:20:18 +00:00
|
|
|
else
|
2016-08-04 15:03:18 +02:00
|
|
|
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
else if (found)
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpf;
|
2009-04-20 10:20:18 +00:00
|
|
|
else
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpl->frames.last;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (; gpf; gpf = gpf->prev) {
|
2009-04-20 10:20:18 +00:00
|
|
|
if (gpf->framenum <= cframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
found = 1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the appropriate frame */
|
|
|
|
|
if (addnew) {
|
|
|
|
|
if ((found) && (gpf->framenum == cframe))
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpf;
|
2015-12-13 21:03:13 +13:00
|
|
|
else if (addnew == GP_GETFRAME_ADD_COPY)
|
2016-08-04 15:03:18 +02:00
|
|
|
gpl->actframe = BKE_gpencil_frame_addcopy(gpl, cframe);
|
2009-04-20 10:20:18 +00:00
|
|
|
else
|
2016-08-04 15:03:18 +02:00
|
|
|
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
else if (found)
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpf;
|
2009-04-20 10:20:18 +00:00
|
|
|
else
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpl->frames.first;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (gpl->frames.first) {
|
|
|
|
|
/* check which of the ends to start checking from */
|
2012-05-06 15:15:33 +00:00
|
|
|
const int first = ((bGPDframe *)(gpl->frames.first))->framenum;
|
|
|
|
|
const int last = ((bGPDframe *)(gpl->frames.last))->framenum;
|
2009-04-20 10:20:18 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (abs(cframe - first) > abs(cframe - last)) {
|
2009-04-20 10:20:18 +00:00
|
|
|
/* find gp-frame which is less than or equal to cframe */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (gpf = gpl->frames.last; gpf; gpf = gpf->prev) {
|
2009-04-20 10:20:18 +00:00
|
|
|
if (gpf->framenum <= cframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
found = 1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* find gp-frame which is less than or equal to cframe */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
2009-04-20 10:20:18 +00:00
|
|
|
if (gpf->framenum <= cframe) {
|
2012-05-06 15:15:33 +00:00
|
|
|
found = 1;
|
2009-04-20 10:20:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the appropriate frame */
|
|
|
|
|
if (addnew) {
|
|
|
|
|
if ((found) && (gpf->framenum == cframe))
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpf;
|
2009-04-20 10:20:18 +00:00
|
|
|
else
|
2016-08-04 15:03:18 +02:00
|
|
|
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
else if (found)
|
2012-05-06 15:15:33 +00:00
|
|
|
gpl->actframe = gpf;
|
2009-04-20 10:20:18 +00:00
|
|
|
else {
|
|
|
|
|
/* unresolved errogenous situation! */
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("Error: cannot find appropriate gp-frame\n");
|
2009-04-20 10:20:18 +00:00
|
|
|
/* gpl->actframe should still be NULL */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* currently no frames (add if allowed to) */
|
|
|
|
|
if (addnew)
|
2016-08-04 15:03:18 +02:00
|
|
|
gpl->actframe = BKE_gpencil_frame_addnew(gpl, cframe);
|
2009-04-20 10:20:18 +00:00
|
|
|
else {
|
|
|
|
|
/* don't do anything... this may be when no frames yet! */
|
|
|
|
|
/* gpl->actframe should still be NULL */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return */
|
|
|
|
|
return gpl->actframe;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete the given frame from a layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
bool BKE_gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = false;
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpl, gpf))
|
2013-11-25 04:55:26 +01:00
|
|
|
return false;
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
|
|
|
|
|
/* if this frame was active, make the previous frame active instead
|
|
|
|
|
* since it's tricky to set active frame otherwise
|
|
|
|
|
*/
|
|
|
|
|
if (gpl->actframe == gpf)
|
|
|
|
|
gpl->actframe = gpf->prev;
|
|
|
|
|
else
|
|
|
|
|
gpl->actframe = NULL;
|
|
|
|
|
|
2009-04-20 10:20:18 +00:00
|
|
|
/* free the frame and its data */
|
2016-08-04 15:03:18 +02:00
|
|
|
changed = BKE_gpencil_free_strokes(gpf);
|
2009-04-20 10:20:18 +00:00
|
|
|
BLI_freelinkN(&gpl->frames, gpf);
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
return changed;
|
2009-04-20 10:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get the active gp-layer for editing */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDlayer *BKE_gpencil_layer_getactive(bGPdata *gpd)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpd, gpd->layers.first))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* loop over layers until found (assume only one active) */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
2009-04-20 10:20:18 +00:00
|
|
|
if (gpl->flag & GP_LAYER_ACTIVE)
|
|
|
|
|
return gpl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no active layer found */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the active gp-layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(NULL, gpd, gpd->layers.first, active))
|
2009-04-20 10:20:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* loop over layers deactivating all */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (gpl = gpd->layers.first; gpl; gpl = gpl->next)
|
2009-04-20 10:20:18 +00:00
|
|
|
gpl->flag &= ~GP_LAYER_ACTIVE;
|
|
|
|
|
|
|
|
|
|
/* set as active one */
|
|
|
|
|
active->flag |= GP_LAYER_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete the active gp-layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
|
2009-04-20 10:20:18 +00:00
|
|
|
{
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpd, gpl))
|
|
|
|
|
return;
|
|
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* free layer */
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_free_frames(gpl);
|
2009-04-20 10:20:18 +00:00
|
|
|
BLI_freelinkN(&gpd->layers, gpl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************** */
|
2016-08-03 23:31:48 +02:00
|
|
|
/* get the active gp-brush for editing */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDbrush *BKE_gpencil_brush_getactive(ToolSettings *ts)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDbrush *brush;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, ts, ts->gp_brushes.first)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* loop over brushes until found (assume only one active) */
|
|
|
|
|
for (brush = ts->gp_brushes.first; brush; brush = brush->next) {
|
|
|
|
|
if (brush->flag & GP_BRUSH_ACTIVE) {
|
|
|
|
|
return brush;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no active brush found */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the active gp-brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_brush_setactive(ToolSettings *ts, bGPDbrush *active)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDbrush *brush;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, ts, ts->gp_brushes.first, active)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* loop over brushes deactivating all */
|
|
|
|
|
for (brush = ts->gp_brushes.first; brush; brush = brush->next) {
|
|
|
|
|
brush->flag &= ~GP_BRUSH_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set as active one */
|
|
|
|
|
active->flag |= GP_BRUSH_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete the active gp-brush */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_brush_delete(ToolSettings *ts, bGPDbrush *brush)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, ts, brush)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free curves */
|
|
|
|
|
if (brush->cur_sensitivity) {
|
|
|
|
|
curvemapping_free(brush->cur_sensitivity);
|
|
|
|
|
}
|
|
|
|
|
if (brush->cur_strength) {
|
|
|
|
|
curvemapping_free(brush->cur_strength);
|
|
|
|
|
}
|
|
|
|
|
if (brush->cur_jitter) {
|
|
|
|
|
curvemapping_free(brush->cur_jitter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free */
|
|
|
|
|
BLI_freelinkN(&ts->gp_brushes, brush);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************** */
|
|
|
|
|
/* get the active gp-palette for editing */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDpalette *BKE_gpencil_palette_getactive(bGPdata *gpd)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalette *palette;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpd, gpd->palettes.first)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* loop over palettes until found (assume only one active) */
|
|
|
|
|
for (palette = gpd->palettes.first; palette; palette = palette->next) {
|
|
|
|
|
if (palette->flag & PL_PALETTE_ACTIVE)
|
|
|
|
|
return palette;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no active palette found */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the active gp-palette */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palette_setactive(bGPdata *gpd, bGPDpalette *active)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalette *palette;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpd, gpd->palettes.first, active)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* loop over palettes deactivating all */
|
|
|
|
|
for (palette = gpd->palettes.first; palette; palette = palette->next) {
|
|
|
|
|
palette->flag &= ~PL_PALETTE_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set as active one */
|
|
|
|
|
active->flag |= PL_PALETTE_ACTIVE;
|
|
|
|
|
/* force color recalc */
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_palette_change_strokes(gpd);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete the active gp-palette */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palette_delete(bGPdata *gpd, bGPDpalette *palette)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, gpd, palette)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free colors */
|
|
|
|
|
free_gpencil_colors(palette);
|
|
|
|
|
BLI_freelinkN(&gpd->palettes, palette);
|
|
|
|
|
/* force color recalc */
|
2016-08-04 15:03:18 +02:00
|
|
|
BKE_gpencil_palette_change_strokes(gpd);
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set all strokes to recalc the palette color */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palette_change_strokes(bGPdata *gpd)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl;
|
|
|
|
|
bGPDframe *gpf;
|
|
|
|
|
bGPDstroke *gps;
|
|
|
|
|
|
|
|
|
|
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
|
|
|
|
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
|
|
|
|
for (gps = gpf->strokes.first; gps; gps = gps->next) {
|
|
|
|
|
gps->flag |= GP_STROKE_RECALC_COLOR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* get the active gp-palettecolor for editing */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDpalettecolor *BKE_gpencil_palettecolor_getactive(bGPDpalette *palette)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalettecolor *palcolor;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, palette, palette->colors.first)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* loop over colors until found (assume only one active) */
|
|
|
|
|
for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
|
|
|
|
|
if (palcolor->flag & PC_COLOR_ACTIVE) {
|
|
|
|
|
return palcolor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no active color found */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
/* get the gp-palettecolor looking for name */
|
2016-08-04 15:03:18 +02:00
|
|
|
bGPDpalettecolor *BKE_gpencil_palettecolor_getbyname(bGPDpalette *palette, char *name)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, palette, name)) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BLI_findstring(&palette->colors, name, offsetof(bGPDpalettecolor, info));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Change color name in all strokes */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palettecolor_changename(bGPdata *gpd, char *oldname, const char *newname)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl;
|
|
|
|
|
bGPDframe *gpf;
|
|
|
|
|
bGPDstroke *gps;
|
2016-11-28 02:33:11 +13:00
|
|
|
|
|
|
|
|
/* Sanity checks (gpd may not be set in the RNA pointers sometimes) */
|
|
|
|
|
if (ELEM(NULL, gpd, oldname, newname))
|
|
|
|
|
return;
|
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
|
|
|
|
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
|
|
|
|
for (gps = gpf->strokes.first; gps; gps = gps->next) {
|
|
|
|
|
if (STREQ(gps->colorname, oldname)) {
|
2016-08-18 15:45:20 +02:00
|
|
|
BLI_strncpy(gps->colorname, newname, sizeof(gps->colorname));
|
2016-08-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Delete all strokes of the color */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palettecolor_delete_strokes(struct bGPdata *gpd, char *name)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDlayer *gpl;
|
|
|
|
|
bGPDframe *gpf;
|
|
|
|
|
bGPDstroke *gps, *gpsn;
|
2016-11-28 02:33:11 +13:00
|
|
|
|
|
|
|
|
/* Sanity checks (gpd may not be set in the RNA pointers sometimes) */
|
|
|
|
|
if (ELEM(NULL, gpd, name))
|
|
|
|
|
return;
|
|
|
|
|
|
2016-08-03 23:31:48 +02:00
|
|
|
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
|
|
|
|
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
|
|
|
|
for (gps = gpf->strokes.first; gps; gps = gpsn) {
|
|
|
|
|
gpsn = gps->next;
|
|
|
|
|
|
|
|
|
|
if (STREQ(gps->colorname, name)) {
|
|
|
|
|
if (gps->points) MEM_freeN(gps->points);
|
|
|
|
|
if (gps->triangles) MEM_freeN(gps->triangles);
|
|
|
|
|
BLI_freelinkN(&gpf->strokes, gps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the active gp-palettecolor */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palettecolor_setactive(bGPDpalette *palette, bGPDpalettecolor *active)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
bGPDpalettecolor *palcolor;
|
|
|
|
|
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, palette, palette->colors.first, active)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* loop over colors deactivating all */
|
|
|
|
|
for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
|
|
|
|
|
palcolor->flag &= ~PC_COLOR_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set as active one */
|
|
|
|
|
active->flag |= PC_COLOR_ACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete the active gp-palettecolor */
|
2016-08-04 15:03:18 +02:00
|
|
|
void BKE_gpencil_palettecolor_delete(bGPDpalette *palette, bGPDpalettecolor *palcolor)
|
2016-08-03 23:31:48 +02:00
|
|
|
{
|
|
|
|
|
/* error checking */
|
|
|
|
|
if (ELEM(NULL, palette, palcolor)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free */
|
|
|
|
|
BLI_freelinkN(&palette->colors, palcolor);
|
|
|
|
|
}
|