5 # include <openvdb/tools/GridTransformer.h>
6 # include <openvdb/tools/VolumeToMesh.h>
46 .
description(
N_(
"Values larger than the threshold are inside the generated mesh"));
98 static Mesh *create_mesh_from_volume_grids(Span<openvdb::GridBase::ConstPtr> grids,
100 const float adaptivity,
101 const bke::VolumeToMeshResolution &resolution)
103 Array<bke::OpenVDBMeshData> mesh_data(grids.size());
104 for (
const int i : grids.index_range()) {
105 mesh_data[i] = bke::volume_to_mesh_data(*grids[i], resolution,
threshold, adaptivity);
111 Array<int> vert_offsets(mesh_data.size());
112 Array<int> poly_offsets(mesh_data.size());
113 Array<int> loop_offsets(mesh_data.size());
114 for (
const int i : grids.index_range()) {
115 const bke::OpenVDBMeshData &
data = mesh_data[i];
116 vert_offsets[i] = vert_offset;
117 poly_offsets[i] = poly_offset;
118 loop_offsets[i] = loop_offset;
119 vert_offset +=
data.verts.size();
120 poly_offset += (
data.tris.size() +
data.quads.size());
121 loop_offset += (3 *
data.tris.size() + 4 *
data.quads.size());
130 for (
const int i : grids.index_range()) {
131 const bke::OpenVDBMeshData &
data = mesh_data[i];
132 bke::fill_mesh_from_openvdb_data(
data.verts,
151 if (volume ==
nullptr) {
155 const bke::VolumeToMeshResolution resolution = get_resolution_param(
params);
158 resolution.settings.voxel_size <= 0.0f) {
162 resolution.settings.voxel_amount <= 0) {
169 Vector<openvdb::GridBase::ConstPtr> grids;
172 openvdb::GridBase::ConstPtr grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid);
173 grids.append(std::move(grid));
176 if (grids.is_empty()) {
180 return create_mesh_from_volume_grids(grids,
181 params.get_input<
float>(
"Threshold"),
182 params.get_input<
float>(
"Adaptivity"),
199 params.error_message_add(NodeWarningType::Error,
200 TIP_(
"Disabled, Blender was compiled without OpenVDB"));
203 params.set_output(
"Mesh", std::move(geometry_set));
@ GEO_COMPONENT_TYPE_MESH
@ GEO_COMPONENT_TYPE_VOLUME
General operations, lookup, etc. for materials.
void BKE_id_material_eval_ensure_default_slot(struct ID *id)
struct Mesh * BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, bool select_new_edges)
void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth)
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
#define NODE_STORAGE_FUNCS(StorageT)
void nodeSetSocketAvailability(struct bNodeTree *ntree, struct bNodeSocket *sock, bool is_available)
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_get_for_read(const struct Volume *volume, int grid_index)
int BKE_volume_num_grids(const struct Volume *volume)
bool BKE_volume_load(const struct Volume *volume, const struct Main *bmain)
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 make_available(bNode &node) const
StringRefNull description() const
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
static void node_declare(NodeDeclarationBuilder &b)
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_geo_exec(GeoNodeExecParams params)
static void node_init(bNodeTree *UNUSED(ntree), bNode *node)
static void node_update(bNodeTree *ntree, bNode *node)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
void register_node_type_geo_volume_to_mesh()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const Volume * get_volume_for_read() const
void keep_only_during_modify(const blender::Span< GeometryComponentType > component_types)
void modify_geometry_sets(ForeachSubGeometryCallback callback)
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
NodeDeclareFunction declare
union blender::bke::VolumeToMeshResolution::@78 settings
VolumeToMeshResolutionMode mode