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-18Fix T95724: boundary error in `BLI_str_unescape_ex`Sybren A. Stüvel
Fix boundary error in `BLI_str_unescape_ex`. The `dst_maxncpy` parameter indicates the maximum buffer size, not the maximum number of characters. As these are strings, the loop has to stop one byte early to allow space for the trailing zero byte. Thanks @mano-wii for the patch!
2022-02-02BLI: fix memory leak in VectorSetJacques Lucke
The leak happened when the vector set had to grow when it was empty but it had allocated the keys array already.
2022-01-28Remove compilation warnings TexResult.Jeroen Bakker
2022-01-28DrawManager: Image engine support huge images.Jeroen Bakker
Adding better support for drawing huge images in the image/uv editor. Also solved tearing artifacts. The approach is that for each image/uv editor a screen space gpu texture is created that only contains the visible pixels. When zooming or panning the gpu texture is rebuild. Although the solution isn't memory intensive other parts of blender memory usage scales together with the image size. * Due to complexity we didn't implement partial updates when drawing images tiled (wrap repeat). This could be added, but is complicated as a change in the source could mean many different changes on the GPU texture. The work around for now is to tag all gpu textures to be dirty when changes are detected. Original plan was to have 4 screen space images to support panning without gpu texture creation. For now we don't see the need to implement it as the solution is already fast. Especially when GPU memory is shared with CPU ram. Reviewed By: fclem Maniphest Tasks: T92525, T92903 Differential Revision: https://developer.blender.org/D13424
2022-01-28Cleanup: add compiler attributes to BLI_path functionsCampbell Barton
2022-01-28BLI_path: assert passing relative paths to BLI_path_cmp_normalizedCampbell Barton
Assert when "//" prefixed relative paths are passed to BLI_path_cmp_normalized as this can't be expanded and it's possible the paths come from different blend files.
2022-01-28Cleanup: indentation for CMake filesCampbell Barton
Also minor white-space & case changes.
2022-01-28Cleanup: spelling in commentsCampbell Barton
Also minor wording improvements.
2022-01-28Cleanup: rename BLI_paths_equal to BLI_path_cmp_normalizedCampbell Barton
Changes to recent addition: c85c52f2ce478ab0e30c5e93fd5a5cb812db232f. Having both BLI_paths_equal and BLI_path_cmp made it ambiguous which should be used, as `BLI_paths_equal` wasn't the equivalent to `BLI_path_cmp(..) == 0` as it is for string equals macro `STREQ(..)`. It's also a more specialized function which is not used for path comparison throughout Blender's internal path handling logic. Instead rename this `BLI_path_cmp_normalized` and return the result of `BLI_path_cmp` to make it clear paths are modified before comparison. Also add comments about the conventions for Blender's path comparison as well as a possible equivalent to Python's `os.path.samefile` for checking if two paths point to the same location on the file-system.
2022-01-27BLI_float4x4: Add operator[]Clément Foucault
This makes porting existing code using `float[4][4]` easier.
2022-01-27Revert "Cleanup: Remove unused variables in winstuff.c"Ray Molenkamp
This reverts commit 32a96b80a349f30a878d82aaa1ed1ed574cef277. this needed an ifdef, not a removal, will land a proper fix later
2022-01-27Cleanup: Remove unused variables in winstuff.cRay Molenkamp
This clears up 4 unused variable warnings coming from BLI_windows_register_blend_extension
2022-01-27USD Preview Surface material export.Michael Kowalski
Add `USD Preview Surface From Nodes` export option, to convert a Principled BSDF material node network to an approximate USD Preview Surface shader representation. If this option is disabled, the original material export behavior is maintained, where viewport setting are saved to the Preview Surface shader. Also added the following options for texture export. - `Export Textures`: If converting Preview Surface, export textures referenced by shader nodes to a 'textures' directory which is a sibling of the USD file. - `Overwrite Textures`: Allow overwriting existing texture files when exporting textures (this option is off by default). - `Relative Texture Paths`: Make texture asset paths relative to the USD. The entry point for the new functionality is `create_usd_preview_surface_material()`, called from `USDAbstractWriter::ensure_usd_material()`. The material conversion currently handles a small subset of Blender shading nodes, `BSDF_DIFFUSE`, `BSDF_PRINCIPLED`, `TEX_IMAGE` and `UVMAP`. Texture export is handled by copying texture files from their original location to a `textures` folder in the same directory as the USD. In-memory and packed textures are saved directly to the textures folder. This patch is based, in part, on code in Tangent Animation's USD exporter branch. Reviewed By: sybren, HooglyBoogly Differential Revision: https://developer.blender.org/D13647
2022-01-26BLI_string_ref: Add back missing rfind()Clément Foucault
Must have been removed in a bad merge or something.
2022-01-24Cleanup: sort cmake file listsCampbell Barton
2022-01-24Cleanup: Grammar: its self vs. itselfHans Goudey
2022-01-24Cleanup: spelling in commentsCampbell Barton
2022-01-20Geometry Nodes: Curve Primitive ArcCharlie Jolly
This adds a new curve primitive to generate arcs. Radius mode (default): Generates a fixed radius arc on XY plane with controls for Angle, Sweep and Invert. Points mode: Generates a three point curve arc from Start to End via Middle with an Angle Offset and option to invert the arc. There are also outputs for arc center, radius and normal direction relative to the Z-axis. This patch is based on previous patches D11713 and D13100 from @guitargeek. Thank you. Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D13640
2022-01-20Cleanup: spelling in commentsCampbell Barton
2022-01-18Cleanup: spelling in commentsCampbell Barton
2022-01-18BLI: Add index_range method to VectorSetHans Goudey
This can simplify iterating through all of the indices in the vector, which is fairly common, since one of the benefits of the data structure is that all values are contiguous.
2022-01-14blenlib Any tests: Fix unknown pragma warning on Windows.Ankit Meel
Part of a5cb7c1e62a07c17e346278b1c4e9ea58c9f54e0 is reverted since it created unknown pragma warning on windows. Use a trick to do self-assigning. Reviewed by Jacques Lucke in chat.
2022-01-14Cleanup: compiler warnings with clangBrecht Van Lommel
2022-01-14blenlib/ Any tests: fix self-assignment warning and typoAnkit Meel
Fix assignment warning source/blender/blenlib/tests/BLI_any_test.cc:56:5: warning: explicitly assigning value of variable of type 'blender::Any<void, 8, 8>' to itself [-Wself-assign-overloaded] c = c; Reviewed By: JacquesLucke Differential Revision: https://developer.blender.org/D13835
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-13Cleanup: Run `make format`Julian Eisel
2022-01-13Build: remove usage of link_directoriesBrecht Van Lommel
We are now always using absolute paths for libraries, as recommended by the CMake docs. Followup to D9177.
2022-01-12BLI_math: Fix building when WITH_GMP is offClément Foucault
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 @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
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-11Explicit Color OCIO role comment fix.Evan Wilson
This is an update to the correct OCIO role. It changes `SceneReference` to `scene_linear` See https://opencolorio.readthedocs.io/en/latest/guides/authoring/overview.html#config-roles > - reference - the color space against which the other color spaces are defined >NOTE: The reference role has sometimes been misinterpreted as being the space in which “reference art” is stored in. > > - scene_linear - the scene-referred linear-to-light color space, often the same as the reference space The current OCIO UX working group doc says: >reference: This role has had multiple interpreted meanings over the years and is a common point of confusion. It is kept in OCIO for backwards compatibility, but the recommendation is that it is not used by apps. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D11398
2022-01-10Fix compile error with msvcJacques Lucke
2022-01-10Cleanup: add utility macro to simplify using std::enable_ifJacques Lucke
2022-01-07Remove dead numaapi code in blenlibSergey Sharybin
It it rather an old experiment now which didn't pay off. The initial idea was to have main and jobs threads on fast nodes of TR2 processors. This didn't really work reliably because in Blender we need to be able to create nested threads without their affinity set. This is not how some of OS are creating nested threads, and we don't always have access to child threads to reset their affinity. So overall complexity of the initial idea implementation became too much compared to the performance gain.
2022-01-07Fix BKE_image_ensure_tile_token being called with a full pathCampbell Barton
Assert that only the file name component is passed in since special handling for UDIM should only be applied to the file name. Also remove an unnecessary NULL check on the filename argument.
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.
2022-01-06Cleanup: move public doc-strings into headersCampbell Barton
Some recent changes re-introduced public-style doc-strings in the source file.
2022-01-06Cleanup: sort cmake file listsCampbell Barton
2022-01-06Cleanup: spelling in commentsCampbell Barton
2022-01-06Cleanup: Spelling/grammar in commentsHans Goudey
2022-01-04Fix soft light blend mode mathRichard Antalik
Function `blend_color_softlight_float` used math different to compositor and produced result that had abrupt value changes. Use math based on modified screen blend mode as compositor does.
2022-01-04Fix out of range color in blend modesRichard Antalik
Result of Exclusion and Pin Light blend modes could be greater than 255 which caused artifacts. Limit color value to 0-255 range.
2022-01-04BLI: Add slice method to MutableSpanHans Goudey
Span had a slice method with an IndexRange argument, but MutableSpan did not, yet. This commit makes the two types consistent.
2022-01-03Cleanup: Renamed to_object_value to to_dictionary_value.Jeroen Bakker
2022-01-03Cleanup: rename ValueType.Object to ValueType.Dictionary.Jeroen Bakker