diff options
Diffstat (limited to 'source/blender/blenkernel/BKE_gpencil_geom.h')
-rw-r--r-- | source/blender/blenkernel/BKE_gpencil_geom.h | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h index c1ccae7a437..1e9c9d8ba01 100644 --- a/source/blender/blenkernel/BKE_gpencil_geom.h +++ b/source/blender/blenkernel/BKE_gpencil_geom.h @@ -38,6 +38,71 @@ struct bGPDspoint; struct bGPDstroke; struct bGPdata; +typedef enum eGPStrokeGeoUpdateFlag { + /* Default geometry update. Triangulate the stroke, update UVs and bounding box. If the stroke + type is bezier, regenerate the polyline first (GP_GEO_UPDATE_POLYLINE_REGENERATE_ALL). */ + GP_GEO_UPDATE_DEFAULT = 0, + + /* == Curve refitting flags == */ + /* On a stroke geometry update, if the stroke is of type bézier, there is the option to use the + points in the polyline to do a curve fitting. This is useful when an operation writes to the + polyline and the shape of the curve is out of sync and needs to be refitted. These flags + control what attributes the curve should be fitted to. */ + + /* Refit the curve point positions. */ + GP_GEO_UPDATE_CURVE_REFIT_POSITION = (1 << 1), + /* Refit the curve point pressures. */ + GP_GEO_UPDATE_CURVE_REFIT_PRESSURE = (1 << 2), + /* Refit the curve point strengths. */ + GP_GEO_UPDATE_CURVE_REFIT_STRENGTH = (1 << 3), + /* Refit the curve point vertex colors. */ + GP_GEO_UPDATE_CURVE_REFIT_COLOR = (1 << 4), + /* Refit the curve point weights. */ + GP_GEO_UPDATE_CURVE_REFIT_WEIGHT = (1 << 5), + /* Do a partial refit. Uses the `GP_SPOINT_TAG` point flag to determin what curve segments need + to be refitted. Only affected curve segments will be updated. */ + GP_GEO_UPDATE_CURVE_PARTIAL_REFIT = (1 << 6), + + /* == Polyline regeneration flags == */ + /* The polyline is regenerated when the curve geometry is updated. This is because the polyline + is used for rendering instead of the actual curve data. These flag control what attributes + should be regenerated when the curve was updated. */ + + /* Regenerate the polyline positions from the curve data. */ + GP_GEO_UPDATE_POLYLINE_POSITION = (1 << 7), + /* Regenerate the polyline point pressure from the curve data. */ + GP_GEO_UPDATE_POLYLINE_PRESSURE = (1 << 8), + /* Regenerate the polyline point strength from the curve data. */ + GP_GEO_UPDATE_POLYLINE_STRENGTH = (1 << 9), + /* Regenerate the polyline vertex colors from the curve data. */ + GP_GEO_UPDATE_POLYLINE_COLOR = (1 << 10), + /* Regenerate the polyline weights from the curve data. */ + GP_GEO_UPDATE_POLYLINE_WEIGHT = (1 << 11), + + /* Add additional flags here: (1 << 12), (2 << 12), ... */ + /* GP_GEO_UPDATE_XXX = (1 << 12), */ +} eGPStrokeGeoUpdateFlag; + +/* Refit all attributes. */ +#define GP_GEO_UPDATE_CURVE_REFIT_ALL \ + (GP_GEO_UPDATE_CURVE_REFIT_POSITION | GP_GEO_UPDATE_CURVE_REFIT_PRESSURE | \ + GP_GEO_UPDATE_CURVE_REFIT_STRENGTH | GP_GEO_UPDATE_CURVE_REFIT_COLOR | \ + GP_GEO_UPDATE_CURVE_REFIT_WEIGHT) + +/* Check if any curve refitting is done. */ +#define GP_GEO_UPDATE_CURVE_REFIT_ANY(flag) (flag & GP_GEO_UPDATE_CURVE_REFIT_ALL) + +/* Regenerate all attributes of the polyline from the curve data. */ +#define GP_GEO_UPDATE_POLYLINE_REGENERATE_ALL \ + (GP_GEO_UPDATE_POLYLINE_POSITION | GP_GEO_UPDATE_POLYLINE_PRESSURE | \ + GP_GEO_UPDATE_POLYLINE_STRENGTH | GP_GEO_UPDATE_POLYLINE_COLOR | \ + GP_GEO_UPDATE_POLYLINE_WEIGHT) + +/* Check if any atttributes of the polyline need to be regenerated. Note that we update all + * attributes by default (GP_GEO_UPDATE_DEFAULT). */ +#define GP_GEO_UPDATE_POLYLINE_REGENERATE_ANY(flag) \ + ((flag & GP_GEO_UPDATE_POLYLINE_REGENERATE_ALL) || flag == GP_GEO_UPDATE_DEFAULT) + /* Object boundbox. */ bool BKE_gpencil_data_minmax(const struct bGPdata *gpd, float r_min[3], float r_max[3]); bool BKE_gpencil_stroke_minmax(const struct bGPDstroke *gps, @@ -78,7 +143,10 @@ void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points, const float scale, int *r_direction); void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps); -void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, struct bGPDstroke *gps); + +void BKE_gpencil_stroke_geometry_update(struct bGPdata *gpd, + struct bGPDstroke *gps, + const eGPStrokeGeoUpdateFlag flag); void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps); void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]); |