Blender
V3.3
|
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_array_utils.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_hash.h"
#include "BLI_heap.h"
#include "BLI_math_vec_types.hh"
#include "BLI_math_vector.h"
#include "BLI_polyfill_2d.h"
#include "BLI_span.hh"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "DEG_depsgraph_query.h"
Go to the source code of this file.
Classes | |
struct | GpEdge |
struct | tGPDeleteIsland |
struct | tSamplePoint |
struct | tSampleEdge |
struct | tPerimeterPoint |
Macros | |
#define | BOTH 0 |
#define | START 1 |
#define | END 2 |
#define | START 1 |
#define | END 2 |
Functions | |
Grease Pencil Object: Bound-box Support | |
bool | BKE_gpencil_stroke_minmax (const bGPDstroke *gps, const bool use_select, float r_min[3], float r_max[3]) |
bool | BKE_gpencil_data_minmax (const bGPdata *gpd, float r_min[3], float r_max[3]) |
void | BKE_gpencil_centroid_3d (bGPdata *gpd, float r_centroid[3]) |
void | BKE_gpencil_stroke_boundingbox_calc (bGPDstroke *gps) |
static void | boundbox_gpencil (Object *ob) |
BoundBox * | BKE_gpencil_boundbox_get (Object *ob) |
Stroke Sample | |
static int | stroke_march_next_point (const bGPDstroke *gps, const int index_next_pt, const float *current, const float dist, float *result, float *pressure, float *strength, float *vert_color, float *uv_fac, float *uv_fill, float *uv_rot, float *ratio_result, int *index_from, int *index_to) |
static int | stroke_march_next_point_no_interp (const bGPDstroke *gps, const int index_next_pt, const float *current, const float dist, const float sharp_threshold, float *result) |
static int | stroke_march_count (const bGPDstroke *gps, const float dist, const float sharp_threshold) |
static void | stroke_defvert_create_nr_list (MDeformVert *dv_list, int count, ListBase *result, int *totweight) |
static MDeformVert * | stroke_defvert_new_count (int count, int totweight, ListBase *def_nr_list) |
static void | stroke_interpolate_deform_weights (bGPDstroke *gps, int index_from, int index_to, float ratio, MDeformVert *vert) |
bool | BKE_gpencil_stroke_sample (bGPdata *gpd, bGPDstroke *gps, const float dist, const bool select, const float sharp_threshold) |
static bool | BKE_gpencil_stroke_extra_points (bGPDstroke *gps, const int count_before, const int count_after) |
bool | BKE_gpencil_stroke_stretch (bGPDstroke *gps, const float dist, const float overshoot_fac, const short mode, const bool follow_curvature, const int extra_point_count, const float segment_influence, const float max_angle, const bool invert_curvature) |
Stroke Trim | |
bool | BKE_gpencil_stroke_trim_points (bGPDstroke *gps, const int index_from, const int index_to) |
Stroke Split | |
bool | BKE_gpencil_stroke_split (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, const int before_index, bGPDstroke **remaining_gps) |
Stroke Shrink | |
bool | BKE_gpencil_stroke_shrink (bGPDstroke *gps, const float dist, const short mode) |
Stroke Smooth Positions | |
bool | BKE_gpencil_stroke_smooth_point (bGPDstroke *gps, int point_index, float influence, int iterations, const bool smooth_caps, const bool keep_shape, bGPDstroke *r_gps) |
Stroke Smooth Strength | |
bool | BKE_gpencil_stroke_smooth_strength (bGPDstroke *gps, int point_index, float influence, int iterations, bGPDstroke *r_gps) |
Stroke Smooth Thickness | |
bool | BKE_gpencil_stroke_smooth_thickness (bGPDstroke *gps, int point_index, float influence, int iterations, bGPDstroke *r_gps) |
Stroke Smooth UV | |
bool | BKE_gpencil_stroke_smooth_uv (struct bGPDstroke *gps, int point_index, float influence, int iterations, struct bGPDstroke *r_gps) |
void | BKE_gpencil_stroke_smooth (bGPDstroke *gps, const float influence, const int iterations, const bool smooth_position, const bool smooth_strength, const bool smooth_thickness, const bool smooth_uv, const bool keep_shape, const float *weights) |
void | BKE_gpencil_stroke_2d_flat (const bGPDspoint *points, int totpoints, float(*points2d)[2], int *r_direction) |
void | BKE_gpencil_stroke_2d_flat_ref (const bGPDspoint *ref_points, int ref_totpoints, const bGPDspoint *points, int totpoints, float(*points2d)[2], const float scale, int *r_direction) |
static void | gpencil_calc_stroke_fill_uv (const float(*points2d)[2], bGPDstroke *gps, const float minv[2], const float maxv[2], float(*r_uv)[2]) |
Stroke Fill Triangulate | |
void | BKE_gpencil_stroke_fill_triangulate (bGPDstroke *gps) |
void | BKE_gpencil_stroke_uv_update (bGPDstroke *gps) |
void | BKE_gpencil_stroke_geometry_update (bGPdata *gpd, bGPDstroke *gps) |
float | BKE_gpencil_stroke_length (const bGPDstroke *gps, bool use_3d) |
float | BKE_gpencil_stroke_segment_length (const struct bGPDstroke *gps, const int start_index, const int end_index, bool use_3d) |
bool | BKE_gpencil_stroke_trim (bGPdata *gpd, bGPDstroke *gps) |
bool | BKE_gpencil_stroke_close (bGPDstroke *gps) |
Dissolve Points | |
void | BKE_gpencil_dissolve_points (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, const short tag) |
Normal Calculation | |
void | BKE_gpencil_stroke_normal (const bGPDstroke *gps, float r_normal[3]) |
Stroke Simplify | |
void | BKE_gpencil_stroke_simplify_adaptive (bGPdata *gpd, bGPDstroke *gps, float epsilon) |
void | BKE_gpencil_stroke_simplify_fixed (bGPdata *gpd, bGPDstroke *gps) |
void | BKE_gpencil_stroke_subdivide (bGPdata *gpd, bGPDstroke *gps, int level, int type) |
Merge by Distance | |
void | BKE_gpencil_stroke_merge_distance (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, const float threshold, const bool use_unselected) |
static int | gpencil_next_edge (GpEdge *gp_edges, int totedges, GpEdge *gped_init, const float threshold, const bool reverse) |
static int | gpencil_walk_edge (GHash *v_table, GpEdge *gp_edges, int totedges, uint *stroke_array, int init_idx, const float angle, const bool reverse) |
static void | gpencil_generate_edgeloops (Object *ob, bGPdata *gpd, bGPDframe *gpf_stroke, int stroke_mat_index, const float angle, const int thickness, const float offset, const float matrix[4][4], const bool use_seams, const bool use_vgroups) |
static Material * | gpencil_add_material (Main *bmain, Object *ob_gp, const char *name, const float color[4], const bool use_stroke, const bool use_fill, int *r_idx) |
static int | gpencil_material_find_index_by_name (Object *ob, const char *name) |
static void | make_element_name (const char *obname, const char *name, const int maxlen, char *r_name) |
bool | BKE_gpencil_convert_mesh (Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob_gp, Object *ob_mesh, const float angle, const int thickness, const float offset, const float matrix[4][4], const int frame_offset, const bool use_seams, const bool use_faces, const bool use_vgroups) |
void | BKE_gpencil_transform (bGPdata *gpd, const float mat[4][4]) |
int | BKE_gpencil_stroke_point_count (const bGPdata *gpd) |
void | BKE_gpencil_point_coords_get (bGPdata *gpd, GPencilPointCoordinates *elem_data) |
void | BKE_gpencil_point_coords_apply (bGPdata *gpd, const GPencilPointCoordinates *elem_data) |
void | BKE_gpencil_point_coords_apply_with_mat4 (bGPdata *gpd, const GPencilPointCoordinates *elem_data, const float mat[4][4]) |
void | BKE_gpencil_stroke_set_random_color (bGPDstroke *gps) |
void | BKE_gpencil_stroke_flip (bGPDstroke *gps) |
static void | gpencil_stroke_join_islands (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps_first, bGPDstroke *gps_last) |
bGPDstroke * | BKE_gpencil_stroke_delete_tagged_points (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *next_stroke, int tag_flags, const bool select, const bool flat_cap, const int limit) |
void | BKE_gpencil_curve_delete_tagged_points (bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *next_stroke, bGPDcurve *gpc, int tag_flags) |
static void | gpencil_stroke_copy_point (bGPDstroke *gps, MDeformVert *dvert, bGPDspoint *point, const float delta[3], float pressure, float strength, float deltatime) |
void | BKE_gpencil_stroke_join (bGPDstroke *gps_a, bGPDstroke *gps_b, const bool leave_gaps, const bool fit_thickness, const bool smooth) |
void | BKE_gpencil_stroke_copy_to_keyframes (bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, const bool tail) |
Stroke Uniform Subdivide | |
static tSamplePoint * | new_sample_point_from_gp_point (const bGPDspoint *pt, const MDeformVert *dvert) |
static tSampleEdge * | new_sample_edge_from_sample_points (tSamplePoint *from, tSamplePoint *to) |
void | BKE_gpencil_stroke_uniform_subdivide (bGPdata *gpd, bGPDstroke *gps, const uint32_t target_number, const bool select) |
void | BKE_gpencil_stroke_to_view_space (RegionView3D *rv3d, bGPDstroke *gps, const float diff_mat[4][4]) |
void | BKE_gpencil_stroke_from_view_space (RegionView3D *rv3d, bGPDstroke *gps, const float diff_mat[4][4]) |
Stroke to Perimeter | |
static tPerimeterPoint * | new_perimeter_point (const float pt[3]) |
static int | generate_arc_from_point_to_point (ListBase *list, tPerimeterPoint *from, tPerimeterPoint *to, float center_pt[3], int subdivisions, bool clockwise) |
static int | generate_semi_circle_from_point_to_point (ListBase *list, tPerimeterPoint *from, tPerimeterPoint *to, int subdivisions) |
static int | generate_perimeter_cap (const float point[4], const float other_point[4], float radius, ListBase *list, int subdivisions, short cap_type) |
static ListBase * | gpencil_stroke_perimeter_ex (const bGPdata *gpd, const bGPDlayer *gpl, const bGPDstroke *gps, int subdivisions, int *r_num_perimeter_points) |
bGPDstroke * | BKE_gpencil_stroke_perimeter_from_view (struct RegionView3D *rv3d, bGPdata *gpd, const bGPDlayer *gpl, bGPDstroke *gps, const int subdivisions, const float diff_mat[4][4]) |
float | BKE_gpencil_stroke_average_pressure_get (bGPDstroke *gps) |
bool | BKE_gpencil_stroke_is_pressure_constant (bGPDstroke *gps) |
#define BOTH 0 |
#define END 2 |
#define END 2 |
#define START 1 |
#define START 1 |
Get grease pencil object bounding box.
ob | Grease pencil object |
Definition at line 149 of file gpencil_geom.cc.
References Object_Runtime::bb, boundbox_gpencil(), copy_v3_v3(), Object::data, DEG_get_original_id(), ELEM, bGPdata::flag, GP_DATA_CACHE_IS_DIRTY, Object::id, if(), Object::runtime, and BoundBox::vec.
Referenced by BKE_object_boundbox_get(), and BKE_object_minmax().
Compute center of bounding box.
gpd | Grease pencil data-block |
r_centroid | Location of the center |
Definition at line 108 of file gpencil_geom.cc.
References BKE_gpencil_data_minmax(), max, min, and mul_v3_v3fl().
Referenced by object_origin_set_exec(), and blender::io::gpencil::GpencilImporterSVG::read().
bool BKE_gpencil_convert_mesh | ( | struct Main * | bmain, |
struct Depsgraph * | depsgraph, | ||
struct Scene * | scene, | ||
struct Object * | ob_gp, | ||
struct Object * | ob_mesh, | ||
float | angle, | ||
int | thickness, | ||
float | offset, | ||
const float | matrix[4][4], | ||
int | frame_offset, | ||
bool | use_seams, | ||
bool | use_faces, | ||
bool | use_vgroups | ||
) |
Convert a mesh object to grease pencil stroke.
bmain | Main thread pointer. |
depsgraph | Original depsgraph. |
scene | Original scene. |
ob_gp | Grease pencil object to add strokes. |
ob_mesh | Mesh to convert. |
angle | Limit angle to consider a edge-loop ends. |
thickness | Thickness of the strokes. |
offset | Offset along the normals. |
matrix | Transformation matrix. |
frame_offset | Destination frame number offset. |
use_seams | Only export seam edges. |
use_faces | Export faces as filled strokes. |
Definition at line 2682 of file gpencil_geom.cc.
References angle(), BKE_defgroup_copy_list(), BKE_gpencil_layer_addnew(), BKE_gpencil_layer_frame_get(), BKE_gpencil_layer_named_get(), BKE_gpencil_material_find_index_by_name_prefix(), BKE_gpencil_stroke_add(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_subdivide(), BKE_object_get_evaluated_mesh(), BKE_object_material_get(), RenderData::cfra, color, copy_v3_v3(), copy_v4_v4(), Object::data, MDeformWeight::def_nr, DEG_get_evaluated_object(), DEG_id_tag_update(), depsgraph, bGPDstroke::dvert, Mesh::dvert, MDeformVert::dw, ELEM, bGPDstroke::flag, GP_GETFRAME_ADD_NEW, GP_STROKE_CYCLIC, GP_SUBDIV_SIMPLE, gpencil_add_material(), gpencil_generate_edgeloops(), gpencil_material_find_index_by_name(), bGPdata::id, Material::id, Object::id, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, MPoly::loopstart, make_element_name(), MPoly::mat_nr, MEM_callocN, Mesh::mloop, Mesh::mpoly, mul_m4_v3(), Mesh::mvert, ID::name, OB_GPENCIL, offset, bGPDstroke::points, bGPDspoint::pressure, Material::r, Scene::r, scene, bGPDspoint::strength, Mesh::totedge, MPoly::totloop, Mesh::totpoly, MDeformVert::totweight, Object::type, MLoop::v, bGPdata::vertex_group_active_index, Mesh::vertex_group_active_index, bGPdata::vertex_group_names, Mesh::vertex_group_names, MDeformWeight::weight, and bGPDspoint::x.
Referenced by object_convert_exec().
void BKE_gpencil_curve_delete_tagged_points | ( | bGPdata * | gpd, |
bGPDframe * | gpf, | ||
bGPDstroke * | gps, | ||
bGPDstroke * | next_stroke, | ||
bGPDcurve * | gpc, | ||
int | tag_flags | ||
) |
Definition at line 3283 of file gpencil_geom.cc.
References BKE_gpencil_editcurve_recalculate_handles(), BKE_gpencil_free_stroke(), BKE_gpencil_stroke_duplicate(), BKE_gpencil_stroke_editcurve_new(), BKE_gpencil_stroke_geometry_update(), BLI_addtail(), BLI_insertlinkbefore(), BLI_remlink(), bGPDcurve::curve_points, bGPDstroke::editcurve, bGPDcurve_point::flag, bGPDstroke::flag, GP_STROKE_CYCLIC, GP_STROKE_NEEDS_CURVE_UPDATE, is_cyclic(), MEM_recallocN, bGPDstroke::points, bGPDframe::strokes, and bGPDcurve::tot_curve_points.
Referenced by gpencil_delete_selected_points().
Definition at line 85 of file gpencil_geom.cc.
References BKE_gpencil_stroke_minmax(), INIT_MINMAX, bGPdata::layers, LISTBASE_FOREACH, and bGPDframe::strokes.
Referenced by BKE_gpencil_centroid_3d(), and boundbox_gpencil().
void BKE_gpencil_dissolve_points | ( | struct bGPdata * | gpd, |
struct bGPDframe * | gpf, | ||
struct bGPDstroke * | gps, | ||
short | tag | ||
) |
Dissolve points in stroke.
gpd | Grease pencil data-block |
gpf | Grease pencil frame |
gps | Grease pencil stroke |
tag | Type of tag for point |
Definition at line 1915 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke_weights(), BKE_gpencil_stroke_geometry_update(), BLI_freelinkN(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, MEM_callocN, MEM_dupallocN, MEM_freeN, bGPDstroke::points, bGPDframe::strokes, bGPDstroke::totpoints, and bGPDstroke::triangles.
Referenced by BKE_gpencil_stroke_merge_distance().
void BKE_gpencil_point_coords_apply | ( | struct bGPdata * | gpd, |
const GPencilPointCoordinates * | elem_data | ||
) |
Definition at line 2923 of file gpencil_geom.cc.
References BKE_gpencil_stroke_geometry_update(), GPencilPointCoordinates::co, copy_v3_v3(), bGPdata::layers, LISTBASE_FOREACH, bGPDstroke::points, GPencilPointCoordinates::pressure, bGPDspoint::pressure, and bGPDspoint::x.
Referenced by ED_object_data_xform_restore().
void BKE_gpencil_point_coords_apply_with_mat4 | ( | struct bGPdata * | gpd, |
const GPencilPointCoordinates * | elem_data, | ||
const float | mat[4][4] | ||
) |
Definition at line 2956 of file gpencil_geom.cc.
References BKE_gpencil_stroke_geometry_update(), GPencilPointCoordinates::co, bGPdata::layers, LISTBASE_FOREACH, mat4_to_scale(), mul_v3_m4v3(), bGPDstroke::points, GPencilPointCoordinates::pressure, bGPDspoint::pressure, and bGPDspoint::x.
Referenced by ED_object_data_xform_by_mat4().
void BKE_gpencil_point_coords_get | ( | struct bGPdata * | gpd, |
GPencilPointCoordinates * | elem_data | ||
) |
Definition at line 2893 of file gpencil_geom.cc.
References GPencilPointCoordinates::co, copy_v3_v3(), bGPdata::layers, LISTBASE_FOREACH, bGPDstroke::points, GPencilPointCoordinates::pressure, bGPDspoint::pressure, and bGPDspoint::x.
Referenced by ED_object_data_xform_create_ex().
void BKE_gpencil_stroke_2d_flat | ( | const bGPDspoint * | points, |
int | totpoints, | ||
float(*) | points2d[2], | ||
int * | r_direction | ||
) |
Definition at line 1367 of file gpencil_geom.cc.
References BLI_assert, copy_v3_v3(), blender::math::cross(), cross_v3_v3v3(), dot_v3v3(), mul_v3_v3fl(), normal, normalize_v3(), sub_v3_v3v3(), and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_fill_triangulate().
void BKE_gpencil_stroke_2d_flat_ref | ( | const bGPDspoint * | ref_points, |
int | ref_totpoints, | ||
const bGPDspoint * | points, | ||
int | totpoints, | ||
float(*) | points2d[2], | ||
const float | scale, | ||
int * | r_direction | ||
) |
Definition at line 1441 of file gpencil_geom.cc.
References add_v3_v3v3(), BLI_assert, copy_v3_v3(), cross_v3_v3v3(), dot_v3v3(), mul_v3_fl(), mul_v3_v3fl(), normal, normalize_v3(), sub_v3_v3v3(), v1, vn, and bGPDspoint::x.
float BKE_gpencil_stroke_average_pressure_get | ( | struct bGPDstroke * | gps | ) |
Get average pressure.
Definition at line 4304 of file gpencil_geom.cc.
References float(), bGPDstroke::points, bGPDspoint::pressure, and bGPDstroke::totpoints.
void BKE_gpencil_stroke_boundingbox_calc | ( | struct bGPDstroke * | gps | ) |
Compute stroke bounding box.
gps | Grease pencil Stroke |
Definition at line 118 of file gpencil_geom.cc.
References BKE_gpencil_stroke_minmax(), bGPDstroke::boundbox_max, bGPDstroke::boundbox_min, and INIT_MINMAX.
Referenced by BKE_gpencil_stroke_geometry_update(), ED_gpencil_stroke_check_collision(), gpencil_primitive_interaction_end(), gpencil_stroke_newfrombuffer(), and blender::io::gpencil::GpencilImporterSVG::read().
bool BKE_gpencil_stroke_close | ( | struct bGPDstroke * | gps | ) |
Close grease pencil stroke.
gps | Stroke to close |
Definition at line 1820 of file gpencil_geom.cc.
References BKE_defvert_ensure_index(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, bGPDstroke::flag, float(), GP_SPOINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_SELECT, interp_v3_v3v3(), interp_v4_v4v4(), interpf(), len_v3v3(), MAX2, MEM_recallocN, bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, bGPDstroke::totpoints, MDeformVert::totweight, bGPDspoint::vert_color, MDeformWeight::weight, and bGPDspoint::x.
Referenced by ED_gpencil_stroke_close_by_distance(), gpencil_convert_spline(), and gpencil_stroke_cyclical_set_exec().
void BKE_gpencil_stroke_copy_to_keyframes | ( | struct bGPdata * | gpd, |
struct bGPDlayer * | gpl, | ||
struct bGPDframe * | gpf, | ||
struct bGPDstroke * | gps, | ||
bool | tail | ||
) |
Copy the stroke of the frame to all frames selected (except current).
Definition at line 3568 of file gpencil_geom.cc.
References BKE_gpencil_frame_addnew(), BKE_gpencil_frame_selected_hash(), BKE_gpencil_layer_frame_find(), BKE_gpencil_stroke_duplicate(), BLI_addhead(), BLI_addtail(), BLI_ghash_free(), BLI_ghash_int_new_ex(), BLI_ghashIterator_getKey(), bGPDframe::framenum, GHASH_ITER, POINTER_AS_INT, and bGPDframe::strokes.
Referenced by gpencil_primitive_interaction_end(), and gpencil_stroke_newfrombuffer().
bGPDstroke* BKE_gpencil_stroke_delete_tagged_points | ( | struct bGPdata * | gpd, |
struct bGPDframe * | gpf, | ||
struct bGPDstroke * | gps, | ||
struct bGPDstroke * | next_stroke, | ||
int | tag_flags, | ||
bool | select, | ||
bool | flat_cap, | ||
int | limit | ||
) |
Split the given stroke into several new strokes, partitioning it based on whether the stroke points have a particular flag is set (e.g. GP_SPOINT_SELECT in most cases, but not always).
Definition at line 3116 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke(), BKE_gpencil_stroke_duplicate(), BKE_gpencil_stroke_geometry_update(), BLI_addtail(), BLI_insertlinkbefore(), BLI_remlink(), bool, bGPDstroke::caps, double(), bGPDstroke::dvert, MDeformVert::dw, e, tGPDeleteIsland::end_idx, bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_SELECT, GP_SPOINT_TAG, GP_STROKE_CAP_FLAT, GP_STROKE_CYCLIC, gpencil_stroke_join_islands(), bGPDstroke::inittime, is_cyclic(), MEM_callocN, MEM_dupallocN, MEM_freeN, bGPDstroke::points, select(), tGPDeleteIsland::start_idx, bGPDframe::strokes, bGPDspoint::time, and bGPDstroke::totpoints.
Referenced by annotation_stroke_eraser_dostroke(), ED_gpencil_stroke_join_and_trim(), gpencil_cutter_dissolve(), gpencil_delete_selected_points(), gpencil_dissolve_points(), gpencil_stroke_eraser_dostroke(), gpencil_stroke_separate_exec(), gpencil_stroke_split_exec(), and image_to_gpencil_exec().
|
static |
Give extra stroke points before and after the original tip points.
gps | Target stroke |
count_before | how many extra points to be added before a stroke |
count_after | how many extra points to be added after a stroke |
Definition at line 582 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke_weights(), BLI_assert, CLAMPIS, bGPDstroke::dvert, MDeformVert::dw, MDeformVert::flag, MEM_freeN, MEM_mallocN, bGPDstroke::points, bGPDstroke::totpoints, and MDeformVert::totweight.
Referenced by BKE_gpencil_stroke_stretch().
void BKE_gpencil_stroke_fill_triangulate | ( | struct bGPDstroke * | gps | ) |
Triangulate stroke to generate data for filling areas.
gps | Grease pencil stroke |
Definition at line 1570 of file gpencil_geom.cc.
References ARRAY_SET_ITEMS, BKE_gpencil_stroke_2d_flat(), BLI_assert, BLI_polyfill_calc(), copy_v2_v2(), float(), gpencil_calc_stroke_fill_uv(), MEM_callocN, MEM_freeN, MEM_mallocN, MEM_SAFE_FREE, bGPDstroke::points, bGPDstroke::tot_triangles, bGPDstroke::totpoints, bGPDstroke::triangles, bGPDspoint::uv_fill, and bGPDtriangle::verts.
Referenced by BKE_gpencil_stroke_geometry_update().
void BKE_gpencil_stroke_flip | ( | struct bGPDstroke * | gps | ) |
Flip stroke.
Definition at line 3007 of file gpencil_geom.cc.
References BLI_array_reverse, bGPDstroke::dvert, bGPDstroke::points, and bGPDstroke::totpoints.
Referenced by BKE_gpencil_stroke_join(), build_sequential(), gpencil_add_move_points(), gpencil_interpolate_seq_exec(), gpencil_interpolate_set_points(), and gpencil_stroke_flip_exec().
void BKE_gpencil_stroke_from_view_space | ( | struct RegionView3D * | rv3d, |
struct bGPDstroke * | gps, | ||
const float | diff_mat[4][4] | ||
) |
Stroke from view space Transforms a stroke from view space back to world space. Inverse of BKE_gpencil_stroke_to_view_space
Definition at line 3808 of file gpencil_geom.cc.
References invert_m4_m4(), mul_m4_v3(), mul_v3_m4v3(), bGPDstroke::points, bGPDstroke::totpoints, RegionView3D::viewinv, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_perimeter_from_view().
void BKE_gpencil_stroke_geometry_update | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps | ||
) |
Recalc all internal geometry data for the stroke
gpd | Grease pencil data-block |
gps | Grease pencil stroke |
Definition at line 1644 of file gpencil_geom.cc.
References BKE_gpencil_stroke_boundingbox_calc(), BKE_gpencil_stroke_fill_triangulate(), BKE_gpencil_stroke_update_geometry_from_editcurve(), BKE_gpencil_stroke_uv_update(), bGPdata::curve_edit_resolution, bGPDstroke::editcurve, bGPDcurve::flag, bGPDstroke::flag, bGPdata::flag, GP_CURVE_NEEDS_STROKE_UPDATE, GP_DATA_CURVE_ADAPTIVE_RESOLUTION, GP_STROKE_NEEDS_CURVE_UPDATE, GPENCIL_CURVE_EDIT_SESSIONS_ON, blender::opensubdiv::is_adaptive(), MEM_SAFE_FREE, bGPDstroke::tot_triangles, bGPDstroke::totpoints, and bGPDstroke::triangles.
Referenced by add_stroke(), add_stroke_cyclic(), add_stroke_simple(), apply_dash_for_frame(), applyLength(), BKE_gpencil_convert_mesh(), BKE_gpencil_curve_delete_tagged_points(), BKE_gpencil_dissolve_points(), BKE_gpencil_from_image(), BKE_gpencil_point_coords_apply(), BKE_gpencil_point_coords_apply_with_mat4(), BKE_gpencil_stroke_delete_tagged_points(), BKE_gpencil_stroke_merge_distance(), BKE_gpencil_stroke_perimeter_from_view(), BKE_gpencil_stroke_sample(), BKE_gpencil_stroke_simplify_adaptive(), BKE_gpencil_stroke_simplify_fixed(), BKE_gpencil_stroke_split(), BKE_gpencil_stroke_subdivide(), BKE_gpencil_stroke_trim(), BKE_gpencil_stroke_uniform_subdivide(), BKE_gpencil_strokes_selected_update_editcurve(), BKE_gpencil_transform(), blo_do_versions_280(), build_sequential(), deformStroke(), duplicateStroke(), ED_gpencil_create_monkey(), ED_gpencil_create_stroke(), ED_gpencil_select_curve_toggle_all(), ED_gpencil_trace_data_to_strokes(), generate_geometry(), gpencil_add_move_points(), gpencil_bake_grease_pencil_animation_exec(), gpencil_convert_spline(), gpencil_curve_extrude_points(), gpencil_dissolve_selected_curve_points(), gpencil_dissolve_selected_stroke_points(), gpencil_duplicate_exec(), gpencil_duplicate_points(), gpencil_editcurve_set_handle_type_exec(), gpencil_editmode_toggle_exec(), gpencil_generate_edgeloops(), gpencil_generic_stroke_select(), gpencil_insert_point(), gpencil_interpolate_modal(), gpencil_interpolate_seq_exec(), gpencil_interpolate_set_points(), gpencil_interpolate_update_strokes(), gpencil_primitive_interaction_end(), gpencil_primitive_update_strokes(), gpencil_recalc_geometry_exec(), gpencil_reset_transform_fill_exec(), gpencil_sculpt_brush_do_frame(), gpencil_select_exec(), gpencil_smooth_stroke(), gpencil_snap_to_grid(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_do_circle_sel(), gpencil_stroke_enter_editcurve_mode_exec(), gpencil_stroke_from_buffer(), gpencil_stroke_join_exec(), gpencil_stroke_join_islands(), gpencil_stroke_merge_exec(), gpencil_stroke_newfrombuffer(), gpencil_stroke_normalize_exec(), gpencil_stroke_subdivide_exec(), gpencil_strokes_copy_exec(), gpencil_strokes_paste_exec(), gpencil_strokes_reproject_exec(), gpencil_subdivide_stroke(), gpencil_update_geometry(), gpencil_uv_transform_calc(), lineart_gpencil_generate(), object_origin_set_exec(), recalcData_gpencil_strokes(), and reduce_stroke_points().
bool BKE_gpencil_stroke_is_pressure_constant | ( | struct bGPDstroke * | gps | ) |
Check if the thickness of the stroke is constant.
Definition at line 4320 of file gpencil_geom.cc.
References bGPDstroke::points, bGPDspoint::pressure, and bGPDstroke::totpoints.
void BKE_gpencil_stroke_join | ( | struct bGPDstroke * | gps_a, |
struct bGPDstroke * | gps_b, | ||
bool | leave_gaps, | ||
bool | fit_thickness, | ||
bool | smooth | ||
) |
Join two strokes using the shortest distance (reorder stroke if necessary).
Definition at line 3439 of file gpencil_geom.cc.
References BKE_gpencil_stroke_flip(), BKE_gpencil_stroke_smooth_point(), copy_v3_v3(), bGPDstroke::dvert, ELEM, float(), gpencil_stroke_copy_point(), len, len_squared_v3v3(), MAX2, MIN2, point, bGPDstroke::points, bGPDspoint::pressure, smooth(), bGPDspoint::strength, bGPDstroke::thickness, Particle::time, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by ED_gpencil_stroke_join_and_trim(), and gpencil_stroke_join_exec().
float BKE_gpencil_stroke_length | ( | const bGPDstroke * | gps, |
bool | use_3d | ||
) |
Definition at line 1681 of file gpencil_geom.cc.
References len_v2v2(), len_v3v3(), bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.
void BKE_gpencil_stroke_merge_distance | ( | struct bGPdata * | gpd, |
struct bGPDframe * | gpf, | ||
struct bGPDstroke * | gps, | ||
float | threshold, | ||
bool | use_unselected | ||
) |
Reduce a series of points when the distance is below a threshold. Special case for first and last points (both are kept) for other points, the merge point always is at first point.
gpd | Grease pencil data-block. |
gpf | Grease Pencil frame. |
gps | Grease Pencil stroke. |
threshold | Distance between points. |
use_unselected | Set to true to analyze all stroke and not only selected points. |
Definition at line 2324 of file gpencil_geom.cc.
References BKE_gpencil_dissolve_points(), BKE_gpencil_stroke_geometry_update(), bGPDspoint::flag, GP_SPOINT_SELECT, GP_SPOINT_TAG, len_squared_v3v3(), bGPDstroke::points, threshold, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by deformStroke(), ED_gpencil_stroke_join_and_trim(), and gpencil_merge_by_distance_exec().
bool BKE_gpencil_stroke_minmax | ( | const bGPDstroke * | gps, |
const bool | use_select, | ||
float | r_min[3], | ||
float | r_max[3] | ||
) |
Definition at line 57 of file gpencil_geom.cc.
References GP_SPOINT_SELECT, minmax_v3v3_v3(), bGPDstroke::points, and bGPDstroke::totpoints.
Referenced by BKE_gpencil_data_minmax(), and BKE_gpencil_stroke_boundingbox_calc().
void BKE_gpencil_stroke_normal | ( | const bGPDstroke * | gps, |
float | r_normal[3] | ||
) |
Definition at line 2003 of file gpencil_geom.cc.
References cross_v3_v3v3(), normalize_v3(), bGPDstroke::points, sub_v3_v3v3(), bGPDstroke::totpoints, bGPDspoint::x, and zero_v3().
bGPDstroke* BKE_gpencil_stroke_perimeter_from_view | ( | struct RegionView3D * | rv3d, |
bGPdata * | gpd, | ||
const bGPDlayer * | gpl, | ||
bGPDstroke * | gps, | ||
const int | subdivisions, | ||
const float | diff_mat[4][4] | ||
) |
Definition at line 4231 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke(), BKE_gpencil_stroke_from_view_space(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_new(), BKE_gpencil_stroke_to_view_space(), BLI_freelistN(), copy_v3_v3(), bGPDstroke::dvert, bGPDstroke::editcurve, bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_SELECT, gpencil_stroke_perimeter_ex(), LISTBASE_FOREACH_INDEX, bGPDstroke::mat_nr, MEM_dupallocN, MEM_freeN, MEM_recallocN, bGPDstroke::next, bGPDstroke::points, bGPDspoint::pressure, bGPDstroke::prev, bGPDspoint::strength, bGPDstroke::totpoints, bGPDstroke::triangles, bGPDspoint::uv_fac, bGPDspoint::uv_rot, and bGPDspoint::x.
int BKE_gpencil_stroke_point_count | ( | const bGPdata * | gpd | ) |
Definition at line 2867 of file gpencil_geom.cc.
References bGPdata::layers, LISTBASE_FOREACH, and bGPDstroke::totpoints.
bool BKE_gpencil_stroke_sample | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps, | ||
const float | dist, | ||
const bool | select, | ||
const float | sharp_threshold | ||
) |
Resample a stroke
gpd | Grease pencil data-block |
gps | Stroke to sample |
dist | Distance of one segment |
sharp_threshold | Threshold for preserving sharp corners |
Definition at line 447 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke_weights(), BKE_gpencil_stroke_geometry_update(), BLI_assert, BLI_pophead(), copy_v2_v2(), copy_v3_v3(), copy_v4_v4(), count, bGPDstroke::dvert, bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_SELECT, GP_STROKE_CYCLIC, is_cyclic(), MEM_callocN, MEM_freeN, bGPDstroke::points, bGPDspoint::pressure, select(), bGPDspoint::strength, stroke_defvert_create_nr_list(), stroke_defvert_new_count(), stroke_interpolate_deform_weights(), stroke_march_count(), stroke_march_next_point(), bGPDstroke::totpoints, bGPDspoint::uv_fac, bGPDspoint::uv_rot, and bGPDspoint::x.
Referenced by deformStroke(), ED_gpencil_trace_data_to_strokes(), gpencil_convert_spline(), and gpencil_stroke_sample_exec().
float BKE_gpencil_stroke_segment_length | ( | const struct bGPDstroke * | gps, |
int | start_index, | ||
int | end_index, | ||
bool | use_3d | ||
) |
Calculate grease pencil stroke length between points.
Definition at line 1701 of file gpencil_geom.cc.
References len_v2v2(), len_v3v3(), MAX2, MIN2, bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by ED_gpencil_stroke_join_and_trim().
void BKE_gpencil_stroke_set_random_color | ( | struct bGPDstroke * | gps | ) |
Set a random color to stroke using vertex color.
gps | Stroke |
Definition at line 2992 of file gpencil_geom.cc.
References BLI_assert, BLI_hash_int_01(), BLI_hash_int_2d(), color, copy_v4_v4(), bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::vert_color, bGPDspoint::x, bGPDspoint::y, and bGPDspoint::z.
Referenced by lineart_gpencil_generate().
bool BKE_gpencil_stroke_shrink | ( | struct bGPDstroke * | gps, |
float | dist, | ||
short | mode | ||
) |
Shrink the stroke by length.
gps | Stroke to shrink |
dist | delta length |
mode | 1->Start, 2->End |
Definition at line 928 of file gpencil_geom.cc.
References BKE_gpencil_stroke_trim_points(), END, interp_v3_v3v3(), len, len_v3v3(), bGPDstroke::points, START, bGPDstroke::totpoints, x, and bGPDspoint::x.
Referenced by gpencil_modify_stroke().
void BKE_gpencil_stroke_simplify_adaptive | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps, | ||
float | epsilon | ||
) |
Reduce a series of points to a simplified version, but maintains the general shape of the series.
Ramer - Douglas - Peucker algorithm by http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
gpd | Grease pencil data-block |
gps | Grease pencil stroke |
epsilon | Epsilon value to define precision of the algorithm |
Definition at line 2039 of file gpencil_geom.cc.
References BKE_gpencil_free_point_weights(), BKE_gpencil_stroke_geometry_update(), closest_to_line_segment_v3(), bGPDstroke::dvert, MDeformVert::dw, blender::robust_pred::epsilon, len_v3v3(), max_i(), MEM_callocN, MEM_dupallocN, MEM_SAFE_FREE, bGPDstroke::points, bGPDstroke::totpoints, and x.
Referenced by deformStroke(), gpencil_stroke_newfrombuffer(), and gpencil_stroke_simplify_exec().
void BKE_gpencil_stroke_simplify_fixed | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps | ||
) |
Simplify alternate vertex of stroke except extremes.
gpd | Grease pencil data-block |
gps | Grease pencil stroke |
Definition at line 2143 of file gpencil_geom.cc.
References BKE_gpencil_free_point_weights(), BKE_gpencil_stroke_geometry_update(), bGPDstroke::dvert, MDeformVert::dw, MEM_dupallocN, MEM_recallocN, MEM_SAFE_FREE, bGPDstroke::points, and bGPDstroke::totpoints.
Referenced by deformStroke(), gpencil_stroke_from_buffer(), and gpencil_stroke_simplify_fixed_exec().
void BKE_gpencil_stroke_smooth | ( | struct bGPDstroke * | gps, |
const float | influence, | ||
const int | iterations, | ||
const bool | smooth_position, | ||
const bool | smooth_strength, | ||
const bool | smooth_thickness, | ||
const bool | smooth_uv, | ||
const bool | keep_shape, | ||
const float * | weights | ||
) |
Apply smooth operation to the stroke.
gps | Stroke to smooth |
influence | The interpolation factor for the smooth and the original stroke |
iterations | Radius of points to consider, equivalent to iterations |
smooth_position | Smooth point locations |
smooth_strength | Smooth point strength |
smooth_thickness | Smooth point thickness |
smooth_uv | Smooth uv rotation/factor |
keep_shape | Use different distribution for smooth locations to keep the shape |
weights | per point weights to multiply influence with (optional, can be null) |
Definition at line 1317 of file gpencil_geom.cc.
References BKE_gpencil_stroke_smooth_point(), BKE_gpencil_stroke_smooth_strength(), BKE_gpencil_stroke_smooth_thickness(), BKE_gpencil_stroke_smooth_uv(), MEM_dupallocN, MEM_freeN, bGPDstroke::points, and bGPDstroke::totpoints.
Referenced by deformStroke(), gpencil_interpolate_seq_exec(), gpencil_interpolate_set_points(), and gpencil_stroke_newfrombuffer().
bool BKE_gpencil_stroke_smooth_point | ( | struct bGPDstroke * | gps, |
int | point_index, | ||
float | influence, | ||
int | iterations, | ||
bool | smooth_caps, | ||
bool | keep_shape, | ||
struct bGPDstroke * | r_gps | ||
) |
Apply smooth position to stroke point.
gps | Stroke to smooth |
i | Point index |
inf | Amount of smoothing to apply |
iterations | Radius of points to consider, equivalent to iterations |
smooth_caps | Apply smooth to stroke extremes |
keep_shape | Smooth out fine details first |
r_gps | Stroke to put the result into |
Definition at line 1007 of file gpencil_geom.cc.
References add_v3_v3(), copy_v3_v3(), double(), ELEM, exp(), bGPDstroke::flag, float(), GP_STROKE_CYCLIC, interp_v3_v3v3(), is_cyclic(), M_SQRT3, madd_v3_v3fl(), mul_v3_fl(), point_index, bGPDstroke::points, sub_v3_v3v3(), bGPDstroke::totpoints, w(), and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_join(), BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), gpencil_smooth_stroke(), gpencil_stroke_from_buffer(), and gpencil_stroke_newfrombuffer().
bool BKE_gpencil_stroke_smooth_strength | ( | struct bGPDstroke * | gps, |
int | point_index, | ||
float | influence, | ||
int | iterations, | ||
struct bGPDstroke * | r_gps | ||
) |
Apply smooth strength to stroke point.
gps | Stroke to smooth |
point_index | Point index |
influence | Amount of smoothing to apply |
iterations | Radius of points to consider, equivalent to iterations |
r_gps | Stroke to put the result into |
Definition at line 1127 of file gpencil_geom.cc.
References CLAMP_MAX, CLAMP_MIN, bGPDstroke::flag, float(), GP_STROKE_CYCLIC, is_cyclic(), point_index, bGPDstroke::points, bGPDspoint::strength, bGPDstroke::totpoints, and w().
Referenced by BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), gpencil_smooth_stroke(), and gpencil_stroke_newfrombuffer().
bool BKE_gpencil_stroke_smooth_thickness | ( | struct bGPDstroke * | gps, |
int | point_index, | ||
float | influence, | ||
int | iterations, | ||
struct bGPDstroke * | r_gps | ||
) |
Apply smooth for thickness to stroke point (use pressure).
gps | Stroke to smooth |
point_index | Point index |
influence | Amount of smoothing to apply |
iterations | Radius of points to consider, equivalent to iterations |
r_gps | Stroke to put the result into |
Definition at line 1185 of file gpencil_geom.cc.
References CLAMP_MAX, CLAMP_MIN, bGPDstroke::flag, float(), GP_STROKE_CYCLIC, is_cyclic(), point_index, bGPDstroke::points, bGPDspoint::pressure, bGPDstroke::totpoints, and w().
Referenced by BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), and gpencil_smooth_stroke().
bool BKE_gpencil_stroke_smooth_uv | ( | struct bGPDstroke * | gps, |
int | point_index, | ||
float | influence, | ||
int | iterations, | ||
struct bGPDstroke * | r_gps | ||
) |
Apply smooth for UV rotation/factor to stroke point.
gps | Stroke to smooth |
point_index | Point index |
influence | Amount of smoothing to apply |
iterations | Radius of points to consider, equivalent to iterations |
r_gps | Stroke to put the result into |
Definition at line 1243 of file gpencil_geom.cc.
References ELEM, bGPDstroke::flag, float(), GP_STROKE_CYCLIC, is_cyclic(), point_index, bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::uv_fac, bGPDspoint::uv_rot, and w().
Referenced by BKE_gpencil_stroke_smooth(), gpencil_brush_smooth_apply(), and gpencil_smooth_stroke().
bool BKE_gpencil_stroke_split | ( | struct bGPdata * | gpd, |
struct bGPDframe * | gpf, | ||
struct bGPDstroke * | gps, | ||
int | before_index, | ||
struct bGPDstroke ** | remaining_gps | ||
) |
Split stroke.
gpd | Grease pencil data-block. |
gpf | Grease pencil frame. |
gps | Grease pencil original stroke. |
before_index | Position of the point to split. |
remaining_gps | Secondary stroke after split. |
Definition at line 870 of file gpencil_geom.cc.
References BKE_gpencil_stroke_add_existing_style(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_trim_points(), MDeformWeight::def_nr, bGPDstroke::dvert, MDeformVert::dw, MDeformVert::flag, bGPDstroke::mat_nr, MEM_mallocN, bGPDstroke::points, bGPDstroke::thickness, bGPDstroke::totpoints, MDeformVert::totweight, and MDeformWeight::weight.
bool BKE_gpencil_stroke_stretch | ( | struct bGPDstroke * | gps, |
float | dist, | ||
float | overshoot_fac, | ||
short | mode, | ||
bool | follow_curvature, | ||
int | extra_point_count, | ||
float | segment_influence, | ||
float | max_angle, | ||
bool | invert_curvature | ||
) |
Backbone stretch similar to Freestyle.
gps | Stroke to sample. |
dist | Length of the added section. |
overshoot_fac | Relative length of the curve which is used to determine the extension. |
mode | Affect to Start, End or Both extremes (0->Both, 1->Start, 2->End). |
follow_curvature | True for approximating curvature of given overshoot. |
extra_point_count | When follow_curvature is true, use this amount of extra points. |
Definition at line 630 of file gpencil_geom.cc.
References add_v3_v3(), add_v3_v3v3(), angle(), angle_normalized_v3v3(), axis_angle_to_quat(), BKE_gpencil_stroke_extra_points(), BOTH, ceil(), CLAMP, copy_v3_v3(), cross_v3_v3v3(), ELEM, END, fabs(), fabsf, blender::math::floor(), fmaxf, fminf, fmodf, interp_v3_v3v3(), is_zero_v3(), CCL_NAMESPACE_BEGIN::isfinite(), len, len_v3(), M_PI, madd_v3_v3fl(), mul_qt_v3(), mul_v3_m3v3(), normalize_v3(), normalize_v3_length(), bGPDstroke::points, powf, quat_to_mat3(), result, rot, KDL::sin(), START, sub_v3_v3(), sub_v3_v3v3(), bGPDstroke::totpoints, UNLIKELY, bGPDspoint::x, and zero_v3().
Referenced by gpencil_modify_stroke().
void BKE_gpencil_stroke_subdivide | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps, | ||
int | level, | ||
int | type | ||
) |
Subdivide a stroke
gpd | Grease pencil data-block |
gps | Stroke |
level | Level of subdivision |
type | Type of subdivision |
Definition at line 2203 of file gpencil_geom.cc.
References BKE_gpencil_stroke_geometry_update(), CLAMP, copy_v3_v3(), copy_v4_v4(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, bGPDstroke::flag, GP_STROKE_CYCLIC, GP_SUBDIV_SIMPLE, GPENCIL_STRENGTH_MIN, bGPDspoint_Runtime::idx_orig, interp_v3_v3v3(), interp_v4_v4v4(), interpf(), MEM_dupallocN, MEM_malloc_arrayN, MEM_SAFE_FREE, next, bGPDstroke::points, bGPDspoint::pressure, blender::meshintersect::prev(), bGPDspoint_Runtime::pt_orig, bGPDspoint::runtime, bGPDspoint::strength, bGPDspoint::time, bGPDstroke::totpoints, MDeformVert::totweight, type, bGPDspoint::uv_fac, bGPDspoint::uv_fill, bGPDspoint::uv_rot, bGPDspoint::vert_color, MDeformWeight::weight, and bGPDspoint::x.
Referenced by BKE_gpencil_convert_mesh(), and deformStroke().
void BKE_gpencil_stroke_to_view_space | ( | struct RegionView3D * | rv3d, |
struct bGPDstroke * | gps, | ||
const float | diff_mat[4][4] | ||
) |
Stroke to view space Transforms a stroke to view space. This allows for manipulations in 2D but also easy conversion back to 3D.
Definition at line 3795 of file gpencil_geom.cc.
References mul_m4_v3(), mul_v3_m4v3(), bGPDstroke::points, bGPDstroke::totpoints, RegionView3D::viewmat, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_perimeter_from_view().
bool BKE_gpencil_stroke_trim | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps | ||
) |
Trim stroke to the first intersection or loop.
gps | Stroke data |
Definition at line 1728 of file gpencil_geom.cc.
References Freestyle::a, usdtokens::b(), BKE_gpencil_stroke_geometry_update(), Freestyle::c, closest(), closest_to_line_v3(), copy_v3_v3(), bGPDstroke::dvert, MDeformVert::dw, ELEM, intersect(), isect_line_line_v3(), len_v3(), MEM_dupallocN, MEM_recallocN, MEM_SAFE_FREE, point, bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by gpencil_stroke_newfrombuffer(), and gpencil_stroke_trim_exec().
bool BKE_gpencil_stroke_trim_points | ( | struct bGPDstroke * | gps, |
int | index_from, | ||
int | index_to | ||
) |
Trim stroke to needed segments.
gps | Target stroke. |
index_from | the index of the first point to be used in the trimmed result. |
index_to | the index of the last point to be used in the trimmed result. |
Definition at line 812 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke_weights(), MDeformWeight::def_nr, bGPDstroke::dvert, MDeformVert::dw, MDeformVert::flag, MEM_freeN, MEM_mallocN, bGPDstroke::points, bGPDstroke::totpoints, MDeformVert::totweight, and MDeformWeight::weight.
Referenced by BKE_gpencil_stroke_shrink(), and BKE_gpencil_stroke_split().
void BKE_gpencil_stroke_uniform_subdivide | ( | struct bGPdata * | gpd, |
struct bGPDstroke * | gps, | ||
uint32_t | target_number, | ||
bool | select | ||
) |
Subdivide the grease pencil stroke so the number of points is target_number. Does not change the shape of the stroke. The new points will be distributed as uniformly as possible by repeatedly subdividing the current longest edge.
gps | The stroke to be up-sampled. |
target_number | The number of points the up-sampled stroke should have. |
select | Select/Deselect the stroke. |
Definition at line 3660 of file gpencil_geom.cc.
References BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_select_index_set(), BLI_addtail(), BLI_assert, BLI_heap_free(), BLI_heap_insert(), BLI_heap_new(), BLI_heap_pop_min(), BLI_insertlinkafter(), copy_v3_v3(), copy_v4_v4(), MDeformWeight::def_nr, bGPDstroke::dvert, tSamplePoint::dw, MDeformVert::dw, ListBase::first, bGPDspoint::flag, bGPDstroke::flag, tSampleEdge::from, GP_SPOINT_SELECT, GP_STROKE_CYCLIC, GP_STROKE_SELECT, interp_v3_v3v3(), interp_v4_v4v4(), interpf(), is_cyclic(), ListBase::last, tSampleEdge::length_sq, LISTBASE_FOREACH_MUTABLE, MEM_callocN, MEM_freeN, MEM_recallocN, MEM_SAFE_FREE, MIN2, new_sample_edge_from_sample_points(), new_sample_point_from_gp_point(), tSamplePoint::next, bGPDstroke::points, tSamplePoint::pressure, bGPDspoint::pressure, select(), tSamplePoint::strength, bGPDspoint::strength, tSamplePoint::time, bGPDspoint::time, tSampleEdge::to, bGPDstroke::totpoints, tSamplePoint::totweight, MDeformVert::totweight, bGPDspoint::vert_color, tSamplePoint::vertex_color, MDeformWeight::weight, tSamplePoint::x, and bGPDspoint::x.
Referenced by gpencil_interpolate_seq_exec(), and gpencil_interpolate_set_points().
void BKE_gpencil_stroke_uv_update | ( | struct bGPDstroke * | gps | ) |
Update Stroke UV data.
gps | Grease pencil stroke |
Definition at line 1629 of file gpencil_geom.cc.
References len_v3v3(), bGPDstroke::points, bGPDstroke::totpoints, bGPDspoint::uv_fac, and x.
Referenced by BKE_gpencil_stroke_geometry_update(), ED_gpencil_update_color_uv(), and gpencil_sbuffer_stroke_ensure().
Apply grease pencil Transforms.
gpd | Grease pencil data-block |
mat | Transformation matrix |
Definition at line 2834 of file gpencil_geom.cc.
References BKE_gpencil_stroke_geometry_update(), bGPdata::layers, LISTBASE_FOREACH, mat4_to_scale(), mul_m4_v3(), bGPDstroke::points, bGPDspoint::pressure, and bGPDspoint::x.
Referenced by apply_objects_internal().
Create bounding box values.
ob | Grease pencil object |
Definition at line 128 of file gpencil_geom.cc.
References Object_Runtime::bb, BKE_boundbox_init_from_minmax(), BKE_gpencil_data_minmax(), BOUNDBOX_DIRTY, Object::data, BoundBox::flag, if(), max, min, and Object::runtime.
Referenced by BKE_gpencil_boundbox_get().
|
static |
Definition at line 3840 of file gpencil_geom.cc.
References add_v2_v2(), angle(), atan2f, BLI_insertlinkafter(), BLI_insertlinkbefore(), copy_v2_v2(), cross_v2v2(), dot_v2v2(), float(), from, is_zero_v2(), M_PI, new_perimeter_point(), rotate_v2_v2fl(), sub_v2_v2v2(), and tPerimeterPoint::x.
Referenced by gpencil_stroke_perimeter_ex().
|
static |
Definition at line 3939 of file gpencil_geom.cc.
References add_v2_v2(), BLI_addtail(), copy_v3_v3(), generate_semi_circle_from_point_to_point(), GP_STROKE_CAP_ROUND, is_zero_v2(), mul_v2_fl(), negate_v2_v2(), new_perimeter_point(), normalize_v2(), point, and sub_v2_v2v2().
Referenced by gpencil_stroke_perimeter_ex().
|
static |
Definition at line 3903 of file gpencil_geom.cc.
References add_v2_v2(), angle(), BLI_insertlinkafter(), float(), from, interp_v3_v3v3(), is_zero_v2(), M_PI, new_perimeter_point(), rotate_v2_v2fl(), sub_v2_v2v2(), and tPerimeterPoint::x.
Referenced by generate_perimeter_cap().
|
static |
Definition at line 2620 of file gpencil_geom.cc.
References ARRAY_SET_ITEMS, BKE_gpencil_object_material_new(), color, copy_v4_v4(), MaterialGPencilStyle::fill_rgba, MaterialGPencilStyle::flag, GP_MATERIAL_FILL_SHOW, GP_MATERIAL_STROKE_SHOW, Material::gp_style, and MaterialGPencilStyle::stroke_rgba.
Referenced by BKE_gpencil_convert_mesh().
|
static |
Definition at line 1526 of file gpencil_geom.cc.
References add_v2_v2(), Freestyle::c, center, KDL::cos(), mul_v2_fl(), KDL::sin(), bGPDstroke::totpoints, bGPDstroke::uv_rotation, bGPDstroke::uv_scale, bGPDstroke::uv_translation, x, and y.
Referenced by BKE_gpencil_stroke_fill_triangulate().
|
static |
Definition at line 2482 of file gpencil_geom.cc.
References add_v3_v3v3(), angle(), BKE_gpencil_stroke_add(), BKE_gpencil_stroke_geometry_update(), BKE_mesh_vertex_normals_ensure(), BLI_ghash_free(), BLI_ghash_int_new(), MVert::co, copy_v3_v3(), Object::data, MDeformWeight::def_nr, bGPDstroke::dvert, Mesh::dvert, MDeformVert::dw, e, GpEdge::flag, MEdge::flag, float(), gpencil_walk_edge(), if(), MAX2, ME_SEAM, Mesh::medge, MEM_callocN, MEM_mallocN, MEM_SAFE_FREE, mul_m4_v3(), mul_v3_v3fl(), Mesh::mvert, GpEdge::n1, GpEdge::n2, offset, bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, sub_v3_v3v3(), Mesh::totedge, MDeformVert::totweight, GpEdge::v1, MEdge::v1, GpEdge::v1_co, GpEdge::v2, MEdge::v2, GpEdge::v2_co, GpEdge::vec, MDeformWeight::weight, and bGPDspoint::x.
Referenced by BKE_gpencil_convert_mesh().
|
static |
Definition at line 2656 of file gpencil_geom.cc.
References BKE_object_material_get(), Material::gp_style, Material::id, ID::name, STREQ, and Object::totcol.
Referenced by BKE_gpencil_convert_mesh().
|
static |
Definition at line 2408 of file gpencil_geom.cc.
References angle(), angle_v3v3(), GpEdge::flag, threshold, GpEdge::v1, GpEdge::v2, and GpEdge::vec.
Referenced by gpencil_walk_edge().
|
static |
Definition at line 3390 of file gpencil_geom.cc.
References copy_v4_v4(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, MEM_callocN, MEM_dupallocN, MEM_reallocN, point, bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, Particle::time, bGPDspoint::time, bGPDstroke::totpoints, MDeformVert::totweight, bGPDspoint::vert_color, bGPDspoint::x, bGPDspoint::y, and bGPDspoint::z.
Referenced by BKE_gpencil_stroke_join().
|
static |
Definition at line 3027 of file gpencil_geom.cc.
References BKE_gpencil_free_stroke(), BKE_gpencil_stroke_duplicate(), BKE_gpencil_stroke_geometry_update(), BLI_addhead(), BLI_remlink(), copy_v3_v3(), copy_v4_v4(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, bGPDstroke::flag, GP_STROKE_CYCLIC, MEM_callocN, MEM_dupallocN, bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, bGPDframe::strokes, bGPDspoint::time, bGPDstroke::totpoints, bGPDspoint::vert_color, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_delete_tagged_points().
|
static |
Calculate the perimeter (outline) of a stroke as list of tPerimeterPoint.
subdivisions | Number of subdivisions for the start and end caps |
Definition at line 3990 of file gpencil_geom.cc.
References add_v2_v2(), add_v2_v2v2(), angle(), BLI_addtail(), BLI_freelistN(), BLI_listbase_reverse(), BLI_movelisttolist(), bGPDstroke::caps, compare_v3v3(), copy_v2_v2(), copy_v3_v3(), dot_v2v2(), fabsf, ListBase::first, generate_arc_from_point_to_point(), generate_perimeter_cap(), interp_v3_v3v3(), ListBase::last, len_v2(), bGPDlayer::line_change, MEM_freeN, negate_v2(), new_perimeter_point(), next, normalize_v2(), normalize_v2_length(), bGPdata::pixfactor, bGPDstroke::points, bGPDspoint::pressure, blender::meshintersect::prev(), sub_v2_v2v2(), bGPDstroke::thickness, bGPDstroke::totpoints, tPerimeterPoint::x, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_perimeter_from_view().
|
static |
Definition at line 2439 of file gpencil_geom.cc.
References angle(), BLI_ghash_haskey(), BLI_ghash_insert(), GpEdge::flag, gpencil_next_edge(), POINTER_FROM_INT, GpEdge::v1, and GpEdge::v2.
Referenced by gpencil_generate_edgeloops().
|
static |
Create the name with the object name and a suffix.
Definition at line 2671 of file gpencil_geom.cc.
References BLI_str_replace_char(), BLI_strncpy_utf8(), SNPRINTF, and str.
Referenced by BKE_gpencil_convert_mesh().
|
static |
Definition at line 3833 of file gpencil_geom.cc.
References copy_v3_v3(), and tPerimeterPoint::x.
Referenced by generate_arc_from_point_to_point(), generate_perimeter_cap(), generate_semi_circle_from_point_to_point(), and gpencil_stroke_perimeter_ex().
|
static |
Definition at line 3651 of file gpencil_geom.cc.
References from, len_squared_v3v3(), blender::nodes::node_geo_extrude_mesh_cc::new_edge(), and tSamplePoint::x.
Referenced by BKE_gpencil_stroke_uniform_subdivide().
|
static |
Definition at line 3628 of file gpencil_geom.cc.
References copy_v3_v3(), copy_v4_v4(), MDeformWeight::def_nr, tSamplePoint::dw, MDeformVert::dw, MEM_callocN, tSamplePoint::pressure, bGPDspoint::pressure, tSamplePoint::strength, bGPDspoint::strength, tSamplePoint::time, bGPDspoint::time, tSamplePoint::totweight, MDeformVert::totweight, bGPDspoint::vert_color, tSamplePoint::vertex_color, MDeformWeight::weight, tSamplePoint::x, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_uniform_subdivide().
|
static |
Definition at line 378 of file gpencil_geom.cc.
References BLI_addtail(), count, LinkData::data, MDeformWeight::def_nr, MDeformVert::dw, LinkData::next, POINTER_FROM_INT, result, and MDeformVert::totweight.
Referenced by BKE_gpencil_stroke_sample().
|
static |
Definition at line 413 of file gpencil_geom.cc.
References count, LinkData::data, MDeformWeight::def_nr, MDeformVert::dw, ListBase::first, MEM_mallocN, LinkData::next, POINTER_AS_INT, and MDeformVert::totweight.
Referenced by BKE_gpencil_stroke_sample().
|
static |
Definition at line 434 of file gpencil_geom.cc.
References BKE_defvert_find_weight(), MDeformWeight::def_nr, bGPDstroke::dvert, MDeformVert::dw, interpf(), MDeformVert::totweight, and MDeformWeight::weight.
Referenced by BKE_gpencil_stroke_sample().
|
static |
Definition at line 352 of file gpencil_geom.cc.
References copy_v3_v3(), bGPDspoint::flag, GP_SPOINT_TEMP_TAG, point, bGPDstroke::points, stroke_march_next_point_no_interp(), bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_sample().
|
static |
Definition at line 184 of file gpencil_geom.cc.
References copy_v3_v3(), bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_TEMP_TAG, GP_STROKE_CYCLIC, interp_v2_v2v2(), interp_v3_v3v3(), interp_v4_v4v4(), interpf(), len_v3v3(), point, bGPDstroke::points, bGPDspoint::pressure, result, bGPDspoint::strength, bGPDstroke::totpoints, bGPDspoint::uv_fac, bGPDspoint::uv_fill, bGPDspoint::uv_rot, bGPDspoint::vert_color, and bGPDspoint::x.
Referenced by BKE_gpencil_stroke_sample().
|
static |
Definition at line 288 of file gpencil_geom.cc.
References angle_v3v3v3(), copy_v3_v3(), bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_TEMP_TAG, GP_STROKE_CYCLIC, interp_v3_v3v3(), len_v3v3(), point, bGPDstroke::points, result, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by stroke_march_count().