Blender  V3.3
Classes | Macros | Typedefs | Enumerations | Functions
subsurf_ccg.c File Reference
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "atomic_ops.h"
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_ccg.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pbvh.h"
#include "BKE_scene.h"
#include "BKE_subsurf.h"
#include "BLI_array.h"
#include "CCGSubSurf.h"

Go to the source code of this file.

Classes

struct  FaceVertWeightEntry
 
struct  WeightTable
 
struct  CopyFinalLoopArrayData
 

Macros

#define USE_LOOP_LAYOUT_FAST
 
#define SUB_ELEMS_FACE   50
 

Typedefs

typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE]
 
typedef struct FaceVertWeightEntry FaceVertWeightEntry
 
typedef struct WeightTable WeightTable
 
typedef struct CopyFinalLoopArrayData CopyFinalLoopArrayData
 

Enumerations

enum  CCGFlags {
  CCG_USE_AGING = 1 , CCG_USE_ARENA = 2 , CCG_CALC_NORMALS = 4 , CCG_ALLOC_MASK = 8 ,
  CCG_SIMPLE_SUBDIV = 16
}
 

Functions

static CCGDerivedMeshgetCCGDerivedMesh (CCGSubSurf *ss, int drawInteriorEdges, int useSubsurfUv, DerivedMesh *dm)
 
static voidarena_alloc (CCGAllocatorHDL a, int numBytes)
 
static voidarena_realloc (CCGAllocatorHDL a, void *ptr, int newSize, int oldSize)
 
static void arena_free (CCGAllocatorHDL UNUSED(a), void *UNUSED(ptr))
 
static void arena_release (CCGAllocatorHDL a)
 
static CCGSubSurf_getSubSurf (CCGSubSurf *prevSS, int subdivLevels, int numLayers, CCGFlags flags)
 
static int getEdgeIndex (CCGSubSurf *ss, CCGEdge *e, int x, int edgeSize)
 
static int getFaceIndex (CCGSubSurf *ss, CCGFace *f, int S, int x, int y, int edgeSize, int gridSize)
 
static void get_face_uv_map_vert (UvVertMap *vmap, struct MPoly *mpoly, struct MLoop *ml, int fi, CCGVertHDL *fverts)
 
static int ss_sync_from_uv (CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, const MLoopUV *mloopuv)
 
static void set_subsurf_legacy_uv (CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int n)
 
static void set_subsurf_uv (CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int layer_index)
 
static floatget_ss_weights (WeightTable *wtable, int gridCuts, int faceLen)
 
static void free_ss_weights (WeightTable *wtable)
 
static void ss_sync_ccg_from_derivedmesh (CCGSubSurf *ss, DerivedMesh *dm, float(*vertexCos)[3], int useFlatSubdiv)
 
static void ss_sync_from_derivedmesh (CCGSubSurf *ss, DerivedMesh *dm, float(*vertexCos)[3], int use_flat_subdiv, bool UNUSED(use_subdiv_uvs))
 
static int ccgDM_getVertMapIndex (CCGSubSurf *ss, CCGVert *v)
 
static int ccgDM_getEdgeMapIndex (CCGSubSurf *ss, CCGEdge *e)
 
static int ccgDM_getFaceMapIndex (CCGSubSurf *ss, CCGFace *f)
 
static void minmax_v3_v3v3 (const float vec[3], float min[3], float max[3])
 
static void UNUSED_FUNCTION() ccgDM_getMinMax (DerivedMesh *dm, float r_min[3], float r_max[3])
 
static int ccgDM_getNumVerts (DerivedMesh *dm)
 
static int ccgDM_getNumEdges (DerivedMesh *dm)
 
static int ccgDM_getNumPolys (DerivedMesh *dm)
 
static int ccgDM_getNumLoops (DerivedMesh *dm)
 
static CCGElemget_vertex_elem (CCGDerivedMesh *ccgdm, int vertNum)
 
static void ccgDM_getFinalVertCo (DerivedMesh *dm, int vertNum, float r_co[3])
 
static void ccgDM_getFinalVertNo (DerivedMesh *dm, int vertNum, float r_no[3])
 
BLI_INLINE void ccgDM_to_MVert (MVert *mv, const CCGKey *key, CCGElem *elem)
 
static void ccgDM_copyFinalVertArray (DerivedMesh *dm, MVert *mvert)
 
