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-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-23Cleanup: use ELEM macroCampbell Barton
2022-09-22Refactor: const-correctness in bmesh conversion assertSergey Sharybin
2022-09-21Attributes: Allow calling "finish" on empty accessorsHans Goudey
This removes some boilerplate when creating many optional attributes.
2022-09-21Mesh: Avoid uninitialized values when converting BMesh to MeshHans Goudey
I didn't observe this issue in practice, but since the write_only version of the attribute API isn't meant to initialize trivial types, theoretically this could be a problem if the attribute is created halfway through converting the BMesh to a Mesh.
2022-09-21Fix race condition in memory freeing in edit mesh wrapper to meshSergey Sharybin
The BM_mesh_bm_to_me_for_eval() cal be called on the same BMesh from multiple threads. This adds a restriction that this function should not modify the BMesh. This started to be violated quite madly during the generic attributes changes. This change makes it so that the BMesh is not modified. The code looks less functional-like, but it solves the threading conflict. Ideally the BMesh will be const in the function but doing it now is a bit tricky due to the other APIs. The repro case for the crash is a bit tricky to reproduce from scratch. For those who has access to the Heis production repo /pro/lib/char/pack_bot/pack_bot.blend file can be used. Simply add loop to "GEO-leg.R" object and use bevel operator on the new loop. There is still some write of the element indices happening in this function. In theory those could be removed (together with the dirty index tag clear) but it leads to obscure crashes in area far away from this one. I've left it unchanged for now as on 64bit platforms those assignments should not be causing real issues. Differential Revision: https://developer.blender.org/D16023
2022-09-20Fix: BMesh to Mesh conversion does not create all necessary layersHans Goudey
Even meshes without any faces must have MPoly and MLoop layers, etc. This caused a crash in the extrude node when the edit mesh had no faces (see T101208). Issue with f94130c94b24ac6578.
2022-09-19Cleanup: use doxy sectionsCampbell Barton
2022-09-19Cleanup: spellingCampbell Barton
2022-09-17Cleanup: spelling, punctuation & repeated words in commentsCampbell Barton
2022-09-16Cleanup: spelling in commentsCampbell Barton
2022-09-10Cleanup: spelling in commentsCampbell Barton
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-06Fix T100854, T100856: Invalid shape keys when exiting edit modeHans Goudey
The `mvert` pointer was passed to `bm_to_mesh_shape` and was never reset to the beginning of the vertex array. Use spans instead to eliminate this error completely. This also has the benefit of letting the CustomData system handle allocation of mesh layers.
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-02Cleanup: Fix clang-tidy warnings: [modernize-use-nullptr]Clément Foucault
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-26Cleanup: Move bmesh_query_uv.c to C++Hans Goudey
Helpful for D14365.
2022-08-26Cleanup: reduce variable scopeCampbell Barton
2022-08-25Cleanup: remove redundant calculation in bmo_poke_execCampbell Barton
Mistake in [0] calculated the mean-face-center which wasn't used. 0: 23344bca6c5d1de330169a04ed8d21145fc60053
2022-08-19Cleanup: replace uint cd_loop_uv_offset with intChris Blackbourn
See https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Integer_Types
2022-08-17Cleanup: strip blank lines around comment blocksCampbell Barton
2022-08-12Cleanup: replace misleading use of 'true' for the bit-field sizeCampbell Barton
Also use a bit-field for SnapObjectParams.keep_on_same_target
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-08-09Cleanup: use static_cast in bmesh_mesh.ccCampbell Barton
2022-08-06Merge branch 'blender-v3.3-release'Howard Trickey
2022-08-06Fix T98025: Revert "Fix Bevel intersection continuity."Howard Trickey
This reverts commit 94866ef84f1907116409f8fe9c1f313405 A number of reports of bevel regressions came after the commit to fix bevel intersection continuity. Since the fix for some of those regressions is not obvious we will revert the continuity improvement and do it as part of the Bevel V2 project.
2022-07-28Cleanup: quiet GCC stringop-overflow warningCampbell Barton
2022-07-26Cleanup: Move mesh_tessellate.c to C++Hans Goudey
2022-07-23Cleanup: Typo with uv sphere normal creationChris Blackbourn
Regression from 087f27a52f78
2022-07-22BMesh: move bmesh_mesh to C++Campbell Barton
This allows parts of the code to be threaded more easily.
2022-07-22Fix T87779: Asymmetric vertex positions in circles primitivesCampbell Barton
Add sin_cos_from_fraction which ensures each quadrant has matching values when their sign is flipped.
2022-07-22UV: Edge support for select shortest path operatorSiddhartha Jejurkar
Calculating shortest path selection in UV edge mode was done using vertex path logic. Since the UV editor now supports proper edge selection [0], this approach can sometimes give incorrect results. This problem is now fixed by adding separate logic to calculate the shortest path in UV edge mode. Resolves T99344. [0]: ffaaa0bcbf477c30cf3665b9330bbbb767397169 Reviewed By: campbellbarton Ref D15511.
2022-07-14Cleanup: spelling in commentsCampbell Barton
Also remove duplicate comments in bmesh_log.h, caused by automated comment relocation in [0]. [0]: c4e041da23b9c45273fcd4874308c536b6a315d1
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: spelling in comments, minor formatting tweaksCampbell Barton
2022-06-01Cleanup: spelling in comments, use doxy sectionsCampbell Barton
2022-06-01Cleanup: use 'e' prefix for enum typesCampbell Barton
- CustomDataType -> eCustomDataType - CustomDataMask -> eCustomDataMask - AttributeDomain -> eAttrDomain - NamedAttributeUsage -> eNamedAttrUsage
2022-05-30Cleanup: Remove outdated commentHans Goudey
2022-05-17Cleanup: formatCampbell Barton
2022-05-15Merge branch 'blender-v3.2-release'Joseph Eagar
2022-05-15Fix T80174: Dyntopo not initializing face set values correctlyJoseph Eagar
BMLog was zeroing face sets when creating new faces, which is not valid. They're now set to 1.
2022-05-13Cleanup: spelling in comments, capitalize tagsCampbell Barton
Also add missing task-ID reference & remove colon after \note as it doesn't render properly in doxygen.
2022-05-05Docs: add doc-string for BMFace.mat_nr struct memberCampbell Barton