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);
|
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);
|
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(
|
const bool result = multiresModifier_reshapeFromVertcos(
|
||||||
depsgraph, dst, mmd, deformed_verts, num_deformed_verts);
|
depsgraph, dst, mmd, BKE_mesh_vert_positions(src_mesh_eval), src_mesh_eval->totvert);
|
||||||
sixthat marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
MEM_freeN(deformed_verts);
|
|
||||||
|
|
||||||
return result;
|
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);
|
const bool is_deformed = check_sculpt_object_deformed(ob, true);
|
||||||
if (is_deformed && me_eval_deform != nullptr) {
|
if (is_deformed && me_eval_deform != nullptr) {
|
||||||
int totvert;
|
BKE_pbvh_vert_coords_apply(
|
||||||
float(*v_cos)[3] = BKE_mesh_vert_coords_alloc(me_eval_deform, &totvert);
|
pbvh, BKE_mesh_vert_positions(me_eval_deform), me_eval_deform->totvert);
|
||||||
BKE_pbvh_vert_coords_apply(pbvh, v_cos, totvert);
|
|
||||||
MEM_freeN(v_cos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pbvh;
|
return pbvh;
|
||||||
|
|
|
@ -3441,7 +3441,6 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
|
||||||
EffectorWeights *clmd_effweights;
|
EffectorWeights *clmd_effweights;
|
||||||
int totpoint;
|
int totpoint;
|
||||||
int totedge;
|
int totedge;
|
||||||
float(*deformedVerts)[3];
|
|
||||||
bool realloc_roots;
|
bool realloc_roots;
|
||||||
|
|
||||||
if (!psys->clmd) {
|
if (!psys->clmd) {
|
||||||
|
@ -3495,12 +3494,12 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
|
||||||
psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
|
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);
|
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,
|
||||||
clothModifier_do(
|
sim->depsgraph,
|
||||||
psys->clmd, sim->depsgraph, sim->scene, sim->ob, psys->hair_in_mesh, deformedVerts);
|
sim->scene,
|
||||||
BKE_mesh_vert_coords_apply(psys->hair_out_mesh, deformedVerts);
|
sim->ob,
|
||||||
|
psys->hair_in_mesh,
|
||||||
MEM_freeN(deformedVerts);
|
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 */
|
/* restore cloth effector weights */
|
||||||
psys->clmd->sim_parms->effector_weights = clmd_effweights;
|
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);
|
Scene *sce = CTX_data_scene(C);
|
||||||
ShrinkwrapModifierData ssmd = {{nullptr}};
|
ShrinkwrapModifierData ssmd = {{nullptr}};
|
||||||
ModifierEvalContext ctx = {depsgraph, ob_source, ModifierApplyFlag(0)};
|
ModifierEvalContext ctx = {depsgraph, ob_source, ModifierApplyFlag(0)};
|
||||||
int totvert;
|
|
||||||
|
|
||||||
ssmd.target = ob_target;
|
ssmd.target = ob_target;
|
||||||
ssmd.shrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE;
|
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;
|
ssmd.keepDist = 0.0f;
|
||||||
|
|
||||||
Mesh *src_me = static_cast<Mesh *>(ob_source->data);
|
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);
|
shrinkwrapModifier_deform(&ssmd,
|
||||||
|
&ctx,
|
||||||
BKE_mesh_vert_coords_apply(src_me, vertexCos);
|
sce,
|
||||||
|
ob_source,
|
||||||
MEM_freeN(vertexCos);
|
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)
|
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. */
|
/* Get our vertex coordinates. */
|
||||||
if (index_num != verts_num) {
|
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__));
|
v_cos = static_cast<float(*)[3]>(MEM_malloc_arrayN(index_num, sizeof(float[3]), __func__));
|
||||||
for (i = 0; i < index_num; i++) {
|
for (i = 0; i < index_num; i++) {
|
||||||
copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
|
copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
|
||||||
}
|
}
|
||||||
MEM_freeN(tv_cos);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
v_cos = BKE_mesh_vert_coords_alloc(mesh, nullptr);
|
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.