Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-07-22Fix T99884: Crash when converting to old curve typeHans Goudey
The conversion from Curves to CurveEval used an incorrect type for one of the builtin attributes. Also, an incorrect default was used for reading the nurbs_weight attribute.
2022-07-08Geometry Nodes: new geometry attribute APIJacques Lucke
Currently, there are two attribute API. The first, defined in `BKE_attribute.h` is accessible from RNA and C code. The second is implemented with `GeometryComponent` and is only accessible in C++ code. The second is widely used, but only being accessible through the `GeometrySet` API makes it awkward to use, and even impossible for types that don't correspond directly to a geometry component like `CurvesGeometry`. This patch adds a new attribute API, designed to replace the `GeometryComponent` attribute API now, and to eventually replace or be the basis of the other one. The basic idea is that there is an `AttributeAccessor` class that allows code to interact with a set of attributes owned by some geometry. The accessor itself has no ownership. `AttributeAccessor` is a simple type that can be passed around by value. That makes it easy to return it from functions and to store it in containers. For const-correctness, there is also a `MutableAttributeAccessor` that allows changing individual and can add or remove attributes. Currently, `AttributeAccessor` is composed of two pointers. The first is a pointer to the owner of the attribute data. The second is a pointer to a struct with function pointers, that is similar to a virtual function table. The functions know how to access attributes on the owner. The actual attribute access for geometries is still implemented with the `AttributeProvider` pattern, which makes it easy to support different sources of attributes on a geometry and simplifies dealing with built-in attributes. There are different ways to get an attribute accessor for a geometry: * `GeometryComponent.attributes()` * `CurvesGeometry.attributes()` * `bke::mesh_attributes(const Mesh &)` * `bke::pointcloud_attributes(const PointCloud &)` All of these also have a `_for_write` variant that returns a `MutabelAttributeAccessor`. Differential Revision: https://developer.blender.org/D15280
2022-07-02BLI: improve span access to virtual arraysJacques Lucke
* Make the class names more consistent. * Implement missing move-constructors and assignment-operators.
2022-05-13Cleanup: Use standard variable names for curvesHans Goudey
2022-05-11Cleanup: use '_num' suffix, mostly for curves & spline codeCampbell Barton
Replace tot/amount & size with num, in keeping with T85728.
2022-04-25Curves: Cache the number of curves of each typeHans Goudey
Remembering the number of curves of every type makes it fast to know whether processing specific to a single curve type has to be done. This information was accessed in quite a few places, so this should be an overall reduction in overhead for the new curves type. The cache is computed eagerly, in other words every time after changing the curve types. In order to reduce verbosity I added helper functions for some common ways to set the types. Differential Revision: https://developer.blender.org/D14732
2022-04-15Curves: initial geometry nodes support for curves objectsJacques Lucke
* Curves objects now support the geometry nodes modifier. * It's possible to use the curves object with the Object Info node. * The spreadsheet shows the curve data. The main thing holding this back currently is that the drawing code for the curves object is very incomplete. E.g. it resamples the curves always in the end, which is not expected for curves in general. Differential Revision: https://developer.blender.org/D14277
2022-04-14Fix: Use consistent type for nurbs order attributeHans Goudey
An 8 bit integer should be enough for now. We can change this if we ever want to allow increasing the order past 256.
2022-04-09Curves: Port tangent and normal calculation to the new data-blockHans Goudey
Port the "Normal" and "Curve Tangent" nodes to the new curves data-block to avoid the conversion to `CurveEval`. This should make them faster by avoiding all that copying, but otherwise nothing else has changed. This also includes a fix to move the normal mode as a built-in curve attribute when converting to and from `CurveEval`. The attribute is needed because the option is used implicitly in many nodes currently. Differential Revision: https://developer.blender.org/D14609
2022-04-08Cleanup: Define new curves normal mode in DNAHans Goudey
Don't include the tangent mode for now, since that was never implemented for geometry nodes curves.
2022-04-07Cleanup: clang-formatCampbell Barton
2022-04-07Fix: Copy resolution when creating CurveEval from CurvesMattias Fredriksson
Set the curve resolution to Bezier and Nurbs curves when converting data using `curves_to_curve_eval`. This was missed in 9ec12c26f16ea3d. Differential Revision: https://developer.blender.org/D14577
2022-04-07Curves: Name mutable data retrieval functions explicitlyHans Goudey
Add "for_write" on function names that retrieve mutable data arrays. Though this makes function names longer, it's likely worth it because it allows more easily using the const functions in a non-const context, and reduces cases of mistakenly retrieving with edit access. In the long term, this situation might change more if we implement attributes storage that is accessible directly on `CurvesGeometry` without duplicating the attribute API on geometry components, which is currently the rough plan. Differential Revision: https://developer.blender.org/D14562
2022-03-24Cleanup: Adjust naming in new curves codeHans Goudey
Rename "size" variables and functions to use "num" instead, based on T85728 (though this doesn't apply to simple C++ containers, it applies here). Rename "range" to "points" in some functions, so be more specific. Differential Revision: https://developer.blender.org/D14431
2022-03-19BLI: move generic data structures to blenlibJacques Lucke
This is a follow up to rB2252bc6a5527cd7360d1ccfe7a2d1bc640a8dfa6.
2022-03-11Cleanup: Use new enum for NURBS curve knots modesHans Goudey
Move the definition of the enum to `Curves` DNA, since the values will be saved in files, and ongoing development needs to use this.
2022-03-11Curve: Improve NURBS knot generation modesLaurynas Duburas
This patch enables all 8 combinations of Nurbs modes: Cyclic, Bezier and Endpoint. Also removes restriction on Bezier Nurbs order. The most significant changes are mode combinations bringing new meaning. In D13891 is a scheme showing NURBS with same control points in a modes, and also further description of each possible case. Differential Revision: https://developer.blender.org/D13891
2022-03-04Fix T96164: Crash with curve domain attributesHans Goudey
When converting from the new type to the old, the curve domain attributes weren't properly resized, so their data was not properly allocated.
2022-03-01Fix: Use correct default in Curves to CurveEval conversionHans Goudey
Currently the code expects the radius attribuet to always exist on the input Curves. This won't be true in the future though, so the correct default value of one should be used when creating the data on CurveEval, where the data is not optional.
2022-02-28Geometry Nodes: Begin conversion to new curvesHans Goudey
This commit changes `CurveComponent` to store the new curve type by adding conversions to and from `CurveEval` in most nodes. This will temporarily make performance of curves in geometry nodes much worse, but as functionality is implemented for the new type and it is used in more places, performance will become better than before. We still use `CurveEval` for drawing curves, because the new `Curves` data-block has no evaluated points yet. So the `Curve` ID is still generated for rendering in the same way as before. It's also still needed for drawing curve object edit mode overlays. The old curve component isn't removed yet, because it is still used to implement the conversions to and from `CurveEval`. A few more attributes are added to make this possible: - `nurbs_weight`: The weight for each control point on NURBS curves. - `nurbs_order`: The order of the NURBS curve - `knots_mode`: Necessary for conversion, not defined yet. - `handle_type_{left/right}`: An 8 bit integer attribute. Differential Revision: https://developer.blender.org/D14145
2022-02-23Cleanup: Use new curves type enum for CurveEvalHans Goudey
Though this is less aesthetically pleasing, it makes the transition to the new curves type (T95941) a bit simpler, and it has to be done anyway.
2022-02-23Cleanup: Use new enum for CurveEval handle typesHans Goudey
This will make the transition to the new curves data structure a bit simple, since the handle types can be copied directly between the two. The change to CurveEval is simple because it is runtime-only.
2022-02-11File headers: SPDX License migrationCampbell Barton
Use a shorter/simpler license convention, stops the header taking so much space. Follow the SPDX license specification: https://spdx.org/licenses - C/C++/objc/objc++ - Python - Shell Scripts - CMake, GNUmakefile While most of the source tree has been included - `./extern/` was left out. - `./intern/cycles` & `./intern/atomic` are also excluded because they use different header conventions. doc/license/SPDX-license-identifiers.txt has been added to list SPDX all used identifiers. See P2788 for the script that automated these edits. Reviewed By: brecht, mont29, sergey Ref D14069
2021-12-29Fix T94113: Local view + Geometry Nodes is broken for instancesGermano Cavalcante
`GeometrySet::compute_boundbox_without_instances` may not initialize min max in some cases such as meshes without vertices. This can result in a Bounding Box with impossible dimensions (min=FLT_MAX, max=-FLT_MAX). So repeat the same solution seen in `BKE_object_boundbox_calc_from_mesh` and set boundbox values to zero. Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D13664
2021-12-14Geometry Nodes: support instance attributes when realizing instancesJacques Lucke
This patch refactors the instance-realization code and adds new functionality. * Named and anonymous attributes are propagated from instances to the realized geometry. If the same attribute exists on the geometry and on an instance, the attribute on the geometry has precedence. * The id attribute has special handling to avoid creating the same id on many output points. This is necessary to make e.g. the Random Value node work as expected afterwards. Realizing instance attributes has an effect on existing files, especially due to the id attribute. To avoid breaking existing files, the Realize Instances node now has a legacy option that is enabled for all already existing Realize Instances nodes. Removing this legacy behavior does affect some existing files (although not many). We can decide whether it's worth to remove the old behavior as a separate step. This refactor also improves performance when realizing instances. That is mainly due to multi-threading. See D13446 to get the file used for benchmarking. The curve code is not as optimized as it could be yet. That's mainly because the storage for these attributes might change soonish and it wasn't worth optimizing for the current storage format right now. ``` 1,000,000 x mesh vertex: 530 ms -> 130 ms 1,000,000 x simple cube: 1290 ms -> 190 ms 1,000,000 x point: 1000 ms -> 150 ms 1,000,000 x curve spiral: 1740 ms -> 330 ms 1,000,000 x curve line: 1110 ms -> 210 ms 10,000 x subdivided cylinder: 170 ms -> 40 ms 10 x subdivided spiral: 180 ms -> 180 ms ``` Differential Revision: https://developer.blender.org/D13446
2021-12-02Cleanup: Move public docs to BKE_spline.hh headerHans Goudey
2021-11-22CurveEval: Add total_length() and total_control_point_size() methodsJohnny Matthews
Add the following methods to the CurveEval class: total_length() : returns the total length of the curve without needing to allocate a new array total_control_point_size() : returns the total number of control points without needing to allocate a new array
2021-11-11Fix: Prevent use of uninitialized memory when creating Bezier splineMartijn Versteegh
When Constructing bezier splines from dna, the positions of the left/right handles were set directly in the internal vectors, by requesting a reference to them. The problem is that BezierSpline::handle_positions_left() calls ensure_auto_handles() before returning the reference. That function does some calculations on uninitialized memory if the positions array is not yet filled. Differential Revision: https://developer.blender.org/D13107
2021-11-02Cleanup: Improve curve point attribute assertHans Goudey
This properly checks the order of point domain attributes on each spline, and avoids the map, which makes the code easier to understand. The assert is also added to realizing instances and the join node. Differential Revision: https://developer.blender.org/D13071
2021-10-29Geometry Nodes: do cache invalidation after writing attributesJacques Lucke
This is a better and more general fix for T92511 and T92508 than the ones that I committed before. Previously, we tagged caches dirty when first accessing attributes. This led to incorrect caches when under some circumstances. Now cache invalidation is part of `OutputAttribute.save()`. A nice side benefit of this change is that it may make things more efficient in some cases, because we don't invalidate caches when they don't have to be invalidated. Differential Revision: https://developer.blender.org/D13009
2021-09-21Geometry Nodes: Curve Sample NodeHans Goudey
This node allows sampling positions, tangents, and normals at any arbitrary point along a curve. The curve can include multiple splines, all are taken into account. The node does not yet support transferring generic attributes like radius, because some more general tooling will make that much more feasible and useful in different scenarios. This is a field node, so it is evaluated in the context of a data-flow node like "Set Position". One nice thing about that is it can easily be used to move an entire geometry like the follow path constraint. The point along the curve is chosen either with a factor of the total length of the curve, or a length into the curve, the same choice used in the curve trim node. Differential Revision: https://developer.blender.org/D12565
2021-09-20Cleanup: Fix/improve variable names and commentsHans Goudey
2021-09-09Geometry Nodes: fields and anonymous attributesJacques Lucke
This implements the initial core framework for fields and anonymous attributes (also see T91274). The new functionality is hidden behind the "Geometry Nodes Fields" feature flag. When enabled in the user preferences, the following new nodes become available: `Position`, `Index`, `Normal`, `Set Position` and `Attribute Capture`. Socket inspection has not been updated to work with fields yet. Besides these changes at the user level, this patch contains the ground work for: * building and evaluating fields at run-time (`FN_fields.hh`) and * creating and accessing anonymous attributes on geometry (`BKE_anonymous_attribute.h`). For evaluating fields we use a new so called multi-function procedure (`FN_multi_function_procedure.hh`). It allows composing multi-functions in arbitrary ways and supports efficient evaluation as is required by fields. See `FN_multi_function_procedure.hh` for more details on how this evaluation mechanism can be used. A new `AttributeIDRef` has been added which allows handling named and anonymous attributes in the same way in many places. Hans and I worked on this patch together. Differential Revision: https://developer.blender.org/D12414
2021-07-23Cleanup: Add function to check a curve's spline typesHans Goudey
The need for this has come up a few times.
2021-07-15Cleanup: ensure one newline at end of file, strip trailing spaceCampbell Barton
2021-06-28Cleanup: Add function to create a CurveEval from a nurbs listHans Goudey
Sometimes the current spline list isn't part of the original curve, like when using the deformed control points, etc. This will be helpful in the curve modifier stack.
2021-06-21Curves: Multithread Curve to CurveEval conversionHans Goudey
A different data structure / implementation is used for curves in the node tree currently. Converting from the DNA `Curve` structure to this wasn't slow, but it's nice to decrease overhead. In a test of 14000 splines with 128000 points, this halves the runtime from about 5ms to about 2.5ms.
2021-06-16Splines: Add resize method to CurveEvalHans Goudey
This helps when adding splines to a new curve in parallel.
2021-05-19Geometry Nodes: Support for dynamic attributes on curve splinesHans Goudey
With this patch you will be able to add and remove attributes from curve data inside of geometry nodes. The following is currently implemented: * Adding attributes with any data type to splines or spline points. * Support for working with multiple splines at the same time. * Interaction with the three builtin point attributes. * Resampling attributes in the resample node. The following is not implemented in this patch: * Joining attributes when joining splines with the join geometry node. * Domain interpolation between spline and point domains. * More efficient ways to call attribute operations once per spline. Differential Revision: https://developer.blender.org/D11251
2021-05-19Cleanup: Use copy constructor for CurveEvalHans Goudey
There is no need for a special "copy" method with a copy constructor, which will be necessary to explicitly copy attributes anyway.
2021-05-16Cleanup: Improve commentsHans Goudey
2021-05-16Splines: Convenience methods for point offsets of multiple splinesHans Goudey
Since spline data is stored separately for each spline, the data often needs to be flattened into a separate array. It's helpful to have the necessarily-sequential part of that split off into a separate method. I've found myself using functions like these in quite a few places.
2021-05-12Cleanup: Splines: Add accessors to spline vectorHans Goudey
Not allowing external direct access to the vector of splines in the curve will help for things like reallocating custom data when a spline is added or removed.
2021-05-03Geometry Nodes: Initial basic curve data supportHans Goudey
This patch adds initial curve support to geometry nodes. Currently there is only one node available, the "Curve to Mesh" node, T87428. However, the aim of the changes here is larger than just supporting curve data in nodes-- it also uses the opportunity to add better spline data structures, intended to replace the existing curve evaluation code. The curve code in Blender is quite old, and it's generally regarded as some of the messiest, hardest-to-understand code as well. The classes in `BKE_spline.hh` aim to be faster, more extensible, and much more easily understandable. Further explanation can be found in comments in that file. Initial builtin spline attributes are supported-- reading and writing from the `cyclic` and `resolution` attributes works with any of the attribute nodes. Also, only Z-up normal calculation is implemented at the moment, and tilts do not apply yet. **Limitations** - For now, you must bring curves into the node tree with an "Object Info" node. Changes to the curve modifier stack will come later. - Converting to a mesh is necessary to visualize the curve data. Further progress can be tracked in: T87245 Higher level design document: https://wiki.blender.org/wiki/Modules/Physics_Nodes/Projects/EverythingNodes/CurveNodes Differential Revision: https://developer.blender.org/D11091