From 844591b17cb7f8a11ad8a04825705308b1d2c98a Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 29 Aug 2008 17:33:15 +0000 Subject: [PATCH] set_orig_file_size --- panda/src/gobj/texture.cxx | 63 ++++++++++++++++++++++++-------------- panda/src/gobj/texture.h | 2 ++ 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 318be8ab19..563d178302 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -2263,6 +2263,46 @@ write(ostream &out, int indent_level) const { } } + +//////////////////////////////////////////////////////////////////// +// Function: Texture::set_size_padded +// Access: Published +// Description: Changes the size of the texture, padding +// if necessary, and setting the pad region +// as well. +//////////////////////////////////////////////////////////////////// +void Texture:: +set_size_padded(int x, int y, int z) { + ReMutexHolder holder(_lock); + if (get_textures_power_2() != ATS_none) { + set_x_size(up_to_power_2(x)); + set_y_size(up_to_power_2(y)); + set_z_size(up_to_power_2(z)); + } else { + set_x_size(x); + set_y_size(y); + set_z_size(z); + } + set_pad_size(get_x_size() - x, + get_y_size() - y, + get_z_size() - z); +} + +//////////////////////////////////////////////////////////////////// +// Function: Texture::set_orig_file_size +// Access: Published +// Description: Specifies the size of the texture as it exists in its +// original disk file, before any Panda scaling. +//////////////////////////////////////////////////////////////////// +void Texture:: +set_orig_file_size(int x, int y, int z) { + ReMutexHolder holder(_lock); + _orig_file_x_size = x; + _orig_file_y_size = y; + + nassertv(z == _z_size); +} + //////////////////////////////////////////////////////////////////// // Function: Texture::set_format // Access: Published @@ -4290,29 +4330,6 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { } } - -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_size_padded -// Description: Changes the size of the texture, padding -// if necessary, and setting the pad region -// as well. -//////////////////////////////////////////////////////////////////// -void Texture:: -set_size_padded(int x, int y, int z) { - if (get_textures_power_2() != ATS_none) { - set_x_size(up_to_power_2(x)); - set_y_size(up_to_power_2(y)); - set_z_size(up_to_power_2(z)); - } else { - set_x_size(x); - set_y_size(y); - set_z_size(z); - } - set_pad_size(get_x_size() - x, - get_y_size() - y, - get_z_size() - z); -} - //////////////////////////////////////////////////////////////////// // Function: Texture::consider_rescale // Access: Private diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index ac69e1fe30..e7c25c15e5 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -389,6 +389,8 @@ PUBLISHED: INLINE int get_orig_file_x_size() const; INLINE int get_orig_file_y_size() const; INLINE int get_orig_file_z_size() const; + + void set_orig_file_size(int x, int y, int z = 1); void set_format(Format format); void set_component_type(ComponentType component_type);