19 # include <openvdb/tools/GridTransformer.h>
20 # include <openvdb/tools/VolumeToMesh.h>
41 {
SOCK_FLOAT,
N_(
"Voxel Amount"), 64.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
42 {
SOCK_FLOAT,
N_(
"Threshold"), 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
88 static void create_mesh_from_volume(
GeometrySet &geometry_set_in,
99 bke::VolumeToMeshResolution resolution;
102 resolution.settings.voxel_amount =
params.get_input<
float>(
"Voxel Amount");
103 if (resolution.settings.voxel_amount <= 0.0f) {
108 resolution.settings.voxel_size =
params.get_input<
float>(
"Voxel Size");
109 if (resolution.settings.voxel_size <= 0.0f) {
116 if (volume ==
nullptr) {
123 const std::string grid_name =
params.get_input<std::string>(
"Density");
125 if (volume_grid ==
nullptr) {
129 float threshold =
params.get_input<
float>(
"Threshold");
130 float adaptivity =
params.get_input<
float>(
"Adaptivity");
132 const openvdb::GridBase::ConstPtr grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
133 Mesh *
mesh = bke::volume_to_mesh(*grid, resolution, threshold, adaptivity);
134 if (
mesh ==
nullptr) {
149 create_mesh_from_volume(geometry_set_in, geometry_set_out,
params);
152 params.set_output(
"Geometry", geometry_set_out);
void nodeSetSocketAvailability(struct bNodeSocket *sock, bool is_available)
void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth)
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
#define NODE_CLASS_GEOMETRY
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
struct bNodeSocket * nodeFindSocket(const struct bNode *node, eNodeSocketInOut in_out, const char *identifier)
void nodeRegisterType(struct bNodeType *ntype)
#define GEO_NODE_VOLUME_TO_MESH
const VolumeGrid * BKE_volume_grid_find_for_read(const struct Volume *volume, const char *name)
bool BKE_volume_load(const struct Volume *volume, const struct Main *bmain)
#define STRNCPY(dst, src)
static uint8 component(Color32 c, uint i)
struct Main * DEG_get_bmain(const Depsgraph *graph)
VolumeToMeshResolutionMode
@ VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE
@ VOLUME_TO_MESH_RESOLUTION_MODE_GRID
@ VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void replace(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void *(* MEM_callocN)(size_t len, const char *str)
static void geo_node_volume_to_mesh_init(bNodeTree *UNUSED(ntree), bNode *node)
static void geo_node_volume_to_mesh_update(bNodeTree *UNUSED(ntree), bNode *node)
static void geo_node_volume_to_mesh_exec(GeoNodeExecParams params)
static bNodeSocketTemplate geo_node_volume_to_mesh_out[]
void register_node_type_geo_volume_to_mesh()
static bNodeSocketTemplate geo_node_volume_to_mesh_in[]
static void geo_node_volume_to_mesh_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
bool has(const GeometryComponentType component_type) const
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
Compact definition of a node socket.
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)