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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-09-21 02:38:12 +0300
committerHans Goudey <h.goudey@me.com>2022-09-21 02:38:20 +0300
commit6f15141f2731382792514571ffa5d89c9dcf7492 (patch)
tree66e58eba4a1c2ec60dd3b436d5c7ab8e50453a96
parentcbbed90486c6fb6f15c4fa5529ca5cdaf32e9e14 (diff)
Fix T101188: Fluid modifier doesn't work
05952aa94d33eeb504fa modified this area incorrectly, transforming vertices outside of the mesh. That would have been fine, but the mesh is used to retrieve the bounding box. Instead just avoid duplicating the positions and normals completely, and avoid using referenced layers just to be extra safe.
-rw-r--r--source/blender/blenkernel/intern/fluid.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index ff75aedce25..349614b93dd 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -998,7 +998,6 @@ static void obstacles_from_mesh(Object *coll_ob,
float dt)
{
if (fes->mesh) {
- Mesh *me = NULL;
const MLoopTri *looptri;
BVHTreeFromMesh tree_data = {NULL};
int numverts, i;
@@ -1006,13 +1005,11 @@ static void obstacles_from_mesh(Object *coll_ob,
float *vert_vel = NULL;
bool has_velocity = false;
- me = BKE_mesh_copy_for_eval(fes->mesh, true);
+ Mesh *me = BKE_mesh_copy_for_eval(fes->mesh, false);
+ MVert *verts = BKE_mesh_verts_for_write(me);
int min[3], max[3], res[3];
- /* Duplicate vertices to modify. */
- MVert *verts = MEM_dupallocN(BKE_mesh_verts(me));
-
const MLoop *mloop = BKE_mesh_loops(me);
looptri = BKE_mesh_runtime_looptri_ensure(me);
numverts = me->totvert;
@@ -1097,7 +1094,6 @@ static void obstacles_from_mesh(Object *coll_ob,
if (vert_vel) {
MEM_freeN(vert_vel);
}
- MEM_SAFE_FREE(verts);
BKE_id_free(NULL, me);
}
}
@@ -2074,10 +2070,8 @@ static void emit_from_mesh(
/* Copy mesh for thread safety as we modify it.
* Main issue is its VertArray being modified, then replaced and freed. */
- Mesh *me = BKE_mesh_copy_for_eval(ffs->mesh, true);
-
- /* Duplicate vertices to modify. */
- MVert *verts = MEM_dupallocN(BKE_mesh_verts(me));
+ Mesh *me = BKE_mesh_copy_for_eval(ffs->mesh, false);
+ MVert *verts = BKE_mesh_verts_for_write(me);
const MLoop *mloop = BKE_mesh_loops(me);
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me);
@@ -2102,7 +2096,8 @@ static void emit_from_mesh(
/* Transform mesh vertices to domain grid space for fast lookups.
* This is valid because the mesh is copied above. */
- float(*vert_normals)[3] = MEM_dupallocN(BKE_mesh_vertex_normals_ensure(me));
+ BKE_mesh_vertex_normals_ensure(me);
+ float(*vert_normals)[3] = BKE_mesh_vertex_normals_for_write(me);
for (i = 0; i < numverts; i++) {
/* Vertex position. */
mul_m4_v3(flow_ob->obmat, verts[i].co);
@@ -2178,8 +2173,6 @@ static void emit_from_mesh(
if (vert_vel) {
MEM_freeN(vert_vel);
}
- MEM_SAFE_FREE(verts);
- MEM_SAFE_FREE(vert_normals);
BKE_id_free(NULL, me);
}
}