Cleanup: Remove indirect includes from paint_intern.hh

Many files were including headers unnecessarily because
they were included incirectly here. Instead use more forward
declarations and includes in the specific files that need inline
functions. Also:
 - Add const to arguments for one function
 - Remove `flip_qt` and `flip_qt_qt`from the header
This commit is contained in:
Hans Goudey 2024-05-14 12:24:16 -04:00
parent 3d1c8a3ff3
commit 60bcbb50e4
25 changed files with 112 additions and 74 deletions

@ -14,6 +14,7 @@
#include "BKE_mesh_sample.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_paint.hh"
#include "BKE_report.hh"
#include "ED_screen.hh"

@ -9,6 +9,7 @@
#include "BKE_crazyspace.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_paint.hh"
#include "ED_screen.hh"
#include "ED_view3d.hh"

@ -16,6 +16,7 @@
#include "BKE_brush.hh"
#include "BKE_context.hh"
#include "BKE_curves.hh"
#include "BKE_paint.hh"
#include "DEG_depsgraph.hh"

@ -7,6 +7,7 @@
#include "curves_sculpt_intern.hh"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_rotation.h"
#include "BLI_task.hh"
#include "BLI_vector.hh"

@ -5,6 +5,7 @@
#include "BKE_brush.hh"
#include "BKE_context.hh"
#include "BKE_crazyspace.hh"
#include "BKE_paint.hh"
#include "ED_screen.hh"
#include "ED_view3d.hh"

@ -6,6 +6,7 @@
#include "BKE_deform.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_object_deform.h"
#include "BKE_paint.hh"
#include "BKE_report.hh"
#include "DEG_depsgraph_query.hh"

@ -17,6 +17,7 @@
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_paint.hh"
#include "DEG_depsgraph_query.hh"
#include "DNA_brush_enums.h"

@ -9,6 +9,7 @@
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_material.h"
#include "BKE_paint.hh"
#include "BKE_scene.hh"
#include "BLI_color.hh"

@ -8,6 +8,7 @@
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_paint.hh"
#include "BLI_index_mask.hh"
#include "BLI_math_vector.hh"

@ -2,6 +2,8 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_math_rotation.h"
#include "BKE_context.hh"
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"

@ -9,6 +9,7 @@
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_material.h"
#include "BKE_paint.hh"
#include "BLI_bounds.hh"
#include "BLI_length_parameterize.hh"

@ -13,11 +13,13 @@
#include "BKE_grease_pencil_vertex_groups.hh"
#include "BKE_modifier.hh"
#include "BKE_object_deform.h"
#include "BKE_paint.hh"
#include "BKE_scene.hh"
#include "DEG_depsgraph_query.hh"
#include "BLI_kdtree.h"
#include "BLI_rect.h"
#include "DNA_meshdata_types.h"

