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-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: spellingCampbell Barton
2022-09-16Cleanup: 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-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-07-26Cleanup: Move mesh_tessellate.c to C++Hans Goudey
2022-07-22BMesh: move bmesh_mesh to C++Campbell Barton
This allows parts of the code to be threaded more easily.
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-04-28Fix: Incorrect conversion from C bitfield syntaxHans Goudey
Recent cleanups 9a8669ac81b99b2 and 1c790555a02bfc3 incorrectly interpereted the bitfield width syntax as a default value. Also resolve two other compilation warnings.
2022-04-05Refactor: Unify vertex and sculpt colors into newJoseph Eagar
color attribute system. This commit removes sculpt colors from experimental status and unifies it with vertex colors. It introduces the concept of "color attributes", which are any attributes that represents colors. Color attributes can be represented with byte or floating-point numbers and can be stored in either vertices or face corners. Color attributes share a common namespace (so you can no longer have a floating-point sculpt color attribute and a byte vertex color attribute with the same name). Note: this commit does not include vertex paint mode, which is a separate patch, see: https://developer.blender.org/D14179 Differential Revision: https://developer.blender.org/D12587 Ref D12587
2022-03-28Cleanup: use "num" as a suffix in: source/blender/modifiersCampbell Barton
Also rename DNA struct members.
2022-03-25Cleanup: use count or num instead of nbrCampbell Barton
Follow conventions from T85728.
2022-03-23Cleanup: move documentation to headers, other minor correctionsCampbell Barton
2022-03-22Cleanup: Use bool for BMesh creation paramsHans Goudey
These boolean options are passed as uint, but they would be easier to understand if using bool. Differential Revision: https://developer.blender.org/D14405
2022-03-22Fix T96308: Mesh to BMesh conversion doesn't calculate vertex normalsHans Goudey
Currently there is a "calc_face_normal" argument to mesh to bmesh conversion, but vertex normals had always implicitly inherited whatever dirty state the mesh input's vertex normals were in. Probably they were most often assumed to not be dirty, but this was never really correct in the general case. Ever since the refactor to move vertex normals out of mesh vertices, cfa53e0fbeed7178c7, the copying logic has been explicit: copy the normals when they are not dirty. But it turns out that more control is needed, and sometimes normals should be calculated for the resulting BMesh. This commit adds an option to the conversion to calculate vertex normals, true by default. In almost all places except the decimate and edge split modifiers, I just copied the value of the "calc_face_normals" argument. Differential Revision: https://developer.blender.org/D14406
2022-03-07Cleanup: fix various typosBrecht Van Lommel
Contributed by luzpaz. Differential Revision: https://developer.blender.org/D14203
2022-03-07Merge branch 'blender-v3.1-release'Campbell Barton
2022-03-07Fix T96205: Active shape key gets lost upon edit mode undoCampbell Barton
Regression in d961adb866cc2d7a95e4c6a7f06c49e346ec1abe, it's important that for the Mesh used for undo storage matches the shape-key instead of using the coordinates of the Basis key. Prior to bfdbc78466ac14d45f353db9aa39cb21bb962701 a different method of restoring the basis shape-key coordinates was used (restoring from the input `Mesh.mvert` array). When undo wrote the edit-mesh into the mesh this was always NULL so the basis shape keys coordinates were never used. Now a parameter has been added so undo can use the active shape for the meshes vertex coordinates. Reviewed By: sergey Maniphest Tasks: T96205 Ref D14258
2022-03-03Merge branch 'blender-v3.1-release'Campbell Barton
2022-03-03Fix T96135: Mesh coordinates are set to the last edited shape-keyCampbell Barton
When exiting edit-mode set the vertex coordinates to the basis-shape when editing non-basis keys. Regression in bfdbc78466ac14d45f353db9aa39cb21bb962701. Reviewed By: sergey Ref D14234
2022-03-02UI: Comments Misspellings of Vertex/VerticesNikhil Shringarpurey
Correct misspellings in code comments of "vertex" and "vertices". See D13932 for more details. Differential Revision: https://developer.blender.org/D13932 Reviewed by Harley Acheson
2022-02-24Merge branch 'blender-v3.1-release'Hans Goudey
2022-02-24Fix: Crash switching between sculpt and edit modeHans Goudey
Also fix a couple other places where normals layers weren't properly tagged dirty or reallocated when the mesh changes. Caused by cfa53e0fbeed7178. When the size of a mesh changes, the normal layers need to be reallocated. There were a couple of places that cleared other runtime data with `BKE_mesh_runtime_clear_geometry` but didn't deal with normals properly. Clearing the runtime "geometry" is different from clearing the normals, because sometimes the size of the normal layers doesn't have to change, in which case simply tagging them dirty is fine.
2022-02-24Merge branch 'blender-v3.1-release'Jacques Lucke