Blender  V3.3
Macros
gpencil_curve.c File Reference
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math_vector.h"
#include "BLT_translation.h"
#include "DNA_collection_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_curve.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_object.h"
#include "curve_fit_nd.h"
#include "DEG_depsgraph_query.h"

Go to the source code of this file.

Macros

#define COORD_FITTING_INFLUENCE   20.0f
 
#define POINT_DIM   9
 

Functions

Convert to curve object
static int gpencil_check_same_material_color (Object *ob_gp, const float color_stroke[4], const float color_fill[4], const bool do_stroke, const bool do_fill, Material **r_mat)
 
static Materialgpencil_add_from_curve_material (Main *bmain, Object *ob_gp, const float stroke_color[4], const float fill_color[4], const bool stroke, const bool fill, int *r_idx)
 
static void gpencil_add_new_points (bGPDstroke *gps, const float *coord_array, const float pressure_start, const float pressure_end, const int init, const int totpoints, const float init_co[3], const bool last)
 
static Collectiongpencil_get_parent_collection (Scene *scene, Object *ob)
 
static int gpencil_get_stroke_material_fromcurve (Main *bmain, Object *ob_gp, Object *ob_cu, bool *do_stroke, bool *do_fill)
 
static void gpencil_convert_spline (Main *bmain, Object *ob_gp, Object *ob_cu, const float scale_thickness, const float sample, bGPDframe *gpf, Nurb *nu)
 
static void gpencil_editstroke_deselect_all (bGPDcurve *gpc)
 
void BKE_gpencil_convert_curve (Main *bmain, Scene *scene, Object *ob_gp, Object *ob_cu, const bool use_collections, const float scale_thickness, const float sample)
 
Edit-Curve Kernel Functions
static bGPDcurvegpencil_stroke_editcurve_generate_edgecases (bGPDstroke *gps, const float stroke_radius)
 
bGPDcurveBKE_gpencil_stroke_editcurve_generate (bGPDstroke *gps, const float error_threshold, const float corner_angle, const float stroke_radius)
 
void BKE_gpencil_stroke_editcurve_update (bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps)
 
void BKE_gpencil_editcurve_stroke_sync_selection (bGPdata *UNUSED(gpd), bGPDstroke *gps, bGPDcurve *gpc)
 
void BKE_gpencil_stroke_editcurve_sync_selection (bGPdata *gpd, bGPDstroke *gps, bGPDcurve *gpc)
 
static void gpencil_interpolate_fl_from_to (float from, float to, float *point_offset, int it, int stride)
 
static void gpencil_interpolate_v4_from_to (float from[4], float to[4], float *point_offset, int it, int stride)
 
static float gpencil_approximate_curve_segment_arclength (bGPDcurve_point *cpt_start, bGPDcurve_point *cpt_end)
 
static void gpencil_calculate_stroke_points_curve_segment (bGPDcurve_point *cpt, bGPDcurve_point *cpt_next, float *points_offset, int resolu, int stride)
 
static floatgpencil_stroke_points_from_editcurve_adaptive_resolu (bGPDcurve_point *curve_point_array, int curve_point_array_len, int resolution, bool is_cyclic, int *r_points_len)
 
static floatgpencil_stroke_points_from_editcurve_fixed_resolu (bGPDcurve_point *curve_point_array, int curve_point_array_len, int resolution, bool is_cyclic, int *r_points_len)
 
void BKE_gpencil_stroke_update_geometry_from_editcurve (bGPDstroke *gps, const uint resolution, const bool adaptive)
 
void BKE_gpencil_editcurve_recalculate_handles (bGPDstroke *gps)
 
static int gpencil_editcurve_subdivide_count (bGPDcurve *gpc, bool is_cyclic)
 
static void gpencil_editcurve_subdivide_curve_segment (bGPDcurve_point *cpt_start, bGPDcurve_point *cpt_end, bGPDcurve_point *cpt_new)
 
