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-11-08BLI: new basic CacheMutexJacques Lucke
This patch introduces a new `CacheMutex` which makes it easy to implement lazily computed caches in e.g. `Curves`. For more details see `BLI_cache_mutex.hh`. Differential Revision: https://developer.blender.org/D16419
2022-10-19Fix T101926: Curves: Remove type-specific attributes when deletingHans Goudey
Remove NURBS or Bezier specific attributes after removing points or curves. In theory we could avoid copying those attributes in the first place, but that doesn't seem worth the extra complexity here, since we don't necessarily know the result curve type counts before copying attributes.
2022-10-19Geometry Nodes: Use common utility for copying attribute dataHans Goudey
Attribute copying often uses identical logic for copying selected elements or copying with an index map. Instead of reimplementing this in each file, use the common implementation in the array_utils namespace. This makes the commonality more obvious, gives improved performance (this implementation is multithreaded), reduces binary size (I observed a 173KB reduction), and probably reduces compile time.
2022-10-18Fix T101660: crash when trying to propagate string attributes in some nodesJacques Lucke
String attributes are intentionally not fully supported in geometry nodes yet because more design work is necessary to decide how they should behave. For now just disable handling string attributes to avoid crashes.
2022-09-28Geometry Nodes: Curve and mesh topology access nodesHans Goudey
This patch contains an initial set of nodes to access basic mesh topology information, as explored in T100020. The nodes allow six direct topology mappings for meshes: - **Corner -> Face** The face a corner is in, the index in the face - **Vertex -> Edge** Choose an edge attached to the vertex - **Vertex -> Corner** Choose a corner attached to the vertex - **Corner -> Edge** The next and previous edge at each face corner - **Corner -> Vertex** The vertex associated with a corner - **Corner -> Corner** Offset a corner index within a face And two new topology mappings for curves: - **Curve -> Points** Choose a point within a curve - **Point -> Curve** The curve a point is in, the index in the curve The idea is that some of the 16 possible mesh mappings are more important, and that this is a useful set of nodes to start exploring this area. For mappings with an arbitrary number of connections, we must sort them and use an index to choose a single element, because geometry nodes does not support list fields. Note that the sort index has repeating behavior as it goes over the "Total" number of connections, and negative sort indices choose from the end. Currently which of the "start" elements is used is determined by the field context, so the "Field at Index" and "Interpolate Domain" nodes will be quite important. Also, currently the "Sort Index" inputs are clamped to the number of connections. One important feature that isn't implemented here is using the winding order for the output elements. This can be a separate mode for some of these nodes. It will be optional because of the performance impact. There are several todos for separate commits after this: - Rename "Control Point Neighbors" to be consistent with this naming - Version away the "Vertex Neighbors" node which is fully redundant now - Implement a special case for when no weights are used for performance - De-duplicating some of the sorting logic between the nodes - Improve performance and memory use of topology mappings - Look into caching some of the mappings on meshes Differential Revision: https://developer.blender.org/D16029
2022-09-24Curves: Use early out when apapting domain of single valueHans Goudey
When adapting the domain of a single value virtual array, skip allocating an array for the result and just return another single value. Among other cases, this can help when everything is selected in sculpt mode, moving domain interpolation from 5% of perf samples to 0% when sculpting.
2022-09-13Cleanup: remove unused functionCampbell Barton
2022-09-13Cleanup: Use attribute API for curves functionsHans Goudey
2022-09-12Geometry: Avoid unnecessary initialization when resizing data arraysHans Goudey
When resizing mesh and curves attribute storage, avoid initializing the new memory for basic types. Also, avoid skipping "no free" layers; all layers should be reallocated to the new size since they may be accessed. The semantics introduced in 25237d2625078c6d1 are essential for this change, because otherwise we don't have a way to construct non-trivial types in the new memory. In a basic test of the extrude node, I observed a performance improvement of about 30%, from 55ms to 42ms. Differential Revision: https://developer.blender.org/D15818
2022-09-05Merge branch 'blender-v3.3-release'Jacques Lucke
2022-09-05Fix T100796: wrong tangents on bezier splines with duplicate points and handlesJacques Lucke
Differential Revision: https://developer.blender.org/D15880
2022-09-02Merge branch 'blender-v3.3-release'Hans Goudey
2022-09-02Fix T100768: Reverse curves skips handles of middle Bezier pointsHans Goudey
Reversing Bezier handle types and positions would skip the middle point of curves with an odd number of segments, which is still necessary to swap in order to avoid changing the curve's shape.
2022-08-31Curves: Avoid unnecessarily initializing new positions layerHans Goudey
When creating a curves data-block, one is expected to set the new position values. We can slightly improve performance by avoiding doing that redundantly. Similar to cccc6d6905be7ac32cb.
2022-08-30Attributes: Improve custom data initialization optionsHans Goudey
When allocating new `CustomData` layers, often we do redundant initialization of arrays. For example, it's common that values are allocated, set to their default value, and then set to some other value. This is wasteful, and it negates the benefits of optimizations to the allocator like D15082. There are two reasons for this. The first is array-of-structs storage that makes it annoying to initialize values manually, and the second is confusing options in the Custom Data API. This patch addresses the latter. The `CustomData` "alloc type" options are rearranged. Now, besides the options that use existing layers, there are two remaining: * `CD_SET_DEFAULT` sets the default value. * Usually zeroes, but for colors this is white (how it was before). * Should be used when you add the layer but don't set all values. * `CD_CONSTRUCT` refers to the "default construct" C++ term. * Only necessary or defined for non-trivial types like vertex groups. * Doesn't do anything for trivial types like `int` or `float3`. * Should be used every other time, when all values will be set. The attribute API's `AttributeInit` types are updated as well. To update code, replace `CD_CALLOC` with `CD_SET_DEFAULT` and `CD_DEFAULT` with `CD_CONSTRUCT`. This doesn't cause any functional changes yet. Follow-up commits will change to avoid initializing new layers where the correctness is clear. Differential Revision: https://developer.blender.org/D15617
2022-08-28Curves: Avoid creating types array when unnecessaryHans Goudey
When the curve type attribute doesn't exist, there is no reason to create an array for it only to fill the default value, which will add overhead to subsequent "add" operations. I added a "get_if_single" method to virtual array to simplify this check. Also use the existing functions for filling curve types. Differential Revision: https://developer.blender.org/D15560
2022-08-19Merge branch 'blender-v3.3-release'Jacques Lucke
2022-08-19Fix: nurbs basis cache not computed before it is usedJacques Lucke
2022-08-12Cleanup: repeated words in commentsCampbell Barton
2022-08-03Attribute Math: Improve performance of mixer in some casesIliay Katueshenock
The `DefaultMixer` for mixing generic data types has some issues: 1. The full buffer is always zeroed, even if only some is used. 2. Finalizing also works on all values, even if only some are used. 3. "mixing" doesn't allow setting the first value, requiring that everything is cleared beforehand. This commit adds the following functionality: 1. Constructor with the specified `IndexMask` for preliminary zeroing. 2. `set` method to overwrite the value. 3. `finalize` with the specified mask to process a subset of values. This is useful in situations where you want to use the DefaultMixer without having to overwrite all the values many times. A performance improvement was observed for NURBS curve evaluation and attribute interpolation from the point to curve domain of about 15% and 35% respectively (100,000 curves). Differential Revision: https://developer.blender.org/D15434
2022-07-27Curves: Bring back parallel copying of curve and point attributesHans Goudey
This was removed in cacdea7f4a5b49d to fix a bug, but copying point and curve attributes should be fine as long as the attribute arrays are retrieved before-hand. Differential Revision: https://developer.blender.org/D15541
2022-07-26BLI: add use_threading parameter to parallel_invokeIliay Katueshenock
`parallel_invoke` allows executing functions on separate threads. However, creating tasks in tbb has a measurable amount of overhead. Therefore, it can be benefitial to disable parallelization when the amount of work done per function is small. See D15539 for some benchmark results. Differential Revision: https://developer.blender.org/D15539
2022-07-25Fix T99850: incorrect tangents on evaluated bezier curvesJacques Lucke
Cyclic curves don't need the tangent correction based on the first and last handle position.
2022-07-25Fix: crash when accessing attributes from multiple threadsJacques Lucke
Calling two non-const methods on a `MutableAttributeAccessor` at the same time in multiple threads is not safe. While I don't know what caused the crash here exactly, I do know that it happens while looking up the attribute for writing, which may modify the unterlying geometry. I couldn't reproduce the bug with a debug build or without threading.
2022-07-21Fix T99878: Deleting curves or points removes anonymous attributesHans Goudey
Use the attribute API instead of the CustomData API, to correctly handle anonymous attributes and simplify the code. One non-obvious thing to note is that the type counts are recalculated by the "finish" function of the `curve_type` attribute, so they don't need to be copied explicitly. Also, the mutable attribute accessor cannot be an reference if we want to give it an rvalue, which is convenient in this case.
2022-07-20Curves: Remove redundant custom data pointersHans Goudey
These mutable pointers present problems with ownership in relation to proper copy-on-write for attributes. The simplest solution is to just remove them and retrieve the layers from `CustomData` when they are needed. This also removes the complexity and redundancy of having to update the pointers as the curves change. A similar change will apply to meshes and point clouds. One downside of this change is that it makes random access with RNA slower. However, it's simple to just use the RNA attribute API instead, which is unaffected. In this patch I updated Cycles to do that. With the future attribute CoW changes, this generic approach makes sense because Cycles can just request ownership of the existing arrays. Differential Revision: https://developer.blender.org/D15486
2022-07-02BLI: improve span access to virtual arraysJacques Lucke
* Make the class names more consistent. * Implement missing move-constructors and assignment-operators.
2022-07-01Curves: Avoid initializing offsets when first allocatedHans Goudey
The offsets array that encodes the sizes of each curve must be filled anyway, or the curves will be in an invalid state. Calloc is unnecessary here. To make that situation clearer, fill the offsets with -1 in debug builds. Always set the first offset to zero though, since that can save some boilerplate in other areas.
2022-06-20Fix: assert when deleting all curvesJacques Lucke
2022-06-09Curves: Port delete geometry node to the new curves typeHans Goudey
Add a method to remove points from the new curves type, just like the existing curve removal function. No functional changes are expected. The code is simpler because all data is just stored as attributes, but also different because the point data for all curves is stored in the same arrays. Similar performance improvements as other commits in T95443 are expected, expecially for cases where there are many small curves. Differential Revision: https://developer.blender.org/D15130
2022-06-08Curves: Port set type node to new data-blockHans Goudey
This commit ports the "Set Spline Type" node to the new curves type. Performance should be improved in similar ways to the other refactors from the conversion task (T95443). Converting to and from Catmull Rom curves is now supported. There are a few cases where a lot of work can be skipped: when the number of points doesn't change, and when the types already match the goal type. The refactor has a few other explicit goals as well: - Don't count on initialization of attribute arrays when they are first allocated. - Avoid copying the entire data-block when possible. - Make decisions about which attributes to copy when changing curves more obvious. - Use higher-level methods to copy data between curve points. - Optimize for the common cases of single types and full selections. - Process selected curves of the same types in the same loop. The Bezier to NURBS conversion is written by Piotr Makal (@pmakal). Differential Revision: https://developer.blender.org/D14769
2022-06-05Curves: Fix overallocation for curve attributes when deleting curvesHans Goudey
Curve attributes were allocated to the size of the point domain, which wouldn't cause bad behavior, just potentially worse performance.
2022-06-05Curves: use uv coordinates to attach curves to meshJacques Lucke
This implements the new way to attach curves to a mesh surface using a uv map (based on the recent discussion in T95776). The curves data block now not only stores a reference to the surface object but also a name of a uv map on that object. Having a uv map is optional for most operations, but it will be required later for animation (when the curves are supposed to be deformed based on deformation of the surface). The "Empty Hair" operator in the Add menu sets the uv map name automatically if possible. It's possible to start working without a uv map and to attach the curves to a uv map later on. It's also possible to reattach the curves to a new uv map using the "Curves > Snap to Nearest Surface" operator in curves sculpt mode. Note, the implementation to do the reverse lookup from uv to a position on the surface is trivial and inefficient now. A more efficient data structure will be implemented separately soon. Differential Revision: https://developer.blender.org/D15125
2022-06-01Cleanup: use 'e' prefix for enum typesCampbell Barton
- CustomDataType -> eCustomDataType - CustomDataMask -> eCustomDataMask - AttributeDomain -> eAttrDomain - NamedAttributeUsage -> eNamedAttrUsage
2022-05-31Curves: Add soft selection in sculpt modeHans Goudey
This commit adds a float selection to curve control points or curves, a sculpt tool to paint the selection, and uses the selection influence in the existing sculpt brushes. The selection is the inverse of the "mask" from mesh sculpt mode currently. That change is described in more detail here: T97903 Since some sculpt tools are really "per curve" tools, they use the average point selection of all of their points. The delete brush considers a curve selected if any of its points have a non-zero selection. There is a new option to choose the selection domain, which affects how painting the selection works. You can also turn the selection off by clicking on the active domain. Sculpt brushes can be faster when the selection is small, because finding selected curves or points is generally faster than the existing brush intersection and distance checks. The main limitation currently is that we can't see the selection in the viewport by default. For now, to see the selection one has to add a simple material to the curves object as shown in the differential revision. And one has to switch to Material Preview in the 3d view. Differential Revision: https://developer.blender.org/D14934
2022-05-11Cleanup: use '_num' suffix, mostly for curves & spline codeCampbell Barton
Replace tot/amount & size with num, in keeping with T85728.
2022-05-11Cleanup: use '_num' suffix instead of '_size' for CurveGeometryCampbell Barton
Follow conventions from T85728.
2022-05-06Fix: Handle default better in curves type count cacheHans Goudey
When the curve types array isn't allocated, the default type is Catmull Rom. Because the type counts are calculated eagerly, they must be in a valid state.
2022-05-04Curves: Add method to find indices for curve type in a selectionHans Goudey
For example, this can be used to find the indices of all Bezier curves inside an existing selection. The important part is that it is optimized for the case when all curves have the same type.
2022-05-04Curves: Optimize filling all curves with a single typeHans Goudey
If all curves are selected for setting the new type, skip counting the types and just set it directly.
2022-05-04Curves: Use copied original data for invalid NURBS curvesHans Goudey
NURBS curves can be invalid when the order is less than the number of points, or in a few other situations. Currently the evaluated data of an invalid NURBS curve is empty. This is inconvenient because it requires checking for empty curves when it otherwise wouldn't be necessary. This patch replaces that fallback with copying the original data to the evaluated points. This makes conceptual sense too, as if the curve couldn't be evaluated-- which wouldn't necessarily delete it. Usually the UI protects against this happening, but it's currently possible to create an invalid curve with some operations like the delete geometry node. Differential Revision: https://developer.blender.org/D14837
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: Port curve to mesh node to the new data-blockHans Goudey
This commit changes the Curve to Mesh node to work with `Curves` instead of `CurveEval`. The change ends up basically completely rewriting the node, since the different attribute storage means that the decisions made previously don't make much sense anymore. The main loops are now "for each attribute: for each curve combination" rather than the other way around, with the goal of taking advantage of the locality of curve attributes. This improvement is quite noticeable with many small curves; I measured a 4-5x improvement (around 4-5s to <1s) when converting millions of curves to tens of millions of faces. I didn't obverse any change in performance compared to 3.1 with fewer curves though. The changes also solve an algorithmic flaw where any interpolated attributes would be evaluated for every curve combination instead of just once per curve. This can be a large improvement when there are many profile curves. The code relies heavily on a function `foreach_curve_combination` which calculates some basic information about each combination and calls a templated function. I made assumptions about unnecessary reads being removed by compiler optimizations. For further performance improvements in the future that might be an area to investigate. Another might be using a "for a group of curves: for each attribute: for each curve" pattern to increase the locality of memory access. Differential Revision: https://developer.blender.org/D14642
2022-04-15Fix: Apply tilt in curves data-block normals calculationHans Goudey
The ported normal calculation from ceed37fc5cbb466a0 neglected to use the tilt attribute to rotate the normals around the tangents. This commit adds that behavior back, adding a new math header file to avoid duplicating the rotation function for normalized axes. Differential Revision: https://developer.blender.org/D14655
2022-04-14Curves: Avoid duplicating evaluated positions with all poly curvesHans Goudey
If all of the curves are poly curves, the evaluated positions are the same as the original positions. In this case just reuse the original positions span as the evaluated positions.
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-09Fix: error in previous commitJacques Lucke
2022-04-09Curves: correctly initialize new attributesAngus Stanton
Previously, the new attributes were zero-initialized. However, sometimes the default has to be something else. The old behavior led to unexpected behavior in the Snap Curves to Surface operator in Deform mode, when the curves were not attached to the surface before. Differential Revision: https://developer.blender.org/D14588
2022-04-09Fix: Various fixes and cleanups in new curves codeHans Goudey
- Use "curve" instead of "spline" in comments - Use non-plural variable names - Tag topology dirty after resolution modified rather than positions - Reorder enum values to change which value is zero (and the default) - Remove a duplicate unused variable
2022-04-08Fix: accidentally swapped value with itselfJacques Lucke
Found in T96889.