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-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-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-31Fix compile error from merge.Joseph Eagar
2022-08-31Merge branch 'blender-v3.3-release'Joseph Eagar
2022-08-31Core: Remove color attribute limit from CustomData APIJoseph Eagar
Note: does not fix the limit in PBVH draw which is caused by VBO limits not MAX_MCOL.
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-31Nodes: move NodeTreeRef functionality into node runtime dataJacques Lucke
The purpose of `NodeTreeRef` was to speed up various queries on a read-only `bNodeTree`. Not that we have runtime data in nodes and sockets, we can also store the result of some queries there. This has some benefits: * No need for a read-only separate node tree data structure which increased complexity. * Makes it easier to reuse cached queries in more parts of Blender that can benefit from it. A downside is that we loose some type safety that we got by having different types for input and output sockets, as well as internal and non-internal links. This patch also refactors `DerivedNodeTree` so that it does not use `NodeTreeRef` anymore, but uses `bNodeTree` directly instead. To provide a convenient API (that is also close to what `NodeTreeRef` has), a new approach is implemented: `bNodeTree`, `bNode`, `bNodeSocket` and `bNodeLink` now have C++ methods declared in `DNA_node_types.h` which are implemented in `BKE_node_runtime.hh`. To make this work, `makesdna` now skips c++ sections when parsing dna header files. No user visible changes are expected. Differential Revision: https://developer.blender.org/D15491
2022-08-31Cleanup: break before the default case in switch statementsCampbell Barton
While missing the break before a default that only breaks isn't an error, it means adding new cases needs to remember to add the break for an existing case, changing the default case will also result in an unintended fall-through. Also avoid `default:;` and add an explicit break.
2022-08-31Mesh: Avoid redundant custom data layer initializationHans Goudey
In all these cases, it was clear that the layer values were set right after the layer was created anyway. So there's no point in using calloc or setting the values to zero first. See 25237d2625078c6d for more info.
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-30Geometry Nodes: Use separate field context for each geometry typeHans Goudey
Using the same `GeometryComponentFieldContext` for all situations, even when only one geometry type is supported is misleading, and mixes too many different abstraction levels into code that could be simpler. With the attribute API moved out of geometry components recently, the "component" system is just getting in the way here. This commit adds specific field contexts for geometry types: meshes, curves, point clouds, and instances. There are also separate field input helper classes, to help reduce boilerplate for fields that only support specific geometry types. Another benefit of this change is that it separates geometry components from fields, which makes it easier to see the purpose of the two concepts, and how they relate. Because we want to be able to evaluate a field on just `CurvesGeometry` rather than the full `Curves` data-block, the generic "geometry context" had to be changed to avoid using `GeometryComponent`, since there is no corresponding geometry component type. The resulting void pointer is ugly, but only turns up in three places in practice. When Apple clang supports `std::variant`, that could be used instead. Differential Revision: https://developer.blender.org/D15519
2022-08-26Cleanup: reduce variable scopeCampbell Barton
2022-08-25Merge branch 'blender-v3.3-release'Bastien Montagne
2022-08-25Fix T100255: Make RigidBodyWorld (and effector_weights) collections refcounted.Bastien Montagne
Those collections were so far mainly just tagged as fake user (even though a few places in code already incremented usercount on them). Since we now clear the fakeuser flag when linking/appending data, ensure that these collections are preserved by making these usages regular ID refcounting ones. Reviewed By: brecht Differential Revision: https://developer.blender.org/D15783
2022-08-23Merge branch 'blender-v3.3-release'Philipp Oeser
2022-08-23Fix T100578: Surface Deform modifier displays wrong in editmodePhilipp Oeser
This was the case when the "Show in Editmode" option was used and a vertexgroup affected the areas. Probably an oversight in {rBdeaff945d0b9}?, seems like deforming modifiers always need to call `BKE_mesh_wrapper_ensure_mdata` in `deformVertsEM` when a vertex group is used. Maniphest Tasks: T100578 Differential Revision: https://developer.blender.org/D15756
2022-08-23Cleanup: match names between functions & declarationsCampbell Barton
2022-08-16Cleanup: some refactoring in mapped mesh extractionBrecht Van Lommel
* Flip the logic to first detect if we are dealing with an unmodified mesh in editmode. And then if not, detect if we need a mapping or not. * runtime.is_original is only valid for the bmesh wrapper. Rename it to clarify that and only check it when the mesh is a bmesh wrapper. * Remove MR_EXTRACT_MAPPED and instead check only for the existence of the origindex arrays. Previously it would sometimes access those arrays without MR_EXTRACT_MAPPED set, which according to a comment means they are invalid. Differential Revision: https://developer.blender.org/D15676
2022-08-12Cleanup: remove use_normals arugment to MOD_deform_mesh_eval_getCampbell Barton
Accessing the normals creates them on demand so there was no need to pass an argument requesting them.
2022-08-12Merge branch 'blender-v3.3-release'Campbell Barton
2022-08-12Fix T100191: Crash with the wave modifier using normals in edit-modeCampbell Barton
2022-08-12Cleanup: screw modifier comments & namingCampbell Barton
Rename dist to dist_sq as it's the squared distance, also prefer __func__ in temporary allocated arrays.
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-11Cleanup: remove redundant MEM_SAFE_FREECampbell Barton
MEM_SAFE_FREE isn't necessary when the memory is known to be allocated and clearing the value afterwards isn't necessary.
2022-08-09I18n: make more parts of the UI translatableDamien Picard
- "Name collisions" label in mesh properties - "Threshold" labels in Vertex Weight Edit modifier - "Particle System" label in Particle Instance modifier - Slot number in the Shader Editor - Status bar keymap items during modal operations: add TIP_() macro to status bar interface template - On dumping messages, sort preset files so their messages are stable between runs Ref. T43295 Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15607
2022-08-09I18n: make more parts of the UI translatableDamien Picard
- "Name collisions" label in mesh properties - "Threshold" labels in Vertex Weight Edit modifier - "Particle System" label in Particle Instance modifier - Slot number in the Shader Editor - Status bar keymap items during modal operations: add TIP_() macro to status bar interface template - On dumping messages, sort preset files so their messages are stable between runs Ref. T43295 Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15607
2022-08-09Cleanup: use own username in code-comment tagsCampbell Barton
2022-08-04Depsgraph: More clear function name for transform dependnecySergey Sharybin
The name was confusing to a level that it sounded like the relation goes the opposite direction than it is intended.
2022-07-31Cleanup: Remove mesh edge "tmp tag"Hans Goudey
Ref T95966. Also fixes modification of input mesh, which should be considered constant.
2022-07-28Cleanup: Use new IDProperty creation API for geometry ndoes modifierHans Goudey
Use the API from 36068487d076bfd8 instead of the uglier `IDPropertyTemplate` API.
2022-07-28Geometry Nodes: add assert to check if node supports lazynessIliay Katueshenock
Only nodes supporting lazyness can mark inputs as unused. For other nodes, this is done automatically of all outputs are unused. Differential Revision: https://developer.blender.org/D15409
2022-07-22Cleanup: Use r_ prefix for boolean return parametersHans Goudey
Also rearrange some lines to simplify logic.
2022-07-20Cleanup: remove unused get_cage_mesh parameterJacques Lucke
All callers passed `false` for this parameter, making it more confusing than useful. If this functionality is needed again in the future, a separate function should be added. Differential Revision: https://developer.blender.org/D15401
2022-07-20Add a 'Apply and Delete All' operation to shapekeys.Bastien Montagne
Adds a new option to the 'Delete ShpaKeys' operator, which first applies the current mix to the object data, before removing all shapekeys. Request from @JulienKaspar from Blender studio. Reviewed By: JulienKaspar Differential Revision: https://developer.blender.org/D15443
2022-07-19Cleanup: Remove compile option for curves objectHans Goudey
After becb1530b1c81a408e20 the new curves object type isn't hidden behind an experimental flag anymore, and other areas depend on this, so disabling curves at compile time doesn't make sense anymore.
2022-07-15Fix overly noisy surface deform warning messageSergey Sharybin
An increased number of vertices is not a stopper for the surface deform modifier anymore. It might still be useful to expose the message in the UI, but printing error message to the console on every modifier evaluation makes real errors to become almost invisible. Differential Revision: https://developer.blender.org/D15468
2022-07-15UI: make many modifier strings translatableDamien Picard
This includes: - new modifier names It mostly uses `N_` because the strings are actually translated elsewhere. The goal is simply to export them to .po files. Most of the new translations were reported in T43295#1105335. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15418
2022-07-14Modifiers: fix mesh to volume modifier on non-volume objectsJacques Lucke
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-07-08Fix T99191: Boolean modifier creates invalid material indicesHans Goudey
Similar to 1a6d0ec71cf3b0c2c which changed the mesh boolean node (and also caused this bug), this commit changes the material mapping for the exact mode of the boolean modifier. Now the result should contain any material on the faces of the input objects (including materials linked to objects and meshes). The improvement is possible because materials can be changed during evaluation (as of 1a81d268a19f2f1402). Differential Revision: https://developer.blender.org/D15365
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-29Geometry Nodes: Only calculate mesh to volume bounds when necessaryHans Goudey
In "size" voxel resolution mode, calculating the bounds of the mesh to volume node's input mesh isn't necessary. For high poly this can take a few milliseconds, so this commit skips the calculation unless we need it for the "Amount" mode. Differential Revision: https://developer.blender.org/D15324
2022-06-29Geometry Nodes: Add Mesh To Volume NodeErik Abrahamsson
This adds a Mesh To Volume Node T86838 based on the existing modifier. The mesh to volume conversion is implemented in the geometry module, and shared between the node and the modifier. Currently the node outputs a grid with the name "density". This may change in the future depending on the decisions made in T91668. The original patch was by Kris (@Metricity), further implementation by Geramy Loveless (@GeramyLoveless), then finished by Erik Abrahamsson (@erik85). Differential Revision: https://developer.blender.org/D10895
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-06-21Cleanup: removed unused Blender Internal bump/normal mapping texture codeBrecht Van Lommel
The TexResult.nor output does not appear to be used anywhere.
2022-06-16Geometry Nodes: add 'Intersecting Edges' output for boolean nodePhilipp Oeser
This patch adds a 'Intersecting Edges' output with a boolean selection that only gives you the new edges on intersections. Will work on a couple of examples next, this should make some interesting effects possible (including getting us closer to the "bevel- after-boolean-usecase") To achieve this, a Vector is passed to `direct_mesh_boolean` when the iMesh is still available (and intersecting edges appended), then from those edge indices a selection will be stored as attribute. Differential Revision: https://developer.blender.org/D15151
2022-06-14Fix T98813: crash with GPU subdiv in edit mode and instanced geometryBrecht Van Lommel
Instancing with geometry nodes uses just the evaluated Mesh, and ignores the Object that it came from. That meant that it would try to look up the subsurf modifier on the instancer object which does not have the subsurf modifier. Instead of storing a session UUID and looking up the modifier data, store a point to the subsurf modifier runtime data. Unlike the modifier data, this runtime data is preserved across depsgraph CoW. It must be for the subdiv descriptor contained in it to stay valid along with the draw cache. As a bonus, this moves various Mesh_Runtime variables into the subsurf runtime data, reducing memory usage for meshes not using subdivision surfaces. Also fixes T98693, issues with subdivision level >= 8 due to integer overflow. Differential Revision: https://developer.blender.org/D15184
2022-06-07Fix T98626: Mesh Deform modifier stops working on a linked collection upon undo.Bastien Montagne
Regression from rBb66368f3fd9c, we still need to store all data on undo writes, since overrides are not re-applied after undo/redo.