Commit: f7a1433ffbf1db4481fb187df52e19c16615f910 Author: Jeroen Bakker Date: Fri Jan 13 15:09:15 2023 +0100 Branches: temp-T101739-fix-seam-bleeding-non-manifold https://developer.blender.org/rBf7a1433ffbf1db4481fb187df52e19c16615f910
Add support for byte textures. =================================================================== M source/blender/blenkernel/BKE_pbvh_pixels.hh =================================================================== diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh index 3defa5fcbab..90cade4efa7 100644 --- a/source/blender/blenkernel/BKE_pbvh_pixels.hh +++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh @@ -258,7 +258,8 @@ struct NodeData { /** \name Fix non-manifold edge bleeding. * \{ */ -/** TODO: move to image wrappers? */ +// TODO: move to image wrappers? +// TODO: Add compile time checks. template<typename T, int Channels = 4> struct ImageBufferAccessor { ImBuf &image_buffer; @@ -268,14 +269,31 @@ template<typename T, int Channels = 4> struct ImageBufferAccessor { float4 read_pixel(const int2 coordinate) { - int offset = (coordinate.y * image_buffer.x + coordinate.x) * Channels; - return float4(&image_buffer.rect_float[offset]); + if constexpr ((std::is_same_v<T, float>)) { + int offset = (coordinate.y * image_buffer.x + coordinate.x) * Channels; + return float4(&image_buffer.rect_float[offset]); + } + if constexpr ((std::is_same_v<T, int>)) { + int offset = (coordinate.y * image_buffer.x + coordinate.x); + float4 result; + rgba_uchar_to_float(result, + static_cast<uchar *>(static_cast<void *>(&image_buffer.rect[offset]))); + return result; + } + return float4(); } void write_pixel(const int2 coordinate, float4 new_value) { - int offset = (coordinate.y * image_buffer.x + coordinate.x) * Channels; - copy_v4_v4(&image_buffer.rect_float[offset], new_value); + if constexpr ((std::is_same_v<T, float>)) { + int offset = (coordinate.y * image_buffer.x + coordinate.x) * Channels; + copy_v4_v4(&image_buffer.rect_float[offset], new_value); + } + if constexpr ((std::is_same_v<T, int>)) { + int offset = (coordinate.y * image_buffer.x + coordinate.x); + rgba_float_to_uchar(static_cast<uchar *>(static_cast<void *>(&image_buffer.rect[offset])), + new_value); + } } }; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs