Compare commits

...

30 Commits

Author SHA1 Message Date
17438ed193 Changed licencing headers. 2022-02-27 22:48:13 +01:00
933700d902 Changes based on review by
Jacques Lucke (JacquesLucke).
2022-02-20 00:12:38 +01:00
74c3ea60bb Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	source/blender/blenkernel/BKE_node.h
#	source/blender/geometry/CMakeLists.txt
2022-02-18 23:21:11 +01:00
a9044edce5 updated to fields workflow. 2022-01-17 00:19:03 +01:00
5405feb818 Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	release/scripts/startup/nodeitems_builtins.py
#	source/blender/blenkernel/BKE_node.h
#	source/blender/blenkernel/intern/node.cc
#	source/blender/geometry/CMakeLists.txt
#	source/blender/makesrna/intern/rna_nodetree.c
#	source/blender/modifiers/intern/MOD_remesh.c
#	source/blender/nodes/CMakeLists.txt
#	source/blender/nodes/NOD_geometry.h
#	source/blender/nodes/NOD_static_types.h
2022-01-16 21:27:07 +01:00
ce4420e803 Changes based on review by Jacques Lucke
(JacquesLucke)
2021-08-15 09:05:00 +02:00
4bab2cca5d Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	source/blender/blenkernel/BKE_node.h
#	source/blender/modifiers/CMakeLists.txt
2021-08-15 02:10:46 +02:00
326d86f23f Merge remote-tracking branch 'origin/soc-2021-porting-modifiers-to-nodes-remesh-blocks' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc
2021-07-31 00:07:32 +02:00
17b7cbe975 - changes based on Review by Jacques Lucke (JacquesLucke) 2021-07-31 00:06:43 +02:00
94210c3186 - changes based on Review by Jacques Lucke (JacquesLucke) 2021-07-30 23:51:31 +02:00
9d2342fd28 Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks 2021-07-30 21:11:26 +02:00
5c79a2953b changes based on review by Hans Goudey (HooglyBoogly) 2021-07-24 11:38:36 +02:00
7f33ff779f Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks 2021-07-24 11:20:30 +02:00
80870aebd0 added mode selector 2021-07-23 23:23:49 +02:00
aaee6e13d4 Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	source/blender/blenkernel/BKE_node.h
2021-07-23 21:08:25 +02:00
226ae2e69f moved remesh_blocks to geometry module 2021-07-19 00:10:22 +02:00
0b654b04cb Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks 2021-07-16 23:13:48 +02:00
e1f9b7442b cleanup 2021-07-14 00:27:13 +02:00
7bad25040a - renamed WITH_MOD_REMESH to WITH_REMESH_DUALCON
since it is now shared between node and modifier no longer specific to
the modifier.
2021-07-14 00:23:50 +02:00
c7a1eeaf7b Merge remote-tracking branch 'origin/soc-2021-porting-modifiers-to-nodes-remesh-blocks' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	source/blender/nodes/geometry/nodes/node_geo_remesh_blocks.cc
2021-07-13 23:43:22 +02:00
b191448bcb - fixed a bug with mesh renderin points. 2021-07-13 23:42:13 +02:00
0a75579e1f Geometry Nodes: Remesh Blocks
This patch adds a Remesh Blocks node (compared to Remesh Voxel)

It internaly  moves the remesh algorithm,
used in all modes of the Remesh modifier except the Voxel mode to blender kernel
and shares that code with the modifier.

Differential Revision: https://developer.blender.org/D11905
2021-07-13 22:15:37 +02:00
80f6798191 - cleanup 2021-07-13 22:00:23 +02:00
60c84d0a64 Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh-blocks
# Conflicts:
#	source/blender/blenkernel/BKE_node.h
2021-07-13 20:39:12 +02:00
ef0e0af332 - Renamed Remesh to Remesh Block.
- Moved Dualcon Remesh to BKE
- Used new BKE_mesh_remesh_blocks in modifier and node.
2021-07-12 23:55:33 +02:00
344b59b66c Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh
# Conflicts:
#	release/scripts/startup/nodeitems_builtins.py
#	source/blender/blenkernel/BKE_node.h
2021-07-09 23:29:44 +02:00
54a45d1c1b Merge branch 'master' into soc-2021-porting-modifiers-to-nodes-remesh
# Conflicts:
#	source/blender/blenkernel/BKE_node.h
#	source/blender/nodes/NOD_geometry.h
2021-07-05 22:23:42 +02:00
2f65eed0e7 - make initial setup work. 2021-05-27 21:05:39 +02:00
ff8ad9b24b - first impression 2021-05-27 20:32:20 +02:00
0ddfdb0dbf Initial setup for remesh node 2021-05-20 11:01:08 +02:00
22 changed files with 346 additions and 155 deletions

