Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-07-02 09:20:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-07-02 09:20:22 +0300
commit1844160a221cc4df36d8f465f8904c8689099490 (patch)
treea0da2f771974471f11367e39440e1b74a4be7dbf /source/blender
parent10c1f208b724a87258f4751e01d6bc8a4488a694 (diff)
DerivedMesh: cleanup & minor edirs
- place return args last position - move crazyspace function out of DerivedMesh header - use bool for args - flow control on own lines to ease debugging
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h246
-rw-r--r--source/blender/blenkernel/BKE_crazyspace.h17
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c486
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c6
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/object_update.c4
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/editors/space_view3d/drawobject.c5
-rw-r--r--source/blender/editors/transform/transform_conversions.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c4
-rw-r--r--source/blender/makesdna/DNA_object_types.h3
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c2
12 files changed, 471 insertions, 308 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 789d86b7816..70ae9cda370 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -96,7 +96,6 @@ struct MCol;
struct ColorBand;
struct GPUVertexAttribs;
struct GPUDrawObject;
-struct BMEditMesh;
struct PBVH;
/* number of sub-elements each mesh element has (for interpolation) */
@@ -469,25 +468,17 @@ struct DerivedMesh {
void (*release)(DerivedMesh *dm);
};
-/** utility function to initialize a DerivedMesh's function pointers to
- * the default implementation (for those functions which have a default)
- */
void DM_init_funcs(DerivedMesh *dm);
-/** utility function to initialize a DerivedMesh for the desired number
- * of vertices, edges and faces (doesn't allocate memory for them, just
- * sets up the custom data layers)
- */
-void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
- int numFaces, int numLoops, int numPolys);
+void DM_init(
+ DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
+ int numFaces, int numLoops, int numPolys);
-/** utility function to initialize a DerivedMesh for the desired number
- * of vertices, edges and faces, with a layer setup copied from source
- */
-void DM_from_template(DerivedMesh *dm, DerivedMesh *source,
- DerivedMeshType type,
- int numVerts, int numEdges, int numFaces,
- int numLoops, int numPolys);
+void DM_from_template(
+ DerivedMesh *dm, DerivedMesh *source,
+ DerivedMeshType type,
+ int numVerts, int numEdges, int numFaces,
+ int numLoops, int numPolys);
/** utility function to release a DerivedMesh's layers
* returns 1 if DerivedMesh has to be released by the backend, 0 otherwise
@@ -498,8 +489,9 @@ int DM_release(DerivedMesh *dm);
*/
void DM_to_mesh(DerivedMesh *dm, struct Mesh *me, struct Object *ob, CustomDataMask mask, bool take_ownership);
-struct BMEditMesh *DM_to_editbmesh(struct DerivedMesh *dm,
- struct BMEditMesh *existing, const bool do_tessellate);
+struct BMEditMesh *DM_to_editbmesh(
+ struct DerivedMesh *dm,
+ struct BMEditMesh *existing, const bool do_tessellate);
/* conversion to bmesh only */
void DM_to_bmesh_ex(struct DerivedMesh *dm, struct BMesh *bm, const bool calc_face_normal);
@@ -509,10 +501,6 @@ struct BMesh *DM_to_bmesh(struct DerivedMesh *dm, const bool calc_face_normal);
/** Utility function to convert a DerivedMesh to a shape key block */
void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb);
-/** set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
- * zero for the layer type, so only layer types specified by the mask
- * will be copied
- */
void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask);
/* adds a vertex/edge/face custom data layer to a DerivedMesh, optionally
@@ -520,16 +508,21 @@ void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask);
* alloctype defines how the layer is allocated or copied, and how it is
* freed, see BKE_customdata.h for the different options
*/
-void DM_add_vert_layer(struct DerivedMesh *dm, int type, int alloctype,
- void *layer);
-void DM_add_edge_layer(struct DerivedMesh *dm, int type, int alloctype,
- void *layer);
-void DM_add_tessface_layer(struct DerivedMesh *dm, int type, int alloctype,
- void *layer);
-void DM_add_loop_layer(DerivedMesh *dm, int type, int alloctype,
- void *layer);
-void DM_add_poly_layer(struct DerivedMesh *dm, int type, int alloctype,
- void *layer);
+void DM_add_vert_layer(
+ struct DerivedMesh *dm, int type, int alloctype,
+ void *layer);
+void DM_add_edge_layer(
+ struct DerivedMesh *dm, int type, int alloctype,
+ void *layer);
+void DM_add_tessface_layer(
+ struct DerivedMesh *dm, int type, int alloctype,
+ void *layer);
+void DM_add_loop_layer(
+ DerivedMesh *dm, int type, int alloctype,
+ void *layer);
+void DM_add_poly_layer(
+ struct DerivedMesh *dm, int type, int alloctype,
+ void *layer);
/* custom data access functions
* return pointer to data from first layer which matches type
@@ -564,16 +557,21 @@ void DM_set_tessface_data(struct DerivedMesh *dm, int index, int type, void *dat
* copy count elements from source_index in source to dest_index in dest
* these copy all layers for which the CD_FLAG_NOCOPY flag is not set
*/
-void DM_copy_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_tessface_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_loop_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
-void DM_copy_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int source_index, int dest_index, int count);
+void DM_copy_vert_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int source_index, int dest_index, int count);
+void DM_copy_edge_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int source_index, int dest_index, int count);
+void DM_copy_tessface_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int source_index, int dest_index, int count);
+void DM_copy_loop_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int source_index, int dest_index, int count);
+void DM_copy_poly_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int source_index, int dest_index, int count);
/* custom data free functions
* free count elements, starting at index
@@ -596,49 +594,36 @@ void DM_update_tessface_data(DerivedMesh *dm);
void DM_update_materials(DerivedMesh *dm, struct Object *ob);
struct MTFace *DM_paint_uvlayer_active_get(DerivedMesh *dm, int mat_nr);
-/** interpolates vertex data from the vertices indexed by src_indices in the
- * source mesh using the given weights and stores the result in the vertex
- * indexed by dest_index in the dest mesh
- */
-void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices, float *weights,
- int count, int dest_index);
-
-/** interpolates edge data from the edges indexed by src_indices in the
- * source mesh using the given weights and stores the result in the edge indexed
- * by dest_index in the dest mesh.
- * if weights is NULL, all weights default to 1.
- * if vert_weights is non-NULL, any per-vertex edge data is interpolated using
- * vert_weights[i] multiplied by weights[i].
- */
+void DM_interp_vert_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int *src_indices, float *weights,
+ int count, int dest_index);
+
typedef float EdgeVertWeight[SUB_ELEMS_EDGE][SUB_ELEMS_EDGE];
-void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, EdgeVertWeight *vert_weights,
- int count, int dest_index);
-
-/** interpolates face data from the faces indexed by src_indices in the
- * source mesh using the given weights and stores the result in the face indexed
- * by dest_index in the dest mesh.
- * if weights is NULL, all weights default to 1.
- * if vert_weights is non-NULL, any per-vertex face data is interpolated using
- * vert_weights[i] multiplied by weights[i].
- */
+void DM_interp_edge_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int *src_indices,
+ float *weights, EdgeVertWeight *vert_weights,
+ int count, int dest_index);
+
typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE];
-void DM_interp_tessface_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, FaceVertWeight *vert_weights,
- int count, int dest_index);
+void DM_interp_tessface_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int *src_indices,
+ float *weights, FaceVertWeight *vert_weights,
+ int count, int dest_index);
void DM_swap_tessface_data(struct DerivedMesh *dm, int index, const int *corner_indices);
-void DM_interp_loop_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index);
+void DM_interp_loop_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int *src_indices,
+ float *weights, int count, int dest_index);
-void DM_interp_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index);
+void DM_interp_poly_data(
+ struct DerivedMesh *source, struct DerivedMesh *dest,
+ int *src_indices,
+ float *weights, int count, int dest_index);
/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
void vDM_ColorBand_store(const struct ColorBand *coba, const char alert_color[4]);
@@ -653,56 +638,67 @@ DMCoNo *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int totcos);
/* */
-DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
-DerivedMesh *mesh_get_derived_deform(struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
+DerivedMesh *mesh_get_derived_final(
+ struct Scene *scene, struct Object *ob,
+ CustomDataMask dataMask);
+DerivedMesh *mesh_get_derived_deform(
+ struct Scene *scene, struct Object *ob,
+ CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object *ob,
- struct ModifierData *md, int build_shapekey_layers);
+DerivedMesh *mesh_create_derived_for_modifier(
+ struct Scene *scene, struct Object *ob,
+ struct ModifierData *md, int build_shapekey_layers);
-DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
+DerivedMesh *mesh_create_derived_render(
+ struct Scene *scene, struct Object *ob,
+ CustomDataMask dataMask);
-DerivedMesh *getEditDerivedBMesh(struct BMEditMesh *em, struct Object *ob,
- float (*vertexCos)[3]);
+DerivedMesh *getEditDerivedBMesh(
+ struct BMEditMesh *em, struct Object *ob,
+ float (*vertexCos)[3]);
-DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index);
+DerivedMesh *mesh_create_derived_index_render(
+ struct Scene *scene, struct Object *ob,
+ CustomDataMask dataMask, int index);
/* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
-DerivedMesh *mesh_create_derived_view(struct Scene *scene, struct Object *ob,
- CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *ob,
- float (*vertCos)[3],
- CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Object *ob,
- float (*vertCos)[3],
- CustomDataMask dataMask);
+DerivedMesh *mesh_create_derived_view(
+ struct Scene *scene, struct Object *ob,
+ CustomDataMask dataMask);
+DerivedMesh *mesh_create_derived_no_deform(
+ struct Scene *scene, struct Object *ob,
+ float (*vertCos)[3],
+ CustomDataMask dataMask);
+DerivedMesh *mesh_create_derived_no_deform_render(
+ struct Scene *scene, struct Object *ob,
+ float (*vertCos)[3],
+ CustomDataMask dataMask);
/* for gameengine */
-DerivedMesh *mesh_create_derived_no_virtual(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_physics(struct Scene *scene, struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
-
-DerivedMesh *editbmesh_get_derived_base(struct Object *, struct BMEditMesh *em);
-DerivedMesh *editbmesh_get_derived_cage(struct Scene *scene, struct Object *,
- struct BMEditMesh *em, CustomDataMask dataMask);
-DerivedMesh *editbmesh_get_derived_cage_and_final(struct Scene *scene, struct Object *,
- struct BMEditMesh *em, DerivedMesh **r_final,
- CustomDataMask dataMask);
+DerivedMesh *mesh_create_derived_no_virtual(
+ struct Scene *scene, struct Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask);
+DerivedMesh *mesh_create_derived_physics(
+ struct Scene *scene, struct Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask);
+
+DerivedMesh *editbmesh_get_derived_base(
+ struct Object *, struct BMEditMesh *em);
+DerivedMesh *editbmesh_get_derived_cage(
+ struct Scene *scene, struct Object *,
+ struct BMEditMesh *em, CustomDataMask dataMask);
+DerivedMesh *editbmesh_get_derived_cage_and_final(
+ struct Scene *scene, struct Object *,
+ struct BMEditMesh *em, CustomDataMask dataMask,
+ DerivedMesh **r_final);
DerivedMesh *object_get_derived_final(struct Object *ob, const bool for_render);
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
-void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
- CustomDataMask dataMask, int build_shapekey_layers);
-
-/** returns an array of deform matrices for crazyspace correction, and the
- * number of modifiers left */
-int editbmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct BMEditMesh *em,
- float (**deformmats)[3][3], float (**deformcos)[3]);
+void makeDerivedMesh(
+ struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
+ CustomDataMask dataMask, const bool build_shapekey_layers);
void weight_to_rgb(float r_rgb[3], const float weight);
/** Update the weight MCOL preview layer.
@@ -712,8 +708,9 @@ void weight_to_rgb(float r_rgb[3], const float weight);
* Else, it must be of num length, as indices, which contains vertices' idx to apply weights to.
* (other vertices are assumed zero weight).
*/
-void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag,
- float *weights, int num, const int *indices);
+void DM_update_weight_mcol(
+ struct Object *ob, struct DerivedMesh *dm, int const draw_flag,
+ float *weights, int num, const int *indices);
/** convert layers requested by a GLSL material to actually available layers in
* the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
@@ -741,8 +738,9 @@ typedef struct DMVertexAttribs {
int tottface, totmcol, tottang, totorco;
} DMVertexAttribs;
-void DM_vertex_attributes_from_gpu(DerivedMesh *dm,
- struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs);
+void DM_vertex_attributes_from_gpu(
+ DerivedMesh *dm,
+ struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs);
void DM_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert);
@@ -763,9 +761,11 @@ void DM_debug_print_cdlayers(CustomData *cdata);
bool DM_is_valid(DerivedMesh *dm);
#endif
-BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i) ATTR_NONNULL(1);
+BLI_INLINE int DM_origindex_mface_mpoly(
+ const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i) ATTR_NONNULL(1);
-BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
+BLI_INLINE int DM_origindex_mface_mpoly(
+ const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
{
const int j = index_mf_to_mpoly[i];
return (j != ORIGINDEX_NONE) ? (index_mp_to_orig ? index_mp_to_orig[j] : j) : ORIGINDEX_NONE;
diff --git a/source/blender/blenkernel/BKE_crazyspace.h b/source/blender/blenkernel/BKE_crazyspace.h
index 98bcdc5cfaa..ee6c5c57678 100644
--- a/source/blender/blenkernel/BKE_crazyspace.h
+++ b/source/blender/blenkernel/BKE_crazyspace.h
@@ -40,13 +40,22 @@ struct BMEditMesh;
struct Mesh;
/* crazyspace.c */
-float (*BKE_crazyspace_get_mapped_editverts(struct Scene *scene, struct Object *obedit))[3];
+float (*BKE_crazyspace_get_mapped_editverts(
+ struct Scene *scene, struct Object *obedit))[3];
void BKE_crazyspace_set_quats_editmesh(
struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
const bool use_select);
-void BKE_crazyspace_set_quats_mesh(struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
-int BKE_sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
-void BKE_crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]);
+void BKE_crazyspace_set_quats_mesh(
+ struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
+int BKE_crazyspace_get_first_deform_matrices_editbmesh(
+ struct Scene *, struct Object *, struct BMEditMesh *em,
+ float (**deformmats)[3][3], float (**deformcos)[3]);
+int BKE_sculpt_get_first_deform_matrices(
+ struct Scene *scene, struct Object *ob,
+ float (**deformmats)[3][3], float (**deformcos)[3]);
+void BKE_crazyspace_build_sculpt(
+ struct Scene *scene, struct Object *ob,
+ float (**deformmats)[3][3], float (**deformcos)[3]);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 0f3a87b19e2..7ced227f5b7 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -245,6 +245,10 @@ static CustomData *dm_getPolyCData(DerivedMesh *dm)
return &dm->polyData;
}
+/**
+ * Utility function to initialize a DerivedMesh's function pointers to
+ * the default implementation (for those functions which have a default)
+ */
void DM_init_funcs(DerivedMesh *dm)
{
/* default function implementations */
@@ -278,8 +282,14 @@ void DM_init_funcs(DerivedMesh *dm)
bvhcache_init(&dm->bvhCache);
}
-void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
- int numTessFaces, int numLoops, int numPolys)
+/**
+ * Utility function to initialize a DerivedMesh for the desired number
+ * of vertices, edges and faces (doesn't allocate memory for them, just
+ * sets up the custom data layers)
+ */
+void DM_init(
+ DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
+ int numTessFaces, int numLoops, int numPolys)
{
dm->type = type;
dm->numVertData = numVerts;
@@ -302,9 +312,14 @@ void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges,
copy_vn_i(dm->polyData.typemap, CD_NUMTYPES, -1);
}
-void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
- int numVerts, int numEdges, int numTessFaces,
- int numLoops, int numPolys)
+/**
+ * Utility function to initialize a DerivedMesh for the desired number
+ * of vertices, edges and faces, with a layer setup copied from source
+ */
+void DM_from_template(
+ DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
+ int numVerts, int numEdges, int numTessFaces,
+ int numLoops, int numPolys)
{
CustomData_copy(&source->vertData, &dm->vertData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numVerts);
@@ -678,7 +693,9 @@ void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb)
float *fp;
MVert *mvert;
- if (totvert == 0 || me->totvert == 0 || me->totvert != totvert) return;
+ if (totvert == 0 || me->totvert == 0 || me->totvert != totvert) {
+ return;
+ }
if (kb->data) MEM_freeN(kb->data);
kb->data = MEM_mallocN(me->key->elemsize * me->totvert, "kb->data");
@@ -692,6 +709,11 @@ void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb)
}
}
+/**
+ * set the CD_FLAG_NOCOPY flag in custom data layers where the mask is
+ * zero for the layer type, so only layer types specified by the mask
+ * will be copied
+ */
void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask)
{
CustomData_set_only_copy(&dm->vertData, mask);
@@ -865,27 +887,51 @@ void DM_free_poly_data(struct DerivedMesh *dm, int index, int count)
CustomData_free_elem(&dm->polyData, index, count);
}
-void DM_interp_vert_data(DerivedMesh *source, DerivedMesh *dest,
- int *src_indices, float *weights,
- int count, int dest_index)
+/**
+ * interpolates vertex data from the vertices indexed by src_indices in the
+ * source mesh using the given weights and stores the result in the vertex
+ * indexed by dest_index in the dest mesh
+ */
+void DM_interp_vert_data(
+ DerivedMesh *source, DerivedMesh *dest,
+ int *src_indices, float *weights,
+ int count, int dest_index)
{
CustomData_interp(&source->vertData, &dest->vertData, src_indices,
weights, NULL, count, dest_index);
}
-void DM_interp_edge_data(DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, EdgeVertWeight *vert_weights,
- int count, int dest_index)
+/**
+ * interpolates edge data from the edges indexed by src_indices in the
+ * source mesh using the given weights and stores the result in the edge indexed
+ * by dest_index in the dest mesh.
+ * if weights is NULL, all weights default to 1.
+ * if vert_weights is non-NULL, any per-vertex edge data is interpolated using
+ * vert_weights[i] multiplied by weights[i].
+ */
+void DM_interp_edge_data(
+ DerivedMesh *source, DerivedMesh *dest,
+ int *src_indices,
+ float *weights, EdgeVertWeight *vert_weights,
+ int count, int dest_index)
{
CustomData_interp(&source->edgeData, &dest->edgeData, src_indices,
weights, (float *)vert_weights, count, dest_index);
}
-void DM_interp_tessface_data(DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, FaceVertWeight *vert_weights,
- int count, int dest_index)
+/**
+ * interpolates face data from the faces indexed by src_indices in the
+ * source mesh using the given weights and stores the result in the face indexed
+ * by dest_index in the dest mesh.
+ * if weights is NULL, all weights default to 1.
+ * if vert_weights is non-NULL, any per-vertex face data is interpolated using
+ * vert_weights[i] multiplied by weights[i].
+ */
+void DM_interp_tessface_data(
+ DerivedMesh *source, DerivedMesh *dest,
+ int *src_indices,
+ float *weights, FaceVertWeight *vert_weights,
+ int count, int dest_index)
{
CustomData_interp(&source->faceData, &dest->faceData, src_indices,
weights, (float *)vert_weights, count, dest_index);
@@ -896,23 +942,24 @@ void DM_swap_tessface_data(DerivedMesh *dm, int index, const int *corner_indices
CustomData_swap(&dm->faceData, index, corner_indices);
}
-void DM_interp_loop_data(DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index)
+void DM_interp_loop_data(
+ DerivedMesh *source, DerivedMesh *dest,
+ int *src_indices,
+ float *weights, int count, int dest_index)
{
CustomData_interp(&source->loopData, &dest->loopData, src_indices,
weights, NULL, count, dest_index);
}
-void DM_interp_poly_data(DerivedMesh *source, DerivedMesh *dest,
- int *src_indices,
- float *weights, int count, int dest_index)
+void DM_interp_poly_data(
+ DerivedMesh *source, DerivedMesh *dest,
+ int *src_indices,
+ float *weights, int count, int dest_index)
{
CustomData_interp(&source->polyData, &dest->polyData, src_indices,
weights, NULL, count, dest_index);
}
-///
DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
{
DerivedMesh *dm = CDDM_from_mesh(me);
@@ -927,8 +974,9 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
return dm;
}
-DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
- ModifierData *md, int build_shapekey_layers)
+DerivedMesh *mesh_create_derived_for_modifier(
+ Scene *scene, Object *ob,
+ ModifierData *md, int build_shapekey_layers)
{
Mesh *me = ob->data;
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -937,8 +985,13 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
md->scene = scene;
- if (!(md->mode & eModifierMode_Realtime)) return NULL;
- if (mti->isDisabled && mti->isDisabled(md, 0)) return NULL;
+ if (!(md->mode & eModifierMode_Realtime)) {
+ return NULL;
+ }
+
+ if (mti->isDisabled && mti->isDisabled(md, 0)) {
+ return NULL;
+ }
if (build_shapekey_layers && me->key && (kb = BLI_findlink(&me->key->block, ob->shapenr - 1))) {
BKE_keyblock_convert_to_mesh(kb, me);
@@ -1028,8 +1081,12 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
float (*orco)[3];
int free;
- if (em) dm = CDDM_from_editbmesh(em, false, false);
- else dm = CDDM_from_mesh(me);
+ if (em) {
+ dm = CDDM_from_editbmesh(em, false, false);
+ }
+ else {
+ dm = CDDM_from_mesh(me);
+ }
orco = get_orco_coords_dm(ob, em, layer, &free);
@@ -1041,8 +1098,9 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
return dm;
}
-static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm,
- DerivedMesh *orcodm, int layer)
+static void add_orco_dm(
+ Object *ob, BMEditMesh *em, DerivedMesh *dm,
+ DerivedMesh *orcodm, int layer)
{
float (*orco)[3], (*layerorco)[3];
int totvert, free;
@@ -1233,13 +1291,16 @@ void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4])
G_dm_wcinfo.alert_color = alert_color;
}
-/* return an array of vertex weight colors, caller must free.
+/**
+ * return an array of vertex weight colors, caller must free.
*
- * note that we could save some memory and allocate RGB only but then we'd need to
+ * \note that we could save some memory and allocate RGB only but then we'd need to
* re-arrange the colors when copying to the face since MCol has odd ordering,
- * so leave this as is - campbell */
-static void calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo,
- unsigned char (*r_wtcol_v)[4])
+ * so leave this as is - campbell
+ */
+static void calc_weightpaint_vert_array(
+ Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo,
+ unsigned char (*r_wtcol_v)[4])
{
MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
int numVerts = dm->getNumVerts(dm);
@@ -1280,13 +1341,15 @@ static void calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const d
}
}
-/* return an array of vertex weight colors from given weights, caller must free.
+/** return an array of vertex weight colors from given weights, caller must free.
*
- * note that we could save some memory and allocate RGB only but then we'd need to
+ * \note that we could save some memory and allocate RGB only but then we'd need to
* re-arrange the colors when copying to the face since MCol has odd ordering,
- * so leave this as is - campbell */
-static void calc_colors_from_weights_array(const int num, const float *weights,
- unsigned char (*r_wtcol_v)[4])
+ * so leave this as is - campbell
+ */
+static void calc_colors_from_weights_array(
+ const int num, const float *weights,
+ unsigned char (*r_wtcol_v)[4])
{
unsigned char (*wc)[4] = r_wtcol_v;
int i;
@@ -1296,8 +1359,9 @@ static void calc_colors_from_weights_array(const int num, const float *weights,
}
}
-void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
- float *weights, int num, const int *indices)
+void DM_update_weight_mcol(
+ Object *ob, DerivedMesh *dm, int const draw_flag,
+ float *weights, int num, const int *indices)
{
BMEditMesh *em = (dm->type == DM_TYPE_EDITBMESH) ? BKE_editmesh_from_object(ob) : NULL;
unsigned char (*wtcol_v)[4];
@@ -1491,16 +1555,21 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
CDDM_calc_normals_mapping_ex(dm, (dm->dirty & DM_DIRTY_NORMALS) ? false : true);
}
}
-/* new value for useDeform -1 (hack for the gameengine):
+
+/**
+ * new value for useDeform -1 (hack for the gameengine):
+ *
* - apply only the modifier stack of the object, skipping the virtual modifiers,
* - don't apply the key
* - apply deform modifiers and input vertexco
*/
-static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos)[3],
- DerivedMesh **deform_r, DerivedMesh **final_r,
- int useRenderParams, int useDeform,
- int needMapping, CustomDataMask dataMask,
- int index, int useCache, int build_shapekey_layers)
+static void mesh_calc_modifiers(
+ Scene *scene, Object *ob, float (*inputVertexCos)[3],
+ const bool useRenderParams, int useDeform,
+ const bool need_mapping, CustomDataMask dataMask,
+ const int index, const bool useCache, const bool build_shapekey_layers,
+ /* return args */
+ DerivedMesh **r_deform, DerivedMesh **r_final)
{
Mesh *me = ob->data;
ModifierData *firstmd, *md, *previewmd = NULL;
@@ -1510,7 +1579,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
float (*deformedVerts)[3] = NULL;
DerivedMesh *dm = NULL, *orcodm, *clothorcodm, *finaldm;
int numVerts = me->totvert;
- int required_mode;
+ const int required_mode = useRenderParams ? eModifierMode_Render : eModifierMode_Realtime;
bool isPrevDeform = false;
const bool skipVirtualArmature = (useDeform < 0);
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
@@ -1537,6 +1606,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
ModifierApplyFlag app_flags = useRenderParams ? MOD_APPLY_RENDER : 0;
ModifierApplyFlag deform_app_flags = app_flags;
+
+
if (useCache)
app_flags |= MOD_APPLY_USECACHE;
if (useDeform)
@@ -1556,9 +1627,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
modifiers_clearErrors(ob);
- if (useRenderParams) required_mode = eModifierMode_Render;
- else required_mode = eModifierMode_Realtime;
-
if (do_mod_wmcol || do_mod_mcol) {
/* Find the last active modifier generating a preview, or NULL if none. */
/* XXX Currently, DPaint modifier just ignores this.
@@ -1577,8 +1645,10 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, previewmd, previewmask);
curr = datamasks;
- if (deform_r) *deform_r = NULL;
- *final_r = NULL;
+ if (r_deform) {
+ *r_deform = NULL;
+ }
+ *r_final = NULL;
if (useDeform) {
if (inputVertexCos)
@@ -1590,8 +1660,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
md->scene = scene;
- if (!modifier_isEnabled(scene, md, required_mode)) continue;
- if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
+ if (!modifier_isEnabled(scene, md, required_mode)) {
+ continue;
+ }
+
+ if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) {
+ continue;
+ }
if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
if (!deformedVerts)
@@ -1604,7 +1679,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
}
/* grab modifiers until index i */
- if ((index >= 0) && (BLI_findindex(&ob->modifiers, md) >= index))
+ if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index))
break;
}
@@ -1612,14 +1687,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* places that wish to use the original mesh but with deformed
* coordinates (vpaint, etc.)
*/
- if (deform_r) {
- *deform_r = CDDM_from_mesh(me);
+ if (r_deform) {
+ *r_deform = CDDM_from_mesh(me);
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
if (deformedVerts) {
- CDDM_apply_vert_coords(*deform_r, deformedVerts);
+ CDDM_apply_vert_coords(*r_deform, deformedVerts);
}
}
}
@@ -1644,12 +1719,19 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
md->scene = scene;
- if (!modifier_isEnabled(scene, md, required_mode)) continue;
- if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
+ if (!modifier_isEnabled(scene, md, required_mode)) {
+ continue;
+ }
+
+ if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) {
+ continue;
+ }
+
if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
modifier_setError(md, "Modifier requires original data, bad stack position");
continue;
}
+
if (sculpt_mode &&
(!has_multires || multires_applied || sculpt_dyntopo))
{
@@ -1657,8 +1739,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if (md->type == eModifierType_Multires && ((MultiresModifierData *)md)->sculptlvl == 0) {
/* If multires is on level 0 skip it silently without warning message. */
- if (!sculpt_dyntopo)
+ if (!sculpt_dyntopo) {
continue;
+ }
}
if (sculpt_dyntopo && !useRenderParams)
@@ -1680,8 +1763,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
modifier_setError(md, "Hide, Mask and optimized display disabled");
}
}
- if (needMapping && !modifier_supportsMapping(md)) continue;
- if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
+
+ if (need_mapping && !modifier_supportsMapping(md)) {
+ continue;
+ }
+
+ if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) {
+ continue;
+ }
/* add an orco layer if needed by this modifier */
if (mti->requiredDataMask)
@@ -1766,7 +1855,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* requests it, this way Mirror, Solidify etc will keep ORIGINDEX
* data by using generic DM_copy_vert_data() functions.
*/
- if (needMapping || (nextmask & CD_MASK_ORIGINDEX)) {
+ if (need_mapping || (nextmask & CD_MASK_ORIGINDEX)) {
/* calc */
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
@@ -1790,7 +1879,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
/* needMapping check here fixes bug [#28112], otherwise its
* possible that it wont be copied */
mask |= append_mask;
- DM_set_only_copy(dm, mask | (needMapping ? CD_MASK_ORIGINDEX : 0));
+ DM_set_only_copy(dm, mask | (need_mapping ? CD_MASK_ORIGINDEX : 0));
/* add cloth rest shape key if need */
if (mask & CD_MASK_CLOTH_ORCO)
@@ -1854,7 +1943,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if (ndm) {
/* if the modifier returned a new dm, release the old one */
- if (clothorcodm && clothorcodm != ndm) clothorcodm->release(clothorcodm);
+ if (clothorcodm && clothorcodm != ndm) {
+ clothorcodm->release(clothorcodm);
+ }
clothorcodm = ndm;
}
}
@@ -1873,7 +1964,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform);
/* grab modifiers until index i */
- if ((index >= 0) && (BLI_findindex(&ob->modifiers, md) >= index))
+ if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index))
break;
if (sculpt_mode && md->type == eModifierType_Multires) {
@@ -1930,8 +2021,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if (dataMask & CD_MASK_ORCO) {
add_orco_dm(ob, NULL, finaldm, orcodm, CD_ORCO);
- if (deform_r && *deform_r)
- add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO);
+ if (r_deform && *r_deform)
+ add_orco_dm(ob, NULL, *r_deform, NULL, CD_ORCO);
}
if (do_loop_normals) {
@@ -1968,7 +2059,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
}
#endif /* WITH_GAMEENGINE */
- *final_r = finaldm;
+ *r_final = finaldm;
if (orcodm)
orcodm->release(orcodm);
@@ -2002,9 +2093,12 @@ float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *r_numVerts))[3]
bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm)
{
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
+ const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
+
+ if (!modifier_isEnabled(scene, md, required_mode)) {
+ return false;
+ }
- if (!modifier_isEnabled(scene, md, required_mode)) return 0;
if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
modifier_setError(md, "Modifier requires original data, bad stack position");
return false;
@@ -2013,9 +2107,11 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *
return true;
}
-static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, DerivedMesh **cage_r,
- DerivedMesh **final_r,
- CustomDataMask dataMask)
+static void editbmesh_calc_modifiers(
+ Scene *scene, Object *ob, BMEditMesh *em,
+ CustomDataMask dataMask,
+ /* return args */
+ DerivedMesh **r_cage, DerivedMesh **r_final)
{
ModifierData *md, *previewmd = NULL;
float (*deformedVerts)[3] = NULL;
@@ -2023,7 +2119,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
DerivedMesh *dm = NULL, *orcodm = NULL;
int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
CDMaskLink *datamasks, *curr;
- int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
+ const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
int draw_flag = dm_drawflag_calc(scene->toolsettings);
// const bool do_mod_mcol = true; // (ob->mode == OB_MODE_OBJECT);
@@ -2041,8 +2137,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
modifiers_clearErrors(ob);
- if (cage_r && cageIndex == -1) {
- *cage_r = getEditDerivedBMesh(em, ob, NULL);
+ if (r_cage && cageIndex == -1) {
+ *r_cage = getEditDerivedBMesh(em, ob, NULL);
}
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -2064,8 +2160,9 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
md->scene = scene;
- if (!editbmesh_modifier_is_enabled(scene, md, dm))
+ if (!editbmesh_modifier_is_enabled(scene, md, dm)) {
continue;
+ }
/* add an orco layer if needed by this modifier */
if (dm && mti->requiredDataMask) {
@@ -2109,14 +2206,15 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
if (dm) {
if (deformedVerts) {
DerivedMesh *tdm = CDDM_copy(dm);
- if (!(cage_r && dm == *cage_r)) dm->release(dm);
+ if (!(r_cage && dm == *r_cage)) {
+ dm->release(dm);
+ }
dm = tdm;
CDDM_apply_vert_coords(dm, deformedVerts);
}
- else if (cage_r && dm == *cage_r) {
- /* dm may be changed by this modifier, so we need to copy it
- */
+ else if (r_cage && dm == *r_cage) {
+ /* dm may be changed by this modifier, so we need to copy it */
dm = CDDM_copy(dm);
}
@@ -2196,18 +2294,18 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
append_mask |= CD_MASK_PREVIEW_MLOOPCOL;
}
- if (cage_r && i == cageIndex) {
+ if (r_cage && i == cageIndex) {
if (dm && deformedVerts) {
- *cage_r = CDDM_copy(dm);
- CDDM_apply_vert_coords(*cage_r, deformedVerts);
+ *r_cage = CDDM_copy(dm);
+ CDDM_apply_vert_coords(*r_cage, deformedVerts);
}
else if (dm) {
- *cage_r = dm;
+ *r_cage = dm;
}
else {
- *cage_r =
- getEditDerivedBMesh(em, ob,
- deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
+ *r_cage = getEditDerivedBMesh(
+ em, ob,
+ deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
}
}
}
@@ -2219,42 +2317,44 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
* then we need to build one.
*/
if (dm && deformedVerts) {
- *final_r = CDDM_copy(dm);
+ *r_final = CDDM_copy(dm);
- if (!(cage_r && dm == *cage_r)) dm->release(dm);
+ if (!(r_cage && dm == *r_cage)) {
+ dm->release(dm);
+ }
- CDDM_apply_vert_coords(*final_r, deformedVerts);
+ CDDM_apply_vert_coords(*r_final, deformedVerts);
}
else if (dm) {
- *final_r = dm;
+ *r_final = dm;
}
- else if (!deformedVerts && cage_r && *cage_r) {
+ else if (!deformedVerts && r_cage && *r_cage) {
/* cage should already have up to date normals */
- *final_r = *cage_r;
+ *r_final = *r_cage;
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_wmcol)
- DM_update_weight_mcol(ob, *final_r, draw_flag, NULL, 0, NULL);
+ DM_update_weight_mcol(ob, *r_final, draw_flag, NULL, 0, NULL);
if (do_init_statvis)
- DM_update_statvis_color(scene, ob, *final_r);
+ DM_update_statvis_color(scene, ob, *r_final);
}
else {
/* this is just a copy of the editmesh, no need to calc normals */
- *final_r = getEditDerivedBMesh(em, ob, deformedVerts);
+ *r_final = getEditDerivedBMesh(em, ob, deformedVerts);
deformedVerts = NULL;
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_wmcol)
- DM_update_weight_mcol(ob, *final_r, draw_flag, NULL, 0, NULL);
+ DM_update_weight_mcol(ob, *r_final, draw_flag, NULL, 0, NULL);
if (do_init_statvis)
- DM_update_statvis_color(scene, ob, *final_r);
+ DM_update_statvis_color(scene, ob, *r_final);
}
if (do_loop_normals) {
/* Compute loop normals */
- DM_calc_loop_normals(*final_r, do_loop_normals, loop_normals_split_angle);
- if (cage_r && *cage_r && (*cage_r != *final_r)) {
- DM_calc_loop_normals(*cage_r, do_loop_normals, loop_normals_split_angle);
+ DM_calc_loop_normals(*r_final, do_loop_normals, loop_normals_split_angle);
+ if (r_cage && *r_cage && (*r_cage != *r_final)) {
+ DM_calc_loop_normals(*r_cage, do_loop_normals, loop_normals_split_angle);
}
}
@@ -2263,13 +2363,13 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
* but don't recalculate if the last modifier in the stack gives us tessfaces
* check if the derived meshes are DM_TYPE_EDITBMESH before calling, this isn't essential
* but quiets annoying error messages since tessfaces wont be created. */
- if ((*final_r)->type != DM_TYPE_EDITBMESH) {
- DM_ensure_tessface(*final_r);
+ if ((*r_final)->type != DM_TYPE_EDITBMESH) {
+ DM_ensure_tessface(*r_final);
}
- if (cage_r && *cage_r) {
- if ((*cage_r)->type != DM_TYPE_EDITBMESH) {
- if (*cage_r != *final_r) {
- DM_ensure_tessface(*cage_r);
+ if (r_cage && *r_cage) {
+ if ((*r_cage)->type != DM_TYPE_EDITBMESH) {
+ if (*r_cage != *r_final) {
+ DM_ensure_tessface(*r_cage);
}
}
}
@@ -2277,12 +2377,12 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
/* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
if (!do_loop_normals) {
- dm_ensure_display_normals(*final_r);
+ dm_ensure_display_normals(*r_final);
}
/* add an orco layer if needed */
if (dataMask & CD_MASK_ORCO)
- add_orco_dm(ob, em, *final_r, orcodm, CD_ORCO);
+ add_orco_dm(ob, em, *r_final, orcodm, CD_ORCO);
if (orcodm)
orcodm->release(orcodm);
@@ -2291,24 +2391,25 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
MEM_freeN(deformedVerts);
}
-static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
- int build_shapekey_layers, int needMapping)
+static void mesh_build_data(
+ Scene *scene, Object *ob, CustomDataMask dataMask,
+ const bool build_shapekey_layers, const bool need_mapping)
{
BLI_assert(ob->type == OB_MESH);
BKE_object_free_derived_caches(ob);
BKE_object_sculpt_modifiers_changed(ob);
- mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform,
- &ob->derivedFinal, 0, 1,
- needMapping, dataMask, -1, 1, build_shapekey_layers);
+ mesh_calc_modifiers(
+ scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
+ &ob->derivedDeform, &ob->derivedFinal);
DM_set_object_boundbox(ob, ob->derivedFinal);
ob->derivedFinal->needsFree = 0;
ob->derivedDeform->needsFree = 0;
ob->lastDataMask = dataMask;
- ob->lastNeedMapping = needMapping;
+ ob->lastNeedMapping = need_mapping;
if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
@@ -2327,7 +2428,10 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C
BKE_editmesh_free_derivedmesh(em);
- editbmesh_calc_modifiers(scene, obedit, em, &em->derivedCage, &em->derivedFinal, dataMask);
+ editbmesh_calc_modifiers(
+ scene, obedit, em, dataMask,
+ &em->derivedCage, &em->derivedFinal);
+
DM_set_object_boundbox(obedit, em->derivedFinal);
em->lastDataMask = dataMask;
@@ -2337,20 +2441,22 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C
BLI_assert(!(em->derivedFinal->dirty & DM_DIRTY_NORMALS));
}
-static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, int *r_needmapping)
+static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *r_need_mapping)
{
Object *actob = scene->basact ? scene->basact->object : NULL;
CustomDataMask mask = ob->customdata_mask;
bool editing = BKE_paint_select_face_test(ob);
- if (r_needmapping)
- *r_needmapping = 0;
+ if (r_need_mapping) {
+ *r_need_mapping = false;
+ }
if (ob == actob) {
/* weight paint and face select need original indices because of selection buffer drawing */
- if (r_needmapping)
- *r_needmapping = (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT)));
+ if (r_need_mapping) {
+ *r_need_mapping = (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT | OB_MODE_VERTEX_PAINT)));
+ }
/* check if we need tfaces & mcols due to face select or texture paint */
if ((ob->mode & OB_MODE_TEXTURE_PAINT) || editing) {
@@ -2373,17 +2479,18 @@ static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, int *r
return mask;
}
-void makeDerivedMesh(Scene *scene, Object *ob, BMEditMesh *em,
- CustomDataMask dataMask, int build_shapekey_layers)
+void makeDerivedMesh(
+ Scene *scene, Object *ob, BMEditMesh *em,
+ CustomDataMask dataMask, const bool build_shapekey_layers)
{
- int needMapping;
- dataMask |= object_get_datamask(scene, ob, &needMapping);
+ bool need_mapping;
+ dataMask |= object_get_datamask(scene, ob, &need_mapping);
if (em) {
editbmesh_build_data(scene, ob, em, dataMask);
}
else {
- mesh_build_data(scene, ob, dataMask, build_shapekey_layers, needMapping);
+ mesh_build_data(scene, ob, dataMask, build_shapekey_layers, need_mapping);
}
}
@@ -2394,11 +2501,15 @@ DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dat
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- int needMapping;
- dataMask |= object_get_datamask(scene, ob, &needMapping);
+ bool need_mapping;
+ dataMask |= object_get_datamask(scene, ob, &need_mapping);
- if (!ob->derivedFinal || (dataMask & ob->lastDataMask) != dataMask || (needMapping != ob->lastNeedMapping))
- mesh_build_data(scene, ob, dataMask, 0, needMapping);
+ if (!ob->derivedFinal ||
+ ((dataMask & ob->lastDataMask) != dataMask) ||
+ (need_mapping != ob->lastNeedMapping))
+ {
+ mesh_build_data(scene, ob, dataMask, false, need_mapping);
+ }
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
return ob->derivedFinal;
@@ -2409,12 +2520,16 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- int needmapping;
+ bool need_mapping;
- dataMask |= object_get_datamask(scene, ob, &needmapping);
+ dataMask |= object_get_datamask(scene, ob, &need_mapping);
- if (!ob->derivedDeform || (dataMask & ob->lastDataMask) != dataMask || (needmapping != ob->lastNeedMapping))
- mesh_build_data(scene, ob, dataMask, 0, needmapping);
+ if (!ob->derivedDeform ||
+ ((dataMask & ob->lastDataMask) != dataMask) ||
+ (need_mapping != ob->lastNeedMapping))
+ {
+ mesh_build_data(scene, ob, dataMask, false, need_mapping);
+ }
return ob->derivedDeform;
}
@@ -2423,7 +2538,9 @@ DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask
{
DerivedMesh *final;
- mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1, 0, 0);
+ mesh_calc_modifiers(
+ scene, ob, NULL, true, 1, false, dataMask, -1, false, false,
+ NULL, &final);
return final;
}
@@ -2431,13 +2548,17 @@ DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask
DerivedMesh *mesh_create_derived_index_render(Scene *scene, Object *ob, CustomDataMask dataMask, int index)
{
DerivedMesh *final;
-
- mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, index, 0, 0);
+
+ mesh_calc_modifiers(
+ scene, ob, NULL, true, 1, false, dataMask, index, false, false,
+ NULL, &final);
return final;
}
-DerivedMesh *mesh_create_derived_view(Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_view(
+ Scene *scene, Object *ob,
+ CustomDataMask dataMask)
{
DerivedMesh *final;
@@ -2447,58 +2568,75 @@ DerivedMesh *mesh_create_derived_view(Scene *scene, Object *ob, CustomDataMask d
*/
ob->transflag |= OB_NO_PSYS_UPDATE;
- mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1, 0, 0);
+ mesh_calc_modifiers(
+ scene, ob, NULL, false, 1, false, dataMask, -1, false, false,
+ NULL, &final);
ob->transflag &= ~OB_NO_PSYS_UPDATE;
return final;
}
-DerivedMesh *mesh_create_derived_no_deform(Scene *scene, Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_no_deform(
+ Scene *scene, Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask)
{
DerivedMesh *final;
- mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, 0, 0, dataMask, -1, 0, 0);
+ mesh_calc_modifiers(
+ scene, ob, vertCos, false, 0, false, dataMask, -1, false, false,
+ NULL, &final);
return final;
}
-DerivedMesh *mesh_create_derived_no_virtual(Scene *scene, Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_no_virtual(
+ Scene *scene, Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask)
{
DerivedMesh *final;
- mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, -1, 0, dataMask, -1, 0, 0);
+ mesh_calc_modifiers(
+ scene, ob, vertCos, false, -1, false, dataMask, -1, false, false,
+ NULL, &final);
return final;
}
-DerivedMesh *mesh_create_derived_physics(Scene *scene, Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_physics(
+ Scene *scene, Object *ob, float (*vertCos)[3],
+ CustomDataMask dataMask)
{
DerivedMesh *final;
- mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, -1, 1, dataMask, -1, 0, 0);
+ mesh_calc_modifiers(
+ scene, ob, vertCos, false, -1, true, dataMask, -1, false, false,
+ NULL, &final);
return final;
}
-DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob,
- float (*vertCos)[3],
- CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_no_deform_render(
+ Scene *scene, Object *ob,
+ float (*vertCos)[3],
+ CustomDataMask dataMask)
{
DerivedMesh *final;
- mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 1, 0, 0, dataMask, -1, 0, 0);
+ mesh_calc_modifiers(
+ scene, ob, vertCos, true, 0, false, dataMask, -1, false, false,
+ NULL, &final);
return final;
}
/***/
-DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, BMEditMesh *em, DerivedMesh **r_final,
- CustomDataMask dataMask)
+DerivedMesh *editbmesh_get_derived_cage_and_final(
+ Scene *scene, Object *obedit, BMEditMesh *em,
+ CustomDataMask dataMask,
+ /* return args */
+ DerivedMesh **r_final)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
@@ -2627,8 +2765,9 @@ typedef struct {
BLI_bitmap *vertex_visit;
} MappedUserData;
-static void make_vertexcos__mapFunc(void *userData, int index, const float co[3],
- const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
+static void make_vertexcos__mapFunc(
+ void *userData, int index, const float co[3],
+ const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
{
MappedUserData *mappedData = (MappedUserData *)userData;
@@ -2851,16 +2990,24 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
/* discard degenerate faces */
is_degenerate = 0;
- if (equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) ||
- equals_v2v2(tex_coords[0], tex_coords[1]) || equals_v2v2(tex_coords[0], tex_coords[2]) || equals_v2v2(tex_coords[1], tex_coords[2]))
+ if (equals_v3v3(verts[0], verts[1]) ||
+ equals_v3v3(verts[0], verts[2]) ||
+ equals_v3v3(verts[1], verts[2]) ||
+ equals_v2v2(tex_coords[0], tex_coords[1]) ||
+ equals_v2v2(tex_coords[0], tex_coords[2]) ||
+ equals_v2v2(tex_coords[1], tex_coords[2]))
{
is_degenerate = 1;
}
/* verify last vertex as well if this is a quad */
if (is_degenerate == 0 && nr_verts == 4) {
- if (equals_v3v3(verts[3], verts[0]) || equals_v3v3(verts[3], verts[1]) || equals_v3v3(verts[3], verts[2]) ||
- equals_v2v2(tex_coords[3], tex_coords[0]) || equals_v2v2(tex_coords[3], tex_coords[1]) || equals_v2v2(tex_coords[3], tex_coords[2]))
+ if (equals_v3v3(verts[3], verts[0]) ||
+ equals_v3v3(verts[3], verts[1]) ||
+ equals_v3v3(verts[3], verts[2]) ||
+ equals_v2v2(tex_coords[3], tex_coords[0]) ||
+ equals_v2v2(tex_coords[3], tex_coords[1]) ||
+ equals_v2v2(tex_coords[3], tex_coords[2]))
{
is_degenerate = 1;
}
@@ -3413,8 +3560,9 @@ void DM_init_origspace(DerivedMesh *dm)
#ifndef NDEBUG
#include "BLI_dynstr.h"
-static void dm_debug_info_layers(DynStr *dynstr, DerivedMesh *dm, CustomData *cd,
- void *(*getElemDataArray)(DerivedMesh *, int))
+static void dm_debug_info_layers(
+ DynStr *dynstr, DerivedMesh *dm, CustomData *cd,
+ void *(*getElemDataArray)(DerivedMesh *, int))
{
int type;
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 392aac13999..c8de0786697 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -108,7 +108,7 @@ float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
/* disable subsurf temporal, get mapped cos, and enable it */
if (modifiers_disable_subsurf_temporary(obedit)) {
/* need to make new derivemesh */
- makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, 0);
+ makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
}
/* now get the cage */
@@ -247,7 +247,9 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mapped
}
}
-int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em,
+/** returns an array of deform matrices for crazyspace correction, and the
+ * number of modifiers left */
+int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob, BMEditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3])
{
ModifierData *md;
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index fbce501f57f..63cec629bf3 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -2359,7 +2359,7 @@ float (*BKE_editmesh_vertexCos_get(BMEditMesh *em, Scene *scene, int *r_numVerts
struct CageUserData data;
float (*cos_cage)[3];
- cage = editbmesh_get_derived_cage_and_final(scene, em->ob, em, &final, CD_MASK_BAREMESH);
+ cage = editbmesh_get_derived_cage_and_final(scene, em->ob, em, CD_MASK_BAREMESH, &final);
cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
/* when initializing cage verts, we only want the first cage coordinate for each vertex,
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 483968c6bd9..c1c6268924a 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -195,10 +195,10 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
}
#endif
if (em) {
- makeDerivedMesh(scene, ob, em, data_mask, 0); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
}
else {
- makeDerivedMesh(scene, ob, NULL, data_mask, 0);
+ makeDerivedMesh(scene, ob, NULL, data_mask, false);
}
break;
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index c2d2bffbbe5..560dacf72b2 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -145,7 +145,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* derivedMesh might be needed for solving parenting,
* so re-create it here */
- makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, 0);
+ makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, false);
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 8cca1c8b1ef..56de06bedac 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4310,8 +4310,9 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
if (obedit != ob)
finalDM = cageDM = editbmesh_get_derived_base(ob, em);
else
- cageDM = editbmesh_get_derived_cage_and_final(scene, ob, em, &finalDM,
- scene->customdata_mask);
+ cageDM = editbmesh_get_derived_cage_and_final(
+ scene, ob, em, scene->customdata_mask,
+ &finalDM);
DM_update_materials(finalDM, ob);
if (cageDM != finalDM) {
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index cae1fca9a79..80d8ce67b75 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -2371,7 +2371,7 @@ static void createTransEditVerts(TransInfo *t)
if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) {
/* check if we can use deform matrices for modifier from the
* start up to stack, they are more accurate than quats */
- totleft = editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos);
+ totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(t->scene, t->obedit, em, &defmats, &defcos);
}
/* if we still have more modifiers, also do crazyspace
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index b2c4970479a..9431d754b5f 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -598,7 +598,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* first try existing derivedmesh */
if (!draw_uvs_dm_shadow(em->derivedFinal)) {
/* create one if it does not exist */
- cagedm = editbmesh_get_derived_cage_and_final(scene, obedit, me->edit_btmesh, &finaldm, CD_MASK_BAREMESH | CD_MASK_MTFACE);
+ cagedm = editbmesh_get_derived_cage_and_final(
+ scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH | CD_MASK_MTFACE,
+ &finaldm);
/* when sync selection is enabled, all faces are drawn (except for hidden)
* so if cage is the same as the final, theres no point in drawing this */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 2daba6a3f0d..a9276fb5820 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -192,7 +192,8 @@ typedef struct Object {
int dupon, dupoff, dupsta, dupend;
/* did last modifier stack generation need mapping support? */
- int lastNeedMapping;
+ char lastNeedMapping; /* bool */
+ char pad[3];
/* during realtime */
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 22148d1f5ae..5bd33d2a49f 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -318,7 +318,7 @@ static void meshdeformModifier_do(
*/
if (mmd->object == md->scene->obedit) {
BMEditMesh *em = BKE_editmesh_from_object(mmd->object);
- tmpdm = editbmesh_get_derived_cage_and_final(md->scene, mmd->object, em, &cagedm, 0);
+ tmpdm = editbmesh_get_derived_cage_and_final(md->scene, mmd->object, em, 0, &cagedm);
if (tmpdm)
tmpdm->release(tmpdm);
}