43 float3 barycentric = end_barycentric - start_barycentric;
44 return float2(barycentric.x, barycentric.y);
52 const float2 start_uv(
float(
x) / image_buffer->
x,
float(
y) / image_buffer->
y);
53 const float2 end_uv(
float(
x + 1) / image_buffer->
x,
float(
y) / image_buffer->
y);
58 const ImBuf *image_buffer,
59 const int triangle_index,
66 for (
int y = miny;
y < maxy;
y++) {
67 bool start_detected =
false;
73 for (
x = minx;
x < maxx;
x++) {
74 float2 uv((
float(
x) + 0.5f) / image_buffer->
x, (
float(
y) + 0.5f) / image_buffer->
y);
80 start_detected =
true;
89 if (!start_detected) {
99 for (
int i = 0; i <
node->totprim; i++) {
128 if (image_buffer ==
nullptr) {
136 for (
int triangle_index = 0; triangle_index < triangles.
size(); triangle_index++) {
145 const int miny =
floor(minv * image_buffer->
y);
147 const int maxy =
min_ii(
ceil(maxv * image_buffer->
y), image_buffer->
y);
149 const int minx =
floor(minu * image_buffer->
x);
151 const int maxx =
min_ii(
ceil(maxu * image_buffer->
x), image_buffer->
x);
156 tile_data, image_buffer, triangle_index, uvs, minx, miny, maxx, maxy);
166 node_data->
tiles.append(tile_data);
179 if (node_data !=
nullptr) {
188 for (
int n = 0; n < pbvh->
totnode; n++) {
209 if (nodes_to_update_len == 0) {
213 r_nodes_to_update.
reserve(nodes_to_update_len);
215 for (
int n = 0; n < pbvh->
totnode; n++) {
223 if (
node->pixels.node_data ==
nullptr) {
224 NodeData *node_data = MEM_new<NodeData>(__func__);
225 node->pixels.node_data = node_data;
243 if (image_buffer ==
nullptr) {
246 for (
int n = 0; n < pbvh->
totnode; n++) {
253 if (tile_node_data ==
nullptr) {
264 if (image_buffer->
rect) {
266 static_cast<void *
>(&image_buffer->
rect[pixel_offset]));
288 if (ldata_uv ==
nullptr) {
323 #ifdef DO_PRINT_STATISTICS
326 int64_t compressed_data_len = 0;
328 for (
int n = 0; n < pbvh->
totnode; n++) {
336 compressed_data_len += tile_data.encoded_pixels.size() *
sizeof(
PackedPixelRow);
337 for (
const PackedPixelRow &encoded_pixels : tile_data.encoded_pixels) {
342 printf(
"Encoded %lld pixels in %lld bytes (%f bytes per pixel)\n",
367 if (image_buffer ==
nullptr) {
391 MEM_delete(node_data);
392 node->pixels.node_data =
nullptr;
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer(const struct CustomData *data, int type)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
void BKE_image_partial_update_mark_full_update(struct Image *image)
Mark the whole image to be updated.
A BVH for high poly meshes.
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings, bool use_threading, int totnode)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_fff(float a, float b, float c)
MINLINE int min_ii(int a, int b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float min_fff(float a, float b, float c)
int barycentric_inside_triangle_v2(const float w[3])
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
MINLINE void copy_v4_uchar(unsigned char r[4], unsigned char a)
MINLINE void copy_v4_fl(float r[4], float f)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void append(const T &value)
void reserve(const int64_t min_capacity)
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
static bool is_inside(int x, int y, int cols, int rows)
ccl_gpu_kernel_postfix ccl_global float int num_pixels
ccl_global const KernelWorkTile * tile
ccl_device_inline float3 ceil(const float3 &a)
static bool barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
NodeData & BKE_pbvh_pixels_node_data_get(PBVHNode &node)
constexpr bool USE_WATERTIGHT_CHECK
static void do_encode_pixels(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static float2 calc_barycentric_delta(const float2 uvs[3], const float2 start_uv, const float2 end_uv)
static void init_triangles(PBVH *pbvh, PBVHNode *node, NodeData *node_data, const MLoop *mloop)
static void extract_barycentric_pixels(UDIMTilePixels &tile_data, const ImBuf *image_buffer, const int triangle_index, const float2 uvs[3], const int minx, const int miny, const int maxx, const int maxy)
static int64_t count_nodes_to_update(PBVH *pbvh)
static bool should_pixels_be_updated(PBVHNode *node)
static float2 calc_barycentric_delta_x(const ImBuf *image_buffer, const float2 uvs[3], const int x, const int y)
static void apply_watertight_check(PBVH *pbvh, Image *image, ImageUser *image_user)
void BKE_pbvh_pixels_mark_image_dirty(PBVHNode &node, Image &image, ImageUser &image_user)
static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image_user)
static bool find_nodes_to_update(PBVH *pbvh, Vector< PBVHNode * > &r_nodes_to_update)
vec_base< uint16_t, 2 > ushort2
vec_base< float, 2 > float2
vec_base< int32_t, 3 > int3
void pbvh_pixels_free(PBVHNode *node)
void BKE_pbvh_build_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image_user)
const struct MLoopTri * looptri
int get_tile_number() const
int2 get_tile_offset() const
Vector< PBVHNode * > * nodes
void mark_region(Image &image, const image::ImageTileWrapper &image_tile, ImBuf &image_buffer)
void rebuild_undo_regions()
struct blender::bke::pbvh::pixels::NodeData::@58 flags
UDIMTilePixels * find_tile_data(const image::ImageTileWrapper &image_tile)
Vector< UDIMTilePixels > tiles
ushort2 start_image_coordinate
float2 start_barycentric_coord
uint64_t mem_size() const
void append(const int3 vert_indices)
TrianglePaintInput & get_paint_input(const int index)
Vector< PackedPixelRow > pixel_rows