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-11Merge branch 'master' into refactor-mesh-position-genericrefactor-mesh-position-genericHans Goudey
2022-11-05Cleanup: Move legacy mesh conversions to proper fileHans Goudey
2022-10-12Cleanup: Use const vertex pointer argumentHans Goudey
2022-09-28Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-09-27Cleanup: Use signed integers for mesh vertex indicesHans Goudey
2022-09-23Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-09-23Fix: Crash with empty vertex group in mask modifierHans Goudey
The C++ vertex group data accessor returned a span with null data that wasn't empty. Instead of adding a null check as well as the size check, just return an empty span when there is no vertex group data.
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-15Fix possible to remove mesh position attributeHans Goudey
2022-09-12Start converting mesh positions to a generic attributeHans Goudey
2022-09-11Merge branch 'master' into refactor-mesh-selection-genericHans Goudey
2022-09-09Cleanup: Simplify BKE_mesh_nomain_to_meshHans Goudey
- Remove "take ownership" argument which was confusing and always true - The argument made ownership very confusing - Better to avoid boolean arguments that switch a function's purpose - Remove "mask" argument which was basically wrong and not used properly - "EVERYTHING" was used because developers are wary of removing data - Instead use `CD_MASK_MESH` for its purpose of original mesh data - Remove use of shallow copied temporary mesh, which is unnecessary now - Split shape key processing into separate functions and use C++ types - Copy fields explicitly rather than using memcpy for the whole struct - Use higher level functions and avoid redundant code - The whole idea is pretty simple and can be built from standard logic - Adjust `CustomData` logic to be consistent with "assign" expectations - Clear the layer data from the source, and moves the anonymous ID Differential Revision: https://developer.blender.org/D15857
2022-09-08Merge branch 'master' into refactor-mesh-selection-genericHans Goudey
2022-09-08Cleanup: prefer terms verts/polys over vertices/polygonsCampbell Barton
Follows existing naming for the most part, also use "num" as a suffix in some instances (following our naming conventions).
2022-09-07Merge branch 'master' into refactor-mesh-selection-genericHans Goudey
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-05Merge branch 'master' into refactor-mesh-selection-genericHans Goudey
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-08-31Merge branch 'master' into refactor-mesh-selection-genericHans Goudey
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-25Merge branch 'master' into refactor-mesh-selection-genericHans Goudey
2022-08-17Metaball: Evaluate metaball objects as mesh componentsHans Goudey
With the ultimate goal of simplifying drawing and evaluation, this patch makes the following changes and removes code: - Use `Mesh` instead of `DispList` for evaluated basis metaballs. - Remove all `DispList` drawing code, which is now unused. - Simplify code that converts evaluated metaballs to meshes. - Store the evaluated mesh in the evaluated geometry set. This has the following indirect benefits: - Evaluated meshes from metaball objects can be used in geometry nodes. - Renderers can ignore evaluated metaball objects completely - Cycles rendering no longer has to convert to mesh from `DispList`. - We get closer to removing `DispList` completely. - Optimizations to mesh rendering will also apply to metaball objects. The vertex normals on the evaluated mesh are technically invalid; the regular calculation wouldn't reproduce them. Metaball objects don't support modifiers though, so it shouldn't be a problem. Eventually we can support per-vertex custom normals (T93551). Differential Revision: https://developer.blender.org/D14593
2022-08-14Mesh: Move selection status from flags to generic attributes (WIP)Hans Goudey
2022-08-12Cleanup: repeated words in commentsCampbell Barton
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-26Cleanup: Move mesh_tessellate.c to C++Hans Goudey
2022-07-12Fix threading crash due to conflict in mesh wrapper typeSergey Sharybin
A mesh wrapper might be being accessed for read-only from one thread while another thread converts the wrapper type to something else. The proposes solution is to defer assignment of the mesh wrapper type until the wrapper is fully converted. The good thing about this approach is that it does not introduce extra synchronization (and, potentially, evaluation pipeline stalls). The downside is that it might not work with all possible wrapper types in the future. If a wrapper type which does not clear data separation is ever added in the future we will re-consider the threading safety then. Unfortunately, some changes outside of the mesh wrapper file are to be made to allow "incremental" construction of the mesh prior changing its wrapper type. Unfortunately, there is no simplified file which demonstrates the issue. It was investigated using Heist production file checked at the revision 1228: `pro/lib/char/einar/einar.shading.blend`. The repro case is simple: tab into edit mode, possibly few times. The gist is that there several surface deform and shrinkwrap modifiers which uses the same target. While one of them is building BVH tree (which changes wrapper type) the other one accesses it for read-only via `BKE_mesh_wrapper_vert_coords_copy_with_mat4()`. Differential Revision: https://developer.blender.org/D15424
2022-07-11Cleanup: spelling in commentsCampbell Barton
2022-07-08Curves: support deforming curves on surfaceJacques Lucke
Curves that are attached to a surface can now follow the surface when it is modified using shape keys or modifiers (but not when the original surface is deformed in edit or sculpt mode). The surface is allowed to be changed in any way that keeps uv maps intact. So deformation is allowed, but also some topology changes like subdivision. The following features are added: * A new `Deform Curves on Surface` node, which deforms curves with attachment information based on the surface object and uv map set in the properties panel. * A new `Add Rest Position` checkbox in the shape keys panel. When checked, a new `rest_position` vector attribute is added to the mesh before shape keys and modifiers are applied. This is necessary to support proper deformation of the curves, but can also be used for other purposes. * The `Add > Curve > Empty Hair` operator now sets up a simple geometry nodes setup that deforms the hair. It also makes sure that the rest position attribute is added to the surface. * A new `Object (Attach Curves to Surface)` operator in the `Set Parent To` (ctrl+P) menu, which attaches existing curves to the surface and sets the surface object as parent. Limitations: * Sculpting the procedurally deformed curves will be implemented separately. * The `Deform Curves on Surface` node is not generic and can only be used for one specific purpose currently. We plan to generalize this more in the future by adding support by exposing more inputs and/or by turning it into a node group. Differential Revision: https://developer.blender.org/D14864
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
2022-06-23Cleanup: Make function staticHans Goudey
2022-06-23Mesh: Add an explicit "positions changed" functionHans Goudey
We store various lazily calculated caches on meshes, some of which depend on the vertex positions staying the same. The current API to invalidate these caches is a bit confusing. With an explicit set of functions modeled after the functions in `BKE_node_tree_update.h`, it becomes clear which function to call. This may become more important if more lazy caches are added in the future. Differential Revision: https://developer.blender.org/D14760
2022-05-15Cleanup: Simplify loop syntax, make function staticHans Goudey
Use range based for loops, spans, references, and slice. Change split from D14685, in order to simplify refactor to the mesh hide masks.
2022-05-11Mesh: Add Auto Smooth option to Shade Smooth operatorPablo Vazquez
Add a property to the **Shade Smooth** operator to quickly enable the Mesh `use_auto_smooth` option. The `Angle` property is exposed in the **Adjust Last Operation** panel to make it easy to tweak on multiple objects without having to go to the Properties editor. The operator is exposed in the `Object` menu and `Object Context Menu`. === Demo === {F13066173, size=full} Regarding the implementation, there are multiple ways to go about this (like making a whole new operator altogether), but I think a property is the cleanest/simplest. I imagine there are simpler ways to achieve this without duplicating the `use_auto_smooth` property in the operator itself (getting it from the Mesh props?), but I couldn't find other operators doing something similar. Reviewed By: #modeling, mont29 Differential Revision: https://developer.blender.org/D14894
2022-05-05Workaround T81065: Merge UV's when applying modifiersCampbell Barton
Support merging UV's that share the same vertex and are very close when applying modifiers. This is needed to prevent UV's becoming "detached" which can happen when applying the subdivision surface modifier. This regression was caused by [0] which removed selection threshold for nearby coordinates. While restoring the UV selection threshold could be done - some selection operations that walk around connected UV fans wouldn't behave in a deterministic way (such as select shortest path). There are also other cases where UV's may be compared without a threshold such as tangent calculation and exporters which have their own logic to handling UV's. Also resolves T86896, T89903. [0]: b88dd3b8e7b9c02ae08d4679bb427963c5d21250 Reviewed By: sergey Ref D14841
2022-04-26Cleanup: Move anonymous attribute removal to geometry componentHans Goudey
Implementing removal of anonymous attributes with `GeometryComponent` instead of `Mesh` makes it more reusable for other types like curves.
2022-04-04Cleanup: ensure space after file named in headersCampbell Barton
Add blank lines after file references to avoid them being interpreted as doc-strings the following declarations.
2022-03-28Cleanup: use "num" as a suffix in: source/blender/modifiersCampbell Barton
Also rename DNA struct members.
2022-03-22Fix T96294: Crash and error with shape key normal calculationHans Goudey
A mistake in the mesh normal refactor caused the wrong mesh to be used when calculating normals with a shape key's deformation. This commit fixes the normal calculation by using the correct mesh, with just adjusted vertex positions, and calculating the results directly into the result arrays when possible. This completely avoids the need to make a local copy of the mesh, which makes sense, since the only thing that changes is the vertex positions. Differential Revision: https://developer.blender.org/D14317
2022-02-28Cleanup: Move mesh_validate.c to C++Hans Goudey
This patch was tested on the build bots on all platforms.
2022-02-26Merge branch 'blender-v3.1-release'Hans Goudey
2022-02-26Fix: Failing OBJ export tests due to mesh normals commitHans Goudey
In some cases, the normal edit modifier calculated the normals on one mesh with the "ensure" functions, then copied the mesh and retrieved the layers "for write" on the copy. Since 59343ee1627f4c369e23, normal layers are never copied, and normals are allocated with malloc instead of calloc, so the mutable memory was uninitialized. Fix by calculating normals on the correct mesh, and also add a warning to the "for write" functions in the header.
2022-02-22Merge branch 'blender-v3.1-release'Hans Goudey
2022-02-22Fix T95839: Data race when lazily creating mesh normal layersHans Goudey
Currently, when normals are calculated for a const mesh, a custom data layer might be added if it doesn't already exist. Adding a custom data layer to a mesh is not thread-safe, so this can be a problem in some situations. This commit moves derived mesh normals for polygons and vertices out of `CustomData` to `Mesh_Runtime`. Most of the hard work for this was already done by rBcfa53e0fbeed7178. Some changes to logic elsewhere are necessary/helpful: - No need to call both `BKE_mesh_runtime_clear_cache` and `BKE_mesh_normals_tag_dirty`, since the former also does the latter. - Cleanup/simplify mesh conversion and copying since normals are handled with other runtime data. Storing these normals like other runtime data clarifies their status as derived data, meaning custom data moves more towards storing original/editable data. This means normals won't automatically benefit from the planned copy-on-write refactor (T95845), so it will have to be added manually like for the other runtime data. Differential Revision: https://developer.blender.org/D14154
2022-02-19Merge branch 'blender-v3.1-release'Hans Goudey
2022-02-18Cleanup: Remove unused argument to mesh tessellationHans Goudey
This removes manual handling of normals that was hard-coded to false in the one place the function was called. This change will help to make a fix to T95839 simpler.
2022-02-18Mesh: Avoid creating incorrect original index layersHans Goudey
Currently, whenever any BMesh is converted to a Mesh (except for edit mode switching), original index (`CD_ORIGINDEX`) layers are added. This is incorrect, because many operations just convert some Mesh into a BMesh and then back, but they shouldn't make any assumption about where their input mesh came from. It might even come from a primitive in geometry nodes, where there are no original indices at all. Conceptually, mesh original indices should be filled by the modifier stack when first creating the evaluated mesh. So that's where they're moved in this patch. A separate function now fills the indices with their default (0,1,2,3...) values. The way the mesh wrapper system defers the BMesh to Mesh conversion makes this a bit less obvious though. The old behavior is incorrect, but it's also slower, because three arrays the size of the mesh's vertices, edges, and faces had to be allocated and filled during the BMesh to Mesh conversion, which just ends up putting more pressure on the cache. In the many cases where original indices aren't used, I measured an **8% speedup** for the conversion (from 76.5ms to 70.7ms). Generally there is an assumption that BMesh is "original" and Mesh is "evaluated". After this patch, that assumption isn't quite as strong, but it still exists for two reasons. First, original indices are added whenever converting a BMesh "wrapper" to a Mesh. Second, original indices are not added to the BMesh at the beginning of evaluation, which assumes that every BMesh in the viewport is original and doesn't need the mapping. Differential Revision: https://developer.blender.org/D14018
2022-02-11File headers: SPDX License migrationCampbell Barton
Use a shorter/simpler license convention, stops the header taking so much space. Follow the SPDX license specification: https://spdx.org/licenses - C/C++/objc/objc++ - Python - Shell Scripts - CMake, GNUmakefile While most of the source tree has been included - `./extern/` was left out. - `./intern/cycles` & `./intern/atomic` are also excluded because they use different header conventions. doc/license/SPDX-license-identifiers.txt has been added to list SPDX all used identifiers. See P2788 for the script that automated these edits. Reviewed By: brecht, mont29, sergey Ref D14069
2022-02-10Fix T95613: remove anonymous attributes when converting objectJacques Lucke
This is the same behavior as when applying a geometry nodes modifier that adds anonymous attributes.
2022-01-25Fix depsgraphs sharing IDs via evaluated edit meshSergey Sharybin
The evaluated mesh is a result of evaluated modifiers, and referencing other evaluated IDs such as materials. It can not be stored in the EditMesh structure which is intended to be re-used by many areas. Such sharing was causing ownership errors causing bugs like T93855: Cycles crash with edit mode and simultaneous viewport and final render The proposed solution is to store the evaluated edit mesh and its cage in the object's runtime field. The motivation goes as following: - It allows to avoid ownership problems like the ones in the linked report. - Object level is chosen over mesh level is because the evaluated mesh is affected by modifiers, which are on the object level. This patch allows to have modifier stack of an object which shares mesh with an object which is in edit mode to be properly taken into account (before the change the modifier stack from the active object will be used for all objects which share the mesh). There is a change in the way how copy-on-write is handled in the edit mode to allow proper state update when changing active scene (or having two windows with different scenes). Previously, the copt-on-write would have been ignored by skipping tagging CoW component. Now it is ignored from within the CoW operation callback. This allows to update edit pointers for objects which are not from the current depsgraph and where the edit_mesh was never assigned in the case when the depsgraph was evaluated prior the active depsgraph. There is no user level changes changes expected with the CoW handling changes: should not affect on neither performance, nor memory consumption. Tested scenarios: - Various modifiers configurations of objects sharing mesh and be part of the same scene. - Steps from the reports: T93855, T82952, T77359 This also fixes T76609, T72733 and perhaps other reports. Differential Revision: https://developer.blender.org/D13824