Commit Graph

23 Commits

Author SHA1 Message Date
Hans Goudey
8b7a0b307b Cleanup: Make AttributeStorage method const 2025-08-19 10:23:13 -04:00
Hans Goudey
814d04aaf9 Attributes: Reset various runtime data for writing files
These fields are always reset at runtime. Writing zeros should be easier
to compress since a lot of other data is zeroed, and it also makes it
easier for developers to filter out noise when looking at data buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/144582
2025-08-14 23:39:16 +02:00
Hans Goudey
9c9695b103 Refactor: Move ReportList definition from DNA to blenkernel
Ever since [0], ReportList is not actually used in any DNA structs.
That makes sense, since reports are conceptually only necessary
at runtime. Move the definition of the struct to BKE_report.hh, and
fix a bunch of include errors where types were previously available
transitively. Besides adding some clarity, theoretically this change
could reduce compile times because of less header parsing.

[0]: 1bf6d8b0b9

Pull Request: https://projects.blender.org/blender/blender/pulls/138872
2025-07-24 15:59:52 +02:00
Jacques Lucke
20eaa1b1b0 Fix: Attributes: missing null check in when accessing attribute for write 2025-07-18 16:21:25 +02:00
Jacques Lucke
55e2fd2929 Cleanup: unify naming for named constructors
Previously, we used an inconsistent naming scheme for such "named constructors".
Now it always uses `from_*`.

Pull Request: https://projects.blender.org/blender/blender/pulls/142175
2025-07-17 09:09:16 +02:00
Brecht Van Lommel
8d8e61fefd Logging: Change various categories and log levels
* Remove bke, ed and wm prefixes
* Add prefixes like: geom, object, blend, lib.
* Shorten some category names
* A few log level changes to improve --log-level info output

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Hans Goudey
09902044ff Fix: Default value ignored for some new builtin attributes
0dbe435aa8 was not complete.

Pull Request: https://projects.blender.org/blender/blender/pulls/141304
2025-07-01 21:27:14 +02:00
Hans Goudey
a3d14424d6 Merge branch 'blender-v4.5-release' 2025-06-27 11:24:56 -04:00
Hans Goudey
7fe9e87263 Fix: AttributeStorage skips reading attributes from empty domains
This check was meant to catch unknown failure cases but instead it
meant any attribute with an empty array (e.g. from a mesh with no
faces) would not be loaded. Instead the failure case should only be
when there is no data when the array is not meant to be empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/141096
2025-06-27 17:22:01 +02:00
Hans Goudey
f74e304b00 Attributes: Use AttributeStorage instead of CustomData for Instances
Part of #122398.

This commit moves the runtime instances type to use `AttributeStorage`.
Besides sharing some utility functions with point clouds, a resize
method is implemented.

Pull Request: https://projects.blender.org/blender/blender/pulls/140991
2025-06-26 17:03:56 +02:00
Hans Goudey
25e0957f8e Cleanup: Attributes: Resolve reference binding to null warning
The sharing info might be null if the array is null / empty.
2025-06-25 05:08:18 +02:00
Hans Goudey
4b4314483d Cleanup: Attributes: Properly use unitialized memory for copy
Add a "ForUninitialized" utility function and use copy construction
correctly. This doesn't make a difference yet because we only
have trivially constructible attribute types so far.
2025-06-25 05:08:18 +02:00
Hans Goudey
417f8dee40 Merge branch 'blender-v4.5-release' 2025-06-20 11:46:56 -04:00
Hans Goudey
5d184bd1d6 Fix: Potential memory leak reading AttributeStorage
For unsupported domains, storage types, or other issues with
reading the attribute data, the attribute name and data struct
could be leaked.
2025-06-20 11:40:42 -04:00
Hans Goudey
f61fbc468a Attributes: Remove AttributeStorage legacy compatibility option
Remove the use_attribute_storage_write experimental option and always
write in the new format, which is supported by 4.5. The new format is
only used at runtime by point clouds currently but there is no reason
for it to be an option at this point.

