[Bf-blender-cvs] [404a0d5840f] sculpt-dev: Sculpt-dev: Pre-merge preperations
Joseph Eagar
noreply at git.blender.org
Tue Sep 20 19:53:17 CEST 2022
Commit: 404a0d5840f51eb195d541f9f5b09add8567017c
Author: Joseph Eagar
Date: Fri Sep 16 23:58:26 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB404a0d5840f51eb195d541f9f5b09add8567017c
Sculpt-dev: Pre-merge preperations
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/paint.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 0fd92636637..0f02891896d 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -24,7 +24,7 @@
extern "C" {
#endif
-struct SculptCustomLayer;
+struct SculptAttribute;
struct MSculptVert;
struct BMFace;
struct BMesh;
@@ -59,7 +59,6 @@ struct Scene;
struct StrokeCache;
struct SubdivCCG;
struct Tex;
-struct SculptCustomLayer;
struct ToolSettings;
struct UnifiedPaintSettings;
struct View3D;
@@ -628,7 +627,7 @@ typedef struct SculptArray {
int *symmetry_pass;
float *smooth_strength;
- struct SculptCustomLayer *scl_inst, *scl_sym;
+ struct SculptAttribute *scl_inst, *scl_sym;
} SculptArray;
typedef struct SculptFakeNeighbors {
@@ -644,61 +643,6 @@ typedef struct SculptFakeNeighbors {
/* Session data (mode-specific) */
-/* Custom Temporary Attributes */
-
-typedef struct SculptLayerParams {
- /* Allocate a flat array outside the CustomData system. Cannot be combined with permanent. */
- int simple_array : 1;
-
- /* Do not mark CustomData layer as temporary. Cannot be combined with simple_array. Doesn't
- * work with PBVH_GRIDS.
- */
- int permanent : 1; // cannot be combined with simple_array
- int nocopy : 1;
- int nointerp : 1;
- int stroke_only : 1; /* release layer at end of struct, except for PBVH_BMESH */
-} SculptLayerParams;
-
-typedef struct SculptCustomLayer {
- eAttrDomain domain;
- int proptype;
- SculptLayerParams params;
-
- char name[MAX_CUSTOMDATA_LAYER_NAME];
-
- bool is_cdlayer; // false for multires data
- void *data; // only valid for multires and face
- int elemsize;
- int cd_offset; // for bmesh
- struct CustomDataLayer *layer; // not for multires
- bool from_bmesh; // note that layers can be fixed arrays but still from a bmesh, e.g. filter
- // laplacian smooth
- bool released;
- bool ready;
-} SculptCustomLayer;
-
-/* Standard names for sculpt attributes. */
-typedef enum {
- SCULPT_SCL_FAIRING_MASK,
- SCULPT_SCL_FAIRING_FADE,
- SCULPT_SCL_PREFAIRING_CO,
- SCULPT_SCL_PERS_CO,
- SCULPT_SCL_PERS_NO,
- SCULPT_SCL_PERS_DISP,
- SCULPT_SCL_LAYER_DISP,
- SCULPT_SCL_LAYER_STROKE_ID,
- SCULPT_SCL_ORIG_FSETS,
- SCULPT_SCL_SMOOTH_VEL,
- SCULPT_SCL_SMOOTH_BDIS,
- SCULPT_SCL_AUTOMASKING,
- SCULPT_SCL_LIMIT_SURFACE,
- SCULPT_SCL_LAYER_MAX,
-} SculptStandardAttr;
-
-#define SCULPT_SCL_GET_NAME(stdattr) ("__" #stdattr)
-
-#define SCULPT_MAX_TEMP_LAYERS 64
-
typedef struct SculptSession {
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
struct { /* Special handling for multires meshes */
@@ -911,37 +855,37 @@ typedef struct SculptSession {
/* This is a fixed-size array so we can pass pointers to its elements
* to client code. This is important to keep bmesh offsets up to date.
*/
- struct SculptCustomLayer temp_layers[SCULPT_MAX_TEMP_LAYERS];
+ struct SculptAttribute temp_layers[SCULPT_MAX_TEMP_LAYERS];
/* Convienence SculptCusotmLayer pointers. */
struct {
/* Persistent base. */
- SculptCustomLayer *persistent_co;
- SculptCustomLayer *persistent_no;
- SculptCustomLayer *persistent_disp;
+ SculptAttribute *persistent_co;
+ SculptAttribute *persistent_no;
+ SculptAttribute *persistent_disp;
/* Fairing. */
- SculptCustomLayer *fairing_fade;
- SculptCustomLayer *fairing_mask;
- SculptCustomLayer *prefairing_co;
+ SculptAttribute *fairing_fade;
+ SculptAttribute *fairing_mask;
+ SculptAttribute *prefairing_co;
/* Automasking. */
- SculptCustomLayer *automasking_factor;
+ SculptAttribute *automasking_factor;
/* Layer brush. */
- SculptCustomLayer *layer_disp;
- SculptCustomLayer *layer_id;
+ SculptAttribute *layer_disp;
+ SculptAttribute *layer_id;
/* Limit Surface */
- SculptCustomLayer *limit_surface;
+ SculptAttribute *limit_surface;
/* Smooth */
- SculptCustomLayer *smooth_bdist;
- SculptCustomLayer *smooth_vel;
+ SculptAttribute *smooth_bdist;
+ SculptAttribute *smooth_vel;
/* Face Sets */
- SculptCustomLayer *orig_fsets;
+ SculptAttribute *orig_fsets;
} scl;
bool save_temp_layers;
@@ -978,13 +922,13 @@ void BKE_sculptsession_bmesh_attr_update_internal(struct Object *ob);
void BKE_sculptsession_sync_attributes(struct Object *ob, struct Mesh *me);
void BKE_sculptsession_bmesh_add_layers(struct Object *ob);
-SculptCustomLayer *BKE_sculptsession_attr_layer_get(struct Object *ob,
+SculptAttribute *BKE_sculptsession_attr_layer_get(struct Object *ob,
eAttrDomain domain,
int proptype,
const char *name,
SculptLayerParams *params,
bool *r_is_new);
-bool BKE_sculptsession_attr_release_layer(struct Object *ob, SculptCustomLayer *scl);
+bool BKE_sculptsession_attr_release_layer(struct Object *ob, SculptAttribute *scl);
void BKE_sculptsession_update_attr_refs(struct Object *ob);
int BKE_sculptsession_get_totvert(const SculptSession *ss);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 90ef8528b1f..9c4d33a883c 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1553,14 +1553,6 @@ void BKE_sculptsession_free(Object *ob)
MEM_SAFE_FREE(ss->vemap);
MEM_SAFE_FREE(ss->vemap_mem);
- for (int i = 0; i < SCULPT_MAX_TEMP_LAYERS; i++) {
- SculptCustomLayer *scl = ss->temp_layers + i;
-
- if (!scl->released && !scl->is_cdlayer) {
- BKE_sculptsession_attr_release_layer(ob, scl);
- }
- }
-
if (ss->tex_pool) {
BKE_image_pool_free(ss->tex_pool);
}
@@ -3085,539 +3077,7 @@ BMesh *BKE_sculptsession_empty_bmesh_create()
return bm;
}
-char dyntopo_node_idx_vertex_id[] = "_dyntopo_vnode_id";
-char dyntopo_node_idx_face_id[] = "_dyntopo_fnode_id";
-char dyntopo_faces_areas_layer_id[] = "__dyntopo_face_areas";
-
-void BKE_sculptsession_bmesh_add_layers(Object *ob)
-{
- SculptSession *ss = ob->sculpt;
-
- int cd_node_layer_index, cd_face_node_layer_index;
-
- BMCustomLayerReq vlayers[] = {
- {CD_PAINT_MASK, NULL, 0},
- {CD_DYNTOPO_VERT, NULL, CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY},
- {CD_PROP_INT32, dyntopo_node_idx_vertex_id, CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY}};
-
- BM_data_layers_ensure(ss->bm, &ss->bm->vdata, vlayers, ARRAY_SIZE(vlayers));
-
- ss->cd_vert_mask_offset = CustomData_get_offset(&ss->bm->vdata, CD_PAINT_MASK);
-
- BMCustomLayerReq flayers[] = {
- {CD_PROP_INT32, dyntopo_node_idx_face_id, CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY},
- {CD_PROP_FLOAT2, dyntopo_faces_areas_layer_id, CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY},
- };
- BM_data_layers_ensure(ss->bm, &ss->bm->pdata, flayers, ARRAY_SIZE(flayers));
-
- // get indices again, as they might have changed after adding new layers
- cd_node_layer_index = CustomData_get_named_layer_index(
- &ss->bm->vdata, CD_PROP_INT32, dyntopo_node_idx_vertex_id);
- cd_face_node_layer_index = CustomData_get_named_layer_index(
- &ss->bm->pdata, CD_PROP_INT32, dyntopo_node_idx_face_id);
-
- ss->cd_sculpt_vert = CustomData_get_offset(&ss->bm->vdata, CD_DYNTOPO_VERT);
-
- ss->cd_vert_node_offset = CustomData_get_n_offset(
- &ss->bm->vdata,
- CD_PROP_INT32,
- cd_node_layer_index - CustomData_get_layer_index(&ss->bm->vdata, CD_PROP_INT32));
-
- ss->bm->vdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY;
-
- ss->cd_face_node_offset = CustomData_get_n_offset(
- &ss->bm->pdata,
- CD_PROP_INT32,
- cd_face_node_layer_index - CustomData_get_layer_index(&ss->bm->pdata, CD_PROP_INT32));
-
- ss->bm->pdata.layers[cd_face_node_layer_index].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY;
- ss->cd_faceset_offset = CustomData_get_offset(&ss->bm->pdata, CD_SCULPT_FACE_SETS);
-
- ss->cd_face_areas = CustomData_get_named_layer_index(
- &ss->bm->pdata, CD_PROP_FLOAT2, dyntopo_faces_areas_layer_id);
-
- ss->cd_face_areas = ss->bm->pdata.layers[ss->cd_face_areas].offset;
-
- eAttrDomain domain;
- CustomDataLayer *cl;
- Mesh *me = BKE_object_get_original_mesh(ob);
-
- if (BKE_pbvh_get_color_layer(me, &cl, &domain)) {
- ss->vcol_domain = (int)domain;
- ss->vcol_type = cl->type;
- ss->cd_vcol_offset = cl->offset;
- }
- else {
- ss->cd_vcol_offset = -1;
- ss->vcol_type = -1;
- ss->vcol_domain = (int)ATTR_DOMAIN_NUM;
- }
-}
-
-static bool sculpt_attr_get_layer(SculptSession *ss,
- Object *ob,
- eAttrDomain domain,
- int proptype,
- const char *name,
- SculptCustomLayer *out,
- bool autocreate,
- SculptLayerParams *params)
-{
- if (ss->save_temp_layers && !params->simple_array) {
- params->permanent = true;
- }
-
- bool simple_array = params->simple_array;
- bool permanent = params->permanent;
- bool nocopy = params->nocopy;
- bool nointerp = params->nointerp;
-
- out->params = *params;
- out->proptype = proptype;
- out->domain = domain;
- BLI_strncpy_utf8(out->name, name, sizeof(out->name));
-
- if (ss->pbvh && BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
- if (permanent) {
- printf(
- "%s: error: tried to make permanent customdata in multires mode; will make local "
- "array "
- "instead.\n",
- __func__);
- permanent = false;
- }
- }
-
- BLI_assert(!(simple_array && permanent));
-
- if (simple_array) {
- CustomData *cdata = NULL;
- int totelem = 0;
-
- PBVHType pbvhtype = ss->pbvh ? BKE_pbvh_type(ss->pbvh) : (ss->bm ? PBVH_BMESH : PBVH_FACES);
-
- switch (pbvhtype) {
- case PBVH_BMESH: {
- switch (domain) {
- case ATTR_DOMAIN_POINT:
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list