[Bf-blender-cvs] [bf661c0a26f] refactor-mesh-corners-generic: Merge branch 'master' into refactor-mesh-corners-generic

Hans Goudey noreply at git.blender.org
Mon Dec 5 05:58:56 CET 2022


Commit: bf661c0a26f040a37a54398939b6ef7a5d6c3675
Author: Hans Goudey
Date:   Sun Dec 4 16:38:47 2022 -0600
Branches: refactor-mesh-corners-generic
https://developer.blender.org/rBbf661c0a26f040a37a54398939b6ef7a5d6c3675

Merge branch 'master' into refactor-mesh-corners-generic

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/data_transfer.cc
index 1ab8ed29236,0e2fa029a77..48e37d0670c
--- a/source/blender/blenkernel/intern/data_transfer.cc
+++ b/source/blender/blenkernel/intern/data_transfer.cc
@@@ -1562,14 -1569,10 +1571,9 @@@ bool BKE_object_data_transfer_ex(struc
        }
  
        if (mdef && vg_idx != -1 && !weights[LDATA]) {
 -        weights[LDATA] = static_cast<float *>(
 -            MEM_mallocN(sizeof(*weights[LDATA]) * (size_t)num_loops_dst, __func__));
 +        weights[LDATA] = MEM_mallocN(sizeof(*weights[LDATA]) * (size_t)num_loops_dst, __func__);
-         BKE_defvert_extract_vgroup_to_loopweights(mdef,
-                                                   vg_idx,
-                                                   num_verts_dst,
-                                                   corner_verts,
-                                                   num_loops_dst,
-                                                   invert_vgroup,
-                                                   weights[LDATA]);
+         BKE_defvert_extract_vgroup_to_loopweights(
+             mdef, vg_idx, num_verts_dst, loops_dst, num_loops_dst, invert_vgroup, weights[LDATA]);
        }
  
        if (data_transfer_layersmapping_generate(&lay_map,
diff --cc source/blender/blenkernel/intern/key.cc
index bc1eb29b5b9,37b2d14133c..1dc52e370e5
--- a/source/blender/blenkernel/intern/key.cc
+++ b/source/blender/blenkernel/intern/key.cc
@@@ -2226,15 -2248,15 +2232,15 @@@ void BKE_keyblock_mesh_calc_normals(con
      return;
    }
  
-   float(*positions)[3] = MEM_dupallocN(BKE_mesh_positions(mesh));
 -  MVert *verts = static_cast<MVert *>(MEM_dupallocN(BKE_mesh_verts(mesh)));
 -  BKE_keyblock_convert_to_mesh(kb, verts, mesh->totvert);
++  float(*positions)[3] = static_cast<float(*)[3]>(MEM_dupallocN(BKE_mesh_positions(mesh)));
 +  BKE_keyblock_convert_to_mesh(kb, positions, mesh->totvert);
    const MEdge *edges = BKE_mesh_edges(mesh);
    const MPoly *polys = BKE_mesh_polys(mesh);
 -  const MLoop *loops = BKE_mesh_loops(mesh);
 +  const int *corner_verts = BKE_mesh_corner_verts(mesh);
  
-   const bool loop_normals_needed = r_loopnors != NULL;
-   const bool vert_normals_needed = r_vertnors != NULL || loop_normals_needed;
-   const bool poly_normals_needed = r_polynors != NULL || vert_normals_needed ||
+   const bool loop_normals_needed = r_loopnors != nullptr;
+   const bool vert_normals_needed = r_vertnors != nullptr || loop_normals_needed;
+   const bool poly_normals_needed = r_polynors != nullptr || vert_normals_needed ||
                                     loop_normals_needed;
  
    float(*vert_normals)[3] = r_vertnors;
@@@ -2265,8 -2289,9 +2273,9 @@@
                                            vert_normals);
    }
    if (loop_normals_needed) {
-     short(*clnors)[2] = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL); /* May be NULL. */
+     short(*clnors)[2] = static_cast<short(*)[2]>(
+         CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL)); /* May be nullptr. */
 -    BKE_mesh_normals_loop_split(verts,
 +    BKE_mesh_normals_loop_split(positions,
                                  vert_normals,
                                  mesh->totvert,
                                  edges,
diff --cc source/blender/makesdna/DNA_mesh_types.h
index 8ca81799d25,7a28485c768..22e126399ad
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@@ -13,12 -13,11 +13,15 @@@
  #include "DNA_meshdata_types.h"
  #include "DNA_session_uuid_types.h"
  
 +#ifdef __cplusplus
 +#  include "BLI_math_vec_types.hh"
 +#endif
 +
  /** Workaround to forward-declare C++ type in C header. */
  #ifdef __cplusplus
+ 
+ #  include "BLI_math_vec_types.hh"
+ 
  namespace blender {
  template<typename T> class Span;
  template<typename T> class MutableSpan;
diff --cc source/blender/modifiers/intern/MOD_displace.cc
index 6436bf29bdc,84ede5fdd2a..47f9cb492ae
--- a/source/blender/modifiers/intern/MOD_displace.cc
+++ b/source/blender/modifiers/intern/MOD_displace.cc
@@@ -282,9 -284,10 +282,9 @@@ static void displaceModifier_do(Displac
      return;
    }
  
 -  mvert = BKE_mesh_verts_for_write(mesh);
    MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index);
  
-   if (defgrp_index >= 0 && dvert == NULL) {
+   if (defgrp_index >= 0 && dvert == nullptr) {
      /* There is a vertex group, but it has no vertices. */
      return;
    }
diff --cc source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
index 02d7ebdaf6c,be98f53d161..c7adc907a14
--- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
@@@ -37,11 -37,10 +37,10 @@@ class PlanarFieldInput final : public b
                                   const eAttrDomain domain,
                                   IndexMask /*mask*/) const final
    {
 -    const Span<MVert> verts = mesh.verts();
 +    const Span<float3> positions = mesh.positions();
      const Span<MPoly> polys = mesh.polys();
 -    const Span<MLoop> loops = mesh.loops();
 +    const Span<int> corner_verts = mesh.corner_verts();
-     const Span<float3> poly_normals{
-         reinterpret_cast<const float3 *>(BKE_mesh_poly_normals_ensure(&mesh)), mesh.totpoly};
+     const Span<float3> poly_normals = mesh.poly_normals();
  
      bke::MeshFieldContext context{mesh, ATTR_DOMAIN_FACE};
      fn::FieldEvaluator evaluator{context, polys.size()};
@@@ -49,7 -48,7 +48,8 @@@
      evaluator.evaluate();
      const VArray<float> thresholds = evaluator.get_evaluated<float>(0);
  
-     auto planar_fn = [positions, polys, corner_verts, thresholds, poly_normals](const int i) -> bool {
 -    auto planar_fn = [verts, polys, loops, thresholds, poly_normals](const int i) -> bool {
++    auto planar_fn =
++        [positions, polys, corner_verts, thresholds, poly_normals](const int i) -> bool {
        const MPoly &poly = polys[i];
        if (poly.totloop <= 3) {
          return true;
diff --cc source/blender/render/intern/bake.cc
index 5c5b6e62c69,cab3dbf54bc..019ecb08a27
--- a/source/blender/render/intern/bake.cc
+++ b/source/blender/render/intern/bake.cc
@@@ -459,28 -460,28 +460,28 @@@ static TriTessFace *mesh_calc_tri_tessf
    uint mpoly_prev = UINT_MAX;
    float no[3];
  
 -  const MVert *verts = BKE_mesh_verts(me);
 +  const float(*positions)[3] = BKE_mesh_positions(me);
    const MPoly *polys = BKE_mesh_polys(me);
 -  const MLoop *loops = BKE_mesh_loops(me);
 +  const int *corner_verts = BKE_mesh_corner_verts(me);
  
-   looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__);
-   triangles = MEM_callocN(sizeof(TriTessFace) * tottri, __func__);
+   looptri = static_cast<MLoopTri *>(MEM_mallocN(sizeof(*looptri) * tottri, __func__));
+   triangles = static_cast<TriTessFace *>(MEM_callocN(sizeof(TriTessFace) * tottri, __func__));
  
    const float(*precomputed_normals)[3] = BKE_mesh_poly_normals_are_dirty(me) ?
-                                              NULL :
+                                              nullptr :
                                               BKE_mesh_poly_normals_ensure(me);
    const bool calculate_normal = precomputed_normals ? false : true;
  
-   if (precomputed_normals != NULL) {
+   if (precomputed_normals != nullptr) {
      BKE_mesh_recalc_looptri_with_normals(
 -        loops, polys, verts, me->totloop, me->totpoly, looptri, precomputed_normals);
 +        corner_verts, polys, positions, me->totloop, me->totpoly, looptri, precomputed_normals);
    }
    else {
 -    BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri);
 +    BKE_mesh_recalc_looptri(corner_verts, polys, positions, me->totloop, me->totpoly, looptri);
    }
  
-   const TSpace *tspace = NULL;
-   const float(*loop_normals)[3] = NULL;
+   const TSpace *tspace = nullptr;
+   const float(*loop_normals)[3] = nullptr;
    if (tangent) {
      BKE_mesh_ensure_normals_for_display(me_eval);
      BKE_mesh_calc_normals_split(me_eval);
@@@ -739,12 -742,12 +742,12 @@@ void RE_bake_pixels_populate(Mesh *me
    }
  
    const int tottri = poly_to_tri_count(me->totpoly, me->totloop);
-   MLoopTri *looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__);
+   MLoopTri *looptri = static_cast<MLoopTri *>(MEM_mallocN(sizeof(*looptri) * tottri, __func__));
  
 -  const MVert *verts = BKE_mesh_verts(me);
 +  const float(*positions)[3] = BKE_mesh_positions(me);
    const MPoly *polys = BKE_mesh_polys(me);
 -  const MLoop *loops = BKE_mesh_loops(me);
 -  BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri);
 +  const int *corner_verts = BKE_mesh_corner_verts(me);
 +  BKE_mesh_recalc_looptri(corner_verts, polys, positions, me->totloop, me->totpoly, looptri);
  
    const int *material_indices = BKE_mesh_material_indices(me);
    const int materials_num = targets->materials_num;
diff --cc source/blender/render/intern/multires_bake.cc
index 8f43f9f1f2d,270f2fb22f2..e0a7e0e5a32
--- a/source/blender/render/intern/multires_bake.cc
+++ b/source/blender/render/intern/multires_bake.cc
@@@ -472,11 -472,11 +472,11 @@@ static void do_multires_bake(MultiresBa
    MultiresBakeThread *handles;
    MultiresBakeQueue queue;
  
 -  MVert *mvert = dm->getVertArray(dm);
 +  const float(*positions)[3] = (float(*)[3])dm->getVertArray(dm);
    MPoly *mpoly = dm->getPolyArray(dm);
-   const int *corner_verts = dm->getCornerVertArray(dm);
+   MLoop *mloop = dm->getLoopArray(dm);
 -  MLoopUV *mloopuv = static_cast<MLoopUV *>(dm->getLoopDataArray(dm, CD_MLOOPUV));
 -  float *pvtangent = nullptr;
 +  MLoopUV *mloopuv = dm->getLoopDataArray(dm, CD_MLOOPUV);
 +  float *pvtangent = NULL;
  
    ListBase threads;
    int i, tot_thread = bkr->threads > 0 ? bkr->threads : BLI_system_thread_count();
@@@ -555,9 -553,9 +555,9 @@@
      handle->queue = &queue;
  
      handle->data.mpoly = mpoly;
 -    handle->data.material_indices = static_cast<const int *>(
 -        CustomData_get_layer_named(&dm->polyData, CD_PROP_INT32, "material_index"));
 +    handle->data.material_indices = CustomData_get_layer_named(
 +        &dm->polyData, CD_PROP_INT32, "material_index");
-     handle->data.positi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list