Blender  V2.93
BKE_gpencil_geom.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2008, Blender Foundation
17  * This is a new part of Blender
18  */
19 
20 #pragma once
21 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct Depsgraph;
31 struct Main;
32 struct Object;
33 struct RegionView3D;
34 struct Scene;
35 struct bGPDcurve;
36 struct bGPDframe;
37 struct bGPDspoint;
38 struct bGPDstroke;
39 struct bGPdata;
40 
41 /* Object boundbox. */
42 bool BKE_gpencil_data_minmax(const struct bGPdata *gpd, float r_min[3], float r_max[3]);
43 bool BKE_gpencil_stroke_minmax(const struct bGPDstroke *gps,
44  const bool use_select,
45  float r_min[3],
46  float r_max[3]);
47 
48 struct BoundBox *BKE_gpencil_boundbox_get(struct Object *ob);
49 void BKE_gpencil_centroid_3d(struct bGPdata *gpd, float r_centroid[3]);
51 
52 /* stroke geometry utilities */
53 void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]);
55  struct bGPDstroke *gps,
56  float epsilon);
57 void BKE_gpencil_stroke_simplify_fixed(struct bGPdata *gpd, struct bGPDstroke *gps);
58 void BKE_gpencil_stroke_subdivide(struct bGPdata *gpd,
59  struct bGPDstroke *gps,
60  int level,
61  int type);
62 bool BKE_gpencil_stroke_trim(struct bGPdata *gpd, struct bGPDstroke *gps);
64  struct bGPDframe *gpf,
65  struct bGPDstroke *gps,
66  const float threshold,
67  const bool use_unselected);
68 
69 void BKE_gpencil_stroke_2d_flat(const struct bGPDspoint *points,
70  int totpoints,
71  float (*points2d)[2],
72  int *r_direction);
73 void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points,
74  int ref_totpoints,
75  const struct bGPDspoint *points,
76  int totpoints,
77  float (*points2d)[2],
78  const float scale,
79  int *r_direction);
81 void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps);
83 
84 void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]);
85 
86 typedef struct GPencilPointCoordinates {
87  /* This is used when doing "move only origin" in object_data_transform.c.
88  * pressure is needs to be stored here as it is tied to object scale. */
89  float co[3];
90  float pressure;
92 
95 void BKE_gpencil_point_coords_apply(struct bGPdata *gpd, const GPencilPointCoordinates *elem_data);
97  const GPencilPointCoordinates *elem_data,
98  const float mat[4][4]);
99 
100 bool BKE_gpencil_stroke_sample(struct bGPdata *gpd,
101  struct bGPDstroke *gps,
102  const float dist,
103  const bool select);
104 bool BKE_gpencil_stroke_smooth(struct bGPDstroke *gps, int i, float inf);
105 bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps, int point_index, float influence);
106 bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps, int point_index, float influence);
107 bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, int point_index, float influence);
108 bool BKE_gpencil_stroke_close(struct bGPDstroke *gps);
109 void BKE_gpencil_dissolve_points(struct bGPdata *gpd,
110  struct bGPDframe *gpf,
111  struct bGPDstroke *gps,
112  const short tag);
113 
114 bool BKE_gpencil_stroke_stretch(struct bGPDstroke *gps, const float dist, const float tip_length);
116  const int index_from,
117  const int index_to);
119  struct bGPDframe *gpf,
120  struct bGPDstroke *gps,
121  struct bGPDstroke *next_stroke,
122  int tag_flags,
123  const bool select,
124  const bool flat_cap,
125  const int limit);
127  struct bGPDframe *gpf,
128  struct bGPDstroke *gps,
129  struct bGPDstroke *next_stroke,
130  struct bGPDcurve *gpc,
131  int tag_flags);
132 
133 void BKE_gpencil_stroke_flip(struct bGPDstroke *gps);
134 bool BKE_gpencil_stroke_split(struct bGPdata *gpd,
135  struct bGPDframe *gpf,
136  struct bGPDstroke *gps,
137  const int before_index,
138  struct bGPDstroke **remaining_gps);
139 bool BKE_gpencil_stroke_shrink(struct bGPDstroke *gps, const float dist);
140 
141 float BKE_gpencil_stroke_length(const struct bGPDstroke *gps, bool use_3d);
142 float BKE_gpencil_stroke_segment_length(const struct bGPDstroke *gps,
143  const int start_index,
144  const int end_index,
145  bool use_3d);
146 
148 
149 void BKE_gpencil_stroke_join(struct bGPDstroke *gps_a,
150  struct bGPDstroke *gps_b,
151  const bool leave_gaps,
152  const bool fit_thickness);
154  struct bGPDlayer *gpl,
155  struct bGPDframe *gpf,
156  struct bGPDstroke *gps,
157  const bool tail);
158 
159 bool BKE_gpencil_convert_mesh(struct Main *bmain,
160  struct Depsgraph *depsgraph,
161  struct Scene *scene,
162  struct Object *ob_gp,
163  struct Object *ob_mesh,
164  const float angle,
165  const int thickness,
166  const float offset,
167  const float matrix[4][4],
168  const int frame_offset,
169  const bool use_seams,
170  const bool use_faces);
171 
173  struct bGPDstroke *gps,
174  const uint32_t target_number,
175  const bool select);
176 
178  struct bGPDstroke *gps,
179  const float diff_mat[4][4]);
181  struct bGPDstroke *gps,
182  const float diff_mat[4][4]);
184  struct bGPdata *gpd,
185  const struct bGPDlayer *gpl,
186  struct bGPDstroke *gps,
187  const int subdivisions,
188  const float diff_mat[4][4]);
191 #ifdef __cplusplus
192 }
193 #endif
bool BKE_gpencil_stroke_minmax(const struct bGPDstroke *gps, const bool use_select, float r_min[3], float r_max[3])
void BKE_gpencil_stroke_flip(struct bGPDstroke *gps)
void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps)
float BKE_gpencil_stroke_average_pressure_get(struct bGPDstroke *gps)
bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps, int point_index, float influence)
Definition: gpencil_geom.c:841
void BKE_gpencil_stroke_2d_flat(const struct bGPDspoint *points, int totpoints, float(*points2d)[2], int *r_direction)
void BKE_gpencil_stroke_merge_distance(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, const float threshold, const bool use_unselected)
void BKE_gpencil_centroid_3d(struct bGPdata *gpd, float r_centroid[3])
Definition: gpencil_geom.c:130
void BKE_gpencil_point_coords_apply(struct bGPdata *gpd, const GPencilPointCoordinates *elem_data)
bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps, int point_index, float influence)
Definition: gpencil_geom.c:905
struct bGPDstroke * BKE_gpencil_stroke_delete_tagged_points(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, struct bGPDstroke *next_stroke, int tag_flags, const bool select, const bool flat_cap, const int limit)
void BKE_gpencil_stroke_from_view_space(struct RegionView3D *rv3d, struct bGPDstroke *gps, const float diff_mat[4][4])
void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3])
bool BKE_gpencil_convert_mesh(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_gp, struct 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)
bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, int point_index, float influence)
Definition: gpencil_geom.c:968
float BKE_gpencil_stroke_length(const struct bGPDstroke *gps, bool use_3d)
void BKE_gpencil_stroke_subdivide(struct bGPdata *gpd, struct bGPDstroke *gps, int level, int type)
void BKE_gpencil_stroke_simplify_adaptive(struct bGPdata *gpd, struct bGPDstroke *gps, float epsilon)
bool BKE_gpencil_stroke_stretch(struct bGPDstroke *gps, const float dist, const float tip_length)
Definition: gpencil_geom.c:537
void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps)
void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4])
bool BKE_gpencil_stroke_sample(struct bGPdata *gpd, struct bGPDstroke *gps, const float dist, const bool select)
Definition: gpencil_geom.c:429
void BKE_gpencil_stroke_to_view_space(struct RegionView3D *rv3d, struct bGPDstroke *gps, const float diff_mat[4][4])
bool BKE_gpencil_stroke_smooth(struct bGPDstroke *gps, int i, float inf)
Definition: gpencil_geom.c:778
void BKE_gpencil_stroke_uniform_subdivide(struct bGPdata *gpd, struct bGPDstroke *gps, const uint32_t target_number, const bool select)
void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points, int ref_totpoints, const struct bGPDspoint *points, int totpoints, float(*points2d)[2], const float scale, int *r_direction)
struct GPencilPointCoordinates GPencilPointCoordinates
void BKE_gpencil_stroke_simplify_fixed(struct bGPdata *gpd, struct bGPDstroke *gps)
void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps)
struct bGPDstroke * BKE_gpencil_stroke_perimeter_from_view(struct RegionView3D *rv3d, struct bGPdata *gpd, const struct bGPDlayer *gpl, struct bGPDstroke *gps, const int subdivisions, const float diff_mat[4][4])
bool BKE_gpencil_stroke_shrink(struct bGPDstroke *gps, const float dist)
Definition: gpencil_geom.c:706
bool BKE_gpencil_stroke_is_pressure_constant(struct bGPDstroke *gps)
void BKE_gpencil_stroke_boundingbox_calc(struct bGPDstroke *gps)
Definition: gpencil_geom.c:144
struct BoundBox * BKE_gpencil_boundbox_get(struct Object *ob)
Definition: gpencil_geom.c:182
void BKE_gpencil_point_coords_get(struct bGPdata *gpd, GPencilPointCoordinates *elem_data)
void BKE_gpencil_stroke_join(struct bGPDstroke *gps_a, struct bGPDstroke *gps_b, const bool leave_gaps, const bool fit_thickness)
void BKE_gpencil_stroke_set_random_color(struct bGPDstroke *gps)
void BKE_gpencil_curve_delete_tagged_points(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, struct bGPDstroke *next_stroke, struct bGPDcurve *gpc, int tag_flags)
bool BKE_gpencil_data_minmax(const struct bGPdata *gpd, float r_min[3], float r_max[3])
float BKE_gpencil_stroke_segment_length(const struct bGPDstroke *gps, const int start_index, const int end_index, bool use_3d)
void BKE_gpencil_stroke_copy_to_keyframes(struct bGPdata *gpd, struct bGPDlayer *gpl, struct bGPDframe *gpf, struct bGPDstroke *gps, const bool tail)
bool BKE_gpencil_stroke_split(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, const int before_index, struct bGPDstroke **remaining_gps)
Definition: gpencil_geom.c:646
bool BKE_gpencil_stroke_trim_points(struct bGPDstroke *gps, const int index_from, const int index_to)
Definition: gpencil_geom.c:587
int BKE_gpencil_stroke_point_count(struct bGPdata *gpd)
void BKE_gpencil_point_coords_apply_with_mat4(struct bGPdata *gpd, const GPencilPointCoordinates *elem_data, const float mat[4][4])
bool BKE_gpencil_stroke_close(struct bGPDstroke *gps)
void BKE_gpencil_dissolve_points(struct bGPdata *gpd, struct bGPDframe *gpf, struct bGPDstroke *gps, const short tag)
bool BKE_gpencil_stroke_trim(struct bGPdata *gpd, struct bGPDstroke *gps)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
Scene scene
const Depsgraph * depsgraph
static double epsilon
unsigned int uint32_t
Definition: stdint.h:83
Definition: BKE_main.h:116
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167