Blender  V2.93
Classes | Typedefs | Enumerations | Functions | Variables
MOD_surfacedeform.c File Reference
#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 SDefBindWeightDatacomputeBindWeights (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 Documentation

◆ SDefAdjacency

typedef struct SDefAdjacency SDefAdjacency

◆ SDefAdjacencyArray

◆ SDefBindCalcData

◆ SDefBindPoly

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).

Note
Some of these values could be de-duplicated however these are only needed once when running bind, so optimizing this structure isn't a priority.

◆ SDefBindWeightData

◆ SDefDeformData

◆ SDefEdgePolys

typedef struct SDefEdgePolys SDefEdgePolys

Polygons per edge (only 2, any more will exit calculation).

Enumeration Type Documentation

◆ anonymous enum

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

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.

Function Documentation

◆ bindVert()

static void bindVert ( void *__restrict  userdata,
const int  index,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

◆ blendRead()

static void blendRead ( BlendDataReader reader,
ModifierData md 
)
static

◆ blendWrite()

static void blendWrite ( BlendWriter writer,
const ModifierData md 
)
static

◆ buildAdjacencyMap()

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 
)
static

◆ computeAngularWeight()

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().

◆ 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().

◆ computeNormalDisplacement()

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().

◆ copyData()

static void copyData ( const ModifierData md,
ModifierData target,
const int  flag 
)
static

◆ deformVert()

static void deformVert ( void *__restrict  userdata,
const int  index,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

◆ deformVerts()

static void deformVerts ( ModifierData md,
const ModifierEvalContext ctx,
Mesh mesh,
float(*)  vertexCos[3],
int  numVerts 
)
static

◆ deformVertsEM()

static void deformVertsEM ( ModifierData md,
const ModifierEvalContext ctx,
struct BMEditMesh em,
Mesh mesh,
float(*)  vertexCos[3],
int  numVerts 
)
static

◆ foreachIDLink()

static void foreachIDLink ( ModifierData md,
Object ob,
IDWalkFunc  walk,
void *  userData 
)
static

Definition at line 265 of file MOD_surfacedeform.c.

References IDWALK_NOP, and SurfaceDeformModifierData::target.

◆ freeAdjacencyMap()

static void freeAdjacencyMap ( SDefAdjacencyArray *const  vert_edges,
SDefAdjacency *const  adj_ref,
SDefEdgePolys *const  edge_polys 
)
static

Definition at line 281 of file MOD_surfacedeform.c.

References MEM_freeN.

Referenced by surfacedeformBind().

◆ freeBindData()

static void freeBindData ( SDefBindWeightData *const  bwdata)
static

◆ freeData()

static void freeData ( ModifierData md)
static

◆ initData()

static void initData ( ModifierData md)
static

◆ isDisabled()

static bool isDisabled ( const Scene UNUSEDscene,
ModifierData md,
bool   UNUSEDuseRenderParams 
)
static

◆ isPolyValid()

BLI_INLINE int isPolyValid ( const float  coords[][2],
const uint  nr 
)

◆ nearestVert()

BLI_INLINE uint nearestVert ( SDefBindCalcData *const  data,
const float  point_co[3] 
)

◆ panel_draw()

static void panel_draw ( const bContext UNUSEDC,
Panel panel 
)
static

◆ panelRegister()

static void panelRegister ( ARegionType region_type)
static

◆ requiredDataMask()

static void requiredDataMask ( Object UNUSEDob,
ModifierData md,
CustomData_MeshMasks r_cddata_masks 
)
static

◆ sortPolyVertsEdge()

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().

◆ sortPolyVertsTri()

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().

◆ surfacedeformBind()

static bool surfacedeformBind ( Object ob,
SurfaceDeformModifierData smd_orig,
SurfaceDeformModifierData smd_eval,
float(*)  vertexCos[3],
uint  numverts,
uint  tnumpoly,
uint  tnumverts,
Mesh target 
)
static

◆ surfacedeformModifier_do()

static void surfacedeformModifier_do ( ModifierData md,
const ModifierEvalContext ctx,
float(*)  vertexCos[3],
uint  numverts,
Object ob,
Mesh mesh 
)
static

◆ updateDepsgraph()

static void updateDepsgraph ( ModifierData md,
const ModifierUpdateDepsgraphContext ctx 
)
static

Variable Documentation

◆ modifierType_SurfaceDeform

ModifierTypeInfo modifierType_SurfaceDeform

Definition at line 1636 of file MOD_surfacedeform.c.