void BKE_gpencil_editcurve_subdivide (bGPDstroke *gps, const int cuts)
 
void BKE_gpencil_strokes_selected_update_editcurve (bGPdata *gpd)
 
void BKE_gpencil_strokes_selected_sync_selection_editcurve (bGPdata *gpd)
 

Macro Definition Documentation

◆ COORD_FITTING_INFLUENCE

#define COORD_FITTING_INFLUENCE   20.0f

Definition at line 43 of file gpencil_curve.c.

◆ POINT_DIM

#define POINT_DIM   9

Function Documentation

◆ BKE_gpencil_convert_curve()

void BKE_gpencil_convert_curve ( struct Main bmain,
struct Scene scene,
struct Object ob_gp,
struct Object ob_cu,
bool  use_collections,
float  scale_thickness,
float  sample 
)

Convert a curve object to grease pencil stroke.

Parameters
bmainMain thread pointer
sceneOriginal scene.
ob_gpGrease pencil object to add strokes.
ob_cuCurve to convert.
use_collectionsCreate layers using collection names.
scale_thicknessScale thickness factor.
sampleSample distance, zero to disable.

Definition at line 464 of file gpencil_curve.c.

References Object::actcol, BKE_gpencil_layer_active_get(), BKE_gpencil_layer_addnew(), BKE_gpencil_layer_frame_get(), BKE_gpencil_layer_named_get(), BKE_gpencil_merge_materials(), BKE_object_material_slot_remove(), BKE_object_material_slot_used(), RenderData::cfra, Object::data, DATA_, DEG_id_tag_update(), ELEM, ListBase::first, GP_GETFRAME_ADD_COPY, gpencil_convert_spline(), gpencil_get_parent_collection(), Collection::id, Object::id, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, LISTBASE_FOREACH, ID::name, NULL, Curve::nurb, OB_GPENCIL, Scene::r, sample, scene, Object::totcol, and Object::type.

Referenced by object_convert_exec().

◆ BKE_gpencil_editcurve_recalculate_handles()

void BKE_gpencil_editcurve_recalculate_handles ( struct bGPDstroke gps)

◆ BKE_gpencil_editcurve_stroke_sync_selection()

void BKE_gpencil_editcurve_stroke_sync_selection ( bGPdata UNUSEDgpd,
bGPDstroke gps,
bGPDcurve gpc 
)

◆ BKE_gpencil_editcurve_subdivide()

void BKE_gpencil_editcurve_subdivide ( bGPDstroke gps,
const int  cuts 
)

◆ BKE_gpencil_stroke_editcurve_generate()

bGPDcurve* BKE_gpencil_stroke_editcurve_generate ( struct bGPDstroke gps,
float  error_threshold,
float  corner_angle,
float  stroke_radius 
)

◆ BKE_gpencil_stroke_editcurve_sync_selection()

void BKE_gpencil_stroke_editcurve_sync_selection ( struct bGPdata gpd,
struct bGPDstroke gps,
struct bGPDcurve gpc 
)

◆ BKE_gpencil_stroke_editcurve_update()

void BKE_gpencil_stroke_editcurve_update ( struct bGPdata gpd,
struct bGPDlayer gpl,
struct bGPDstroke gps 
)

◆ BKE_gpencil_stroke_update_geometry_from_editcurve()

void BKE_gpencil_stroke_update_geometry_from_editcurve ( struct bGPDstroke gps,
uint  resolution,
bool  is_adaptive 
)

◆ BKE_gpencil_strokes_selected_sync_selection_editcurve()

void BKE_gpencil_strokes_selected_sync_selection_editcurve ( bGPdata gpd)

◆ BKE_gpencil_strokes_selected_update_editcurve()

void BKE_gpencil_strokes_selected_update_editcurve ( bGPdata gpd)

◆ gpencil_add_from_curve_material()

