mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 11:28:17 -04:00
Problem with not knowing size on old textures
This commit is contained in:
parent
f27f662b82
commit
c68fd64442
@ -21,6 +21,7 @@
|
|||||||
#include "texturePlacement.h"
|
#include "texturePlacement.h"
|
||||||
#include "textureImage.h"
|
#include "textureImage.h"
|
||||||
#include "palettizer.h"
|
#include "palettizer.h"
|
||||||
|
#include "paletteImage.h"
|
||||||
|
|
||||||
#include <indent.h>
|
#include <indent.h>
|
||||||
#include <datagram.h>
|
#include <datagram.h>
|
||||||
@ -430,6 +431,7 @@ place_all() {
|
|||||||
Placements::iterator pli;
|
Placements::iterator pli;
|
||||||
for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
|
for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
|
||||||
TexturePlacement *placement = (*pli);
|
TexturePlacement *placement = (*pli);
|
||||||
|
|
||||||
if (placement->get_omit_reason() == OR_working) {
|
if (placement->get_omit_reason() == OR_working) {
|
||||||
PalettePage *page = get_page(placement->get_properties());
|
PalettePage *page = get_page(placement->get_properties());
|
||||||
page->assign(placement);
|
page->assign(placement);
|
||||||
@ -444,6 +446,36 @@ place_all() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PaletteGroup::update_unknown_textures
|
||||||
|
// Access: Public
|
||||||
|
// Description: Checks for new information on any textures within the
|
||||||
|
// group for which some of the saved information is
|
||||||
|
// incomplete. This may be necessary before we can
|
||||||
|
// properly place all of the textures.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PaletteGroup::
|
||||||
|
update_unknown_textures(const TxaFile &txa_file) {
|
||||||
|
Placements::iterator pli;
|
||||||
|
for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
|
||||||
|
TexturePlacement *placement = (*pli);
|
||||||
|
|
||||||
|
if (!placement->is_size_known()) {
|
||||||
|
// This texture's size isn't known; we have to determine its
|
||||||
|
// size.
|
||||||
|
TextureImage *texture = placement->get_texture();
|
||||||
|
if (!texture->got_txa_file()) {
|
||||||
|
// But first, we need to look up the texture in the .txa file.
|
||||||
|
texture->pre_txa_file();
|
||||||
|
txa_file.match_texture(texture);
|
||||||
|
texture->post_txa_file();
|
||||||
|
}
|
||||||
|
|
||||||
|
placement->determine_size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PaletteGroup::write_image_info
|
// Function: PaletteGroup::write_image_info
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -34,6 +34,7 @@ class EggFile;
|
|||||||
class TexturePlacement;
|
class TexturePlacement;
|
||||||
class PalettePage;
|
class PalettePage;
|
||||||
class TextureImage;
|
class TextureImage;
|
||||||
|
class TxaFile;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : PaletteGroup
|
// Class : PaletteGroup
|
||||||
@ -80,6 +81,7 @@ public:
|
|||||||
void unplace(TexturePlacement *placement);
|
void unplace(TexturePlacement *placement);
|
||||||
|
|
||||||
void place_all();
|
void place_all();
|
||||||
|
void update_unknown_textures(const TxaFile &txa_file);
|
||||||
|
|
||||||
void write_image_info(ostream &out, int indent_level = 0) const;
|
void write_image_info(ostream &out, int indent_level = 0) const;
|
||||||
void optimal_resize();
|
void optimal_resize();
|
||||||
|
@ -293,6 +293,8 @@ count_coverage() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool PaletteImage::
|
bool PaletteImage::
|
||||||
place(TexturePlacement *placement) {
|
place(TexturePlacement *placement) {
|
||||||
|
nassertr(placement->is_size_known(), true);
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
if (find_hole(x, y, placement->get_x_size(), placement->get_y_size())) {
|
if (find_hole(x, y, placement->get_x_size(), placement->get_y_size())) {
|
||||||
placement->place_at(this, x, y);
|
placement->place_at(this, x, y);
|
||||||
|
@ -104,7 +104,8 @@ place_all() {
|
|||||||
|
|
||||||
Assigned::const_iterator ai;
|
Assigned::const_iterator ai;
|
||||||
for (ai = _assigned.begin(); ai != _assigned.end(); ++ai) {
|
for (ai = _assigned.begin(); ai != _assigned.end(); ++ai) {
|
||||||
place(*ai);
|
TexturePlacement *placement = (*ai);
|
||||||
|
place(placement);
|
||||||
}
|
}
|
||||||
|
|
||||||
_assigned.clear();
|
_assigned.clear();
|
||||||
|
@ -206,10 +206,9 @@ report_pi() const {
|
|||||||
if (si != sorted_groups.begin()) {
|
if (si != sorted_groups.begin()) {
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
}
|
}
|
||||||
cout << " " << group->get_name() << " ("
|
cout << " " << group->get_name()
|
||||||
<< group->get_dirname_order() << ","
|
// << " (" << group->get_dirname_order() << "," << group->get_dependency_order() << ")"
|
||||||
<< group->get_dependency_order() << "): "
|
<< ": " << group->get_groups() << "\n";
|
||||||
<< group->get_groups() << "\n";
|
|
||||||
group->write_image_info(cout, 4);
|
group->write_image_info(cout, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,6 +454,7 @@ process_command_line_eggs(bool force_texture_read) {
|
|||||||
Groups::iterator gi;
|
Groups::iterator gi;
|
||||||
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
||||||
PaletteGroup *group = (*gi).second;
|
PaletteGroup *group = (*gi).second;
|
||||||
|
group->update_unknown_textures(_txa_file);
|
||||||
group->place_all();
|
group->place_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,6 +539,7 @@ process_all(bool force_texture_read) {
|
|||||||
Groups::iterator gi;
|
Groups::iterator gi;
|
||||||
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
|
||||||
PaletteGroup *group = (*gi).second;
|
PaletteGroup *group = (*gi).second;
|
||||||
|
group->update_unknown_textures(_txa_file);
|
||||||
group->place_all();
|
group->place_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ TextureImage() {
|
|||||||
_ever_read_image = false;
|
_ever_read_image = false;
|
||||||
_forced_grayscale = false;
|
_forced_grayscale = false;
|
||||||
_forced_unalpha = false;
|
_forced_unalpha = false;
|
||||||
|
_got_txa_file = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -260,6 +261,8 @@ pre_txa_file() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void TextureImage::
|
void TextureImage::
|
||||||
post_txa_file() {
|
post_txa_file() {
|
||||||
|
_got_txa_file = true;
|
||||||
|
|
||||||
// First, get the actual size of the texture.
|
// First, get the actual size of the texture.
|
||||||
SourceTextureImage *source = get_preferred_source();
|
SourceTextureImage *source = get_preferred_source();
|
||||||
if (source != (SourceTextureImage *)NULL) {
|
if (source != (SourceTextureImage *)NULL) {
|
||||||
@ -323,6 +326,17 @@ post_txa_file() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextureImage::got_txa_file
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if this TextureImage has been looked up
|
||||||
|
// in the .txa file this session, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TextureImage::
|
||||||
|
got_txa_file() const {
|
||||||
|
return _got_txa_file;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextureImage::determine_placement_size
|
// Function: TextureImage::determine_placement_size
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
|
|
||||||
void pre_txa_file();
|
void pre_txa_file();
|
||||||
void post_txa_file();
|
void post_txa_file();
|
||||||
|
bool got_txa_file() const;
|
||||||
void determine_placement_size();
|
void determine_placement_size();
|
||||||
|
|
||||||
bool get_omit() const;
|
bool get_omit() const;
|
||||||
@ -127,6 +128,7 @@ private:
|
|||||||
|
|
||||||
bool _read_source_image;
|
bool _read_source_image;
|
||||||
PNMImage _source_image;
|
PNMImage _source_image;
|
||||||
|
bool _got_txa_file;
|
||||||
|
|
||||||
|
|
||||||
// The TypedWritable interface follows.
|
// The TypedWritable interface follows.
|
||||||
|
@ -379,6 +379,21 @@ determine_size() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePlacement::is_size_known
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if the texture's size is known, false
|
||||||
|
// otherwise. Usually this can only be false after
|
||||||
|
// determine_size() has been called there is something
|
||||||
|
// wrong with the texture (in which case the placement
|
||||||
|
// will automatically omit itself from the palette
|
||||||
|
// anyway).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TexturePlacement::
|
||||||
|
is_size_known() const {
|
||||||
|
return _size_known;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePlacement::get_omit_reason
|
// Function: TexturePlacement::get_omit_reason
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -66,6 +66,7 @@ public:
|
|||||||
DestTextureImage *get_dest() const;
|
DestTextureImage *get_dest() const;
|
||||||
|
|
||||||
bool determine_size();
|
bool determine_size();
|
||||||
|
bool is_size_known() const;
|
||||||
OmitReason get_omit_reason() const;
|
OmitReason get_omit_reason() const;
|
||||||
int get_x_size() const;
|
int get_x_size() const;
|
||||||
int get_y_size() const;
|
int get_y_size() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user