BLI_INLINE void ccgDM_to_MEdge (MEdge *med, const int v1, const int v2, const short flag)
 
static void ccgDM_copyFinalEdgeArray (DerivedMesh *dm, MEdge *medge)
 
static void copyFinalLoopArray_task_cb (void *__restrict userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
 
static void ccgDM_copyFinalLoopArray (DerivedMesh *dm, MLoop *mloop)
 
static void ccgDM_copyFinalPolyArray (DerivedMesh *dm, MPoly *mpoly)
 
static void ccgDM_release (DerivedMesh *dm)
 
static voidccgDM_get_vert_data_layer (DerivedMesh *dm, int type)
 
static voidccgDM_get_edge_data_layer (DerivedMesh *dm, int type)
 
static voidccgDM_get_poly_data_layer (DerivedMesh *dm, int type)
 
static int ccgDM_getNumGrids (DerivedMesh *dm)
 
static int ccgDM_getGridSize (DerivedMesh *dm)
 
static void ccgdm_create_grids (DerivedMesh *dm)
 
static CCGElem ** ccgDM_getGridData (DerivedMesh *dm)
 
static int * ccgDM_getGridOffset (DerivedMesh *dm)
 
static void ccgDM_getGridKey (DerivedMesh *dm, CCGKey *key)
 
static DMFlagMatccgDM_getGridFlagMats (DerivedMesh *dm)
 
static BLI_bitmap ** ccgDM_getGridHidden (DerivedMesh *dm)
 
static void ccgDM_recalcLoopTri (DerivedMesh *dm)
 
static void set_default_ccgdm_callbacks (CCGDerivedMesh *ccgdm)
 
static void create_ccgdm_maps (CCGDerivedMesh *ccgdm, CCGSubSurf *ss)
 
static void set_ccgdm_all_geometry (CCGDerivedMesh *ccgdm, CCGSubSurf *ss, DerivedMesh *dm, bool useSubsurfUv)
 
struct DerivedMeshsubsurf_make_derived_from_derived (struct DerivedMesh *dm, struct SubsurfModifierData *smd, const struct Scene *scene, float(*vertCos)[3], SubsurfFlags flags)
 
void subsurf_calculate_limit_positions (Mesh *me, float(*r_positions)[3])
 

Macro Definition Documentation

◆ SUB_ELEMS_FACE

#define SUB_ELEMS_FACE   50

Definition at line 469 of file subsurf_ccg.c.

◆ USE_LOOP_LAYOUT_FAST

#define USE_LOOP_LAYOUT_FAST

Definition at line 59 of file subsurf_ccg.c.

Typedef Documentation

◆ CopyFinalLoopArrayData

◆ FaceVertWeight

typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE]

Definition at line 470 of file subsurf_ccg.c.

◆ FaceVertWeightEntry

◆ WeightTable

typedef struct WeightTable WeightTable

Enumeration Type Documentation

◆ CCGFlags

enum CCGFlags
Enumerator
CCG_USE_AGING 
CCG_USE_ARENA 
CCG_CALC_NORMALS 
CCG_ALLOC_MASK 
CCG_SIMPLE_SUBDIV 

Definition at line 91 of file subsurf_ccg.c.

Function Documentation

◆ _getSubSurf()

static CCGSubSurf* _getSubSurf ( CCGSubSurf prevSS,
int  subdivLevels,
int  numLayers,
CCGFlags  flags 
)
static

◆ arena_alloc()

static void* arena_alloc ( CCGAllocatorHDL  a,
int  numBytes 
)
static

Definition at line 67 of file subsurf_ccg.c.

References Freestyle::a, and BLI_memarena_alloc().

Referenced by _getSubSurf().

◆ arena_free()

static void arena_free ( CCGAllocatorHDL   UNUSEDa,
void UNUSEDptr 
)
static

Definition at line 81 of file subsurf_ccg.c.

Referenced by _getSubSurf().

◆ arena_realloc()

static void* arena_realloc ( CCGAllocatorHDL  a,
void ptr,
int  newSize,
int  oldSize 
)
static

Definition at line 72 of file subsurf_ccg.c.

References Freestyle::a, BLI_memarena_alloc(), and ptr.

Referenced by _getSubSurf().

◆ arena_release()

static void arena_release ( CCGAllocatorHDL  a)
static