static Material* gpencil_add_from_curve_material ( Main bmain,
Object ob_gp,
const float  stroke_color[4],
const float  fill_color[4],
const bool  stroke,
const bool  fill,
int *  r_idx 
)
static

◆ gpencil_add_new_points()

static void gpencil_add_new_points ( bGPDstroke gps,
const float coord_array,
const float  pressure_start,
const float  pressure_end,
const int  init,
const int  totpoints,
const float  init_co[3],
const bool  last 
)
static

◆ gpencil_approximate_curve_segment_arclength()

static float gpencil_approximate_curve_segment_arclength ( bGPDcurve_point cpt_start,
bGPDcurve_point cpt_end 
)
static

◆ gpencil_calculate_stroke_points_curve_segment()

static void gpencil_calculate_stroke_points_curve_segment ( bGPDcurve_point cpt,
bGPDcurve_point cpt_next,
float points_offset,
int  resolu,
int  stride 
)
static

◆ gpencil_check_same_material_color()

static int gpencil_check_same_material_color ( Object ob_gp,
const float  color_stroke[4],
const float  color_fill[4],
const bool  do_stroke,
const bool  do_fill,
Material **  r_mat 
)
static

◆ gpencil_convert_spline()

static void gpencil_convert_spline ( Main bmain,
Object ob_gp,
Object ob_cu,
const float  scale_thickness,
const float  sample,
bGPDframe gpf,
Nurb nu 
)
static

◆ gpencil_editcurve_subdivide_count()

static int gpencil_editcurve_subdivide_count ( bGPDcurve gpc,
bool  is_cyclic 
)
static

◆ gpencil_editcurve_subdivide_curve_segment()

static void gpencil_editcurve_subdivide_curve_segment ( bGPDcurve_point cpt_start,
bGPDcurve_point cpt_end,
bGPDcurve_point cpt_new 
)
static

◆ gpencil_editstroke_deselect_all()

static void gpencil_editstroke_deselect_all ( bGPDcurve gpc)
static

◆ gpencil_get_parent_collection()

static Collection* gpencil_get_parent_collection ( Scene scene,
Object ob 
)
static

◆ gpencil_get_stroke_material_fromcurve()

static int gpencil_get_stroke_material_fromcurve ( Main bmain,
Object ob_gp,
Object ob_cu,
bool do_stroke,
bool do_fill 
)
static

Definition at line 216 of file gpencil_curve.c.

References Object::data, and NULL.

Referenced by gpencil_convert_spline().

◆ gpencil_interpolate_fl_from_to()

static void gpencil_interpolate_fl_from_to ( float  from,
float  to,
float point_offset,
int  it,
int  stride 
)
static

Definition at line 840 of file gpencil_curve.c.

References float(), from, interpf(), POINTER_OFFSET, r, and stride.

Referenced by gpencil_calculate_stroke_points_curve_segment().

◆ gpencil_interpolate_v4_from_to()

static void gpencil_interpolate_v4_from_to ( float  from[4],
float  to[4],
float point_offset,
int  it,
int  stride 
)
static

◆ gpencil_stroke_editcurve_generate_edgecases()

static bGPDcurve* gpencil_stroke_editcurve_generate_edgecases ( bGPDstroke gps,
const float  stroke_radius 
)
static

◆ gpencil_stroke_points_from_editcurve_adaptive_resolu()

static float* gpencil_stroke_points_from_editcurve_adaptive_resolu ( bGPDcurve_point curve_point_array,
int  curve_point_array_len,
int  resolution,
bool  is_cyclic,
int *  r_points_len 
)
static

◆ gpencil_stroke_points_from_editcurve_fixed_resolu()

static float* gpencil_stroke_points_from_editcurve_fixed_resolu ( bGPDcurve_point curve_point_array,
int  curve_point_array_len,
int  resolution,
bool  is_cyclic,
int *  r_points_len 
)
static