Compare commits
30 Commits
temp-T1019
...
soc-2021-p
Author | SHA1 | Date | |
---|---|---|---|
17438ed193 | |||
933700d902 | |||
74c3ea60bb | |||
a9044edce5 | |||
5405feb818 | |||
ce4420e803 | |||
4bab2cca5d | |||
326d86f23f | |||
17b7cbe975 | |||
94210c3186 | |||
9d2342fd28 | |||
5c79a2953b | |||
7f33ff779f | |||
80870aebd0 | |||
aaee6e13d4 | |||
226ae2e69f | |||
0b654b04cb | |||
e1f9b7442b | |||
7bad25040a | |||
c7a1eeaf7b | |||
b191448bcb | |||
0a75579e1f | |||
80f6798191 | |||
60c84d0a64 | |||
ef0e0af332 | |||
344b59b66c | |||
54a45d1c1b | |||
2f65eed0e7 | |||
ff8ad9b24b | |||
0ddfdb0dbf |
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -19,7 +19,7 @@ if(WITH_AUDASPACE)
|
||||
add_subdirectory(audaspace)
|
||||
endif()
|
||||
|
||||
if(WITH_MOD_REMESH)
|
||||
if(WITH_REMESH_DUALCON)
|
||||
add_subdirectory(dualcon)
|
||||
endif()
|
||||
|
||||
|
@@ -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")
|
||||
|
@@ -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
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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}")
|
||||
|
34
source/blender/geometry/GEO_mesh_remesh_blocks.h
Normal file
34
source/blender/geometry/GEO_mesh_remesh_blocks.h
Normal 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
|
157
source/blender/geometry/intern/remesh_blocks.c
Normal file
157
source/blender/geometry/intern/remesh_blocks.c
Normal 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
|
||||
}
|
@@ -367,6 +367,7 @@ blender_include_dirs(
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
../../draw
|
||||
../../geometry
|
||||
../../gpu
|
||||
../../ikplugin
|
||||
../../imbuf
|
||||
|
@@ -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;
|
||||
|
@@ -113,6 +113,7 @@ set(SRC
|
||||
set(LIB
|
||||
bf_blenkernel
|
||||
bf_blenlib
|
||||
bf_geometry
|
||||
)
|
||||
|
||||
if(WITH_ALEMBIC)
|
||||
|
@@ -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;
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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", "")
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user