Page MenuHome

WIP GPencil: Stroke to perimeter
Needs ReviewPublic

Authored by Falk David (filedescriptor) on Jan 20 2020, 5:13 PM.

Details

Summary

Description

This differential implements the function BKE_gpencil_stroke_perimeter_ex and an operator (GPENCIL_OT_stroke_to_perimeter) that uses it.
The BKE function returns a flat x, y, z float array representing the points on the perimeter of the stroke.

Demo

Here is a video, showing the operator in action:

Issues

  • The algorithm does not take the line_change stroke thickness adjustment in the layer settings into account.
  • Running the operator on multiple strokes at once freezes blender.
  • Code needs to be refactored to be rebased onto greasepencil-refactor
  • F6 menu does not pop up
  • End caps don't have the right thickness
  • Inner miter on corners does not take the thickness of points into account

Performance

These tests were done on a ThinkPad E580 running Ubuntu 18.04.3 LTS.


We can clearly see the O(n) runtime of the algorithm.

Diff Detail

Event Timeline

Falk David (filedescriptor) retitled this revision from GPencil: Add empty operator stroke_to_perimeter for testing to GPencil: Stroke to perimeter.Jan 20 2020, 5:16 PM
Falk David (filedescriptor) edited the summary of this revision. (Show Details)

Published a wrong diff

source/blender/editors/gpencil/gpencil_edit.c
4765

Maybe it would be easy to use if you pass rv3d only and get the matrixs from that inside the function.

Falk David (filedescriptor) added inline comments.
source/blender/editors/gpencil/gpencil_edit.c
4765

Yes, I had it like this before. My reasoning behind it was that if you want to project from a specific angle (e.g. onto x-y plane), you have that option. But if this is not needed, I can change it back

Falk David (filedescriptor) retitled this revision from GPencil: Stroke to perimeter to WIP GPencil: Stroke to perimeter.Jan 21 2020, 8:05 AM
Falk David (filedescriptor) edited the summary of this revision. (Show Details)

Make layer thickness adjustment affect stroke radius

Falk David (filedescriptor) edited the summary of this revision. (Show Details)
Falk David (filedescriptor) edited the summary of this revision. (Show Details)

Fixed a bug where blender would freeze due to an infinite loop in the operator.

Falk David (filedescriptor) edited the summary of this revision. (Show Details)
Falk David (filedescriptor) edited the summary of this revision. (Show Details)

Rebased branch onto greasepencil-refactor and implemented rounded corners

Fixed a merge issue, where a change did not propagate.

Falk David (filedescriptor) edited the summary of this revision. (Show Details)
  • Fixed a bug where at a 180 deg angle a loop would appear inside the perimeter
  • Fixed a bug in the poll function that would result in the operator menu not showing up
  • Fixed a couple of compiler-warnings

Added the function BKE_gpencil_perimeter_stroke_get that creates a stroke perimeter from any given stroke.