[Bf-blender-cvs] [f4e261bfed5] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Hans Goudey
noreply at git.blender.org
Fri Nov 4 11:58:52 CET 2022
Commit: f4e261bfed553c98f6e987dc84591ecc680e1ebb
Author: Hans Goudey
Date: Thu Nov 3 17:40:33 2022 +0100
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBf4e261bfed553c98f6e987dc84591ecc680e1ebb
Merge branch 'master' into refactor-mesh-position-generic
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_ui/properties_data_mesh.py
index 6a0eca747ad,a6b97fbdc85..79947ae16c4
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@@ -592,11 -592,14 +592,14 @@@ class DATA_PT_mesh_attributes(MeshButto
colliding_names = []
for collection in (
# Built-in names.
- {"position": None, "shade_smooth": None, "normal": None, "crease": None},
+ {"shade_smooth": None, "normal": None, "crease": None},
mesh.attributes,
mesh.uv_layers,
- ob.vertex_groups,
+ None if ob is None else ob.vertex_groups,
):
+ if collection is None:
+ colliding_names.append("Cannot check for object vertex groups when pinning mesh")
+ continue
for name in collection.keys():
unique_names_len = len(unique_names)
unique_names.add(name)
diff --cc source/blender/blenkernel/intern/cloth.c
index 718da435f32,88ba50fe901..57f9db5b104
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@@ -267,8 -268,8 +267,8 @@@ static int do_step_cloth
copy_v3_v3(verts->txold, verts->x);
/* Get the current position. */
- copy_v3_v3(verts->xconst, mvert[i].co);
+ copy_v3_v3(verts->xconst, positions[i]);
- mul_m4_v3(ob->obmat, verts->xconst);
+ mul_m4_v3(ob->object_to_world, verts->xconst);
if (vert_mass_changed) {
verts->mass = clmd->sim_parms->mass;
@@@ -760,9 -761,9 +760,9 @@@ static bool cloth_from_object
/* set initial values */
for (i = 0; i < mesh->totvert; i++, verts++) {
if (first) {
- copy_v3_v3(verts->x, mvert[i].co);
+ copy_v3_v3(verts->x, positions[i]);
- mul_m4_v3(ob->obmat, verts->x);
+ mul_m4_v3(ob->object_to_world, verts->x);
if (shapekey_rest) {
copy_v3_v3(verts->xrest, shapekey_rest[i]);
@@@ -1153,8 -1154,8 +1153,8 @@@ static void cloth_update_verts(Object *
/* vertex count is already ensured to match */
for (i = 0; i < mesh->totvert; i++, verts++) {
- copy_v3_v3(verts->xrest, mvert[i].co);
+ copy_v3_v3(verts->xrest, positions[i]);
- mul_m4_v3(ob->obmat, verts->xrest);
+ mul_m4_v3(ob->object_to_world, verts->xrest);
}
}
diff --cc source/blender/blenkernel/intern/dynamicpaint.c
index c0266971563,b9cec17b6e0..adba978ce88
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@@ -3777,8 -3782,8 +3777,8 @@@ static void dynamicPaint_brushMeshCalcu
mesh_p = BKE_mesh_copy_for_eval(dynamicPaint_brush_mesh_get(brush), false);
numOfVerts_p = mesh_p->totvert;
- mvert_p = BKE_mesh_verts_for_write(mesh_p);
+ float(*positions_p)[3] = BKE_mesh_positions_for_write(mesh_p);
- copy_m4_m4(prev_obmat, ob->obmat);
+ copy_m4_m4(prev_obmat, ob->object_to_world);
/* current frame mesh */
scene->r.cfra = cur_fra;
@@@ -3809,9 -3814,9 +3809,9 @@@
/* calculate speed */
DynamicPaintBrushVelocityData data = {
.brush_vel = *brushVel,
- .mvert_p = mvert_p,
- .mvert_c = mvert_c,
+ .positions_p = positions_p,
+ .positions_c = positions_c,
- .obmat = ob->obmat,
+ .obmat = ob->object_to_world,
.prev_obmat = prev_obmat,
.timescale = timescale,
};
@@@ -4273,8 -4279,8 +4273,8 @@@ static bool dynamicPaint_paintMesh(Deps
* (Faster than transforming per surface point
* coordinates and normals to object space) */
for (ii = 0; ii < numOfVerts; ii++) {
- mul_m4_v3(brushOb->obmat, positions[ii]);
- mul_m4_v3(brushOb->object_to_world, mvert[ii].co);
- boundInsert(&mesh_bb, mvert[ii].co);
++ mul_m4_v3(brushOb->object_to_world, positions[ii]);
+ boundInsert(&mesh_bb, positions[ii]);
/* for proximity project calculate average normal */
if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) {
@@@ -6106,8 -6112,8 +6106,8 @@@ static bool dynamicPaint_generateBakeDa
*/
bData->mesh_bounds.valid = false;
for (index = 0; index < canvasNumOfVerts; index++) {
- copy_v3_v3(canvas_verts[index].v, mvert[index].co);
+ copy_v3_v3(canvas_verts[index].v, positions[index]);
- mul_m4_v3(ob->obmat, canvas_verts[index].v);
+ mul_m4_v3(ob->object_to_world, canvas_verts[index].v);
boundInsert(&bData->mesh_bounds, canvas_verts[index].v);
}
@@@ -6137,8 -6143,8 +6137,8 @@@
dynamicPaint_prepareAdjacencyData(surface, false);
/* Copy current frame vertices to check against in next frame */
- copy_m4_m4(bData->prev_obmat, ob->obmat);
+ copy_m4_m4(bData->prev_obmat, ob->object_to_world);
- memcpy(bData->prev_verts, mvert, canvasNumOfVerts * sizeof(MVert));
+ memcpy(bData->prev_positions, positions, canvasNumOfVerts * sizeof(float[3]));
bData->clear = 0;
diff --cc source/blender/blenkernel/intern/effect.c
index 001436e3df0,c2ae4efbde8..3222b9857bf
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@@ -701,14 -701,14 +701,14 @@@ bool get_effector_data(EffectorCache *e
else if (eff->pd && eff->pd->shape == PFIELD_SHAPE_POINTS) {
/* TODO: hair and points object support */
const Mesh *me_eval = BKE_object_get_evaluated_mesh(eff->ob);
- const MVert *verts = BKE_mesh_verts(me_eval);
+ const float(*positions)[3] = BKE_mesh_positions(me_eval);
const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(me_eval);
if (me_eval != NULL) {
- copy_v3_v3(efd->loc, verts[*efd->index].co);
+ copy_v3_v3(efd->loc, positions[*efd->index]);
copy_v3_v3(efd->nor, vert_normals[*efd->index]);
- mul_m4_v3(eff->ob->obmat, efd->loc);
- mul_mat3_m4_v3(eff->ob->obmat, efd->nor);
+ mul_m4_v3(eff->ob->object_to_world, efd->loc);
+ mul_mat3_m4_v3(eff->ob->object_to_world, efd->nor);
normalize_v3(efd->nor);
diff --cc source/blender/blenkernel/intern/fluid.c
index 63e54f3a07c,a3d2d73678c..52640990532
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@@ -1037,11 -1036,11 +1036,11 @@@ static void obstacles_from_mesh(Object
float co[3];
/* Vertex position. */
- mul_m4_v3(coll_ob->obmat, positions[i]);
- mul_m4_v3(coll_ob->object_to_world, verts[i].co);
- manta_pos_to_cell(fds, verts[i].co);
++ mul_m4_v3(coll_ob->object_to_world, positions[i]);
+ manta_pos_to_cell(fds, positions[i]);
/* Vertex velocity. */
- add_v3fl_v3fl_v3i(co, verts[i].co, fds->shift);
+ add_v3fl_v3fl_v3i(co, positions[i], fds->shift);
if (has_velocity) {
sub_v3_v3v3(&vert_vel[i * 3], co, &fes->verts_old[i * 3]);
mul_v3_fl(&vert_vel[i * 3], 1.0f / dt);
@@@ -2100,11 -2099,11 +2099,11 @@@ static void emit_from_mesh
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, positions[i]);
- mul_m4_v3(flow_ob->object_to_world, verts[i].co);
- manta_pos_to_cell(fds, verts[i].co);
++ mul_m4_v3(flow_ob->object_to_world, positions[i]);
+ manta_pos_to_cell(fds, positions[i]);
/* Vertex normal. */
- mul_mat3_m4_v3(flow_ob->obmat, vert_normals[i]);
+ mul_mat3_m4_v3(flow_ob->object_to_world, vert_normals[i]);
mul_mat3_m4_v3(fds->imat, vert_normals[i]);
normalize_v3(vert_normals[i]);
@@@ -2120,9 -2119,9 +2119,9 @@@
}
/* Calculate emission map bounds. */
- bb_boundInsert(bb, verts[i].co);
+ bb_boundInsert(bb, positions[i]);
}
- mul_m4_v3(flow_ob->obmat, flow_center);
+ mul_m4_v3(flow_ob->object_to_world, flow_center);
manta_pos_to_cell(fds, flow_center);
/* Set emission map.
@@@ -3499,10 -3500,10 +3498,10 @@@ static Mesh *create_smoke_geometry(Flui
mul_m4_v3(fds->obmat, ob_cache_loc);
sub_v3_v3v3(fds->obj_shift_f, ob_cache_loc, ob_loc);
/* Convert shift to local space and apply to vertices. */
- mul_mat3_m4_v3(ob->imat, fds->obj_shift_f);
+ mul_mat3_m4_v3(ob->world_to_object, fds->obj_shift_f);
/* Apply shift to vertices. */
for (int i = 0; i < num_verts; i++) {
- add_v3_v3(mverts[i].co, fds->obj_shift_f);
+ add_v3_v3(positions[i], fds->obj_shift_f);
}
}
diff --cc source/blender/blenkernel/intern/mesh_remesh_voxel.cc
index 1ea01e6e45e,f38efd2cf65..21259c5d7a4
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
@@@ -295,16 -303,20 +296,18 @@@ void BKE_mesh_remesh_reproject_paint_ma
&target->vdata, CD_PAINT_MASK, CD_CONSTRUCT, nullptr, target->totvert);
}
- for (int i = 0; i < target->totvert; i++) {
- BVHTreeNearest nearest;
- nearest.index = -1;
- nearest.dist_sq = FLT_MAX;
- BLI_bvhtree_find_nearest(
- bvhtree.tree, target_positions[i], &nearest, bvhtree.nearest_callback, &bvhtree);
- if (nearest.index != -1) {
- target_mask[i] = source_mask[nearest.index];
+ blender::threading::parallel_for(IndexRange(target->totvert), 4096, [&](const IndexRange range) {
+ for (const int i : range) {
- float from_co[3];
+ BVHTreeNearest nearest;
+ nearest.index = -1;
+ nearest.dist_sq = FLT_MAX;
- copy_v3_v3(from_co, target_verts[i].co);
+ BLI_bvhtree_find_nearest(
- bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
++ bvhtree.tree, target_positions[i], &nearest, bvhtree.nearest_callback, &bvhtree);
+ if (nearest.index != -1) {
+ target_mask[i] = source_mask[nearest.index];
+ }
}
- }
+ });
free_bvhtree_from_mesh(&bvhtree);
}
@@@ -336,24 -348,24 +339,27 @@@ void BKE_remesh_reproject_sculpt_face_s
BVHTreeFromMesh bvhtree = {nullptr};
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_LOOPTRI,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list