From 76f386a37a9cf14ac729be048230f81a0a397fc8 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 15 Oct 2021 14:08:52 -0500 Subject: Geometry Nodes: Fields transfer attribute node This commit adds an updated version of the old attribute transfer node. It works like a function node, so it works in the context of a geometry, with a simple data output. The "Nearest" mode finds the nearest element of the specified domain on the target geometry and copies the value directly from the target input. The "Nearest Face Interpolated" finds the nearest point on anywhere on the surface of the target mesh and linearly interpolates the value on the target from the face's corners. The node also has a new "Index" mode, which can pick data from specific indices on the target geometry. The implicit default is to do a simple copy from the target geometry, but any indices could be used. It is also possible to use a single value for the index to to retrieve a single value from an attribute at a certain index. Differential Revision: https://developer.blender.org/D12785 --- source/blender/blenkernel/BKE_mesh_sample.hh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 2fbf7372a09..4845876751b 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -44,17 +44,20 @@ void sample_point_attribute(const Mesh &mesh, Span looptri_indices, Span bary_coords, const GVArray &data_in, + const IndexMask mask, GMutableSpan data_out); void sample_corner_attribute(const Mesh &mesh, Span looptri_indices, Span bary_coords, const GVArray &data_in, + const IndexMask mask, GMutableSpan data_out); void sample_face_attribute(const Mesh &mesh, Span looptri_indices, const GVArray &data_in, + const IndexMask mask, GMutableSpan data_out); enum class eAttributeMapMode { @@ -83,6 +86,12 @@ class MeshAttributeInterpolator { const Span positions, const Span looptri_indices); + void sample_data(const GVArray &src, + const AttributeDomain domain, + const eAttributeMapMode mode, + const IndexMask mask, + const GMutableSpan dst); + void sample_attribute(const ReadAttributeLookup &src_attribute, OutputAttribute &dst_attribute, eAttributeMapMode mode); -- cgit v1.2.3 From 0a6cf3ed0c64a0e4e58ecd40a491d0e6c93532f2 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 19 Oct 2021 09:01:39 -0500 Subject: Geometry Nodes: Fields version of the raycast node This patch includes an updated version of the raycast node that uses fields instead of attributes for inputs instead of outputs. This makes the node's UI much clearer. It should be faster too, since the evaluation system for fields provides multi-threading. The source position replaces the input geometry (since this node is evaluated in the context of a geometry like the other field nodes). Thanks to @guitargeek for an initial version of this patch. Differential Revision: https://developer.blender.org/D12638 --- source/blender/blenkernel/BKE_mesh_sample.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 4845876751b..17f8e766724 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -75,6 +75,7 @@ enum class eAttributeMapMode { class MeshAttributeInterpolator { private: const Mesh *mesh_; + const IndexMask mask_; const Span positions_; const Span looptri_indices_; @@ -83,13 +84,13 @@ class MeshAttributeInterpolator { public: MeshAttributeInterpolator(const Mesh *mesh, + const IndexMask mask, const Span positions, const Span looptri_indices); void sample_data(const GVArray &src, const AttributeDomain domain, const eAttributeMapMode mode, - const IndexMask mask, const GMutableSpan dst); void sample_attribute(const ReadAttributeLookup &src_attribute, -- cgit v1.2.3 From 3d3bc748849834ef74563deb603ab43859cffeeb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2022 11:38:08 +1100 Subject: Cleanup: remove redundant const qualifiers for POD types MSVC used to warn about const mismatch for arguments passed by value. Remove these as newer versions of MSVC no longer show this warning. --- source/blender/blenkernel/BKE_mesh_sample.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 17f8e766724..238b6f4dcae 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -89,8 +89,8 @@ class MeshAttributeInterpolator { const Span looptri_indices); void sample_data(const GVArray &src, - const AttributeDomain domain, - const eAttributeMapMode mode, + AttributeDomain domain, + eAttributeMapMode mode, const GMutableSpan dst); void sample_attribute(const ReadAttributeLookup &src_attribute, -- cgit v1.2.3 From a2c1c368af48644fa8995ecbe7138cc0d7900c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 12 Jan 2022 12:19:00 +0100 Subject: BLI: Refactor vector types & functions to use templates 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 --- source/blender/blenkernel/BKE_mesh_sample.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 238b6f4dcae..738b768d906 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -22,7 +22,7 @@ #include "FN_generic_virtual_array.hh" -#include "BLI_float3.hh" +#include "BLI_math_vec_types.hh" #include "BKE_attribute.h" -- cgit v1.2.3 From e5766752d04794c2693dedad75baeb8c7d68f4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 12 Jan 2022 12:43:40 +0100 Subject: Revert "BLI: Refactor vector types & functions to use templates" Reverted because the commit removes a lot of commits. This reverts commit a2c1c368af48644fa8995ecbe7138cc0d7900c30. --- source/blender/blenkernel/BKE_mesh_sample.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 738b768d906..238b6f4dcae 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -22,7 +22,7 @@ #include "FN_generic_virtual_array.hh" -#include "BLI_math_vec_types.hh" +#include "BLI_float3.hh" #include "BKE_attribute.h" -- cgit v1.2.3 From 46e049d0ce2bce2f53ddc41a0dbbea2969d00a5d Mon Sep 17 00:00:00 2001 From: Clment Foucault Date: Wed, 12 Jan 2022 12:46:52 +0100 Subject: BLI: Refactor vector types & functions to use templates 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 --- source/blender/blenkernel/BKE_mesh_sample.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 238b6f4dcae..738b768d906 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -22,7 +22,7 @@ #include "FN_generic_virtual_array.hh" -#include "BLI_float3.hh" +#include "BLI_math_vec_types.hh" #include "BKE_attribute.h" -- cgit v1.2.3 From fb6bd8864411ee27db05ceadcb80f690f44e48dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 12 Jan 2022 12:49:36 +0100 Subject: Revert "BLI: Refactor vector types & functions to use templates" Includes unwanted changes This reverts commit 46e049d0ce2bce2f53ddc41a0dbbea2969d00a5d. --- source/blender/blenkernel/BKE_mesh_sample.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 738b768d906..238b6f4dcae 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -22,7 +22,7 @@ #include "FN_generic_virtual_array.hh" -#include "BLI_math_vec_types.hh" +#include "BLI_float3.hh" #include "BKE_attribute.h" -- cgit v1.2.3 From d43b5791e0c1f6581a539c2663ec8200e107740a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 12 Jan 2022 12:57:07 +0100 Subject: BLI: Refactor vector types & functions to use templates 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 --- source/blender/blenkernel/BKE_mesh_sample.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh') diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh index 238b6f4dcae..738b768d906 100644 --- a/source/blender/blenkernel/BKE_mesh_sample.hh +++ b/source/blender/blenkernel/BKE_mesh_sample.hh @@ -22,7 +22,7 @@ #include "FN_generic_virtual_array.hh" -#include "BLI_float3.hh" +#include "BLI_math_vec_types.hh" #include "BKE_attribute.h" -- cgit v1.2.3