From f7832b1583cd13bde182192bce358db3062a0547 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 19 Oct 2020 12:11:38 +0200 Subject: Volumes: new Volume to Mesh modifier This modifier is the opposite of the recently added Mesh to Volume modifier. It converts the "surface" of a volume into a mesh. The "surface" is defined by a threshold value. All voxels with a density higher than the threshold are considered to be inside the volume, while all others will be outside. By default, the resolution of the generated mesh depends on the voxel size of the volume grid. The resolution can be customized. It should be noted that a lower resolution might not make this modifier faster. This is because we have to downsample the openvdb grid, which isn't a cheap operation. Converting a mesh to a volume and then back to a mesh is possible, but it does require two separate mesh objects for now. Reviewers: brecht Differential Revision: https://developer.blender.org/D9141 --- source/blender/makesdna/DNA_modifier_types.h | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source/blender/makesdna') diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 7a13b9f4852..34d2c80dc5d 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -97,6 +97,7 @@ typedef enum ModifierType { eModifierType_Simulation = 57, eModifierType_MeshToVolume = 58, eModifierType_VolumeDisplace = 59, + eModifierType_VolumeToMesh = 60, NUM_MODIFIER_TYPES, } ModifierType; @@ -2275,6 +2276,39 @@ enum { MOD_VOLUME_DISPLACE_MAP_OBJECT = 2, }; +typedef struct VolumeToMeshModifierData { + ModifierData modifier; + + /** This is the volume object that is supposed to be converted to a mesh. */ + struct Object *object; + + float threshold; + float adaptivity; + + /** VolumeToMeshFlag */ + uint32_t flag; + + /** VolumeToMeshResolutionMode */ + int resolution_mode; + float voxel_size; + int voxel_amount; + + /** MAX_NAME */ + char grid_name[64]; +} VolumeToMeshModifierData; + +/** VolumeToMeshModifierData->resolution_mode */ +typedef enum VolumeToMeshResolutionMode { + VOLUME_TO_MESH_RESOLUTION_MODE_GRID = 0, + VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT = 1, + VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE = 2, +} VolumeToMeshResolutionMode; + +/** VolumeToMeshModifierData->flag */ +typedef enum VolumeToMeshFlag { + VOLUME_TO_MESH_USE_SMOOTH_SHADE = 1 << 0, +} VolumeToMeshFlag; + #ifdef __cplusplus } #endif -- cgit v1.2.3