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-04Cleanup: Mesh: Remove redundant edge render flagHans Goudey
Currently there are both "EDGERENDER" and "EDGEDRAW" flags, which are almost always used together. Both are runtime data and not exposed to RNA, used to skip drawing some edges after the subdivision surface modifier. The render flag is a relic of the Blender internal renderer. This commit removes the render flag and replaces its uses with the draw flag.
2022-11-03Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-10-18Fix T101883: Issue applying modifier to mesh with shape keysHans Goudey
Caused by 21f2bacad977d3fd83d which misunderstood the logic handling shape keys in this function. The shape key on the original mesh in the main data-base should be cleared if the "no-main" mesh doesn't have any shape key layers and the vertex count has changed. The complexity is necessary because shape keys are stored differently on original and evaluated meshes. Also change to "Warn" because this is expected behavior in some cases, like when applying a geometry nodes modifier that creates a new mesh from scratch.
2022-10-14Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-10-13Mesh: Move runtime data out of DNAHans Goudey
This commit replaces the `Mesh_Runtime` struct embedded in `Mesh` with `blender::bke::MeshRuntime`. This has quite a few benefits: - It's possible to use C++ types like `std::mutex`, `Array`, `BitVector`, etc. more easily - Meshes saved in files are slightly smaller - Copying and writing meshes is a bit more obvious without clearing of runtime data, etc. The first is by far the most important. It will allows us to avoid a bunch of manual memory management boilerplate that is error-prone and annoying. It should also simplify future CoW improvements for runtime data. This patch doesn't change anything besides changing `mesh.runtime.data` to `mesh.runtime->data`. The cleanups above will happen separately. Differential Revision: https://developer.blender.org/D16180
2022-10-07Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-10-04Fix T101583: Issues applying modifier to mesh with shape keysHans Goudey
The wrong mesh was used to read the position attribute. Also, there was always a warning about missing shape keys when that wasn't the case.
2022-10-04Cleanup: replace UNUSED macro with commented args in C++ codeHans Goudey
This is the conventional way of dealing with unused arguments in C++, since it works on all compilers. Regex find and replace: `UNUSED\((\w+)\)` -> `/*$1*/`
2022-09-28Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-09-25Cleanup: remove redundant parenthesis (especially with macros)Campbell Barton
2022-09-25Cleanup: replace C-style casts with functional casts for numeric typesCampbell Barton
2022-09-23Merge branch 'refactor-mesh-selection-generic' into ↵Hans Goudey
refactor-mesh-position-generic
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-15Fix possible to remove mesh position attributeHans Goudey
2022-09-15Remove unused variablesHans Goudey
2022-09-13Merge branch 'master' into refactor-mesh-position-genericHans Goudey
2022-09-12Geometry: Avoid unnecessary initialization when resizing data arraysHans Goudey
When resizing mesh and curves attribute storage, avoid initializing the new memory for basic types. Also, avoid skipping "no free" layers; all layers should be reallocated to the new size since they may be accessed. The semantics introduced in 25237d2625078c6d1 are essential for this change, because otherwise we don't have a way to construct non-trivial types in the new memory. In a basic test of the extrude node, I observed a performance improvement of about 30%, from 55ms to 42ms. Differential Revision: https://developer.blender.org/D15818
2022-09-12Start converting mesh positions to a generic attributeHans Goudey
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-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-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-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-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-12Cleanup: use short names for verts & polys as they're unambiguousCampbell Barton
Follow conventions used in most existing code.
2022-08-11Curve: Simplify legacy curve conversion to meshHans Goudey
Build the mesh directly instead of returning arrays which need to be copied to a new mesh. Also decrease the scope of some variables.
2022-08-10Fix T99661: Use after free converting edit mode curve object to meshHans Goudey
The fix from c0fdf16561034f85aadae8a was missing in one place. We don't want to free the edit mode pointers, those are just copied because the edit mode changes aren't present in the actual original data-block.
2022-07-20Point Cloud: Remove redundant custom data pointersHans Goudey
Similar to e9f82d3dc7eebadcc52, but for point clouds instead. Differential Revision: https://developer.blender.org/D15487
2022-07-08Geometry Nodes: new geometry attribute APIJacques Lucke
Currently, there are two attribute API. The first, defined in `BKE_attribute.h` is accessible from RNA and C code. The second is implemented with `GeometryComponent` and is only accessible in C++ code. The second is widely used, but only being accessible through the `GeometrySet` API makes it awkward to use, and even impossible for types that don't correspond directly to a geometry component like `CurvesGeometry`. This patch adds a new attribute API, designed to replace the `GeometryComponent` attribute API now, and to eventually replace or be the basis of the other one. The basic idea is that there is an `AttributeAccessor` class that allows code to interact with a set of attributes owned by some geometry. The accessor itself has no ownership. `AttributeAccessor` is a simple type that can be passed around by value. That makes it easy to return it from functions and to store it in containers. For const-correctness, there is also a `MutableAttributeAccessor` that allows changing individual and can add or remove attributes. Currently, `AttributeAccessor` is composed of two pointers. The first is a pointer to the owner of the attribute data. The second is a pointer to a struct with function pointers, that is similar to a virtual function table. The functions know how to access attributes on the owner. The actual attribute access for geometries is still implemented with the `AttributeProvider` pattern, which makes it easy to support different sources of attributes on a geometry and simplifies dealing with built-in attributes. There are different ways to get an attribute accessor for a geometry: * `GeometryComponent.attributes()` * `CurvesGeometry.attributes()` * `bke::mesh_attributes(const Mesh &)` * `bke::pointcloud_attributes(const PointCloud &)` All of these also have a `_for_write` variant that returns a `MutabelAttributeAccessor`. Differential Revision: https://developer.blender.org/D15280
2022-06-25Cleanup: Remove unused argumentHans Goudey
2022-06-05Cleanup: Remove unused BKE_spline.hh includesHans Goudey
2022-05-19Cleanup: Decrease variable scopeHans Goudey
2022-05-19Cleanup: Remove redundant functionHans Goudey
`BKE_object_get_evaluated_mesh` now looks inside `geometry_set_eval`.
2022-05-19Merge branch 'blender-v3.2-release'Bastien Montagne
Conflicts: source/blender/blenkernel/intern/lib_override.c
2022-05-19Fix T98237: Double free with curve object conversion to meshHans Goudey
In some cases (when there is an evaluated curve), the conversion code would try to free the evaluated data-block twice, because freeing the object would free it from `data_eval` and then the data-block was freed again explicitly. Now check if the data-block is stored in `data_eval` before freeing `object.data` manually. This is another area that's made more complex by the fact that we change the meaning of `object.data` for evaluated objects. The solution is more complicated than it should be, but it works whether or not an evaluated mesh or curve exists.
2022-05-15Cleanup: Remove includes from DerivedMesh headerHans Goudey
Headers should only include other headers when absolutely necessary, to avoid unnecessary dependencies and increasing compile times. To make this change simpler, three DerivedMesh functions with a single use were removed.
2022-05-14Cleanup: Further use of const for retrieved custom data layersHans Goudey
Similar to cf69652618fefcd22b2cde9a2.
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-20Mesh: Avoid unnecessary normal calculation and dirty tagsHans Goudey
This is mostly a cleanup to avoid hardcoding the eager calculation of normals it isn't necessary, by reducing calls to `BKE_mesh_calc_normals` and by removing calls to `BKE_mesh_normals_tag_dirty` when the mesh is newly created and already has dirty normals anyway. This reduces boilerplate code and makes the "dirty by default" state more clear. Any regressions from this commit should be easy to fix, though the lazy calculation is solid enough that none are expected.
2022-04-15Curves: Port curve to mesh node to the new data-blockHans Goudey
This commit changes the Curve to Mesh node to work with `Curves` instead of `CurveEval`. The change ends up basically completely rewriting the node, since the different attribute storage means that the decisions made previously don't make much sense anymore. The main loops are now "for each attribute: for each curve combination" rather than the other way around, with the goal of taking advantage of the locality of curve attributes. This improvement is quite noticeable with many small curves; I measured a 4-5x improvement (around 4-5s to <1s) when converting millions of curves to tens of millions of faces. I didn't obverse any change in performance compared to 3.1 with fewer curves though. The changes also solve an algorithmic flaw where any interpolated attributes would be evaluated for every curve combination instead of just once per curve. This can be a large improvement when there are many profile curves. The code relies heavily on a function `foreach_curve_combination` which calculates some basic information about each combination and calls a templated function. I made assumptions about unnecessary reads being removed by compiler optimizations. For further performance improvements in the future that might be an area to investigate. Another might be using a "for a group of curves: for each attribute: for each curve" pattern to increase the locality of memory access. Differential Revision: https://developer.blender.org/D14642
2022-04-13Fix compilation error with MSVCSergey Sharybin
Caused by previous DNA change.
2022-04-13Cover some DNA files with C++ utility macrosSergey Sharybin
Solves compilation warning with Clang, and moves manipulation with DNA structures to the designed way for C++. The tests and few other places are update to the new code by Jacques. Ref T96847 Maniphest Tasks: T96847 Differential Revision: https://developer.blender.org/D14625
2022-04-04Cleanup: Simplify zero-initializing DNA structures in C++Sergey Sharybin
Avoids duplication of type which previously was specified twice in a line.
2022-03-29Cleanup: Use higher level semantic for zeroing DNA objects in C++Sergey Sharybin
Replaces old-style memzero-style of call with zero-initializer. Allows to shorten typical initialization code to a single line: Object foo = blender::dna::shallow_zero_initialize<Object>() This will allow to more easily convert designated initializer which is often used to fill object with zeroes to the explicit function calls: MyDNAStruct foo = {}; will be translated to MyDNAStruct foo = blender::dna::shallow_zero_initialize<MyDNAStruct>(); Differential Revision: https://developer.blender.org/D14486
2022-03-29Cleanup: Remove redundant DNA C++ helper functionSergey Sharybin
Use shallow_copy, no need in copy_memory. The latter appeared as some last minute solution for a compilation warning on Friday.
2022-03-28Fix (unreported) crash in some mesh-from-object code.Bastien Montagne
Crashed e.g. FBX exporter. Mistake in rB0c33e84020deca.
2022-03-25Fix compilation warnings after previous changeSergey Sharybin
Thanks Jacques for finding solution for deprecation warning which was generated by GCC for constructor. The rest of the change is related on fixing memaccess warning which was happening when memset/memcpy was used directly on the DNA object pointer. Now there are two utility functions for this: - blender::dna::zero_memory - blender::dna::copy_memory