diff --git a/source/blender/blenkernel/BKE_paint.hh b/source/blender/blenkernel/BKE_paint.hh index 40c5c887000..edb5b9a3b26 100644 --- a/source/blender/blenkernel/BKE_paint.hh +++ b/source/blender/blenkernel/BKE_paint.hh @@ -10,28 +10,26 @@ #include "BLI_array.hh" #include "BLI_bit_vector.hh" -#include "BLI_bitmap.h" -#include "BLI_compiler_compat.h" #include "BLI_math_matrix_types.hh" #include "BLI_math_vector_types.hh" #include "BLI_offset_indices.hh" #include "BLI_ordered_edge.hh" #include "BLI_set.hh" -#include "BLI_utildefines.h" #include "DNA_brush_enums.h" +#include "DNA_customdata_types.h" #include "DNA_object_enums.h" #include "BKE_pbvh.hh" -#include "bmesh.hh" - struct BMFace; +struct BMLog; struct BMesh; struct BlendDataReader; struct BlendLibReader; struct BlendWriter; struct Brush; +struct CustomDataLayer; struct CurveMapping; struct Depsgraph; struct EnumPropertyItem; @@ -785,27 +783,6 @@ void BKE_sculpt_attribute_destroy_temporary_all(Object *ob); /* Destroy attributes that were marked as stroke only in SculptAttributeParams. */ void BKE_sculpt_attributes_destroy_temporary_stroke(Object *ob); -BLI_INLINE void *BKE_sculpt_vertex_attr_get(const PBVHVertRef vertex, const SculptAttribute *attr) -{ - if (attr->data) { - char *p = (char *)attr->data; - int idx = (int)vertex.i; - - if (attr->data_for_bmesh) { - BMElem *v = (BMElem *)vertex.i; - idx = v->head.index; - } - - return p + attr->elem_size * (int)idx; - } - else { - BMElem *v = (BMElem *)vertex.i; - return BM_ELEM_CD_GET_VOID_P(v, attr->bmesh_cd_offset); - } - - return NULL; -} - /** * Create new color layer on object if it doesn't have one and if experimental feature set has * sculpt vertex color enabled. Returns truth if new layer has been added, false otherwise. diff --git a/source/blender/blenkernel/BKE_pbvh.hh b/source/blender/blenkernel/BKE_pbvh.hh index 15b184db036..6a7a3fbd58b 100644 --- a/source/blender/blenkernel/BKE_pbvh.hh +++ b/source/blender/blenkernel/BKE_pbvh.hh @@ -6,11 +6,9 @@ /** \file * \ingroup bke - * \brief External data structures for PBVH. Does not include data structures internal to the draw - * code. + * \brief External data structures for PBVH. Does not include internal data structures. */ -#include "BLI_compiler_compat.h" #include "BLI_utildefines.h" struct PBVHNode; @@ -76,7 +74,7 @@ struct PBVHPublic { struct PBVH; struct PBVHNode; -BLI_INLINE PBVHType BKE_pbvh_type(const PBVH *pbvh) +inline PBVHType BKE_pbvh_type(const PBVH *pbvh) { return ((const PBVHPublic *)pbvh)->type; } diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 8a3d73902f8..dc48d31ffc9 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -30,6 +30,7 @@ #include "DNA_brush_types.h" #include "DNA_customdata_types.h" +#include "DNA_key_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -2954,6 +2955,39 @@ void SCULPT_flip_quat_by_symm_area(float quat[4], } } +bool SCULPT_tool_needs_all_pbvh_nodes(const Brush *brush) +{ + if (brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) { + /* Elastic deformations in any brush need all nodes to avoid artifacts as the effect + * of the Kelvinlet is not constrained by the radius. */ + return true; + } + + if (brush->sculpt_tool == SCULPT_TOOL_POSE) { + /* Pose needs all nodes because it applies all symmetry iterations at the same time + * and the IK chain can grow to any area of the model. */ + /* TODO: This can be optimized by filtering the nodes after calculating the chain. */ + return true; + } + + if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { + /* Boundary needs all nodes because it is not possible to know where the boundary + * deformation is going to be propagated before calculating it. */ + /* TODO: after calculating the boundary info in the first iteration, it should be + * possible to get the nodes that have vertices included in any boundary deformation + * and cache them. */ + return true; + } + + if (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK && + brush->snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC) + { + /* Snake hook in elastic deform type has same requirements as the elastic deform tool. */ + return true; + } + return false; +} + void SCULPT_calc_brush_plane( Sculpt *sd, Object *ob, Span nodes, float r_area_no[3], float r_area_co[3]) { diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index 8beeadd5f5d..c706ecfaa36 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -15,7 +15,6 @@ #include "BLI_math_base_safe.h" #include "BLI_math_vector_types.hh" #include "BLI_set.hh" -#include "BLI_task.h" #include "BLI_vector.hh" #include "DNA_brush_types.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index a9d1c970509..8e8af4519c0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -105,6 +105,17 @@ Vector brush_affected_nodes_gather(SculptSession *ss, Brush *brush) return Vector(); } +bool is_cloth_deform_brush(const Brush *brush) +{ + return (brush->sculpt_tool == SCULPT_TOOL_CLOTH && ELEM(brush->cloth_deform_type, + BRUSH_CLOTH_DEFORM_GRAB, + BRUSH_CLOTH_DEFORM_SNAKE_HOOK)) || + /* All brushes that are not the cloth brush deform the simulation using softbody + * constraints instead of applying forces. */ + (brush->sculpt_tool != SCULPT_TOOL_CLOTH && + brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM); +} + static float cloth_brush_simulation_falloff_get(const Brush *brush, const float radius, const float location[3], diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.cc b/source/blender/editors/sculpt_paint/sculpt_detail.cc index 6f826bfe657..f872fde4df0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.cc +++ b/source/blender/editors/sculpt_paint/sculpt_detail.cc @@ -15,6 +15,7 @@ #include "BLT_translation.h" +#include "DNA_brush_types.h" #include "DNA_mesh_types.h" #include "BKE_context.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index d35d2ff5f4c..91c509c202b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -8,37 +8,22 @@ #pragma once -#include #include -#include "DNA_brush_types.h" -#include "DNA_key_types.h" -#include "DNA_listBase.h" -#include "DNA_scene_types.h" -#include "DNA_vec_types.h" - #include "BKE_attribute.hh" -#include "BKE_paint.hh" #include "BKE_pbvh_api.hh" #include "BLI_array.hh" #include "BLI_bit_vector.hh" -#include "BLI_bitmap.h" -#include "BLI_compiler_attrs.h" -#include "BLI_compiler_compat.h" #include "BLI_generic_array.hh" -#include "BLI_implicit_sharing.hh" #include "BLI_math_matrix_types.hh" #include "BLI_math_vector_types.hh" #include "BLI_set.hh" #include "BLI_span.hh" -#include "BLI_threads.h" #include "BLI_vector.hh" #include "ED_view3d.hh" -#include - namespace blender::ed::sculpt_paint { namespace auto_mask { struct NodeData; @@ -219,7 +204,7 @@ struct Node { bool applied; /* shape keys */ - char shapeName[sizeof(KeyBlock::name)]; + char shapeName[MAX_NAME]; /* sizeof(KeyBlock::name). */ /* Geometry modification operations. * @@ -1044,38 +1029,7 @@ void SCULPT_orig_vert_data_unode_init(SculptOrigVertData *data, /** \name Brush Utilities. * \{ */ -BLI_INLINE bool SCULPT_tool_needs_all_pbvh_nodes(const Brush *brush) -{ - if (brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) { - /* Elastic deformations in any brush need all nodes to avoid artifacts as the effect - * of the Kelvinlet is not constrained by the radius. */ - return true; - } - - if (brush->sculpt_tool == SCULPT_TOOL_POSE) { - /* Pose needs all nodes because it applies all symmetry iterations at the same time - * and the IK chain can grow to any area of the model. */ - /* TODO: This can be optimized by filtering the nodes after calculating the chain. */ - return true; - } - - if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) { - /* Boundary needs all nodes because it is not possible to know where the boundary - * deformation is going to be propagated before calculating it. */ - /* TODO: after calculating the boundary info in the first iteration, it should be - * possible to get the nodes that have vertices included in any boundary deformation - * and cache them. */ - return true; - } - - if (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK && - brush->snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC) - { - /* Snake hook in elastic deform type has same requirements as the elastic deform tool. */ - return true; - } - return false; -} +bool SCULPT_tool_needs_all_pbvh_nodes(const Brush *brush); void SCULPT_calc_brush_plane(Sculpt *sd, Object *ob, @@ -1461,16 +1415,7 @@ void plane_falloff_preview_draw(uint gpuattr, blender::Vector brush_affected_nodes_gather(SculptSession *ss, Brush *brush); -BLI_INLINE bool is_cloth_deform_brush(const Brush *brush) -{ - return (brush->sculpt_tool == SCULPT_TOOL_CLOTH && ELEM(brush->cloth_deform_type, - BRUSH_CLOTH_DEFORM_GRAB, - BRUSH_CLOTH_DEFORM_SNAKE_HOOK)) || - /* All brushes that are not the cloth brush deform the simulation using softbody - * constraints instead of applying forces. */ - (brush->sculpt_tool != SCULPT_TOOL_CLOTH && - brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM); -} +bool is_cloth_deform_brush(const Brush *brush); } @@ -1881,6 +1826,23 @@ int SCULPT_vertex_island_get(const SculptSession *ss, PBVHVertRef vertex); /** \} */ -/* Make SCULPT_ alias to a few blenkernel sculpt methods. */ +inline void *SCULPT_vertex_attr_get(const PBVHVertRef vertex, const SculptAttribute *attr) +{ + if (attr->data) { + char *p = (char *)attr->data; + int idx = (int)vertex.i; -#define SCULPT_vertex_attr_get BKE_sculpt_vertex_attr_get + if (attr->data_for_bmesh) { + BMElem *v = (BMElem *)vertex.i; + idx = v->head.index; + } + + return p + attr->elem_size * (int)idx; + } + else { + BMElem *v = (BMElem *)vertex.i; + return BM_ELEM_CD_GET_VOID_P(v, attr->bmesh_cd_offset); + } + + return NULL; +} diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc index 51d5bb89519..7fbb0403dda 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc @@ -8,6 +8,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_brush_types.h" + #include "BLI_hash.h" #include "BLI_math_color_blend.h" #include "BLI_task.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc index 448a745d7f6..7de4915bd38 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc @@ -5,6 +5,7 @@ /* Paint a color made from hash of node pointer. */ //#define DEBUG_PIXEL_NODES +#include "DNA_brush_types.h" #include "DNA_image_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index 6ae3bb53797..6d11e75d7b4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -12,7 +12,6 @@ #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" -#include "BLI_task.h" #include "BKE_brush.hh" #include "BKE_context.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index 9c180007b36..3254f48ba2a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -40,7 +40,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "DNA_mesh_types.h" +#include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -54,7 +54,6 @@ #include "BKE_layer.h" #include "BKE_main.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" #include "BKE_multires.hh" #include "BKE_object.hh" #include "BKE_paint.hh" @@ -1221,14 +1220,14 @@ static Node *alloc_node(Object *ob, PBVHNode *node, Type type) } else { unode->vert_hidden.resize(unode->vert_indices.size()); - usculpt->undo_size += BLI_BITMAP_SIZE(unode->vert_indices.size()); + usculpt->undo_size += unode->vert_hidden.size() / 8; } break; } case Type::HideFace: { unode->face_hidden.resize(unode->face_indices.size()); - usculpt->undo_size += BLI_BITMAP_SIZE(unode->face_indices.size()); + usculpt->undo_size += unode->face_hidden.size() / 8; break; } case Type::Mask: { diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.cc b/source/blender/makesrna/intern/rna_sculpt_paint.cc index e038ad512aa..c802b445c09 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.cc +++ b/source/blender/makesrna/intern/rna_sculpt_paint.cc @@ -33,6 +33,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "bmesh.hh" + const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[] = { {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs"}, {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth hairs"},