This is a second commit repeating 84212bae4b
after that was reverted. Issues that came up with Grease Pencil writing
have been resolved in the meantime.
2025-06-19 11:54:07 -04:00
Hans Goudey
77da71cd9d Merge branch 'blender-v4.5-release' 2025-06-19 11:45:07 -04:00
Hans Goudey
e82a051ade Fix: Issues in Grease Pencil blend file writing
After a recent commit, multiple drawings were always written using the
same address because we used the same stack memory in a loop. This
causes the blend file reading to not be able to distinguish between the
structs, meaning the file is corrupt. However, we already had the same
problem in some cases because of the inline buffer in `BlendWriteData`.
To resolve this, make all "temporary" data for writing live as long as
the writing is going on for the ID. This is somewhat inefficient since
it makes memory reuse impossible for this temporary data. In the future
we should use a technique like #127706 to address this.

For testing, I saved and loaded multiple production files with Grease
Pencil objects, with and without the "write with attribute storage"
option enabled. The fix still goes to 4.5 though, because the first
mentioned issue is present there, and the `CustomDataLayer` vector
address reuse is potentially a problem too.

Pull Request: https://projects.blender.org/blender/blender/pulls/140667
2025-06-19 17:44:28 +02:00
Falk David
0e737b23c5 Revert "Attributes: Remove AttributeStorage legacy compatibility option"
This reverts commit 84212bae4b.
2025-06-19 12:20:20 +02:00
Hans Goudey
84212bae4b Attributes: Remove AttributeStorage legacy compatibility option
Remove the `use_attribute_storage_write` experimental option and always
write in the new format, which is supported by 4.5. The new format is
only used at runtime by point clouds currently but there is no reason
for it to be an option at this point.

Pull Request: https://projects.blender.org/blender/blender/pulls/140284
2025-06-16 15:48:23 +02:00
Hans Goudey
fa03c53d4a Point Cloud: Use AttributeStorage instead of CustomData
This moves `PointCloud` to use the recently added `AttributeStorage`
at runtime. Mainly this involves implementing the higher level attribute
API on top, and implementing the RNA API as well. The attribute RNA type
is now backed by either CustomDataLayer or bke::Attribute. For now the
new code is specific to point clouds but next steps can reuse it for
Grease Pencil layer attributes, curves, and eventually meshes.

Point cloud attributes no longer have a name length limit.

Internally, the `AttributeStorage` API is extended with a few additions:
- The data structs have static constructors for convenience.
- A few functions give index-based access to attributes
- A "rename" function is added.

The `Attribute` RNA type now exposes a `storage_type` property.
For now the "single value" option is still unused at runtime, and
accessing the single value data isn't implemented yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/139165
2025-06-09 21:53:20 +02:00
Hans Goudey
2673224ee5 Attributes: Implement memory counter for AttributeStorage
Similar to CustomData_count_memory.
2025-05-20 10:21:23 -04:00
Hans Goudey
1f4faa906c Fix: AttributeStorage shared data reading broken
Issue in original commit. The data pointer argument is already a pointer
to the array pointer. No need for three star programming here.
2025-05-20 10:21:23 -04:00
Hans Goudey
bb8719030d Geometry: Initial replacement of CustomData with AttributeStorage
As described in #122398, implement read and write support for a new
attribute storage system. Currently this is only implemented to support
forward compatibility; the format used at runtime isn't changed at all.
That can be done one step at a time during the 4.5 and 5.0 development
cycles. A new experimental option for testing tells Blender to always
save with the new format.

The main benefit of the new structure is that it matches the attribute
system design, it allows for future attribute storage optimization, and
each attribute is an allocated struct, which will give pointer stability
for the Python API.

The next step is to connect the attribute API and the RNA API to
AttributeStorage for the simplest geometry type, point clouds.

Pull Request: https://projects.blender.org/blender/blender/pulls/133874
2025-05-09 17:27:07 +02:00