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-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-12Revert "BLI: Refactor vector types & functions to use templates"Clément Foucault
Includes unwanted changes This reverts commit 46e049d0ce2bce2f53ddc41a0dbbea2969d00a5d.
2022-01-12BLI: Refactor vector types & functions to use templatesClment Foucault
This patch implements the vector types (i.e:`float2`) by making heavy usage of templating. All vector functions are now outside of the vector classes (inside the `blender::math` namespace) and are not vector size dependent for the most part. In the ongoing effort to make shaders less GL centric, we are aiming to share more code between GLSL and C++ to avoid code duplication. ####Motivations: - We are aiming to share UBO and SSBO structures between GLSL and C++. This means we will use many of the existing vector types and others we currently don't have (uintX, intX). All these variations were asking for many more code duplication. - Deduplicate existing code which is duplicated for each vector size. - We also want to share small functions. Which means that vector functions should be static and not in the class namespace. - Reduce friction to use these types in new projects due to their incompleteness. - The current state of the `BLI_(float|double|mpq)(2|3|4).hh` is a bit of a let down. Most clases are incomplete, out of sync with each others with different codestyles, and some functions that should be static are not (i.e: `float3::reflect()`). ####Upsides: - Still support `.x, .y, .z, .w` for readability. - Compact, readable and easilly extendable. - All of the vector functions are available for all the vectors types and can be restricted to certain types. Also template specialization let us define exception for special class (like mpq). - With optimization ON, the compiler unroll the loops and performance is the same. ####Downsides: - Might impact debugability. Though I would arge that the bugs are rarelly caused by the vector class itself (since the operations are quite trivial) but by the type conversions. - Might impact compile time. I did not saw a significant impact since the usage is not really widespread. - Functions needs to be rewritten to support arbitrary vector length. For instance, one can't call `len_squared_v3v3` in `math::length_squared()` and call it a day. - Type cast does not work with the template version of the `math::` vector functions. Meaning you need to manually cast `float *` and `(float *)[3]` to `float3` for the function calls. i.e: `math::distance_squared(float3(nearest.co), positions[i]);` - Some parts might loose in readability: `float3::dot(v1.normalized(), v2.normalized())` becoming `math::dot(math::normalize(v1), math::normalize(v2))` But I propose, when appropriate, to use `using namespace blender::math;` on function local or file scope to increase readability. `dot(normalize(v1), normalize(v2))` ####Consideration: - Include back `.length()` method. It is quite handy and is more C++ oriented. - I considered the GLM library as a candidate for replacement. It felt like too much for what we need and would be difficult to extend / modify to our needs. - I used Macros to reduce code in operators declaration and potential copy paste bugs. This could reduce debugability and could be reverted. - This touches `delaunay_2d.cc` and the intersection code. I would like to know @howardt opinion on the matter. - The `noexcept` on the copy constructor of `mpq(2|3)` is being removed. But according to @JacquesLucke it is not a real problem for now. I would like to give a huge thanks to @JacquesLucke who helped during this and pushed me to reduce the duplication further. Reviewed By: brecht, sergey, JacquesLucke Differential Revision: https://developer.blender.org/D13791
2022-01-12Revert "BLI: Refactor vector types & functions to use templates"Clément Foucault
Reverted because the commit removes a lot of commits. This reverts commit a2c1c368af48644fa8995ecbe7138cc0d7900c30.
2022-01-12BLI: Refactor vector types & functions to use templatesClément Foucault
This patch implements the vector types (i.e:float2) by making heavy usage of templating. All vector functions are now outside of the vector classes (inside the blender::math namespace) and are not vector size dependent for the most part. In the ongoing effort to make shaders less GL centric, we are aiming to share more code between GLSL and C++ to avoid code duplication. Motivations: - We are aiming to share UBO and SSBO structures between GLSL and C++. This means we will use many of the existing vector types and others we currently don't have (uintX, intX). All these variations were asking for many more code duplication. - Deduplicate existing code which is duplicated for each vector size. - We also want to share small functions. Which means that vector functions should be static and not in the class namespace. - Reduce friction to use these types in new projects due to their incompleteness. - The current state of the BLI_(float|double|mpq)(2|3|4).hh is a bit of a let down. Most clases are incomplete, out of sync with each others with different codestyles, and some functions that should be static are not (i.e: float3::reflect()). Upsides: - Still support .x, .y, .z, .w for readability. - Compact, readable and easilly extendable. - All of the vector functions are available for all the vectors types and can be restricted to certain types. Also template specialization let us define exception for special class (like mpq). - With optimization ON, the compiler unroll the loops and performance is the same. Downsides: - Might impact debugability. Though I would arge that the bugs are rarelly caused by the vector class itself (since the operations are quite trivial) but by the type conversions. - Might impact compile time. I did not saw a significant impact since the usage is not really widespread. - Functions needs to be rewritten to support arbitrary vector length. For instance, one can't call len_squared_v3v3 in math::length_squared() and call it a day. - Type cast does not work with the template version of the math:: vector functions. Meaning you need to manually cast float * and (float *)[3] to float3 for the function calls. i.e: math::distance_squared(float3(nearest.co), positions[i]); - Some parts might loose in readability: float3::dot(v1.normalized(), v2.normalized()) becoming math::dot(math::normalize(v1), math::normalize(v2)) But I propose, when appropriate, to use using namespace blender::math; on function local or file scope to increase readability. dot(normalize(v1), normalize(v2)) Consideration: - Include back .length() method. It is quite handy and is more C++ oriented. - I considered the GLM library as a candidate for replacement. It felt like too much for what we need and would be difficult to extend / modify to our needs. - I used Macros to reduce code in operators declaration and potential copy paste bugs. This could reduce debugability and could be reverted. - This touches delaunay_2d.cc and the intersection code. I would like to know @Howard Trickey (howardt) opinion on the matter. - The noexcept on the copy constructor of mpq(2|3) is being removed. But according to @Jacques Lucke (JacquesLucke) it is not a real problem for now. I would like to give a huge thanks to @Jacques Lucke (JacquesLucke) who helped during this and pushed me to reduce the duplication further. Reviewed By: brecht, sergey, JacquesLucke Differential Revision: http://developer.blender.org/D13791
2022-01-12Cleanup: remove redundant const qualifiers for POD typesCampbell Barton
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-14Cleanup: resolve parameter mis-matches in doc-stringsCampbell Barton
Renamed or removed parameters which no longer exist.
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-10-12Cleanup: spelling in commentsCampbell Barton
2021-08-09Cleanup: spelling in commentsCampbell Barton
2021-07-02Cleanup: Use const mesh to ensure BVH and triangulation cacheHans Goudey
As noted in a comment now, these functions only update a cache, so they don't change the logical state of the mesh, which is "it will have the data when necessary." Using a const argument will help const correctness when accessing an object's evaluated mesh.
2021-02-05Geometry Nodes: Add Attribute Proximity NodeVictor-Louis De Gusseme
This node calculates a distance from each point to the closest position on a target geometry, similar to the vertex weight proximity modifier. Mapping the output distance to a different range can be done with an attribute math node after this node. A drop-down changes whether to calculate distances from points, edges, or faces. In points mode, the node also calculates distances from point cloud points. Design task and use cases: T84842 Differential Revision: https://developer.blender.org/D10154
2020-09-04Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fixSebastian Parborg
No functional changes
2020-08-07Code Style: use "#pragma once" in source directoryJacques Lucke
This replaces header include guards with `#pragma once`. A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`), because they are used in other places. This patch has been generated by P1561 followed by `make format`. Differential Revision: https://developer.blender.org/D8466
2020-06-02BVHCache: PerformanceJeroen Bakker
This patch changes the BVHCache implementation. It will use a primitive array in stead of the ListBase. The locking is also changed from a global lock to a per cache instance lock. The performance of `gabby.blend` available on the cloud increased from 9.7 fps to 10.5 fps. Reviewed By: Brecht van Lommel Differential Revision: https://developer.blender.org/D7817
2020-05-15Cleanup: int->BVHCacheType enumJeroen Bakker
2020-03-02Cleanup: make remaining blenkernel headers work in C++Jacques Lucke
2019-08-25Cleanup: redundant struct declarationsCampbell Barton
2019-08-24BKE bvhutils: create and use new `BKE_bvhtree_from_editmesh_get`mano-wii
With this function it is easier to create and have control over editmeshes `BHVtree`s.
2019-08-22Cleanup/Refactor: Simplify/deduplicate bvhutils codemano-wii
This is a step that allow using `bvh_cache` for `EditMeshe`s.
2019-05-29Fix T65027: Snap 3D cursor on hidden faces doesn't work in Edit Mode.mano-wii
I'm not very fond of adding new types of bvhtrees. But this is probably the most efficient solution.
2019-04-27Cleanup: comments (long lines) in blenkernelCampbell Barton
2019-04-17ClangFormat: apply to source, most of internCampbell Barton
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
2019-02-18doxygen: add newline after \fileCampbell Barton
While \file doesn't need an argument, it can't have another doxy command after it.
2019-02-06Cleanup: remove redundant doxygen \file argumentCampbell Barton
Move \ingroup onto same line to be more compact and make it clear the file is in the group.
2019-02-01Cleanup: remove redundant, invalid info from headersCampbell Barton
BF-admins agree to remove header information that isn't useful, to reduce noise. - BEGIN/END license blocks Developers should add non license comments as separate comment blocks. No need for separator text. - Contributors This is often invalid, outdated or misleading especially when splitting files. It's more useful to git-blame to find out who has developed the code. See P901 for script to perform these edits.
2019-01-28Cleanup: sort forward declarations of enum & structCampbell Barton
Done using: source/tools/utils_maintenance/c_sort_blocks.py
2018-10-15Cleanup: remove DerivedMesh bvhtree_from_mesh_getCampbell Barton
2018-09-24Merge branch 'master' into blender2.8Brecht Van Lommel
2018-09-24Spelling fixes in comments and descriptions, patch by luzpaz.Brecht Van Lommel
Differential Revision: https://developer.blender.org/D3719
2018-07-23transform_snap_object: Better bvhtree creation management for editing ↵Germano
multiple objects. - Use the object referenced in `BMEditMesh` as the `ghash` key to save the bvhtrees in cache; - Create a boundbox around edit_mesh to test the snap before creating bvhtree; - Save the `edit_mesh`s bvhtree in the mesh bvh_cache; This is a part of the D3504.
2018-05-13BKE_bvhutils: allow caching NULL bvh_trees.Germano
This prevents zero-leafs bvhtrees from being recalculated multiple times.
2018-05-12Remove unused function: `BKE_bvhtree_from_mesh_looptri`.Germano
2018-05-10BKE: bvhutils: Added support for bvhtrees from loose verts and bvhtree from ↵Germano
loose edges
2018-05-09BKE: bvhutils: Port bvhtree_from_mesh_get to take a Mesh param instead of a ↵Germano
DerivedMesh. Differential Revision: https://developer.blender.org/D3227
2018-05-08looptri + bvhtree support for MeshSybren A. Stüvel
2018-05-04BKE: bvhuils: remove member `sphere_radius`.Germano
This member currently doubles the value of `ray->radius` or is not even used.
2018-05-04BKE: BVHtree: Replace all external references of `bvhtree_from_mesh_looptri` ↵Germano
with `bvhtree_from_mesh_get`.
2018-05-04BKE: BVHtree: make `bvhtree_from_mesh_edges` a static function.Germano
This will help us have more control over bvhtrees that are cached.
2018-05-03BKE bvhtree: Add `tree_type` parameter to `bvhtree_from_mesh_get`.Germano
This will allow greater control of the bvhtrees that are obtained, and helps identify problems. It is also an additional step to unify the functions.
2018-05-01Refactoring: bvhutils: Use a function that gets the bvhtree through an ↵Germano
identifier type. Reviewed By: @campbellbarton Differential Revision: https://developer.blender.org/D3192
2018-01-28Cleanup: style, spellingCampbell Barton
2017-02-17Remove unused functions related to distance between BoundBox and rayGermano Cavalcante
2017-02-17Do not release the arrays used in the parameters of the expanded functions ↵Germano Cavalcante
of bvhutils The release of these arrays should be the programmer's discretion since these arrays can continue to be used. Only the expanded functions `bvhtree_from_mesh_edges_ex` and `bvhtree_from_mesh_looptri_ex` are currently being used in blender (in mesh_remap.c), and from what I could to analyze, these changes can prevent a crash.
2017-02-06Standardization and style for BKE_bvhutilsGermano Cavalcante
Add `bvhtree_from_mesh_edges_ex` and callbacks to nearest_to_ray (Similar to the other functions of this code)
2016-07-02Cleanup: comment blocksCampbell Barton
2016-06-30Transform Snap: Optimize edge-snap using BVH treeGermano Cavalcante
changes in BLI_kdopbvh: - `BLI_bvhtree_find_nearest_to_ray` now takes is_ray_normalized and scale argument. - `BLI_bvhtree_find_nearest_to_ray_angle` has been added (use for perspective view). changes in BLI_bvhutils: - `bvhtree_from_editmesh_edges_ex` was added. changes in math_geom: - `dist_squared_ray_to_seg_v3` was added. other changes: - `do_ray_start_correction` is no longer necessary to snap to verts. - the way in which the test of depth was done before is being simulated in callbacks.
2016-06-29Fix T48695: Slowdown w/ edit-mesh & shrinkwrapGermano Cavalcante
0b5a0d84 caused regression since edit-mesh BVH wasn't cached, each shrink-wrap modifier created its own BVH.
2016-05-11Correct check for tree being in BVH cacheCampbell Barton