GPv3: Drawing Placement #115602

Merged
Falk David merged 9 commits from filedescriptor/blender:gpv3-drawing-placements into main 2023-12-05 11:01:56 +01:00
Member

This PR adds the drawing placement modes from GPv2.

The drawing placement defines the depth (origin, view, surface, etc.) and a plane (view, cursor, xz, etc.).

This introduces a new helper class DrawingPlacement that does all of the internals to find the correct projection and just exposes a simple function to project from screen space to the drawing plane/surface.

Note: Drawing on other strokes currently doesn't work, because GPv3 can't be rendered to image yet. We use the depth buffer of the grease pencil render result to find the right depth.

image
image

This PR adds the drawing placement modes from GPv2. The drawing placement defines the depth (origin, view, surface, etc.) and a plane (view, cursor, xz, etc.). This introduces a new helper class `DrawingPlacement` that does all of the internals to find the correct projection and just exposes a simple function to project from screen space to the drawing plane/surface. Note: Drawing on other strokes currently doesn't work, because GPv3 can't be rendered to image yet. We use the depth buffer of the grease pencil render result to find the right depth. ![image](/attachments/20965794-6e81-4d93-9746-07d56cc35fa5) ![image](/attachments/bba959af-1814-43da-9596-d63c765b2857)
Falk David added 4 commits 2023-11-30 11:49:27 +01:00
Falk David added 1 commit 2023-11-30 11:57:30 +01:00
Falk David requested review from Hans Goudey 2023-11-30 11:57:40 +01:00
Falk David requested review from Antonio Vazquez 2023-11-30 11:57:45 +01:00
Falk David changed title from WIP: GPv3: Drawing Placement to GPv3: Drawing Placement 2023-11-30 11:58:12 +01:00
Falk David added this to the Grease Pencil project 2023-11-30 12:01:13 +01:00
Author
Member

Changes to be documented once this is merged:

Replaced the gpd.zdepth_offset property with a toolsetting: gpencil_surface_offset.

Changes to be documented once this is merged: Replaced the `gpd.zdepth_offset` property with a toolsetting: `gpencil_surface_offset`.
Hans Goudey reviewed 2023-12-01 21:49:45 +01:00
Hans Goudey left a comment
Member

I didn't get the change to test this yet, but I guess there are others doing that anyway. My only point is about structuring this in a more data-oriented way then-- currently storing all the necessary data in a class and processing one point at a time doesn't seem to scale well. It's hard to judge whether the redundancy/complexity of storing the inputs in a class is worth it, but at least the API should still allow doing more work at a time.

I didn't get the change to test this yet, but I guess there are others doing that anyway. My only point is about structuring this in a more data-oriented way then-- currently storing all the necessary data in a class and processing one point at a time doesn't seem to scale well. It's hard to judge whether the redundancy/complexity of storing the inputs in a class is worth it, but at least the API should still allow doing more work at a time.
@ -30,0 +116,4 @@
ED_view3d_depth_override(depsgraph, region, view3d, nullptr, mode, &this->depth_cache_);
}
void DrawingPlacement::set_origin_to_nearest_stroke(const float2 co)
Member

I'd structuring the API to process more than one element at a time. That's a principle of data oriented design-- there's rarely ever only one of something, and when there is, it's fast anyway because there's only one value. This would help to eliminate branching and decrease the overhead of "constant" operations per position.

Though we probably can't benefit from it much yet, since all the functions this uses process a single element at a time too.

I'd structuring the API to process more than one element at a time. That's a principle of data oriented design-- there's rarely ever only one of something, and when there is, it's fast anyway because there's only one value. This would help to eliminate branching and decrease the overhead of "constant" operations per position. Though we probably can't benefit from it much yet, since all the functions this uses process a single element at a time too.
Author
Member

In the case of set_origin_to_nearest_stroke we're just changing the origin of the drawing plane. So this is a one-time operation.
For project I could add an API that would project multiple coordinates at a time.

In the case of `set_origin_to_nearest_stroke` we're just changing the `origin` of the drawing plane. So this is a one-time operation. For `project` I could add an API that would project multiple coordinates at a time.
filedescriptor marked this conversation as resolved
Falk David added 2 commits 2023-12-04 15:04:43 +01:00
Hans Goudey reviewed 2023-12-04 15:12:09 +01:00
Hans Goudey left a comment
Member

I'd probably just remove the 1 point at a time from the API to make it annoying to call, but this is fine too

I'd probably just remove the 1 point at a time from the API to make it annoying to call, but this is fine too
@ -28,2 +31,4 @@
namespace blender::ed::greasepencil {
DrawingPlacement::DrawingPlacement(const Scene &scene,
const ARegion *region,
Member

Looks like these aren't meant to be null ever, might as well make them references, even if you just store them as pointers again

Looks like these aren't meant to be null ever, might as well make them references, even if you just store them as pointers again
filedescriptor marked this conversation as resolved
@ -54,0 +59,4 @@
enum class DrawingPlacementPlane { View, Front, Side, Top, Cursor };
class DrawingPlacement {
private:
Member

private is redundant for classes

`private` is redundant for classes
filedescriptor marked this conversation as resolved
@ -54,0 +92,4 @@
* Projects a screen space coordinate to the local drawing space.
*/
float3 project(const float2 co) const;
void project(const Span<float2> src, MutableSpan<float3> dst) const;
Member

Remove const for by-value arguments in declarations

Remove const for by-value arguments in declarations
filedescriptor marked this conversation as resolved
Falk David added 1 commit 2023-12-04 15:36:48 +01:00
Hans Goudey approved these changes 2023-12-04 15:59:35 +01:00
@ -54,0 +90,4 @@
/**
* Projects a screen space coordinate to the local drawing space.
*/
float3 project(const float2 co) const;
Member

Here too, and above!

Here too, and above!
filedescriptor marked this conversation as resolved
Falk David added 1 commit 2023-12-04 16:42:11 +01:00
Falk David merged commit 5fea1eda36 into main 2023-12-05 11:01:56 +01:00
Falk David referenced this issue from a commit 2023-12-05 11:01:56 +01:00
Falk David deleted branch gpv3-drawing-placements 2023-12-05 11:01:58 +01:00
Author
Member

Note: Some changes need to be documented (#114419):

  • Setting the drawing origin to "Surface" will grey-out the drawing plane (because it isn't used in this mode).
  • The offset from the surface is now a tool setting. It also respects world space and is not zoom-dependent.
Note: Some changes need to be documented (#114419): * Setting the drawing origin to "Surface" will grey-out the drawing plane (because it isn't used in this mode). * The offset from the surface is now a tool setting. It also respects world space and is not zoom-dependent.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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#115602
No description provided.