Cleanup: vertex coordinate access, naming & minor changes
This also splits vertex access and allocation so it's possible to copy coordinates into an existing array without allocating it.
This commit is contained in:
parent
4a2d1953f3
commit
189aa32a3a
Notes:
blender-bot
2023-02-14 04:56:36 +01:00
Referenced by issue #69035, Bug in UVs display and crashes.
|
@ -393,7 +393,7 @@ struct Mesh *editbmesh_get_eval_cage_and_final(struct Depsgraph *depsgraph,
|
|||
const struct CustomData_MeshMasks *dataMask,
|
||||
struct Mesh **r_final);
|
||||
|
||||
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
|
||||
float (*editbmesh_vert_coords_alloc(struct BMEditMesh *em, int *r_vert_len))[3];
|
||||
bool editbmesh_modifier_is_enabled(struct Scene *scene,
|
||||
struct ModifierData *md,
|
||||
bool has_prev_mesh);
|
||||
|
|
|
@ -124,11 +124,15 @@ void BKE_curve_nurb_vert_active_set(struct Curve *cu, const struct Nurb *nu, con
|
|||
bool BKE_curve_nurb_vert_active_get(struct Curve *cu, struct Nurb **r_nu, void **r_vert);
|
||||
void BKE_curve_nurb_vert_active_validate(struct Curve *cu);
|
||||
|
||||
float (*BKE_curve_nurbs_vertexCos_get(struct ListBase *lb, int *r_numVerts))[3];
|
||||
void BK_curve_nurbs_vertexCos_apply(struct ListBase *lb, const float (*vertexCos)[3]);
|
||||
float (*BKE_curve_nurbs_vert_coords_alloc(struct ListBase *lb, int *r_vert_len))[3];
|
||||
void BKE_curve_nurbs_vert_coords_get(struct ListBase *lb, float (*vert_coords)[3], int vert_len);
|
||||
|
||||
float (*BKE_curve_nurbs_keyVertexCos_get(struct ListBase *lb, float *key))[3];
|
||||
void BKE_curve_nurbs_keyVertexTilts_apply(struct ListBase *lb, float *key);
|
||||
void BK_curve_nurbs_vert_coords_apply(struct ListBase *lb, const float (*vert_coords)[3]);
|
||||
|
||||
float (*BKE_curve_nurbs_key_vert_coords_alloc(struct ListBase *lb,
|
||||
float *key,
|
||||
int *r_vert_len))[3];
|
||||
void BKE_curve_nurbs_key_vert_tilts_apply(struct ListBase *lb, float *key);
|
||||
|
||||
void BKE_curve_editNurb_keyIndex_delCV(struct GHash *keyindex, const void *cv);
|
||||
void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex);
|
||||
|
|
|
@ -88,7 +88,7 @@ void BKE_editmesh_free(BMEditMesh *em);
|
|||
|
||||
void BKE_editmesh_color_free(BMEditMesh *em);
|
||||
void BKE_editmesh_color_ensure(BMEditMesh *em, const char htype);
|
||||
float (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3];
|
||||
float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3];
|
||||
void BKE_editmesh_lnorspace_update(BMEditMesh *em);
|
||||
void BKE_editmesh_ensure_autosmooth(BMEditMesh *em);
|
||||
|
||||
|
@ -98,7 +98,7 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em,
|
|||
struct EditMeshData *emd,
|
||||
const struct MeshStatVis *statvis);
|
||||
|
||||
float (*BKE_editmesh_vertexCos_get(
|
||||
struct Depsgraph *depsgraph, struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
|
||||
float (*BKE_editmesh_vert_coords_alloc(
|
||||
struct Depsgraph *depsgraph, struct BMEditMesh *em, struct Scene *scene, int *r_vert_len))[3];
|
||||
|
||||
#endif /* __BKE_EDITMESH_H__ */
|
||||
|
|
|
@ -58,7 +58,7 @@ void outside_lattice(struct Lattice *lt);
|
|||
|
||||
void curve_deform_verts(struct Object *cuOb,
|
||||
struct Object *target,
|
||||
float (*vertexCos)[3],
|
||||
float (*vert_coords)[3],
|
||||
int numVerts,
|
||||
struct MDeformVert *dvert,
|
||||
const int defgrp_index,
|
||||
|
@ -73,14 +73,14 @@ void curve_deform_vector(struct Object *cuOb,
|
|||
void lattice_deform_verts(struct Object *laOb,
|
||||
struct Object *target,
|
||||
struct Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
float (*vert_coords)[3],
|
||||
int numVerts,
|
||||
const char *vgroup,
|
||||
float influence);
|
||||
void armature_deform_verts(struct Object *armOb,
|
||||
struct Object *target,
|
||||
const struct Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
float (*vert_coords)[3],
|
||||
float (*defMats)[3][3],
|
||||
int numVerts,
|
||||
int deformflag,
|
||||
|
@ -88,8 +88,8 @@ void armature_deform_verts(struct Object *armOb,
|
|||
const char *defgrp_name,
|
||||
struct bGPDstroke *gps);
|
||||
|
||||
float (*BKE_lattice_vertexcos_get(const struct Lattice *lt, int *r_numVerts))[3];
|
||||
void BKE_lattice_vertexcos_apply(struct Lattice *lt, const float (*vertexCos)[3]);
|
||||
float (*BKE_lattice_vert_coords_alloc(const struct Lattice *lt, int *r_vert_len))[3];
|
||||
void BKE_lattice_vert_coords_apply(struct Lattice *lt, const float (*vert_coords)[3]);
|
||||
void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph,
|
||||
struct Scene *scene,
|
||||
struct Object *ob);
|
||||
|
|
|
@ -208,8 +208,6 @@ bool BKE_mesh_uv_cdlayer_rename(struct Mesh *me,
|
|||
const char *new_name,
|
||||
bool do_tessface);
|
||||
|
||||
float (*BKE_mesh_vertexCos_get(const struct Mesh *me, int *r_numVerts))[3];
|
||||
|
||||
void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
|
||||
|
||||
/* Create new mesh from the given object at its current state.
|
||||
|
@ -268,8 +266,11 @@ void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type);
|
|||
|
||||
void BKE_mesh_count_selected_items(const struct Mesh *mesh, int r_count[3]);
|
||||
|
||||
void BKE_mesh_apply_vert_coords(struct Mesh *mesh, const float (*vertCoords)[3]);
|
||||
void BKE_mesh_apply_vert_normals(struct Mesh *mesh, const short (*vertNormals)[3]);
|
||||
float (*BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3];
|
||||
void BKE_mesh_vert_coords_get(const struct Mesh *mesh, float (*vert_coords)[3]);
|
||||
|
||||
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float (*vert_coords)[3]);
|
||||
void BKE_mesh_vert_normals_apply(struct Mesh *mesh, const short (*vertNormals)[3]);
|
||||
|
||||
/* *** mesh_evaluate.c *** */
|
||||
|
||||
|
|
|
@ -278,9 +278,9 @@ float *BKE_pbvh_node_layer_disp_get(PBVH *pbvh, PBVHNode *node);
|
|||
void BKE_pbvh_node_layer_disp_free(PBVHNode *node);
|
||||
|
||||
/* vertex deformer */
|
||||
float (*BKE_pbvh_get_vertCos(struct PBVH *pbvh))[3];
|
||||
void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, const float (*vertCos)[3], const int totvert);
|
||||
bool BKE_pbvh_isDeformed(struct PBVH *pbvh);
|
||||
float (*BKE_pbvh_vert_coords_alloc(struct PBVH *pbvh))[3];
|
||||
void BKE_pbvh_vert_coords_apply(struct PBVH *pbvh, const float (*vertCos)[3], const int totvert);
|
||||
bool BKE_pbvh_is_deformed(struct PBVH *pbvh);
|
||||
|
||||
/* Vertex Iterator */
|
||||
|
||||
|
|
|
@ -889,7 +889,7 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
|
|||
orco = get_orco_coords(ob, em, layer, &free);
|
||||
|
||||
if (orco) {
|
||||
BKE_mesh_apply_vert_coords(mesh, orco);
|
||||
BKE_mesh_vert_coords_apply(mesh, orco);
|
||||
if (free) {
|
||||
MEM_freeN(orco);
|
||||
}
|
||||
|
@ -909,10 +909,10 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc
|
|||
free = 1;
|
||||
|
||||
if (mesh_orco->totvert == totvert) {
|
||||
orco = BKE_mesh_vertexCos_get(mesh_orco, NULL);
|
||||
orco = BKE_mesh_vert_coords_alloc(mesh_orco, NULL);
|
||||
}
|
||||
else {
|
||||
orco = BKE_mesh_vertexCos_get(mesh, NULL);
|
||||
orco = BKE_mesh_vert_coords_alloc(mesh, NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1208,14 +1208,14 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
|
||||
if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
|
||||
if (!deformed_verts) {
|
||||
deformed_verts = BKE_mesh_vertexCos_get(mesh_input, &num_deformed_verts);
|
||||
deformed_verts = BKE_mesh_vert_coords_alloc(mesh_input, &num_deformed_verts);
|
||||
}
|
||||
else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
if (mesh_final == NULL) {
|
||||
mesh_final = BKE_mesh_copy_for_eval(mesh_input, true);
|
||||
ASSERT_IS_VALID_MESH(mesh_final);
|
||||
}
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
|
||||
modwrap_deformVerts(md, &mectx, mesh_final, deformed_verts, num_deformed_verts);
|
||||
|
@ -1239,7 +1239,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
mesh_deform = BKE_mesh_copy_for_eval(mesh_input, true);
|
||||
|
||||
if (deformed_verts) {
|
||||
BKE_mesh_apply_vert_coords(mesh_deform, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_deform, deformed_verts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1322,10 +1322,10 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
/* Deforming a mesh, read the vertex locations
|
||||
* out of the mesh and deform them. Once done with this
|
||||
* run of deformers verts will be written back. */
|
||||
deformed_verts = BKE_mesh_vertexCos_get(mesh_final, &num_deformed_verts);
|
||||
deformed_verts = BKE_mesh_vert_coords_alloc(mesh_final, &num_deformed_verts);
|
||||
}
|
||||
else {
|
||||
deformed_verts = BKE_mesh_vertexCos_get(mesh_input, &num_deformed_verts);
|
||||
deformed_verts = BKE_mesh_vert_coords_alloc(mesh_input, &num_deformed_verts);
|
||||
}
|
||||
}
|
||||
/* if this is not the last modifier in the stack then recalculate the normals
|
||||
|
@ -1333,7 +1333,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
/* XXX, this covers bug #23673, but we may need normal calc for other types */
|
||||
if (mesh_final) {
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1352,7 +1352,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
/* apply vertex coordinates or build a Mesh as necessary */
|
||||
if (mesh_final) {
|
||||
if (deformed_verts) {
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1360,7 +1360,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
ASSERT_IS_VALID_MESH(mesh_final);
|
||||
|
||||
if (deformed_verts) {
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
|
||||
/* Initialize original indices the first time we evaluate a
|
||||
|
@ -1539,7 +1539,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
}
|
||||
}
|
||||
if (deformed_verts) {
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
MEM_freeN(deformed_verts);
|
||||
deformed_verts = NULL;
|
||||
}
|
||||
|
@ -1599,14 +1599,14 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *r_numVerts))[3]
|
||||
float (*editbmesh_vert_coords_alloc(BMEditMesh *em, int *r_vert_len))[3]
|
||||
{
|
||||
BMIter iter;
|
||||
BMVert *eve;
|
||||
float(*cos)[3];
|
||||
int i;
|
||||
|
||||
*r_numVerts = em->bm->totvert;
|
||||
*r_vert_len = em->bm->totvert;
|
||||
|
||||
cos = MEM_malloc_arrayN(em->bm->totvert, 3 * sizeof(float), "vertexcos");
|
||||
|
||||
|
@ -1778,10 +1778,10 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
/* Deforming a derived mesh, read the vertex locations
|
||||
* out of the mesh and deform them. Once done with this
|
||||
* run of deformers verts will be written back. */
|
||||
deformed_verts = BKE_mesh_vertexCos_get(mesh_final, &num_deformed_verts);
|
||||
deformed_verts = BKE_mesh_vert_coords_alloc(mesh_final, &num_deformed_verts);
|
||||
}
|
||||
else {
|
||||
deformed_verts = editbmesh_get_vertex_cos(em_input, &num_deformed_verts);
|
||||
deformed_verts = editbmesh_vert_coords_alloc(em_input, &num_deformed_verts);
|
||||
}
|
||||
}
|
||||
else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
|
@ -1791,7 +1791,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
mesh_copy_autosmooth(mesh_final, mesh_input);
|
||||
}
|
||||
BLI_assert(deformed_verts != NULL);
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
|
||||
if (mti->deformVertsEM) {
|
||||
|
@ -1811,7 +1811,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
BKE_id_free(NULL, mesh_final);
|
||||
}
|
||||
mesh_final = mesh_tmp;
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
else if (mesh_final == mesh_cage) {
|
||||
/* 'me' may be changed by this modifier, so we need to copy it. */
|
||||
|
@ -1825,7 +1825,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
mesh_copy_autosmooth(mesh_final, mesh_input);
|
||||
|
||||
if (deformed_verts) {
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1895,7 +1895,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
if (r_cage && i == cageIndex) {
|
||||
if (mesh_final && deformed_verts) {
|
||||
mesh_cage = BKE_mesh_copy_for_eval(mesh_final, false);
|
||||
BKE_mesh_apply_vert_coords(mesh_cage, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_cage, deformed_verts);
|
||||
}
|
||||
else if (mesh_final) {
|
||||
mesh_cage = mesh_final;
|
||||
|
@ -1927,7 +1927,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||
BKE_id_free(NULL, mesh_final);
|
||||
}
|
||||
mesh_final = mesh_tmp;
|
||||
BKE_mesh_apply_vert_coords(mesh_final, deformed_verts);
|
||||
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
|
||||
}
|
||||
}
|
||||
else if (!deformed_verts && mesh_cage) {
|
||||
|
|
|
@ -293,7 +293,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
|
|||
BLI_linklist_free((LinkNode *)datamasks, NULL);
|
||||
|
||||
me = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, &data_mask, NULL);
|
||||
deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
|
||||
deformedVerts = editbmesh_vert_coords_alloc(em, &numVerts);
|
||||
defmats = MEM_mallocN(sizeof(*defmats) * numVerts, "defmats");
|
||||
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
|
@ -383,7 +383,7 @@ int BKE_sculpt_get_first_deform_matrices(struct Depsgraph *depsgraph,
|
|||
* state. */
|
||||
Mesh *me = object_eval.data;
|
||||
me_eval = BKE_mesh_copy_for_eval(me, true);
|
||||
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
|
||||
deformedVerts = BKE_mesh_vert_coords_alloc(me, &numVerts);
|
||||
defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
|
||||
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
|
@ -485,7 +485,7 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph,
|
|||
int a, numVerts;
|
||||
Mesh *mesh = (Mesh *)object->data;
|
||||
|
||||
*deformcos = BKE_mesh_vertexCos_get(mesh, &numVerts);
|
||||
*deformcos = BKE_mesh_vert_coords_alloc(mesh, &numVerts);
|
||||
*deformmats = MEM_callocN(sizeof(*(*deformmats)) * numVerts, "defmats");
|
||||
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
|
|
|
@ -4606,18 +4606,13 @@ void BKE_nurb_direction_switch(Nurb *nu)
|
|||
}
|
||||
}
|
||||
|
||||
float (*BKE_curve_nurbs_vertexCos_get(ListBase *lb, int *r_numVerts))[3]
|
||||
void BKE_curve_nurbs_vert_coords_get(ListBase *lb, float (*vert_coords)[3], int vert_len)
|
||||
{
|
||||
int i, numVerts = *r_numVerts = BKE_nurbList_verts_count(lb);
|
||||
float *co, (*cos)[3] = MEM_malloc_arrayN(numVerts, sizeof(*cos), "cu_vcos");
|
||||
Nurb *nu;
|
||||
|
||||
co = cos[0];
|
||||
for (nu = lb->first; nu; nu = nu->next) {
|
||||
float *co = vert_coords[0];
|
||||
for (Nurb *nu = lb->first; nu; nu = nu->next) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt = nu->bezt;
|
||||
|
||||
for (i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
for (int i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
copy_v3_v3(co, bezt->vec[0]);
|
||||
co += 3;
|
||||
copy_v3_v3(co, bezt->vec[1]);
|
||||
|
@ -4628,28 +4623,33 @@ float (*BKE_curve_nurbs_vertexCos_get(ListBase *lb, int *r_numVerts))[3]
|
|||
}
|
||||
else {
|
||||
BPoint *bp = nu->bp;
|
||||
|
||||
for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
for (int i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
copy_v3_v3(co, bp->vec);
|
||||
co += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cos;
|
||||
BLI_assert(co == vert_coords[vert_len]);
|
||||
}
|
||||
|
||||
void BK_curve_nurbs_vertexCos_apply(ListBase *lb, const float (*vertexCos)[3])
|
||||
float (*BKE_curve_nurbs_vert_coords_alloc(ListBase *lb, int *r_vert_len))[3]
|
||||
{
|
||||
const float *co = vertexCos[0];
|
||||
Nurb *nu;
|
||||
int i;
|
||||
const int vert_len = BKE_nurbList_verts_count(lb);
|
||||
float(*vert_coords)[3] = MEM_malloc_arrayN(vert_len, sizeof(*vert_coords), __func__);
|
||||
BKE_curve_nurbs_vert_coords_get(lb, vert_coords, vert_len);
|
||||
*r_vert_len = vert_len;
|
||||
return vert_coords;
|
||||
}
|
||||
|
||||
for (nu = lb->first; nu; nu = nu->next) {
|
||||
void BK_curve_nurbs_vert_coords_apply(ListBase *lb, const float (*vert_coords)[3])
|
||||
{
|
||||
const float *co = vert_coords[0];
|
||||
|
||||
for (Nurb *nu = lb->first; nu; nu = nu->next) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt = nu->bezt;
|
||||
|
||||
for (i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
for (int i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
copy_v3_v3(bezt->vec[0], co);
|
||||
co += 3;
|
||||
copy_v3_v3(bezt->vec[1], co);
|
||||
|
@ -4661,7 +4661,7 @@ void BK_curve_nurbs_vertexCos_apply(ListBase *lb, const float (*vertexCos)[3])
|
|||
else {
|
||||
BPoint *bp = nu->bp;
|
||||
|
||||
for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
for (int i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
copy_v3_v3(bp->vec, co);
|
||||
co += 3;
|
||||
}
|
||||
|
@ -4671,18 +4671,17 @@ void BK_curve_nurbs_vertexCos_apply(ListBase *lb, const float (*vertexCos)[3])
|
|||
}
|
||||
}
|
||||
|
||||
float (*BKE_curve_nurbs_keyVertexCos_get(ListBase *lb, float *key))[3]
|
||||
float (*BKE_curve_nurbs_key_vert_coords_alloc(ListBase *lb, float *key, int *r_vert_len))[3]
|
||||
{
|
||||
int i, numVerts = BKE_nurbList_verts_count(lb);
|
||||
float *co, (*cos)[3] = MEM_malloc_arrayN(numVerts, sizeof(*cos), "cu_vcos");
|
||||
Nurb *nu;
|
||||
int vert_len = BKE_nurbList_verts_count(lb);
|
||||
float(*cos)[3] = MEM_malloc_arrayN(vert_len, sizeof(*cos), __func__);
|
||||
|
||||
co = cos[0];
|
||||
for (nu = lb->first; nu; nu = nu->next) {
|
||||
float *co = cos[0];
|
||||
for (Nurb *nu = lb->first; nu; nu = nu->next) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt = nu->bezt;
|
||||
|
||||
for (i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
for (int i = 0; i < nu->pntsu; i++, bezt++) {
|
||||
copy_v3_v3(co, &key[0]);
|
||||
co += 3;
|
||||
copy_v3_v3(co, &key[3]);
|
||||
|
@ -4695,18 +4694,18 @@ float (*BKE_curve_nurbs_keyVertexCos_get(ListBase *lb, float *key))[3]
|
|||
else {
|
||||
BPoint *bp = nu->bp;
|
||||
|
||||
for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
for (int i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) {
|
||||
copy_v3_v3(co, key);
|
||||
co += 3;
|
||||
key += KEYELEM_FLOAT_LEN_BPOINT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*r_vert_len = vert_len;
|
||||
return cos;
|
||||
}
|
||||
|
||||
void BKE_curve_nurbs_keyVertexTilts_apply(ListBase *lb, float *key)
|
||||
void BKE_curve_nurbs_key_vert_tilts_apply(ListBase *lb, float *key)
|
||||
{
|
||||
Nurb *nu;
|
||||
int i;
|
||||
|
|
|
@ -892,8 +892,7 @@ static void curve_calc_modifiers_pre(
|
|||
* tilts, which is passed through in the modifier stack.
|
||||
* this is also the reason curves do not use a virtual
|
||||
* shape key modifier yet. */
|
||||
deformedVerts = BKE_curve_nurbs_keyVertexCos_get(nurb, keyVerts);
|
||||
numVerts = BKE_nurbList_verts_count(nurb);
|
||||
deformedVerts = BKE_curve_nurbs_key_vert_coords_alloc(nurb, keyVerts, &numVerts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -909,7 +908,7 @@ static void curve_calc_modifiers_pre(
|
|||
}
|
||||
|
||||
if (!deformedVerts) {
|
||||
deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
|
||||
deformedVerts = BKE_curve_nurbs_vert_coords_alloc(nurb, &numVerts);
|
||||
}
|
||||
|
||||
mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
|
||||
|
@ -921,11 +920,11 @@ static void curve_calc_modifiers_pre(
|
|||
}
|
||||
|
||||
if (deformedVerts) {
|
||||
BK_curve_nurbs_vertexCos_apply(nurb, deformedVerts);
|
||||
BK_curve_nurbs_vert_coords_apply(nurb, deformedVerts);
|
||||
MEM_freeN(deformedVerts);
|
||||
}
|
||||
if (keyVerts) { /* these are not passed through modifier stack */
|
||||
BKE_curve_nurbs_keyVertexTilts_apply(nurb, keyVerts);
|
||||
BKE_curve_nurbs_key_vert_tilts_apply(nurb, keyVerts);
|
||||
}
|
||||
|
||||
if (keyVerts) {
|
||||
|
@ -933,18 +932,18 @@ static void curve_calc_modifiers_pre(
|
|||
}
|
||||
}
|
||||
|
||||
static float (*displist_get_allverts(ListBase *dispbase, int *totvert))[3]
|
||||
static float (*displist_vert_coords_alloc(ListBase *dispbase, int *r_vert_len))[3]
|
||||
{
|
||||
DispList *dl;
|
||||
float(*allverts)[3], *fp;
|
||||
|
||||
*totvert = 0;
|
||||
*r_vert_len = 0;
|
||||
|
||||
for (dl = dispbase->first; dl; dl = dl->next) {
|
||||
*totvert += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
|
||||
*r_vert_len += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr;
|
||||
}
|
||||
|
||||
allverts = MEM_mallocN((*totvert) * sizeof(float) * 3, "displist_get_allverts allverts");
|
||||
allverts = MEM_mallocN((*r_vert_len) * sizeof(float) * 3, "displist_vert_coords_alloc allverts");
|
||||
fp = (float *)allverts;
|
||||
for (dl = dispbase->first; dl; dl = dl->next) {
|
||||
int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr);
|
||||
|
@ -955,7 +954,7 @@ static float (*displist_get_allverts(ListBase *dispbase, int *totvert))[3]
|
|||
return allverts;
|
||||
}
|
||||
|
||||
static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
|
||||
static void displist_vert_coords_apply(ListBase *dispbase, float (*allverts)[3])
|
||||
{
|
||||
DispList *dl;
|
||||
const float *fp;
|
||||
|
@ -1027,7 +1026,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
* we need to create a Mesh for each curve that uses modifiers. */
|
||||
if (modified == NULL /* && need_normal */) {
|
||||
if (vertCos != NULL) {
|
||||
displist_apply_allverts(dispbase, vertCos);
|
||||
displist_vert_coords_apply(dispbase, vertCos);
|
||||
}
|
||||
|
||||
if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) {
|
||||
|
@ -1041,7 +1040,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
(mti->type == eModifierTypeType_DeformOrConstruct && !modified)) {
|
||||
if (modified) {
|
||||
if (!vertCos) {
|
||||
vertCos = BKE_mesh_vertexCos_get(modified, &totvert);
|
||||
vertCos = BKE_mesh_vert_coords_alloc(modified, &totvert);
|
||||
}
|
||||
if (need_normal) {
|
||||
BKE_mesh_ensure_normals(modified);
|
||||
|
@ -1050,7 +1049,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
}
|
||||
else {
|
||||
if (!vertCos) {
|
||||
vertCos = displist_get_allverts(dispbase, &totvert);
|
||||
vertCos = displist_vert_coords_alloc(dispbase, &totvert);
|
||||
}
|
||||
mti->deformVerts(md, &mectx_deform, NULL, vertCos, totvert);
|
||||
}
|
||||
|
@ -1071,12 +1070,12 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
BKE_id_free(NULL, modified);
|
||||
modified = temp_mesh;
|
||||
|
||||
BKE_mesh_apply_vert_coords(modified, vertCos);
|
||||
BKE_mesh_vert_coords_apply(modified, vertCos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (vertCos) {
|
||||
displist_apply_allverts(dispbase, vertCos);
|
||||
displist_vert_coords_apply(dispbase, vertCos);
|
||||
}
|
||||
|
||||
if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) {
|
||||
|
@ -1115,13 +1114,13 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
|
|||
BKE_id_free(NULL, modified);
|
||||
modified = temp_mesh;
|
||||
|
||||
BKE_mesh_apply_vert_coords(modified, vertCos);
|
||||
BKE_mesh_vert_coords_apply(modified, vertCos);
|
||||
BKE_mesh_calc_normals_mapping_simple(modified);
|
||||
|
||||
MEM_freeN(vertCos);
|
||||
}
|
||||
else {
|
||||
displist_apply_allverts(dispbase, vertCos);
|
||||
displist_vert_coords_apply(dispbase, vertCos);
|
||||
MEM_freeN(vertCos);
|
||||
vertCos = NULL;
|
||||
}
|
||||
|
|
|
@ -517,8 +517,8 @@ static void cage_mapped_verts_callback(void *userData,
|
|||
}
|
||||
}
|
||||
|
||||
float (*BKE_editmesh_vertexCos_get(
|
||||
struct Depsgraph *depsgraph, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
|
||||
float (*BKE_editmesh_vert_coords_alloc(
|
||||
struct Depsgraph *depsgraph, BMEditMesh *em, Scene *scene, int *r_vert_len))[3]
|
||||
{
|
||||
Mesh *cage;
|
||||
BLI_bitmap *visit_bitmap;
|
||||
|
@ -540,8 +540,8 @@ float (*BKE_editmesh_vertexCos_get(
|
|||
|
||||
MEM_freeN(visit_bitmap);
|
||||
|
||||
if (r_numVerts) {
|
||||
*r_numVerts = em->bm->totvert;
|
||||
if (r_vert_len) {
|
||||
*r_vert_len = em->bm->totvert;
|
||||
}
|
||||
|
||||
return cos_cage;
|
||||
|
|
|
@ -209,7 +209,7 @@ void BKE_editmesh_color_ensure(BMEditMesh *em, const char htype)
|
|||
}
|
||||
}
|
||||
|
||||
float (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3]
|
||||
float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3]
|
||||
{
|
||||
BMIter iter;
|
||||
BMVert *eve;
|
||||
|
@ -222,7 +222,7 @@ float (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3]
|
|||
copy_v3_v3(orco[i], eve->co);
|
||||
}
|
||||
|
||||
*r_numVerts = em->bm->totvert;
|
||||
*r_vert_len = em->bm->totvert;
|
||||
|
||||
return orco;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||
BPoint *bp;
|
||||
int i, u, v, w;
|
||||
float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
|
||||
float *co, (*vertexCos)[3] = NULL;
|
||||
float *co, (*vert_coords)[3] = NULL;
|
||||
|
||||
/* vertex weight groups are just freed all for now */
|
||||
if (lt->dvert) {
|
||||
|
@ -159,7 +159,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||
}
|
||||
}
|
||||
|
||||
vertexCos = MEM_mallocN(sizeof(*vertexCos) * uNew * vNew * wNew, "tmp_vcos");
|
||||
vert_coords = MEM_mallocN(sizeof(*vert_coords) * uNew * vNew * wNew, "tmp_vcos");
|
||||
|
||||
calc_lat_fudu(lt->flag, uNew, &fu, &du);
|
||||
calc_lat_fudu(lt->flag, vNew, &fv, &dv);
|
||||
|
@ -187,7 +187,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||
}
|
||||
}
|
||||
|
||||
co = vertexCos[0];
|
||||
co = vert_coords[0];
|
||||
for (w = 0, wc = fw; w < wNew; w++, wc += dw) {
|
||||
for (v = 0, vc = fv; v < vNew; v++, vc += dv) {
|
||||
for (u = 0, uc = fu; u < uNew; u++, co += 3, uc += du) {
|
||||
|
@ -212,7 +212,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||
|
||||
copy_m4_m4(mat, ltOb->obmat);
|
||||
unit_m4(ltOb->obmat);
|
||||
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew * vNew * wNew, NULL, 1.0f);
|
||||
lattice_deform_verts(ltOb, NULL, NULL, vert_coords, uNew * vNew * wNew, NULL, 1.0f);
|
||||
copy_m4_m4(ltOb->obmat, mat);
|
||||
|
||||
lt->typeu = typeu;
|
||||
|
@ -238,10 +238,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||
bp = lt->def;
|
||||
|
||||
for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) {
|
||||
copy_v3_v3(bp->vec, vertexCos[i]);
|
||||
copy_v3_v3(bp->vec, vert_coords[i]);
|
||||
}
|
||||
|
||||
MEM_freeN(vertexCos);
|
||||
MEM_freeN(vert_coords);
|
||||
}
|
||||
|
||||
void BKE_lattice_init(Lattice *lt)
|
||||
|
@ -747,7 +747,7 @@ static bool calc_curve_deform(
|
|||
|
||||
void curve_deform_verts(Object *cuOb,
|
||||
Object *target,
|
||||
float (*vertexCos)[3],
|
||||
float (*vert_coords)[3],
|
||||
int numVerts,
|
||||
MDeformVert *dvert,
|
||||
const int defgrp_index,
|
||||
|
@ -786,11 +786,11 @@ void curve_deform_verts(Object *cuOb,
|
|||
const float weight = defvert_find_weight(dvert_iter, defgrp_index);
|
||||
|
||||
if (weight > 0.0f) {
|
||||
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
||||
copy_v3_v3(vec, vertexCos[a]);
|
||||
mul_m4_v3(cd.curvespace, vert_coords[a]);
|
||||
copy_v3_v3(vec, vert_coords[a]);
|
||||
calc_curve_deform(cuOb, vec, defaxis, &cd, NULL);
|
||||
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
|
||||
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
||||
interp_v3_v3v3(vert_coords[a], vert_coords[a], vec, weight);
|
||||
mul_m4_v3(cd.objectspace, vert_coords[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -800,8 +800,8 @@ void curve_deform_verts(Object *cuOb,
|
|||
|
||||
for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) {
|
||||
if (defvert_find_weight(dvert_iter, defgrp_index) > 0.0f) {
|
||||
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
||||
minmax_v3v3_v3(cd.dmin, cd.dmax, vertexCos[a]);
|
||||
mul_m4_v3(cd.curvespace, vert_coords[a]);
|
||||
minmax_v3v3_v3(cd.dmin, cd.dmax, vert_coords[a]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -810,10 +810,10 @@ void curve_deform_verts(Object *cuOb,
|
|||
|
||||
if (weight > 0.0f) {
|
||||
/* already in 'cd.curvespace', prev for loop */
|
||||
copy_v3_v3(vec, vertexCos[a]);
|
||||
copy_v3_v3(vec, vert_coords[a]);
|
||||
calc_curve_deform(cuOb, vec, defaxis, &cd, NULL);
|
||||
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
|
||||
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
||||
interp_v3_v3v3(vert_coords[a], vert_coords[a], vec, weight);
|
||||
mul_m4_v3(cd.objectspace, vert_coords[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -821,9 +821,9 @@ void curve_deform_verts(Object *cuOb,
|
|||
else {
|
||||
if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
||||
calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL);
|
||||
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
||||
mul_m4_v3(cd.curvespace, vert_coords[a]);
|
||||
calc_curve_deform(cuOb, vert_coords[a], defaxis, &cd, NULL);
|
||||
mul_m4_v3(cd.objectspace, vert_coords[a]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -831,14 +831,14 @@ void curve_deform_verts(Object *cuOb,
|
|||
INIT_MINMAX(cd.dmin, cd.dmax);
|
||||
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
||||
minmax_v3v3_v3(cd.dmin, cd.dmax, vertexCos[a]);
|
||||
mul_m4_v3(cd.curvespace, vert_coords[a]);
|
||||
minmax_v3v3_v3(cd.dmin, cd.dmax, vert_coords[a]);
|
||||
}
|
||||
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
/* already in 'cd.curvespace', prev for loop */
|
||||
calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL);
|
||||
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
||||
calc_curve_deform(cuOb, vert_coords[a], defaxis, &cd, NULL);
|
||||
mul_m4_v3(cd.objectspace, vert_coords[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ void curve_deform_vector(
|
|||
|
||||
typedef struct LatticeDeformUserdata {
|
||||
LatticeDeformData *lattice_deform_data;
|
||||
float (*vertexCos)[3];
|
||||
float (*vert_coords)[3];
|
||||
MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
float fac;
|
||||
|
@ -896,18 +896,18 @@ static void lattice_deform_vert_task(void *__restrict userdata,
|
|||
if (data->dvert != NULL) {
|
||||
const float weight = defvert_find_weight(data->dvert + index, data->defgrp_index);
|
||||
if (weight > 0.0f) {
|
||||
calc_latt_deform(data->lattice_deform_data, data->vertexCos[index], weight * data->fac);
|
||||
calc_latt_deform(data->lattice_deform_data, data->vert_coords[index], weight * data->fac);
|
||||
}
|
||||
}
|
||||
else {
|
||||
calc_latt_deform(data->lattice_deform_data, data->vertexCos[index], data->fac);
|
||||
calc_latt_deform(data->lattice_deform_data, data->vert_coords[index], data->fac);
|
||||
}
|
||||
}
|
||||
|
||||
void lattice_deform_verts(Object *laOb,
|
||||
Object *target,
|
||||
Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
float (*vert_coords)[3],
|
||||
int numVerts,
|
||||
const char *vgroup,
|
||||
float fac)
|
||||
|
@ -942,11 +942,13 @@ void lattice_deform_verts(Object *laOb,
|
|||
}
|
||||
}
|
||||
|
||||
LatticeDeformUserdata data = {.lattice_deform_data = lattice_deform_data,
|
||||
.vertexCos = vertexCos,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.fac = fac};
|
||||
LatticeDeformUserdata data = {
|
||||
.lattice_deform_data = lattice_deform_data,
|
||||
.vert_coords = vert_coords,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.fac = fac,
|
||||
};
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
|
@ -1055,31 +1057,30 @@ void outside_lattice(Lattice *lt)
|
|||
}
|
||||
}
|
||||
|
||||
float (*BKE_lattice_vertexcos_get(const Lattice *lt, int *r_numVerts))[3]
|
||||
float (*BKE_lattice_vert_coords_alloc(const Lattice *lt, int *r_vert_len))[3]
|
||||
{
|
||||
int i, numVerts;
|
||||
float(*vertexCos)[3];
|
||||
int vert_len;
|
||||
float(*vert_coords)[3];
|
||||
|
||||
if (lt->editlatt) {
|
||||
lt = lt->editlatt->latt;
|
||||
}
|
||||
numVerts = *r_numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
vert_len = *r_vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
|
||||
vertexCos = MEM_mallocN(sizeof(*vertexCos) * numVerts, "lt_vcos");
|
||||
vert_coords = MEM_mallocN(sizeof(*vert_coords) * vert_len, __func__);
|
||||
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
copy_v3_v3(vertexCos[i], lt->def[i].vec);
|
||||
for (int i = 0; i < vert_len; i++) {
|
||||
copy_v3_v3(vert_coords[i], lt->def[i].vec);
|
||||
}
|
||||
|
||||
return vertexCos;
|
||||
return vert_coords;
|
||||
}
|
||||
|
||||
void BKE_lattice_vertexcos_apply(Lattice *lt, const float (*vertexCos)[3])
|
||||
void BKE_lattice_vert_coords_apply(Lattice *lt, const float (*vert_coords)[3])
|
||||
{
|
||||
int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
copy_v3_v3(lt->def[i].vec, vertexCos[i]);
|
||||
const int vert_len = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
for (int i = 0; i < vert_len; i++) {
|
||||
copy_v3_v3(lt->def[i].vec, vert_coords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1092,7 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
|
|||
Object *ob_orig = DEG_get_original_object(ob);
|
||||
VirtualModifierData virtualModifierData;
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
|
||||
float(*vertexCos)[3] = NULL;
|
||||
float(*vert_coords)[3] = NULL;
|
||||
int numVerts, editmode = (lt->editlatt != NULL);
|
||||
const ModifierEvalContext mectx = {depsgraph, ob, 0};
|
||||
|
||||
|
@ -1121,29 +1122,29 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!vertexCos) {
|
||||
vertexCos = BKE_lattice_vertexcos_get(ob_orig->data, &numVerts);
|
||||
if (!vert_coords) {
|
||||
vert_coords = BKE_lattice_vert_coords_alloc(ob_orig->data, &numVerts);
|
||||
}
|
||||
mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts);
|
||||
mti->deformVerts(md, &mectx, NULL, vert_coords, numVerts);
|
||||
}
|
||||
|
||||
if (ob->id.tag & LIB_TAG_COPIED_ON_WRITE) {
|
||||
if (vertexCos) {
|
||||
BKE_lattice_vertexcos_apply(ob->data, vertexCos);
|
||||
MEM_freeN(vertexCos);
|
||||
if (vert_coords) {
|
||||
BKE_lattice_vert_coords_apply(ob->data, vert_coords);
|
||||
MEM_freeN(vert_coords);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Displist won't do anything; this is just for posterity's sake until we remove it. */
|
||||
if (!vertexCos) {
|
||||
vertexCos = BKE_lattice_vertexcos_get(ob_orig->data, &numVerts);
|
||||
if (!vert_coords) {
|
||||
vert_coords = BKE_lattice_vert_coords_alloc(ob_orig->data, &numVerts);
|
||||
}
|
||||
|
||||
DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
|
||||
dl->type = DL_VERTS;
|
||||
dl->parts = 1;
|
||||
dl->nr = numVerts;
|
||||
dl->verts = (float *)vertexCos;
|
||||
dl->verts = (float *)vert_coords;
|
||||
|
||||
BLI_addtail(&ob->runtime.curve_cache->disp, dl);
|
||||
}
|
||||
|
|
|
@ -801,7 +801,7 @@ Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(BMEditMesh *em,
|
|||
me->runtime.is_original = true;
|
||||
if (vertexCos) {
|
||||
/* We will own this array in the future. */
|
||||
BKE_mesh_apply_vert_coords(me, vertexCos);
|
||||
BKE_mesh_vert_coords_apply(me, vertexCos);
|
||||
MEM_freeN(vertexCos);
|
||||
me->runtime.is_original = false;
|
||||
}
|
||||
|
@ -1301,25 +1301,6 @@ void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a newly MEM_malloc'd array of all the mesh vertex locations
|
||||
* \note \a r_verts_len may be NULL
|
||||
*/
|
||||
float (*BKE_mesh_vertexCos_get(const Mesh *me, int *r_verts_len))[3]
|
||||
{
|
||||
int i, verts_len = me->totvert;
|
||||
float(*cos)[3] = MEM_malloc_arrayN(verts_len, sizeof(*cos), "vertexcos1");
|
||||
|
||||
if (r_verts_len) {
|
||||
*r_verts_len = verts_len;
|
||||
}
|
||||
for (i = 0; i < verts_len; i++) {
|
||||
copy_v3_v3(cos[i], me->mvert[i].co);
|
||||
}
|
||||
|
||||
return cos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the index of the loop in 'poly' which references vertex,
|
||||
* returns -1 if not found
|
||||
|
@ -1665,24 +1646,42 @@ void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3])
|
|||
/* We could support faces in paint modes. */
|
||||
}
|
||||
|
||||
void BKE_mesh_apply_vert_coords(Mesh *mesh, const float (*vertCoords)[3])
|
||||
void BKE_mesh_vert_coords_get(const Mesh *mesh, float (*vert_coords)[3])
|
||||
{
|
||||
const MVert *mv = mesh->mvert;
|
||||
for (int i = 0; i < mesh->totvert; i++, mv++) {
|
||||
copy_v3_v3(vert_coords[i], mv->co);
|
||||
}
|
||||
}
|
||||
|
||||
float (*BKE_mesh_vert_coords_alloc(const Mesh *mesh, int *r_vert_len))[3]
|
||||
{
|
||||
float(*vert_coords)[3] = MEM_mallocN(sizeof(float[3]) * mesh->totvert, __func__);
|
||||
BKE_mesh_vert_coords_get(mesh, vert_coords);
|
||||
if (r_vert_len) {
|
||||
*r_vert_len = mesh->totvert;
|
||||
}
|
||||
return vert_coords;
|
||||
}
|
||||
|
||||
void BKE_mesh_vert_coords_apply(Mesh *mesh, const float (*vert_coords)[3])
|
||||
{
|
||||
/* This will just return the pointer if it wasn't a referenced layer. */
|
||||
MVert *mv = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert);
|
||||
mesh->mvert = mv;
|
||||
for (int i = 0; i < mesh->totvert; i++, mv++) {
|
||||
copy_v3_v3(mv->co, vertCoords[i]);
|
||||
copy_v3_v3(mv->co, vert_coords[i]);
|
||||
}
|
||||
mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
||||
}
|
||||
|
||||
void BKE_mesh_apply_vert_normals(Mesh *mesh, const short (*vertNormals)[3])
|
||||
void BKE_mesh_vert_normals_apply(Mesh *mesh, const short (*vert_normals)[3])
|
||||
{
|
||||
/* This will just return the pointer if it wasn't a referenced layer. */
|
||||
MVert *mv = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert);
|
||||
mesh->mvert = mv;
|
||||
for (int i = 0; i < mesh->totvert; i++, mv++) {
|
||||
copy_v3_v3_short(mv->no, vertNormals[i]);
|
||||
copy_v3_v3_short(mv->no, vert_normals[i]);
|
||||
}
|
||||
mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
|
||||
}
|
||||
|
|
|
@ -1341,11 +1341,11 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
|
|||
|
||||
if (mti->type == eModifierTypeType_OnlyDeform) {
|
||||
int numVerts;
|
||||
float(*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
|
||||
float(*deformedVerts)[3] = BKE_mesh_vert_coords_alloc(me, &numVerts);
|
||||
|
||||
BKE_id_copy_ex(NULL, &me->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
|
||||
mti->deformVerts(md_eval, &mectx, result, deformedVerts, numVerts);
|
||||
BKE_mesh_apply_vert_coords(result, deformedVerts);
|
||||
BKE_mesh_vert_coords_apply(result, deformedVerts);
|
||||
|
||||
if (build_shapekey_layers) {
|
||||
add_shapekey_layers(result, me);
|
||||
|
|
|
@ -291,7 +291,7 @@ void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
|
|||
float best_match = FLT_MAX, match;
|
||||
|
||||
const int numverts_src = me_src->totvert;
|
||||
float(*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL);
|
||||
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL);
|
||||
|
||||
mesh_calc_eigen_matrix(NULL, (const float(*)[3])vcos_src, numverts_src, mat_src);
|
||||
mesh_calc_eigen_matrix(verts_dst, NULL, numverts_dst, mat_dst);
|
||||
|
@ -548,7 +548,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
}
|
||||
else if (ELEM(mode, MREMAP_MODE_VERT_EDGE_NEAREST, MREMAP_MODE_VERT_EDGEINTERP_NEAREST)) {
|
||||
MEdge *edges_src = me_src->medge;
|
||||
float(*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL);
|
||||
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL);
|
||||
|
||||
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_EDGES, 2);
|
||||
nearest.index = -1;
|
||||
|
@ -602,7 +602,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
|
|||
MREMAP_MODE_VERT_POLYINTERP_VNORPROJ)) {
|
||||
MPoly *polys_src = me_src->mpoly;
|
||||
MLoop *loops_src = me_src->mloop;
|
||||
float(*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL);
|
||||
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL);
|
||||
|
||||
size_t tmp_buff_size = MREMAP_DEFAULT_BUFSIZE;
|
||||
float(*vcos)[3] = MEM_mallocN(sizeof(*vcos) * tmp_buff_size, __func__);
|
||||
|
@ -752,7 +752,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
const int num_verts_src = me_src->totvert;
|
||||
const int num_edges_src = me_src->totedge;
|
||||
MEdge *edges_src = me_src->medge;
|
||||
float(*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL);
|
||||
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL);
|
||||
|
||||
MeshElemMap *vert_to_edge_src_map;
|
||||
int *vert_to_edge_src_map_mem;
|
||||
|
@ -901,7 +901,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
|
|||
MEdge *edges_src = me_src->medge;
|
||||
MPoly *polys_src = me_src->mpoly;
|
||||
MLoop *loops_src = me_src->mloop;
|
||||
float(*vcos_src)[3] = BKE_mesh_vertexCos_get(me_src, NULL);
|
||||
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL);
|
||||
|
||||
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2);
|
||||
|
||||
|
@ -1350,7 +1350,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
size_t islands_res_buff_size = MREMAP_DEFAULT_BUFSIZE;
|
||||
|
||||
if (!use_from_vert) {
|
||||
vcos_src = BKE_mesh_vertexCos_get(me_src, NULL);
|
||||
vcos_src = BKE_mesh_vert_coords_alloc(me_src, NULL);
|
||||
|
||||
vcos_interp = MEM_mallocN(sizeof(*vcos_interp) * buff_size_interp, __func__);
|
||||
indices_interp = MEM_mallocN(sizeof(*indices_interp) * buff_size_interp, __func__);
|
||||
|
|
|
@ -891,7 +891,7 @@ bool multiresModifier_reshapeFromObject(struct Depsgraph *depsgraph,
|
|||
Object *src_eval = DEG_get_evaluated_object(depsgraph, src);
|
||||
Mesh *src_mesh_eval = mesh_get_eval_final(depsgraph, scene_eval, src_eval, &CD_MASK_BAREMESH);
|
||||
int num_deformed_verts;
|
||||
float(*deformed_verts)[3] = BKE_mesh_vertexCos_get(src_mesh_eval, &num_deformed_verts);
|
||||
float(*deformed_verts)[3] = BKE_mesh_vert_coords_alloc(src_mesh_eval, &num_deformed_verts);
|
||||
bool result = multires_reshape_from_vertcos(
|
||||
depsgraph, dst, &reshape_mmd, deformed_verts, num_deformed_verts, false);
|
||||
MEM_freeN(deformed_verts);
|
||||
|
@ -926,7 +926,7 @@ bool multiresModifier_reshapeFromDeformModifier(struct Depsgraph *depsgraph,
|
|||
* deformation modifiers will be applied though). */
|
||||
Mesh *multires_mesh = BKE_multires_create_mesh(depsgraph, scene_eval, &highest_mmd, object);
|
||||
int num_deformed_verts;
|
||||
float(*deformed_verts)[3] = BKE_mesh_vertexCos_get(multires_mesh, &num_deformed_verts);
|
||||
float(*deformed_verts)[3] = BKE_mesh_vert_coords_alloc(multires_mesh, &num_deformed_verts);
|
||||
/* Apply deformation modifier on the multires, */
|
||||
const ModifierEvalContext modifier_ctx = {
|
||||
.depsgraph = depsgraph,
|
||||
|
|
|
@ -1222,10 +1222,10 @@ static void sculpt_update_object(
|
|||
BKE_sculptsession_free_deformMats(ss);
|
||||
|
||||
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) :
|
||||
BKE_mesh_vertexCos_get(me, NULL);
|
||||
BKE_mesh_vert_coords_alloc(me, NULL);
|
||||
|
||||
BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos);
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos, me->totvert);
|
||||
BKE_pbvh_vert_coords_apply(ss->pbvh, ss->deform_cos, me->totvert);
|
||||
|
||||
for (a = 0; a < me->totvert; ++a) {
|
||||
invert_m3(ss->deform_imats[a]);
|
||||
|
@ -1242,14 +1242,14 @@ static void sculpt_update_object(
|
|||
|
||||
/* if pbvh is deformed, key block is already applied to it */
|
||||
if (ss->kb) {
|
||||
bool pbvh_deformed = BKE_pbvh_isDeformed(ss->pbvh);
|
||||
bool pbvh_deformed = BKE_pbvh_is_deformed(ss->pbvh);
|
||||
if (!pbvh_deformed || ss->deform_cos == NULL) {
|
||||
float(*vertCos)[3] = BKE_keyblock_convert_to_vertcos(ob, ss->kb);
|
||||
|
||||
if (vertCos) {
|
||||
if (!pbvh_deformed) {
|
||||
/* apply shape keys coordinates to PBVH */
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, me->totvert);
|
||||
BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, me->totvert);
|
||||
}
|
||||
if (ss->deform_cos == NULL) {
|
||||
ss->deform_cos = vertCos;
|
||||
|
@ -1477,8 +1477,8 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform)
|
|||
const bool is_deformed = check_sculpt_object_deformed(ob, true);
|
||||
if (is_deformed && me_eval_deform != NULL) {
|
||||
int totvert;
|
||||
float(*v_cos)[3] = BKE_mesh_vertexCos_get(me_eval_deform, &totvert);
|
||||
BKE_pbvh_apply_vertCos(pbvh, v_cos, totvert);
|
||||
float(*v_cos)[3] = BKE_mesh_vert_coords_alloc(me_eval_deform, &totvert);
|
||||
BKE_pbvh_vert_coords_apply(pbvh, v_cos, totvert);
|
||||
MEM_freeN(v_cos);
|
||||
}
|
||||
|
||||
|
|
|
@ -3490,10 +3490,10 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
|
|||
psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
|
||||
|
||||
BKE_id_copy_ex(NULL, &psys->hair_in_mesh->id, (ID **)&psys->hair_out_mesh, LIB_ID_COPY_LOCALIZE);
|
||||
deformedVerts = BKE_mesh_vertexCos_get(psys->hair_out_mesh, NULL);
|
||||
deformedVerts = BKE_mesh_vert_coords_alloc(psys->hair_out_mesh, NULL);
|
||||
clothModifier_do(
|
||||
psys->clmd, sim->depsgraph, sim->scene, sim->ob, psys->hair_in_mesh, deformedVerts);
|
||||
BKE_mesh_apply_vert_coords(psys->hair_out_mesh, deformedVerts);
|
||||
BKE_mesh_vert_coords_apply(psys->hair_out_mesh, deformedVerts);
|
||||
|
||||
MEM_freeN(deformedVerts);
|
||||
|
||||
|
|
|
@ -533,7 +533,7 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim)
|
|||
* Do a full rebuild with on Mesh data structure.
|
||||
*
|
||||
* \note Unlike mpoly/mloop/verts, looptri is **totally owned** by PBVH
|
||||
* (which means it may rewrite it if needed, see #BKE_pbvh_apply_vertCos().
|
||||
* (which means it may rewrite it if needed, see #BKE_pbvh_vert_coords_apply().
|
||||
*/
|
||||
void BKE_pbvh_build_mesh(PBVH *bvh,
|
||||
const MPoly *mpoly,
|
||||
|
@ -2306,7 +2306,7 @@ void BKE_pbvh_node_layer_disp_free(PBVHNode *node)
|
|||
}
|
||||
}
|
||||
|
||||
float (*BKE_pbvh_get_vertCos(PBVH *pbvh))[3]
|
||||
float (*BKE_pbvh_vert_coords_alloc(PBVH *pbvh))[3]
|
||||
{
|
||||
float(*vertCos)[3] = NULL;
|
||||
|
||||
|
@ -2324,7 +2324,7 @@ float (*BKE_pbvh_get_vertCos(PBVH *pbvh))[3]
|
|||
return vertCos;
|
||||
}
|
||||
|
||||
void BKE_pbvh_apply_vertCos(PBVH *pbvh, const float (*vertCos)[3], const int totvert)
|
||||
void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], const int totvert)
|
||||
{
|
||||
if (totvert != pbvh->totvert) {
|
||||
BLI_assert(!"PBVH: Given deforming vcos number does not natch PBVH vertex number!");
|
||||
|
@ -2368,7 +2368,7 @@ void BKE_pbvh_apply_vertCos(PBVH *pbvh, const float (*vertCos)[3], const int tot
|
|||
}
|
||||
}
|
||||
|
||||
bool BKE_pbvh_isDeformed(PBVH *pbvh)
|
||||
bool BKE_pbvh_is_deformed(PBVH *pbvh)
|
||||
{
|
||||
return pbvh->deformed;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ static int dl_tri_len(const DispList *dl)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* see: displist_get_allverts */
|
||||
/* see: displist_vert_coords_alloc */
|
||||
static int curve_render_surface_vert_len_get(const ListBase *lb)
|
||||
{
|
||||
int vert_len = 0;
|
||||
|
|
|
@ -2658,7 +2658,7 @@ static void knifetool_init_bmbvh(KnifeTool_OpData *kcd)
|
|||
Object *obedit_eval = (Object *)DEG_get_evaluated_id(kcd->vc.depsgraph, &kcd->em->ob->id);
|
||||
BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
|
||||
|
||||
kcd->cagecos = (const float(*)[3])BKE_editmesh_vertexCos_get(
|
||||
kcd->cagecos = (const float(*)[3])BKE_editmesh_vert_coords_alloc(
|
||||
kcd->vc.depsgraph, em_eval, scene_eval, NULL);
|
||||
|
||||
kcd->bmbvh = BKE_bmbvh_new_from_editmesh(
|
||||
|
|
|
@ -714,9 +714,9 @@ static int modifier_apply_obdata(
|
|||
RPT_INFO,
|
||||
"Applied modifier only changed CV points, not tessellated/bevel vertices");
|
||||
|
||||
vertexCos = BKE_curve_nurbs_vertexCos_get(&curve_eval->nurb, &numVerts);
|
||||
vertexCos = BKE_curve_nurbs_vert_coords_alloc(&curve_eval->nurb, &numVerts);
|
||||
mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
|
||||
BK_curve_nurbs_vertexCos_apply(&curve->nurb, vertexCos);
|
||||
BK_curve_nurbs_vert_coords_apply(&curve->nurb, vertexCos);
|
||||
|
||||
MEM_freeN(vertexCos);
|
||||
|
||||
|
|
|
@ -4349,7 +4349,7 @@ static void sculpt_update_keyblock(Object *ob)
|
|||
vertCos = ss->orig_cos;
|
||||
}
|
||||
else {
|
||||
vertCos = BKE_pbvh_get_vertCos(ss->pbvh);
|
||||
vertCos = BKE_pbvh_vert_coords_alloc(ss->pbvh);
|
||||
}
|
||||
|
||||
if (vertCos) {
|
||||
|
|
|
@ -189,7 +189,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
|
||||
/* pbvh uses it's own mvert array, so coords should be */
|
||||
/* propagated to pbvh here */
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, ss->kb->totelem);
|
||||
BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, ss->kb->totelem);
|
||||
|
||||
MEM_freeN(vertCos);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ static void deformVerts(ModifierData *md,
|
|||
}
|
||||
}
|
||||
|
||||
BKE_mesh_apply_vert_coords(mesh_src, vertexCos);
|
||||
BKE_mesh_vert_coords_apply(mesh_src, vertexCos);
|
||||
|
||||
clothModifier_do(clmd, ctx->depsgraph, scene, ctx->object, mesh_src, vertexCos);
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ static void deformVerts(ModifierData *md,
|
|||
float current_time = 0;
|
||||
unsigned int mvert_num = 0;
|
||||
|
||||
BKE_mesh_apply_vert_coords(mesh_src, vertexCos);
|
||||
BKE_mesh_vert_coords_apply(mesh_src, vertexCos);
|
||||
BKE_mesh_calc_normals(mesh_src);
|
||||
|
||||
current_time = DEG_get_ctime(ctx->depsgraph);
|
||||
|
|
|
@ -635,12 +635,12 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
if (csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) {
|
||||
/* caller needs to do sanity check here */
|
||||
csmd->bind_coords_num = numVerts;
|
||||
rest_coords = (const float(*)[3])csmd->bind_coords;
|
||||
rest_coords = csmd->bind_coords;
|
||||
}
|
||||
else {
|
||||
int me_numVerts;
|
||||
rest_coords = (const float(*)[3])((em) ? BKE_editmesh_vertexCos_get_orco(em, &me_numVerts) :
|
||||
BKE_mesh_vertexCos_get(ob->data, &me_numVerts));
|
||||
rest_coords = em ? BKE_editmesh_vert_coords_alloc_orco(em, &me_numVerts) :
|
||||
BKE_mesh_vert_coords_alloc(ob->data, &me_numVerts);
|
||||
|
||||
BLI_assert((unsigned int)me_numVerts == numVerts);
|
||||
is_rest_coords_alloc = true;
|
||||
|
|
|
@ -290,7 +290,7 @@ static Mesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example)
|
|||
gzclose(gzf);
|
||||
|
||||
BKE_mesh_calc_edges(mesh, false, false);
|
||||
BKE_mesh_apply_vert_normals(mesh, (short(*)[3])normals);
|
||||
BKE_mesh_vert_normals_apply(mesh, (short(*)[3])normals);
|
||||
MEM_freeN(normals);
|
||||
|
||||
// CDDM_calc_normals(result);
|
||||
|
|
|
@ -401,7 +401,7 @@ static void meshdeformModifier_do(ModifierData *md,
|
|||
}
|
||||
|
||||
/* setup deformation data */
|
||||
cagecos = BKE_mesh_vertexCos_get(cagemesh, NULL);
|
||||
cagecos = BKE_mesh_vert_coords_alloc(cagemesh, NULL);
|
||||
bindcagecos = (float(*)[3])mmd->bindcagecos;
|
||||
|
||||
/* We allocate 1 element extra to make it possible to
|
||||
|
|
|
@ -152,7 +152,7 @@ static void deformVerts(ModifierData *md,
|
|||
|
||||
/* make new mesh */
|
||||
psmd->mesh_final = BKE_mesh_copy_for_eval(mesh_src, false);
|
||||
BKE_mesh_apply_vert_coords(psmd->mesh_final, vertexCos);
|
||||
BKE_mesh_vert_coords_apply(psmd->mesh_final, vertexCos);
|
||||
BKE_mesh_calc_normals(psmd->mesh_final);
|
||||
|
||||
BKE_mesh_tessface_ensure(psmd->mesh_final);
|
||||
|
|
|
@ -130,7 +130,7 @@ static void deformVerts(ModifierData *md,
|
|||
float *vec;
|
||||
MVert *x, *v;
|
||||
|
||||
BKE_mesh_apply_vert_coords(surmd->mesh, vertexCos);
|
||||
BKE_mesh_vert_coords_apply(surmd->mesh, vertexCos);
|
||||
BKE_mesh_calc_normals(surmd->mesh);
|
||||
|
||||
numverts = surmd->mesh->totvert;
|
||||
|
|
|
@ -198,7 +198,7 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
|
|||
/* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether
|
||||
* we really need vertexCos here. */
|
||||
if (vertexCos) {
|
||||
BKE_mesh_apply_vert_coords(mesh, vertexCos);
|
||||
BKE_mesh_vert_coords_apply(mesh, vertexCos);
|
||||
mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
mloop_uv = CustomData_duplicate_referenced_layer_named(
|
||||
&mesh->ldata, CD_MLOOPUV, uvname, numLoops);
|
||||
|
||||
coords = BKE_mesh_vertexCos_get(mesh, &numVerts);
|
||||
coords = BKE_mesh_vert_coords_alloc(mesh, &numVerts);
|
||||
|
||||
/* convert coords to world space */
|
||||
for (i = 0, co = coords; i < numVerts; ++i, ++co) {
|
||||
|
|
|
@ -492,7 +492,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
|
||||
/* Get our vertex coordinates. */
|
||||
if (numIdx != numVerts) {
|
||||
float(*tv_cos)[3] = BKE_mesh_vertexCos_get(mesh, NULL);
|
||||
float(*tv_cos)[3] = BKE_mesh_vert_coords_alloc(mesh, NULL);
|
||||
v_cos = MEM_malloc_arrayN(numIdx, sizeof(float[3]), "WeightVGProximity Modifier, v_cos");
|
||||
for (i = 0; i < numIdx; i++) {
|
||||
copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
|
||||
|
@ -500,7 +500,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
MEM_freeN(tv_cos);
|
||||
}
|
||||
else {
|
||||
v_cos = BKE_mesh_vertexCos_get(mesh, NULL);
|
||||
v_cos = BKE_mesh_vert_coords_alloc(mesh, NULL);
|
||||
}
|
||||
|
||||
/* Compute wanted distances. */
|
||||
|
|
Loading…
Reference in New Issue