Blender V2.61 - r43446
|
#include <math.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_brush_types.h"
#include "DNA_color_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_windowmanager_types.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "BLI_bpath.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BKE_brush.h"
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_paint.h"
#include "BKE_texture.h"
#include "BKE_icons.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
Go to the source code of this file.
Classes | |
struct | BrushPainterCache |
struct | BrushPainter |
Defines | |
#define | BR_TEST(field, t) |
#define | BR_TEST_FLAG(_f) |
Typedefs | |
typedef struct BrushPainterCache | BrushPainterCache |
Functions | |
static void | brush_set_defaults (Brush *brush) |
Brush * | add_brush (const char *name) |
Brush * | copy_brush (Brush *brush) |
void | free_brush (Brush *brush) |
static void | extern_local_brush (Brush *brush) |
void | make_local_brush (Brush *brush) |
void | brush_debug_print_state (Brush *br) |
void | brush_reset_sculpt (Brush *br) |
void | brush_curve_preset (Brush *b, int preset) |
int | brush_texture_set_nr (Brush *brush, int nr) |
int | brush_texture_delete (Brush *brush) |
int | brush_clone_image_set_nr (Brush *brush, int nr) |
int | brush_clone_image_delete (Brush *brush) |
void | brush_sample_tex (const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) |
void | brush_imbuf_new (const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction) |
void | brush_set_size (Scene *scene, Brush *brush, int size) |
int | brush_size (const Scene *scene, Brush *brush) |
int | brush_use_locked_size (const Scene *scene, Brush *brush) |
int | brush_use_size_pressure (const Scene *scene, Brush *brush) |
int | brush_use_alpha_pressure (const Scene *scene, Brush *brush) |
void | brush_set_unprojected_radius (Scene *scene, Brush *brush, float unprojected_radius) |
float | brush_unprojected_radius (const Scene *scene, Brush *brush) |
static void | brush_set_alpha (Scene *scene, Brush *brush, float alpha) |
float | brush_alpha (const Scene *scene, Brush *brush) |
void | brush_scale_unprojected_radius (float *unprojected_radius, int new_brush_size, int old_brush_size) |
void | brush_scale_size (int *brush_size, float new_unprojected_radius, float old_unprojected_radius) |
BrushPainter * | brush_painter_new (Scene *scene, Brush *brush) |
void | brush_painter_require_imbuf (BrushPainter *painter, short flt, short texonly, int size) |
void | brush_painter_free (BrushPainter *painter) |
static void | brush_painter_do_partial (BrushPainter *painter, ImBuf *oldtexibuf, int x, int y, int w, int h, int xt, int yt, float *pos) |
static void | brush_painter_fixed_tex_partial_update (BrushPainter *painter, float *pos) |
static void | brush_painter_refresh_cache (BrushPainter *painter, float *pos, int use_color_correction) |
void | brush_painter_break_stroke (BrushPainter *painter) |
static void | brush_apply_pressure (BrushPainter *painter, Brush *brush, float pressure) |
void | brush_jitter_pos (const Scene *scene, Brush *brush, float pos[2], float jitterpos[2]) |
int | brush_painter_paint (BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user, int use_color_correction) |
float | brush_curve_strength_clamp (Brush *br, float p, const float len) |
float | brush_curve_strength (Brush *br, float p, const float len) |
unsigned int * | brush_gen_texture_cache (Brush *br, int half_side) |
struct ImBuf * | brush_gen_radial_control_imbuf (Brush *br) |
Definition in file brush.c.
#define BR_TEST | ( | field, | |
t | |||
) |
if(br->field != def.field) \ printf("br->" #field " = %" #t ";\n", br->field)
Referenced by brush_debug_print_state().
#define BR_TEST_FLAG | ( | _f | ) |
if((br->flag & _f) && !(def.flag & _f)) \ printf("br->flag |= " #_f ";\n"); \ else if(!(br->flag & _f) && (def.flag & _f)) \ printf("br->flag &= ~" #_f ";\n")
Referenced by brush_debug_print_state().
typedef struct BrushPainterCache BrushPainterCache |
Brush* add_brush | ( | const char * | name | ) | [read] |
Definition at line 124 of file brush.c.
References alloc_libblock(), brush_curve_preset(), brush_set_defaults(), CURVE_PRESET_SMOOTH, ID::flag, G, Brush::id, ID_BR, LIB_FAKEUSER, Brush::sculpt_tool, and SCULPT_TOOL_DRAW.
Referenced by brush_add_exec(), and paint_init().
Definition at line 712 of file brush.c.
References Brush::alpha, UnifiedPaintSettings::alpha, UnifiedPaintSettings::flag, Scene::toolsettings, UNIFIED_PAINT_ALPHA, and ToolSettings::unified_paint_settings.
static void brush_apply_pressure | ( | BrushPainter * | painter, |
Brush * | brush, | ||
float | pressure | ||
) | [static] |
Definition at line 1040 of file brush.c.
References BRUSH_JITTER_PRESSURE, brush_set_alpha(), brush_set_size(), BRUSH_SPACING_PRESSURE, brush_use_alpha_pressure(), brush_use_size_pressure(), Brush::flag, Brush::jitter, MAX2, BrushPainter::scene, Brush::spacing, BrushPainter::startalpha, BrushPainter::startjitter, BrushPainter::startsize, and BrushPainter::startspacing.
Referenced by brush_painter_paint().
int brush_clone_image_delete | ( | Brush * | brush | ) |
Definition at line 478 of file brush.c.
References Brush::clone, Image::id, BrushClone::image, NULL, and ID::us.
Referenced by brush_clone_image_set_nr().
int brush_clone_image_set_nr | ( | Brush * | brush, |
int | nr | ||
) |
Definition at line 460 of file brush.c.
References BLI_findlink(), brush_clone_image_delete(), Brush::clone, G, Image::id, id_us_plus(), BrushClone::image, and BrushClone::offset.
void brush_curve_preset | ( | Brush * | b, |
int | preset | ||
) |
Definition at line 413 of file brush.c.
References CurveMapping::clipr, CurveMapping::cm, CUMA_EXTEND_EXTRAPOLATE, Brush::curve, curvemap_reset(), CURVEMAP_SLOPE_NEGATIVE, curvemapping_add(), curvemapping_changed(), CurveMap::flag, NULL, and CurveMapping::preset.
Referenced by add_brush(), brush_curve_preset_exec(), brush_reset_sculpt(), and direct_link_brush().
float brush_curve_strength | ( | Brush * | br, |
float | p, | ||
const float | len | ||
) |
Definition at line 1249 of file brush.c.
References Brush::curve, curvemapping_evaluateF(), and len().
Referenced by brush_imbuf_new(), load_tex(), overlapped_curve(), and tex_strength().
float brush_curve_strength_clamp | ( | Brush * | br, |
float | p, | ||
const float | len | ||
) |
Definition at line 1237 of file brush.c.
References Brush::curve, curvemapping_evaluateF(), len(), and p.
Referenced by brush_gen_radial_control_imbuf(), brush_imbuf_new(), calc_vp_strength_dl(), and do_projectpaint_thread().
void brush_debug_print_state | ( | Brush * | br | ) |
Definition at line 244 of file brush.c.
References blend(), BR_TEST, BR_TEST_FLAG, BRUSH_ACCUMULATE, BRUSH_ADAPTIVE_SPACE, BRUSH_AIRBRUSH, BRUSH_ALPHA_PRESSURE, BRUSH_ANCHORED, BRUSH_CUSTOM_ICON, BRUSH_DIR_IN, BRUSH_EDGE_TO_EDGE, BRUSH_FIXED_TEX, BRUSH_FRONTFACE, BRUSH_INVERSE_SMOOTH_PRESSURE, BRUSH_JITTER_PRESSURE, BRUSH_LOCK_ALPHA, BRUSH_LOCK_SIZE, BRUSH_OFFSET_PRESSURE, BRUSH_ORIGINAL_NORMAL, BRUSH_PERSISTENT, BRUSH_PLANE_TRIM, BRUSH_RAKE, BRUSH_RANDOM_ROTATION, BRUSH_RESTORE_MESH, brush_set_defaults(), BRUSH_SIZE_PRESSURE, BRUSH_SMOOTH_STROKE, BRUSH_SPACE, BRUSH_SPACE_ATTEN, BRUSH_SPACING_PRESSURE, BRUSH_TEXTURE_OVERLAY, BRUSH_TORUS, simple_enum_gen::d, NULL, plane_trim(), and size().
Definition at line 1306 of file brush.c.
References brush_curve_strength_clamp(), brush_gen_texture_cache(), i, MEM_callocN(), MEM_freeN(), pow(), ImBuf::rect_float, sqrt(), ImBuf::x, and ImBuf::y.
Referenced by radial_control_set_tex().
unsigned int* brush_gen_texture_cache | ( | Brush * | br, |
int | half_side | ||
) |
Definition at line 1260 of file brush.c.
References BKE_image_get_ibuf(), co, Tex::ima, MEM_callocN(), Brush::mtex, multitex_ext(), NULL, step(), TexResult::tb, MTex::tex, TEX_RGB, TexResult::tg, TexResult::tin, and TexResult::tr.
Referenced by brush_gen_radial_control_imbuf(), and sculpt_update_tex().
void brush_imbuf_new | ( | const Scene * | scene, |
Brush * | brush, | ||
short | flt, | ||
short | texfall, | ||
int | bufsize, | ||
ImBuf ** | outbuf, | ||
int | use_color_correction | ||
) |
Definition at line 524 of file brush.c.
References brush_alpha(), brush_curve_strength(), brush_curve_strength_clamp(), brush_sample_tex(), brush_size(), copy_v3_v3(), F3TOCHAR3, FTOCHAR, IB_rect, IB_rectfloat, IMB_allocImBuf(), len_v2(), mul_v3_v3(), mul_v3_v3v3(), ImBuf::rect, ImBuf::rect_float, Brush::rgb, srgb_to_linearrgb_v3_v3(), ImBuf::x, and ImBuf::y.
Definition at line 1052 of file brush.c.
References BLI_frand(), BRUSH_ANCHORED, BRUSH_RESTORE_MESH, brush_size(), copy_v2_v2(), Brush::flag, Brush::jitter, and len_v2().
void brush_painter_break_stroke | ( | BrushPainter * | painter | ) |
Definition at line 1035 of file brush.c.
References BrushPainter::firsttouch.
Referenced by imapaint_paint_stroke().
static void brush_painter_do_partial | ( | BrushPainter * | painter, |
ImBuf * | oldtexibuf, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
int | xt, | ||
int | yt, | ||
float * | pos | ||
) | [static] |
Definition at line 840 of file brush.c.
References BrushPainter::brush, brush_sample_tex(), brush_size(), BrushPainter::cache, copy_v3_v3(), BrushPainterCache::flt, FTOCHAR, BrushPainterCache::ibuf, BrushPainterCache::maskibuf, MIN2, NULL, ImBuf::rect, ImBuf::rect_float, BrushPainter::scene, BrushPainter::startpaintpos, BrushPainterCache::texibuf, simple_enum_gen::w, ImBuf::x, and ImBuf::y.
Referenced by brush_painter_fixed_tex_partial_update().
static void brush_painter_fixed_tex_partial_update | ( | BrushPainter * | painter, |
float * | pos | ||
) | [static] |
Definition at line 933 of file brush.c.
References BrushPainter::brush, brush_painter_do_partial(), brush_size(), BrushPainter::cache, BrushPainterCache::flt, IB_rect, IB_rectfloat, BrushPainterCache::ibuf, IMB_allocImBuf(), IMB_freeImBuf(), IMB_rectclip(), BrushPainter::lastpaintpos, NULL, BrushPainter::scene, BrushPainterCache::texibuf, simple_enum_gen::w, ImBuf::x, and ImBuf::y.
Referenced by brush_painter_refresh_cache().
void brush_painter_free | ( | BrushPainter * | painter | ) |
Definition at line 825 of file brush.c.
References BrushPainter::brush, brush_set_alpha(), brush_set_size(), BrushPainter::cache, BrushPainterCache::ibuf, IMB_freeImBuf(), Brush::jitter, BrushPainterCache::maskibuf, MEM_freeN(), BrushPainter::scene, Brush::spacing, BrushPainter::startalpha, BrushPainter::startjitter, BrushPainter::startsize, BrushPainter::startspacing, and BrushPainterCache::texibuf.
Referenced by paint_exit().
BrushPainter* brush_painter_new | ( | Scene * | scene, |
Brush * | brush | ||
) |
Definition at line 786 of file brush.c.
References BrushPainter::brush, brush_alpha(), brush_size(), BrushPainter::cache, BrushPainter::firsttouch, Brush::jitter, BrushPainterCache::lastsize, MEM_callocN(), BrushPainter::scene, Brush::spacing, BrushPainter::startalpha, BrushPainter::startjitter, BrushPainter::startsize, and BrushPainter::startspacing.
Referenced by texture_paint_init().
int brush_painter_paint | ( | BrushPainter * | painter, |
BrushFunc | func, | ||
float * | pos, | ||
double | time, | ||
float | pressure, | ||
void * | user, | ||
int | use_color_correction | ||
) |
Definition at line 1079 of file brush.c.
References BrushPainter::accumdistance, BrushPainter::accumtime, BrushPainter::brush, BRUSH_AIRBRUSH, brush_apply_pressure(), brush_jitter_pos(), brush_painter_refresh_cache(), brush_set_alpha(), brush_set_size(), brush_size(), BRUSH_SPACE, BrushPainter::cache, BrushPainterCache::enabled, BrushPainter::firsttouch, Brush::flag, BrushPainterCache::ibuf, Brush::jitter, BrushPainter::lastmousepos, BrushPainter::lastpaintpos, BrushPainter::lastpressure, BrushPainter::lasttime, len(), MAX2, normalize_v2(), Brush::rate, BrushPainter::scene, Brush::spacing, BrushPainter::startalpha, BrushPainter::startjitter, BrushPainter::startpaintpos, BrushPainter::startsize, BrushPainter::startspacing, step(), and sub_v2_v2v2().
Referenced by imapaint_paint_sub_stroke(), and project_paint_sub_stroke().
static void brush_painter_refresh_cache | ( | BrushPainter * | painter, |
float * | pos, | ||
int | use_color_correction | ||
) | [static] |
Definition at line 988 of file brush.c.
References BrushPainter::brush, brush_alpha(), BRUSH_FIXED_TEX, brush_imbuf_new(), brush_painter_fixed_tex_partial_update(), brush_size(), BrushPainter::cache, Brush::flag, BrushPainterCache::flt, BrushPainterCache::ibuf, if(), IMB_freeImBuf(), Brush::jitter, BrushPainterCache::lastalpha, BrushPainterCache::lastjitter, BrushPainter::lastpaintpos, BrushPainterCache::lastsize, BrushPainterCache::maskibuf, Brush::mtex, NULL, BrushPainter::scene, BrushPainterCache::size, size(), and MTex::tex.
Referenced by brush_painter_paint().
void brush_painter_require_imbuf | ( | BrushPainter * | painter, |
short | flt, | ||
short | texonly, | ||
int | size | ||
) |
Definition at line 803 of file brush.c.
References BrushPainter::cache, BrushPainterCache::enabled, BrushPainterCache::flt, BrushPainterCache::ibuf, IMB_freeImBuf(), BrushPainterCache::lastsize, BrushPainterCache::maskibuf, NULL, BrushPainterCache::size, size(), BrushPainterCache::texibuf, and BrushPainterCache::texonly.
Referenced by imapaint_paint_sub_stroke().
void brush_reset_sculpt | ( | Brush * | br | ) |
Definition at line 331 of file brush.c.
References Brush::add_col, Brush::alpha, BRUSH_ALPHA_PRESSURE, brush_curve_preset(), BRUSH_DIR_IN, BRUSH_FRONTFACE, brush_set_defaults(), BRUSH_SPACE, BRUSH_SPACE_ATTEN, CURVE_PRESET_SMOOTH, Brush::flag, Brush::sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_GRAB, SCULPT_TOOL_INFLATE, SCULPT_TOOL_NUDGE, SCULPT_TOOL_PINCH, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SCRAPE, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, Brush::size, Brush::spacing, and Brush::sub_col.
Referenced by brush_reset_exec().
void brush_sample_tex | ( | const Scene * | scene, |
Brush * | brush, | ||
const float | xy[2], | ||
float | rgba[4], | ||
const int | thread | ||
) |
Definition at line 490 of file brush.c.
References brush_size(), co, externtex(), Brush::mtex, and MTex::tex.
void brush_scale_size | ( | int * | brush_size, |
float | new_unprojected_radius, | ||
float | old_unprojected_radius | ||
) |
void brush_scale_unprojected_radius | ( | float * | unprojected_radius, |
int | new_brush_size, | ||
int | old_brush_size | ||
) |
Definition at line 702 of file brush.c.
References Brush::alpha, UnifiedPaintSettings::alpha, UnifiedPaintSettings::flag, Scene::toolsettings, UNIFIED_PAINT_ALPHA, and ToolSettings::unified_paint_settings.
Referenced by brush_apply_pressure(), brush_painter_free(), and brush_painter_paint().
static void brush_set_defaults | ( | Brush * | brush | ) | [static] |
Definition at line 70 of file brush.c.
References Brush::add_col, Brush::alpha, BrushClone::alpha, Brush::autosmooth_factor, Brush::blend, BRUSH_ALPHA_PRESSURE, BRUSH_SPACE, BRUSH_SPACE_ATTEN, Brush::clone, Brush::crease_pinch_factor, default_mtex(), Brush::flag, Brush::jitter, Brush::mtex, Brush::normal_weight, Brush::ob_mode, OB_MODE_ALL_PAINT, Brush::plane_offset, Brush::plane_trim, Brush::rate, Brush::rgb, SCULPT_DISP_DIR_AREA, Brush::sculpt_plane, Brush::size, Brush::smooth_stroke_factor, Brush::smooth_stroke_radius, Brush::spacing, Brush::sub_col, Brush::texture_overlay_alpha, and Brush::texture_sample_bias.
Referenced by add_brush(), brush_debug_print_state(), and brush_reset_sculpt().
Definition at line 639 of file brush.c.
References UnifiedPaintSettings::flag, UnifiedPaintSettings::size, size(), Brush::size, Scene::toolsettings, ToolSettings::unified_paint_settings, and UNIFIED_PAINT_SIZE.
Referenced by brush_apply_pressure(), brush_painter_free(), brush_painter_paint(), brush_scale_size_exec(), paint_draw_cursor(), paint_exit(), texture_paint_camera_project_exec(), and texture_paint_init().
Definition at line 683 of file brush.c.
References UnifiedPaintSettings::flag, Scene::toolsettings, ToolSettings::unified_paint_settings, UNIFIED_PAINT_SIZE, UnifiedPaintSettings::unprojected_radius, and Brush::unprojected_radius.
Referenced by brush_scale_size_exec(), paint_cursor_on_hit(), and sculpt_update_cache_variants().
Definition at line 649 of file brush.c.
References UnifiedPaintSettings::flag, Brush::size, UnifiedPaintSettings::size, Scene::toolsettings, ToolSettings::unified_paint_settings, and UNIFIED_PAINT_SIZE.
int brush_texture_delete | ( | Brush * | brush | ) |
Definition at line 452 of file brush.c.
References Tex::id, Brush::mtex, MTex::tex, and ID::us.
Referenced by brush_texture_set_nr().
int brush_texture_set_nr | ( | Brush * | brush, |
int | nr | ||
) |
Definition at line 428 of file brush.c.
References add_texture(), BLI_findlink(), brush_texture_delete(), copy_texture(), G, id_us_plus(), Brush::mtex, NULL, MTex::tex, and ID::us.
Definition at line 693 of file brush.c.
References UnifiedPaintSettings::flag, Scene::toolsettings, ToolSettings::unified_paint_settings, UNIFIED_PAINT_SIZE, UnifiedPaintSettings::unprojected_radius, and Brush::unprojected_radius.
Definition at line 674 of file brush.c.
References BRUSH_ALPHA_PRESSURE, UnifiedPaintSettings::flag, Brush::flag, Scene::toolsettings, UNIFIED_PAINT_ALPHA, UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE, and ToolSettings::unified_paint_settings.
Definition at line 656 of file brush.c.
References BRUSH_LOCK_SIZE, UnifiedPaintSettings::flag, Brush::flag, Scene::toolsettings, UNIFIED_PAINT_BRUSH_LOCK_SIZE, ToolSettings::unified_paint_settings, and UNIFIED_PAINT_SIZE.
Definition at line 665 of file brush.c.
References BRUSH_SIZE_PRESSURE, UnifiedPaintSettings::flag, Brush::flag, Scene::toolsettings, UNIFIED_PAINT_BRUSH_SIZE_PRESSURE, ToolSettings::unified_paint_settings, and UNIFIED_PAINT_SIZE.
Definition at line 143 of file brush.c.
References copy_libblock(), Brush::curve, curvemapping_copy(), ID::flag, Brush::icon_imbuf, Brush::id, id_us_plus(), IMB_dupImBuf(), LIB_FAKEUSER, Brush::mtex, NULL, Brush::preview, MTex::tex, and ID::us.
Referenced by brush_add_exec(), id_copy(), and make_local_brush().
static void extern_local_brush | ( | Brush * | brush | ) | [static] |
Definition at line 182 of file brush.c.
References Brush::clone, id_lib_extern(), BrushClone::image, Brush::mtex, and MTex::tex.
Referenced by make_local_brush().
void free_brush | ( | Brush * | brush | ) |
Definition at line 169 of file brush.c.
References BKE_previewimg_free(), Brush::curve, curvemapping_free(), Brush::icon_imbuf, Tex::id, IMB_freeImBuf(), Brush::mtex, Brush::preview, MTex::tex, and ID::us.
Referenced by free_libblock().
void make_local_brush | ( | Brush * | brush | ) |
Definition at line 188 of file brush.c.
References BKE_id_lib_local_paths(), Brush::clone, copy_brush(), ELEM, extern_local_brush(), FALSE, ListBase::first, ID::flag, G, Scene::id, Brush::id, Image::id, id_clear_lib_data(), BrushClone::image, ToolSettings::imapaint, ID::lib, LIB_FAKEUSER, ID::next, NULL, ImagePaintSettings::paint, paint_brush(), paint_brush_set(), Main::scene, bContext::scene, Scene::toolsettings, TRUE, and ID::us.
Referenced by id_make_local().