Cleanup: Remove unnecessary/indirect includes in sculpt headers

The main goal is removing bmesh.hh from BKE_paint.hh, since that
includes it in many more files than necessary. Also remove more
includes from sculpt_intern.hh.
This commit is contained in:
Hans Goudey
2023-12-26 10:45:53 -05:00
parent a683d1b0c6
commit d54b24c55a
12 changed files with 81 additions and 96 deletions

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -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<PBVHNode *> nodes, float r_area_no[3], float r_area_co[3])
{

View File

@@ -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"

View File

@@ -105,6 +105,17 @@ Vector<PBVHNode *> brush_affected_nodes_gather(SculptSession *ss, Brush *brush)
return Vector<PBVHNode *>();
}
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],

View File

@@ -15,6 +15,7 @@
#include "BLT_translation.h"
#include "DNA_brush_types.h"
#include "DNA_mesh_types.h"
#include "BKE_context.hh"

View File

@@ -8,37 +8,22 @@
#pragma once
#include <memory>
#include <queue>
#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 <functional>
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<PBVHNode *> 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;
}

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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: {

View File

@@ -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"},