diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index e437f20743..b8307c8f95 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -74,6 +74,14 @@ ConfigVariableInt max_texture_dimension "loaded from a file) will be automatically scaled down, if " "necessary, so that neither dimension is larger than this value.")); +ConfigVariableDouble texture_scale +("texture-scale", 1.0, + PRC_DESC("This is a global scale factor that is applied to each texture " + "as it is loaded from disk. For instance, a value of 0.5 will " + "reduce each texture to one-half its size in each dimension. This " + "scale factor is applied before textures-power-2 or " + "max-texture-dimension.")); + ConfigVariableBool keep_texture_ram ("keep-texture-ram", false, PRC_DESC("Set this to true to retain the ram image for each texture after it " diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index 0de4b81c12..9dadb68f43 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -38,6 +38,7 @@ EXPCL_PANDA istream &operator >> (istream &in, AutoTextureScale &ats); // Configure variables for gobj package. extern EXPCL_PANDA ConfigVariableInt max_texture_dimension; +extern EXPCL_PANDA ConfigVariableDouble texture_scale; extern EXPCL_PANDA ConfigVariableBool keep_texture_ram; extern EXPCL_PANDA ConfigVariableBool preload_textures; extern EXPCL_PANDA ConfigVariableBool compressed_textures; diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 7b6a9a306d..7672b3ce40 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1873,9 +1873,6 @@ unclean_set_num_rows(int n) { bool any_changed = false; - int color_array = -1; - int orig_color_rows = -1; - for (size_t i = 0; i < _cdata->_arrays.size(); i++) { if (_array_writers[i]->get_num_rows() != n) { // Copy-on-write. diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index f084a3b2db..dc59d7d939 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -37,6 +37,7 @@ #include "bam.h" #include "zStream.h" #include "indent.h" +#include "cmath.h" #include @@ -2816,6 +2817,9 @@ consider_rescale(PNMImage &pnmimage, const string &name) { int new_x_size = pnmimage.get_x_size(); int new_y_size = pnmimage.get_y_size(); + new_x_size = (int)cfloor(new_x_size * texture_scale + 0.5); + new_y_size = (int)cfloor(new_y_size * texture_scale + 0.5); + switch (textures_power_2) { case ATS_down: new_x_size = down_to_power_2(new_x_size);