|
Blender
V2.93
|
#include "BLI_alloca.h"#include "BLI_math.h"#include "BLI_math_geom.h"#include "BLI_task.h"#include "BLT_translation.h"#include "DNA_defaults.h"#include "DNA_mesh_types.h"#include "DNA_meshdata_types.h"#include "DNA_object_types.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "BKE_bvhutils.h"#include "BKE_context.h"#include "BKE_deform.h"#include "BKE_editmesh.h"#include "BKE_lib_id.h"#include "BKE_lib_query.h"#include "BKE_mesh.h"#include "BKE_mesh_runtime.h"#include "BKE_mesh_wrapper.h"#include "BKE_modifier.h"#include "BKE_screen.h"#include "UI_interface.h"#include "UI_resources.h"#include "BLO_read_write.h"#include "RNA_access.h"#include "DEG_depsgraph.h"#include "DEG_depsgraph_query.h"#include "MEM_guardedalloc.h"#include "MOD_ui_common.h"#include "MOD_util.h"Go to the source code of this file.
Classes | |
| struct | SDefAdjacency |
| struct | SDefAdjacencyArray |
| struct | SDefEdgePolys |
| struct | SDefBindCalcData |
| struct | SDefBindPoly |
| struct | SDefBindWeightData |
| struct | SDefDeformData |
Typedefs | |
| typedef struct SDefAdjacency | SDefAdjacency |
| typedef struct SDefAdjacencyArray | SDefAdjacencyArray |
| typedef struct SDefEdgePolys | SDefEdgePolys |
| typedef struct SDefBindCalcData | SDefBindCalcData |
| typedef struct SDefBindPoly | SDefBindPoly |
| typedef struct SDefBindWeightData | SDefBindWeightData |
| typedef struct SDefDeformData | SDefDeformData |
Enumerations | |
| enum | { MOD_SDEF_BIND_RESULT_SUCCESS = 1 , MOD_SDEF_BIND_RESULT_GENERIC_ERR = 0 , MOD_SDEF_BIND_RESULT_MEM_ERR = -1 , MOD_SDEF_BIND_RESULT_NONMANY_ERR = -2 , MOD_SDEF_BIND_RESULT_CONCAVE_ERR = -3 , MOD_SDEF_BIND_RESULT_OVERLAP_ERR = -4 } |
| enum | { MOD_SDEF_INFINITE_WEIGHT_ANGULAR = (1 << 0) , MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ = (1 << 1) , MOD_SDEF_INFINITE_WEIGHT_DIST = (1 << 2) } |
Functions | |
| static void | initData (ModifierData *md) |
| static void | requiredDataMask (Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks) |
| static void | freeData (ModifierData *md) |
| static void | copyData (const ModifierData *md, ModifierData *target, const int flag) |
| static void | foreachIDLink (ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) |
| static void | updateDepsgraph (ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) |
| static void | freeAdjacencyMap (SDefAdjacencyArray *const vert_edges, SDefAdjacency *const adj_ref, SDefEdgePolys *const edge_polys) |
| static int | buildAdjacencyMap (const MPoly *poly, const MEdge *edge, const MLoop *const mloop, const uint numpoly, const uint numedges, SDefAdjacencyArray *const vert_edges, SDefAdjacency *adj, SDefEdgePolys *const edge_polys) |
| BLI_INLINE void | sortPolyVertsEdge (uint *indices, const MLoop *const mloop, const uint edge, const uint num) |
| BLI_INLINE void | sortPolyVertsTri (uint *indices, const MLoop *const mloop, const uint loopstart, const uint num) |
| BLI_INLINE uint | nearestVert (SDefBindCalcData *const data, const float point_co[3]) |
| BLI_INLINE int | isPolyValid (const float coords[][2], const uint nr) |
| static void | freeBindData (SDefBindWeightData *const bwdata) |
| BLI_INLINE float | computeAngularWeight (const float point_angle, const float edgemid_angle) |
| BLI_INLINE SDefBindWeightData * | computeBindWeights (SDefBindCalcData *const data, const float point_co[3]) |
| BLI_INLINE float | computeNormalDisplacement (const float point_co[3], const float point_co_proj[3], const float normal[3]) |
| static void | bindVert (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict UNUSED(tls)) |
| static bool | surfacedeformBind (Object *ob, SurfaceDeformModifierData *smd_orig, SurfaceDeformModifierData *smd_eval, float(*vertexCos)[3], uint numverts, uint tnumpoly, uint tnumverts, Mesh *target) |
| static void | deformVert (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict UNUSED(tls)) |
| static void | surfacedeformModifier_do (ModifierData *md, const ModifierEvalContext *ctx, float(*vertexCos)[3], uint numverts, Object *ob, Mesh *mesh) |
| static void | deformVerts (ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float(*vertexCos)[3], int numVerts) |
| static void | deformVertsEM (ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em, Mesh *mesh, float(*vertexCos)[3], int numVerts) |
| static bool | isDisabled (const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) |
| static void | panel_draw (const bContext *UNUSED(C), Panel *panel) |
| static void | panelRegister (ARegionType *region_type) |
| static void | blendWrite (BlendWriter *writer, const ModifierData *md) |
| static void | blendRead (BlendDataReader *reader, ModifierData *md) |
Variables | |
| ModifierTypeInfo | modifierType_SurfaceDeform |
| typedef struct SDefAdjacency SDefAdjacency |
| typedef struct SDefAdjacencyArray SDefAdjacencyArray |
| typedef struct SDefBindCalcData SDefBindCalcData |
| typedef struct SDefBindPoly SDefBindPoly |
This represents the relationship between a point (a source coordinate) and the face-corner it's being bound to (from the target mesh).
| typedef struct SDefBindWeightData SDefBindWeightData |
| typedef struct SDefDeformData SDefDeformData |
| typedef struct SDefEdgePolys SDefEdgePolys |
Polygons per edge (only 2, any more will exit calculation).
| anonymous enum |
| Enumerator | |
|---|---|
| MOD_SDEF_BIND_RESULT_SUCCESS | |
| MOD_SDEF_BIND_RESULT_GENERIC_ERR | |
| MOD_SDEF_BIND_RESULT_MEM_ERR | |
| MOD_SDEF_BIND_RESULT_NONMANY_ERR | |
| MOD_SDEF_BIND_RESULT_CONCAVE_ERR | |
| MOD_SDEF_BIND_RESULT_OVERLAP_ERR | |
Definition at line 179 of file MOD_surfacedeform.c.
| anonymous enum |
| Enumerator | |
|---|---|
| MOD_SDEF_INFINITE_WEIGHT_ANGULAR | |
| MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ | |
| MOD_SDEF_INFINITE_WEIGHT_DIST | |
Definition at line 189 of file MOD_surfacedeform.c.
|
static |
Definition at line 953 of file MOD_surfacedeform.c.
References add_v3_v3v3(), SDefBindWeightData::bind_polys, SDefVert::binds, BLI_assert, SDefBindPoly::centroid, computeBindWeights(), computeNormalDisplacement(), SDefBindPoly::coords, SDefBindPoly::coords_v2, copy_v3_v3(), data, SDefBindPoly::dominant_angle_weight, SDefBindPoly::dominant_edge, SDefBindPoly::edge_inds, SDefBindPoly::edge_vert_inds, freeBindData(), SDefBind::influence, SDefBindPoly::inside, interp_weights_poly_v2(), interp_weights_tri_v3(), isect_line_plane_v3(), SDefBindPoly::loopstart, madd_v3_v3fl(), MEM_calloc_arrayN, MEM_malloc_arrayN, mid_v3_v3v3v3(), MOD_SDEF_BIND_RESULT_MEM_ERR, MOD_SDEF_BIND_RESULT_SUCCESS, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI, MOD_SDEF_MODE_NGON, SDefBind::mode, norm(), SDefBindPoly::normal, SDefBind::normal_dist, normal_tri_v3(), NULL, SDefVert::numbinds, SDefBindWeightData::numbinds, SDefBind::numverts, SDefBindPoly::numverts, SDefBindPoly::point_v2, sortPolyVertsEdge(), sortPolyVertsTri(), MLoop::v, v1, v2, SDefBind::vert_inds, SDefBind::vert_weights, SDefBindPoly::weight, and zero_v3().
Referenced by surfacedeformBind().
|
static |
Definition at line 1608 of file MOD_surfacedeform.c.
References SDefVert::binds, BLO_read_data_address, BLO_read_float3_array(), BLO_read_float_array(), BLO_read_uint32_array(), ELEM, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI, SDefBind::mode, SDefVert::numbinds, SDefBind::numverts, SurfaceDeformModifierData::numverts, SDefBind::vert_inds, SDefBind::vert_weights, and SurfaceDeformModifierData::verts.
|
static |
Definition at line 1580 of file MOD_surfacedeform.c.
References SDefVert::binds, BLO_write_float3_array(), BLO_write_float_array(), BLO_write_struct_array, BLO_write_uint32_array(), ELEM, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI, SDefBind::mode, SDefVert::numbinds, SDefBind::numverts, SurfaceDeformModifierData::numverts, SDefBind::vert_inds, SDefBind::vert_weights, and SurfaceDeformModifierData::verts.
|
static |
Definition at line 292 of file MOD_surfacedeform.c.
References MLoop::e, SDefAdjacencyArray::first, SDefAdjacency::index, MPoly::loopstart, MOD_SDEF_BIND_RESULT_NONMANY_ERR, MOD_SDEF_BIND_RESULT_SUCCESS, SDefAdjacency::next, SDefAdjacencyArray::num, SDefEdgePolys::num, SDefEdgePolys::polys, MPoly::totloop, MEdge::v1, and MEdge::v2.
Referenced by surfacedeformBind().
| BLI_INLINE float computeAngularWeight | ( | const float | point_angle, |
| const float | edgemid_angle | ||
| ) |
Definition at line 480 of file MOD_surfacedeform.c.
References M_PI_2, min_ff(), and sinf.
Referenced by computeBindWeights().
| BLI_INLINE SDefBindWeightData* computeBindWeights | ( | SDefBindCalcData *const | data, |
| const float | point_co[3] | ||
| ) |
Definition at line 485 of file MOD_surfacedeform.c.
References angle(), angle_normalized_v2v2(), angle_normalized_v3v3(), angle_signed_v2v2(), area_tri_v2(), SDefBindWeightData::bind_polys, BLI_assert, SDefBindPoly::cent_edgemid_vecs_v2, SDefBindPoly::centroid, SDefBindPoly::centroid_v2, computeAngularWeight(), SDefBindPoly::coords, SDefBindPoly::coords_v2, copy_v3_v3(), SDefBindPoly::corner_edgemid_angles, SDefBindPoly::corner_ind, cross_v3_v3v3(), data, dist_to_line_v2(), SDefBindPoly::dominant_angle_weight, SDefBindPoly::dominant_edge, MLoop::e, SDefBindPoly::edge_inds, SDefBindPoly::edge_vert_inds, SDefBindPoly::edgemid_angle, ELEM, fabsf, freeBindData(), SDefAdjacency::index, SDefBindPoly::index, SDefBindPoly::inside, interpf(), isect_point_poly_v2(), libmv::isnan(), isPolyValid(), len_v2v2(), len_v3v3(), MPoly::loopstart, SDefBindPoly::loopstart, M_PI, M_PI_2, madd_v2_v2fl(), map_to_plane_axis_angle_v2_v3v3fl(), max_ff(), MEM_calloc_arrayN, MEM_callocN, MEM_malloc_arrayN, mid_v2_v2v2(), mid_v3_v3_array(), min_ff(), MOD_SDEF_BIND_RESULT_GENERIC_ERR, MOD_SDEF_BIND_RESULT_MEM_ERR, MOD_SDEF_BIND_RESULT_SUCCESS, MOD_SDEF_INFINITE_WEIGHT_ANGULAR, MOD_SDEF_INFINITE_WEIGHT_DIST, MOD_SDEF_INFINITE_WEIGHT_DIST_PROJ, nearestVert(), SDefAdjacency::next, SDefBindPoly::normal, normal_poly_v3(), normalize_v2(), normalize_v3(), NULL, SDefEdgePolys::num, SDefBindWeightData::numbinds, SDefBindWeightData::numpoly, SDefBindPoly::numverts, SDefBindPoly::point_edgemid_angles, SDefBindPoly::point_v2, SDefEdgePolys::polys, powf, SDefBindPoly::scale_mid, SDefBindPoly::scales, signf(), sinf, sqr(), sqrtf, sub_v2_v2(), sub_v2_v2v2(), MPoly::totloop, MLoop::v, SDefBindPoly::weight, SDefBindPoly::weight_angular, SDefBindPoly::weight_dist, SDefBindPoly::weight_dist_proj, world, and zero_v2().
Referenced by bindVert().
| BLI_INLINE float computeNormalDisplacement | ( | const float | point_co[3], |
| const float | point_co_proj[3], | ||
| const float | normal[3] | ||
| ) |
Definition at line 936 of file MOD_surfacedeform.c.
References dot_v3v3(), len_v3(), normal, and sub_v3_v3v3().
Referenced by bindVert().
|
static |
Definition at line 236 of file MOD_surfacedeform.c.
References SDefVert::binds, BKE_modifier_copydata_generic(), MEM_dupallocN, SDefVert::numbinds, SurfaceDeformModifierData::numverts, SDefBind::vert_inds, SDefBind::vert_weights, and SurfaceDeformModifierData::verts.
|
static |
Definition at line 1277 of file MOD_surfacedeform.c.
References BKE_defvert_find_weight(), BLI_array_alloca, copy_v3_v3(), data, float(), SDefBind::influence, madd_v3_v3fl(), MAX2, MEM_freeN, MEM_malloc_arrayN, mid_v3_v3_array(), MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI, MOD_SDEF_MODE_NGON, SDefBind::mode, norm(), SDefBind::normal_dist, normal_poly_v3(), SDefBind::numverts, sub_v3_v3(), UNLIKELY, SDefBind::vert_inds, SDefBind::vert_weights, and zero_v3().
Referenced by surfacedeformModifier_do().
|
static |
Definition at line 1478 of file MOD_surfacedeform.c.
References BKE_id_free(), SurfaceDeformModifierData::defgrp_name, ELEM, mesh, MOD_deform_mesh_eval_get(), NULL, ModifierEvalContext::object, and surfacedeformModifier_do().
|
static |
Definition at line 1499 of file MOD_surfacedeform.c.
References BKE_id_free(), BKE_mesh_wrapper_ensure_mdata(), SurfaceDeformModifierData::defgrp_name, ELEM, mesh, MOD_deform_mesh_eval_get(), NULL, ModifierEvalContext::object, and surfacedeformModifier_do().
|
static |
Definition at line 265 of file MOD_surfacedeform.c.
References IDWALK_NOP, and SurfaceDeformModifierData::target.
|
static |
Definition at line 281 of file MOD_surfacedeform.c.
References MEM_freeN.
Referenced by surfacedeformBind().
|
static |
Definition at line 464 of file MOD_surfacedeform.c.
References SDefBindWeightData::bind_polys, SDefBindPoly::coords, SDefBindPoly::coords_v2, MEM_freeN, MEM_SAFE_FREE, and SDefBindWeightData::numpoly.
Referenced by bindVert(), and computeBindWeights().
|
static |
Definition at line 216 of file MOD_surfacedeform.c.
References SDefVert::binds, MEM_SAFE_FREE, SDefVert::numbinds, SurfaceDeformModifierData::numverts, SDefBind::vert_inds, SDefBind::vert_weights, and SurfaceDeformModifierData::verts.
Referenced by surfacedeformBind(), and surfacedeformModifier_do().
|
static |
Definition at line 195 of file MOD_surfacedeform.c.
References BLI_assert, DNA_struct_default_get, MEMCMP_STRUCT_AFTER_IS_ZERO, and MEMCPY_STRUCT_AFTER.
|
static |
Definition at line 1526 of file MOD_surfacedeform.c.
References SurfaceDeformModifierData::flags, MOD_SDEF_BIND, NULL, OB_MESH, SurfaceDeformModifierData::target, Object::type, and SurfaceDeformModifierData::verts.
| BLI_INLINE int isPolyValid | ( | const float | coords[][2], |
| const uint | nr | ||
| ) |
Definition at line 423 of file MOD_surfacedeform.c.
References copy_v2_v2(), dot_v2v2(), is_poly_convex_v2(), len_squared_v2v2(), MOD_SDEF_BIND_RESULT_CONCAVE_ERR, MOD_SDEF_BIND_RESULT_OVERLAP_ERR, MOD_SDEF_BIND_RESULT_SUCCESS, normalize_v2(), and sub_v2_v2v2().
Referenced by computeBindWeights().
| BLI_INLINE uint nearestVert | ( | SDefBindCalcData *const | data, |
| const float | point_co[3] | ||
| ) |
Definition at line 381 of file MOD_surfacedeform.c.
References BLI_bvhtree_find_nearest(), data, BVHTreeNearest::dist_sq, dist_squared_to_line_segment_v3(), MLoop::e, BVHTreeNearest::index, len_squared_v3v3(), MPoly::loopstart, mul_v3_m4v3(), MPoly::totloop, MEdge::v1, and MEdge::v2.
Referenced by computeBindWeights().
Definition at line 1539 of file MOD_surfacedeform.c.
References col, IFACE_, Panel::layout, modifier_panel_end(), modifier_panel_get_property_pointers(), modifier_vgroup_ui(), NULL, ptr, RNA_boolean_get(), RNA_pointer_get(), RNA_pointer_is_null(), uiItemO(), uiItemR(), uiItemS(), uiLayoutColumn(), uiLayoutSetActive(), and uiLayoutSetPropSep().
Referenced by panelRegister().
|
static |
Definition at line 1575 of file MOD_surfacedeform.c.
References eModifierType_SurfaceDeform, modifier_panel_register(), and panel_draw().
|
static |
Definition at line 204 of file MOD_surfacedeform.c.
References CD_MASK_MDEFORMVERT, SurfaceDeformModifierData::defgrp_name, and CustomData_MeshMasks::vmask.
| BLI_INLINE void sortPolyVertsEdge | ( | uint * | indices, |
| const MLoop *const | mloop, | ||
| const uint | edge, | ||
| const uint | num | ||
| ) |
Definition at line 341 of file MOD_surfacedeform.c.
References e, MLoop::e, indices, and MLoop::v.
Referenced by bindVert().
| BLI_INLINE void sortPolyVertsTri | ( | uint * | indices, |
| const MLoop *const | mloop, | ||
| const uint | loopstart, | ||
| const uint | num | ||
| ) |
Definition at line 365 of file MOD_surfacedeform.c.
References indices, and MLoop::v.
Referenced by bindVert().
|
static |
Definition at line 1138 of file MOD_surfacedeform.c.
References bindVert(), BKE_bvhtree_from_mesh_get(), BKE_mesh_runtime_looptri_ensure(), BKE_modifier_set_error(), BLI_parallel_range_settings_defaults(), BLI_task_parallel_range(), buildAdjacencyMap(), BVHTREE_FROM_LOOPTRI, MVert::co, data, SurfaceDeformModifierData::falloff, free_bvhtree_from_mesh(), freeAdjacencyMap(), freeData(), invert_m4_m4(), SurfaceDeformModifierData::mat, Mesh::medge, MEM_calloc_arrayN, MEM_freeN, MEM_malloc_arrayN, Mesh::mloop, MOD_SDEF_BIND_RESULT_CONCAVE_ERR, MOD_SDEF_BIND_RESULT_GENERIC_ERR, MOD_SDEF_BIND_RESULT_MEM_ERR, MOD_SDEF_BIND_RESULT_NONMANY_ERR, MOD_SDEF_BIND_RESULT_OVERLAP_ERR, MOD_SDEF_BIND_RESULT_SUCCESS, Mesh::mpoly, mul_v3_m4v3(), Mesh::mvert, NULL, SurfaceDeformModifierData::numpoly, SurfaceDeformModifierData::numverts, Mesh::totedge, BVHTreeFromMesh::tree, TaskParallelSettings::use_threading, and SurfaceDeformModifierData::verts.
Referenced by surfacedeformModifier_do().
|
static |
Definition at line 1375 of file MOD_surfacedeform.c.
References BKE_mesh_wrapper_ensure_mdata(), BKE_mesh_wrapper_poly_len(), BKE_mesh_wrapper_vert_coords_copy_with_mat4(), BKE_mesh_wrapper_vert_len(), BKE_modifier_get_evaluated_mesh_from_evaluated_object(), BKE_modifier_get_original(), BKE_modifier_set_error(), BLI_parallel_range_settings_defaults(), BLI_task_parallel_range(), data, SurfaceDeformModifierData::defgrp_name, deformVert(), DEG_is_active(), ModifierEvalContext::depsgraph, SurfaceDeformModifierData::flags, freeData(), invert_m4_m4(), SurfaceDeformModifierData::mat, MEM_freeN, MEM_malloc_arrayN, mesh, MOD_get_vgroup(), MOD_SDEF_BIND, MOD_SDEF_INVERT_VGROUP, mul_m4_m4m4(), NULL, SurfaceDeformModifierData::numpoly, SurfaceDeformModifierData::numverts, Object::obmat, SurfaceDeformModifierData::strength, surfacedeformBind(), SurfaceDeformModifierData::target, TaskParallelSettings::use_threading, and SurfaceDeformModifierData::verts.
Referenced by deformVerts(), and deformVertsEM().
|
static |
Definition at line 272 of file MOD_surfacedeform.c.
References DEG_add_object_relation(), DEG_OB_COMP_GEOMETRY, ModifierUpdateDepsgraphContext::node, NULL, and SurfaceDeformModifierData::target.
| ModifierTypeInfo modifierType_SurfaceDeform |
Definition at line 1636 of file MOD_surfacedeform.c.