Blender
V4.5
source
blender
blenkernel
intern
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
5
#include "
DNA_pointcloud_types.h
"
6
7
#include "
BKE_pointcloud.hh
"
8
9
#include "
attribute_access_intern.hh
"
10
11
namespace
blender::bke
{
12
13
static
void
tag_component_positions_changed
(
void
*owner)
14
{
15
PointCloud
&points = *
static_cast<
PointCloud
*
>
(owner);
16
points.tag_positions_changed();
17
}
18
19
static
void
tag_component_radius_changed
(
void
*owner)
20
{
21
PointCloud
&points = *
static_cast<
PointCloud
*
>
(owner);
22
points.tag_radii_changed();
23
}
24
29
static
GeometryAttributeProviders
create_attribute_providers_for_pointcloud
()
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"
,
46
AttrDomain::Point
,
47
CD_PROP_FLOAT3
,
48
BuiltinAttributeProvider::NonDeletable
,
49
point_access,
50
tag_component_positions_changed
);
51
static
BuiltinCustomDataLayerProvider
radius(
"radius"
,
52
AttrDomain::Point
,
53
CD_PROP_FLOAT
,
54
BuiltinAttributeProvider::Deletable
,
55
point_access,
56
tag_component_radius_changed
);
57
static
BuiltinCustomDataLayerProvider
id
(
"id"
,
58
AttrDomain::Point
,
59
CD_PROP_INT32
,
60
BuiltinAttributeProvider::Deletable
,
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
67
static
AttributeAccessorFunctions
get_pointcloud_accessor_functions
()
68
{
69
static
const
GeometryAttributeProviders
providers =
create_attribute_providers_for_pointcloud
();
70
AttributeAccessorFunctions
fn
=
71
attribute_accessor_functions::accessor_functions_for_providers<providers>
();
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) {
78
case
AttrDomain::Point
:
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
99
const
AttributeAccessorFunctions
&
pointcloud_attribute_accessor_functions
()
100
{
101
static
const
AttributeAccessorFunctions
fn
=
get_pointcloud_accessor_functions
();
102
return
fn
;
103
}
104
105
}
// namespace blender::bke
BKE_pointcloud.hh
General operations for point clouds.
CD_PROP_FLOAT
@ CD_PROP_FLOAT
Definition
DNA_customdata_types.h:113
CD_PROP_FLOAT3
@ CD_PROP_FLOAT3
Definition
DNA_customdata_types.h:166
CD_PROP_INT32
@ CD_PROP_INT32
Definition
DNA_customdata_types.h:114
DNA_pointcloud_types.h
attribute_access_intern.hh
blender::GVArray
Definition
BLI_generic_virtual_array.hh:174
blender::bke::BuiltinAttributeProvider::NonDeletable
@ NonDeletable
Definition
attribute_access_intern.hh:44
blender::bke::BuiltinAttributeProvider::Deletable
@ Deletable
Definition
attribute_access_intern.hh:43
blender::bke::BuiltinCustomDataLayerProvider
Definition
attribute_access_intern.hh:181
blender::bke::CustomDataAttributeProvider
Definition
attribute_access_intern.hh:134
blender::bke::GeometryAttributeProviders
Definition
attribute_access_intern.hh:216
blender::bke::attribute_accessor_functions::accessor_functions_for_providers
AttributeAccessorFunctions accessor_functions_for_providers()
Definition
attribute_access_intern.hh:412
blender::bke::id
Definition
AS_asset_library.hh:27
blender::bke
Definition
AS_asset_library.hh:27
blender::bke::tag_component_positions_changed
static void tag_component_positions_changed(void *owner)
Definition
mesh_attributes.cc:711
blender::bke::AttrDomain
AttrDomain
Definition
BKE_attribute.hh:63
blender::bke::AttrDomain::Point
@ Point
Definition
BKE_attribute.hh:67
blender::bke::create_attribute_providers_for_pointcloud
static GeometryAttributeProviders create_attribute_providers_for_pointcloud()
Definition
pointcloud_attributes.cc:29
blender::bke::tag_component_radius_changed
static void tag_component_radius_changed(void *owner)
Definition
pointcloud_attributes.cc:19
blender::bke::pointcloud_attribute_accessor_functions
const AttributeAccessorFunctions & pointcloud_attribute_accessor_functions()
Definition
pointcloud_attributes.cc:99
blender::bke::get_pointcloud_accessor_functions
static AttributeAccessorFunctions get_pointcloud_accessor_functions()
Definition
pointcloud_attributes.cc:67
blender::fn
Definition
BKE_attribute.hh:27
CustomData
Definition
DNA_customdata_types.h:67
PointCloud
Definition
DNA_pointcloud_types.h:40
PointCloud::totpoint
int totpoint
Definition
DNA_pointcloud_types.h:52
PointCloud::pdata
struct CustomData pdata
Definition
DNA_pointcloud_types.h:61
blender::bke::AttributeAccessorFunctions
Definition
BKE_attribute.hh:495
blender::bke::CustomDataAccessInfo
Definition
attribute_access_intern.hh:22
Generated on
for Blender by
doxygen
1.15.0