This represents a single egg file known to the palettizer. More...
#include "eggFile.h"
Public Member Functions | |
void | apply_properties_to_source () |
Calls apply_properties_to_source() for each texture reference, updating all the referenced source textures with the complete set of property information from this egg file. More... | |
void | build_cross_links () |
Calls TextureImage::note_egg_file() and SourceTextureImage::increment_egg_count() for each texture the egg file references, and PaletteGroup::increment_egg_count() for each palette group it wants. More... | |
void | choose_placements () |
Once all the textures have been assigned to groups (but before they may actually be placed), chooses a suitable TexturePlacement for each texture that appears in the egg file. More... | |
void | clear_surprise () |
Removes the 'surprise' flag; this file has been successfully matched against a line in the .txa file. More... | |
virtual int | complete_pointers (TypedWritable **p_list, BamReader *manager) |
Called after the object is otherwise completely read from a Bam file, this function's job is to store the pointers that were retrieved from the Bam file for each pointer object written. More... | |
bool | from_command_line (EggData *data, const Filename &source_filename, const Filename &dest_filename, const std::string &egg_comment) |
Accepts the information about the egg file as supplied from the command line. More... | |
const PaletteGroups & | get_complete_groups () const |
Returns the complete set of PaletteGroups that the egg file is assigned to. More... | |
PaletteGroup * | get_default_group () const |
Returns the PaletteGroup that was specified as the default group on the command line at the time the egg file last appeared on the command line. More... | |
const PaletteGroups & | get_explicit_groups () const |
Returns the set of PaletteGroups that the egg file has been explicitly assigned to in the .txa file. More... | |
const Filename & | get_source_filename () const |
Returns the filename this egg file was read from. More... | |
void | get_textures (pset< TextureImage * > &result) const |
Fills up the indicated set with the set of textures referenced by this egg file. More... | |
virtual TypeHandle | get_type () const |
bool | had_data () const |
Returns true if the EggData for this EggFile has ever been loaded in this session. More... | |
bool | has_data () const |
Returns true if the EggData for this EggFile has been loaded, and not yet released. More... | |
bool | is_stale () const |
Returns true if the egg file needs to be updated, i.e. More... | |
bool | is_surprise () const |
Returns true if this particular egg file is a 'surprise', i.e. More... | |
void | mark_stale () |
Marks this particular egg file as stale, meaning that something has changed, such as the location of a texture within its palette, which causes the egg file to need to be regenerated. More... | |
void | match_txa_groups (const PaletteGroups &groups) |
Adds the indicated set of groups, read from the .txa file, to the set of groups to which the egg file is assigned. More... | |
void | post_txa_file () |
Once the egg file has been matched against all of the matching lines the .txa file, do whatever adjustment is necessary. More... | |
void | pre_txa_file () |
Does some processing prior to scanning the .txa file. More... | |
bool | read_egg (bool noabs) |
Reads in the egg file from its _source_filename. More... | |
void | release_egg_data () |
Releases the memory that was loaded by a previous call to read_egg(). More... | |
void | remove_egg () |
Removes this egg file from all things that reference it, in preparation for removing it from the database. More... | |
void | scan_textures () |
Scans the egg file for texture references and updates the _textures list appropriately. More... | |
void | update_egg () |
Once all textures have been placed appropriately, updates the egg file with all the information to reference the new textures. More... | |
virtual void | write_datagram (BamWriter *writer, Datagram &datagram) |
Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file. More... | |
void | write_description (std::ostream &out, int indent_level=0) const |
Writes a one-line description of the egg file and its group assignments to the indicated output stream. More... | |
bool | write_egg () |
Writes out the egg file to its _dest_filename. More... | |
void | write_texture_refs (std::ostream &out, int indent_level=0) const |
Writes the list of texture references to the indicated output stream, one per line. More... | |
Public Member Functions inherited from TypedWritable | |
TypedWritable (const TypedWritable ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More... | |
vector_uchar | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More... | |
bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More... | |
virtual void | finalize (BamReader *manager) |
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More... | |
virtual TypeHandle | force_init_type () |
UpdateSeq | get_bam_modified () const |
Returns the current bam_modified counter. More... | |
void | mark_bam_modified () |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More... | |
void | operator= (const TypedWritable ©) |
virtual bool | require_fully_complete () const |
Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More... | |
virtual void | update_bam_nested (BamWriter *manager) |
Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More... | |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from Namable | |
Namable (const std::string &initial_name="") | |
void | clear_name () |
Resets the Namable's name to empty. More... | |
const std::string & | get_name () const |
bool | has_name () const |
Returns true if the Namable has a nonempty name set, false if the name is empty. More... | |
void | output (std::ostream &out) const |
Outputs the Namable. More... | |
void | set_name (const std::string &name) |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Registers the current object as something that can be read from a Bam file. More... | |
Static Public Member Functions inherited from TypedWritable | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr) |
Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
Static Public Member Functions inherited from Namable | |
static TypeHandle | get_class_type () |
static void | init_type () |
Additional Inherited Members | |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from Namable | |
get_name | |
set_name | |
Static Public Attributes inherited from TypedWritable | |
static TypedWritable *const | Null = nullptr |
This represents a single egg file known to the palettizer.
It may reference a number of textures, and may also be assigned to a number of groups. All of its textures will try to assign themselves to one of its groups.
void EggFile::apply_properties_to_source | ( | ) |
Calls apply_properties_to_source() for each texture reference, updating all the referenced source textures with the complete set of property information from this egg file.
Definition at line 364 of file eggFile.cxx.
References TextureReference::apply_properties_to_source().
void EggFile::build_cross_links | ( | ) |
Calls TextureImage::note_egg_file() and SourceTextureImage::increment_egg_count() for each texture the egg file references, and PaletteGroup::increment_egg_count() for each palette group it wants.
This sets up some of the back references to support determining an ideal texture assignment.
Definition at line 325 of file eggFile.cxx.
References PaletteGroups::clear(), PaletteGroups::empty(), TextureReference::get_texture(), PaletteGroups::insert(), and PaletteGroups::make_complete().
void EggFile::choose_placements | ( | ) |
Once all the textures have been assigned to groups (but before they may actually be placed), chooses a suitable TexturePlacement for each texture that appears in the egg file.
This will be necessary to do at some point before writing out the egg file anyway, and doing it before the textures are placed allows us to decide what the necessary UV range is for each to- be-placed texture.
Definition at line 381 of file eggFile.cxx.
References PaletteGroups::begin(), PaletteGroups::count(), PaletteGroups::empty(), get_complete_groups(), TexturePlacement::get_group(), TextureImage::get_groups(), TextureImage::get_placement(), TextureReference::get_placement(), TextureReference::get_texture(), and PaletteGroups::make_intersection().
void EggFile::clear_surprise | ( | ) |
Removes the 'surprise' flag; this file has been successfully matched against a line in the .txa file.
Definition at line 285 of file eggFile.cxx.
|
virtual |
Called after the object is otherwise completely read from a Bam file, this function's job is to store the pointers that were retrieved from the Bam file for each pointer object written.
The return value is the number of pointers processed from the list.
Reimplemented from TypedWritable.
Definition at line 740 of file eggFile.cxx.
bool EggFile::from_command_line | ( | EggData * | data, |
const Filename & | source_filename, | ||
const Filename & | dest_filename, | ||
const std::string & | egg_comment | ||
) |
Accepts the information about the egg file as supplied from the command line.
Returns true if the egg file is valid, false otherwise.
Definition at line 57 of file eggFile.cxx.
const PaletteGroups & EggFile::get_complete_groups | ( | ) | const |
Returns the complete set of PaletteGroups that the egg file is assigned to.
This is the set of all the groups it is explicitly assigned to, plus all the groups that these groups depend on.
Definition at line 276 of file eggFile.cxx.
Referenced by choose_placements().
PaletteGroup * EggFile::get_default_group | ( | ) | const |
Returns the PaletteGroup that was specified as the default group on the command line at the time the egg file last appeared on the command line.
Definition at line 266 of file eggFile.cxx.
const PaletteGroups & EggFile::get_explicit_groups | ( | ) | const |
Returns the set of PaletteGroups that the egg file has been explicitly assigned to in the .txa file.
Definition at line 257 of file eggFile.cxx.
const Filename & EggFile::get_source_filename | ( | ) | const |
Returns the filename this egg file was read from.
Definition at line 91 of file eggFile.cxx.
void EggFile::get_textures | ( | pset< TextureImage * > & | result | ) | const |
Fills up the indicated set with the set of textures referenced by this egg file.
It is the user's responsibility to ensure the set is empty before making this call; otherwise, the new textures will be appended to the existing set.
Definition at line 210 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
bool EggFile::had_data | ( | ) | const |
Returns true if the EggData for this EggFile has ever been loaded in this session.
Definition at line 438 of file eggFile.cxx.
bool EggFile::has_data | ( | ) | const |
Returns true if the EggData for this EggFile has been loaded, and not yet released.
Definition at line 429 of file eggFile.cxx.
bool EggFile::is_stale | ( | ) | const |
Returns true if the egg file needs to be updated, i.e.
some palettizations have changed affecting it, or false otherwise.
Definition at line 313 of file eggFile.cxx.
Referenced by write_description().
bool EggFile::is_surprise | ( | ) | const |
Returns true if this particular egg file is a 'surprise', i.e.
it wasn't matched by a line in the .txa file that didn't include the keyword 'cont'.
Definition at line 294 of file eggFile.cxx.
Referenced by Palettizer::report_pi().
void EggFile::mark_stale | ( | ) |
Marks this particular egg file as stale, meaning that something has changed, such as the location of a texture within its palette, which causes the egg file to need to be regenerated.
Definition at line 304 of file eggFile.cxx.
Referenced by TextureReference::mark_egg_stale().
void EggFile::match_txa_groups | ( | const PaletteGroups & | groups | ) |
Adds the indicated set of groups, read from the .txa file, to the set of groups to which the egg file is assigned.
Definition at line 231 of file eggFile.cxx.
References PaletteGroups::clear(), and PaletteGroups::make_union().
void EggFile::post_txa_file | ( | ) |
Once the egg file has been matched against all of the matching lines the .txa file, do whatever adjustment is necessary.
Definition at line 249 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
void EggFile::pre_txa_file | ( | ) |
Does some processing prior to scanning the .txa file.
Definition at line 221 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
bool EggFile::read_egg | ( | bool | noabs | ) |
Reads in the egg file from its _source_filename.
It is only valid to call this if it has not already been read in, e.g. from the command line. Returns true if successful, false if there is an error.
This may also be called after a previous call to release_egg_data(), in order to re-read the same egg file.
Definition at line 480 of file eggFile.cxx.
|
static |
Registers the current object as something that can be read from a Bam file.
Definition at line 697 of file eggFile.cxx.
References BamReader::get_factory().
Referenced by init_palettizer().
void EggFile::release_egg_data | ( | ) |
Releases the memory that was loaded by a previous call to read_egg().
Definition at line 553 of file eggFile.cxx.
References TextureReference::release_egg_data().
void EggFile::remove_egg | ( | ) |
Removes this egg file from all things that reference it, in preparation for removing it from the database.
Definition at line 462 of file eggFile.cxx.
References TextureReference::get_placement(), and TexturePlacement::remove_egg().
Referenced by Palettizer::remove_egg_file().
void EggFile::scan_textures | ( | ) |
Scans the egg file for texture references and updates the _textures list appropriately.
This assumes the egg file was supplied on the command line and thus the _data member is available.
Definition at line 102 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
void EggFile::update_egg | ( | ) |
Once all textures have been placed appropriately, updates the egg file with all the information to reference the new textures.
Definition at line 447 of file eggFile.cxx.
Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.
Reimplemented from TypedWritable.
Definition at line 707 of file eggFile.cxx.
References Datagram::add_bool(), Datagram::add_string(), Datagram::add_uint32(), FilenameUnifier::make_bam_filename(), TypedWritable::write_datagram(), PaletteGroups::write_datagram(), and BamWriter::write_pointer().
void EggFile::write_description | ( | std::ostream & | out, |
int | indent_level = 0 |
||
) | const |
Writes a one-line description of the egg file and its group assignments to the indicated output stream.
Definition at line 591 of file eggFile.cxx.
References PaletteGroups::empty(), indent(), and is_stale().
Referenced by Palettizer::report_pi().
bool EggFile::write_egg | ( | ) |
Writes out the egg file to its _dest_filename.
Returns true if successful, false if there is an error.
Definition at line 569 of file eggFile.cxx.
void EggFile::write_texture_refs | ( | std::ostream & | out, |
int | indent_level = 0 |
||
) | const |
Writes the list of texture references to the indicated output stream, one per line.
Definition at line 612 of file eggFile.cxx.
Referenced by Palettizer::report_pi().