Definition at line 86 of file subsurf_ccg.c.

References Freestyle::a, and BLI_memarena_free().

Referenced by _getSubSurf().

◆ ccgDM_copyFinalEdgeArray()

static void ccgDM_copyFinalEdgeArray ( DerivedMesh dm,
MEdge medge 
)
static

◆ ccgDM_copyFinalLoopArray()

static void ccgDM_copyFinalLoopArray ( DerivedMesh dm,
MLoop mloop 
)
static

◆ ccgDM_copyFinalPolyArray()

static void ccgDM_copyFinalPolyArray ( DerivedMesh dm,
MPoly mpoly 
)
static

◆ ccgDM_copyFinalVertArray()

static void ccgDM_copyFinalVertArray ( DerivedMesh dm,
MVert mvert 
)
static

◆ ccgdm_create_grids()

static void ccgdm_create_grids ( DerivedMesh dm)
static

◆ ccgDM_get_edge_data_layer()

static void* ccgDM_get_edge_data_layer ( DerivedMesh dm,
int  type 
)
static

◆ ccgDM_get_poly_data_layer()

static void* ccgDM_get_poly_data_layer ( DerivedMesh dm,
int  type 
)
static

◆ ccgDM_get_vert_data_layer()

static void* ccgDM_get_vert_data_layer ( DerivedMesh dm,
int  type 
)
static

◆ ccgDM_getEdgeMapIndex()

static int ccgDM_getEdgeMapIndex ( CCGSubSurf ss,
CCGEdge e 
)
static

Definition at line 667 of file subsurf_ccg.c.

References ccgSubSurf_getEdgeUserData(), and e.

Referenced by ccgDM_get_edge_data_layer(), and set_ccgdm_all_geometry().

◆ ccgDM_getFaceMapIndex()

static int ccgDM_getFaceMapIndex ( CCGSubSurf ss,
CCGFace f 
)
static

Definition at line 672 of file subsurf_ccg.c.

References ccgSubSurf_getFaceUserData().

Referenced by ccgDM_get_poly_data_layer().

◆ ccgDM_getFinalVertCo()

static void ccgDM_getFinalVertCo ( DerivedMesh dm,
int  vertNum,
float  r_co[3] 
)
static

◆ ccgDM_getFinalVertNo()

static void ccgDM_getFinalVertNo ( DerivedMesh dm,
int  vertNum,
float  r_no[3] 
)
static

◆ ccgDM_getGridData()

static CCGElem** ccgDM_getGridData ( DerivedMesh dm)
static

Definition at line 1428 of file subsurf_ccg.c.

References ccgdm_create_grids(), and CCGDerivedMesh::gridData.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getGridFlagMats()

static DMFlagMat* ccgDM_getGridFlagMats ( DerivedMesh dm)
static

Definition at line 1450 of file subsurf_ccg.c.

References ccgdm_create_grids(), and CCGDerivedMesh::gridFlagMats.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getGridHidden()

static BLI_bitmap** ccgDM_getGridHidden ( DerivedMesh dm)
static

Definition at line 1458 of file subsurf_ccg.c.

References ccgdm_create_grids(), and CCGDerivedMesh::gridHidden.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getGridKey()

static void ccgDM_getGridKey ( DerivedMesh dm,
CCGKey key 
)
static

Definition at line 1444 of file subsurf_ccg.c.

References CCG_key_top_level(), and CCGDerivedMesh::ss.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getGridOffset()

static int* ccgDM_getGridOffset ( DerivedMesh dm)
static

Definition at line 1436 of file subsurf_ccg.c.

References ccgdm_create_grids(), and CCGDerivedMesh::gridOffset.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getGridSize()

static int ccgDM_getGridSize ( DerivedMesh dm)
static

Definition at line 1368 of file subsurf_ccg.c.

References ccgSubSurf_getGridSize(), and CCGDerivedMesh::ss.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getMinMax()

static void UNUSED_FUNCTION() ccgDM_getMinMax ( DerivedMesh dm,
float  r_min[3],
float  r_max[3] 
)
static

◆ ccgDM_getNumEdges()

static int ccgDM_getNumEdges ( DerivedMesh dm)
static

Definition at line 758 of file subsurf_ccg.c.

References ccgSubSurf_getNumFinalEdges(), and CCGDerivedMesh::ss.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getNumGrids()

