Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_set_instances.cc
| Show First 20 Lines • Show All 559 Lines • ▼ Show 20 Lines | if (set.has<PointCloudComponent>()) { | ||||
| totpoint += component.attribute_domain_size(ATTR_DOMAIN_POINT); | totpoint += component.attribute_domain_size(ATTR_DOMAIN_POINT); | ||||
| } | } | ||||
| } | } | ||||
| if (totpoint == 0) { | if (totpoint == 0) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| PointCloud *new_pointcloud = BKE_pointcloud_new_nomain(totpoint); | PointCloud *new_pointcloud = BKE_pointcloud_new_nomain(totpoint); | ||||
| MutableSpan new_positions{(float3 *)new_pointcloud->co, new_pointcloud->totpoint}; | |||||
| /* Transform each instance's point locations into the new point cloud. */ | /* Transform each instance's point locations into the new point cloud. */ | ||||
| int offset = 0; | int offset = 0; | ||||
| for (const GeometryInstanceGroup &set_group : set_groups) { | for (const GeometryInstanceGroup &set_group : set_groups) { | ||||
| const GeometrySet &set = set_group.geometry_set; | const GeometrySet &set = set_group.geometry_set; | ||||
| const PointCloud *pointcloud = set.get_pointcloud_for_read(); | const PointCloud *pointcloud = set.get_pointcloud_for_read(); | ||||
| if (pointcloud == nullptr) { | if (pointcloud == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| for (const float4x4 &transform : set_group.transforms) { | for (const float4x4 &transform : set_group.transforms) { | ||||
| for (const int i : IndexRange(pointcloud->totpoint)) { | for (const int i : IndexRange(pointcloud->totpoint)) { | ||||
| const float3 old_position = pointcloud->co[i]; | new_positions[offset + i] = transform * float3(pointcloud->co[i]); | ||||
| const float3 new_position = transform * old_position; | |||||
| copy_v3_v3(new_pointcloud->co[offset + i], new_position); | |||||
| } | } | ||||
| offset += pointcloud->totpoint; | offset += pointcloud->totpoint; | ||||
| } | } | ||||
| } | } | ||||
| return new_pointcloud; | return new_pointcloud; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines | |||||