@ -8,42 +8,52 @@
#pragma once
#include "BKE_paint.hh"
#include "BLI_array.hh"
#include "BLI_compiler_compat.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_math_vector_types.hh"
#include "BLI_span.hh"
#include "BLI_vector.hh"
#include "ED_select_utils.hh"
#include "DNA_object_enums.h"
#include "DNA_scene_enums.h"
#include "DNA_vec_types.h"
#include "DNA_scene_types.h"
enum class PaintMode : int8_t;
struct ARegion;
struct bContext;
struct Brush;
struct ColorManagedDisplay;
struct ColorSpace;
struct Depsgraph;
struct Image;
struct ImagePool;
struct ImageUser;
struct ImBuf;
struct Main;
struct MTex;
struct Object;
struct Paint;
struct PBVHNode;
struct PointerRNA;
struct RegionView3D;
struct Scene;
struct SpaceImage;
struct VPaint;
struct ViewContext;
struct bContext;
struct ReportList;
struct Scene;
struct SculptSession;
struct SpaceImage;
struct ToolSettings;
struct VertProjHandle;
struct ViewContext;
struct VPaint;
struct wmEvent;
struct wmKeyConfig;
struct wmKeyMap;
struct wmOperator;
struct wmOperatorType;
struct VertProjHandle;
namespace blender::ed::sculpt_paint {
struct PaintStroke;
}
struct StrokeCache;
} // namespace blender::ed::sculpt_paint
struct CoNo {
float co[3];
@ -348,7 +358,9 @@ void paint_calc_redraw_planes(float planes[4][4],
Object *ob,
const rcti *screen_rect);
float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius);
float paint_calc_object_space_radius(const ViewContext *vc,
const blender::float3 &center,
float pixel_radius);
/**
* Returns true when a color was sampled and false when a value was sampled.
@ -421,39 +433,11 @@ BLI_INLINE void flip_v3_v3(float out[3], const float in[3], const ePaintSymmetry
}
}
BLI_INLINE void flip_qt_qt(float out[4], const float in[4], const ePaintSymmetryFlags symm)
{
float axis[3], angle;
quat_to_axis_angle(axis, &angle, in);
normalize_v3(axis);
if (symm & PAINT_SYMM_X) {
axis[0] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Y) {
axis[1] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Z) {
axis[2] *= -1.0f;
angle *= -1.0f;
}
axis_angle_normalized_to_quat(out, axis, angle);
}
BLI_INLINE void flip_v3(float v[3], const ePaintSymmetryFlags symm)
{
flip_v3_v3(v, v, symm);
}
BLI_INLINE void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
{
flip_qt_qt(quat, quat, symm);
}
/* stroke operator */
enum BrushStrokeMode {
BRUSH_STROKE_NORMAL,
@ -509,7 +493,6 @@ struct BlurKernel {
int pixel_len; /* pixels around center that kernel is wide */
};
enum eBlurKernelType;
/**
* Paint blur kernels. Projective painting enforces use of a 2x2 kernel due to lagging.
* Can be extended to other blur kernels later,
@ -562,7 +545,7 @@ void init_session(
Vector<PBVHNode *> pbvh_gather_generic(Object *ob, VPaint *wp, Brush *brush);
void mode_enter_generic(
Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, const eObjectMode mode_flag);
Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, eObjectMode mode_flag);
void mode_exit_generic(Object *ob, const eObjectMode mode_flag);
bool mode_toggle_poll_test(bContext *C);

@ -39,6 +39,7 @@
#include "WM_types.hh"
#include "ED_sculpt.hh"
#include "ED_select_utils.hh"
#include "bmesh.hh"

@ -55,6 +55,7 @@
#include "ED_image.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "ED_view3d.hh"
#include "BLI_sys_types.h"
@ -126,7 +127,9 @@ void paint_calc_redraw_planes(float planes[4][4],
ED_view3d_clipping_calc(&bb, planes, region, ob, &rect);
}
float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius)
float paint_calc_object_space_radius(const ViewContext *vc,
const blender::float3 &center,
const float pixel_radius)
{
Object *ob = vc->obact;
float delta[3], scale, loc[3];

@ -20,6 +20,7 @@
#include "BLI_color_mix.hh"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_rotation.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_task.h"

@ -8,6 +8,8 @@
* Intended for use by `paint_vertex.cc` & `paint_vertex_weight_ops.cc`.
*/
#include <algorithm>
#include "BLI_listbase.h"
#include "BLI_string_utils.hh"
@ -150,7 +152,7 @@ int ED_wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
BLI_INLINE float wval_blend(const float weight, const float paintval, const float alpha)
{
const float talpha = min_ff(alpha, 1.0f); /* blending with values over 1 doesn't make sense */
const float talpha = std::min(alpha, 1.0f); /* blending with values over 1 doesn't make sense */
return (paintval * talpha) + (weight * (1.0f - talpha));
}
BLI_INLINE float wval_add(const float weight, const float paintval, const float alpha)
@ -183,7 +185,7 @@ BLI_INLINE float wval_colordodge(float weight, float paintval, float fac)
}
mfac = 1.0f - fac;
temp = (paintval == 1.0f) ? 1.0f :
min_ff((weight * (225.0f / 255.0f)) / (1.0f - paintval), 1.0f);
std::min((weight * (225.0f / 255.0f)) / (1.0f - paintval), 1.0f);
return mfac * weight + temp * fac;
}
BLI_INLINE float wval_difference(float weight, float paintval, float fac)
@ -203,7 +205,7 @@ BLI_INLINE float wval_screen(float weight, float paintval, float fac)
return weight;
}
mfac = 1.0f - fac;
temp = max_ff(1.0f - ((1.0f - weight) * (1.0f - paintval)), 0);
temp = std::max(1.0f - ((1.0f - weight) * (1.0f - paintval)), 0.0f);
return mfac * weight + temp * fac;
}
BLI_INLINE float wval_hardlight(float weight, float paintval, float fac)

