From cf05109a2ecb2bea6970bc83632901502fcd66ac Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 6 Aug 2024 15:23:07 -0400 Subject: [PATCH] Sculpt: Use int triangle indices for image paint We don't support more than ~2 billion triangles anyway, no sense in wasting memory with a bunch of 64 bit ints. --- source/blender/blenkernel/BKE_pbvh_pixels.hh | 4 ++-- source/blender/blenkernel/intern/pbvh_pixels.cc | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh index b85267abf37..454b6dd7f6f 100644 --- a/source/blender/blenkernel/BKE_pbvh_pixels.hh +++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh @@ -19,7 +19,7 @@ namespace blender::bke::pbvh::pixels { struct UVPrimitivePaintInput { /** Corresponding index into triangles */ - int64_t tri_index; + int tri_index; /** * Delta barycentric coordinates between 2 neighboring UVs in the U direction. * @@ -33,7 +33,7 @@ struct UVPrimitivePaintInput { * delta_barycentric_coord_u is initialized in a later stage as it requires image tile * dimensions. */ - UVPrimitivePaintInput(int64_t tri_index) + UVPrimitivePaintInput(int tri_index) : tri_index(tri_index), delta_barycentric_coord_u(0.0f, 0.0f) { } diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 13cf65623e0..591aad1baf4 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -361,8 +361,8 @@ constexpr bool USE_WATERTIGHT_CHECK = false; static void extract_barycentric_pixels(UDIMTilePixels &tile_data, const ImBuf *image_buffer, const uv_islands::UVIslandsMask &uv_mask, - const int64_t uv_island_index, - const int64_t uv_primitive_index, + const int uv_island_index, + const int uv_primitive_index, const float2 uvs[3], const float2 tile_offset, const int minx, @@ -494,7 +494,7 @@ static void do_encode_pixels(EncodePixelsUserData *data, const int n) const int maxx = min_ii(ceil(maxu * image_buffer->x), image_buffer->x); /* TODO: Perform bounds check */ - int64_t uv_prim_index = node_data->uv_primitives.size(); + int uv_prim_index = node_data->uv_primitives.size(); node_data->uv_primitives.append(geom_prim_index); UVPrimitivePaintInput &paint_input = node_data->uv_primitives.last(); @@ -544,9 +544,9 @@ static bool should_pixels_be_updated(const Node &node) return true; } -static int64_t count_nodes_to_update(Tree &pbvh) +static int count_nodes_to_update(Tree &pbvh) { - int64_t result = 0; + int result = 0; for (Node &node : pbvh.nodes_) { if (should_pixels_be_updated(node)) { result++; @@ -566,7 +566,7 @@ static int64_t count_nodes_to_update(Tree &pbvh) */ static bool find_nodes_to_update(Tree &pbvh, Vector &r_nodes_to_update) { - int64_t nodes_to_update_len = count_nodes_to_update(pbvh); + int nodes_to_update_len = count_nodes_to_update(pbvh); if (nodes_to_update_len == 0) { return false; } @@ -729,8 +729,8 @@ static bool update_pixels(Tree &pbvh, Mesh *mesh, Image *image, ImageUser *image #ifdef DO_PRINT_STATISTICS /* Print some statistics about compression ratio. */ { - int64_t compressed_data_len = 0; - int64_t num_pixels = 0; + int compressed_data_len = 0; + int num_pixels = 0; for (int n = 0; n < pbvh->totnode; n++) { Node *node = &pbvh->nodes[n]; if ((node->flag & PBVH_Leaf) == 0) {