View File

@@ -270,10 +270,11 @@ if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF)
endif()
# Geometry
option(WITH_MOD_REMESH "Enable Remesh Algorithm using Dualcon" ON)
# Modifiers
option(WITH_MOD_FLUID "Enable Mantaflow Fluid Simulation Framework" ON)
option(WITH_MOD_REMESH "Enable Remesh Modifier" ON)
option(WITH_MOD_OCEANSIM "Enable Ocean Modifier" ON)
# Image format support
@@ -2044,7 +2045,7 @@ if(FIRST_RUN)
info_cfg_text("Modifiers:")
info_cfg_option(WITH_MOD_FLUID)
info_cfg_option(WITH_MOD_OCEANSIM)
info_cfg_option(WITH_MOD_REMESH)
info_cfg_option(WITH_REMESH_DUALCON)
info_cfg_text("OpenGL:")
if(WIN32)

View File

@@ -39,7 +39,7 @@ set(WITH_LZMA ON CACHE BOOL "" FORCE)
set(WITH_LZO ON CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID ON CACHE BOOL "" FORCE)
set(WITH_MOD_OCEANSIM ON CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH ON CACHE BOOL "" FORCE)
set(WITH_REMESH_DUALCON ON CACHE BOOL "" FORCE)
set(WITH_NANOVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)

View File

@@ -43,7 +43,7 @@ set(WITH_LZMA OFF CACHE BOOL "" FORCE)
set(WITH_LZO OFF CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID OFF CACHE BOOL "" FORCE)
set(WITH_MOD_OCEANSIM OFF CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH OFF CACHE BOOL "" FORCE)
set(WITH_REMESH_DUALCON OFF CACHE BOOL "" FORCE)
set(WITH_NANOVDB OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)

View File

@@ -40,7 +40,7 @@ set(WITH_LZMA ON CACHE BOOL "" FORCE)
set(WITH_LZO ON CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID ON CACHE BOOL "" FORCE)
set(WITH_MOD_OCEANSIM ON CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH ON CACHE BOOL "" FORCE)
set(WITH_REMESH_DUALCON ON CACHE BOOL "" FORCE)
set(WITH_NANOVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)

View File

@@ -19,7 +19,7 @@ if(WITH_AUDASPACE)
add_subdirectory(audaspace)
endif()
if(WITH_MOD_REMESH)
if(WITH_REMESH_DUALCON)
add_subdirectory(dualcon)
endif()

View File

@@ -131,6 +131,7 @@ def mesh_node_items(context):
yield NodeItem("GeometryNodeMeshBoolean")
yield NodeItem("GeometryNodeMeshToCurve")
yield NodeItem("GeometryNodeMeshToPoints")
yield NodeItem("GeometryNodeRemeshBlocks")
yield NodeItem("GeometryNodeSplitEdges")
yield NodeItem("GeometryNodeSubdivideMesh")
yield NodeItem("GeometryNodeSubdivisionSurface")

View File

@@ -1514,6 +1514,7 @@ struct TexResult;
#define GEO_NODE_SCALE_ELEMENTS 1151
#define GEO_NODE_EXTRUDE_MESH 1152
#define GEO_NODE_MERGE_BY_DISTANCE 1153
#define GEO_NODE_REMESH_BLOCKS 1154
/** \} */

View File

@@ -4832,6 +4832,7 @@ static void registerGeometryNodes()
register_node_type_geo_string_to_curves();
register_node_type_geo_subdivision_surface();
register_node_type_geo_switch();
register_node_type_geo_remesh_blocks();
register_node_type_geo_transfer_attribute();
register_node_type_geo_transform();
register_node_type_geo_translate_instances();

View File

