Blender V2.61 - r43446
|
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
#include "RNA_access.h"
#include "BKE_context.h"
#include "BKE_paint.h"
#include "BKE_brush.h"
#include "WM_api.h"
#include "WM_types.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "paint_intern.h"
#include "sculpt_intern.h"
#include <float.h>
#include <math.h>
Go to the source code of this file.
Classes | |
struct | PaintStroke |
struct | Snapshot |
Typedefs | |
typedef struct PaintStroke | PaintStroke |
typedef struct Snapshot | Snapshot |
Functions | |
static void | paint_draw_smooth_stroke (bContext *C, int x, int y, void *customdata) |
static int | same_snap (Snapshot *snap, Brush *brush, ViewContext *vc) |
static void | make_snap (Snapshot *snap, Brush *brush, ViewContext *vc) |
static int | load_tex (Sculpt *sd, Brush *br, ViewContext *vc) |
static int | project_brush_radius (RegionView3D *rv3d, float radius, float location[3], bglMats *mats) |
static int | sculpt_get_brush_geometry (bContext *C, int x, int y, int *pixel_radius, float location[3]) |
static void | paint_draw_alpha_overlay (Sculpt *sd, Brush *brush, ViewContext *vc, int x, int y) |
static void | paint_cursor_on_hit (Sculpt *sd, Brush *brush, ViewContext *vc, const float location[3]) |
static void | paint_draw_cursor (bContext *C, int x, int y, void *UNUSED(unused)) |
static float | event_tablet_data (wmEvent *event, int *pen_flip) |
static void | paint_brush_stroke_add_step (bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2]) |
static int | paint_smooth_stroke (PaintStroke *stroke, float output[2], wmEvent *event) |
static int | paint_space_stroke (bContext *C, wmOperator *op, wmEvent *event, const float final_mouse[2]) |
PaintStroke * | paint_stroke_new (bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, StrokeDone done, int event_type) |
void | paint_stroke_free (PaintStroke *stroke) |
int | paint_space_stroke_enabled (Brush *br) |
int | paint_stroke_modal (bContext *C, wmOperator *op, wmEvent *event) |
int | paint_stroke_exec (bContext *C, wmOperator *op) |
int | paint_stroke_cancel (bContext *C, wmOperator *op) |
ViewContext * | paint_stroke_view_context (PaintStroke *stroke) |
void * | paint_stroke_mode_data (struct PaintStroke *stroke) |
void | paint_stroke_set_mode_data (PaintStroke *stroke, void *mode_data) |
int | paint_poll (bContext *C) |
void | paint_cursor_start (bContext *C, int(*poll)(bContext *C)) |
Definition in file paint_stroke.c.
typedef struct PaintStroke PaintStroke |
static float event_tablet_data | ( | wmEvent * | event, |
int * | pen_flip | ||
) | [static] |
Definition at line 659 of file paint_stroke.c.
References wmTabletData::Active, wmEvent::custom, EVT_DATA_TABLET, EVT_TABLET_ERASER, EVT_TABLET_NONE, and wmTabletData::Pressure.
Referenced by paint_brush_stroke_add_step(), and paint_space_stroke().
static int load_tex | ( | Sculpt * | sd, |
Brush * | br, | ||
ViewContext * | vc | ||
) | [static] |
Definition at line 161 of file paint_stroke.c.
References angle(), ViewContext::ar, atan2f, avg, brush_curve_strength(), MTex::brush_map_mode, brush_size(), CurveMapping::changed_timestamp, PreviewImage::changed_timestamp, cosf, Brush::curve, i, init(), len(), make_snap(), MEM_freeN(), MEM_mallocN(), Brush::mtex, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED, NULL, MTex::ofs, paint_get_tex_pixel(), Tex::preview, MTex::rot, same_snap(), ViewContext::scene, sinf, MTex::size, size(), sqrtf, MTex::tex, Brush::texture_sample_bias, ARegion::winx, and ARegion::winy.
Referenced by paint_draw_alpha_overlay().
static void make_snap | ( | Snapshot * | snap, |
Brush * | brush, | ||
ViewContext * | vc | ||
) | [static] |
Definition at line 141 of file paint_stroke.c.
References ViewContext::ar, MTex::brush_map_mode, Snapshot::brush_map_mode, brush_size(), Snapshot::brush_size, copy_v3_v3(), Brush::mtex, MTex::ofs, Snapshot::ofs, MTex::rot, Snapshot::rot, ViewContext::scene, MTex::size, Snapshot::size, MTex::tex, ARegion::winx, Snapshot::winx, ARegion::winy, and Snapshot::winy.
Referenced by load_tex().
static void paint_brush_stroke_add_step | ( | bContext * | C, |
wmOperator * | op, | ||
wmEvent * | event, | ||
float | mouse_in[2] | ||
) | [static] |
Definition at line 678 of file paint_stroke.c.
References add_v2_v2v2(), PaintStroke::brush, brush_jitter_pos(), BRUSH_JITTER_PRESSURE, copy_v2_v2(), CTX_data_scene(), wmOperator::customdata, event_tablet_data(), Brush::flag, PaintStroke::get_location, PaintStroke::last_mouse_position, mul_v2_fl(), ViewContext::obact, paint_brush(), paint_get_active(), wmOperator::ptr, RNA_boolean_set(), RNA_collection_add(), RNA_float_set(), RNA_float_set_array(), Object::sculpt, sub_v2_v2v2(), PaintStroke::update_step, PaintStroke::vc, and zero_v3().
Referenced by paint_space_stroke(), and paint_stroke_modal().
static void paint_cursor_on_hit | ( | Sculpt * | sd, |
Brush * | brush, | ||
ViewContext * | vc, | ||
const float | location[3] | ||
) | [static] |
Definition at line 512 of file paint_stroke.c.
References Sculpt::anchored_size, BRUSH_ANCHORED, brush_set_unprojected_radius(), brush_size(), brush_use_locked_size(), brush_use_size_pressure(), Sculpt::draw_anchored, Sculpt::draw_pressure, Brush::flag, paint_calc_object_space_radius(), Sculpt::pressure_value, and ViewContext::scene.
Referenced by paint_draw_cursor().
Definition at line 980 of file paint_stroke.c.
References CTX_data_scene(), CTX_wm_manager(), NULL, p, Paint::paint_cursor, paint_draw_cursor(), paint_get_active(), and WM_paint_cursor_activate().
static void paint_draw_alpha_overlay | ( | Sculpt * | sd, |
Brush * | brush, | ||
ViewContext * | vc, | ||
int | x, | ||
int | y | ||
) | [static] |
Definition at line 414 of file paint_stroke.c.
References Sculpt::anchored_initial_mouse, Sculpt::anchored_size, ViewContext::ar, MTex::brush_map_mode, BRUSH_RAKE, brush_size(), BRUSH_TEXTURE_OVERLAY, brush_use_size_pressure(), Sculpt::draw_anchored, Sculpt::draw_pressure, ELEM, Brush::flag, Sculpt::last_angle, load_tex(), Brush::mtex, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED, Sculpt::pressure_value, RAD2DEGF, ViewContext::scene, UserDef::sculpt_paint_overlay_col, Sculpt::special_rotation, Brush::texture_overlay_alpha, U, ARegion::winrct, rcti::xmax, rctf::xmax, rcti::xmin, rctf::xmin, rcti::ymax, rctf::ymax, rcti::ymin, and rctf::ymin.
Referenced by paint_draw_cursor().
static void paint_draw_cursor | ( | bContext * | C, |
int | x, | ||
int | y, | ||
void * | UNUSEDunused | ||
) | [static] |
Definition at line 542 of file paint_stroke.c.
References Brush::add_col, Sculpt::anchored_initial_mouse, Sculpt::anchored_size, ViewContext::ar, KDL::atan2(), PaintStroke::brush, brush_alpha(), BRUSH_DIR_IN, BRUSH_INVERTED, brush_set_size(), brush_size(), brush_use_alpha_pressure(), brush_use_locked_size(), CTX_data_scene(), CTX_data_tool_settings(), Sculpt::draw_anchored, Sculpt::draw_pressure, ELEM5, Brush::flag, Paint::flags, glutil_draw_lined_arc(), Sculpt::last_angle, Sculpt::last_x, Sculpt::last_y, M_PI, ViewContext::obact, paint_brush(), paint_cursor_on_hit(), paint_draw_alpha_overlay(), paint_get_active(), PAINT_SHOW_BRUSH, PAINT_SHOW_BRUSH_ON_SURFACE, Sculpt::pressure_value, ViewContext::scene, ToolSettings::sculpt, Object::sculpt, sculpt_get_brush_geometry(), Brush::sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, Brush::sub_col, PaintStroke::vc, view3d_set_viewcontext(), ARegion::winrct, rcti::xmin, and rcti::ymin.
Referenced by paint_cursor_start().
static void paint_draw_smooth_stroke | ( | bContext * | C, |
int | x, | ||
int | y, | ||
void * | customdata | ||
) | [static] |
Definition at line 92 of file paint_stroke.c.
References BRUSH_SMOOTH_STROKE, CTX_data_scene(), CTX_wm_region(), Brush::flag, PaintStroke::last_mouse_position, paint_brush(), paint_get_active(), sdrawline(), ARegion::winrct, rcti::xmin, and rcti::ymin.
Referenced by paint_stroke_modal().
int paint_poll | ( | bContext * | C | ) |
Definition at line 970 of file paint_stroke.c.
References CTX_data_active_object(), CTX_data_scene(), CTX_wm_area(), CTX_wm_region(), p, paint_brush(), paint_get_active(), ARegion::regiontype, RGN_TYPE_WINDOW, SPACE_VIEW3D, and ScrArea::spacetype.
Referenced by paint_stroke_modal(), and sculpt_poll().
static int paint_smooth_stroke | ( | PaintStroke * | stroke, |
float | output[2], | ||
wmEvent * | event | ||
) | [static] |
Definition at line 734 of file paint_stroke.c.
References PaintStroke::brush, BRUSH_ANCHORED, BRUSH_RESTORE_MESH, BRUSH_SMOOTH_STROKE, ELEM4, Brush::flag, PaintStroke::last_mouse_position, Brush::sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, Brush::smooth_stroke_factor, and Brush::smooth_stroke_radius.
Referenced by paint_stroke_modal().
static int paint_space_stroke | ( | bContext * | C, |
wmOperator * | op, | ||
wmEvent * | event, | ||
const float | final_mouse[2] | ||
) | [static] |
Definition at line 761 of file paint_stroke.c.
References add_v2_v2(), PaintStroke::brush, brush_size(), brush_use_size_pressure(), copy_v2_v2(), CTX_data_scene(), wmOperator::customdata, event_tablet_data(), i, PaintStroke::last_mouse_position, len_v2(), length(), mul_v2_fl(), NULL, paint_brush_stroke_add_step(), paint_space_stroke_enabled(), Brush::spacing, and sub_v2_v2v2().
Referenced by paint_stroke_modal().
int paint_space_stroke_enabled | ( | Brush * | br | ) |
Definition at line 834 of file paint_stroke.c.
References BRUSH_ANCHORED, BRUSH_SPACE, ELEM4, Brush::flag, Brush::sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK, and SCULPT_TOOL_THUMB.
Referenced by paint_space_stroke(), paint_stroke_modal(), and sculpt_update_cache_variants().
int paint_stroke_cancel | ( | bContext * | C, |
wmOperator * | op | ||
) |
Definition at line 942 of file paint_stroke.c.
References wmOperator::customdata, PaintStroke::done, MEM_freeN(), NULL, and OPERATOR_CANCELLED.
Referenced by sculpt_brush_stroke_cancel(), vpaint_cancel(), and wpaint_cancel().
int paint_stroke_exec | ( | bContext * | C, |
wmOperator * | op | ||
) |
Definition at line 918 of file paint_stroke.c.
References wmOperator::customdata, PaintStroke::done, MEM_freeN(), NULL, OPERATOR_FINISHED, wmOperator::ptr, RNA_BEGIN, RNA_END, PaintStroke::stroke_started, PaintStroke::test_start, and PaintStroke::update_step.
Referenced by sculpt_brush_stroke_exec().
void paint_stroke_free | ( | PaintStroke * | stroke | ) |
Definition at line 828 of file paint_stroke.c.
References MEM_freeN().
Referenced by sculpt_brush_stroke_invoke(), and sculpt_get_brush_geometry().
int paint_stroke_modal | ( | bContext * | C, |
wmOperator * | op, | ||
wmEvent * | event | ||
) |
Definition at line 841 of file paint_stroke.c.
References PaintStroke::brush, BRUSH_AIRBRUSH, BRUSH_ANCHORED, BRUSH_SMOOTH_STROKE, CTX_wm_manager(), CTX_wm_window(), wmEvent::customdata, wmOperator::customdata, PaintStroke::done, ELEM, PaintStroke::event_type, Brush::flag, INBETWEEN_MOUSEMOVE, KM_RELEASE, PaintStroke::last_mouse_position, MEM_freeN(), MOUSEMOVE, NDOF_MOTION, OPERATOR_FINISHED, OPERATOR_PASS_THROUGH, OPERATOR_RUNNING_MODAL, paint_brush_stroke_add_step(), paint_draw_smooth_stroke(), paint_poll(), paint_smooth_stroke(), paint_space_stroke(), paint_space_stroke_enabled(), Brush::rate, PaintStroke::smooth_stroke_cursor, PaintStroke::stroke_started, PaintStroke::test_start, TIMER, PaintStroke::timer, wmEvent::type, wmEvent::val, WM_event_add_timer(), WM_event_remove_timer(), WM_paint_cursor_activate(), and WM_paint_cursor_end().
Referenced by PAINT_OT_vertex_paint(), PAINT_OT_weight_paint(), and SCULPT_OT_brush_stroke().
void* paint_stroke_mode_data | ( | struct PaintStroke * | stroke | ) |
Definition at line 960 of file paint_stroke.c.
References PaintStroke::mode_data.
Referenced by vpaint_stroke_done(), vpaint_stroke_update_step(), wpaint_stroke_done(), and wpaint_stroke_update_step().
PaintStroke* paint_stroke_new | ( | bContext * | C, |
StrokeGetLocation | get_location, | ||
StrokeTestStart | test_start, | ||
StrokeUpdateStep | update_step, | ||
StrokeDone | done, | ||
int | event_type | ||
) | [read] |
Definition at line 807 of file paint_stroke.c.
References ViewContext::ar, PaintStroke::brush, CTX_data_scene(), PaintStroke::done, PaintStroke::event_type, PaintStroke::get_location, PaintStroke::mats, MEM_callocN(), ViewContext::obact, paint_brush(), paint_get_active(), ViewContext::rv3d, PaintStroke::test_start, PaintStroke::update_step, PaintStroke::vc, view3d_get_transformation(), and view3d_set_viewcontext().
Referenced by sculpt_brush_stroke_exec(), sculpt_brush_stroke_invoke(), sculpt_get_brush_geometry(), vpaint_invoke(), and wpaint_invoke().
void paint_stroke_set_mode_data | ( | PaintStroke * | stroke, |
void * | mode_data | ||
) |
Definition at line 965 of file paint_stroke.c.
References PaintStroke::mode_data.
Referenced by vpaint_stroke_test_start(), and wpaint_stroke_test_start().
ViewContext* paint_stroke_view_context | ( | PaintStroke * | stroke | ) | [read] |
Definition at line 955 of file paint_stroke.c.
References PaintStroke::vc.
Referenced by sculpt_stroke_get_location(), sculpt_update_cache_invariants(), and sculpt_update_cache_variants().
static int project_brush_radius | ( | RegionView3D * | rv3d, |
float | radius, | ||
float | location[3], | ||
bglMats * | mats | ||
) | [static] |
Definition at line 332 of file paint_stroke.c.
References add_v3_v3v3(), cross_v3_v3v3(), ED_view3d_global_to_vector(), fabsf, len_v2v2(), mul_v3_fl(), normalize_v3(), and projectf().
Referenced by sculpt_get_brush_geometry().
static int same_snap | ( | Snapshot * | snap, |
Brush * | brush, | ||
ViewContext * | vc | ||
) | [static] |
Definition at line 122 of file paint_stroke.c.
References ViewContext::ar, Snapshot::brush_map_mode, MTex::brush_map_mode, Snapshot::brush_size, brush_size(), equals_v3v3(), Brush::mtex, MTEX_MAP_MODE_FIXED, Snapshot::ofs, MTex::ofs, Snapshot::rot, MTex::rot, ViewContext::scene, Snapshot::size, MTex::size, MTex::tex, Snapshot::winx, ARegion::winx, Snapshot::winy, and ARegion::winy.
Referenced by load_tex().
static int sculpt_get_brush_geometry | ( | bContext * | C, |
int | x, | ||
int | y, | ||
int * | pixel_radius, | ||
float | location[3] | ||
) | [static] |
Definition at line 372 of file paint_stroke.c.
References ViewContext::ar, PaintStroke::brush, brush_size(), brush_unprojected_radius(), CTX_data_scene(), CTX_data_tool_settings(), PaintStroke::mats, mul_m4_v3(), NULL, ViewContext::obact, Object::obmat, Sculpt::paint, paint_brush(), paint_stroke_free(), paint_stroke_new(), SculptSession::pbvh, project_brush_radius(), ViewContext::rv3d, ToolSettings::sculpt, Object::sculpt, sculpt_stroke_get_location(), PaintStroke::vc, ARegion::winrct, rcti::xmin, and rcti::ymin.
Referenced by paint_draw_cursor().