static int ccgDM_getNumGrids ( DerivedMesh dm)
static

◆ ccgDM_getNumLoops()

static int ccgDM_getNumLoops ( DerivedMesh dm)
static

Definition at line 772 of file subsurf_ccg.c.

References ccgSubSurf_getNumFinalFaces(), and CCGDerivedMesh::ss.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getNumPolys()

static int ccgDM_getNumPolys ( DerivedMesh dm)
static

Definition at line 765 of file subsurf_ccg.c.

References ccgSubSurf_getNumFinalFaces(), and CCGDerivedMesh::ss.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getNumVerts()

static int ccgDM_getNumVerts ( DerivedMesh dm)
static

Definition at line 751 of file subsurf_ccg.c.

References ccgSubSurf_getNumFinalVerts(), and CCGDerivedMesh::ss.

Referenced by set_default_ccgdm_callbacks().

◆ ccgDM_getVertMapIndex()

static int ccgDM_getVertMapIndex ( CCGSubSurf ss,
CCGVert v 
)
static

Definition at line 662 of file subsurf_ccg.c.

References ccgSubSurf_getVertUserData(), and v.

Referenced by ccgDM_get_vert_data_layer(), and set_ccgdm_all_geometry().

◆ ccgDM_recalcLoopTri()

static void ccgDM_recalcLoopTri ( DerivedMesh dm)
static

◆ ccgDM_release()

static void ccgDM_release ( DerivedMesh dm)
static

◆ ccgDM_to_MEdge()

BLI_INLINE void ccgDM_to_MEdge ( MEdge med,
const int  v1,
const int  v2,
const short  flag 
)

Definition at line 947 of file subsurf_ccg.c.

References MEdge::bweight, MEdge::crease, MEdge::flag, v1, MEdge::v1, v2, and MEdge::v2.

Referenced by ccgDM_copyFinalEdgeArray().

◆ ccgDM_to_MVert()

BLI_INLINE void ccgDM_to_MVert ( MVert mv,
const CCGKey key,
CCGElem elem 
)

Definition at line 878 of file subsurf_ccg.c.

References CCG_elem_co(), and copy_v3_v3().

Referenced by ccgDM_copyFinalVertArray().

◆ copyFinalLoopArray_task_cb()