@ -23,6 +23,7 @@
#include "BLI_ghash.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_set.hh"
#include "BLI_span.hh"
#include "BLI_task.h"
@ -2975,6 +2976,34 @@ ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3])
return symm_area;
}
static void flip_qt_qt(float out[4], const float in[4], const ePaintSymmetryFlags symm)
{
float axis[3], angle;
quat_to_axis_angle(axis, &angle, in);
normalize_v3(axis);
if (symm & PAINT_SYMM_X) {
axis[0] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Y) {
axis[1] *= -1.0f;
angle *= -1.0f;
}
if (symm & PAINT_SYMM_Z) {
axis[2] *= -1.0f;
angle *= -1.0f;
}
axis_angle_normalized_to_quat(out, axis, angle);
}
static void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
{
flip_qt_qt(quat, quat, symm);
}
void SCULPT_flip_v3_by_symm_area(float v[3],
const ePaintSymmetryFlags symm,
const ePaintSymmetryAreas symmarea,

@ -12,6 +12,7 @@
#include "BLI_hash.h"
#include "BLI_index_range.hh"
#include "BLI_math_base_safe.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "BLI_set.hh"
#include "BLI_vector.hh"

@ -12,6 +12,7 @@
#include "BLI_ghash.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector.hh"
#include "BLI_span.hh"

@ -18,6 +18,7 @@
#include "BLI_math_matrix_types.hh"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "BLI_rect.h"
#include "BLI_vector.hh"
#include "BKE_context.hh"

@ -10,6 +10,7 @@
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_task.h"

@ -9,6 +9,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "BLI_span.hh"

@ -23,3 +23,28 @@ typedef enum eSeqImageFitMethod {
SEQ_STRETCH_TO_FILL,
SEQ_USE_ORIGINAL_SIZE,
} eSeqImageFitMethod;
/**
* #Paint::symmetry_flags
* (for now just a duplicate of sculpt symmetry flags).
*/
typedef enum ePaintSymmetryFlags {
PAINT_SYMM_NONE = 0,
PAINT_SYMM_X = (1 << 0),
PAINT_SYMM_Y = (1 << 1),
PAINT_SYMM_Z = (1 << 2),
PAINT_SYMMETRY_FEATHER = (1 << 3),
PAINT_TILE_X = (1 << 4),
PAINT_TILE_Y = (1 << 5),
PAINT_TILE_Z = (1 << 6),
} ePaintSymmetryFlags;
ENUM_OPERATORS(ePaintSymmetryFlags, PAINT_TILE_Z);
#define PAINT_SYMM_AXIS_ALL (PAINT_SYMM_X | PAINT_SYMM_Y | PAINT_SYMM_Z)
#ifdef __cplusplus
inline ePaintSymmetryFlags operator++(ePaintSymmetryFlags &flags, int)
{
flags = ePaintSymmetryFlags(char(flags) + 1);
return flags;
}
#endif

@ -2551,31 +2551,6 @@ typedef enum ePaintFlags {
PAINT_SCULPT_DELAY_UPDATES = (1 << 4),
} ePaintFlags;
/**
* #Paint::symmetry_flags
* (for now just a duplicate of sculpt symmetry flags).
*/
typedef enum ePaintSymmetryFlags {
PAINT_SYMM_NONE = 0,
PAINT_SYMM_X = (1 << 0),
PAINT_SYMM_Y = (1 << 1),
PAINT_SYMM_Z = (1 << 2),
PAINT_SYMMETRY_FEATHER = (1 << 3),
PAINT_TILE_X = (1 << 4),
PAINT_TILE_Y = (1 << 5),
PAINT_TILE_Z = (1 << 6),
} ePaintSymmetryFlags;
ENUM_OPERATORS(ePaintSymmetryFlags, PAINT_TILE_Z);
#define PAINT_SYMM_AXIS_ALL (PAINT_SYMM_X | PAINT_SYMM_Y | PAINT_SYMM_Z)
#ifdef __cplusplus
inline ePaintSymmetryFlags operator++(ePaintSymmetryFlags &flags, int)
{
flags = ePaintSymmetryFlags(char(flags) + 1);
return flags;
}
#endif
/**
* #Sculpt::flags
* These can eventually be moved to paint flags?