Mesh: Remove unnecessary mesh position copying #105756
|
@ -62,13 +62,8 @@ bool multiresModifier_reshapeFromObject(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_vert_coords_alloc(src_mesh_eval, &num_deformed_verts);
|
||||
|
||||
const bool result = multiresModifier_reshapeFromVertcos(
|
||||
depsgraph, dst, mmd, deformed_verts, num_deformed_verts);
|
||||
|
||||
MEM_freeN(deformed_verts);
|
||||
depsgraph, dst, mmd, BKE_mesh_vert_positions(src_mesh_eval), src_mesh_eval->totvert);
|
||||
sixthat marked this conversation as resolved
Outdated
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -2209,10 +2209,8 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool
|
|||
|
||||
const bool is_deformed = check_sculpt_object_deformed(ob, true);
|
||||
if (is_deformed && me_eval_deform != nullptr) {
|
||||
int 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);
|
||||
BKE_pbvh_vert_coords_apply(
|
||||
pbvh, BKE_mesh_vert_positions(me_eval_deform), me_eval_deform->totvert);
|
||||
}
|
||||
|
||||
return pbvh;
|
||||
|
|
|
@ -3441,7 +3441,6 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
|
|||
EffectorWeights *clmd_effweights;
|
||||
int totpoint;
|
||||
int totedge;
|
||||
float(*deformedVerts)[3];
|
||||
bool realloc_roots;
|
||||
|
||||
if (!psys->clmd) {
|
||||
|
@ -3495,12 +3494,12 @@ 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_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_vert_coords_apply(psys->hair_out_mesh, deformedVerts);
|
||||
|
||||
MEM_freeN(deformedVerts);
|
||||
clothModifier_do(psys->clmd,
|
||||
sim->depsgraph,
|
||||
sim->scene,
|
||||
sim->ob,
|
||||
psys->hair_in_mesh,
|
||||
BKE_mesh_vert_positions_for_write(psys->hair_in_mesh));
|
||||
sixthat marked this conversation as resolved
Outdated
Hans Goudey
commented
The update tag from The update tag from `BKE_mesh_vert_coords_apply` is missing here too.
|
||||
|
||||
/* restore cloth effector weights */
|
||||
psys->clmd->sim_parms->effector_weights = clmd_effweights;
|
||||
|
|
|
@ -1530,7 +1530,6 @@ void BKE_shrinkwrap_mesh_nearest_surface_deform(bContext *C, Object *ob_source,
|
|||
Scene *sce = CTX_data_scene(C);
|
||||
ShrinkwrapModifierData ssmd = {{nullptr}};
|
||||
ModifierEvalContext ctx = {depsgraph, ob_source, ModifierApplyFlag(0)};
|
||||
int totvert;
|
||||
|
||||
ssmd.target = ob_target;
|
||||
ssmd.shrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE;
|
||||
|
@ -1538,13 +1537,16 @@ void BKE_shrinkwrap_mesh_nearest_surface_deform(bContext *C, Object *ob_source,
|
|||
ssmd.keepDist = 0.0f;
|
||||
|
||||
Mesh *src_me = static_cast<Mesh *>(ob_source->data);
|
||||
float(*vertexCos)[3] = BKE_mesh_vert_coords_alloc(src_me, &totvert);
|
||||
|
||||
shrinkwrapModifier_deform(&ssmd, &ctx, sce, ob_source, src_me, nullptr, -1, vertexCos, totvert);
|
||||
|
||||
BKE_mesh_vert_coords_apply(src_me, vertexCos);
|
||||
|
||||
MEM_freeN(vertexCos);
|
||||
shrinkwrapModifier_deform(&ssmd,
|
||||
&ctx,
|
||||
sce,
|
||||
ob_source,
|
||||
src_me,
|
||||
nullptr,
|
||||
-1,
|
||||
BKE_mesh_vert_positions_for_write(src_me),
|
||||
src_me->totvert);
|
||||
sixthat marked this conversation as resolved
Hans Goudey
commented
Same here Same here
|
||||
}
|
||||
|
||||
void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, Mesh *target_me, Object *ob_target)
|
||||
|
|
|
@ -516,12 +516,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
|
||||
/* Get our vertex coordinates. */
|
||||
if (index_num != verts_num) {
|
||||
float(*tv_cos)[3] = BKE_mesh_vert_coords_alloc(mesh, nullptr);
|
||||
const float(*tv_cos)[3] = BKE_mesh_vert_positions(mesh);
|
||||
v_cos = static_cast<float(*)[3]>(MEM_malloc_arrayN(index_num, sizeof(float[3]), __func__));
|
||||
for (i = 0; i < index_num; i++) {
|
||||
copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
|
||||
}
|
||||
MEM_freeN(tv_cos);
|
||||
}
|
||||
else {
|
||||
v_cos = BKE_mesh_vert_coords_alloc(mesh, nullptr);
|
||||
|
|
Loading…
Reference in New Issue
I'm not sure this one is right, since the deformed positions weren't applied back to the mesh afterwards before. If I'm right about that, feel free to leave this out, it can be tweaked more in the future.