Python: Define attribute groups based on AttributeOwnerType
The function `rna_def_attributes_common` assumed that the owner of the attributes is an `ID`. This PR refactors the code to partially remove this assumption. The `rna_def_attributes_common` function now takes an argument `AttributeOwnerType type` that defines what `AttributeGroup` should be used. This is in preperation for #116043 where we want to use `rna_def_attributes_common` for grease pencil drawings, which are not IDs. In addition to the refactor explained above, this also changes the API slightly: Previously, the `AttributeGroup` defiend `active_color`, `active_color_index`, `active_color_name`, `default_color_name`, and `render_color_index` for all IDs. These properties could only be used by meshes. So this PR seperates the `AttributeGroup` type into one type per attribute owner: `AttributeGroupMesh`, `AttributeGroupPointCloud`, `AttributeGroupCurves`, and `AttributeGroupGreasePencil`. As such the properties mentioned above are now only usable by meshes. Note that this technically breaks the API and will have to be noted in the release notes. Pull Request: https://projects.blender.org/blender/blender/pulls/123658
This commit is contained in:
@@ -720,7 +720,7 @@ class AttributeDescription:
|
||||
domain: str
|
||||
# Some attributes are required to exist if certain conditions are met. If a required attribute does not exist when
|
||||
# attempting to get it, an AssertionError is raised.
|
||||
is_required_check: Callable[[bpy.types.AttributeGroup], bool] = None
|
||||
is_required_check: Callable[[bpy.types.AttributeGroupMesh], bool] = None
|
||||
# NumPy dtype that matches the internal C data of this attribute.
|
||||
dtype: np.dtype = field(init=False)
|
||||
# The default attribute name to use with foreach_get and foreach_set.
|
||||
|
||||
Reference in New Issue
Block a user