Curves: Support for draw tool #115864
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115864
Loading…
Reference in New Issue
No description provided.
Delete Branch "laurynas/blender:curves-draw-tool"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds new curves support to "Draw Curve" operator.
Thanks for working on this! I think people will really appreciate being able to use this operator for the new type. Overall I'd recommend focusing on separating the new and the old code more. It should be very easy to delete the old code when we remove the old object type. Concretely, that means:
editors/curves/
folder in a new fileThat code duplication vs old code separation thing and was main reason to show you. I started to work in a separate operator and felt bad copying everything and decided to alter existing.
It will be easy to switch back, also couple of issues will fall off.
What to do with
curve_bevel_radius()
?In legacy it is taken from Geometry>Bevel>Depth field and in operator adds thickness to preview while drawing
.
New curves do not have such concept and in this context it is not know if curve will have thickness.
I'm thinking to add some small value for user to feel pen pressure change (maybe only with "Use Pressure" checked).
What to do with
is_curve_2d()
? Again it doesn't exist in new curves. Maybe an option in operator panel?Does
curves.resize(..)
invalidateMutableSpans
obtained with:I'd like to move
resize(..)
belowcurve.*_for_write()
;auto resolution = curves.resolution_for_write();
vs.MutableSpan<int> resolution = curves.resolution_for_write();
The radius is generally stored in the
radius
attribute-- there's no additional factor stored on the whole data-block. So yeah, there's nowhere to get this value from. Maybe a new operator property would work fine ("Radius" in distance units).Same situation here I suppose, so yeah, an operator property makes sense.
Indeed it does, the spans should be retrieved after changing the size of the curves.
The cases we do use it are when it's required by template meta-programming and when it's redundant with a cast like
const auto &value = static_cast<SomeType &>(data);
. The types are helpful to the reader, so otherwise it isn't used.Works pretty well in my tests. I'd suggest just calling the radius "Radius" for RNA and in the UI. It should be written to the curve points too (multiplied with the pressure factor).
@ -0,0 +1,1211 @@
#include "DNA_curve_types.h"
Missing license header:
@ -0,0 +618,4 @@
static int curves_draw_exec(bContext *C, wmOperator *op)
{
using namespace bke;
Typically we'd avoid this sort of
using namespace;
Seeing the namespace in the code makes it clear where the types and functions come from (it replaces theBKE_
prefix from the C code.)@ -0,0 +650,4 @@
const float radius_range = cps->radius_max - cps->radius_min;
Curves *curves_id = static_cast<Curves *>(obedit->data);
blender::bke::CurvesGeometry &curves = curves_id->geometry.wrap();
blender::
unnecessary here@ -0,0 +771,4 @@
MutableSpan<int> resolution = curves.resolution_for_write();
resolution[curve_index] = 12;
IndexRange points_of_curve = curves.points_by_curve()[curve_index];
How about this naming, which is hopefully a bit more typical:
@ -0,0 +777,4 @@
MutableAttributeAccessor curves_attributes = curves.attributes_for_write();
SpanAttributeWriter<float> radius_attribute =
curves_attributes.lookup_or_add_for_write_only_span<float>("radius", ATTR_DOMAIN_POINT);
SpanAttributeWriter<bool> selection_attribute =
For the selection, we should support when it is stored as a float too. There are a few utility methods to help with that:
fill_selection_false
can be called before the resizefill_selection_true
can be called with the new pointsThe curve domain should also be supported though, so I'd recommend something things like this:
@ -0,0 +818,4 @@
}
for (const auto i : IndexRange(i_start, i_end - i_start)) {
const int64_t corner_i = points_of_curve[corners_index[i]];
@ -0,0 +1149,4 @@
return ret;
}
bool editable_curves_in_edit_mode_poll(bContext *C);
This declaration shouldn't be necessary here
@ -0,0 +1153,4 @@
void CURVES_OT_draw(wmOperatorType *ot)
{
using namespace blender::ed::curves;
Should be unnecessary, since this is already in that namespace
@ -0,0 +1156,4 @@
using namespace blender::ed::curves;
ot->name = "Draw Curves";
ot->idname = __func__;
ot->description = "Draw a freehand spline";
spline
->curve
here, just for an attempt at consistency with the new type@ -1244,6 +1244,8 @@ static void CURVES_OT_delete(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
void CURVES_OT_draw(wmOperatorType *ot);
This declaration should be moved to
ED_curves.hh
If it is "Radius" then it is redundant as there are two radii already: "Radius Min" and "Max". "Max" would do the work. Why to have "Max" and then multiply it by some other, instead of writing final value directly into "Max". This "Preview Radius" (formerly "Bevel Radius") is leftover from legacy curves operator. In previous version "Bevel Radius" was curves attribute and in draw operator it was handy to preview final result. Though it was used in final geometry calculations, but it was happening outside the operator.
Now user could input some value close to profile size from latter stages and have some clue of final result while drawing.
Also if to remove it I hardly imagine preview implementation. For ex. if user set radii range from 0.0 to 1.0, with intention max value will mean original profile curve size. Draw operator knows nothing about profile and can't do decent preview. Here comes "Preview Radius".
What I don't like is the label I gave "Pvw Radius", but full didn't fit in UI.
Agree with all other comments, fixed them already.
Hmm. I still think we should use this new property to determine the preview radius and the final radius. It's nice not to have a separate preview and final radius option. For now I think we can just imagine that the curves either don't have a separate profile with a different radius, or that the profile's radius is 1.0. The "Radius Min/Max" properties are more like a scaling factor for tapering.
When the curves are able to be rendered properly with radius in the viewport (like they are with Cycles now, sort of), this will probably make more sense.
For me separate preview option is also a compromise. Other two options I see to hide it from UI and hardcode value 0.1 or 0.0(no black line preview).
Could you try to play around with this file.? To draw curve in this branch with "Preview" 1.0. Current code doesn't take "Preview" into final result, but value 1.0 wouldn't change anything. Result is correct, but preview hardly.
Then say exactly what to do. I don't want to get stuck on this.
Thanks for the example file. I think we should just accept the results will be weird if the profile has non-unit size. The preview is still helpful though. So let's not add a new radius property to the operator, and just use the min and max radius properties directly for the preview. The legacy curve "Bevel Depth" property will basically just be 1.0 now.
At last I understand how you saw things :)
I only played with this small profile.
Done
Great! If you consider the PR finished, could you merge main into the branch and remove the WIP tag? I'll look into review later today then, and hopefully commit this.
WIP: Curves: Support for draw toolto Curves: Support for draw tool