[Bf-blender-cvs] [f94295e46a4] temp-sculpt-colors: Merge branch 'master' into temp-sculpt-colors

Joseph Eagar noreply at git.blender.org
Sat Jan 15 08:10:05 CET 2022


Commit: f94295e46a47900bc5e9f5e5b6a2726bc556ba23
Author: Joseph Eagar
Date:   Fri Jan 14 22:13:14 2022 -0800
Branches: temp-sculpt-colors
https://developer.blender.org/rBf94295e46a47900bc5e9f5e5b6a2726bc556ba23

Merge branch 'master' into temp-sculpt-colors

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



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

diff --cc source/blender/blenkernel/BKE_pbvh.h
index f8969fea990,1ef1c98ce83..dde127a5a15
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -398,8 -397,10 +398,9 @@@ typedef struct PBVHVertexIter 
  
    /* mesh */
    struct MVert *mverts;
+   float (*vert_normals)[3];
    int totvert;
    const int *vert_indices;
 -  struct MPropCol *vcol;
    float *vmask;
  
    /* bmesh */
@@@ -413,9 -414,10 +414,9 @@@
    struct MVert *mvert;
    struct BMVert *bm_vert;
    float *co;
-   short *no;
+   float *no;
    float *fno;
    float *mask;
 -  float *col;
    bool visible;
  } PBVHVertexIter;
  
diff --cc source/blender/blenkernel/intern/mesh.cc
index 1aa5f776a77,1aa3477437a..998893bb9cb
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@@ -157,8 -168,7 +168,9 @@@ static void mesh_copy_data(Main *bmain
      mesh_dst->key->from = &mesh_dst->id;
    }
  
 +  mesh_dst->attr_color_active = mesh_src->attr_color_active;
 +  mesh_dst->attr_color_render = mesh_src->attr_color_render;
+   BKE_mesh_assert_normals_dirty_or_calculated(mesh_dst);
  }
  
  static void mesh_free_data(ID *id)
diff --cc source/blender/blenkernel/intern/pbvh.c
index addcc095432,ce27fdd28a0..beb64c8cfd0
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -31,9 -31,8 +31,9 @@@
  #include "DNA_mesh_types.h"
  #include "DNA_meshdata_types.h"
  
 +#include "BKE_attribute.h"
  #include "BKE_ccg.h"
- #include "BKE_mesh.h" /* for BKE_mesh_calc_normals */
+ #include "BKE_mesh.h"
  #include "BKE_paint.h"
  #include "BKE_pbvh.h"
  #include "BKE_subdiv_ccg.h"
@@@ -1325,18 -1292,12 +1320,19 @@@ static void pbvh_update_draw_buffer_cb(
                                       &pbvh->gridkey,
                                       update_flags);
          break;
 -      case PBVH_FACES:
 +      case PBVH_FACES: {
 +        CustomDataLayer *cl = NULL;
 +        AttributeDomain domain;
 +
 +        BKE_pbvh_get_color_layer(pbvh->mesh, &cl, &domain);
 +
          GPU_pbvh_mesh_buffers_update(node->draw_buffers,
                                       pbvh->verts,
+                                      pbvh->vert_normals,
                                       CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK),
 -                                     CustomData_get_layer(pbvh->ldata, CD_MLOOPCOL),
 +                                     cl ? cl->data : NULL,
 +                                     cl ? cl->type : -1,
 +                                     cl ? domain : ATTR_DOMAIN_AUTO,
                                       CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS),
                                       pbvh->face_sets_color_seed,
                                       pbvh->face_sets_color_default,
@@@ -3000,7 -2960,11 +2996,10 @@@ void pbvh_vertex_iter_init(PBVH *pbvh, 
  
    vi->mask = NULL;
    if (pbvh->type == PBVH_FACES) {
+     /* Cast away const because sculpt/paint code can adjust normals when restoring mesh data. */
+     vi->vert_normals = pbvh->vert_normals;
+ 
      vi->vmask = CustomData_get_layer(pbvh->vdata, CD_PAINT_MASK);
 -    vi->vcol = CustomData_get_layer(pbvh->vdata, CD_PROP_COLOR);
    }
  }
  
