[Bf-blender-cvs] [45e58a7e92e] temp-geometry-nodes-fields-prototype: Merge branch 'master' into temp-geometry-nodes-fields-prototype

Jacques Lucke noreply at git.blender.org
Wed Aug 18 10:21:07 CEST 2021


Commit: 45e58a7e92e5ef00c34fafaba3ca3d749ce30ec2
Author: Jacques Lucke
Date:   Wed Aug 18 10:17:15 2021 +0200
Branches: temp-geometry-nodes-fields-prototype
https://developer.blender.org/rB45e58a7e92e5ef00c34fafaba3ca3d749ce30ec2

Merge branch 'master' into temp-geometry-nodes-fields-prototype

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/customdata.c
index 9e663a31001,1a3200a9b6c..fdce73e737b
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@@ -4258,10 -4244,9 +4258,10 @@@ void CustomData_blend_write_prepare(Cus
  
    for (i = 0, j = 0; i < totlayer; i++) {
      CustomDataLayer *layer = &data->layers[i];
 -    if (layer->flag & CD_FLAG_NOCOPY) { /* Layers with this flag set are not written to file. */
 +    /* Layers with this flag set are not written to file. */
 +    if (layer->flag & (CD_FLAG_NOCOPY | CD_FLAG_ANONYMOUS)) {
        data->totlayer--;
-       /* CLOG_WARN(&LOG, "skipping layer %p (%s)", layer, layer->name); */
+       // CLOG_WARN(&LOG, "skipping layer %p (%s)", layer, layer->name);
      }
      else {
        if (UNLIKELY((size_t)j >= write_layers_size)) {
diff --cc source/blender/nodes/geometry/nodes/node_geo_raycast.cc
index 29ea3e11ff1,88e3bf17d43..9d09d808234
--- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc
@@@ -87,62 -95,64 +87,64 @@@ static void raycast_to_mesh(const Mesh 
    BLI_assert(ray_origins.size() == r_hit_distances.size() || r_hit_distances.is_empty());
  
    BVHTreeFromMesh tree_data;
 -  BKE_bvhtree_from_mesh_get(&tree_data, &mesh, BVHTREE_FROM_LOOPTRI, 4);
 +  BKE_bvhtree_from_mesh_get(&tree_data, mesh, BVHTREE_FROM_LOOPTRI, 4);
+   if (tree_data.tree == nullptr) {
+     free_bvhtree_from_mesh(&tree_data);
+     return;
+   }
  
-   if (tree_data.tree != nullptr) {
-     for (const int i : ray_origins.index_range()) {
-       const float ray_length = ray_lengths[i];
-       const float3 ray_origin = ray_origins[i];
-       const float3 ray_direction = ray_directions[i].normalized();
- 
-       BVHTreeRayHit hit;
-       hit.index = -1;
-       hit.dist = ray_length;
-       if (BLI_bvhtree_ray_cast(tree_data.tree,
-                                ray_origin,
-                                ray_direction,
-                                0.0f,
-                                &hit,
-                                tree_data.raycast_callback,
-                                &tree_data) != -1) {
-         if (!r_hit.is_empty()) {
-           r_hit[i] = hit.index >= 0;
-         }
-         if (!r_hit_indices.is_empty()) {
-           /* Index should always be a valid looptri index, use 0 when hit failed. */
-           r_hit_indices[i] = max_ii(hit.index, 0);
-         }
-         if (!r_hit_positions.is_empty()) {
-           r_hit_positions[i] = hit.co;
-         }
-         if (!r_hit_normals.is_empty()) {
-           r_hit_normals[i] = hit.no;
-         }
-         if (!r_hit_distances.is_empty()) {
-           r_hit_distances[i] = hit.dist;
-         }
+   for (const int i : ray_origins.index_range()) {
+     const float ray_length = ray_lengths[i];
+     const float3 ray_origin = ray_origins[i];
+     const float3 ray_direction = ray_directions[i].normalized();
+ 
+     BVHTreeRayHit hit;
+     hit.index = -1;
+     hit.dist = ray_length;
+     if (BLI_bvhtree_ray_cast(tree_data.tree,
+                              ray_origin,
+                              ray_direction,
+                              0.0f,
+                              &hit,
+                              tree_data.raycast_callback,
+                              &tree_data) != -1) {
+       if (!r_hit.is_empty()) {
+         r_hit[i] = hit.index >= 0;
+       }
+       if (!r_hit_indices.is_empty()) {
+         /* Index should always be a valid looptri index, use 0 when hit failed. */
+         r_hit_indices[i] = max_ii(hit.index, 0);
        }
-       else {
-         if (!r_hit.is_empty()) {
-           r_hit[i] = false;
-         }
-         if (!r_hit_indices.is_empty()) {
-           r_hit_indices[i] = 0;
-         }
-         if (!r_hit_positions.is_empty()) {
-           r_hit_positions[i] = float3(0.0f, 0.0f, 0.0f);
-         }
-         if (!r_hit_normals.is_empty()) {
-           r_hit_normals[i] = float3(0.0f, 0.0f, 0.0f);
-         }
-         if (!r_hit_distances.is_empty()) {
-           r_hit_distances[i] = ray_length;
-         }
+       if (!r_hit_positions.is_empty()) {
+         r_hit_positions[i] = hit.co;
+       }
+       if (!r_hit_normals.is_empty()) {
+         r_hit_normals[i] = hit.no;
+       }
+       if (!r_hit_distances.is_empty()) {
+         r_hit_distances[i] = hit.dist;
+       }
+     }
+     else {
+       if (!r_hit.is_empty()) {
+         r_hit[i] = false;
+       }
+       if (!r_hit_indices.is_empty()) {
+         r_hit_indices[i] = 0;
+       }
+       if (!r_hit_positions.is_empty()) {
+         r_hit_positions[i] = float3(0.0f, 0.0f, 0.0f);
+       }
+       if (!r_hit_normals.is_empty()) {
+         r_hit_normals[i] = float3(0.0f, 0.0f, 0.0f);
+       }
+       if (!r_hit_distances.is_empty()) {
+         r_hit_distances[i] = ray_length;
        }
      }
- 
-     free_bvhtree_from_mesh(&tree_data);
    }
+ 
+   free_bvhtree_from_mesh(&tree_data);
  }
  
  static bke::mesh_surface_sample::eAttributeMapMode get_map_mode(
@@@ -158,12 -168,12 +160,12 @@@
  }
  
  static void raycast_from_points(const GeoNodeExecParams &params,
-                                 const GeometrySet &src_geometry,
+                                 const GeometrySet &target_geometry,
                                  GeometryComponent &dst_component,
 -                                const StringRef hit_name,
 -                                const StringRef hit_position_name,
 -                                const StringRef hit_normal_name,
 -                                const StringRef hit_distance_name,
 +                                const AnonymousCustomDataLayerID *hit_id,
 +                                const AnonymousCustomDataLayerID *hit_position_id,
 +                                const AnonymousCustomDataLayerID *hit_normal_id,
 +                                const AnonymousCustomDataLayerID *hit_distance_id,
                                  const Span<std::string> hit_attribute_names,
                                  const Span<std::string> hit_attribute_output_names)
  {
@@@ -291,46 -270,32 +294,46 @@@
  static void geo_node_raycast_exec(GeoNodeExecParams params)
  {
    GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
-   GeometrySet cast_geometry_set = params.extract_input<GeometrySet>("Target Geometry");
+   GeometrySet target_geometry_set = params.extract_input<GeometrySet>("Target Geometry");
  
 -  const std::string hit_name = params.extract_input<std::string>("Is Hit");
 -  const std::string hit_position_name = params.extract_input<std::string>("Hit Position");
 -  const std::string hit_normal_name = params.extract_input<std::string>("Hit Normal");
 -  const std::string hit_distance_name = params.extract_input<std::string>("Hit Distance");
 -
 -  const Array<std::string> hit_names = {params.extract_input<std::string>("Target Attribute")};
 -  const Array<std::string> hit_output_names = {params.extract_input<std::string>("Hit Attribute")};
 +  const Array<std::string> hit_attribute_names = {
 +      params.extract_input<std::string>("Target Attribute")};
 +  const Array<std::string> hit_attribute_output_names = {
 +      params.extract_input<std::string>("Hit Attribute")};
  
    geometry_set = bke::geometry_set_realize_instances(geometry_set);
-   cast_geometry_set = bke::geometry_set_realize_instances(cast_geometry_set);
+   target_geometry_set = bke::geometry_set_realize_instances(target_geometry_set);
  
 +  AnonymousCustomDataLayerID *hit_id = nullptr;
 +  AnonymousCustomDataLayerID *hit_position_id = nullptr;
 +  AnonymousCustomDataLayerID *hit_normal_id = nullptr;
 +  AnonymousCustomDataLayerID *hit_distance_id = nullptr;
 +  if (params.output_is_required("Is Hit")) {
 +    hit_id = CustomData_anonymous_id_new("Is Hit");
 +  }
 +  if (params.output_is_required("Hit Position")) {
 +    hit_position_id = CustomData_anonymous_id_new("Hit Position");
 +  }
 +  if (params.output_is_required("Hit Normal")) {
 +    hit_normal_id = CustomData_anonymous_id_new("Hit Normal");
 +  }
 +  if (params.output_is_required("Hit Distance")) {
 +    hit_distance_id = CustomData_anonymous_id_new("Hit Distance");
 +  }
 +
    static const Array<GeometryComponentType> types = {
        GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE};
    for (const GeometryComponentType type : types) {
      if (geometry_set.has(type)) {
        raycast_from_points(params,
-                           cast_geometry_set,
+                           target_geometry_set,
                            geometry_set.get_component_for_write(type),
 -                          hit_name,
 -                          hit_position_name,
 -                          hit_normal_name,
 -                          hit_distance_name,
 -                          hit_names,
 -                          hit_output_names);
 +                          hit_id,
 +                          hit_position_id,
 +                          hit_normal_id,
 +                          hit_distance_id,
 +                          hit_attribute_names,
 +                          hit_attribute_output_names);
      }
    }



More information about the Bf-blender-cvs mailing list