Blender V4.3
meshlaplacian.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "BLI_map.hh"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_memarena.h"
#include "BLI_ordered_edge.hh"
#include "BLI_string.h"
#include "BLT_translation.hh"
#include "BKE_attribute.hh"
#include "BKE_bvhutils.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.hh"
#include "ED_armature.hh"
#include "ED_mesh.hh"
#include "ED_object_vgroup.hh"
#include "eigen_capi.h"
#include "meshlaplacian.h"

Go to the source code of this file.

Classes

struct  LaplacianSystem
 
struct  LaplacianSystem::HeatWeighting
 
struct  BVHCallbackUserData
 
struct  MDefBoundIsect
 
struct  MDefBindInfluence
 
struct  MeshDeformBind
 
struct  MeshDeformIsect
 
struct  MeshRayCallbackData
 

Macros

#define C_WEIGHT   1.0f
 
#define WEIGHT_LIMIT_START   0.05f
 
#define WEIGHT_LIMIT_END   0.025f
 
#define DISTANCE_EPSILON   1e-4f
 
#define EPSILON   0.0001f
 
#define MESHDEFORM_TAG_UNTYPED   0
 
#define MESHDEFORM_TAG_BOUNDARY   1
 
#define MESHDEFORM_TAG_INTERIOR   2
 
#define MESHDEFORM_TAG_EXTERIOR   3
 
#define MESHDEFORM_LEN_THRESHOLD   1e-6f
 
#define MESHDEFORM_MIN_INFLUENCE   0.0005f
 

Functions

static void waitcursor (int)
 
static void progress_bar (int, const char *)
 
static void start_progress_bar ()
 
static void end_progress_bar ()
 
static void error (const char *str)
 
static void laplacian_increase_edge_count (blender::Map< blender::OrderedEdge, int > &edgehash, int v1, int v2)
 
static int laplacian_edge_count (const blender::Map< blender::OrderedEdge, int > &edgehash, int v1, int v2)
 
static void laplacian_triangle_area (LaplacianSystem *sys, int i1, int i2, int i3)
 
static void laplacian_triangle_weights (LaplacianSystem *sys, int f, int i1, int i2, int i3)
 
static LaplacianSystemlaplacian_system_construct_begin (int verts_num, int faces_num, int lsq)
 
void laplacian_add_vertex (LaplacianSystem *sys, float *co, int pinned)
 
void laplacian_add_triangle (LaplacianSystem *sys, int v1, int v2, int v3)
 
static void laplacian_system_construct_end (LaplacianSystem *sys)
 
static void laplacian_system_delete (LaplacianSystem *sys)
 
void laplacian_begin_solve (LaplacianSystem *sys, int index)
 
void laplacian_add_right_hand_side (LaplacianSystem *sys, int v, float value)
 
int laplacian_system_solve (LaplacianSystem *sys)
 
float laplacian_system_get_solution (LaplacianSystem *sys, int v)
 
