Page MenuHome

GPencil: Add uniform subdivide BKE to improve interpolation
ClosedPublic

Authored by Falk David (filedescriptor) on Dec 12 2020, 11:44 AM.

Details

Summary

This patch introduces a new BKE function that performs a uniform subdivide.

The goal of this function is to subdivide the stroke to reach a target number of points while maintaining its shape, color, and weights.
This is done by repeatedly subdividing the longest edge in the stroke. Every subdivision adds a new point at the exact middle point of an edge.

The function is intended to be used in the interpolation operators to give better results when interpolating between different sized strokes.

Diff Detail

Repository
rB Blender

Event Timeline

Falk David (filedescriptor) requested review of this revision.Dec 12 2020, 11:44 AM

This function is great, but this patch can be the Kernel function only or inlude the use in the interpolation opeator.

Maybe is better to use it in the interpolation in a separated patch.

source/blender/editors/gpencil/gpencil_intern.h
538 ↗(On Diff #31907)

Why an operator? Really we need this?

This function is great to be used in the interpolation, but what is the point to have an operator for this?

Unit test reminder.

source/blender/blenkernel/intern/gpencil_geom.c
3318

Arithmetic on int and uint types and further stored in uint
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Integer_Types

Use int64_t for integers that we know can be “big”.
Don’t use unsigned integers to indicate that a value is non-negative, use assertions instead.

source/blender/editors/gpencil/gpencil_edit.c
5215 ↗(On Diff #31907)

Comment style

@Ankit Meel (ankitm) I don't think we need 64, int32 is enough. If we have the number of points of a int64 the system would crash long time before in multiple places or it will be totally unusable.

  • GPencil: remove operator
  • GPemci: revert change to interpolation operator
  • GPencil: Change name to uniform_subdivide
  • Merge branch 'master' into gpencil-resample-amount

Not totally sure if need any style change, but the code is ok to move to master

If we find any issue, We can fix it when you use it in the interpolation opeators.

This revision is now accepted and ready to land.Dec 12 2020, 1:36 PM
Falk David (filedescriptor) retitled this revision from GPencil: New uniform subdivide operator to improve interpolation to GPencil: Add uniform subdivide BKE to improve interpolation.Dec 12 2020, 1:39 PM
Falk David (filedescriptor) edited the summary of this revision. (Show Details)
  • GPencil: Comments and integer types
  • GPencil: Fix memory leak
Falk David (filedescriptor) marked an inline comment as done.Dec 15 2020, 2:37 PM