GPv3: Updated Box and Circle, new Semicircle primitives #129068

Open
Charlie Jolly wants to merge 17 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 Module: 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
Charlie Jolly added 2 commits 2024-10-25 17:37:26 +02:00
Charlie Jolly added 1 commit 2024-10-25 18:29:22 +02:00
Charlie Jolly added 1 commit 2024-10-25 20:15:19 +02:00
Charlie Jolly changed title from WIP: GPv3: Add Constraints and Semicircle primitive to WIP: GPv3: Add Constraints, updated Box and Circle, and Semicircle primitive 2024-10-26 15:17:08 +02:00
Charlie Jolly changed title from WIP: GPv3: Add Constraints, updated Box and Circle, and Semicircle primitive to WIP: GPv3: Updated Box and Circle, new Semicircle primitives 2024-10-26 15:31:39 +02:00
Charlie Jolly changed title from WIP: GPv3: Updated Box and Circle, new Semicircle primitives to GPv3: Updated Box and Circle, new Semicircle primitives 2024-10-28 15:27:33 +01:00
Charlie Jolly added 2 commits 2024-11-01 18:18:58 +01:00
casey-bianco-davis requested changes 2024-11-03 19:54:52 +01:00
casey-bianco-davis left a comment
Member

Some small changes.

Some small changes.
@ -136,3 +171,4 @@
ViewOpsData *vod;
};
static float2 calc_circumcenter_2d(float2 a, float2 b, float2 c)

a, b and c should be const

a, b and c should be `const`
CharlieJolly marked this conversation as resolved
@ -143,0 +181,4 @@
const float bc1 = ba[1] * dca - ca[1] * dba;
const float bc2 = -ba[0] * dca + ca[0] * dba;
const float cba = ba[1] * ca[0] - ca[1] * ba[0];
const float2 center = float2(a[0] + 0.5f * bc1 / cba, a[1] + 0.5f * bc2 / cba);

I think they should combined.
const float2 center = a + 0.5f * float2(bc1, bc2) / cba;

I think they should combined. `const float2 center = a + 0.5f * float2(bc1, bc2) / cba;`
CharlieJolly marked this conversation as resolved
@ -387,0 +578,4 @@
const float t = i / float(new_points_num);
const float a = t * math::numbers::pi * 2.0f;
const float2 uv = float2(math::sin(a), math::cos(a)) * 0.5f + 0.5f;
float2 pos = corners[0] * (1 - uv[0]) * (1 - uv[1]);

Make sure to use 1.0f rather then 1 for floats.
i.e float2 pos = corners[0] * (1.0f - uv[0]) * (1.0f - uv[1]);

Make sure to use `1.0f` rather then 1 for floats. i.e `float2 pos = corners[0] * (1.0f - uv[0]) * (1.0f - uv[1]);`
CharlieJolly marked this conversation as resolved
@ -924,0 +1366,4 @@
if (ptd.type == PrimitiveType::Semicircle) {
const float2 start = point_2d_from_temp_index(ptd, ptd.active_control_point_index + 1);
const float2 end = point_2d_from_temp_index(ptd, ptd.active_control_point_index - 1);
float2 mp = math::midpoint(start, end);

Use const if possible.

Use `const` if possible.
CharlieJolly marked this conversation as resolved
Charlie Jolly added 1 commit 2024-11-04 11:57:25 +01:00
Charlie Jolly requested review from Falk David 2024-11-05 11:21:40 +01:00
This pull request has changes conflicting with the target branch.
  • source/blender/editors/grease_pencil/intern/grease_pencil_primitive.cc

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 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
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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 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.