19#ifdef DEBUG_PIXEL_NODES
51 &paint_mode_settings, &ob, &r_image_data->
image, &r_image_data->
image_user);
63 pixel_offset = int(image_pixel_position.y) * image_buffer->
x + int(image_pixel_position.x);
95 pixel_offset = int(image_pixel_position.y) * image_buffer->
x + int(image_pixel_position.x);
107 static_cast<const uchar *
>(
static_cast<const void *
>(
128 const float2 &barycentric_weight)
130 const int3 &
verts = vert_tris[tri_index];
131 const float3 weights(barycentric_weight.x,
132 barycentric_weight.y,
133 1.0f - barycentric_weight.x - barycentric_weight.y);
136 vert_positions[
verts[0]],
137 vert_positions[
verts[1]],
138 vert_positions[
verts[2]],
161 positions[
i] = start + delta *
i;
166 ImageBuffer image_accessor_;
170 const char *last_used_color_space_ =
nullptr;
181 bool pixels_painted =
false;
183 float4 color = image_accessor_.read_pixel(image_buffer);
184 float4 paint_color = brush_color_ * factors[
x];
187#ifdef DEBUG_PIXEL_NODES
189 paint_color[0] *= 0.5f;
190 paint_color[1] *= 0.5f;
191 paint_color[2] *= 0.5f;
196 buffer_color *=
brush.alpha;
198 image_accessor_.write_pixel(image_buffer,
color);
199 pixels_painted =
true;
201 image_accessor_.next_pixel();
203 return pixels_painted;
208 const char *to_colorspace = image_accessor_.get_colorspace_name(image_buffer);
209 if (last_used_color_space_ == to_colorspace) {
214 brush_color_[3] = 1.0f;
219 from_colorspace, to_colorspace);
222 last_used_color_space_ = to_colorspace;
233 const Bounds<float3> brush_bounds(location - radius, location + radius);
272#ifdef DEBUG_PIXEL_NODES
275 brush_color[0] =
float(
hash & 255) / 255.0f;
276 brush_color[1] =
float((
hash >> 8) & 255) / 255.0f;
277 brush_color[2] =
float((
hash >> 16) & 255) / 255.0f;
284 brush_color[3] = 1.0f;
291 bool pixels_updated =
false;
299 if (image_buffer ==
nullptr) {
331 bool pixels_painted =
false;
333 pixels_painted = kernel_float4.
paint(
brush, pixel_row, factors, image_buffer);
336 pixels_painted = kernel_byte4.
paint(
brush, pixel_row, factors, image_buffer);
339 if (pixels_painted) {
355 ImBuf *ibuf,
int x,
int y,
int w,
int h,
int *tx,
int *ty,
int *tw,
int *th)
357 int srcx = 0, srcy = 0;
376 int tilex, tiley, tilew, tileh;
387 for (
int ty = tiley; ty <= tileh; ty++) {
388 for (
int tx = tilex; tx <= tilew; tx++) {
409 ImBuf *tmpibuf =
nullptr;
415 if (image_buffer ==
nullptr) {
419 push_undo(node_data,
image, image_user, image_tile, *image_buffer, &tmpibuf);
472 *r_image_user =
nullptr;
479 *r_image = image_data.
image;
const float * BKE_brush_color_get(const Paint *paint, const Brush *brush)
const float * BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
bool BKE_paint_canvas_image_get(PaintModeSettings *settings, Object *ob, Image **r_image, ImageUser **r_image_user)
A BVH for high poly meshes.
BLI_INLINE unsigned int BLI_hash_int(unsigned int k)
#define LISTBASE_FOREACH(type, var, list)
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
bool isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
#define POINTER_AS_UINT(i)
Object is a sort of wrapper for general info.
#define USER_EXPERIMENTAL_TEST(userdef, member)
void * ED_image_paint_tile_push(PaintTileMap *paint_tile_map, Image *image, ImBuf *ibuf, ImBuf **tmpibuf, ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid, bool use_thread_lock, bool find_prev)
PaintTileMap * ED_image_paint_tile_map_get()
#define ED_IMAGE_UNDO_TILE_BITS
const char * IMB_colormanagement_get_rect_colorspace(const ImBuf *ibuf)
ColormanageProcessor * IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
@ COLOR_ROLE_SCENE_LINEAR
const char * IMB_colormanagement_role_colorspace_name_get(int role)
const char * IMB_colormanagement_get_float_colorspace(const ImBuf *ibuf)
void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4])
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
void IMB_freeImBuf(ImBuf *ibuf)
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
constexpr int64_t size() const
constexpr IndexRange index_range() const
void resize(const int64_t new_size)
void fill(const T &value) const
float4 read_pixel(ImBuf *image_buffer) const
const char * get_colorspace_name(ImBuf *image_buffer)
void write_pixel(ImBuf *image_buffer, const float4 pixel_data) const
void set_image_position(ImBuf *image_buffer, ushort2 image_pixel_position)
const char * get_colorspace_name(ImBuf *image_buffer)
float4 read_pixel(ImBuf *image_buffer) const
void set_image_position(ImBuf *image_buffer, ushort2 image_pixel_position)
void write_pixel(ImBuf *image_buffer, const float4 pixel_data) const
bool paint(const Brush &brush, const PackedPixelRow &pixel_row, const Span< float > factors, ImBuf *image_buffer)
void init_brush_color(ImBuf *image_buffer, float in_brush_color[3])
void foreach_index(Fn &&fn) const
const ccl_global KernelWorkTile * tile
pbvh::Tree * pbvh_get(Object &object)
NodeData & node_data_get(blender::bke::pbvh::Node &node)
void mark_image_dirty(blender::bke::pbvh::Node &node, Image &image, ImageUser &image_user)
void copy_pixels(blender::bke::pbvh::Tree &pbvh, Image &image, ImageUser &image_user, image::TileNumber tile_number)
void collect_dirty_tiles(blender::bke::pbvh::Node &node, Vector< image::TileNumber > &r_dirty_tiles)
PBVHData & data_get(blender::bke::pbvh::Tree &pbvh)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
static void fix_non_manifold_seam_bleeding(bke::pbvh::Tree &pbvh, Image &image, ImageUser &image_user, Span< TileNumber > tile_numbers_to_fix)
static float3 calc_pixel_position(const Span< float3 > vert_positions, const Span< int3 > vert_tris, const int tri_index, const float2 &barycentric_weight)
static BitVector init_uv_primitives_brush_test(SculptSession &ss, const Span< int3 > vert_tris, const Span< UVPrimitivePaintInput > uv_primitives, const Span< float3 > positions)
static void calc_pixel_row_positions(const Span< float3 > vert_positions, const Span< int3 > vert_tris, const Span< UVPrimitivePaintInput > uv_primitives, const PackedPixelRow &pixel_row, const MutableSpan< float3 > positions)
static void do_paint_pixels(const Depsgraph &depsgraph, Object &object, const Paint &paint, const Brush &brush, ImageData image_data, bke::pbvh::Node &node)
static void push_undo(const NodeData &node_data, Image &image, ImageUser &image_user, const image::ImageTileWrapper &image_tile, ImBuf &image_buffer, ImBuf **tmpibuf)
static void undo_region_tiles(ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
static void do_push_undo_tile(Image &image, ImageUser &image_user, bke::pbvh::Node &node)
void calc_brush_strength_factors(const StrokeCache &cache, const Brush &brush, Span< float > distances, MutableSpan< float > factors)
void apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
void filter_distances_with_radius(float radius, Span< float > distances, MutableSpan< float > factors)
void scale_factors(MutableSpan< float > factors, float strength)
void calc_brush_distances(const SculptSession &ss, Span< float3 > vert_positions, Span< int > vert, eBrushFalloffShape falloff_shape, MutableSpan< float > r_distances)
void calc_brush_texture_factors(const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert, MutableSpan< float > factors)
void min_max(const T &value, T &min, T &max)
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
VecBase< uint16_t, 2 > ushort2
VecBase< float, 3 > float3
bool SCULPT_paint_image_canvas_get(PaintModeSettings &paint_mode_settings, Object &ob, Image **r_image, ImageUser **r_image_user)
Get the image canvas for painting on the given object.
void SCULPT_do_paint_brush_image(const Depsgraph &depsgraph, PaintModeSettings &paint_mode_settings, const Sculpt &sd, Object &ob, const blender::IndexMask &node_mask)
bool SCULPT_use_image_paint_brush(PaintModeSettings &settings, Object &ob)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
blender::ed::sculpt_paint::StrokeCache * cache
blender::float3 cursor_location
TileNumber get_tile_number() const
Vector< UDIMTileUndo > undo_regions
struct blender::bke::pbvh::pixels::NodeData::@126372137103364156366300331140353251345266233066 flags
Vector< UVPrimitivePaintInput > uv_primitives
Vector< UDIMTilePixels > tiles
ushort2 start_image_coordinate
ushort uv_primitive_index
float2 start_barycentric_coord
Vector< PackedPixelRow > pixel_rows
void mark_dirty(const PackedPixelRow &pixel_row)
struct blender::bke::pbvh::pixels::UDIMTilePixels::@213142071117224155011332260101117126053322200307 flags
static bool init_active_image(Object &ob, ImageData *r_image_data, PaintModeSettings &paint_mode_settings)