Page MenuHome

WIP GPencil: Stroke to perimeter
AbandonedPublic

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

Details

Summary

Description

This differential implements the function BKE_gpencil_stroke_perimeter_from_view and an operator (GPENCIL_OT_stroke_to_perimeter) that uses it.
The BKE function returns a bGPDstroke representing the points on the perimeter of the given stroke.

Demo

Here is an example of what the operator does:


This function does not handle clipping.

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
  • Parent-relation transformations are not handled correctly
  • End caps don't have the right thickness when manually scaled
  • Inner miter on corners does not take the thickness of the previous and next 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

Repository
rB Blender
Branch
gpencil_stroke_to_perimeter
Build Status
Buildable 6334
Build 6334: arc lint + arc unit

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.

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

Moved main BKE to gpencil_geom.c and fixed the parent transform issue by introducing a new function: BKE_gpencil_stroke_to_view_space. This function handles the transformation to parent as well as view space. A lot of the code has also been simplified and cleaned up.

Fixed an issue where the number of perimeter points was not counted correctly. Fixed an issue where the order of points on rounded corners was incorrect.

This patch will be part of the SVG export.