2011-02-18 13:05:18 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BKE_BRUSH_H__
|
|
|
|
|
#define __BKE_BRUSH_H__
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
|
2011-02-18 13:05:18 +00:00
|
|
|
/** \file BKE_brush.h
|
|
|
|
|
* \ingroup bke
|
2013-07-02 10:14:59 +00:00
|
|
|
*
|
|
|
|
|
* General operations for brushes.
|
2011-02-18 13:05:18 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-10-17 13:43:10 +11:00
|
|
|
enum eCurveMappingPreset;
|
2018-07-31 10:22:19 +02:00
|
|
|
struct bContext;
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
struct Brush;
|
2018-07-31 10:22:19 +02:00
|
|
|
struct Paint;
|
2006-07-31 15:53:03 +00:00
|
|
|
struct ImBuf;
|
2013-01-22 08:05:00 +00:00
|
|
|
struct ImagePool;
|
2013-02-05 12:46:15 +00:00
|
|
|
struct Main;
|
2009-03-11 00:43:08 +00:00
|
|
|
struct Scene;
|
2018-07-31 10:22:19 +02:00
|
|
|
struct ToolSettings;
|
2016-02-18 19:32:33 +11:00
|
|
|
struct UnifiedPaintSettings;
|
2018-08-24 23:59:56 +02:00
|
|
|
struct Material;
|
|
|
|
|
|
2017-10-17 13:43:10 +11:00
|
|
|
// enum eCurveMappingPreset;
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
|
2018-02-06 23:34:58 +11:00
|
|
|
#include "DNA_object_enums.h"
|
2013-03-19 14:25:12 +00:00
|
|
|
|
|
|
|
|
/* globals for brush execution */
|
|
|
|
|
void BKE_brush_system_init(void);
|
|
|
|
|
void BKE_brush_system_exit(void);
|
|
|
|
|
|
2006-07-31 15:53:03 +00:00
|
|
|
/* datablock functions */
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
void BKE_brush_init(struct Brush *brush);
|
2018-02-06 23:34:58 +11:00
|
|
|
struct Brush *BKE_brush_add(struct Main *bmain, const char *name, const eObjectMode ob_mode);
|
2018-07-31 10:22:19 +02:00
|
|
|
struct Brush *BKE_brush_add_gpencil(struct Main *bmain, struct ToolSettings *ts, const char *name);
|
2018-08-05 16:19:24 +02:00
|
|
|
void BKE_brush_init_gpencil_settings(struct Brush *brush);
|
2018-02-06 23:34:58 +11:00
|
|
|
struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode);
|
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
|
|
|
void BKE_brush_copy_data(struct Main *bmain, struct Brush *brush_dst, const struct Brush *brush_src, const int flag);
|
2017-06-14 22:36:30 +02:00
|
|
|
struct Brush *BKE_brush_copy(struct Main *bmain, const struct Brush *brush);
|
2016-07-20 19:49:45 +02:00
|
|
|
void BKE_brush_make_local(struct Main *bmain, struct Brush *brush, const bool lib_local);
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_brush_free(struct Brush *brush);
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_brush_sculpt_reset(struct Brush *brush);
|
2018-07-31 10:22:19 +02:00
|
|
|
void BKE_brush_gpencil_presets(struct bContext *C);
|
2018-08-24 23:59:56 +02:00
|
|
|
void BKE_brush_update_material(struct Main *bmain, struct Material *ma, struct Brush *exclude_brush);
|
2018-07-31 10:22:19 +02:00
|
|
|
struct Brush *BKE_brush_getactive_gpencil(struct ToolSettings *ts);
|
|
|
|
|
struct Paint *BKE_brush_get_gpencil_paint(struct ToolSettings *ts);
|
2010-07-27 16:09:02 +00:00
|
|
|
|
2010-07-20 02:18:10 +00:00
|
|
|
/* image icon function */
|
2010-07-20 11:32:30 +00:00
|
|
|
struct ImBuf *get_brush_icon(struct Brush *brush);
|
2010-07-20 02:18:10 +00:00
|
|
|
|
2011-01-08 01:45:02 +00:00
|
|
|
/* jitter */
|
2016-02-18 19:32:33 +11:00
|
|
|
void BKE_brush_jitter_pos(
|
|
|
|
|
const struct Scene *scene, struct Brush *brush,
|
|
|
|
|
const float pos[2], float jitterpos[2]);
|
2015-01-04 14:20:31 +11:00
|
|
|
void BKE_brush_randomize_texture_coords(struct UnifiedPaintSettings *ups, bool mask);
|
2011-01-08 01:45:02 +00:00
|
|
|
|
2009-01-07 04:38:30 +00:00
|
|
|
/* brush curve */
|
2017-10-17 13:43:10 +11:00
|
|
|
void BKE_brush_curve_preset(struct Brush *b, enum eCurveMappingPreset preset);
|
2015-06-10 13:32:11 +02:00
|
|
|
float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len);
|
2017-10-02 21:07:25 +11:00
|
|
|
float BKE_brush_curve_strength(const struct Brush *br, float p, const float len);
|
2009-01-07 04:38:30 +00:00
|
|
|
|
2006-07-31 15:53:03 +00:00
|
|
|
/* sampling */
|
2016-02-18 19:32:33 +11:00
|
|
|
float BKE_brush_sample_tex_3D(
|
2017-10-03 18:43:18 +11:00
|
|
|
const struct Scene *scene, const struct Brush *br, const float point[3],
|
2016-02-18 19:32:33 +11:00
|
|
|
float rgba[4], const int thread, struct ImagePool *pool);
|
|
|
|
|
float BKE_brush_sample_masktex(
|
|
|
|
|
const struct Scene *scene, struct Brush *br, const float point[2],
|
|
|
|
|
const int thread, struct ImagePool *pool);
|
2013-04-30 16:07:52 +00:00
|
|
|
|
2009-01-25 07:28:11 +00:00
|
|
|
/* texture */
|
2013-09-05 14:02:59 +00:00
|
|
|
unsigned int *BKE_brush_gen_texture_cache(struct Brush *br, int half_side, bool use_secondary);
|
2009-01-25 07:28:11 +00:00
|
|
|
|
|
|
|
|
/* radial control */
|
2013-09-05 14:02:59 +00:00
|
|
|
struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br, bool secondary);
|
2009-01-25 07:28:11 +00:00
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
/* unified strength size and color */
|
|
|
|
|
|
2015-04-17 03:10:57 +10:00
|
|
|
const float *BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush);
|
|
|
|
|
const float *BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush);
|
2014-07-21 12:02:05 +02:00
|
|
|
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3]);
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2015-04-17 03:10:57 +10:00
|
|
|
int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush);
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_brush_size_set(struct Scene *scene, struct Brush *brush, int value);
|
2012-01-14 23:54:51 +00:00
|
|
|
|
2015-04-17 03:10:57 +10:00
|
|
|
float BKE_brush_unprojected_radius_get(const struct Scene *scene, const struct Brush *brush);
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float value);
|
2012-01-14 23:54:51 +00:00
|
|
|
|
2015-04-17 03:10:57 +10:00
|
|
|
float BKE_brush_alpha_get(const struct Scene *scene, const struct Brush *brush);
|
2016-02-18 19:32:33 +11:00
|
|
|
void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float alpha);
|
|
|
|
|
float BKE_brush_weight_get(const struct Scene *scene, const struct Brush *brush);
|
|
|
|
|
void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float value);
|
2010-07-22 18:56:46 +00:00
|
|
|
|
2017-10-05 12:51:36 +11:00
|
|
|
bool BKE_brush_use_locked_size(const struct Scene *scene, const struct Brush *brush);
|
|
|
|
|
bool BKE_brush_use_alpha_pressure(const struct Scene *scene, const struct Brush *brush);
|
|
|
|
|
bool BKE_brush_use_size_pressure(const struct Scene *scene, const struct Brush *brush);
|
2010-07-22 18:56:46 +00:00
|
|
|
|
2017-10-05 12:57:24 +11:00
|
|
|
bool BKE_brush_sculpt_has_secondary_color(const struct Brush *brush);
|
|
|
|
|
|
2012-01-14 23:54:51 +00:00
|
|
|
/* scale unprojected radius to reflect a change in the brush's 2D size */
|
2015-04-17 03:10:57 +10:00
|
|
|
void BKE_brush_scale_unprojected_radius(
|
|
|
|
|
float *unprojected_radius,
|
|
|
|
|
int new_brush_size,
|
|
|
|
|
int old_brush_size);
|
2010-07-22 18:56:46 +00:00
|
|
|
|
2012-01-14 23:54:51 +00:00
|
|
|
/* scale brush size to reflect a change in the brush's unprojected radius */
|
2015-04-17 03:10:57 +10:00
|
|
|
void BKE_brush_scale_size(
|
|
|
|
|
int *r_brush_size,
|
|
|
|
|
float new_unprojected_radius,
|
|
|
|
|
float old_unprojected_radius);
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2011-02-14 03:15:55 +00:00
|
|
|
/* debugging only */
|
2012-05-05 00:58:22 +00:00
|
|
|
void BKE_brush_debug_print_state(struct Brush *br);
|
2011-02-14 03:15:55 +00:00
|
|
|
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
#endif
|