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:
authorHans Goudey <h.goudey@me.com>2021-10-19 17:01:39 +0300
committerHans Goudey <h.goudey@me.com>2021-10-19 17:01:39 +0300
commit0a6cf3ed0c64a0e4e58ecd40a491d0e6c93532f2 (patch)
tree4e2ba0b74c0ceaa0956aa944ec0b473cf2926cd4 /source/blender/blenkernel/intern/mesh_sample.cc
parent9a1d75e0b9580819dba188afdab72295cbf47302 (diff)
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
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_sample.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh_sample.cc33
1 files changed, 12 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/mesh_sample.cc b/source/blender/blenkernel/intern/mesh_sample.cc
index 9842b3aff31..2274d34f0f1 100644
--- a/source/blender/blenkernel/intern/mesh_sample.cc
+++ b/source/blender/blenkernel/intern/mesh_sample.cc
@@ -60,8 +60,6 @@ void sample_point_attribute(const Mesh &mesh,
const IndexMask mask,
const GMutableSpan data_out)
{
- BLI_assert(data_out.size() == looptri_indices.size());
- BLI_assert(data_out.size() == bary_coords.size());
BLI_assert(data_in.size() == mesh.totvert);
BLI_assert(data_in.type() == data_out.type());
@@ -109,8 +107,6 @@ void sample_corner_attribute(const Mesh &mesh,
const IndexMask mask,
const GMutableSpan data_out)
{
- BLI_assert(data_out.size() == looptri_indices.size());
- BLI_assert(data_out.size() == bary_coords.size());
BLI_assert(data_in.size() == mesh.totloop);
BLI_assert(data_in.type() == data_out.type());
@@ -146,7 +142,6 @@ void sample_face_attribute(const Mesh &mesh,
const IndexMask mask,
const GMutableSpan data_out)
{
- BLI_assert(data_out.size() == looptri_indices.size());
BLI_assert(data_in.size() == mesh.totpoly);
BLI_assert(data_in.type() == data_out.type());
@@ -158,9 +153,10 @@ void sample_face_attribute(const Mesh &mesh,
}
MeshAttributeInterpolator::MeshAttributeInterpolator(const Mesh *mesh,
+ const IndexMask mask,
const Span<float3> positions,
const Span<int> looptri_indices)
- : mesh_(mesh), positions_(positions), looptri_indices_(looptri_indices)
+ : mesh_(mesh), mask_(mask), positions_(positions), looptri_indices_(looptri_indices)
{
BLI_assert(positions.size() == looptri_indices.size());
}
@@ -168,15 +164,15 @@ MeshAttributeInterpolator::MeshAttributeInterpolator(const Mesh *mesh,
Span<float3> MeshAttributeInterpolator::ensure_barycentric_coords()
{
if (!bary_coords_.is_empty()) {
- BLI_assert(bary_coords_.size() == positions_.size());
+ BLI_assert(bary_coords_.size() >= mask_.min_array_size());
return bary_coords_;
}
- bary_coords_.reinitialize(positions_.size());
+ bary_coords_.reinitialize(mask_.min_array_size());
const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh_),
BKE_mesh_runtime_looptri_len(mesh_)};
- for (const int i : bary_coords_.index_range()) {
+ for (const int i : mask_) {
const int looptri_index = looptri_indices_[i];
const MLoopTri &looptri = looptris[looptri_index];
@@ -196,15 +192,15 @@ Span<float3> MeshAttributeInterpolator::ensure_barycentric_coords()
Span<float3> MeshAttributeInterpolator::ensure_nearest_weights()
{
if (!nearest_weights_.is_empty()) {
- BLI_assert(nearest_weights_.size() == positions_.size());
+ BLI_assert(nearest_weights_.size() >= mask_.min_array_size());
return nearest_weights_;
}
- nearest_weights_.reinitialize(positions_.size());
+ nearest_weights_.reinitialize(mask_.min_array_size());
const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh_),
BKE_mesh_runtime_looptri_len(mesh_)};
- for (const int i : nearest_weights_.index_range()) {
+ for (const int i : mask_) {
const int looptri_index = looptri_indices_[i];
const MLoopTri &looptri = looptris[looptri_index];
@@ -224,7 +220,6 @@ Span<float3> MeshAttributeInterpolator::ensure_nearest_weights()
void MeshAttributeInterpolator::sample_data(const GVArray &src,
const AttributeDomain domain,
const eAttributeMapMode mode,
- const IndexMask mask,
const GMutableSpan dst)
{
if (src.is_empty() || dst.is_empty()) {
@@ -247,15 +242,15 @@ void MeshAttributeInterpolator::sample_data(const GVArray &src,
/* Interpolate the source attributes on the surface. */
switch (domain) {
case ATTR_DOMAIN_POINT: {
- sample_point_attribute(*mesh_, looptri_indices_, weights, src, mask, dst);
+ sample_point_attribute(*mesh_, looptri_indices_, weights, src, mask_, dst);
break;
}
case ATTR_DOMAIN_FACE: {
- sample_face_attribute(*mesh_, looptri_indices_, src, mask, dst);
+ sample_face_attribute(*mesh_, looptri_indices_, src, mask_, dst);
break;
}
case ATTR_DOMAIN_CORNER: {
- sample_corner_attribute(*mesh_, looptri_indices_, weights, src, mask, dst);
+ sample_corner_attribute(*mesh_, looptri_indices_, weights, src, mask_, dst);
break;
}
case ATTR_DOMAIN_EDGE: {
@@ -274,11 +269,7 @@ void MeshAttributeInterpolator::sample_attribute(const ReadAttributeLookup &src_
eAttributeMapMode mode)
{
if (src_attribute && dst_attribute) {
- this->sample_data(*src_attribute.varray,
- src_attribute.domain,
- mode,
- IndexMask(dst_attribute->size()),
- dst_attribute.as_span());
+ this->sample_data(*src_attribute.varray, src_attribute.domain, mode, dst_attribute.as_span());
}
}