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-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
2022-01-19BMesh: add mesh debug information printingCampbell Barton
- Add BM_mesh_debug_print & BM_mesh_debug_info. - Report flags in Mesh.cd_flag in BKE_mesh_debug_print - Move custom data printing into customdata.cc (noted as a TODO). Note that the term "runtime" has been removed from `BKE_mesh_runtime_debug_print` since these are useful for debugging any kind of mesh data.
2022-01-14Cleanup: spelling in comments, C++ style comments for disabled codeCampbell Barton
Also ensure space at end of comment.
2022-01-13Refactor: Move normals out of MVert, lazy calculationHans Goudey
As described in T91186, this commit moves mesh vertex normals into a contiguous array of float vectors in a custom data layer, how face normals are currently stored. The main interface is documented in `BKE_mesh.h`. Vertex and face normals are now calculated on-demand and cached, retrieved with an "ensure" function. Since the logical state of a mesh is now "has normals when necessary", they can be retrieved from a `const` mesh. The goal is to use on-demand calculation for all derived data, but leave room for eager calculation for performance purposes (modifier evaluation is threaded, but viewport data generation is not). **Benefits** This moves us closer to a SoA approach rather than the current AoS paradigm. Accessing a contiguous `float3` is much more efficient than retrieving data from a larger struct. The memory requirements for accessing only normals or vertex locations are smaller, and at the cost of more memory usage for just normals, they now don't have to be converted between float and short, which also simplifies code In the future, the remaining items can be removed from `MVert`, leaving only `float3`, which has similar benefits (see T93602). Removing the combination of derived and original data makes it conceptually simpler to only calculate normals when necessary. This is especially important now that we have more opportunities for temporary meshes in geometry nodes. **Performance** In addition to the theoretical future performance improvements by making `MVert == float3`, I've done some basic performance testing on this patch directly. The data is fairly rough, but it gives an idea about where things stand generally. - Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms), showing that accessing just `MVert` is now more efficient. - Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight change that at least shows there is no regression. - Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small but observable speedup. - Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms), shows that using normals in geometry nodes is faster. - Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms), shows that calculating normals is slightly faster now. - File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB), Normals are not saved in files, which can help with large meshes. As for memory usage, it may be slightly more in some cases, but I didn't observe any difference in the production files I tested. **Tests** Some modifiers and cycles test results need to be updated with this commit, for two reasons: - The subdivision surface modifier is not responsible for calculating normals anymore. In master, the modifier creates different normals than the result of the `Mesh` normal calculation, so this is a bug fix. - There are small differences in the results of some modifiers that use normals because they are not converted to and from `short` anymore. **Future improvements** - Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier already retrieves normals if they are needed anyway. - Copy normals as part of a better CoW system for attributes. - Make more areas use lazy instead of eager normal calculation. - Remove `BKE_mesh_normals_tag_dirty` in more places since that is now the default state of a new mesh. - Possibly apply a similar change to derived face corner normals. Differential Revision: https://developer.blender.org/D12770
2022-01-07Cleanup: Use forward declaration of struct in headerHans Goudey
This meant that BKE_mesh.h couldn't be used without the DNA headers first.
2022-01-07Cleanup: remove redundant const qualifiers for POD typesCampbell Barton
MSVC used to warn about const mismatch for arguments passed by value. Remove these as newer versions of MSVC no longer show this warning.
2021-12-29Cleanup: Remove unused DerivedMesh functionsHans Goudey
2021-12-10Cleanup/Docs: Add comments to Mesh header, rearrange fieldsHans Goudey
Most of the fields in Mesh had no comments, or outdated misleading comments. For example, "BMESH ONLY" referred to the BMesh project, not the data structure. Given how much these structs are used, it should save a lot of time to have proper comments. I also rearranged the fields in mesh to have a more logical order. Now the most important fields come first. In the process I was able to remove 19 bytes of unnecessary padding (31->12). I just had to change a `short` flag to `char`. Differential Revision: https://developer.blender.org/D13454
2021-12-07Cleanup: move public doc-strings into headers for 'blenkernel'Campbell Barton
- Added space below non doc-string comments to make it clear these aren't comments for the symbols directly below them. - Use doxy sections for some headers. - Minor improvements to doc-strings. Ref T92709
2021-12-01Fix T92561: unstable particle distribution with Alembic filesKévin Dietrich
When enabling or disabling a Mesh Sequence Cache modifier of an Object with a hair particle system, the hair would switch positions. This is caused because original coordinates in Blender are expected to be normalized, and toggling the modifier would cause the usage of different orco layers: one that is normalized, and the other which isn't. This bug exposes a few related issues: - if the Alembic file did not have orco data, `MOD_deform_mesh_eval_get`, used by the particle system modifier, would add an orco layer without normalization - `MOD_deform_mesh_eval_get` would also ignore the presence of an orco layer (e.g. one that could have been read from Alembic) - if the Alembic file did have orco data, the data would be read unnormalized To fix those various issues, original coordinates are normalized when read from Alembic and unnormalized when written to Alembic; and a new utility function `BKE_mesh_orco_ensure` is added to add a normalized orco layer if none exists on the mesh already, this function derives from the code used in the particle system. Reviewed By: brecht Maniphest Tasks: T92561 Differential Revision: https://developer.blender.org/D13306
2021-11-09Fix T91923: Save/Apply as Shape Key ignores shape keysCampbell Barton
Support virtual modifiers when using applying the modifier as a shape.
2021-10-03Cleanup: spelling in commentsCampbell Barton
2021-09-17Cleanup: Pass const mesh argumentHans Goudey
Also remove unnecessary parantheses.
2021-08-24Cleanup: Make function static, remove unused argumentsHans Goudey
2021-08-20Cleanup: rename BKE_mesh_free_data -> BKE_mesh_free_data_for_undoCampbell Barton
This function only makes sense for undo which doesn't initialize the meshes ID. Otherwise BKE_id_free should be used.
2021-08-20Cleanup: rename BKE_mesh_free -> BKE_mesh_free_dataCampbell Barton
It wasn't obvious this didn't free the memory of the mesh it's self leading to memory leaks.
2021-08-13Cleanup: remove unused BKE_mesh_calc_normals_mapping functionsCampbell Barton
This supported calculating normals for MPoly array which was copied to an MFace aligned array. Remove the functions entirely since MFace use is being phased out and these function isn't used anywhere.
2021-08-13Cleanup: split BKE_mesh_calc_normals_poly function in twoCampbell Barton
Remove the 'only_face_normals' argument. - BKE_mesh_calc_normals_poly for polygon normals. - BKE_mesh_calc_normals_poly_and_vertex for poly and vertex normals. Order arguments logically: - Pair array and length arguments. - Position normal array arguments (to be filled) last.
2021-08-02Mesh: Tag normals dirty instead of calculatingHans Goudey
Because mesh vertex and face normals are just derived data, they can be calculated lazily instead of eagerly. Often normal calculation is a relatively expensive task, and the calculation is often redundant if the mesh is deformed afterwards anyway. Instead, normals should be calculated only when they are needed. This commit moves in that direction by adding a new function to tag a mesh's normals dirty and replacing normal calculation with it in some places. Differential Revision: https://developer.blender.org/D12107
2021-07-23Edit Mesh: multi-thread auto-smooth & custom normal calculationsCampbell Barton
Supported multi-threading for bm_mesh_loops_calc_normals. This is done by operating on vertex-loops instead of face-loops. Single threaded operation still loops over faces since iterating over vertices adds some overhead in the case of custom-normals as the order used for accessing loops must be the same as iterating of a faces loops. From isolated timing tests of bm_mesh_loops_calc_normals on high poly models, this gives between 3.5x to 10x speedup, with larger gains for meshes with custom-normals. NOTE: this is part one of two patches for multi-threaded auto-smooth, tagging edges as sharp is still single threaded. Reviewed By: mont29 Ref D11928
2021-07-20Cleanup: Make function static, use const object argumentHans Goudey
Also use `const Curve *` instead of `const Object *`, since the function works at a lower level than objects anyway. And also remove another unused function. Since this section of code for converting curves to meshes will likely be replaced, it's nicer to see which parts actually remain used at this point.
2021-07-20Cleanup: Remove unused functionHans Goudey
2021-07-07Cleanup: update filename referencesCampbell Barton
2021-07-01Cleanup: split normal calculation into it's own fileCampbell Barton
Normals now includes many functions including normal splitting & custom normal manipulation split this into it's own file to centralize related functions.
2021-06-28Cleanup: Use const argumentsHans Goudey
2021-06-20Cleanup: make BKE_mesh_loops_to_tessdata a static functionCampbell Barton
2021-06-20Mesh: optimize object mode face tessellationCampbell Barton
- Multi-thread BKE_mesh_recalc_looptri. - Add BKE_mesh_recalc_looptri_with_normals, this skips having to calculate normals for ngons. Exact performance depends on number of faces, size of ngons and available CPU cores. For high poly meshes the isolated improvement to BKE_mesh_recalc_looptri in my tests was between 6.7x .. 25.0x, with the largest gains seen in meshes containing ngons with many sides. The overall speedup for high poly meshes containing quads and triangles is only ~20% although ngon heavy meshes can be much faster.
2021-06-18Cleanup: rename test_index_face -> BKE_mesh_mface_index_validateCampbell Barton
2021-06-18Cleanup: remove unused MFace custom-data utilitiesCampbell Barton
Remove: - BKE_mesh_loops_to_mface_corners - BKE_mesh_tangent_loops_to_tessdata
2021-06-18Cleanup: move mesh tessellation into it's own fileCampbell Barton
This matches BMesh which also has tessellation in it's own file. Using a separate file helps with organization when extracting code into smaller functions.
2021-06-17Cleanup: split BKE_mesh_copy_settings into two functionsCampbell Barton
- BKE_mesh_copy_parameters_for_eval to be used for evaluated meshes only as it doesn't handle ID user-counts. - BKE_mesh_copy_parameters is a general function for copying parameters between meshes.
2021-05-17Merge branch 'blender-v2.93-release'Brecht Van Lommel
2021-05-17Fix T86278: vertex color baking not working with modifiersBrecht Van Lommel
As in the old Blender Internal baking code, this still relies on there being a good mapping to the original vertices.
2021-04-30Cleanup: correct commentCampbell Barton
2021-01-09Cleanup: use bool arguments & variablesCampbell Barton
2020-12-16Cleanup: remove redundant struct declarationsCampbell Barton
2020-12-14Blenkernel: move DerivedMesh.c to c++Jacques Lucke
Required changes to make it compile with clang tidy: * Use c++ includes like (e.g. climits instead limits.h). * Insert type casts when casting from void* to something else. * Replace NULL with nullptr. * Insert casts from int to enum. * Replace designed initializers (not supported in C++ yet). * Use blender::Vector instead of BLI_array_staticdeclare (does not compile with C++). * Replace typedef statements. Ref T83357.
2020-11-06Merge branch 'blender-v2.91-release' into masterPhilipp Oeser
2020-11-06Fix T81997: Subsurf Optimal Display sticks after object conversionPhilipp Oeser
When using Optimal Display, some edges are not flagged `ME_EDGEDRAW` | `ME_EDGERENDER`. When the modifier is applied through the UI in the modifier stack this is not an issue because the `modifyMesh` callback is run with `MOD_APPLY_TO_BASE_MESH` (this will effectively turn of Optimal Display). When converting to mesh though, this will just get an evaluated mesh (where the edge flags are still the same as with the subdivision modifier). Now ensure every edge is flagged to draw after conversion. Maniphest Tasks: T81997 Differential Revision: https://developer.blender.org/D9331
2020-10-27Cleanup: Use const for PointCloud variableHans Goudey
2020-10-19Volumes: new Volume to Mesh modifierJacques Lucke
This modifier is the opposite of the recently added Mesh to Volume modifier. It converts the "surface" of a volume into a mesh. The "surface" is defined by a threshold value. All voxels with a density higher than the threshold are considered to be inside the volume, while all others will be outside. By default, the resolution of the generated mesh depends on the voxel size of the volume grid. The resolution can be customized. It should be noted that a lower resolution might not make this modifier faster. This is because we have to downsample the openvdb grid, which isn't a cheap operation. Converting a mesh to a volume and then back to a mesh is possible, but it does require two separate mesh objects for now. Reviewers: brecht Differential Revision: https://developer.blender.org/D9141
2020-10-09BKE: parallelize BKE_mesh_calc_edgesJacques Lucke
`BKE_mesh_calc_edges` was the main performance bottleneck in D9141. While openvdb only needed ~115ms, calculating the edges afterwards took ~960ms. Now with some parallelization this is reduced to ~210ms. Parallelizing `BKE_mesh_calc_edges` is not entirely trivial, because it has to perform deduplication and some other things that have to happen in a certain order. Even though the multithreading improves performance with more threads, there are diminishing returns when too many threads are used in this function. The speedup is mainly achieved by having multiple hash tables that are filled in parallel. The distribution of the edges to hash tables is based on a hash (that is different from the hash used in the actual hash tables). I moved the function to C++, because that made it easier for me to optimize it. Furthermore, I added `BLI_task.hh` which contains some light tbb wrappers for parallelization. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D9151
2020-10-09CleanUp: Introduce `eMeshBatchDirtyMode` enumJeroen Bakker
It used to be an int mode.
2020-10-09Revert "CleanUp: Introduce `eMeshBatchDirtyMode` enum"Jeroen Bakker
This reverts commit 0796807720882731cdb70be144aa182e9b0b9ee5.
2020-10-07Refactor: remove `BKE_<id_type>_copy` functions.Bastien Montagne
Those were only shallow wrappers around `BKE_id_copy`, barely used (even fully unused in some cases), and we want to get rid of those ID-specific helpers for the common ID management tasks. Also prevents weird custom behaviors (like `BKE_object_copy`, who was the only basic ID copy function to reset user count of the new copy to zero). Part of 71219.
2020-10-07CleanUp: Introduce `eMeshBatchDirtyMode` enumJeroen Bakker
It used to be an `int mode`.
2020-09-18Cleanup: remove unused navmesh codePhilipp Oeser
These were leftovers from the BGE removal. Differential Revision: https://developer.blender.org/D8862
2020-09-17Pointclouds: support mesh <-> pointcloud in convert operatorPhilipp Oeser
Just converts verts to points and vice versa. Materials and Attribute layers are preserved (so for example if you set custom radii on the pointcloud, convert to mesh, then convert back to pointcloud, this will be preserved). Also not add a Radius layer by default (it is still added and filled when adding a pointcloud object from the menu), a global Radius property that will be used if there is no radius attribute can be added later. A Radius attribute can also be added in the pointcloud data properties (and filled via python). This will also add a new utility function that copies materials between datablocks: BKE_id_materials_copy ref T75717 Differential Revision: https://developer.blender.org/D7391
2020-09-04Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fixSebastian Parborg
No functional changes