Blender
V3.3
|
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_mempool.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_curve.h"
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_view3d.h"
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
#include "curve_intern.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_prototypes.h"
#include "RNA_enum_types.h"
#include "curve_fit_nd.h"
Go to the source code of this file.
Classes | |
struct | StrokeElem |
struct | CurveDrawData |
Macros | |
#define | USE_SPLINE_FIT |
#define | STROKE_SAMPLE_DIST_MIN_PX 1 |
#define | STROKE_SAMPLE_DIST_MAX_PX 3 |
#define | STROKE_CYCLIC_DIST_PX 8 |
Functions | |
StrokeElem / #RNA_OperatorStrokeElement Conversion Functions | |
static float | stroke_elem_radius_from_pressure (const struct CurveDrawData *cdd, const float pressure) |
static float | stroke_elem_radius (const struct CurveDrawData *cdd, const struct StrokeElem *selem) |
static void | stroke_elem_pressure_set (const struct CurveDrawData *cdd, struct StrokeElem *selem, float pressure) |
static void | stroke_elem_interp (struct StrokeElem *selem_out, const struct StrokeElem *selem_a, const struct StrokeElem *selem_b, float t) |
static bool | stroke_elem_project (const struct CurveDrawData *cdd, const int mval_i[2], const float mval_fl[2], float surface_offset, const float radius, float r_location_world[3], float r_normal_world[3]) |
static bool | stroke_elem_project_fallback (const struct CurveDrawData *cdd, const int mval_i[2], const float mval_fl[2], const float surface_offset, const float radius, const float location_fallback_depth[3], float r_location_world[3], float r_location_local[3], float r_normal_world[3], float r_normal_local[3]) |
static bool | stroke_elem_project_fallback_elem (const struct CurveDrawData *cdd, const float location_fallback_depth[3], struct StrokeElem *selem) |
Operator/Stroke Conversion | |
static void | curve_draw_stroke_to_operator_elem (wmOperator *op, const struct StrokeElem *selem) |
static void | curve_draw_stroke_from_operator_elem (wmOperator *op, PointerRNA *itemptr) |
static void | curve_draw_stroke_to_operator (wmOperator *op) |
static void | curve_draw_stroke_from_operator (wmOperator *op) |
Operator Callbacks & Helpers | |
static void | curve_draw_stroke_3d (const struct bContext *UNUSED(C), ARegion *UNUSED(region), void *arg) |
static void | curve_draw_event_add (wmOperator *op, const wmEvent *event) |
static void | curve_draw_event_add_first (wmOperator *op, const wmEvent *event) |
static bool | curve_draw_init (bContext *C, wmOperator *op, bool is_invoke) |
static void | curve_draw_exit (wmOperator *op) |
static void | curve_draw_exec_precalc (wmOperator *op) |
static int | curve_draw_exec (bContext *C, wmOperator *op) |
static int | curve_draw_invoke (bContext *C, wmOperator *op, const wmEvent *event) |
static void | curve_draw_cancel (bContext *UNUSED(C), wmOperator *op) |
static int | curve_draw_modal (bContext *C, wmOperator *op, const wmEvent *event) |
void | CURVE_OT_draw (wmOperatorType *ot) |
#define STROKE_CYCLIC_DIST_PX 8 |
Definition at line 59 of file editcurve_paint.c.
#define STROKE_SAMPLE_DIST_MAX_PX 3 |
Definition at line 56 of file editcurve_paint.c.
#define STROKE_SAMPLE_DIST_MIN_PX 1 |
Definition at line 55 of file editcurve_paint.c.
#define USE_SPLINE_FIT |
Definition at line 48 of file editcurve_paint.c.
|
static |
Definition at line 1129 of file editcurve_paint.c.
References curve_draw_exit().
Referenced by curve_draw_modal(), and CURVE_OT_draw().
|
static |
Definition at line 443 of file editcurve_paint.c.
References ARRAY_SET_ITEMS, BLI_mempool_calloc(), ceil(), copy_v2_v2(), copy_v3_v3(), wmOperator::customdata, ED_region_tag_redraw(), Object::imat, invert_m4_m4(), len_squared_v2v2(), StrokeElem::location_world, CurveDrawData::location_world, CurveDrawData::location_world_valid, StrokeElem::mval, CurveDrawData::mval, wmEvent::mval, ViewContext::obedit, Object::obmat, StrokeElem::pressure, CurveDrawData::prev, ViewContext::region, CurveDrawData::sample, CurveDrawData::selem, sqrt(), square_f(), stroke_elem_interp(), CurveDrawData::stroke_elem_pool, stroke_elem_project_fallback_elem(), STROKE_SAMPLE_DIST_MAX_PX, CurveDrawData::use_substeps, and CurveDrawData::vc.
Referenced by curve_draw_event_add_first(), and curve_draw_modal().
|
static |
Definition at line 499 of file editcurve_paint.c.
References copy_v3_v3(), cross_v3_v3v3(), curve_draw_event_add(), CurveDrawData::CURVE_DRAW_PAINTING, CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS, CURVE_PAINT_PROJECT_SURFACE, ToolSettings::curve_paint_settings, CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE, CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW, wmOperator::customdata, CurvePaintSettings::depth_mode, CurveDrawData::depths, dot_v3v3(), ED_view3d_depth_read_cached_normal(), ELEM, CurvePaintSettings::flag, CurveDrawData::init_event_type, is_zero_v3(), CurveDrawData::location_world_valid, wmEvent::mval, normal, normalize_v3_v3(), NULL, CurveDrawData::offset, CurveDrawData::plane, CurveDrawData::prev, CurveDrawData::project, ViewContext::region, ViewContext::rv3d, ViewContext::scene, CurveDrawData::state, stroke_elem_project(), sub_v3_v3v3(), CurveDrawData::surface_offset, CurvePaintSettings::surface_plane, Scene::toolsettings, UNPACK2, CurveDrawData::use_depth, CurveDrawData::use_offset, CurveDrawData::use_plane, CurveDrawData::vc, and RegionView3D::viewinv.
Referenced by curve_draw_invoke(), and curve_draw_modal().
|
static |
Definition at line 743 of file editcurve_paint.c.
References Curve::actvert, Nurb::bezt, BKE_curve_nurb_active_set(), BKE_nurb_handles_calc(), BKE_nurb_knot_calc_u(), BLI_addtail(), BLI_mempool_iternew(), BLI_mempool_iterstep(), BLI_mempool_len(), Nurb::bp, C, copy_v3_v3(), CU_3D, CU_BEZIER, CU_NURB_CYCLIC, CU_POLY, CU_SMOOTH, curve_draw_exit(), curve_draw_init(), curve_draw_stroke_from_operator(), CURVE_PAINT_FIT_METHOD_REFIT, CURVE_PAINT_FIT_METHOD_SPLIT, CURVE_PAINT_FLAG_PRESSURE_RADIUS, ToolSettings::curve_paint_settings, CurveDrawData::curve_type, wmOperator::customdata, Object::data, DEG_id_tag_update(), ED_curve_deselect_all_multi(), BezTriple::f1, BPoint::f1, BezTriple::f2, BezTriple::f3, Nurb::flag, Curve::flag, CurvePaintSettings::flag, Nurb::flagu, free(), BezTriple::h1, BezTriple::h2, HD_ALIGN, HD_AUTO, HD_FREE, Object::imat, invert_m4_m4(), StrokeElem::location_local, M_PI, MEM_callocN, MEM_freeN, MEM_mallocN, CurveDrawData::min, NC_GEOM, ND_DATA, NULL, ViewContext::obedit, object_editcurve_get(), Object::obmat, OPERATOR_CANCELLED, OPERATOR_FINISHED, Nurb::orderu, Nurb::orderv, Nurb::pntsu, Nurb::pntsv, StrokeElem::pressure, wmOperator::ptr, CurveDrawData::radius, BezTriple::radius, BPoint::radius, CurvePaintSettings::radius_max, CurvePaintSettings::radius_min, CurvePaintSettings::radius_taper_end, CurvePaintSettings::radius_taper_start, CurveDrawData::range, Nurb::resolu, Curve::resolu, Nurb::resolv, Curve::resolv, result, RNA_boolean_get(), RNA_enum_get(), RNA_float_get(), ViewContext::scene, SELECT, CurveDrawData::stroke_elem_pool, Scene::toolsettings, Nurb::type, UNLIKELY, CurveDrawData::vc, BezTriple::vec, BPoint::vec, and WM_event_add_notifier().
Referenced by curve_draw_invoke(), curve_draw_modal(), and CURVE_OT_draw().
|
static |
Initialize values before calling 'exec' (when running interactively).
Definition at line 631 of file editcurve_paint.c.
References BLI_mempool_iternew(), BLI_mempool_iterstep(), BLI_mempool_len(), CurvePaintSettings::corner_angle, CURVE_PAINT_FLAG_CORNERS_DETECT, ToolSettings::curve_paint_settings, wmOperator::customdata, CurvePaintSettings::error_threshold, CurvePaintSettings::fit_method, CurvePaintSettings::flag, len_squared_v2v2(), len_v2v2(), len_v3v3(), StrokeElem::location_local, M_PI, MEM_freeN, MEM_mallocN, StrokeElem::mval, StrokeElem::pressure, wmOperator::ptr, CurvePaintSettings::radius_taper_end, CurvePaintSettings::radius_taper_start, RNA_property_boolean_set(), RNA_property_enum_set(), RNA_property_float_set(), RNA_property_is_set(), RNA_struct_find_property(), ViewContext::scene, square_f(), STROKE_CYCLIC_DIST_PX, CurveDrawData::stroke_elem_pool, stroke_elem_pressure_set(), Scene::toolsettings, and CurveDrawData::vc.
Referenced by curve_draw_modal().
|
static |
Definition at line 607 of file editcurve_paint.c.
References BLI_mempool_destroy(), wmOperator::customdata, CurveDrawData::depths, CurveDrawData::draw_handle_view, ED_region_draw_cb_exit(), ED_view3d_depths_free(), MEM_freeN, NULL, ViewContext::region, CurveDrawData::stroke_elem_pool, ARegion::type, CurveDrawData::vc, ViewContext::win, and WM_cursor_modal_restore().
Referenced by curve_draw_cancel(), and curve_draw_exec().
|
static |
Definition at line 557 of file editcurve_paint.c.
References BKE_report(), BLI_assert, BLI_MEMPOOL_ALLOW_ITER, BLI_mempool_create(), ViewContext::bmain, C, CTX_data_edit_object(), CTX_data_ensure_evaluated_depsgraph(), CTX_data_main(), CTX_data_scene(), CTX_data_view_layer(), CURVE_PAINT_FLAG_DEPTH_STROKE_OFFSET_ABS, ToolSettings::curve_paint_settings, CurveDrawData::curve_type, CurvePaintSettings::curve_type, wmOperator::customdata, depsgraph, ViewContext::depsgraph, ED_view3d_viewcontext_init(), ELEM, CurvePaintSettings::flag, CurveDrawData::max, MEM_callocN, MEM_freeN, CurveDrawData::min, NULL, ViewContext::obedit, CurveDrawData::project, wmOperator::ptr, CurveDrawData::radius, CurvePaintSettings::radius_max, CurvePaintSettings::radius_min, CurveDrawData::range, ViewContext::region, wmOperator::reports, RNA_collection_is_empty(), RPT_ERROR, ViewContext::rv3d, ViewContext::scene, CurveDrawData::stroke_elem_pool, CurveDrawData::surface_offset, CurvePaintSettings::surface_offset, Scene::toolsettings, CurveDrawData::use_surface_offset_absolute, ViewContext::v3d, CurveDrawData::vc, ViewContext::view_layer, and ViewContext::win.
Referenced by curve_draw_exec(), and curve_draw_invoke().
|
static |
Definition at line 1036 of file editcurve_paint.c.
References BKE_report(), C, center, copy_v3_v3(), CU_IS_2D, CU_POLY, Scene::cursor, curve_draw_event_add_first(), curve_draw_exec(), curve_draw_init(), curve_draw_stroke_3d(), CURVE_PAINT_PROJECT_SURFACE, ToolSettings::curve_paint_settings, CurveDrawData::curve_type, wmOperator::customdata, Object::data, ViewContext::depsgraph, CurvePaintSettings::depth_mode, CurveDrawData::depths, dot_v3v3(), CurveDrawData::draw_handle_view, ED_region_draw_cb_activate(), ED_view3d_depth_override(), ED_view3d_win_to_3d(), View3DCursor::location, CurveDrawData::location_world, CurveDrawData::location_world_valid, wmEvent::mval, negate_v3_v3(), normalize_v3_v3(), NULL, OB_WIRE, ViewContext::obedit, Object::obmat, RegionView3D::ofs, OPERATOR_CANCELLED, OPERATOR_RUNNING_MODAL, CurveDrawData::plane, CurveDrawData::prev, CurveDrawData::project, wmOperator::ptr, ViewContext::region, REGION_DRAW_POST_VIEW, wmOperator::reports, RNA_boolean_get(), RNA_struct_property_is_set(), RPT_WARNING, ViewContext::rv3d, CurveDrawData::sample, ViewContext::scene, View3D::shading, Scene::toolsettings, ARegion::type, View3DShading::type, UNPACK2, CurveDrawData::use_depth, CurveDrawData::use_plane, CurveDrawData::use_substeps, ViewContext::v3d, V3D_DEPTH_NO_GPENCIL, CurveDrawData::vc, view3d_operator_needs_opengl(), RegionView3D::viewinv, ViewContext::win, WM_cursor_modal_set(), WM_CURSOR_PAINT_BRUSH, and WM_event_add_modal_handler().
Referenced by CURVE_OT_draw().
|
static |
Definition at line 1135 of file editcurve_paint.c.
References C, curve_draw_cancel(), curve_draw_event_add(), curve_draw_event_add_first(), curve_draw_exec(), curve_draw_exec_precalc(), CurveDrawData::CURVE_DRAW_PAINTING, curve_draw_stroke_to_operator(), wmOperator::customdata, ED_region_tag_redraw(), ELEM, EVT_ESCKEY, CurveDrawData::init_event_type, ISMOUSE_MOTION, KM_PRESS, KM_RELEASE, LEFTMOUSE, len_squared_v2v2(), CurveDrawData::mval, wmEvent::mval, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, CurveDrawData::prev, ViewContext::region, ret, RIGHTMOUSE, square_f(), CurveDrawData::state, STROKE_SAMPLE_DIST_MIN_PX, wmEvent::type, UNPACK2, UNUSED_VARS, wmEvent::val, and CurveDrawData::vc.
Referenced by CURVE_OT_draw().
|
static |
Definition at line 338 of file editcurve_paint.c.
References Curve::bevel_radius, BLI_mempool_iternew(), BLI_mempool_iterstep(), BLI_mempool_len(), color, copy_v3_v3(), wmOperator::customdata, Object::data, float(), GPU_batch_draw(), GPU_batch_preset_sphere(), GPU_batch_program_set_builtin(), GPU_batch_uniform_3fv, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_COMP_F32, GPU_DEPTH_LESS_EQUAL, GPU_DEPTH_NONE, GPU_depth_test(), GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_line_width(), GPU_matrix_mul, GPU_matrix_pop(), GPU_matrix_push(), GPU_matrix_scale_1f(), GPU_matrix_translate_3f(), GPU_PRIM_LINE_STRIP, GPU_SHADER_3D_UNIFORM_COLOR, GPU_vertformat_attr_add(), GPUBatch, imm_cpack(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immVertex3fv(), immVertexFormat(), StrokeElem::location_local, StrokeElem::location_world, MEM_freeN, MEM_mallocN, ViewContext::obedit, Object::obmat, pos, CurveDrawData::stroke_elem_pool, stroke_elem_radius(), TH_WIRE, UI_GetThemeColor3fv(), and CurveDrawData::vc.
Referenced by curve_draw_invoke().
|
static |
Definition at line 324 of file editcurve_paint.c.
References curve_draw_stroke_from_operator_elem(), wmOperator::ptr, RNA_BEGIN, and RNA_END.
Referenced by curve_draw_exec().
|
static |
Definition at line 299 of file editcurve_paint.c.
References BLI_mempool_calloc(), wmOperator::customdata, Object::imat, StrokeElem::location_local, StrokeElem::location_world, mul_v3_m4v3(), StrokeElem::mval, ViewContext::obedit, StrokeElem::pressure, RNA_float_get(), RNA_float_get_array(), CurveDrawData::stroke_elem_pool, and CurveDrawData::vc.
Referenced by curve_draw_stroke_from_operator().
|
static |
Definition at line 311 of file editcurve_paint.c.
References BLI_mempool_iternew(), BLI_mempool_iterstep(), curve_draw_stroke_to_operator_elem(), wmOperator::customdata, and CurveDrawData::stroke_elem_pool.
Referenced by curve_draw_modal().
|
static |
Definition at line 289 of file editcurve_paint.c.
References StrokeElem::location_world, StrokeElem::mval, StrokeElem::pressure, wmOperator::ptr, RNA_collection_add(), RNA_float_set(), and RNA_float_set_array().
Referenced by curve_draw_stroke_to_operator().
void CURVE_OT_draw | ( | wmOperatorType * | ot | ) |
Definition at line 1177 of file editcurve_paint.c.
References wmOperatorType::cancel, curve_draw_cancel(), curve_draw_exec(), curve_draw_invoke(), curve_draw_modal(), CURVE_PAINT_FIT_METHOD_REFIT, DEG2RADF, wmOperatorType::description, ED_operator_editcurve(), wmOperatorType::exec, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::invoke, M_PI, wmOperatorType::modal, wmOperatorType::name, OPTYPE_REGISTER, OPTYPE_UNDO, ot, wmOperatorType::poll, PROP_ANGLE, PROP_HIDDEN, PROP_SKIP_SAVE, RNA_def_boolean(), RNA_def_collection_runtime(), RNA_def_enum(), RNA_def_float_distance(), RNA_def_property_flag(), RNA_def_property_subtype(), RNA_def_property_ui_range(), rna_enum_curve_fit_method_items, and wmOperatorType::srna.
Referenced by ED_operatortypes_curve().
|
static |
Definition at line 156 of file editcurve_paint.c.
References interp_v2_v2v2(), interp_v3_v3v3(), interpf(), StrokeElem::location_local, StrokeElem::location_world, StrokeElem::mval, StrokeElem::pressure, and t.
Referenced by curve_draw_event_add().
|
static |
Definition at line 142 of file editcurve_paint.c.
References is_zero_v3(), StrokeElem::location_local, StrokeElem::location_world, madd_v3_v3fl(), mul_v3_m4v3(), StrokeElem::normal_local, ViewContext::obedit, Object::obmat, StrokeElem::pressure, CurveDrawData::project, stroke_elem_radius_from_pressure(), CurveDrawData::surface_offset, CurveDrawData::use_surface_offset_absolute, and CurveDrawData::vc.
Referenced by curve_draw_exec_precalc().
|
static |
Sets the depth from StrokeElem.mval
Definition at line 170 of file editcurve_paint.c.
References add_v3_v3(), copy_v3_v3(), ViewDepths::depth_range, CurveDrawData::depths, double(), ED_view3d_depth_read_cached(), ED_view3d_depth_read_cached_normal(), ED_view3d_depth_unproject_v3(), ED_view3d_win_to_3d_on_plane(), ViewDepths::h, madd_v3_v3fl(), normal, offset, CurveDrawData::offset, CurveDrawData::plane, CurveDrawData::project, ViewContext::region, CurveDrawData::use_offset, CurveDrawData::use_plane, CurveDrawData::use_surface_offset_absolute, CurveDrawData::vc, ViewDepths::w, and zero_v3().
Referenced by curve_draw_event_add_first(), and stroke_elem_project_fallback().
|
static |
Definition at line 230 of file editcurve_paint.c.
References copy_v3_v3(), ED_view3d_win_to_3d(), Object::imat, is_zero_v3(), mul_transposed_mat3_m4_v3(), mul_v3_m4v3(), normalize_v3(), ViewContext::obedit, Object::obmat, ViewContext::region, stroke_elem_project(), ViewContext::v3d, CurveDrawData::vc, and zero_v3().
Referenced by stroke_elem_project_fallback_elem().
|
static |
Definition at line 265 of file editcurve_paint.c.
References StrokeElem::location_local, StrokeElem::location_world, StrokeElem::mval, StrokeElem::normal_local, StrokeElem::normal_world, CurveDrawData::project, stroke_elem_project_fallback(), stroke_elem_radius(), CurveDrawData::surface_offset, and UNPACK2.
Referenced by curve_draw_event_add().
|
static |
Definition at line 137 of file editcurve_paint.c.
References StrokeElem::pressure, and stroke_elem_radius_from_pressure().
Referenced by curve_draw_stroke_3d(), and stroke_elem_project_fallback_elem().
|
static |
Definition at line 130 of file editcurve_paint.c.
References Curve::bevel_radius, Object::data, CurveDrawData::min, ViewContext::obedit, StrokeElem::pressure, CurveDrawData::radius, CurveDrawData::range, and CurveDrawData::vc.
Referenced by stroke_elem_pressure_set(), and stroke_elem_radius().