Blender  V3.3
BKE_pbvh_pixels.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2022 Blender Foundation. All rights reserved. */
3 
4 #pragma once
5 
6 #include "BLI_math.h"
7 #include "BLI_math_vec_types.hh"
8 #include "BLI_rect.h"
9 #include "BLI_vector.hh"
10 
11 #include "DNA_image_types.h"
12 #include "DNA_meshdata_types.h"
13 
14 #include "BKE_image.h"
15 #include "BKE_image_wrappers.hh"
16 
17 #include "IMB_imbuf_types.h"
18 
20 
29 
38  {
39  }
40 };
41 
48 struct Triangles {
51 
52  public:
53  void append(const int3 vert_indices)
54  {
55  this->paint_input.append(TrianglePaintInput(vert_indices));
56  }
57 
59  {
60  return paint_input[index];
61  }
62 
63  const TrianglePaintInput &get_paint_input(const int index) const
64  {
65  return paint_input[index];
66  }
67 
68  void clear()
69  {
70  paint_input.clear();
71  }
72 
73  uint64_t size() const
74  {
75  return paint_input.size();
76  }
77 
79  {
80  return paint_input.size() * sizeof(TrianglePaintInput);
81  }
82 };
83 
96 };
97 
103  short tile_number;
104 
105  struct {
106  bool dirty : 1;
107  } flags;
108 
109  /* Dirty region of the tile in image space. */
111 
113 
115  {
116  flags.dirty = false;
118  }
119 
120  void mark_dirty(const PackedPixelRow &pixel_row)
121  {
122  int2 start_image_coord(pixel_row.start_image_coordinate.x, pixel_row.start_image_coordinate.y);
123  BLI_rcti_do_minmax_v(&dirty_region, start_image_coord);
124  BLI_rcti_do_minmax_v(&dirty_region, start_image_coord + int2(pixel_row.num_pixels + 1, 0));
125  flags.dirty = true;
126  }
127 
128  void clear_dirty()
129  {
131  flags.dirty = false;
132  }
133 };
134 
135 struct UDIMTileUndo {
136  short tile_number;
138 
140  {
141  }
142 };
143 
144 struct NodeData {
145  struct {
146  bool dirty : 1;
147  } flags;
148 
152 
154  {
155  flags.dirty = false;
156  }
157 
159  {
160  for (UDIMTilePixels &tile : tiles) {
161  if (tile.tile_number == image_tile.get_tile_number()) {
162  return &tile;
163  }
164  }
165  return nullptr;
166  }
167 
169  {
170  undo_regions.clear();
171  for (UDIMTilePixels &tile : tiles) {
172  rcti region;
173  BLI_rcti_init_minmax(&region);
174  for (PackedPixelRow &pixel_row : tile.pixel_rows) {
176  &region, int2(pixel_row.start_image_coordinate.x, pixel_row.start_image_coordinate.y));
177  BLI_rcti_do_minmax_v(&region,
178  int2(pixel_row.start_image_coordinate.x + pixel_row.num_pixels + 1,
179  pixel_row.start_image_coordinate.y + 1));
180  }
181  undo_regions.append(UDIMTileUndo(tile.tile_number, region));
182  }
183  }
184 
185  void mark_region(Image &image, const image::ImageTileWrapper &image_tile, ImBuf &image_buffer)
186  {
187  UDIMTilePixels *tile = find_tile_data(image_tile);
188  if (tile && tile->flags.dirty) {
190  &image, image_tile.image_tile, &image_buffer, &tile->dirty_region);
191  tile->clear_dirty();
192  }
193  }
194 
195  void clear_data()
196  {
197  tiles.clear();
198  triangles.clear();
199  }
200 
201  static void free_func(void *instance)
202  {
203  NodeData *node_data = static_cast<NodeData *>(instance);
204  MEM_delete(node_data);
205  }
206 };
207 
210 
211 } // namespace blender::bke::pbvh::pixels
void BKE_image_partial_update_mark_region(struct Image *image, const struct ImageTile *image_tile, const struct ImBuf *image_buffer, const rcti *updated_region)
Mark a region of the image to update.
void BLI_rcti_init_minmax(struct rcti *rect)
Definition: rct.c:477
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition: rct.c:489
unsigned short ushort
Definition: BLI_sys_types.h:68
Contains defines and structs used throughout the imbuf module.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
void append(const T &value)
Definition: BLI_vector.hh:433
OperationNode * node
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
ccl_global const KernelWorkTile * tile
NodeData & BKE_pbvh_pixels_node_data_get(PBVHNode &node)
Definition: pbvh_pixels.cc:350
void BKE_pbvh_pixels_mark_image_dirty(PBVHNode &node, Image &image, ImageUser &image_user)
Definition: pbvh_pixels.cc:357
vec_base< int32_t, 2 > int2
unsigned __int64 uint64_t
Definition: stdint.h:90
void mark_region(Image &image, const image::ImageTileWrapper &image_tile, ImBuf &image_buffer)
static void free_func(void *instance)
struct blender::bke::pbvh::pixels::NodeData::@58 flags
UDIMTilePixels * find_tile_data(const image::ImageTileWrapper &image_tile)
Vector< TrianglePaintInput > paint_input
const TrianglePaintInput & get_paint_input(const int index) const
void append(const int3 vert_indices)
TrianglePaintInput & get_paint_input(const int index)
void mark_dirty(const PackedPixelRow &pixel_row)
struct blender::bke::pbvh::pixels::UDIMTilePixels::@57 flags
UDIMTileUndo(short tile_number, rcti &region)