add exclude-texture-scale

This commit is contained in:
David Rose 2007-05-09 01:53:30 +00:00
parent 9a23134a7e
commit bff3d9ae76
3 changed files with 26 additions and 3 deletions

View File

@ -82,6 +82,14 @@ ConfigVariableDouble texture_scale
"scale factor is applied before textures-power-2 or "
"max-texture-dimension."));
ConfigVariableList exclude_texture_scale
("exclude-texture-scale",
PRC_DESC("This is a list of glob patterns for texture filenames "
"(excluding the directory part of the filename, but including "
"the extension); for instance, 'digits_*.png'. Any texture "
"filenames that match one of these patterns will not be affected "
"by max-texture-dimension or texture-scale."));
ConfigVariableBool keep_texture_ram
("keep-texture-ram", false,
PRC_DESC("Set this to true to retain the ram image for each texture after it "

View File

@ -39,6 +39,9 @@ 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 ConfigVariableList exclude_texture_scale;
extern EXPCL_PANDA ConfigVariableBool keep_texture_ram;
extern EXPCL_PANDA ConfigVariableBool preload_textures;
extern EXPCL_PANDA ConfigVariableBool compressed_textures;

View File

@ -2830,11 +2830,23 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) {
////////////////////////////////////////////////////////////////////
void Texture::
consider_rescale(PNMImage &pnmimage, const string &name) {
string basename = _filename.get_basename();
bool exclude = false;
int num_excludes = exclude_texture_scale.get_num_unique_values();
for (int i = 0; i < num_excludes && !exclude; ++i) {
GlobPattern pat(exclude_texture_scale.get_unique_value(i));
if (pat.matches(basename)) {
exclude = true;
}
}
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);
if (!exclude) {
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:
@ -2864,7 +2876,7 @@ consider_rescale(PNMImage &pnmimage, const string &name) {
break;
}
if (max_texture_dimension > 0) {
if (max_texture_dimension > 0 && !exclude) {
new_x_size = min(new_x_size, (int)max_texture_dimension);
new_y_size = min(new_y_size, (int)max_texture_dimension);
}