88 snap->old_col == col);
93 snap->old_zoom = zoom;
122 const bool col =
data->col;
125 const int size =
data->size;
126 const float rotation =
data->rotation;
127 const float radius =
data->radius;
129 bool convert_to_linear =
false;
137 if (tex_ibuf && tex_ibuf->
float_data() ==
nullptr) {
138 convert_to_linear =
true;
144 for (
int i = 0; i < size; i++) {
147 int index = j * size + i;
149 float x =
float(i) / size;
150 float y =
float(j) / size;
158 x = (
x - 0.5f) * 2.0f;
159 y = (
y - 0.5f) * 2.0f;
167 if (mtex->
tex && (rotation > 0.001f || rotation < -0.001f)) {
179 if (convert_to_linear) {
187 buffer[
index * 4] = rgba[0] * 255;
188 buffer[
index * 4 + 1] = rgba[1] * 255;
189 buffer[
index * 4 + 2] = rgba[2] * 255;
190 buffer[
index * 4 + 3] = rgba[3] * 255;
196 CLAMP(avg, 0.0f, 1.0f);
202 buffer[
index * 4] = 0;
203 buffer[
index * 4 + 1] = 0;
204 buffer[
index * 4 + 2] = 0;
205 buffer[
index * 4 + 3] = 0;
221 uchar *buffer =
nullptr;
228 target = (primary) ?
paint->runtime->primary_snap.get() :
paint->runtime->secondary_snap.get();
247 for (s >>= 1; s > 0; s >>= 1) {
253 size = std::max(size, 256);
254 size = std::max(size, target->
old_size);
288 data.buffer = buffer;
292 data.rotation = rotation;
293 data.radius = radius;
309 gpu::TextureFormat::UNORM_8;
312 "paint_cursor_overlay", size, size, 1, format, usage,
nullptr);
332 reset_overlay_flag(*
paint, invalid);
346 const int size =
data->size;
348 for (
int i = 0; i < size; i++) {
351 const int index = j * size + i;
352 const float x = ((
float(i) / size) - 0.5f) * 2.0f;
353 const float y = ((
float(j) / size) - 0.5f) * 2.0f;
374 uchar *buffer =
nullptr;
377 const bool refresh = !
paint->runtime->cursor_snap->overlay_texture ||
378 (flag_is_set(overlay_flags,
380 paint->runtime->cursor_snap->zoom != zoom ||
381 paint->runtime->cursor_snap->curve_preset !=
384 init = (
paint->runtime->cursor_snap->overlay_texture !=
nullptr);
389 paint->runtime->cursor_snap->zoom = zoom;
394 for (s >>= 1; s > 0; s >>= 1) {
400 size = std::max(size, 256);
401 size = std::max(size,
paint->runtime->cursor_snap->size);
403 if (
paint->runtime->cursor_snap->size != size) {
404 if (
paint->runtime->cursor_snap->overlay_texture) {
406 paint->runtime->cursor_snap->overlay_texture =
nullptr;
411 paint->runtime->cursor_snap->size = size;
419 data.buffer = buffer;
426 if (!
paint->runtime->cursor_snap->overlay_texture) {
429 "cursor_snap_overaly", size, size, 1, gpu::TextureFormat::UNORM_8, usage,
nullptr);
444 size =
paint->runtime->cursor_snap->size;
471 int overlay_alpha = (primary) ?
brush->texture_overlay_alpha :
brush->mask_overlay_alpha;
522 quad.
xmin = center[0] - radius;
523 quad.
ymin = center[1] - radius;
524 quad.
xmax = center[0] + radius;
525 quad.
ymax = center[1] + radius;
537 quad.
xmin = -
brush->stencil_dimension[0];
538 quad.
ymin = -
brush->stencil_dimension[1];
543 quad.
xmin = -
brush->mask_stencil_dimension[0];
544 quad.
ymin = -
brush->mask_stencil_dimension[1];
545 quad.
xmax =
brush->mask_stencil_dimension[0];
546 quad.
ymax =
brush->mask_stencil_dimension[1];
568 float final_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
570 copy_v3_v3(final_color,
U.sculpt_paint_overlay_col);
572 mul_v4_fl(final_color, overlay_alpha * 0.01f);
576 paint->runtime->secondary_snap->overlay_texture;
638 quad.
xmin =
x - radius;
639 quad.
ymin =
y - radius;
640 quad.
xmax =
x + radius;
641 quad.
ymax =
y + radius;
661 float final_color[4] = {
UNPACK3(
U.sculpt_paint_overlay_col), 1.0f};
667 paint->runtime->cursor_snap->overlay_texture,
668 {GPU_SAMPLER_FILTERING_LINEAR,
669 GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER,
670 GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER});
701 bool alpha_overlay_active =
false;
743 return alpha_overlay_active;
747 const float sel_col[4],
748 const float pivot_col[4],
757 float w = width / 2.0f;
758 const float tri[3][2] = {
760 {co[0] -
w, co[1] -
w},
761 {co[0] +
w, co[1] -
w},
781 const float sel_col[4],
782 const float handle_col[4],
791 float w = width / 2.0f;
792 float minx = co[0] -
w;
793 float miny = co[1] -
w;
794 float maxx = co[0] +
w;
795 float maxy = co[1] +
w;
818 if (bez->
f1 || bez->
f2) {
829 if (bez->
f3 || bez->
f2) {
847 if (
brush->paint_curve &&
brush->paint_curve->points) {
859 float selec_col[4], handle_col[4], pivot_col[4];
864 for (
int i = 0; i < pc->
tot_points - 1; i++, cp++) {
872 pos, selec_col, handle_col, &cp->
bez.
vec[0][0], 8.0f, cp->
bez.
f1 || cp->
bez.
f2);
874 pos, selec_col, handle_col, &cp->
bez.
vec[2][0], 8.0f, cp->
bez.
f3 || cp->
bez.
f2);
876 for (j = 0; j < 2; j++) {
886 float (*
v)[2] =
reinterpret_cast<float (*)[2]
>(
data);
909 pos, selec_col, handle_col, &cp->
bez.
vec[0][0], 8.0f, cp->
bez.
f1 || cp->
bez.
f2);
911 pos, selec_col, handle_col, &cp->
bez.
vec[2][0], 8.0f, cp->
bez.
f3 || cp->
bez.
f2);
965 if (pcontext.
paint ==
nullptr) {
970 if (pcontext.
brush ==
nullptr) {
1001 pcontext.
tilt = tilt;
1065 const bool small = brush_size < 28 && brush_size > 12;
1094 switch (pcontext.
mode) {
1184 *pcontext.
paint, *pcontext.
brush, mouse, pcontext.
mode,
false,
false);
Object is a sort of wrapper for general info.
#define USER_EXPERIMENTAL_TEST(userdef, member)
Read Blender memory allocation and freeing.
#define PRF_scope(category)
#define BLI_assert_unreachable()
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
bool supports_secondary_cursor_color(const Brush &brush)
bool implements_3d_texture_paint(const Brush &brush)
void invalidate_overlay_all(Scene &scene)
@ InvalidTextureSecondary
eOverlayControlFlags get_overlay_flags(const Paint &paint)
void mesh_cursor_inactive_draw(PaintCursorContext &pcontext)
static void paint_draw_2D_view_brush_cursor(PaintCursorContext &pcontext)
static void load_tex_cursor_task_cb(void *__restrict userdata, const int j, const TaskParallelTLS *__restrict)
static void load_tex_task_cb_ex(void *__restrict userdata, const int j, const TaskParallelTLS *__restrict tls)
static void paint_update_mouse_cursor(PaintCursorContext &pcontext)
static bool paint_draw_cursor_overlay(Paint *paint, Brush *brush, int x, int y, float zoom)
static void paint_cursor_draw_3D_view_brush_cursor(PaintCursorContext &pcontext)
static int load_tex(Paint *paint, Brush *br, ViewContext *vc, float zoom, bool col, bool primary)
static void paint_cursor_restore_drawing_state()
BLI_INLINE void draw_bezier_handle_lines(uint pos, const float sel_col[4], BezTriple *bez)
static void paint_cursor_update_anchored_location(PaintCursorContext &pcontext)
void grease_pencil_cursor_draw(PaintCursorContext &pcontext)
static void paint_cursor_update_rake_rotation(PaintCursorContext &pcontext)
static bool paint_cursor_is_3d_view_navigating(const PaintCursorContext &pcontext)
void mesh_cursor_active_draw(PaintCursorContext &pcontext)
BLI_INLINE void draw_tri_point(uint pos, const float sel_col[4], const float pivot_col[4], float *co, float width, bool selected)
BLI_INLINE void draw_rect_point(uint pos, const float sel_col[4], const float handle_col[4], const float *co, float width, bool selected)
static void paint_cursor_setup_3D_drawing(PaintCursorContext &pcontext)
static void paint_cursor_check_and_draw_alpha_overlays(PaintCursorContext &pcontext)
static bool paint_cursor_is_brush_cursor_enabled(const PaintCursorContext &pcontext)
static void paint_cursor_setup_2D_drawing(PaintCursorContext &pcontext)
static void paint_draw_cursor(bContext *C, const int2 &xy, const float2 &tilt, void *)
static bool paint_draw_alpha_overlay(Paint *paint, Brush *brush, ViewContext *vc, int x, int y, float zoom, PaintMode mode)
static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
void mesh_cursor_update_and_init(PaintCursorContext &pcontext)
static int load_tex_cursor(Paint *paint, Brush *br, float zoom)
static void make_tex_snap(bke::paint::TexSnapshot *snap, ViewContext *vc, float zoom)
static bool paint_use_2d_cursor(PaintMode mode, const Brush &brush)
static int same_tex_snap(bke::paint::TexSnapshot *snap, MTex *mtex, ViewContext *vc, bool col, float zoom)
static void paint_draw_legacy_3D_view_brush_cursor(PaintCursorContext &pcontext)
static bool paint_cursor_context_init(bContext *C, const int2 &xy, const float2 &tilt, PaintCursorContext &pcontext)
static void paint_draw_2D_view_brush_cursor_default(PaintCursorContext &pcontext)
bool paint_brush_tool_poll(bContext *C)
static bool paint_draw_tex_overlay(Paint *paint, Brush *brush, ViewContext *vc, int x, int y, float zoom, const PaintMode mode, bool col, bool primary)
void get_color_type_4fv(int colorid, int spacetype, float col[4])
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
struct bNodeTreeExec * ntreeTexBeginExecTree(struct bNodeTree *ntree)
ScrArea * CTX_wm_area(const bContext *C)
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void GPU_matrix_scale_1f(float factor)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BKE_paint_calculate_rake_rotation(Paint &paint, const Brush &brush, const float mouse_pos[2], PaintMode paint_mode, bool in_stroke, bool is_first_dab)
GPUDepthTest GPU_depth_test_get()
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
GPUVertFormat * immVertexFormat()
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
@ PAINT_FALLOFF_SHAPE_TUBE
void immBegin(GPUPrimType, uint vertex_len)
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
void GPU_line_smooth(bool enable)
@ GPU_SAMPLER_FILTERING_LINEAR
wmWindow * CTX_wm_window(const bContext *C)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
void GPU_matrix_rotate_2d(float deg)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void immUniformColor4fv(const float rgba[4])
void immAttr2f(uint attr_id, float x, float y)
Base * CTX_data_active_base(const bContext *C)
void ED_paint_cursor_start(Paint *paint, bool(*poll)(bContext *C))
void GPU_line_width(float width)
void GPU_matrix_scale_2f(float x, float y)
@ GPU_BLEND_ALPHA_PREMULT
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
void BKE_curvemapping_init(CurveMapping *cumap)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void immVertex2f(uint attr_id, float x, float y)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
BMesh const char void * data
@ GPU_SHADER_3D_IMAGE_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
wmWindowManager * CTX_wm_manager(const bContext *C)
void GPU_texture_swizzle_set(gpu::Texture *texture, const char swizzle[4])
void GPU_color_mask(bool r, bool g, bool b, bool a)
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_FILL
void immUniformColor4f(float r, float g, float b, float a)
void ntreeTexEndExecTree(struct bNodeTreeExec *exec)
int BKE_brush_size_get(const Paint *paint, const Brush *brush)
MINLINE void clamp_v4(float vec[4], float min, float max)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool paint_get_tex_pixel(const MTex *mtex, float u, float v, ImagePool *pool, int thread, float *r_intensity, float r_rgba[4])
int BLI_task_parallel_thread_id(const TaskParallelTLS *tls)
void BKE_image_pool_free(ImagePool *pool)
void GPU_matrix_translate_2f(float x, float y)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, wmPaintCursorPoll poll, wmPaintCursorDraw draw, void *customdata)
void immBindTextureSampler(const char *name, gpu::Texture *tex, GPUSamplerState state)
bool BKE_brush_use_size_pressure(const Brush *brush)
float BKE_brush_curve_strength_clamped(const Brush *br, float p, float len)
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
Paint * BKE_paint_get_active_from_context(const bContext *C)
MINLINE float max_ff(float a, float b)
void GPU_texture_free(gpu::Texture *texture)
Brush * BKE_paint_brush(Paint *paint)
void GPU_texture_unbind(gpu::Texture *texture)
void GPU_matrix_translate_2fv(const float vec[2])
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
void WM_cursor_set(wmWindow *win, int curs)
ImagePool * BKE_image_pool_new()
void GPU_blend(GPUBlend blend)
MINLINE void mul_v4_fl(float r[4], float f)
VecBase< float, 3 > float3
@ BRUSH_OVERLAY_SECONDARY
ImBuf * BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
void immVertex2fv(uint attr_id, const float data[2])
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
void immUniformColor3fvAlpha(const float rgb[3], float a)
ARegion * BKE_screen_find_region_type(const bScreen *screen, int region_type) ATTR_NONNULL(1)
void GPU_depth_test(GPUDepthTest test)
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
ocio::ColorSpace ColorSpace
vector snap(vector a, vector b)
#define PAINT_CURVE_NUM_SEGMENTS
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBrushImagePaintType image_brush_type
eBrushCurvePreset curve_distance_falloff_preset
struct CurveMapping * curve_distance_falloff
float texture_sample_bias
eBrushStrokeType stroke_method
const ColorSpace * colorspace
ImBufByteBuffer byte_buffer
const float * float_data() const
eMTex_BrushMapMode brush_map_mode
bke::ObjectRuntime * runtime
struct UnifiedPaintSettings unified_paint_settings
bke::PaintRuntime * runtime
struct bNodeTree * nodetree
bke::bNodeTreeRuntime * runtime
ListBaseT< ARegion > regionbase
SculptSession * sculpt_session
float2 anchored_initial_mouse
float size_pressure_value
gpu::Texture * overlay_texture
UnifiedPaintSettings * ups
PaintCursorDrawingType cursor_type