Blender V4.5
pointcloud_attributes.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
7#include "BKE_pointcloud.hh"
8
10
11namespace blender::bke {
12
13static void tag_component_positions_changed(void *owner)
14{
15 PointCloud &points = *static_cast<PointCloud *>(owner);
16 points.tag_positions_changed();
17}
18
19static void tag_component_radius_changed(void *owner)
20{
21 PointCloud &points = *static_cast<PointCloud *>(owner);
22 points.tag_radii_changed();
23}
24
30{
31 static CustomDataAccessInfo point_access = {
32 [](void *owner) -> CustomData * {
33 PointCloud *pointcloud = static_cast<PointCloud *>(owner);
34 return &pointcloud->pdata;
35 },
36 [](const void *owner) -> const CustomData * {
37 const PointCloud *pointcloud = static_cast<const PointCloud *>(owner);
38 return &pointcloud->pdata;
39 },
40 [](const void *owner) -> int {
41 const PointCloud *pointcloud = static_cast<const PointCloud *>(owner);
42 return pointcloud->totpoint;
43 }};
44
45 static BuiltinCustomDataLayerProvider position("position",
49 point_access,
51 static BuiltinCustomDataLayerProvider radius("radius",
55 point_access,
61 point_access,
62 nullptr);
63 static CustomDataAttributeProvider point_custom_data(AttrDomain::Point, point_access);
64 return GeometryAttributeProviders({&position, &radius, &id}, {&point_custom_data});
65}
66
68{
72 fn.domain_size = [](const void *owner, const AttrDomain domain) {
73 if (owner == nullptr) {
74 return 0;
75 }
76 const PointCloud &pointcloud = *static_cast<const PointCloud *>(owner);
77 switch (domain) {
79 return pointcloud.totpoint;
80 default:
81 return 0;
82 }
83 };
84 fn.domain_supported = [](const void * /*owner*/, const AttrDomain domain) {
85 return domain == AttrDomain::Point;
86 };
87 fn.adapt_domain = [](const void * /*owner*/,
88 const GVArray &varray,
89 const AttrDomain from_domain,
90 const AttrDomain to_domain) {
91 if (from_domain == to_domain && from_domain == AttrDomain::Point) {
92 return varray;
93 }
94 return GVArray{};
95 };
96 return fn;
97}
98
104
105} // namespace blender::bke
General operations for point clouds.
@ CD_PROP_FLOAT
@ CD_PROP_FLOAT3
@ CD_PROP_INT32
AttributeAccessorFunctions accessor_functions_for_providers()
static void tag_component_positions_changed(void *owner)
static GeometryAttributeProviders create_attribute_providers_for_pointcloud()
static void tag_component_radius_changed(void *owner)
const AttributeAccessorFunctions & pointcloud_attribute_accessor_functions()
static AttributeAccessorFunctions get_pointcloud_accessor_functions()
struct CustomData pdata