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
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2021-06-17 11:31:53 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2021-06-17 23:11:32 +0300
commit4b673ebb990684af4a429d963a1026ddf3f2552f (patch)
treee5914b52a95fb60ed3ba3fcc63ceb71c3e2499ad /source/blender/blenkernel/BKE_mesh_sample.hh
parent577d6d3f872206c99dc95c8afaff47ca0339d7fc (diff)
Raycast geometry node.
The //Raycast// node intersects rays from one geometry onto another. It computes hit points on the target mesh and returns normals, distances and any surface attribute specified by the user. A ray starts on each point of the input //Geometry//. Rays continue in the //Ray Direction// until they either hit the //Target Geometry// or reach the //Ray Length// limit. If the target is hit, the value of the //Is Hit// attribute in the output mesh will be true. //Hit Position//, //Hit Normal//, //Hit Distance// and //Hit Index// are the properties of the target mesh at the intersection point. In addition, a //Target Attribute// can be specified that is interpolated at the hit point and the result stored in //Hit Attribute//. Docs: D11620 Reviewed By: HooglyBoogly Differential Revision: https://developer.blender.org/D11619
Diffstat (limited to 'source/blender/blenkernel/BKE_mesh_sample.hh')
-rw-r--r--source/blender/blenkernel/BKE_mesh_sample.hh42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_mesh_sample.hh b/source/blender/blenkernel/BKE_mesh_sample.hh
index f504650e349..c40d2e947e3 100644
--- a/source/blender/blenkernel/BKE_mesh_sample.hh
+++ b/source/blender/blenkernel/BKE_mesh_sample.hh
@@ -28,6 +28,11 @@
struct Mesh;
+namespace blender::bke {
+struct ReadAttributeLookup;
+class OutputAttribute;
+} // namespace blender::bke
+
namespace blender::bke::mesh_surface_sample {
using fn::CPPType;
@@ -35,6 +40,8 @@ using fn::GMutableSpan;
using fn::GSpan;
using fn::GVArray;
+Span<MLoopTri> get_mesh_looptris(const Mesh &mesh);
+
void sample_point_attribute(const Mesh &mesh,
Span<int> looptri_indices,
Span<float3> bary_coords,
@@ -52,4 +59,39 @@ void sample_face_attribute(const Mesh &mesh,
const GVArray &data_in,
GMutableSpan data_out);
+enum class eAttributeMapMode {
+ INTERPOLATED,
+ NEAREST,
+};
+
+/**
+ * A utility class that performs attribute interpolation from a source mesh.
+ *
+ * The interpolator is only valid as long as the mesh is valid.
+ * Barycentric weights are needed when interpolating point or corner domain attributes,
+ * these are computed lazily when needed and re-used.
+ */
+class MeshAttributeInterpolator {
+ private:
+ const Mesh *mesh_;
+ const Span<float3> positions_;
+ const Span<int> looptri_indices_;
+
+ Array<float3> bary_coords_;
+ Array<float3> nearest_weights_;
+
+ public:
+ MeshAttributeInterpolator(const Mesh *mesh,
+ const Span<float3> positions,
+ const Span<int> looptri_indices);
+
+ void sample_attribute(const ReadAttributeLookup &src_attribute,
+ OutputAttribute &dst_attribute,
+ eAttributeMapMode mode);
+
+ protected:
+ Span<float3> ensure_barycentric_coords();
+ Span<float3> ensure_nearest_weights();
+};
+
} // namespace blender::bke::mesh_surface_sample