Cleanup: avoid some unnecessary inverse matrix math.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 31 Jan 2019 11:36:00 +0000 (12:36 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 31 Jan 2019 17:01:47 +0000 (18:01 +0100)
source/blender/blenkernel/intern/object_update.c
source/blender/editors/sculpt_paint/sculpt.c

index a716750ee735256019f1f324880e9993037d00bb..5cf40cd13a4616c5f85180e358273083525c5152 100644 (file)
@@ -282,7 +282,7 @@ void BKE_object_synchronize_to_original(Depsgraph *depsgraph, Object *object)
        object_orig->base_flag = object->base_flag;
        /* Transformation flags. */
        copy_m4_m4(object_orig->obmat, object->obmat);
-       invert_m4_m4(object_orig->imat, object_orig->obmat);
+       copy_m4_m4(object_orig->imat, object->imat);
        copy_m4_m4(object_orig->constinv, object->constinv);
        object_orig->transflag = object->transflag;
        object_orig->flag = object->flag;
index f3a06988f1b2a40aec5901ffdd576d047cf316ab..a9e5a243865221a6d6781173f405122c09c45cb7 100644 (file)
@@ -5168,8 +5168,8 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
        sculpt_restore_mesh(sd, ob);
 
        if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) {
-               float object_space_constant_detail = sd->constant_detail * mat4_to_scale(ob->imat);
-               BKE_pbvh_bmesh_detail_size_set(ss->pbvh, 1.0f / object_space_constant_detail);
+               float object_space_constant_detail = mat4_to_scale(ob->obmat) / sd->constant_detail;
+               BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
        }
        else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
                BKE_pbvh_bmesh_detail_size_set(ss->pbvh, ss->cache->radius * sd->detail_percent / 100.0f);
@@ -6115,8 +6115,8 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
        size = max_fff(dim[0], dim[1], dim[2]);
 
        /* update topology size */
-       float object_space_constant_detail = sd->constant_detail * mat4_to_scale(ob->imat);
-       BKE_pbvh_bmesh_detail_size_set(ss->pbvh, 1.0f / object_space_constant_detail);
+       float object_space_constant_detail = mat4_to_scale(ob->obmat) / sd->constant_detail;
+       BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
 
        sculpt_undo_push_begin("Dynamic topology flood fill");
        sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_COORDS);