Commit Graph

22 Commits

Author SHA1 Message Date
Falk David 7e87435cf4 GPv3: Initial drawing tool
This PR implements an initial drawing tool that can already be used for testing.
While this is not fully feature complete (compared to the current grease pencil draw tool) the following is already implemented:

* Pressure support for radius and opacity.
* Material color and vertex color support.
* New active smoothing algorithm based on curve fitting.
* Simplify algorithm as a post-process step.

Some deliberate limitations include:
* The drawing plane is always the front plane. Drawing on surfaces is also not supported.
*

The current approach has not been optimized for performance yet. The goal was to have a straightforward implementation
first and then focus on performance later.

There are numerous parameters in the code that are hard-coded for now. These should be exposed at some point, potentially as user settings.

Pull Request: https://projects.blender.org/blender/blender/pulls/110093
2023-10-06 10:49:54 +02:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Hans Goudey 3c8f7b1a64 Cleanup: Remove unused/redundant includes from BKE_curves.hh
Avoid including headers that are obviously redundant, and don't
include BLI_task.hh in the header file, since it isn't really related.
2023-02-08 20:29:52 -05:00
Hans Goudey 38a45e46bc Cleanup: Use OffsetIndices class in more cases
The same logic from D17025 is used in other places in the curve code.
This patch uses the class for the evaluated point offsets and the Bezier
control point offsets. This helps to standardize the behavior and make
it easier to read.

Previously the Bezier control point offsets used a slightly different standard
where the first point was the first offset, just so they could have the same
size as the number of points. However two nodes used a helper function
to use the same `OffsetIndices` system, so switch to that there too.
That requires removing the subtraction by one to find the actual offset.

Also add const when accessing data arrays from curves, for consistency.

Differential Revision: https://developer.blender.org/D17038
2023-01-19 13:48:20 -06:00
Campbell Barton c7b247a118 Cleanup: replace static_casts with functional casts for numeric types 2022-09-25 18:31:10 +10:00
Hans Goudey 9435ee8c65 Curves: Port subdivide node to the new data-block
This commit moves the subdivide curve node implementation to the
geometry module, changes it to work on the new curves data-block,
and adds support for Catmull Rom curves. Internally I also added
support for a curve domain selection. That isn't used, but it's
nice to have the option anyway.

Users should notice better performance as well, since we can avoid
many small allocations, and there is no conversion to and from the
old curve type.

The code uses a similar structure to the resample node (60a6fbf5b5)
and the set type node (9e393fc2f1). The resample curves node can be
restructured to be more similar to this soon though.

Differential Revision: https://developer.blender.org/D15334
2022-07-05 16:08:37 -05:00
Hans Goudey dccdc6213e Curves: Expose function to calculate vector handles 2022-07-04 11:51:10 -05:00
Dalai Felinto 65bd9974d1 Cleanup: make format 2022-05-30 16:16:25 +02:00
Hans Goudey ddebb0f783 Cleanup: Fix typo
Contributed by @luzpaz

Differential Revision: https://developer.blender.org/D15058
2022-05-30 14:05:15 +02:00
Hans Goudey 94495049a8 Fix: Assert evaluating single point Bezier curve
Just return early in that case to keep the rest of the function simpler.
2022-04-13 16:57:13 -05:00
Hans Goudey 1d86d61782 Fix: Assert fails when evaluating single point Bezier curve
Return early when there is only one point,
since that means there are no segments.
2022-04-04 18:42:01 -05:00
Hans Goudey 00ba51d37b Geometry Nodes: Port set handle nodes to new data-block
This commit ports the "Set Handle Positions" and "Set Hanle Type"
nodes to use the new curves data-block. The nodes become simpler
and likely much faster too, though they're usually not the bottleneck
anyway.

Most of the code is ported from `BezierSpline` directly. The majority
of the complexity comes from the interaction between different
automatically calculated handle types. In comparison `BezierSpline`,
the calculation of auto handles is done eagerly-- mostly because it's
simpler. Eventually lazy calculation might be good to add.

Differential Revision: https://developer.blender.org/D14464
2022-04-01 08:12:41 -05:00
Campbell Barton 87e5c4230f Cleanup: unbalanced doxy sections 2022-03-30 11:17:16 +11:00
Hans Goudey ac9ddf54a0 Fix: incorrect assert in new code 2022-03-29 14:39:18 -05:00
Hans Goudey 1243cb803e Cleanup: Add asserts, remove default case 2022-03-25 09:12:31 -05:00
Hans Goudey cea51c1bb5 Curves: Bezier and general interpolate to evaluated utility
This commit implements generic evaluation for Bezier curves (which is
really just linear interpolation, since attributes are not stored on
Bezier handles). For complete parity with the old curve type, we would
have to add options for this (RNA: `Spline.radius_interpolation`),
but it's not clear that we want to do that.

This also adds a generic `interpolate_to_evaluate` utility on curves
that hides the implementation details. Though there is theoretically
a performance cost to that, without some abstraction calling code
would usually be too complex.

Differential Revision: https://developer.blender.org/D14447
2022-03-25 09:03:35 -05:00
Hans Goudey 83c99ccb21 Cleanup: Use more specific variable name 2022-03-24 22:17:54 -05:00
Hans Goudey 8146c996eb Fix: Curves last evaluated segment is empty
A mistake in 8538c69921. The offsets include the segment at the
corresponding index, but the evaluated offset calculation was adjusting
the offset for the second to last segment.
2022-03-18 12:05:14 -05:00
Hans Goudey 22de21bef1 Fix: Compiler error on windows and mac
The previous fix including `<algorithm>` was an improvement
but not the actual error, which appears to be that `int64_t` is
long long int on one platform but just long int on another.
The fix includes the template argument directly.
2022-03-16 16:49:31 -05:00
Hans Goudey 7a4af7a01b Fix: Build error after curve evaluation commit 2022-03-16 16:29:24 -05:00
Hans Goudey 8538c69921 Curves: Initial evaluation for curves data-block
This patch adds evaluation for NURBS, Bezier, and Catmull Rom
curves for the new `Curves` data-block. The main difference from
the code in `BKE_spline.hh` is that the functionality is not
encapsulated in classes. Instead, each function has arguments
for all of the information it needs. This makes the code more
reusable and removes a bunch of unnecessary complications
for keeping track of state.

NURBS and Bezier evaluation works the same way as existing code.
The Catmull Rom implementation is new, with the basis function
based on Cycles code. All three types have some basic tests.

For NURBS and Catmull Rom curves, evaluating positions is the
same as any generic attribute, so it's implemented by the generic
interpolation to evaluated points. Bezier curves are a bit special,
because the "handle" control points are stored in a separate attribute.
This patch doesn't include generic interpolation to evaluated points
for Bezier curves.

Ref T95942

Differential Revision: https://developer.blender.org/D14284
2022-03-16 15:47:00 -05:00