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-11Cleanup: Use string argument for attribute API functionHans Goudey
Instead of CustomDataLayer, which exposes the internal implementation more than necessary, and requires that the layer is always available, which isn't always true.
2022-09-25Cleanup: replace C-style casts with functional casts for numeric typesCampbell Barton
2022-09-25Cleanup: replace static_casts with functional casts for numeric typesCampbell Barton
2022-09-15Cleanup: Rename attribute required functionsHans Goudey
Avoid "customdata" in the name, since that's an implementation detail in this context.
2022-09-08Cleanup: Use C++ methods to retrieve attribute accessorsHans Goudey
Replace `mesh_attributes`, `mesh_attributes_for_write` and the point cloud versions with methods on the `Mesh` and `PointCloud` types. This makes them friendlier to use and improves readability. Differential Revision: https://developer.blender.org/D15907
2022-09-07Cleanup: use 'continue' in customdata for loop, reduce right shiftCampbell Barton
2022-09-06Cleanup: early exit when the active layer disallows procedural accessCampbell Barton
Once the active layer index is reached, there is no need to keep searching. Return early instead.
2022-09-03Merge branch 'blender-v3.3-release'Philipp Oeser
2022-09-03Fix T100687: Geometry Attribute Convert crashes in sculpt modePhilipp Oeser
Since above commit, `BKE_id_attributes_active_get` would also return "internal" attributes like ".hide_poly" or ".hide_vert". As a consequence, a couple of poll functions dont return false anymore (attribute remove, attribute convert), allowing these operators to execute, but acting on this "internal" layers is just asking for trouble. In the UI, we dont see these attributes, because `MESH_UL_attributes` checks `is_internal`, same thing we do now in `BKE_id_attributes_active_get`. Maniphest Tasks: T100687 Differential Revision: https://developer.blender.org/D15833
2022-08-31Cleanup: break before the default case in switch statementsCampbell Barton
While missing the break before a default that only breaks isn't an error, it means adding new cases needs to remember to add the break for an existing case, changing the default case will also result in an unintended fall-through. Also avoid `default:;` and add an explicit break.
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-30Cleanup: Use const for custom data layersHans Goudey
2022-08-29Fix T99576: Guard against empty names when removing attributesTom Edwards
It's possible for misbehaving scripts written before 3.3 to reach this state and crash Blender. With this change, the error is reduced to a Python exception. Differential Revision: https://developer.blender.org/D15724
2022-08-04Fix: add attribute with empty string name crashEthan-Hall
Due to a recent change, empty strings are unhandled. This results in Blender crashing. This patch fixes the crash but a discrepancy still exists... Prior to the regression, the empty string would be replaced by the name of the data type. This patch uses "Attribute" for the default name regardless of type. Restoring the previous behavior would require making and/or modifying API methods. Regression introduced in: rBeae36be372a6 Reviewed By: Joseph Eagar & Campbell Barton Differential Revision: https://developer.blender.org/D14734 Ref D14734
2022-07-25Fix T99816: renaming attribute works incorrectlyJacques Lucke
This fixes two issues: * There was a crash when the new attribute name was empty. * The attribute name was incremented (e.g. "Attribute.001") when the old and new name were the same.
2022-07-24Attributes: Use new API for C-API functionsHans Goudey
Use the C++ API to implement more of the existing C functions. This corrects the cases where one tries to add a builtin attribute with the wrong domain or type on curves, though a better warning message would be helpful in the future, and also reduces duplication of the internal logic. Not much more is possible without changing the interface.
2022-07-24Fix: Removing attributes from UI invalidates cachesHans Goudey
Use the new attribute API to implement the attribute remove function used by RNA, except for BMesh attributes. Currently, removing curve attributes from the panel in the property editor does not mark the relevant caches dirty (for example, the cache of curve type counts), because that behavior is implemented with the new attribute API. Also, eventually we want to merge the two APIs, and removing an attribute is the first function that can be partially implemented with the new API. Differential Revision: https://developer.blender.org/D15495
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-06-14Cleanup: Fix const correctness of attribute search functionHans Goudey
Retrieving a mutable custom data layer from a const ID should not be possible.
2022-06-14Attributes: Adjustments to duplicate attribute API functionHans Goudey
Use a name argument, for the same reasons as 6eea5f70e3b79e3c668. Also reuse the layer and unique name creation in `BKE_id_attribute_new` instead of reimplementing it. Also include a few miscellaneous cleanups like using const variables and `std::string`.
2022-06-08D14823: Adds operator to duplicate the active color attribute layerDennis Ranish
Fixes T97706 Adds operator to duplicate the active color attribute layer. Adds `"Color Attribute Specials"` menu to color attribute ui to access the `"geometry.color_attribute_duplicate"` operator. Internally adds a function that duplicates a referenced CustomDataLayer - `BKE_id_attribute_duplicate` mostly copies the existing `BKE_id_attribute_new` - but gets the type and domain from the referenced layer - and copies the data from the old layer into the new layer Reviewed By: Joseph Eagar & Hans Goudey & Julien Kaspar Differential Revision: https://developer.blender.org/D14823 Ref D14823
2022-06-08Attributes: Use names instead of layers for some functionsHans Goudey
This mirrors the C++ attribute API better, separates the implementation of attributes from CustomData slightly, and makes functions simpler, clearer, and safer. Also fix an issue with removing an attribute caused by 97712b018df71c meant the first attribute with the given type was removed instead of the attribute with the given name.
2022-06-07Cleanup: Use const pointers in attribute APIHans Goudey
2022-06-07Fix: Incorrect logic in attribute search functionHans Goudey
If a geometry does not have CustomData for a certain domain, it may still have CustomData on other domains. In that case we need to continue to the other domains instead of returning. This worked for meshes because the domains are all at the start of the `info` array. It didn't work for curves.
2022-06-07Fix: Make renaming attributes check uniqueness on all domainsMartijn Versteegh
This function only checked for uniqueness in the current domain, while attribute names should be unique among all domains within a geometry. Differential Revision: https://developer.blender.org/D15144
2022-06-01Cleanup: use 'e' prefix for enum typesCampbell Barton
- CustomDataType -> eCustomDataType - CustomDataMask -> eCustomDataMask - AttributeDomain -> eAttrDomain - NamedAttributeUsage -> eNamedAttrUsage
2022-06-01Cleanup: conversion from enum/int warningCampbell Barton
2022-06-01Merge branch 'blender-v3.2-release'Joseph Eagar
2022-05-31Attributes: Hide internal UI attributes and disallow procedural accessHans Goudey
This commit hides "UI attributes" described in T97452 from the UI lists in mesh, curve, and point cloud properties, and disallow accessing them in geometry nodes. Internal UI attributes like selection and hiding values should use the attribute system for simplicity and performance, but we don't want to expose those attributes in the attribute panel, which is meant for regular user interaction. Procedural access may be misleading or cause problems, as described in the design task above. These attributes are added by two upcoming patches: D14934, D14685 Differential Revision: https://developer.blender.org/D15069
2022-05-30Cleanup: Move attribute.c to C++Hans Goudey