Cleanup: remove unused derivedmesh code.
This commit is contained in:
@@ -87,21 +87,11 @@ struct Object;
|
|||||||
struct PBVH;
|
struct PBVH;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
|
|
||||||
/* number of sub-elements each mesh element has (for interpolation) */
|
|
||||||
// #define SUB_ELEMS_VERT 0 /* UNUSED */
|
|
||||||
#define SUB_ELEMS_EDGE 2
|
|
||||||
#define SUB_ELEMS_FACE 50
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: all mface interfaces now officially operate on tessellated data.
|
* Note: all mface interfaces now officially operate on tessellated data.
|
||||||
* Also, the mface origindex layer indexes mpolys, not mfaces.
|
* Also, the mface origindex layer indexes mpolys, not mfaces.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct DMCoNo {
|
|
||||||
float co[3];
|
|
||||||
float no[3];
|
|
||||||
} DMCoNo;
|
|
||||||
|
|
||||||
/* keep in sync with MFace/MPoly types */
|
/* keep in sync with MFace/MPoly types */
|
||||||
typedef struct DMFlagMat {
|
typedef struct DMFlagMat {
|
||||||
short mat_nr;
|
short mat_nr;
|
||||||
@@ -411,14 +401,6 @@ void *DM_get_tessface_data_layer(struct DerivedMesh *dm, int type);
|
|||||||
void *DM_get_poly_data_layer(struct DerivedMesh *dm, int type);
|
void *DM_get_poly_data_layer(struct DerivedMesh *dm, int type);
|
||||||
void *DM_get_loop_data_layer(struct DerivedMesh *dm, int type);
|
void *DM_get_loop_data_layer(struct DerivedMesh *dm, int type);
|
||||||
|
|
||||||
/* custom data setting functions
|
|
||||||
* copy supplied data into first layer of type using layer's copy function
|
|
||||||
* (deep copy if appropriate)
|
|
||||||
*/
|
|
||||||
void DM_set_vert_data(struct DerivedMesh *dm, int index, int type, void *data);
|
|
||||||
void DM_set_edge_data(struct DerivedMesh *dm, int index, int type, void *data);
|
|
||||||
void DM_set_tessface_data(struct DerivedMesh *dm, int index, int type, void *data);
|
|
||||||
|
|
||||||
/* custom data copy functions
|
/* custom data copy functions
|
||||||
* copy count elements from source_index in source to dest_index in dest
|
* 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
|
* these copy all layers for which the CD_FLAG_NOCOPY flag is not set
|
||||||
@@ -426,28 +408,6 @@ void DM_set_tessface_data(struct DerivedMesh *dm, int index, int type, void *dat
|
|||||||
void DM_copy_vert_data(
|
void DM_copy_vert_data(
|
||||||
struct DerivedMesh *source, struct DerivedMesh *dest,
|
struct DerivedMesh *source, struct DerivedMesh *dest,
|
||||||
int source_index, int dest_index, int count);
|
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
|
|
||||||
* they free all layers for which the CD_FLAG_NOCOPY flag is not set
|
|
||||||
*/
|
|
||||||
void DM_free_vert_data(struct DerivedMesh *dm, int index, int count);
|
|
||||||
void DM_free_edge_data(struct DerivedMesh *dm, int index, int count);
|
|
||||||
void DM_free_tessface_data(struct DerivedMesh *dm, int index, int count);
|
|
||||||
void DM_free_loop_data(struct DerivedMesh *dm, int index, int count);
|
|
||||||
void DM_free_poly_data(struct DerivedMesh *dm, int index, int count);
|
|
||||||
|
|
||||||
/*sets up mpolys for a DM based on face iterators in source*/
|
/*sets up mpolys for a DM based on face iterators in source*/
|
||||||
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
|
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
|
||||||
@@ -461,31 +421,6 @@ void DM_interp_vert_data(
|
|||||||
int *src_indices, float *weights,
|
int *src_indices, float *weights,
|
||||||
int count, int dest_index);
|
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);
|
|
||||||
|
|
||||||
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_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 mesh_get_mapped_verts_coords(struct Mesh *me_eval, float (*r_cos)[3], const int totcos);
|
void mesh_get_mapped_verts_coords(struct Mesh *me_eval, float (*r_cos)[3], const int totcos);
|
||||||
|
|
||||||
DerivedMesh *mesh_create_derived_render(
|
DerivedMesh *mesh_create_derived_render(
|
||||||
@@ -510,18 +445,12 @@ float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
|
|||||||
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, bool has_prev_mesh);
|
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, bool has_prev_mesh);
|
||||||
void makeDerivedMesh(
|
void makeDerivedMesh(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
|
||||||
const struct CustomData_MeshMasks *dataMask, const bool build_shapekey_layers);
|
const struct CustomData_MeshMasks *dataMask);
|
||||||
|
|
||||||
void DM_add_named_tangent_layer_for_uv(
|
|
||||||
CustomData *uv_data, CustomData *tan_data, int numLoopData,
|
|
||||||
const char *layer_name);
|
|
||||||
|
|
||||||
void DM_calc_loop_tangents(
|
void DM_calc_loop_tangents(
|
||||||
DerivedMesh *dm, bool calc_active_tangent, const char (*tangent_names)[MAX_NAME],
|
DerivedMesh *dm, bool calc_active_tangent, const char (*tangent_names)[MAX_NAME],
|
||||||
int tangent_names_count);
|
int tangent_names_count);
|
||||||
|
|
||||||
void DM_init_origspace(DerivedMesh *dm);
|
|
||||||
|
|
||||||
/* debug only */
|
/* debug only */
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
char *DM_debug_info(DerivedMesh *dm);
|
char *DM_debug_info(DerivedMesh *dm);
|
||||||
|
@@ -39,13 +39,6 @@ struct Mesh;
|
|||||||
struct Object;
|
struct Object;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
|
|
||||||
/* Undefine to hide DerivedMesh-based function declarations */
|
|
||||||
#undef USE_DERIVEDMESH
|
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
struct DerivedMesh;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void BKE_mesh_runtime_reset(struct Mesh *mesh);
|
void BKE_mesh_runtime_reset(struct Mesh *mesh);
|
||||||
void BKE_mesh_runtime_reset_on_copy(struct Mesh *mesh, const int flag);
|
void BKE_mesh_runtime_reset_on_copy(struct Mesh *mesh, const int flag);
|
||||||
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
|
int BKE_mesh_runtime_looptri_len(const struct Mesh *mesh);
|
||||||
@@ -64,19 +57,9 @@ void BKE_mesh_runtime_verttri_from_looptri(
|
|||||||
* to a more suitable location when that file is removed.
|
* to a more suitable location when that file is removed.
|
||||||
* They should also be renamed to use conventions from BKE, not old DerivedMesh.c.
|
* They should also be renamed to use conventions from BKE, not old DerivedMesh.c.
|
||||||
* For now keep the names similar to avoid confusion. */
|
* For now keep the names similar to avoid confusion. */
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
struct DerivedMesh *mesh_get_derived_final(
|
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
|
||||||
#endif
|
|
||||||
struct Mesh *mesh_get_eval_final(
|
struct Mesh *mesh_get_eval_final(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
struct DerivedMesh *mesh_get_derived_deform(
|
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
|
||||||
#endif
|
|
||||||
struct Mesh *mesh_get_eval_deform(
|
struct Mesh *mesh_get_eval_deform(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
struct Depsgraph *depsgraph, struct Scene *scene,
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
||||||
@@ -85,32 +68,20 @@ struct Mesh *mesh_create_eval_final_render(
|
|||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
struct Depsgraph *depsgraph, struct Scene *scene,
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
struct DerivedMesh *mesh_create_derived_index_render(
|
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
|
|
||||||
#endif
|
|
||||||
struct Mesh *mesh_create_eval_final_index_render(
|
struct Mesh *mesh_create_eval_final_index_render(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
struct Depsgraph *depsgraph, struct Scene *scene,
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
|
struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
struct DerivedMesh *mesh_create_derived_view(
|
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
|
||||||
#endif
|
|
||||||
struct Mesh *mesh_create_eval_final_view(
|
struct Mesh *mesh_create_eval_final_view(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
struct Depsgraph *depsgraph, struct Scene *scene,
|
||||||
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
||||||
|
|
||||||
struct Mesh *mesh_create_eval_no_deform(
|
struct Mesh *mesh_create_eval_no_deform(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
struct Depsgraph *depsgraph, struct Scene *scene,
|
||||||
struct Object *ob, float (*vertCos)[3],
|
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
||||||
const struct CustomData_MeshMasks *dataMask);
|
|
||||||
struct Mesh *mesh_create_eval_no_deform_render(
|
struct Mesh *mesh_create_eval_no_deform_render(
|
||||||
struct Depsgraph *depsgraph, struct Scene *scene,
|
struct Depsgraph *depsgraph, struct Scene *scene,
|
||||||
struct Object *ob, float (*vertCos)[3],
|
struct Object *ob, const struct CustomData_MeshMasks *dataMask);
|
||||||
const struct CustomData_MeshMasks *dataMask);
|
|
||||||
|
|
||||||
|
|
||||||
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
|
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
|
||||||
|
@@ -431,14 +431,6 @@ void modwrap_deformVertsEM(
|
|||||||
struct BMEditMesh *em, struct Mesh *me,
|
struct BMEditMesh *em, struct Mesh *me,
|
||||||
float (*vertexCos)[3], int numVerts);
|
float (*vertexCos)[3], int numVerts);
|
||||||
|
|
||||||
/* wrappers for modifier callbacks that accept Mesh and select the proper implementation
|
|
||||||
* depending on if the modifier has been ported to Mesh or is still using DerivedMesh
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct DerivedMesh *modifier_applyModifier_DM_deprecated(
|
|
||||||
struct ModifierData *md, const struct ModifierEvalContext *ctx,
|
|
||||||
struct DerivedMesh *dm);
|
|
||||||
|
|
||||||
struct Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(
|
struct Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(
|
||||||
struct Object *ob_eval, const bool get_cage_mesh);
|
struct Object *ob_eval, const bool get_cage_mesh);
|
||||||
|
|
||||||
|
@@ -768,21 +768,6 @@ void *DM_get_loop_data_layer(DerivedMesh *dm, int type)
|
|||||||
return CustomData_get_layer(&dm->loopData, type);
|
return CustomData_get_layer(&dm->loopData, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DM_set_vert_data(DerivedMesh *dm, int index, int type, void *data)
|
|
||||||
{
|
|
||||||
CustomData_set(&dm->vertData, index, type, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_set_edge_data(DerivedMesh *dm, int index, int type, void *data)
|
|
||||||
{
|
|
||||||
CustomData_set(&dm->edgeData, index, type, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_set_tessface_data(DerivedMesh *dm, int index, int type, void *data)
|
|
||||||
{
|
|
||||||
CustomData_set(&dm->faceData, index, type, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest,
|
void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest,
|
||||||
int source_index, int dest_index, int count)
|
int source_index, int dest_index, int count)
|
||||||
{
|
{
|
||||||
@@ -790,59 +775,6 @@ void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest,
|
|||||||
source_index, dest_index, count);
|
source_index, dest_index, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DM_copy_edge_data(DerivedMesh *source, DerivedMesh *dest,
|
|
||||||
int source_index, int dest_index, int count)
|
|
||||||
{
|
|
||||||
CustomData_copy_data(&source->edgeData, &dest->edgeData,
|
|
||||||
source_index, dest_index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_copy_tessface_data(DerivedMesh *source, DerivedMesh *dest,
|
|
||||||
int source_index, int dest_index, int count)
|
|
||||||
{
|
|
||||||
CustomData_copy_data(&source->faceData, &dest->faceData,
|
|
||||||
source_index, dest_index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_copy_loop_data(DerivedMesh *source, DerivedMesh *dest,
|
|
||||||
int source_index, int dest_index, int count)
|
|
||||||
{
|
|
||||||
CustomData_copy_data(&source->loopData, &dest->loopData,
|
|
||||||
source_index, dest_index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_copy_poly_data(DerivedMesh *source, DerivedMesh *dest,
|
|
||||||
int source_index, int dest_index, int count)
|
|
||||||
{
|
|
||||||
CustomData_copy_data(&source->polyData, &dest->polyData,
|
|
||||||
source_index, dest_index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_free_vert_data(struct DerivedMesh *dm, int index, int count)
|
|
||||||
{
|
|
||||||
CustomData_free_elem(&dm->vertData, index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_free_edge_data(struct DerivedMesh *dm, int index, int count)
|
|
||||||
{
|
|
||||||
CustomData_free_elem(&dm->edgeData, index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_free_tessface_data(struct DerivedMesh *dm, int index, int count)
|
|
||||||
{
|
|
||||||
CustomData_free_elem(&dm->faceData, index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_free_loop_data(struct DerivedMesh *dm, int index, int count)
|
|
||||||
{
|
|
||||||
CustomData_free_elem(&dm->loopData, index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_free_poly_data(struct DerivedMesh *dm, int index, int count)
|
|
||||||
{
|
|
||||||
CustomData_free_elem(&dm->polyData, index, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* interpolates vertex data from the vertices indexed by src_indices in the
|
* 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
|
* source mesh using the given weights and stores the result in the vertex
|
||||||
@@ -857,60 +789,6 @@ void DM_interp_vert_data(
|
|||||||
weights, NULL, count, dest_index);
|
weights, NULL, count, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
CustomData_interp(&source->polyData, &dest->polyData, src_indices,
|
|
||||||
weights, NULL, count, dest_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
|
DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
|
||||||
{
|
{
|
||||||
DerivedMesh *dm = CDDM_from_mesh(me);
|
DerivedMesh *dm = CDDM_from_mesh(me);
|
||||||
@@ -1105,43 +983,6 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_shapekey_layers(Mesh *me_dst, Mesh *me_src, Object *UNUSED(ob))
|
|
||||||
{
|
|
||||||
KeyBlock *kb;
|
|
||||||
Key *key = me_src->key;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!me_src->key)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* ensure we can use mesh vertex count for derived mesh custom data */
|
|
||||||
if (me_src->totvert != me_dst->totvert) {
|
|
||||||
CLOG_WARN(&LOG, "vertex size mismatch (mesh/eval) '%s' (%d != %d)",
|
|
||||||
me_src->id.name + 2, me_src->totvert, me_dst->totvert);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0, kb = key->block.first; kb; kb = kb->next, i++) {
|
|
||||||
int ci;
|
|
||||||
float *array;
|
|
||||||
|
|
||||||
if (me_src->totvert != kb->totelem) {
|
|
||||||
CLOG_WARN(&LOG, "vertex size mismatch (Mesh '%s':%d != KeyBlock '%s':%d)",
|
|
||||||
me_src->id.name + 2, me_src->totvert, kb->name, kb->totelem);
|
|
||||||
array = MEM_calloc_arrayN((size_t)me_src->totvert, sizeof(float[3]), __func__);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
array = MEM_malloc_arrayN((size_t)me_src->totvert, sizeof(float[3]), __func__);
|
|
||||||
memcpy(array, kb->data, (size_t)me_src->totvert * sizeof(float[3]));
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomData_add_layer_named(&me_dst->vdata, CD_SHAPEKEY, CD_ASSIGN, array, me_dst->totvert, kb->name);
|
|
||||||
ci = CustomData_get_layer_index_n(&me_dst->vdata, CD_SHAPEKEY, i);
|
|
||||||
|
|
||||||
me_dst->vdata.layers[ci].uid = kb->uid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
|
static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
|
||||||
{
|
{
|
||||||
if (me_orig->flag & ME_AUTOSMOOTH) {
|
if (me_orig->flag & ME_AUTOSMOOTH) {
|
||||||
@@ -1151,12 +992,16 @@ static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mesh_calc_modifiers(
|
static void mesh_calc_modifiers(
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
|
struct Depsgraph *depsgraph,
|
||||||
|
Scene *scene, Object *ob,
|
||||||
int useDeform,
|
int useDeform,
|
||||||
const bool need_mapping, const CustomData_MeshMasks *dataMask,
|
const bool need_mapping,
|
||||||
const int index, const bool useCache, const bool build_shapekey_layers,
|
const CustomData_MeshMasks *dataMask,
|
||||||
|
const int index,
|
||||||
|
const bool useCache,
|
||||||
/* return args */
|
/* return args */
|
||||||
Mesh **r_deform, Mesh **r_final)
|
Mesh **r_deform,
|
||||||
|
Mesh **r_final)
|
||||||
{
|
{
|
||||||
ModifierData *firstmd, *md, *previewmd = NULL;
|
ModifierData *firstmd, *md, *previewmd = NULL;
|
||||||
CDMaskLink *datamasks, *curr;
|
CDMaskLink *datamasks, *curr;
|
||||||
@@ -1226,9 +1071,6 @@ static void mesh_calc_modifiers(
|
|||||||
Mesh *me = NULL;
|
Mesh *me = NULL;
|
||||||
|
|
||||||
if (useDeform) {
|
if (useDeform) {
|
||||||
if (inputVertexCos)
|
|
||||||
deformedVerts = inputVertexCos;
|
|
||||||
|
|
||||||
/* Apply all leading deforming modifiers */
|
/* Apply all leading deforming modifiers */
|
||||||
for (; md; md = md->next, curr = curr->next) {
|
for (; md; md = md->next, curr = curr->next) {
|
||||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||||
@@ -1274,12 +1116,6 @@ static void mesh_calc_modifiers(
|
|||||||
if (r_deform) {
|
if (r_deform) {
|
||||||
*r_deform = BKE_mesh_copy_for_eval(ob->data, true);
|
*r_deform = BKE_mesh_copy_for_eval(ob->data, true);
|
||||||
|
|
||||||
/* XXX: Is build_shapekey_layers ever even true? This should have crashed long ago... */
|
|
||||||
BLI_assert(!build_shapekey_layers);
|
|
||||||
if (build_shapekey_layers) {
|
|
||||||
add_shapekey_layers(*r_deform, ob->data, ob);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deformedVerts) {
|
if (deformedVerts) {
|
||||||
BKE_mesh_apply_vert_coords(*r_deform, deformedVerts);
|
BKE_mesh_apply_vert_coords(*r_deform, deformedVerts);
|
||||||
}
|
}
|
||||||
@@ -1287,10 +1123,7 @@ static void mesh_calc_modifiers(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* default behavior for meshes */
|
/* default behavior for meshes */
|
||||||
if (inputVertexCos)
|
deformedVerts = BKE_mesh_vertexCos_get(ob->data, &numVerts);
|
||||||
deformedVerts = inputVertexCos;
|
|
||||||
else
|
|
||||||
deformedVerts = BKE_mesh_vertexCos_get(ob->data, &numVerts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1414,10 +1247,6 @@ static void mesh_calc_modifiers(
|
|||||||
me = BKE_mesh_copy_for_eval(ob->data, true);
|
me = BKE_mesh_copy_for_eval(ob->data, true);
|
||||||
ASSERT_IS_VALID_MESH(me);
|
ASSERT_IS_VALID_MESH(me);
|
||||||
|
|
||||||
if (build_shapekey_layers) {
|
|
||||||
add_shapekey_layers(me, ob->data, ob);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deformedVerts) {
|
if (deformedVerts) {
|
||||||
BKE_mesh_apply_vert_coords(me, deformedVerts);
|
BKE_mesh_apply_vert_coords(me, deformedVerts);
|
||||||
}
|
}
|
||||||
@@ -1480,9 +1309,7 @@ static void mesh_calc_modifiers(
|
|||||||
me = me_next;
|
me = me_next;
|
||||||
|
|
||||||
if (deformedVerts) {
|
if (deformedVerts) {
|
||||||
if (deformedVerts != inputVertexCos) {
|
MEM_freeN(deformedVerts);
|
||||||
MEM_freeN(deformedVerts);
|
|
||||||
}
|
|
||||||
deformedVerts = NULL;
|
deformedVerts = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1585,10 +1412,6 @@ static void mesh_calc_modifiers(
|
|||||||
else {
|
else {
|
||||||
*r_final = BKE_mesh_copy_for_eval(ob->data, true);
|
*r_final = BKE_mesh_copy_for_eval(ob->data, true);
|
||||||
|
|
||||||
if (build_shapekey_layers) {
|
|
||||||
add_shapekey_layers(*r_final, ob->data, ob);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deformedVerts) {
|
if (deformedVerts) {
|
||||||
BKE_mesh_apply_vert_coords(*r_final, deformedVerts);
|
BKE_mesh_apply_vert_coords(*r_final, deformedVerts);
|
||||||
}
|
}
|
||||||
@@ -1647,39 +1470,13 @@ static void mesh_calc_modifiers(
|
|||||||
BKE_id_free(NULL, me_orco_cloth);
|
BKE_id_free(NULL, me_orco_cloth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deformedVerts && deformedVerts != inputVertexCos)
|
if (deformedVerts)
|
||||||
MEM_freeN(deformedVerts);
|
MEM_freeN(deformedVerts);
|
||||||
|
|
||||||
BLI_linklist_free((LinkNode *)datamasks, NULL);
|
BLI_linklist_free((LinkNode *)datamasks, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
static void mesh_calc_modifiers_dm(
|
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
|
|
||||||
int useDeform,
|
|
||||||
const bool need_mapping, const CustomData_MeshMasks *dataMask,
|
|
||||||
const int index, const bool useCache, const bool build_shapekey_layers,
|
|
||||||
/* return args */
|
|
||||||
DerivedMesh **r_deformdm, DerivedMesh **r_finaldm)
|
|
||||||
{
|
|
||||||
Mesh *deform_mesh = NULL, *final_mesh = NULL;
|
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
|
||||||
depsgraph, scene, ob, inputVertexCos, useDeform,
|
|
||||||
need_mapping, dataMask, index, useCache, build_shapekey_layers,
|
|
||||||
(r_deformdm ? &deform_mesh : NULL), &final_mesh);
|
|
||||||
|
|
||||||
if (deform_mesh) {
|
|
||||||
*r_deformdm = CDDM_from_mesh_ex(deform_mesh, CD_DUPLICATE, &CD_MASK_MESH);
|
|
||||||
BKE_id_free(NULL, deform_mesh);
|
|
||||||
}
|
|
||||||
|
|
||||||
*r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE, &CD_MASK_MESH);
|
|
||||||
BKE_id_free(NULL, final_mesh);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *r_numVerts))[3]
|
float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *r_numVerts))[3]
|
||||||
{
|
{
|
||||||
BMIter iter;
|
BMIter iter;
|
||||||
@@ -1716,10 +1513,14 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, bool has_prev
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void editbmesh_calc_modifiers(
|
static void editbmesh_calc_modifiers(
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
|
struct Depsgraph *depsgraph,
|
||||||
BMEditMesh *em, const CustomData_MeshMasks *dataMask,
|
Scene *scene,
|
||||||
|
Object *ob,
|
||||||
|
BMEditMesh *em,
|
||||||
|
const CustomData_MeshMasks *dataMask,
|
||||||
/* return args */
|
/* return args */
|
||||||
Mesh **r_cage, Mesh **r_final)
|
Mesh **r_cage,
|
||||||
|
Mesh **r_final)
|
||||||
{
|
{
|
||||||
ModifierData *md;
|
ModifierData *md;
|
||||||
float (*deformedVerts)[3] = NULL;
|
float (*deformedVerts)[3] = NULL;
|
||||||
@@ -2094,7 +1895,7 @@ static void mesh_runtime_check_normals_valid(const Mesh *mesh)
|
|||||||
|
|
||||||
static void mesh_build_data(
|
static void mesh_build_data(
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask,
|
struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask,
|
||||||
const bool build_shapekey_layers, const bool need_mapping)
|
const bool need_mapping)
|
||||||
{
|
{
|
||||||
BLI_assert(ob->type == OB_MESH);
|
BLI_assert(ob->type == OB_MESH);
|
||||||
|
|
||||||
@@ -2115,15 +1916,9 @@ static void mesh_build_data(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
mesh_calc_modifiers(
|
||||||
depsgraph, scene, ob, NULL, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
|
depsgraph, scene, ob, 1, need_mapping, dataMask, -1, true,
|
||||||
&ob->runtime.mesh_deform_eval, &ob->runtime.mesh_eval);
|
&ob->runtime.mesh_deform_eval, &ob->runtime.mesh_eval);
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
/* TODO(campbell): remove these copies, they are expected in various places over the code. */
|
|
||||||
ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, &CD_MASK_MESH);
|
|
||||||
ob->derivedFinal = CDDM_from_mesh_ex(ob->runtime.mesh_eval, CD_REFERENCE, &CD_MASK_MESH);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
|
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
|
||||||
/* Only copy texspace from orig mesh if some modifier (hint: smoke sim, see T58492)
|
/* Only copy texspace from orig mesh if some modifier (hint: smoke sim, see T58492)
|
||||||
* did not re-enable that flag (which always get disabled for eval mesh as a start). */
|
* did not re-enable that flag (which always get disabled for eval mesh as a start). */
|
||||||
@@ -2133,10 +1928,6 @@ static void mesh_build_data(
|
|||||||
|
|
||||||
mesh_finalize_eval(ob);
|
mesh_finalize_eval(ob);
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
ob->derivedFinal->needsFree = 0;
|
|
||||||
ob->derivedDeform->needsFree = 0;
|
|
||||||
#endif
|
|
||||||
ob->runtime.last_data_mask = *dataMask;
|
ob->runtime.last_data_mask = *dataMask;
|
||||||
ob->runtime.last_need_mapping = need_mapping;
|
ob->runtime.last_need_mapping = need_mapping;
|
||||||
|
|
||||||
@@ -2221,7 +2012,7 @@ static void object_get_datamask(const Depsgraph *depsgraph, Object *ob, CustomDa
|
|||||||
|
|
||||||
void makeDerivedMesh(
|
void makeDerivedMesh(
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em,
|
struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em,
|
||||||
const CustomData_MeshMasks *dataMask, const bool build_shapekey_layers)
|
const CustomData_MeshMasks *dataMask)
|
||||||
{
|
{
|
||||||
bool need_mapping;
|
bool need_mapping;
|
||||||
CustomData_MeshMasks cddata_masks = *dataMask;
|
CustomData_MeshMasks cddata_masks = *dataMask;
|
||||||
@@ -2231,35 +2022,12 @@ void makeDerivedMesh(
|
|||||||
editbmesh_build_data(depsgraph, scene, ob, em, &cddata_masks);
|
editbmesh_build_data(depsgraph, scene, ob, em, &cddata_masks);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mesh_build_data(depsgraph, scene, ob, &cddata_masks, build_shapekey_layers, need_mapping);
|
mesh_build_data(depsgraph, scene, ob, &cddata_masks, need_mapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
/* Deprecated DM, use: 'mesh_get_eval_final'. */
|
|
||||||
DerivedMesh *mesh_get_derived_final(
|
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
|
||||||
{
|
|
||||||
/* if there's no derived mesh or the last data mask used doesn't include
|
|
||||||
* the data we need, rebuild the derived mesh
|
|
||||||
*/
|
|
||||||
bool need_mapping;
|
|
||||||
CustomData_MeshMasks cddata_masks = *dataMask;
|
|
||||||
object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
|
|
||||||
|
|
||||||
if (!ob->derivedFinal ||
|
|
||||||
!CustomData_MeshMasks_are_matching(&(ob->lastDataMask), &cddata_masks) ||
|
|
||||||
(need_mapping != ob->lastNeedMapping))
|
|
||||||
{
|
|
||||||
mesh_build_data(depsgraph, scene, ob, cddata_masks, false, need_mapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
|
|
||||||
return ob->derivedFinal;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
||||||
{
|
{
|
||||||
/* This function isn't thread-safe and can't be used during evaluation. */
|
/* This function isn't thread-safe and can't be used during evaluation. */
|
||||||
@@ -2282,35 +2050,13 @@ Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
|
|||||||
{
|
{
|
||||||
CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
|
CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
|
||||||
mesh_build_data(depsgraph, scene, ob, &cddata_masks,
|
mesh_build_data(depsgraph, scene, ob, &cddata_masks,
|
||||||
false, need_mapping || ob->runtime.last_need_mapping);
|
need_mapping || ob->runtime.last_need_mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ob->runtime.mesh_eval) { BLI_assert(!(ob->runtime.mesh_eval->runtime.cd_dirty_vert & CD_MASK_NORMAL)); }
|
if (ob->runtime.mesh_eval) { BLI_assert(!(ob->runtime.mesh_eval->runtime.cd_dirty_vert & CD_MASK_NORMAL)); }
|
||||||
return ob->runtime.mesh_eval;
|
return ob->runtime.mesh_eval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
/* Deprecated DM, use: 'mesh_get_eval_deform' instead. */
|
|
||||||
DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
|
||||||
{
|
|
||||||
/* if there's no derived mesh or the last data mask used doesn't include
|
|
||||||
* the data we need, rebuild the derived mesh
|
|
||||||
*/
|
|
||||||
bool need_mapping;
|
|
||||||
|
|
||||||
CustomData_MeshMasks cddata_masks = *dataMask;
|
|
||||||
object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
|
|
||||||
|
|
||||||
if (!ob->derivedDeform ||
|
|
||||||
!CustomData_MeshMasks_are_matching(&(ob->lastDataMask), &cddata_masks) ||
|
|
||||||
(need_mapping != ob->lastNeedMapping))
|
|
||||||
{
|
|
||||||
mesh_build_data(depsgraph, scene, ob, cddata_masks, false, need_mapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ob->derivedDeform;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
||||||
{
|
{
|
||||||
/* This function isn't thread-safe and can't be used during evaluation. */
|
/* This function isn't thread-safe and can't be used during evaluation. */
|
||||||
@@ -2334,52 +2080,24 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob
|
|||||||
{
|
{
|
||||||
CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
|
CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
|
||||||
mesh_build_data(depsgraph, scene, ob, &cddata_masks,
|
mesh_build_data(depsgraph, scene, ob, &cddata_masks,
|
||||||
false, need_mapping || ob->runtime.last_need_mapping);
|
need_mapping || ob->runtime.last_need_mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ob->runtime.mesh_deform_eval;
|
return ob->runtime.mesh_deform_eval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
/* Deprecated, use `mesh_create_eval_final_render` instead. */
|
|
||||||
DerivedMesh *mesh_create_derived_render(
|
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
|
||||||
{
|
|
||||||
DerivedMesh *final;
|
|
||||||
|
|
||||||
mesh_calc_modifiers_dm(
|
|
||||||
depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
|
|
||||||
NULL, &final);
|
|
||||||
|
|
||||||
return final;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Mesh *mesh_create_eval_final_render(Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
Mesh *mesh_create_eval_final_render(Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
|
||||||
{
|
{
|
||||||
Mesh *final;
|
Mesh *final;
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
mesh_calc_modifiers(
|
||||||
depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
|
depsgraph, scene, ob, 1, false, dataMask, -1, false,
|
||||||
NULL, &final);
|
NULL, &final);
|
||||||
|
|
||||||
return final;
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
/* Deprecated, use `mesh_create_eval_final_index_render` instead. */
|
|
||||||
DerivedMesh *mesh_create_derived_index_render(
|
|
||||||
struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask, int index)
|
|
||||||
{
|
|
||||||
DerivedMesh *final;
|
|
||||||
|
|
||||||
mesh_calc_modifiers_dm(
|
|
||||||
depsgraph, scene, ob, NULL, 1, false, dataMask, index, false, false,
|
|
||||||
NULL, &final);
|
|
||||||
|
|
||||||
return final;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Mesh *mesh_create_eval_final_index_render(
|
Mesh *mesh_create_eval_final_index_render(
|
||||||
Depsgraph *depsgraph, Scene *scene,
|
Depsgraph *depsgraph, Scene *scene,
|
||||||
Object *ob, const CustomData_MeshMasks *dataMask, int index)
|
Object *ob, const CustomData_MeshMasks *dataMask, int index)
|
||||||
@@ -2387,36 +2105,12 @@ Mesh *mesh_create_eval_final_index_render(
|
|||||||
Mesh *final;
|
Mesh *final;
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
mesh_calc_modifiers(
|
||||||
depsgraph, scene, ob, NULL, 1, false, dataMask, index, false, false,
|
depsgraph, scene, ob, 1, false, dataMask, index, false,
|
||||||
NULL, &final);
|
NULL, &final);
|
||||||
|
|
||||||
return final;
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DERIVEDMESH
|
|
||||||
/* Deprecated, use `mesh_create_eval_final_view` instead. */
|
|
||||||
DerivedMesh *mesh_create_derived_view(
|
|
||||||
struct Depsgraph *depsgraph, Scene *scene,
|
|
||||||
Object *ob, const CustomData_MeshMasks *dataMask)
|
|
||||||
{
|
|
||||||
DerivedMesh *final;
|
|
||||||
|
|
||||||
/* XXX hack
|
|
||||||
* psys modifier updates particle state when called during dupli-list generation,
|
|
||||||
* which can lead to wrong transforms. This disables particle system modifier execution.
|
|
||||||
*/
|
|
||||||
ob->transflag |= OB_NO_PSYS_UPDATE;
|
|
||||||
|
|
||||||
mesh_calc_modifiers_dm(
|
|
||||||
depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
|
|
||||||
NULL, &final);
|
|
||||||
|
|
||||||
ob->transflag &= ~OB_NO_PSYS_UPDATE;
|
|
||||||
|
|
||||||
return final;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Mesh *mesh_create_eval_final_view(
|
Mesh *mesh_create_eval_final_view(
|
||||||
Depsgraph *depsgraph, Scene *scene,
|
Depsgraph *depsgraph, Scene *scene,
|
||||||
Object *ob, const CustomData_MeshMasks *dataMask)
|
Object *ob, const CustomData_MeshMasks *dataMask)
|
||||||
@@ -2430,7 +2124,7 @@ Mesh *mesh_create_eval_final_view(
|
|||||||
ob->transflag |= OB_NO_PSYS_UPDATE;
|
ob->transflag |= OB_NO_PSYS_UPDATE;
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
mesh_calc_modifiers(
|
||||||
depsgraph, scene, ob, NULL, 1, false, dataMask, -1, false, false,
|
depsgraph, scene, ob, 1, false, dataMask, -1, false,
|
||||||
NULL, &final);
|
NULL, &final);
|
||||||
|
|
||||||
ob->transflag &= ~OB_NO_PSYS_UPDATE;
|
ob->transflag &= ~OB_NO_PSYS_UPDATE;
|
||||||
@@ -2440,12 +2134,12 @@ Mesh *mesh_create_eval_final_view(
|
|||||||
|
|
||||||
Mesh *mesh_create_eval_no_deform(
|
Mesh *mesh_create_eval_no_deform(
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob,
|
Depsgraph *depsgraph, Scene *scene, Object *ob,
|
||||||
float (*vertCos)[3], const CustomData_MeshMasks *dataMask)
|
const CustomData_MeshMasks *dataMask)
|
||||||
{
|
{
|
||||||
Mesh *final;
|
Mesh *final;
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
mesh_calc_modifiers(
|
||||||
depsgraph, scene, ob, vertCos, 0, false, dataMask, -1, false, false,
|
depsgraph, scene, ob, 0, false, dataMask, -1, false,
|
||||||
NULL, &final);
|
NULL, &final);
|
||||||
|
|
||||||
return final;
|
return final;
|
||||||
@@ -2453,12 +2147,12 @@ Mesh *mesh_create_eval_no_deform(
|
|||||||
|
|
||||||
Mesh *mesh_create_eval_no_deform_render(
|
Mesh *mesh_create_eval_no_deform_render(
|
||||||
Depsgraph *depsgraph, Scene *scene, Object *ob,
|
Depsgraph *depsgraph, Scene *scene, Object *ob,
|
||||||
float (*vertCos)[3], const CustomData_MeshMasks *dataMask)
|
const CustomData_MeshMasks *dataMask)
|
||||||
{
|
{
|
||||||
Mesh *final;
|
Mesh *final;
|
||||||
|
|
||||||
mesh_calc_modifiers(
|
mesh_calc_modifiers(
|
||||||
depsgraph, scene, ob, vertCos, 0, false, dataMask, -1, false, false,
|
depsgraph, scene, ob, 0, false, dataMask, -1, false,
|
||||||
NULL, &final);
|
NULL, &final);
|
||||||
|
|
||||||
return final;
|
return final;
|
||||||
@@ -2523,66 +2217,6 @@ Mesh *editbmesh_get_eval_cage_from_orig(
|
|||||||
|
|
||||||
/***/
|
/***/
|
||||||
|
|
||||||
/* UNUSED */
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
/* ********* For those who don't grasp derived stuff! (ton) :) *************** */
|
|
||||||
|
|
||||||
static void make_vertexcosnos__mapFunc(void *userData, int index, const float co[3],
|
|
||||||
const float no_f[3], const short no_s[3])
|
|
||||||
{
|
|
||||||
DMCoNo *co_no = &((DMCoNo *)userData)[index];
|
|
||||||
|
|
||||||
/* check if we've been here before (normal should not be 0) */
|
|
||||||
if (!is_zero_v3(co_no->no)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_v3_v3(co_no->co, co);
|
|
||||||
if (no_f) {
|
|
||||||
copy_v3_v3(co_no->no, no_f);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
normal_short_to_float_v3(co_no->no, no_s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* always returns original amount me->totvert of vertices and normals, but fully deformed and subsurfered */
|
|
||||||
/* this is needed for all code using vertexgroups (no subsurf support) */
|
|
||||||
/* it stores the normals as floats, but they can still be scaled as shorts (32767 = unit) */
|
|
||||||
/* in use now by vertex/weight paint and particle generating */
|
|
||||||
|
|
||||||
DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
|
|
||||||
{
|
|
||||||
Mesh *me = ob->data;
|
|
||||||
DerivedMesh *dm;
|
|
||||||
DMCoNo *vertexcosnos;
|
|
||||||
|
|
||||||
/* lets prevent crashing... */
|
|
||||||
if (ob->type != OB_MESH || me->totvert == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dm = mesh_get_derived_final(scene, ob, &CD_MASK_BAREMESH_ORIGINDEX);
|
|
||||||
|
|
||||||
if (dm->foreachMappedVert) {
|
|
||||||
vertexcosnos = MEM_calloc_arrayN(me->totvert, sizeof(DMCoNo), "vertexcosnos map");
|
|
||||||
dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DMCoNo *v_co_no = vertexcosnos = MEM_malloc_arrayN(me->totvert, sizeof(DMCoNo), "vertexcosnos map");
|
|
||||||
int a;
|
|
||||||
for (a = 0; a < me->totvert; a++, v_co_no++) {
|
|
||||||
dm->getVertCo(dm, a, v_co_no->co);
|
|
||||||
dm->getVertNo(dm, a, v_co_no->no);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dm->release(dm);
|
|
||||||
return vertexcosnos;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* same as above but for vert coords */
|
/* same as above but for vert coords */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float (*vertexcos)[3];
|
float (*vertexcos)[3];
|
||||||
@@ -2622,19 +2256,6 @@ void mesh_get_mapped_verts_coords(Mesh *me_eval, float (*r_cos)[3], const int to
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DM_add_named_tangent_layer_for_uv(
|
|
||||||
CustomData *uv_data, CustomData *tan_data, int numLoopData,
|
|
||||||
const char *layer_name)
|
|
||||||
{
|
|
||||||
if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
|
|
||||||
CustomData_get_named_layer_index(uv_data, CD_MLOOPUV, layer_name) != -1)
|
|
||||||
{
|
|
||||||
CustomData_add_layer_named(
|
|
||||||
tan_data, CD_TANGENT, CD_CALLOC, NULL,
|
|
||||||
numLoopData, layer_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DM_calc_loop_tangents(
|
void DM_calc_loop_tangents(
|
||||||
DerivedMesh *dm, bool calc_active_tangent,
|
DerivedMesh *dm, bool calc_active_tangent,
|
||||||
const char (*tangent_names)[MAX_NAME], int tangent_names_len)
|
const char (*tangent_names)[MAX_NAME], int tangent_names_len)
|
||||||
@@ -2655,77 +2276,6 @@ void DM_calc_loop_tangents(
|
|||||||
&dm->tangent_mask);
|
&dm->tangent_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DM_init_origspace(DerivedMesh *dm)
|
|
||||||
{
|
|
||||||
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
|
|
||||||
|
|
||||||
OrigSpaceLoop *lof_array = CustomData_get_layer(&dm->loopData, CD_ORIGSPACE_MLOOP);
|
|
||||||
const int numpoly = dm->getNumPolys(dm);
|
|
||||||
// const int numloop = dm->getNumLoops(dm);
|
|
||||||
MVert *mv = dm->getVertArray(dm);
|
|
||||||
MLoop *ml = dm->getLoopArray(dm);
|
|
||||||
MPoly *mp = dm->getPolyArray(dm);
|
|
||||||
int i, j, k;
|
|
||||||
|
|
||||||
float (*vcos_2d)[2] = NULL;
|
|
||||||
BLI_array_staticdeclare(vcos_2d, 64);
|
|
||||||
|
|
||||||
for (i = 0; i < numpoly; i++, mp++) {
|
|
||||||
OrigSpaceLoop *lof = lof_array + mp->loopstart;
|
|
||||||
|
|
||||||
if (mp->totloop == 3 || mp->totloop == 4) {
|
|
||||||
for (j = 0; j < mp->totloop; j++, lof++) {
|
|
||||||
copy_v2_v2(lof->uv, default_osf[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
MLoop *l = &ml[mp->loopstart];
|
|
||||||
float p_nor[3], co[3];
|
|
||||||
float mat[3][3];
|
|
||||||
|
|
||||||
float min[2] = {FLT_MAX, FLT_MAX}, max[2] = {-FLT_MAX, -FLT_MAX};
|
|
||||||
float translate[2], scale[2];
|
|
||||||
|
|
||||||
BKE_mesh_calc_poly_normal(mp, l, mv, p_nor);
|
|
||||||
axis_dominant_v3_to_m3(mat, p_nor);
|
|
||||||
|
|
||||||
BLI_array_clear(vcos_2d);
|
|
||||||
BLI_array_reserve(vcos_2d, mp->totloop);
|
|
||||||
for (j = 0; j < mp->totloop; j++, l++) {
|
|
||||||
mul_v3_m3v3(co, mat, mv[l->v].co);
|
|
||||||
copy_v2_v2(vcos_2d[j], co);
|
|
||||||
|
|
||||||
for (k = 0; k < 2; k++) {
|
|
||||||
if (co[k] > max[k])
|
|
||||||
max[k] = co[k];
|
|
||||||
else if (co[k] < min[k])
|
|
||||||
min[k] = co[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Brings min to (0, 0). */
|
|
||||||
negate_v2_v2(translate, min);
|
|
||||||
|
|
||||||
/* Scale will bring max to (1, 1). */
|
|
||||||
sub_v2_v2v2(scale, max, min);
|
|
||||||
if (scale[0] == 0.0f)
|
|
||||||
scale[0] = 1e-9f;
|
|
||||||
if (scale[1] == 0.0f)
|
|
||||||
scale[1] = 1e-9f;
|
|
||||||
invert_v2(scale);
|
|
||||||
|
|
||||||
/* Finally, transform all vcos_2d into ((0, 0), (1, 1)) square and assign them as origspace. */
|
|
||||||
for (j = 0; j < mp->totloop; j++, lof++) {
|
|
||||||
add_v2_v2v2(lof->uv, vcos_2d[j], translate);
|
|
||||||
mul_v2_v2(lof->uv, scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dm->dirty |= DM_DIRTY_TESS_CDLAYERS;
|
|
||||||
BLI_array_free(vcos_2d);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mesh_init_origspace(Mesh *mesh)
|
static void mesh_init_origspace(Mesh *mesh)
|
||||||
{
|
{
|
||||||
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
|
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
|
||||||
|
@@ -105,7 +105,7 @@ float (*BKE_crazyspace_get_mapped_editverts(
|
|||||||
/* disable subsurf temporal, get mapped cos, and enable it */
|
/* disable subsurf temporal, get mapped cos, and enable it */
|
||||||
if (modifiers_disable_subsurf_temporary(obedit)) {
|
if (modifiers_disable_subsurf_temporary(obedit)) {
|
||||||
/* need to make new derivemesh */
|
/* need to make new derivemesh */
|
||||||
makeDerivedMesh(depsgraph, scene, obedit, me->edit_mesh, &CD_MASK_BAREMESH, false);
|
makeDerivedMesh(depsgraph, scene, obedit, me->edit_mesh, &CD_MASK_BAREMESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now get the cage */
|
/* now get the cage */
|
||||||
|
@@ -859,41 +859,6 @@ void modwrap_deformVertsEM(
|
|||||||
/* end modifier callback wrappers */
|
/* end modifier callback wrappers */
|
||||||
|
|
||||||
|
|
||||||
/* wrappers for modifier callbacks that accept Mesh and select the proper implementation
|
|
||||||
* depending on if the modifier has been ported to Mesh or is still using DerivedMesh
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* deprecated variants of above that accept DerivedMesh */
|
|
||||||
|
|
||||||
struct DerivedMesh *modifier_applyModifier_DM_deprecated(
|
|
||||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
|
||||||
struct DerivedMesh *dm)
|
|
||||||
{
|
|
||||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
|
||||||
|
|
||||||
/* TODO(sybren): deduplicate all the copies of this code in this file. */
|
|
||||||
Mesh *mesh = NULL;
|
|
||||||
if (dm != NULL) {
|
|
||||||
mesh = BKE_id_new_nomain(ID_ME, NULL);
|
|
||||||
DM_to_mesh(dm, mesh, ctx->object, &CD_MASK_EVERYTHING, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh);
|
|
||||||
|
|
||||||
/* Make a DM that doesn't reference new_mesh so we can free the latter. */
|
|
||||||
DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, &CD_MASK_EVERYTHING);
|
|
||||||
|
|
||||||
if (new_mesh != mesh) {
|
|
||||||
BKE_id_free(NULL, new_mesh);
|
|
||||||
}
|
|
||||||
if (mesh != NULL) {
|
|
||||||
BKE_id_free(NULL, mesh);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ndm;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
|
* Get evaluated mesh for other evaluated object, which is used as an operand for the modifier,
|
||||||
* e.g. second operand for boolean modifier.
|
* e.g. second operand for boolean modifier.
|
||||||
|
@@ -178,10 +178,10 @@ void BKE_object_handle_data_update(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (em) {
|
if (em) {
|
||||||
makeDerivedMesh(depsgraph, scene, ob, em, &cddata_masks, false); /* was CD_MASK_BAREMESH */
|
makeDerivedMesh(depsgraph, scene, ob, em, &cddata_masks); /* was CD_MASK_BAREMESH */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
makeDerivedMesh(depsgraph, scene, ob, NULL, &cddata_masks, false);
|
makeDerivedMesh(depsgraph, scene, ob, NULL, &cddata_masks);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -577,6 +577,9 @@ static void set_subsurf_uv(CCGSubSurf *ss,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* face weighting */
|
/* face weighting */
|
||||||
|
#define SUB_ELEMS_FACE 50
|
||||||
|
typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE];
|
||||||
|
|
||||||
typedef struct FaceVertWeightEntry {
|
typedef struct FaceVertWeightEntry {
|
||||||
FaceVertWeight *weight;
|
FaceVertWeight *weight;
|
||||||
float *w;
|
float *w;
|
||||||
|
@@ -175,7 +175,7 @@ static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev, MDeformVert *dv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check if we can do partial updates and have them draw realtime
|
/* check if we can do partial updates and have them draw realtime
|
||||||
* (without rebuilding the 'derivedFinal') */
|
* (without evaluating modifiers) */
|
||||||
static bool vertex_paint_use_fast_update_check(Object *ob)
|
static bool vertex_paint_use_fast_update_check(Object *ob)
|
||||||
{
|
{
|
||||||
Mesh *me_eval = ob->runtime.mesh_eval;
|
Mesh *me_eval = ob->runtime.mesh_eval;
|
||||||
|
@@ -996,10 +996,10 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (use_render) {
|
else if (use_render) {
|
||||||
me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, NULL, &data_masks);
|
me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, &data_masks);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, NULL, &data_masks);
|
me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, &data_masks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1064,10 +1064,10 @@ static Mesh *bvh_get_mesh(
|
|||||||
}
|
}
|
||||||
else if (ob_eval != NULL) {
|
else if (ob_eval != NULL) {
|
||||||
if (use_cage) {
|
if (use_cage) {
|
||||||
return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks); /* ob->derivedDeform */
|
return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks); /* ob->derivedFinal */
|
return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1086,7 +1086,7 @@ static Mesh *bvh_get_mesh(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*r_free_mesh = true;
|
*r_free_mesh = true;
|
||||||
return mesh_create_eval_no_deform_render(depsgraph, scene, ob, NULL, &data_masks);
|
return mesh_create_eval_no_deform_render(depsgraph, scene, ob, &data_masks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1097,7 +1097,7 @@ static Mesh *bvh_get_mesh(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*r_free_mesh = true;
|
*r_free_mesh = true;
|
||||||
return mesh_create_eval_no_deform(depsgraph, scene, ob, NULL, &data_masks);
|
return mesh_create_eval_no_deform(depsgraph, scene, ob, &data_masks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user