static void copyFinalLoopArray_task_cb ( void *__restrict  userdata,
const int  iter,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

◆ create_ccgdm_maps()

static void create_ccgdm_maps ( CCGDerivedMesh ccgdm,
CCGSubSurf ss 
)
static

◆ free_ss_weights()

static void free_ss_weights ( WeightTable wtable)
static

◆ get_face_uv_map_vert()

static void get_face_uv_map_vert ( UvVertMap vmap,
struct MPoly mpoly,
struct MLoop ml,
int  fi,
CCGVertHDL fverts 
)
static

◆ get_ss_weights()

static float* get_ss_weights ( WeightTable wtable,
int  gridCuts,
int  faceLen 
)
static

◆ get_vertex_elem()

static CCGElem* get_vertex_elem ( CCGDerivedMesh ccgdm,
int  vertNum 
)
static

◆ getCCGDerivedMesh()

static CCGDerivedMesh * getCCGDerivedMesh ( CCGSubSurf ss,
int  drawInteriorEdges,
int  useSubsurfUv,
DerivedMesh dm 
)
static

◆ getEdgeIndex()

static int getEdgeIndex ( CCGSubSurf ss,
CCGEdge e,
int  x,
int  edgeSize 
)
static

◆ getFaceIndex()

static int getFaceIndex ( CCGSubSurf ss,
CCGFace f,
int  S,
int  x,
int  y,
int  edgeSize,
int  gridSize 
)
static

◆ minmax_v3_v3v3()

static void minmax_v3_v3v3 ( const float  vec[3],
float  min[3],
float  max[3] 
)
static

Definition at line 677 of file subsurf_ccg.c.

References max, and min.

Referenced by ccgDM_getMinMax().

◆ set_ccgdm_all_geometry()

static void set_ccgdm_all_geometry ( CCGDerivedMesh ccgdm,
CCGSubSurf ss,
DerivedMesh dm,
bool  useSubsurfUv 
)
static

Definition at line 1569 of file subsurf_ccg.c.

References BLI_array_clear, BLI_array_declare, BLI_array_free, BLI_array_grow_items, BLI_assert, ccgDM_getEdgeMapIndex(), ccgDM_getVertMapIndex(), ccgSubSurf_getEdgeEdgeHandle(), ccgSubSurf_getEdgeSize(), ccgSubSurf_getEdgeUserData(), ccgSubSurf_getEdgeVert0(), ccgSubSurf_getEdgeVert1(), ccgSubSurf_getFaceFaceHandle(), ccgSubSurf_getFaceNumVerts(), ccgSubSurf_getFaceUserData(), ccgSubSurf_getFaceVert(), ccgSubSurf_getGridSize(), ccgSubSurf_getNumEdges(), ccgSubSurf_getNumFaces(), ccgSubSurf_getNumFinalEdges(), ccgSubSurf_getNumFinalFaces(), ccgSubSurf_getNumFinalVerts(), ccgSubSurf_getNumVerts(), ccgSubSurf_getVertUserData(), ccgSubSurf_getVertVertHandle(), CD_MLOOPUV, CD_MPOLY, CD_ORIGINDEX, CustomData_copy_data(), CustomData_get_layer(), CustomData_interp(), CustomData_number_of_layers(), CCGDerivedMesh::dm, DM_copy_vert_data(), DM_get_edge_data_layer(), DM_get_poly_data_layer(), DM_get_vert_data_layer(), DM_interp_vert_data(), e, CCGDerivedMesh::edge, DerivedMesh::edgeData, CCGDerivedMesh::edgeFlags, CCGDerivedMesh::edgeMap, CCGDerivedMesh::face, CCGDerivedMesh::faceFlags, CCGDerivedMesh::faceMap, DMFlagMat::flag, MEdge::flag, MPoly::flag, float(), free_ss_weights(), get_ss_weights(), DerivedMesh::getEdgeArray, getNumEdges(), DerivedMesh::loopData, DMFlagMat::mat_nr, MPoly::mat_nr, NULL, ORIGINDEX_NONE, POINTER_AS_INT, DerivedMesh::polyData, CCGDerivedMesh::reverseFaceMap, set_subsurf_uv(), CCGDerivedMesh::ss, CCGDerivedMesh::startEdge, CCGDerivedMesh::startFace, CCGDerivedMesh::startVert, CustomData::totlayer, v, CCGDerivedMesh::vert, CCGDerivedMesh::vertMap, w(), x, and y.

Referenced by getCCGDerivedMesh().

◆ set_default_ccgdm_callbacks()

static void set_default_ccgdm_callbacks ( CCGDerivedMesh ccgdm)
static

◆ set_subsurf_legacy_uv()

static void set_subsurf_legacy_uv ( CCGSubSurf ss,
DerivedMesh dm,
DerivedMesh result,
int  n 
)
static

◆ set_subsurf_uv()

static void set_subsurf_uv ( CCGSubSurf ss,
DerivedMesh dm,
DerivedMesh result,
int  layer_index 
)
static

Definition at line 463 of file subsurf_ccg.c.

References result, and set_subsurf_legacy_uv().

Referenced by set_ccgdm_all_geometry().

◆ ss_sync_ccg_from_derivedmesh()

static void ss_sync_ccg_from_derivedmesh ( CCGSubSurf ss,
DerivedMesh dm,
float(*)  vertexCos[3],
int  useFlatSubdiv 
)
static

◆ ss_sync_from_derivedmesh()

static void ss_sync_from_derivedmesh ( CCGSubSurf ss,
DerivedMesh dm,
float(*)  vertexCos[3],
int  use_flat_subdiv,
bool   UNUSEDuse_subdiv_uvs 
)
static

◆ ss_sync_from_uv()

static int ss_sync_from_uv ( CCGSubSurf ss,
CCGSubSurf origss,
DerivedMesh dm,
const MLoopUV mloopuv 
)
static

◆ subsurf_calculate_limit_positions()

void subsurf_calculate_limit_positions ( Mesh me,
float(*)  r_positions[3] 
)

◆ subsurf_make_derived_from_derived()

struct DerivedMesh* subsurf_make_derived_from_derived ( struct DerivedMesh dm,
struct SubsurfModifierData smd,
const struct Scene scene,
float(*)  vertCos[3],
SubsurfFlags  flags 
)