WIP: GPv3: Add Constraints and Semicircle primitive #129068

Draft
Charlie Jolly wants to merge 10 commits from CharlieJolly/blender:gp-semicircle into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This PR exapnds GP primitives:

  • adds a new semicircle primitive which draws circular arcs.
  • adds constraints and snapping when moving primitive control points.
    Shift - constrains points to 8 way directions.
    Ctrl - snaps points to existing control points.
  • adds improved Box and Circle primitive.
  • helper line drawn when dragging, rotating or scaling primitives.
  • ability to extrude from start point

Notes:
For Semicircle:
M - flips direction of arc when extruding. It can also flip segments when cursor is near the control point.
Shift - constrains control points to [-1,1] range.

For Box/Circle:
This can now be rotated correctly.
B - changes mode to toggle quad mode. Corners can be dragged independently.
Shift - constrains control points.

Issues:

  • No icon
    * No end caps showing in panel

New box mode:
image

New circle mode:
image

Sinister image:
image

This PR exapnds GP primitives: * adds a new semicircle primitive which draws circular arcs. * adds constraints and snapping when moving primitive control points. Shift - constrains points to 8 way directions. Ctrl - snaps points to existing control points. * adds improved Box and Circle primitive. * helper line drawn when dragging, rotating or scaling primitives. * ability to extrude from start point Notes: For Semicircle: M - flips direction of arc when extruding. It can also flip segments when cursor is near the control point. Shift - constrains control points to [-1,1] range. For Box/Circle: This can now be rotated correctly. B - changes mode to toggle quad mode. Corners can be dragged independently. Shift - constrains control points. Issues: * No icon ~~* No end caps showing in panel~~ New box mode: <img width="248" alt="image" src="attachments/c3027ec8-a1bc-4bc4-b7d3-d06dcfcf1a1e"> New circle mode: <img width="334" alt="image" src="attachments/89d8353f-1310-4ecb-919a-0cebb61acf8e"> Sinister image: <img width="994" alt="image" src="attachments/422d0e60-03f0-48ac-882e-d527760e1aaa">
Charlie Jolly added 1 commit 2024-10-15 18:05:30 +02:00
This PR adds a semicircle primitive.

This draws circular arcs.

The control point position allows the user to change segment into
a line or flipped arc.
Charlie Jolly added this to the Grease Pencil project 2024-10-15 18:05:58 +02:00
Charlie Jolly added 2 commits 2024-10-23 12:35:01 +02:00
Add snap to ctrl points
Shift for constraining points
Ctrl for snapping points
Drag line
Charlie Jolly added 1 commit 2024-10-23 12:44:14 +02:00
Charlie Jolly changed title from WIP: GPv3: Add Semicircle primitive to WIP: GPv3: Add Constraints and Semicircle primitive 2024-10-23 13:08:56 +02:00
Charlie Jolly added 1 commit 2024-10-23 13:28:18 +02:00
casey-bianco-davis requested changes 2024-10-23 21:52:36 +02:00
casey-bianco-davis left a comment
Member

Overall I like the tool, I do think that the Filp/F keybind should also work after your done extruding, and be flip the currently hovered over point.

Overall I like the tool, I do think that the `Filp`/`F` keybind should also work after your done extruding, and be flip the currently hovered over point.
@ -1635,6 +1636,7 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
"builtin.box",
"builtin.circle",
"builtin.polyline",
"builtin.semicircle",

Make sure to also add "builtin.semicircle" to brush_basic_grease_pencil_paint_settings in properties_paint_common.py

Make sure to also add `"builtin.semicircle"` to `brush_basic_grease_pencil_paint_settings` in `properties_paint_common.py`
CharlieJolly marked this conversation as resolved
@ -135,1 +138,4 @@
float2 start_drag_position_2d;
float2 end_drag_position_2d;
bool reverse;

Probably should add a comment explaining that this is for extruding.

Probably should add a comment explaining that this is for extruding.
Author
Member

Renamed reverse_extrude

Renamed `reverse_extrude`
CharlieJolly marked this conversation as resolved
@ -136,0 +139,4 @@
float2 start_drag_position_2d;
float2 end_drag_position_2d;
bool reverse;
bool flip;

Maybe rename flip to flipped? same for reverse

Maybe rename `flip` to `flipped`? same for `reverse`
CharlieJolly marked this conversation as resolved
@ -137,2 +145,4 @@
};
/* Copied directly from v3 private function in mesh_fair.cc but using float 2 parameters. */
static float2 calc_circumcenter_2d(const float2 v1, const float2 v2, const float2 v3)

This whole function need to be rewritten to use only float2 work only in 2 dimensions.

This whole function need to be rewritten to use only float2 work only in 2 dimensions.
CharlieJolly marked this conversation as resolved
@ -308,0 +439,4 @@
}
else {
const float2 center_pos = calc_circumcenter_2d(A, B, CP);
float2 CEN = float2(center_pos.x, center_pos.y);

Why does this exists?
And if it should then it should be const

Why does this exists? And if it should then it should be `const`
CharlieJolly marked this conversation as resolved
@ -308,0 +446,4 @@
float flip = angle_cp >= 0.0f ? 1.0f : -1.0f;
const float dist_cp_mp = math::distance(CP, MP);
const float dist_a_mp = math::distance(A, MP);
flip *= dist_a_mp > dist_cp_mp ? -1.0f : 1.0f;

I think flip should be a boolean and const on one line.

e.i. something like
const bool flip = (angle_cp >= 0.0f) ^ (dist_a_mp > dist_cp_mp);

I think `flip` should be a boolean and `const` on one line. e.i. something like `const bool flip = (angle_cp >= 0.0f) ^ (dist_a_mp > dist_cp_mp);`
CharlieJolly marked this conversation as resolved
@ -308,0 +458,4 @@
for (const int i : IndexRange(subdivision + 1)) {
const float t = theta_step * i + angle_offset;
const float x = radius * cos(t);
const float y = radius * sin(t);

Should calulcate both in one line some like

const float xy = radius * float2(cos(t), sin(t));

Should calulcate both in one line some like `const float xy = radius * float2(cos(t), sin(t));`
CharlieJolly marked this conversation as resolved
@ -1070,0 +1402,4 @@
std::reverse(ptd.control_points.begin(), ptd.control_points.end());
std::reverse(ptd.temp_control_points.begin(), ptd.temp_control_points.end());
ptd.reverse = false;
ptd.flip = ptd.flip ? false : true;

ptd.flip = !ptd.flip;

ptd.flip = !ptd.flip;
CharlieJolly marked this conversation as resolved
Charlie Jolly added 1 commit 2024-10-24 16:22:31 +02:00
Add replacement box primitive with better controls
Charlie Jolly added 1 commit 2024-10-25 11:52:33 +02:00
Charlie Jolly added 1 commit 2024-10-25 12:01:19 +02:00
Charlie Jolly added 1 commit 2024-10-25 12:43:02 +02:00
Charlie Jolly added 1 commit 2024-10-25 15:02:00 +02:00
This pull request is marked as a work in progress.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u gp-semicircle:CharlieJolly-gp-semicircle
git checkout CharlieJolly-gp-semicircle
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#129068
No description provided.