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 16:39:10 +0300
committerHans Goudey <h.goudey@me.com>2021-10-19 16:39:10 +0300
commit219058c213d5c9efce3f44216f6513edc93b5536 (patch)
tree26b76ae133b36d41c9a90d43eaa29ebf2b943c5a /source/blender/blenkernel/intern/geometry_set_instances.cc
parentcd36f59027042ff0f2ad53e98088428a4c0c5e38 (diff)
Geometry Nodes: Remove implicit realizing and conversion
This commit removes the implicit conversion from points to a mesh that used to happen before the next modifier. It also removes the implicit realizing of instances that happened before another modifier. Now we have specific nodes for both of these operations, the implicit conversions make less sense, and implicit instance realizing has already been removed in other nodes. This adds another geometry nodes modifier before modifiers that would have realized instances implicitly before. Currently adding another data-block during versioning after linking means that an assert needs to be changed. That should be made unnecessary by T92333. Differential Revision: https://developer.blender.org/D12722
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_set_instances.cc')
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc66
1 files changed, 9 insertions, 57 deletions
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index d92df386575..35c6a7df2c7 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -224,8 +224,7 @@ void geometry_set_gather_instances_attribute_info(Span<GeometryInstanceGroup> se
}
}
-static Mesh *join_mesh_topology_and_builtin_attributes(Span<GeometryInstanceGroup> set_groups,
- const bool convert_points_to_vertices)
+static Mesh *join_mesh_topology_and_builtin_attributes(Span<GeometryInstanceGroup> set_groups)
{
int totverts = 0;
int totloops = 0;
@@ -255,10 +254,6 @@ static Mesh *join_mesh_topology_and_builtin_attributes(Span<GeometryInstanceGrou
materials.add(material);
}
}
- if (convert_points_to_vertices && set.has_pointcloud()) {
- const PointCloud &pointcloud = *set.get_pointcloud_for_read();
- totverts += pointcloud.totpoint * tot_transforms;
- }
}
/* Don't create an empty mesh. */
@@ -345,24 +340,6 @@ static Mesh *join_mesh_topology_and_builtin_attributes(Span<GeometryInstanceGrou
poly_offset += mesh.totpoly;
}
}
-
- const float3 point_normal{0.0f, 0.0f, 1.0f};
- short point_normal_short[3];
- normal_float_to_short_v3(point_normal_short, point_normal);
-
- if (convert_points_to_vertices && set.has_pointcloud()) {
- const PointCloud &pointcloud = *set.get_pointcloud_for_read();
- for (const float4x4 &transform : set_group.transforms) {
- for (const int i : IndexRange(pointcloud.totpoint)) {
- MVert &new_vert = new_mesh->mvert[vert_offset + i];
- const float3 old_position = pointcloud.co[i];
- const float3 new_position = transform * old_position;
- copy_v3_v3(new_vert.co, new_position);
- memcpy(&new_vert.no, point_normal_short, sizeof(point_normal_short));
- }
- vert_offset += pointcloud.totpoint;
- }
- }
}
/* A possible optimization is to only tag the normals dirty when there are transforms that change
@@ -495,12 +472,9 @@ static CurveEval *join_curve_splines_and_builtin_attributes(Span<GeometryInstanc
return new_curve;
}
-static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups,
- bool convert_points_to_vertices,
- GeometrySet &result)
+static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups, GeometrySet &result)
{
- Mesh *new_mesh = join_mesh_topology_and_builtin_attributes(set_groups,
- convert_points_to_vertices);
+ Mesh *new_mesh = join_mesh_topology_and_builtin_attributes(set_groups);
if (new_mesh == nullptr) {
return;
}
@@ -508,21 +482,17 @@ static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups,
MeshComponent &dst_component = result.get_component_for_write<MeshComponent>();
dst_component.replace(new_mesh);
- Vector<GeometryComponentType> component_types;
- component_types.append(GEO_COMPONENT_TYPE_MESH);
- if (convert_points_to_vertices) {
- component_types.append(GEO_COMPONENT_TYPE_POINT_CLOUD);
- }
-
/* Don't copy attributes that are stored directly in the mesh data structs. */
Map<AttributeIDRef, AttributeKind> attributes;
geometry_set_gather_instances_attribute_info(
set_groups,
- component_types,
+ {GEO_COMPONENT_TYPE_MESH},
{"position", "material_index", "normal", "shade_smooth", "crease"},
attributes);
- join_attributes(
- set_groups, component_types, attributes, static_cast<GeometryComponent &>(dst_component));
+ join_attributes(set_groups,
+ {GEO_COMPONENT_TYPE_MESH},
+ attributes,
+ static_cast<GeometryComponent &>(dst_component));
}
static void join_instance_groups_pointcloud(Span<GeometryInstanceGroup> set_groups,
@@ -582,24 +552,6 @@ static void join_instance_groups_curve(Span<GeometryInstanceGroup> set_groups, G
static_cast<GeometryComponent &>(dst_component));
}
-GeometrySet geometry_set_realize_mesh_for_modifier(const GeometrySet &geometry_set)
-{
- if (!geometry_set.has_instances() && !geometry_set.has_pointcloud()) {
- return geometry_set;
- }
-
- GeometrySet new_geometry_set = geometry_set;
- Vector<GeometryInstanceGroup> set_groups;
- geometry_set_gather_instances(geometry_set, set_groups);
- join_instance_groups_mesh(set_groups, true, new_geometry_set);
- /* Remove all instances, even though some might contain other non-mesh data. We can't really
- * keep only non-mesh instances in general. */
- new_geometry_set.remove<InstancesComponent>();
- /* If there was a point cloud, it is now part of the mesh. */
- new_geometry_set.remove<PointCloudComponent>();
- return new_geometry_set;
-}
-
GeometrySet geometry_set_realize_instances(const GeometrySet &geometry_set)
{
if (!geometry_set.has_instances()) {
@@ -610,7 +562,7 @@ GeometrySet geometry_set_realize_instances(const GeometrySet &geometry_set)
Vector<GeometryInstanceGroup> set_groups;
geometry_set_gather_instances(geometry_set, set_groups);
- join_instance_groups_mesh(set_groups, false, new_geometry_set);
+ join_instance_groups_mesh(set_groups, new_geometry_set);
join_instance_groups_pointcloud(set_groups, new_geometry_set);
join_instance_groups_volume(set_groups, new_geometry_set);
join_instance_groups_curve(set_groups, new_geometry_set);