29#include "RNA_prototypes.hh"
49 N_(
"Use uniform voxel scale with no translation or rotation")},
54 N_(
"Define grid transform with a matrix")},
55 {0,
nullptr, 0,
nullptr,
nullptr},
63 N_(
"Assign points to the closest voxel")},
68 N_(
"Linear falloff over the voxel range")},
72 N_(
"Quadratic B-Spline"),
73 N_(
"Quadratic b-spline kernel over 1.5 voxels")},
78 N_(
"Cube b-spline kernel over 2 voxels")},
79 {0,
nullptr, 0,
nullptr,
nullptr},
97 b.use_custom_socket_order();
98 b.allow_any_socket_order();
101 b.add_input<
decl::Menu>(
"Grid Transform Mode"_ustr)
106 .description(
"Method of defining the grid transform");
118 .description(
"Kernel function for computing weights at each voxel");
144 auto &input_decl =
b.add_input(input_type,
UString(name),
UString(identifier));
145 input_decl.socket_name_ptr(
147 input_decl.evaluated_geometry_field();
150 .structure_type(StructureType::Grid)
151 .align_with_previous();
154 b.add_input<
decl::Extend>(
""_ustr,
"__extend__"_ustr).structure_type(StructureType::Field);
156 .structure_type(StructureType::Field)
157 .align_with_previous();
163 data->next_identifier = 0;
165 data->items =
nullptr;
180 auto *dst_storage = MEM_new<NodeGeometryRasterizePoints>(__func__,
182 dst_node->
storage = dst_storage;
204 socket_items::ui::draw_items_list_with_operators<RasterizePointsItemsAccessor>(
205 C, panel, ntree,
node);
206 socket_items::ui::draw_active_item_props<RasterizePointsItemsAccessor>(
208 panel->use_property_split_set(
true);
209 panel->use_property_decorate_set(
false);
210 panel->prop(item_ptr,
"type",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
222 "Grid Transform Mode"_ustr);
224 switch (grid_transform_mode) {
262 const int points_num = points_by_component.
total_size();
263 if (points_num == 0) {
278 value_buffers[i] =
GArray<>(attribute_type, points_num);
281 point_rasterize_attributes.
append({item.
name, rasterize_type});
284 for (
const int component_i : component_types.
index_range()) {
285 const GeometryComponent *component = geometry_set.get_component(component_types[component_i]);
286 const IndexRange points = points_by_component[component_i];
296 const GField &field = fields_by_item[i];
302 geometry::MappedPointDataGrid point_data_grid = geometry::points_to_point_data_grid(
303 positions, point_data_grid_attributes, grid_transform);
307 geometry::points_rasterize(point_data_grid,
309 point_rasterize_attributes,
311 output_attribute_grids);
315 if (output_attribute_grids[i]) {
319 const std::string message = fmt::format(
320 fmt::runtime(
TIP_(
"Could not generate grid for \"{}\"")), item.
name);
346 ntype.
ui_name =
"Rasterize Points";
347 ntype.
ui_description =
"Create volume grids from points with a weighted sum";
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define BLI_assert_unreachable()
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
IndexRange index_range() const
GArray(Allocator allocator={}) noexcept
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr IndexRange()=default
void append(const T &value)
int attribute_domain_size(AttrDomain domain) const
int add_with_destination(GField field, GVMutableArray dst)
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
T get_input(const UString identifier) const
const bNode & node() const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
StructureType structure_type
#define storage(slot, qualifiers)
b[1] b &&[1] b &&[1] b &&[1] b &&[1] b[3] b &&[1] b[3] float determinant(MatBase< C, R >) RET
std::optional< eNodeSocketDatatype > geo_nodes_base_cpp_type_to_socket_type(const CPPType &type)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
const CPPType & points_rasterize_grid_type(const PointRasterizeType rasterize_type)
const CPPType & points_rasterize_attribute_type(const PointRasterizeType rasterize_type)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
T determinant(const MatBase< T, Size, Size > &mat)
static void node_layout_ex(ui::Layout &layout, bContext *C, PointerRNA *ptr)
static EnumPropertyItem grid_transform_mode_items[]
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
static void node_geo_exec(GeoNodeExecParams params)
static void node_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
static geometry::PointRasterizeType get_rasterize_item_type(const NodeGeometryRasterizePointsItemType type)
static EnumPropertyItem kernel_type_items[]
static void node_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static void node_free_storage(bNode *node)
static void node_operators()
static void node_copy_storage(bNodeTree *, bNode *dst_node, const bNode *src_node)
static bool node_insert_link(bke::NodeInsertLinkParams ¶ms)
static void node_register()
void make_common_operators()
void blend_write(BlendWriter *writer, const bNode &node)
void destruct_array(bNode &node)
void blend_read_data(BlendDataReader *reader, bNode &node)
void copy_array(const bNode &src_node, bNode &dst_node)
bool try_add_item_via_any_extend_socket(bNodeTree &ntree, bNode &extend_node, bNode &storage_node, bNodeLink &link, const std::optional< StringRef > socket_identifier=std::nullopt, typename Accessor::ItemT **r_new_item=nullptr)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MatBase< float, 4, 4 > float4x4
BMesh const char void * data
bool BKE_volume_grid_determinant_valid(double determinant)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
NodeGeometryRasterizePointsItemType
@ GEO_NODE_RASTERIZE_POINTS_ITEM_TYPE_SCALAR
@ GEO_NODE_RASTERIZE_POINTS_ITEM_TYPE_VECTOR
VecBase< float, 3 > float3
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void write_string(const char *data)
NodeGeometryRasterizePointsItem * items
static constexpr int _200
NodeBlendWriteFunction blend_write_storage_content
void(*) register_operators()
std::string ui_description
NodeBlendDataReadFunction blend_data_read_storage_content
NodeGeometryExecFunction geometry_node_execute
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
void(*) initfunc(bNodeTree *ntree, bNode *node)
NodeDeclareFunction declare
bool(*) insert_link(NodeInsertLinkParams ¶ms)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
NodeGeometryRasterizePointsItem ItemT
static std::string socket_identifier_for_item(const NodeGeometryRasterizePointsItem &item)
static StructRNA ** item_srna
static void blend_write_item(BlendWriter *writer, const ItemT &item)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)