@@ -17,6 +17,7 @@ set(SRC
intern/mesh_merge_by_distance.cc
intern/mesh_to_curve_convert.cc
intern/point_merge_by_distance.cc
intern/remesh_blocks.c
intern/realize_instances.cc
GEO_mesh_merge_by_distance.hh
@@ -42,4 +43,14 @@ if(WITH_TBB)
)
endif()
if(WITH_REMESH_DUALCON)
list(APPEND INC
../../../intern/dualcon
)
list(APPEND LIB
bf_intern_dualcon
)
add_definitions(-DWITH_REMESH_DUALCON)
endif()
blender_add_lib(bf_geometry "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -0,0 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup geo
*/
#ifdef __cplusplus
extern "C" {
#endif
struct Mesh;
typedef enum eRemeshBlocksMode {
/* Blocks. */
REMESH_BLOCKS_CENTROID = 0,
/* Smooth. */
REMESH_BLOCKS_MASS_POINT = 1,
/* Smooth with sharp edges. */
REMESH_BLOCKS_SHARP_FEATURES = 2,
} eRemeshBlocksMode;
struct Mesh *GEO_mesh_remesh_blocks(const struct Mesh *mesh,
const char remesh_flag,
const eRemeshBlocksMode remesh_mode,
const float threshold,
const int hermite_num,
const float scale,
const int depth);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,157 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup geo
*/
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_customdata_types.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BLI_math_vector.h"
#include "BLI_threads.h"
#include "GEO_mesh_remesh_blocks.h" /* own include */
#include "MEM_guardedalloc.h"
#ifdef WITH_REMESH_DUALCON
# include "dualcon.h"
#endif
static void init_dualcon_mesh(DualConInput *input, const Mesh *mesh)
{
memset(input, 0, sizeof(DualConInput));
input->co = (void *)mesh->mvert;
input->co_stride = sizeof(MVert);
input->totco = mesh->totvert;
input->mloop = (void *)mesh->mloop;
input->loop_stride = sizeof(MLoop);
BKE_mesh_runtime_looptri_ensure(mesh);
input->looptri = (void *)mesh->runtime.looptris.array;
input->tri_stride = sizeof(MLoopTri);
input->tottri = mesh->runtime.looptris.len;
INIT_MINMAX(input->min, input->max);
BKE_mesh_minmax(mesh, input->min, input->max);
}
/* Simple structure to hold the output: a CDDM and two counters to
* keep track of the current elements. */
typedef struct {
Mesh *mesh;
int curvert, curface;
} DualConOutput;
/* Allocate and initialize a DualConOutput. */
static void *dualcon_alloc_output(int totvert, int totquad)
{
DualConOutput *output;
if (!(output = MEM_callocN(sizeof(DualConOutput), "DualConOutput"))) {
return NULL;
}
output->mesh = BKE_mesh_new_nomain(totvert, 0, 0, 4 * totquad, totquad);
return output;
}
static void dualcon_add_vert(void *output_v, const float co[3])
{
DualConOutput *output = output_v;
Mesh *mesh = output->mesh;
BLI_assert(output->curvert < mesh->totvert);
copy_v3_v3(mesh->mvert[output->curvert].co, co);
output->curvert++;
}
static void dualcon_add_quad(void *output_v, const int vert_indices[4])
{
DualConOutput *output = output_v;
Mesh *mesh = output->mesh;
MLoop *mloop;
MPoly *cur_poly;
int i;
BLI_assert(output->curface < mesh->totpoly);
mloop = mesh->mloop;
cur_poly = &mesh->mpoly[output->curface];
cur_poly->loopstart = output->curface * 4;
cur_poly->totloop = 4;
for (i = 0; i < 4; i++) {
mloop[output->curface * 4 + i].v = vert_indices[i];
}
output->curface++;
}
Mesh *GEO_mesh_remesh_blocks(const Mesh *mesh,
const char remesh_flag,
const eRemeshBlocksMode remesh_mode,
const float threshold,
const int hermite_num,
const float scale,
const int depth)
{
#ifdef WITH_REMESH_DUALCON
DualConOutput *output;
DualConInput input;
Mesh *result;
DualConFlags flags = 0;
DualConMode mode = 0;
/* Dualcon modes. */
init_dualcon_mesh(&input, mesh);
if (remesh_flag & MOD_REMESH_FLOOD_FILL) {
flags |= DUALCON_FLOOD_FILL;
}
switch (remesh_mode) {
case REMESH_BLOCKS_CENTROID:
mode = DUALCON_CENTROID;
break;
case REMESH_BLOCKS_MASS_POINT:
mode = DUALCON_MASS_POINT;
break;
case REMESH_BLOCKS_SHARP_FEATURES:
mode = DUALCON_SHARP_FEATURES;
break;
}
/* TODO(jbakker): Dualcon crashes when run in parallel. Could be related to incorrect
* input data or that the library isn't thread safe.
* This was identified when changing the task isolation's during T76553. */
static ThreadMutex dualcon_mutex = BLI_MUTEX_INITIALIZER;
BLI_mutex_lock(&dualcon_mutex);
output = dualcon(&input,
dualcon_alloc_output,
dualcon_add_vert,
dualcon_add_quad,
flags,
mode,
threshold,
hermite_num,
scale,
depth);
BLI_mutex_unlock(&dualcon_mutex);
result = output->mesh;
MEM_freeN(output);
return result;
#else
return BKE_mesh_new_nomain(0,0,0,0,0);
#endif
}

View File

@@ -367,6 +367,7 @@ blender_include_dirs(
../../bmesh
../../depsgraph
../../draw
../../geometry
../../gpu
../../ikplugin
../../imbuf

View File

@@ -31,6 +31,8 @@
#include "BKE_node_tree_update.h"
#include "BKE_texture.h"
#include "GEO_mesh_remesh_blocks.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -9560,6 +9562,30 @@ static void def_geo_subdivision_surface(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_geo_remesh_blocks(StructRNA *srna)
{
static const EnumPropertyItem remesh_mode_items[] = {
{REMESH_BLOCKS_CENTROID, "BLOCKS", 0, "Blocks", "Output a blocky surface with no smoothing"},
{REMESH_BLOCKS_MASS_POINT,
"SMOOTH",
0,
"Smooth",
"Output a smooth surface with no sharp-features detection"},
{REMESH_BLOCKS_SHARP_FEATURES,
"SHARP",
0,
"Sharp",
"Output a surface that reproduces sharp edges and corners from the input mesh"},
{0, NULL, 0, NULL, NULL},
};
PropertyRNA *prop = RNA_def_property(srna, "remesh_blocks_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, remesh_mode_items);
RNA_def_property_ui_text(prop, "Mode", "Mesh smoothing mode for remesh operation");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_geo_accumulate_field(StructRNA *srna)
{
PropertyRNA *prop;

View File

@@ -113,6 +113,7 @@ set(SRC
set(LIB
bf_blenkernel
bf_blenlib
bf_geometry
)
if(WITH_ALEMBIC)

View File

@@ -5,15 +5,8 @@
* \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
#include "BLI_threads.h"
#include "BLT_translation.h"
#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -24,9 +17,10 @@
#include "BKE_context.h"
#include "BKE_mesh.h"
#include "BKE_mesh_remesh_voxel.h"
#include "BKE_mesh_runtime.h"
#include "BKE_screen.h"
#include "GEO_mesh_remesh_blocks.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -35,15 +29,8 @@
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
#include <stdlib.h>
#include <string.h>
#ifdef WITH_MOD_REMESH
# include "BLI_math_vector.h"
# include "dualcon.h"
#endif
static void initData(ModifierData *md)
{
RemeshModifierData *rmd = (RemeshModifierData *)md;
@@ -53,89 +40,10 @@ static void initData(ModifierData *md)
MEMCPY_STRUCT_AFTER(rmd, DNA_struct_default_get(RemeshModifierData), modifier);
}
#ifdef WITH_MOD_REMESH
static void init_dualcon_mesh(DualConInput *input, Mesh *mesh)
{
memset(input, 0, sizeof(DualConInput));
input->co = (void *)mesh->mvert;
input->co_stride = sizeof(MVert);
input->totco = mesh->totvert;
input->mloop = (void *)mesh->mloop;
input->loop_stride = sizeof(MLoop);
BKE_mesh_runtime_looptri_ensure(mesh);
input->looptri = (void *)mesh->runtime.looptris.array;
input->tri_stride = sizeof(MLoopTri);
input->tottri = mesh->runtime.looptris.len;
INIT_MINMAX(input->min, input->max);
BKE_mesh_minmax(mesh, input->min, input->max);
}
/* simple structure to hold the output: a CDDM and two counters to
* keep track of the current elements */
typedef struct {
Mesh *mesh;
int curvert, curface;
} DualConOutput;
/* allocate and initialize a DualConOutput */
static void *dualcon_alloc_output(int totvert, int totquad)
{
DualConOutput *output;
if (!(output = MEM_callocN(sizeof(DualConOutput), "DualConOutput"))) {
return NULL;
}
output->mesh = BKE_mesh_new_nomain(totvert, 0, 0, 4 * totquad, totquad);
return output;
}
static void dualcon_add_vert(void *output_v, const float co[3])
{
DualConOutput *output = output_v;
Mesh *mesh = output->mesh;
BLI_assert(output->curvert < mesh->totvert);
copy_v3_v3(mesh->mvert[output->curvert].co, co);
output->curvert++;
}
static void dualcon_add_quad(void *output_v, const int vert_indices[4])
{
DualConOutput *output = output_v;
Mesh *mesh = output->mesh;
MLoop *mloop;
MPoly *cur_poly;
int i;
BLI_assert(output->curface < mesh->totpoly);
mloop = mesh->mloop;
cur_poly = &mesh->mpoly[output->curface];
cur_poly->loopstart = output->curface * 4;
cur_poly->totloop = 4;
for (i = 0; i < 4; i++) {
mloop[output->curface * 4 + i].v = vert_indices[i];
}
output->curface++;
}
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
{
RemeshModifierData *rmd;
DualConOutput *output;
DualConInput input;
Mesh *result;
DualConFlags flags = 0;
DualConMode mode = 0;
rmd = (RemeshModifierData *)md;
@@ -150,47 +58,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
}
}
else {
/* Dualcon modes. */
init_dualcon_mesh(&input, mesh);
if (rmd->flag & MOD_REMESH_FLOOD_FILL) {
flags |= DUALCON_FLOOD_FILL;
}
switch (rmd->mode) {
case MOD_REMESH_CENTROID:
mode = DUALCON_CENTROID;
break;
case MOD_REMESH_MASS_POINT:
mode = DUALCON_MASS_POINT;
break;
case MOD_REMESH_SHARP_FEATURES:
mode = DUALCON_SHARP_FEATURES;
break;
case MOD_REMESH_VOXEL:
/* Should have been processed before as an OpenVDB operation. */
BLI_assert(false);
break;
}
/* TODO(jbakker): Dualcon crashes when run in parallel. Could be related to incorrect
* input data or that the library isn't thread safe.
* This was identified when changing the task isolation's during T76553. */
static ThreadMutex dualcon_mutex = BLI_MUTEX_INITIALIZER;
BLI_mutex_lock(&dualcon_mutex);
output = dualcon(&input,
dualcon_alloc_output,
dualcon_add_vert,
dualcon_add_quad,
flags,
mode,
rmd->threshold,
rmd->hermite_num,
rmd->scale,
rmd->depth);
BLI_mutex_unlock(&dualcon_mutex);
result = output->mesh;
MEM_freeN(output);
result = GEO_mesh_remesh_blocks(
mesh, rmd->flag, rmd->mode, rmd->threshold, rmd->hermite_num, rmd->scale, rmd->depth);
}
if (rmd->flag & MOD_REMESH_SMOOTH_SHADING) {
@@ -209,17 +78,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
return result;
}
#else /* !WITH_MOD_REMESH */
static Mesh *modifyMesh(ModifierData *UNUSED(md),
const ModifierEvalContext *UNUSED(ctx),
Mesh *mesh)
{
return mesh;
}
#endif /* !WITH_MOD_REMESH */
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;

View File

@@ -153,9 +153,16 @@ if(WITH_GMP)
endif()
if(WITH_OPENVDB)
list(APPEND INC
../../../intern/openvdb
)
list(APPEND INC_SYS
${OPENVDB_INCLUDE_DIRS}
)
list(APPEND LIB
bf_intern_openvdb
${OPENVDB_LIBRARIES}
)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
endif()

View File

@@ -142,6 +142,7 @@ void register_node_type_geo_points_to_volume(void);
void register_node_type_geo_proximity(void);
void register_node_type_geo_raycast(void);
void register_node_type_geo_realize_instances(void);
void register_node_type_geo_remesh_blocks(void);
void register_node_type_geo_rotate_instances(void);
void register_node_type_geo_sample_texture(void);
void register_node_type_geo_scale_elements(void);

View File

@@ -420,6 +420,7 @@ DefNode(GeometryNode, GEO_NODE_SUBDIVIDE_CURVE, 0, "SUBDIVIDE_CURVE", SubdivideC
DefNode(GeometryNode, GEO_NODE_SUBDIVIDE_MESH, 0, "SUBDIVIDE_MESH", SubdivideMesh, "Subdivide Mesh", "")
DefNode(GeometryNode, GEO_NODE_SUBDIVISION_SURFACE, def_geo_subdivision_surface, "SUBDIVISION_SURFACE", SubdivisionSurface, "Subdivision Surface", "")
DefNode(GeometryNode, GEO_NODE_SWITCH, def_geo_switch, "SWITCH", Switch, "Switch", "")
DefNode(GeometryNode, GEO_NODE_REMESH_BLOCKS, def_geo_remesh_blocks, "REMESH_BLOCKS", RemeshBlocks, "Remesh Blocks", "")
DefNode(GeometryNode, GEO_NODE_TRANSFER_ATTRIBUTE, def_geo_transfer_attribute, "ATTRIBUTE_TRANSFER", AttributeTransfer, "Transfer Attribute", "")
DefNode(GeometryNode, GEO_NODE_TRANSFORM, 0, "TRANSFORM", Transform, "Transform", "")
DefNode(GeometryNode, GEO_NODE_TRANSLATE_INSTANCES, 0, "TRANSLATE_INSTANCES", TranslateInstances, "Translate Instances", "")

View File

@@ -151,6 +151,7 @@ set(SRC
nodes/node_geo_points_to_volume.cc
nodes/node_geo_proximity.cc
nodes/node_geo_raycast.cc
nodes/node_geo_remesh_blocks.cc
nodes/node_geo_realize_instances.cc
nodes/node_geo_rotate_instances.cc
nodes/node_geo_scale_elements.cc

View File

@@ -0,0 +1,89 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BKE_mesh.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "GEO_mesh_remesh_blocks.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_remesh_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Geometry>(N_("Mesh")).supported_type(GEO_COMPONENT_TYPE_MESH);
b.add_input<decl::Int>(N_("Depth"))
.description("Resolution of the octree. Higher values give finer details.")
.default_value(4)
.min(2)
.max(64);
b.add_input<decl::Float>(N_("Scale"))
.description("The ratio of the largest dimension of the model over the size of the grid")
.default_value(0.9f)
.min(0.0f)
.max(0.99f);
b.add_input<decl::Float>(N_("Threshold"))
.description(
"When removing disconnected pieces, minimum size of components to preserve as a ratio "
"of the number of polygons in the largest component")
.default_value(1.0f)
.min(0.01f)
.max(FLT_MAX);
b.add_output<decl::Geometry>(N_("Mesh"));
}
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "remesh_blocks_mode", 0, "", ICON_NONE);
}
static void geo_remesh_blocks_init(bNodeTree *UNUSED(ntree), bNode *node)
{
node->custom1 = 0;
}
static void node_geo_exec(GeoNodeExecParams params)
{
GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh");
const char flag = 0;
const eRemeshBlocksMode mode = static_cast<eRemeshBlocksMode>(params.node().custom1);
const int hermite_num = 1;
const int depth = params.extract_input<int>("Depth");
const float scale = min_ff(params.extract_input<float>("Scale"), 0.99f);
const float threshold = params.extract_input<float>("Threshold");
if (geometry_set.has_mesh()) {
const Mesh *input_mesh = geometry_set.get_mesh_for_read();
Mesh *output_mesh = GEO_mesh_remesh_blocks(
input_mesh, flag, mode, threshold, hermite_num, scale, depth);
BKE_mesh_copy_parameters_for_eval(output_mesh, input_mesh);
BKE_mesh_calc_edges(output_mesh, true, false);
BKE_mesh_normals_tag_dirty(output_mesh);
geometry_set.replace_mesh(output_mesh);
}
params.set_output("Mesh", std::move(geometry_set));
}
} // namespace blender::nodes::node_geo_remesh_cc
void register_node_type_geo_remesh_blocks()
{
namespace file_ns = blender::nodes::node_geo_remesh_cc;
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_REMESH_BLOCKS, "Remesh Blocks", NODE_CLASS_GEOMETRY);
ntype.declare = file_ns::node_declare;
node_type_init(&ntype, file_ns::geo_remesh_blocks_init);
ntype.geometry_node_execute = file_ns::node_geo_exec;
ntype.draw_buttons = file_ns::node_layout;
nodeRegisterType(&ntype);
}

View File

@@ -285,8 +285,8 @@ if(WITH_MOD_OCEANSIM)
add_definitions(-DWITH_OCEANSIM)
endif()
if(WITH_MOD_REMESH)
add_definitions(-DWITH_MOD_REMESH)
if(WITH_REMESH_DUALCON)
add_definitions(-DWITH_REMESH_DUALCON)
endif()
if(WITH_MOD_FLUID)

View File

@@ -239,7 +239,7 @@ static PyObject *make_builtopts_info(void)
SetObjIncref(Py_False);
#endif
#ifdef WITH_MOD_REMESH
#ifdef WITH_REMESH_DUALCON
SetObjIncref(Py_True);
#else
SetObjIncref(Py_False);