diff --cc source/blender/editors/geometry/geometry_attributes.cc
index e282e474c6a,9c0f6728701..17dbb61048d
--- a/source/blender/editors/geometry/geometry_attributes.cc
+++ b/source/blender/editors/geometry/geometry_attributes.cc
@@@ -92,10 -88,9 +92,10 @@@ static int geometry_attribute_add_exec(
    RNA_string_get(op->ptr, "name", name);
    CustomDataType type = (CustomDataType)RNA_enum_get(op->ptr, "data_type");
    AttributeDomain domain = (AttributeDomain)RNA_enum_get(op->ptr, "domain");
 -  CustomDataLayer *layer = BKE_id_attribute_new(id, name, type, domain, op->reports);
 +  CustomDataLayer *layer = BKE_id_attribute_new(
 +      id, name, type, CD_MASK_PROP_ALL, domain, op->reports);
  
-   if (layer == NULL) {
+   if (layer == nullptr) {
      return OPERATOR_CANCELLED;
    }
  
@@@ -176,11 -144,13 +176,15 @@@ void GEOMETRY_OT_attribute_add(wmOperat
  static int geometry_attribute_remove_exec(bContext *C, wmOperator *op)
  {
    Object *ob = ED_object_context(C);
-   ID *id = ob->data;
+   ID *id = static_cast<ID *>(ob->data);
    CustomDataLayer *layer = BKE_id_attributes_active_get(id);
  
+   if (layer == nullptr) {
+     return OPERATOR_CANCELLED;
+   }
+ 
 +  next_color_attrs(id, layer);
 +
    if (!BKE_id_attribute_remove(id, layer, op->reports)) {
      return OPERATOR_CANCELLED;
    }
diff --cc source/blender/editors/geometry/geometry_intern.hh
index 04e87de8748,14992476edd..ec20e6da48f
--- a/source/blender/editors/geometry/geometry_intern.hh
+++ b/source/blender/editors/geometry/geometry_intern.hh
@@@ -25,8 -25,6 +25,8 @@@
  
  struct wmOperatorType;
  
- /* *** geometry_attributes.c *** */
+ /* *** geometry_attributes.cc *** */
  void GEOMETRY_OT_attribute_add(struct wmOperatorType *ot);
  void GEOMETRY_OT_attribute_remove(struct wmOperatorType *ot);
 +void GEOMETRY_OT_color_attribute_add(struct wmOperatorType *ot);
 +void GEOMETRY_OT_color_attribute_remove(struct wmOperatorType *ot);
diff --cc source/blender/gpu/GPU_buffers.h
index 7fb7e5b7f4d,0a1d9c3b6d5..e7b8f1abf49
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@@ -98,14 -96,14 +98,15 @@@ enum 
   */
  void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
                                    const struct MVert *mvert,
+                                   const float (*vert_normals)[3],
                                    const float *vmask,
 -                                  const struct MLoopCol *vcol,
 +                                  const void *vcol_data,
 +                                  const int vcol_type,
 +                                  const AttributeDomain vcol_domain,
                                    const int *sculpt_face_sets,
 -                                  int face_sets_color_seed,
 -                                  int face_sets_color_default,
 -                                  const struct MPropCol *vtcol,
 -                                  int update_flags);
 +                                  const int face_sets_color_seed,
 +                                  const int face_sets_color_default,
 +                                  const int update_flags);
  
  /**
   * Creates a vertex buffer (coordinate, normal, color) and,
diff --cc source/blender/gpu/intern/gpu_buffers.c
index 25cd3bdd795,dd53bea4eca..80149854ecf
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@@ -212,10 -210,9 +212,11 @@@ static bool gpu_pbvh_is_looptri_visible
  
  void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
                                    const MVert *mvert,
+                                   const float (*vert_normals)[3],
                                    const float *vmask,
 -                                  const MLoopCol *vcol,
 +                                  const void *vcol_data,
 +                                  const int vcol_type,
 +                                  const AttributeDomain vcol_domain,
                                    const int *sculpt_face_sets,
                                    const int face_sets_color_seed,
                                    const int face_sets_color_default,
diff --cc source/blender/makesdna/DNA_mesh_types.h
index 7f9a7ebd650,fdd389c9c50..edb252b7ecb
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@@ -138,22 -153,8 +153,13 @@@ typedef struct Mesh_Runtime 
    int64_t cd_dirty_loop;
    int64_t cd_dirty_poly;
  
-   /**
-    * Settings for lazily evaluating the subdivision on the CPU if needed. These are
-    * set in the modifier when GPU subdivision can be performed.
-    */
-   char subsurf_apply_render;
-   char subsurf_use_optimal_display;
-   char _pad[2];
-   int subsurf_resolution;
- 
  } Mesh_Runtime;
  
 +typedef struct AttributeRef {
 +  int domain, type;
 +  char name[64];
 +} AttributeRef;
 +
  typedef struct Mesh {
    ID id;
    /** Animation data (must be immediately after id for utilities to use it). */



More information about the Bf-blender-cvs mailing list