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-05Fix: Broken debug build after recent cleanup commitHans Goudey
5060f26f500997232aa1033c3d5
2022-11-05Cleanup: Move function to legacy mesh conversion fileHans Goudey
2022-11-05Cleanup: Move legacy mesh conversions to proper fileHans Goudey
2022-09-27Fix: Assert in legacy mesh conversionHans Goudey
When setting the old face set custom data type, do it in the "layers to write" vector instead of the mesh's poly custom data layers, which weren't "prepared" yet. Otherwise this could make the mesh's custom data typemap invalid.
2022-09-25Cleanup: replace C-style casts with functional casts for numeric typesCampbell Barton
2022-09-24Fix: Invalid CustomData type map created for legacy mesh conversionHans Goudey
Caused by 060a5341419412fd7996cf99.
2022-09-23Mesh: Move selection flags to generic attributesHans Goudey
Using the attribute name semantics from T97452, this patch moves the selection status of mesh elements from the `SELECT` of vertices, and edges, and the `ME_FACE_SEL` of faces to generic boolean attribute Storing this data as generic attributes can significantly simplify and improve code, as described in T95965. The attributes are called `.select_vert`, `.select_edge`, and `.select_poly`. The `.` prefix means they are "UI attributes",so they still contain original data edited by users, but they aren't meant to be accessed procedurally by the user in arbitrary situations. They are also be hidden in the spreadsheet and the attribute list. Until 4.0, the attributes are still written to and read from the mesh in the old way, so neither forward nor backward compatibility are affected. This means memory requirements will be increased by one byte per element when selection is used. When the flags are removed completely, requirements will decrease. Further notes: * The `MVert` flag is empty at runtime now, so it can be ignored. * `BMesh` is unchanged, otherwise the change would be much larger. * Many tests have slightly different results, since the selection attribute uses more generic propagation. Previously you couldn't really rely on edit mode selections being propagated procedurally. Now it mostly works as expected. Similar to 2480b55f216c Ref T95965 Differential Revision: https://developer.blender.org/D15795
2022-09-23Mesh: Move edge crease out of MEdgeHans Goudey
This is very similar to D14077. There are two differences though. First is that vertex creases are already stored in a separate layer, and second is that we can now completely remove use of `Mesh.cd_flag`, since that information is now inherent to whether the layers exist. There are two functional differences here: * Operators are used to add and remove layers instead of a property. * The "crease" attribute can be created and removed by geometry nodes. The second change should make various geometry nodes slightly faster, since the "crease" attribute was always processed before. Creases are now interpolated generically in the CustomData API too, which should help maintain the values across edits better. Meshes get an `edge_creases` RNA property like the existing vertex property, to provide more efficient access to the data in Cycles. One test failure is expected, where different rounding between float the old char storage means that 5 additional points are scattered in a geometry nodes test. Differential Revision: https://developer.blender.org/D15927
2022-09-23Mesh: Move sculpt face sets to a generic attributeHans Goudey
Similar to the other refactors from T95965, this commit moves sculpt face sets to use a generic integer attribute named `".sculpt_face_set"`. This makes face sets accessible in the Python API. The attribute is not visible in the attributes list or the spreadsheet because it is meant for internal use, though that could be an option in the future along with other similar attributes. Currently the change is small, but in the future this could simplify code by allowing use of more generic attribute APIs. Differential Revision: https://developer.blender.org/D16045
2022-09-13Fix: Resolve deprecation warning when copying polygon structHans Goudey
`MPoly` is used and copied in many places. To avoid the need to use a special function for copying MPoly, or the need to add a copy constructor, just rename the `mat_nr` field to include "legacy" in the name. This keeps the original purpose of notifying developers that the field shouldn't be used without any further complexity. Apply the same fix to `bweight`. Differential Revision: https://developer.blender.org/D15841
2022-09-09Mesh: Move bevel weight out of MVert and MEdgeHans Goudey
As described in T95966, the goal is to move to a "struct of arrays" approach rather than gathering an arbitrary set of data in hard-coded structs. This has performance benefits, but also code complexity benefits (this patch removes plenty of code, though the boilerplate for the new operators outweighs that here). To mirror the internal change, the options for storing mesh bevel weights are converted into operators that add or remove the layer, like for some other layers. The most complex change is to the solidify modifier, where bevel weights had special handling. Other than that, most changes are removing clearing of the weights, boilerplate for the add/remove operators, and removing the manual transfer of bevel weights in bmesh - mesh conversion. Eventually bevel weights can become a fully generic attribute, but for now this patch aims to avoid most functional changes. Bevel weights are still written and read from the mesh in the old way, so neither forward nor backward compatibility are affected. As described in T95965, writing in the old format will be done until 4.0. Differential Revision: https://developer.blender.org/D14077
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: Tweak naming for recently added mesh accessorsHans Goudey
Use `verts` instead of `vertices` and `polys` instead of `polygons` in the API added in 05952aa94d33eeb50. This aligns better with existing naming where the shorter names are much more common.
2022-09-05Mesh: Remove redundant custom data pointersHans Goudey
For copy-on-write, we want to share attribute arrays between meshes where possible. Mutable pointers like `Mesh.mvert` make that difficult by making ownership vague. They also make code more complex by adding redundancy. The simplest solution is just removing them and retrieving layers from `CustomData` as needed. Similar changes have already been applied to curves and point clouds (e9f82d3dc7ee, 410a6efb747f). Removing use of the pointers generally makes code more obvious and more reusable. Mesh data is now accessed with a C++ API (`Mesh::edges()` or `Mesh::edges_for_write()`), and a C API (`BKE_mesh_edges(mesh)`). The CoW changes this commit makes possible are described in T95845 and T95842, and started in D14139 and D14140. The change also simplifies the ongoing mesh struct-of-array refactors from T95965. **RNA/Python Access Performance** Theoretically, accessing mesh elements with the RNA API may become slower, since the layer needs to be found on every random access. However, overhead is already high enough that this doesn't make a noticible differenc, and performance is actually improved in some cases. Random access can be up to 10% faster, but other situations might be a bit slower. Generally using `foreach_get/set` are the best way to improve performance. See the differential revision for more discussion about Python performance. Cycles has been updated to use raw pointers and the internal Blender mesh types, mostly because there is no sense in having this overhead when it's already compiled with Blender. In my tests this roughly halves the Cycles mesh creation time (0.19s to 0.10s for a 1 million face grid). Differential Revision: https://developer.blender.org/D15488
2022-09-01Fix: Use of deprecated field in legacy MFace conversionHans Goudey
The material indices have been moved out of MPoly since f1c0249f34c4171. That conversion happens in file reading code currently, so the material indices have to be accessed the new way everywhere.
2022-08-31Mesh: Move material indices to a generic attributeHans Goudey
This patch moves material indices from the mesh `MPoly` struct to a generic integer attribute. The builtin material index was already exposed in geometry nodes, but this makes it a "proper" attribute accessible with Python and visible in the "Attributes" panel. The goals of the refactor are code simplification and memory and performance improvements, mainly because the attribute doesn't have to be stored and processed if there are no materials. However, until 4.0, material indices will still be read and written in the old format, meaning there may be a temporary increase in memory usage. Further notes: * Completely removing the `MPoly.mat_nr` after 4.0 may require changes to DNA or introducing a new `MPoly` type. * Geometry nodes regression tests didn't look at material indices, so the change reveals a bug in the realize instances node that I fixed. * Access to material indices from the RNA `MeshPolygon` type is slower with this patch. The `material_index` attribute can be used instead. * Cycles is changed to read from the attribute instead. * BMesh isn't changed in this patch. Theoretically it could be though, to save 2 bytes per face when less than two materials are used. * Eventually we could use a 16 bit integer attribute type instead. Ref T95967 Differential Revision: https://developer.blender.org/D15675
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-12Cleanup: use short names for verts & polys as they're unambiguousCampbell Barton
Follow conventions used in most existing code.
2022-08-12Cleanup: replace term face with polyCampbell Barton
Be consistent with naming to avoid mixing MPoly/MFace.
2022-08-11Mesh: Move hide flags to generic attributesHans Goudey
This commit moves the hide status of mesh vertices, edges, and faces from the `ME_FLAG` to optional generic boolean attributes. Storing this data as generic attributes can significantly simplify and improve code, as described in T95965. The attributes are called `.hide_vert`, `.hide_edge`, and `.hide_poly`, using the attribute name semantics discussed in T97452. The `.` prefix means they are "UI attributes", so they still contain original data edited by users, but they aren't meant to be accessed procedurally by the user in arbitrary situations. They are also be hidden in the spreadsheet and the attribute list by default, Until 4.0, the attributes are still written to and read from the mesh in the old way, so neither forward nor backward compatibility are affected. This means memory requirements will be increased by one byte per element when the hide status is used. When the flags are removed completely, requirements will decrease when hiding is unused. Further notes: * Some code can be further simplified to skip some processing when the hide attributes don't exist. * The data is still stored in flags for `BMesh`, necessitating some complexity in the conversion to and from `Mesh`. * Access to the "hide" property of mesh elements in RNA is slower. The separate boolean arrays should be used where possible. Ref T95965 Differential Revision: https://developer.blender.org/D14685
2022-07-08Cleanup: Move mesh legacy conversion to a separate fileHans Goudey
It's helpful to make the separation of legacy data formats explicit, because it declutters actively changed code and makes it clear which areas do not follow Blender's current design. In this case I separated the `MFace`/"tessface" conversion code into a separate blenkernel .cc file and header. This also makes refactoring to remove these functions simpler because they're easier to find. In the future, conversions to the `MLoopUV` type and `MVert` can be implemented here for the same reasons (see T95965). Differential Revision: https://developer.blender.org/D15396