static void bvh_callback (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void heat_ray_tree_create (LaplacianSystem *sys)
 
static int heat_ray_source_visible (LaplacianSystem *sys, int vertex, int source)
 
static float heat_source_distance (LaplacianSystem *sys, int vertex, int source)
 
static int heat_source_closest (LaplacianSystem *sys, int vertex, int source)
 
static void heat_set_H (LaplacianSystem *sys, int vertex)
 
static void heat_calc_vnormals (LaplacianSystem *sys)
 
static void heat_laplacian_create (LaplacianSystem *sys)
 
static void heat_system_free (LaplacianSystem *sys)
 
static float heat_limit_weight (float weight)
 
void heat_bone_weighting (Object *ob, Mesh *mesh, float(*verts)[3], int numbones, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float(*root)[3], float(*tip)[3], const bool *selected, const char **r_error_str)
 
static void harmonic_ray_callback (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static MDefBoundIsectmeshdeform_ray_tree_intersect (MeshDeformBind *mdb, const float co1[3], const float co2[3])
 
static int meshdeform_inside_cage (MeshDeformBind *mdb, float *co)
 
BLI_INLINE int meshdeform_index (MeshDeformBind *mdb, int x, int y, int z, int n)
 
BLI_INLINE void meshdeform_cell_center (MeshDeformBind *mdb, int x, int y, int z, int n, float *center)
 
static void meshdeform_add_intersections (MeshDeformBind *mdb, int x, int y, int z)
 
static void meshdeform_bind_floodfill (MeshDeformBind *mdb)
 
static float meshdeform_boundary_phi (const MeshDeformBind *mdb, const MDefBoundIsect *isect, int cagevert)
 
static float meshdeform_interp_w (MeshDeformBind *mdb, const float *gridvec, float *, int)
 
static void meshdeform_check_semibound (MeshDeformBind *mdb, int x, int y, int z)
 
static float meshdeform_boundary_total_weight (MeshDeformBind *mdb, int x, int y, int z)
 
static void meshdeform_matrix_add_cell (MeshDeformBind *mdb, LinearSolver *context, int x, int y, int z)
 
static void meshdeform_matrix_add_rhs (MeshDeformBind *mdb, LinearSolver *context, int x, int y, int z, int cagevert)
 
static void meshdeform_matrix_add_semibound_phi (MeshDeformBind *mdb, int x, int y, int z, int cagevert)
 
static void meshdeform_matrix_add_exterior_phi (MeshDeformBind *mdb, int x, int y, int z, int)
 
static void meshdeform_matrix_solve (MeshDeformModifierData *mmd, MeshDeformBind *mdb)
 
static void harmonic_coordinates_bind (MeshDeformModifierData *mmd, MeshDeformBind *mdb)
 
void ED_mesh_deform_bind_callback (Object *object, MeshDeformModifierData *mmd, Mesh *cagemesh, float *vertexcos, int verts_num, float cagemat[4][4])
 

Variables

static const int MESHDEFORM_OFFSET [7][3]
 

Detailed Description

Algorithms using the mesh laplacian.

Definition in file meshlaplacian.cc.

Macro Definition Documentation

◆ C_WEIGHT

#define C_WEIGHT   1.0f

Definition at line 359 of file meshlaplacian.cc.

Referenced by heat_set_H().

◆ DISTANCE_EPSILON

#define DISTANCE_EPSILON   1e-4f

Definition at line 362 of file meshlaplacian.cc.

Referenced by heat_source_closest().

◆ EPSILON

#define EPSILON   0.0001f

Definition at line 849 of file meshlaplacian.cc.

◆ MESHDEFORM_LEN_THRESHOLD

#define MESHDEFORM_LEN_THRESHOLD   1e-6f

minimum length for MDefBoundIsect.len

Definition at line 857 of file meshlaplacian.cc.

Referenced by meshdeform_ray_tree_intersect().

◆ MESHDEFORM_MIN_INFLUENCE

#define MESHDEFORM_MIN_INFLUENCE   0.0005f

Definition at line 859 of file meshlaplacian.cc.

Referenced by meshdeform_matrix_solve().

◆ MESHDEFORM_TAG_BOUNDARY

#define MESHDEFORM_TAG_BOUNDARY   1

Definition at line 852 of file meshlaplacian.cc.

Referenced by meshdeform_add_intersections(), and meshdeform_bind_floodfill().

◆ MESHDEFORM_TAG_EXTERIOR

◆ MESHDEFORM_TAG_INTERIOR

#define MESHDEFORM_TAG_INTERIOR   2

Definition at line 853 of file meshlaplacian.cc.

Referenced by meshdeform_bind_floodfill(), and meshdeform_matrix_solve().

◆ MESHDEFORM_TAG_UNTYPED

#define MESHDEFORM_TAG_UNTYPED   0

Definition at line 851 of file meshlaplacian.cc.

Referenced by harmonic_coordinates_bind(), and meshdeform_bind_floodfill().

◆ WEIGHT_LIMIT_END

#define WEIGHT_LIMIT_END   0.025f

Definition at line 361 of file meshlaplacian.cc.

Referenced by heat_limit_weight().

◆ WEIGHT_LIMIT_START

#define WEIGHT_LIMIT_START   0.05f

Definition at line 360 of file meshlaplacian.cc.

Referenced by heat_limit_weight().

Function Documentation

◆ bvh_callback()

static void bvh_callback ( void * userdata,
int index,
const BVHTreeRay * ray,
BVHTreeRayHit * hit )
static

◆ ED_mesh_deform_bind_callback()

◆ end_progress_bar()

static void end_progress_bar ( )
static

Definition at line 44 of file meshlaplacian.cc.

Referenced by ED_mesh_deform_bind_callback().

◆ error()

static void error ( const char * str)
static

Definition at line 45 of file meshlaplacian.cc.

References printf, and str.

Referenced by __attribute__(), add_verts_to_dgroups(), ANIM_apply_keyingset(), blender::gpu::MTLShader::bake_compute_pipeline_state(), blender::gpu::MTLShader::bake_pipeline_state(), Freestyle::BezierCurve::BezierCurve(), Freestyle::StrokeShaders::BezierCurveShader::BezierCurveShader(), Freestyle::Operators::bidirectionalChain(), Freestyle::Operators::bidirectionalChain(), BKE_ptcache_write(), BKE_tracking_reconstruction_solve(), BLI_bitmap_draw_2d_line_v2v2i(), BLI_delete_soft(), BLI_file_alias_target(), BLI_file_attributes(), blo_do_versions_280(), bm_edges_sort_winding(), BM_faces_join(), bmo_join_triangles_exec(), BMO_op_vinitf(), bpy_batch_remove(), bpy_user_map(), Freestyle::Operators::chain(), Freestyle::Operators::chain(), BlenderSession::check_and_report_session_error(), blender::gpu::shader::ShaderCreateInfo::check_error(), blender::gpu::debug::check_gl_error(), clean_tracks_exec(), blender::gpu::ShaderCompiler::compile(), copypose_error(), correctivesmooth_modifier_do(), Freestyle::Operators::create(), blender::gpu::MTLContext::debug_capture_begin(), GHOST_XrContext::dispatchErrorMessage(), dynamicPaint_createUVSurface(), ED_scene_fps_average_calc(), egl_chk(), egl_print_error(), libmv::euclidean_resection::EuclideanResectionPPnP(), expr_pylike_error_test(), film_adaptive_sampling_convergence_check(), filtcolum(), blender::gpu::MTLShader::finalize(), blender::gpu::shader::ShaderCreateInfo::finalize(), Freestyle::FitCurveWrapper::FitCubic(), Freestyle::FitCurveWrapper::FitCurve(), Freestyle::FitCurveWrapper::FitCurve(), blender::animrig::CombinedKeyingResult::generate_reports(), blender::gpu::MTLContextComputeUtils::get_buffer_clear_pso(), IESTextParser::get_double(), get_egl_error_enum_string(), get_egl_error_message_string(), get_limit_motor_info2(), IESTextParser::get_long(), GHOST_NDOFManagerCocoa::GHOST_NDOFManagerCocoa(), GPU_offscreen_create(), GPU_shader_create_info_check_error(), ErrorHandler::handleError(), handleNumInput(), IESTextParser::has_error(), blender::io::ply::import_ply_data(), GHOST_ContextEGL::initializeDrawingContext(), GHOST_ContextWGL::initializeDrawingContext(), DenoiseImage::load(), blender::io::ply::load_edge_element(), DenoiseImage::load_previous(), blender::io::ply::load_vertex_element(), make_renderinfo_string(), MemorY_ErroR(), merge_pixels(), meshdeform_matrix_solve(), libmv::Dogleg< Function, Jacobian, Solver >::minimize(), libmv::LevenbergMarquardt< Function, Jacobian, Solver >::minimize(), modify_mesh(), open_images(), DenoiseImage::parse_channels(), parse_channels(), blender::ed::greasepencil::polyline_detect_corners(), blender::ed::greasepencil::polyline_fit_curve(), blender::gpu::present(), blender::gpu::Shader::print_log(), ptcache_basic_header_read(), ptcache_disk_frame_to_mem(), ptcache_file_header_begin_read(), ptcache_mem_frame_to_disk(), ptcache_read_stream(), ptcache_write(), ptcache_write_stream(), pygpu_shader_create_from_info(), pyop_poll_message_get_fn(), pyrna_enum_bitmap_from_set(), pyrna_func_error_prefix(), quad_calc_error(), reconstruct_retrieve_libmv_tracks(), rna_def_function(), RNA_def_property(), RNA_def_property_srna(), RNA_def_struct_ptr(), DenoiseImage::save_output(), save_output(), Freestyle::Operators::sequentialSplit(), Freestyle::Operators::sequentialSplit(), Denoiser::set_error(), Device::set_error(), blender::gpu::MTLCommandBufferManager::submit(), surfaceGenerateGrid(), mv::TEST(), mv::TEST(), mv::TEST(), mv::TEST(), mv::TEST(), mv::TEST(), btDeformableLagrangianForce::testDerivative(), btDeformableLagrangianForce::testHessian(), ui_number_from_string_units(), UI_ThemeGetColorPtr(), libmv::Dogleg< Function, Jacobian, Solver >::Update(), libmv::LevenbergMarquardt< Function, Jacobian, Solver >::Update(), iTaSC::Distance::updateControlOutput(), and wm_xr_error_handler().

◆ harmonic_coordinates_bind()

static void harmonic_coordinates_bind ( MeshDeformModifierData * mmd,
MeshDeformBind * mdb )
static

Definition at line 1582 of file meshlaplacian.cc.

References b, MeshDeformModifierData::bindweights, BKE_bvhtree_from_mesh_get(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_memarena_use_calloc(), MeshDeformBind::boundisect, MeshDeformBind::bvhdata, MeshDeformBind::bvhtree, BVHTREE_FROM_CORNER_TRIS, MeshDeformBind::cage_verts_num, MeshDeformBind::cagecos, MeshDeformBind::cagemesh, MeshDeformBind::cagemesh_cache, copy_v3_v3(), MeshDeformBind::corner_tris, MeshDeformBind::corner_verts, MeshDeformModifierData::dyncellmin, MeshDeformModifierData::dyncellwidth, MeshDeformBind::dyngrid, MeshDeformModifierData::dyngrid, MeshDeformModifierData::dyngridsize, MeshDeformModifierData::dyninfluences, MeshDeformModifierData::dynverts, MeshDeformBind::face_normals, MeshDeformBind::faces, MeshDeformModifierData::flag, free_bvhtree_from_mesh(), MeshDeformModifierData::gridsize, MeshDeformBind::halfwidth, MDefCell::influences_num, MeshDeformModifierData::influences_num, INIT_MINMAX, MeshDeformBind::inside, MeshDeformBind::max, MEM_callocN, MEM_freeN(), MeshDeformBind::memarena, meshdeform_add_intersections(), meshdeform_bind_floodfill(), meshdeform_check_semibound(), meshdeform_inside_cage(), meshdeform_matrix_solve(), MESHDEFORM_TAG_UNTYPED, MeshDeformBind::min, minmax_v3v3_v3(), MOD_MDEF_DYNAMIC_BIND, MDefBindInfluence::next, MDefCell::offset, MeshDeformBind::phi, progress_bar(), MeshDeformBind::semibound, MeshDeformBind::size, MeshDeformBind::size3, MeshDeformBind::tag, MeshDeformBind::totalphi, MeshDeformBind::tri_faces, MDefBindInfluence::vertex, MDefInfluence::vertex, MeshDeformBind::vertexcos, MeshDeformBind::verts_num, MDefBindInfluence::weight, MDefInfluence::weight, MeshDeformBind::weights, MeshDeformBind::width, x, y, and z().

Referenced by ED_mesh_deform_bind_callback().

◆ harmonic_ray_callback()

◆ heat_bone_weighting()

void heat_bone_weighting ( Object * ob,
Mesh * mesh,
float(*) verts[3],
int numbones,
bDeformGroup ** dgrouplist,
bDeformGroup ** dgroupflip,
float(*) root[3],
float(*) tip[3],
const bool * selected,
const char ** r_error_str )

◆ heat_calc_vnormals()

◆ heat_laplacian_create()

◆ heat_limit_weight()

static float heat_limit_weight ( float weight)
static

Definition at line 616 of file meshlaplacian.cc.

References WEIGHT_LIMIT_END, and WEIGHT_LIMIT_START.

Referenced by heat_bone_weighting().

◆ heat_ray_source_visible()

◆ heat_ray_tree_create()

◆ heat_set_H()

◆ heat_source_closest()

static int heat_source_closest ( LaplacianSystem * sys,
int vertex,
int source )
static

◆ heat_source_distance()

◆ heat_system_free()

◆ laplacian_add_right_hand_side()

void laplacian_add_right_hand_side ( LaplacianSystem * sys,
int v,
float value )

◆ laplacian_add_triangle()

void laplacian_add_triangle ( LaplacianSystem * sys,
int v1,
int v2,
int v3 )

Definition at line 234 of file meshlaplacian.cc.

References LaplacianSystem::faces, LaplacianSystem::faces_num, and v2.

Referenced by heat_laplacian_create().

◆ laplacian_add_vertex()

void laplacian_add_vertex ( LaplacianSystem * sys,
float * co,
int pinned )

◆ laplacian_begin_solve()

◆ laplacian_edge_count()

static int laplacian_edge_count ( const blender::Map< blender::OrderedEdge, int > & edgehash,
int v1,
int v2 )
static

◆ laplacian_increase_edge_count()

static void laplacian_increase_edge_count ( blender::Map< blender::OrderedEdge, int > & edgehash,
int v1,
int v2 )
static

◆ laplacian_system_construct_begin()

◆ laplacian_system_construct_end()

◆ laplacian_system_delete()

◆ laplacian_system_get_solution()

float laplacian_system_get_solution ( LaplacianSystem * sys,
int v )

Definition at line 350 of file meshlaplacian.cc.

References LaplacianSystem::context, EIG_linear_solver_variable_get(), and v.

Referenced by heat_bone_weighting().

◆ laplacian_system_solve()

int laplacian_system_solve ( LaplacianSystem * sys)

◆ laplacian_triangle_area()

static void laplacian_triangle_area ( LaplacianSystem * sys,
int i1,
int i2,
int i3 )
static

◆ laplacian_triangle_weights()

◆ meshdeform_add_intersections()

static void meshdeform_add_intersections ( MeshDeformBind * mdb,
int x,
int y,
int z )
static

◆ meshdeform_bind_floodfill()

◆ meshdeform_boundary_phi()

◆ meshdeform_boundary_total_weight()

◆ meshdeform_cell_center()

BLI_INLINE void meshdeform_cell_center ( MeshDeformBind * mdb,
int x,
int y,
int z,
int n,
float * center )

◆ meshdeform_check_semibound()

static void meshdeform_check_semibound ( MeshDeformBind * mdb,
int x,
int y,
int z )
static

◆ meshdeform_index()

◆ meshdeform_inside_cage()

◆ meshdeform_interp_w()

static float meshdeform_interp_w ( MeshDeformBind * mdb,
const float * gridvec,
float * ,
int  )
static

◆ meshdeform_matrix_add_cell()

◆ meshdeform_matrix_add_exterior_phi()

static void meshdeform_matrix_add_exterior_phi ( MeshDeformBind * mdb,
int x,
int y,
int z,
int  )
static

◆ meshdeform_matrix_add_rhs()

◆ meshdeform_matrix_add_semibound_phi()

static void meshdeform_matrix_add_semibound_phi ( MeshDeformBind * mdb,
int x,
int y,
int z,
int cagevert )
static

◆ meshdeform_matrix_solve()

◆ meshdeform_ray_tree_intersect()

◆ progress_bar()

static void progress_bar ( int ,
const char *  )
static

◆ start_progress_bar()

static void start_progress_bar ( )
static

Definition at line 43 of file meshlaplacian.cc.

Referenced by ED_mesh_deform_bind_callback().

◆ waitcursor()

static void waitcursor ( int )
static

Definition at line 41 of file meshlaplacian.cc.

Referenced by ED_mesh_deform_bind_callback().

Variable Documentation

◆ MESHDEFORM_OFFSET

const int MESHDEFORM_OFFSET[7][3]
static
Initial value:
= {
{0, 0, 0},
{1, 0, 0},
{-1, 0, 0},
{0, 1, 0},
{0, -1, 0},
{0, 0, 1},
{0, 0, -1},
}

Definition at line 861 of file meshlaplacian.cc.

Referenced by meshdeform_cell_center(), meshdeform_index(), and meshdeform_inside_cage().