Panda3D
Public Member Functions | Static Public Member Functions | Friends | List of all members
PaletteGroup Class Reference

This is the highest level of grouping for TextureImages. More...

#include "paletteGroup.h"

Inheritance diagram for PaletteGroup:
TypedWritable Namable TypedObject MemoryBase MemoryBase

Public Member Functions

void add_texture_swap_info (const std::string sourceTextureName, const vector_string &swapTextures)
 Store textureswap information from textures.txa. More...
 
void clear_depends ()
 Eliminates all the dependency information for this group. 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...
 
virtual void finalize (BamReader *manager)
 This method is called by the BamReader after all pointers everywhere in the world have been completely read in. More...
 
void get_complete_placements (pvector< TexturePlacement * > &placements) const
 Adds the set of TexturePlacements associated with this group and all dependent groups to the indicated vector. More...
 
int get_dependency_level () const
 Returns the dependency level of this group. More...
 
int get_dependency_order () const
 Returns the dependency order of this group. More...
 
const std::string & get_dirname () const
 Returns the directory name associated with the palette group. More...
 
int get_dirname_order () const
 Returns the dependency order of this group. More...
 
int get_egg_count () const
 Returns the number of egg files that share this PaletteGroup. More...
 
const PaletteGroupsget_groups () const
 Returns the set of groups this group depends on. More...
 
int get_margin_override () const
 Returns the set of groups this group depends on. More...
 
PalettePageget_page (const TextureProperties &properties)
 Returns the page associated with the indicated properties. More...
 
void get_placements (pvector< TexturePlacement * > &placements) const
 Adds the set of TexturePlacements associated with this group to the indicated vector. More...
 
virtual TypeHandle get_type () const
 
void group_with (PaletteGroup *other)
 Indicates a dependency of this group on some other group. More...
 
bool has_dirname () const
 Returns true if the directory name has been explicitly set for this group. More...
 
bool has_margin_override () const
 Returns the set of groups this group depends on. More...
 
void increment_egg_count ()
 Increments by one the number of egg files that are known to reference this PaletteGroup. More...
 
bool is_none_texture_swap () const
 Returns textureswap information is set or not, True if it's not set. More...
 
bool is_preferred_over (const PaletteGroup &other) const
 Returns true if this group should be preferred for adding textures over the other group, if both are available. More...
 
void optimal_resize ()
 Attempts to resize each PalettteImage down to its smallest possible size. More...
 
void place_all ()
 Once all the textures have been assigned to this group, try to place them all onto suitable PaletteImages. More...
 
TexturePlacementprepare (TextureImage *texture)
 Marks the indicated Texture as ready for placing somewhere within this group, and returns a placeholder TexturePlacement object. More...
 
void reset_dependency_level ()
 Unconditionally sets the dependency level and order of this group to zero, in preparation for a later call to set_dependency_level(). More...
 
void reset_images ()
 Throws away all of the current PaletteImages, so that new ones may be created (and the packing made more optimal). More...
 
void set_dependency_level (int level)
 Sets the dependency level of this group to the indicated level, provided that level is not lower than the level that was set previously. More...
 
bool set_dependency_order ()
 Updates the dependency order of this group. More...
 
void set_dirname (const std::string &dirname)
 Sets the directory name associated with the palette group. More...
 
void set_margin_override (const int override)
 Returns the set of groups this group depends on. More...
 
void setup_shadow_images ()
 Ensures that each PaletteImage's _shadow_image has the correct filename and image types, based on what was supplied on the command line and in the .txa file. More...
 
void unplace (TexturePlacement *placement)
 Removes the texture from its position on a PaletteImage, if it has been so placed. More...
 
void update_images (bool redo_all)
 Regenerates each PaletteImage on this group that needs it. More...
 
void update_unknown_textures (const TxaFile &txa_file)
 Checks for new information on any textures within the group for which some of the saved information is incomplete. 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_image_info (std::ostream &out, int indent_level=0) const
 Writes a list of the PaletteImages associated with this group, and all of their textures, to the indicated output stream. More...
 
- Public Member Functions inherited from TypedWritable
 TypedWritable (const TypedWritable &copy)
 
virtual ReferenceCountas_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 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 &copy)
 
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 &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_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...
 
TypedObjectoperator= (const TypedObject &copy)=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 ()
 

Friends

class PaletteGroups
 

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
 

Detailed Description

This is the highest level of grouping for TextureImages.

Textures are assigned to one or several PaletteGroups based on the information in the .txa file; each PaletteGroup is conceptually a collection of textures that are to be moved around (into texture memory, downloaded, etc.) in one big chunk. It is the set of all textures that may be displayed together at any given time.

Definition at line 43 of file paletteGroup.h.

Member Function Documentation

◆ add_texture_swap_info()

void PaletteGroup::add_texture_swap_info ( const std::string  sourceTextureName,
const vector_string &  swapTextures 
)

Store textureswap information from textures.txa.

Definition at line 699 of file paletteGroup.cxx.

◆ clear_depends()

void PaletteGroup::clear_depends ( )

Eliminates all the dependency information for this group.

Definition at line 79 of file paletteGroup.cxx.

References PaletteGroups::clear().

Referenced by Palettizer::read_txa_file().

◆ complete_pointers()

int PaletteGroup::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
)
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 604 of file paletteGroup.cxx.

◆ finalize()

void PaletteGroup::finalize ( BamReader manager)
virtual

This method is called by the BamReader after all pointers everywhere in the world have been completely read in.

It's a hook at which the object can do whatever final setup it requires that depends on other pointers being valid.

Reimplemented from TypedWritable.

Definition at line 638 of file paletteGroup.cxx.

◆ get_complete_placements()

void PaletteGroup::get_complete_placements ( pvector< TexturePlacement * > &  placements) const

Adds the set of TexturePlacements associated with this group and all dependent groups to the indicated vector.

See get_placements().

Definition at line 150 of file paletteGroup.cxx.

References PaletteGroups::begin(), PaletteGroups::end(), get_placements(), and PaletteGroups::make_complete().

Referenced by Palettizer::report_statistics().

◆ get_dependency_level()

int PaletteGroup::get_dependency_level ( ) const

Returns the dependency level of this group.

This is a measure of how specific the group is; the lower the dependency level, the more specific the group.

Groups depend on other groups in a hierarchical relationship. In general, if group a depends on group b, then b->get_dependency_level() > a->get_dependency_level().

Thus, groups that lots of other groups depend on have a higher dependency level; groups that no one else depends on have a low dependency level. This is important when deciding which groups are best suited for assigning a texture to; in general, the texture should be assigned to the most specific suitable group (i.e. the one with the lowest dependency level).

Definition at line 253 of file paletteGroup.cxx.

◆ get_dependency_order()

int PaletteGroup::get_dependency_order ( ) const

Returns the dependency order of this group.

This is similar in principle to the dependency level, but it represents the inverse concept: if group a depends on group b, then a->get_dependency_order() > b->get_dependency_order().

This is not exactly the same thing as n - get_dependency_level(). In particular, this can be used to sort the groups into an ordering such that all the groups that group a depends on appear before group a in the list.

Definition at line 268 of file paletteGroup.cxx.

Referenced by is_preferred_over(), and set_dependency_order().

◆ get_dirname()

const string & PaletteGroup::get_dirname ( ) const

Returns the directory name associated with the palette group.

See set_dirname().

Definition at line 71 of file paletteGroup.cxx.

Referenced by set_dependency_order().

◆ get_dirname_order()

int PaletteGroup::get_dirname_order ( ) const

Returns the dependency order of this group.

This is similar in principle to the dependency level, but it represents the inverse concept: if group a depends on group b, then a->get_dirname_order() > b->get_dirname_order().

This is not exactly the same thing as n - get_dependency_level(). In particular, this can be used to sort the groups into an ordering such that all the groups that group a depends on appear before group a in the list.

Definition at line 282 of file paletteGroup.cxx.

Referenced by is_preferred_over(), and set_dependency_order().

◆ get_egg_count()

int PaletteGroup::get_egg_count ( ) const

Returns the number of egg files that share this PaletteGroup.

Definition at line 319 of file paletteGroup.cxx.

Referenced by is_preferred_over().

◆ get_groups()

const PaletteGroups & PaletteGroup::get_groups ( ) const

Returns the set of groups this group depends on.

Definition at line 102 of file paletteGroup.cxx.

Referenced by Palettizer::report_pi(), and Palettizer::report_statistics().

◆ get_margin_override()

int PaletteGroup::get_margin_override ( ) const

Returns the set of groups this group depends on.

Definition at line 110 of file paletteGroup.cxx.

◆ get_page()

PalettePage * PaletteGroup::get_page ( const TextureProperties properties)

Returns the page associated with the indicated properties.

If no page object has yet been created, creates one.

Definition at line 328 of file paletteGroup.cxx.

◆ get_placements()

void PaletteGroup::get_placements ( pvector< TexturePlacement * > &  placements) const

Adds the set of TexturePlacements associated with this group to the indicated vector.

The vector is not cleared before this operation; if the user wants to retrieve the set of placements particular to this group only, it is the user's responsibility to clear the vector first.

Definition at line 138 of file paletteGroup.cxx.

Referenced by get_complete_placements(), and Palettizer::report_statistics().

◆ group_with()

void PaletteGroup::group_with ( PaletteGroup other)

Indicates a dependency of this group on some other group.

This means that the textures assigned to this group may be considered successfully assigned if they are actually placed in the other group. In practice, this means that the textures associated with the other palette group will always be resident at runtime when textures from this palette group are required.

Definition at line 94 of file paletteGroup.cxx.

References PaletteGroups::insert().

◆ has_dirname()

bool PaletteGroup::has_dirname ( ) const

Returns true if the directory name has been explicitly set for this group.

If it has not, get_dirname() returns an empty string.

Definition at line 62 of file paletteGroup.cxx.

Referenced by Palettizer::get_default_group().

◆ has_margin_override()

bool PaletteGroup::has_margin_override ( ) const

Returns the set of groups this group depends on.

Definition at line 127 of file paletteGroup.cxx.

◆ increment_egg_count()

void PaletteGroup::increment_egg_count ( )

Increments by one the number of egg files that are known to reference this PaletteGroup.

This is designed to aid the heuristics in texture placing; it's useful to know how many different egg files are sharing a particular PaletteGroup.

Definition at line 311 of file paletteGroup.cxx.

◆ is_none_texture_swap()

bool PaletteGroup::is_none_texture_swap ( ) const

Returns textureswap information is set or not, True if it's not set.

Definition at line 711 of file paletteGroup.cxx.

◆ is_preferred_over()

bool PaletteGroup::is_preferred_over ( const PaletteGroup other) const

Returns true if this group should be preferred for adding textures over the other group, if both are available.

In other words, this is a more specific group than the other one.

Definition at line 292 of file paletteGroup.cxx.

References get_dependency_order(), get_dirname_order(), and get_egg_count().

Referenced by TextureImage::assign_groups().

◆ optimal_resize()

void PaletteGroup::optimal_resize ( )

Attempts to resize each PalettteImage down to its smallest possible size.

Definition at line 510 of file paletteGroup.cxx.

References PalettePage::optimal_resize().

Referenced by Palettizer::optimal_resize().

◆ place_all()

void PaletteGroup::place_all ( )

Once all the textures have been assigned to this group, try to place them all onto suitable PaletteImages.

Definition at line 408 of file paletteGroup.cxx.

References TexturePlacement::get_omit_reason().

Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().

◆ prepare()

TexturePlacement * PaletteGroup::prepare ( TextureImage texture)

Marks the indicated Texture as ready for placing somewhere within this group, and returns a placeholder TexturePlacement object.

The texture is not placed immediately, but may be placed later when place_all() is called; at this time, the TexturePlacement fields will be filled in as appropriate.

Definition at line 347 of file paletteGroup.cxx.

◆ register_with_read_factory()

void PaletteGroup::register_with_read_factory ( )
static

Registers the current object as something that can be read from a Bam file.

Definition at line 561 of file paletteGroup.cxx.

References BamReader::get_factory().

Referenced by init_palettizer().

◆ reset_dependency_level()

void PaletteGroup::reset_dependency_level ( )

Unconditionally sets the dependency level and order of this group to zero, in preparation for a later call to set_dependency_level().

See set_dependency_level().

Definition at line 169 of file paletteGroup.cxx.

◆ reset_images()

void PaletteGroup::reset_images ( )

Throws away all of the current PaletteImages, so that new ones may be created (and the packing made more optimal).

Definition at line 523 of file paletteGroup.cxx.

References PalettePage::reset_images().

Referenced by Palettizer::reset_images().

◆ set_dependency_level()

void PaletteGroup::set_dependency_level ( int  level)

Sets the dependency level of this group to the indicated level, provided that level is not lower than the level that was set previously.

Also cascades to all dependent groups. See get_dependency_level().

This call recurses to correctly set the dependency level of all PaletteGroups in the hierarchy.

Definition at line 184 of file paletteGroup.cxx.

References PaletteGroups::begin(), PaletteGroups::end(), and set_dependency_level().

Referenced by set_dependency_level().

◆ set_dependency_order()

bool PaletteGroup::set_dependency_order ( )

Updates the dependency order of this group.

This number is the inverse of the dependency level, and can be used to rank the groups in order so that all the groups that a given group depends on will appear first in the list. See get_dependency_order().

This function returns true if anything was changed, false otherwise.

Definition at line 204 of file paletteGroup.cxx.

References PaletteGroups::begin(), PaletteGroups::end(), get_dependency_order(), get_dirname(), get_dirname_order(), and set_dependency_order().

Referenced by set_dependency_order().

◆ set_dirname()

void PaletteGroup::set_dirname ( const std::string &  dirname)

Sets the directory name associated with the palette group.

This is an optional feature that can be used to place the maps for the different palette groups into different install directories.

Definition at line 53 of file paletteGroup.cxx.

Referenced by Palettizer::get_default_group(), and Palettizer::read_txa_file().

◆ set_margin_override()

void PaletteGroup::set_margin_override ( const int  override)

Returns the set of groups this group depends on.

Definition at line 118 of file paletteGroup.cxx.

◆ setup_shadow_images()

void PaletteGroup::setup_shadow_images ( )

Ensures that each PaletteImage's _shadow_image has the correct filename and image types, based on what was supplied on the command line and in the .txa file.

Definition at line 537 of file paletteGroup.cxx.

References PalettePage::setup_shadow_images().

Referenced by Palettizer::all_params_set().

◆ unplace()

void PaletteGroup::unplace ( TexturePlacement placement)

Removes the texture from its position on a PaletteImage, if it has been so placed.

Definition at line 389 of file paletteGroup.cxx.

◆ update_images()

void PaletteGroup::update_images ( bool  redo_all)

Regenerates each PaletteImage on this group that needs it.

Definition at line 549 of file paletteGroup.cxx.

References PalettePage::update_images().

Referenced by Palettizer::generate_images().

◆ update_unknown_textures()

void PaletteGroup::update_unknown_textures ( const TxaFile txa_file)

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.

Definition at line 435 of file paletteGroup.cxx.

References TexturePlacement::determine_size(), TexturePlacement::get_texture(), TextureImage::got_txa_file(), TexturePlacement::is_size_known(), TxaFile::match_texture(), TextureImage::post_txa_file(), and TextureImage::pre_txa_file().

Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().

◆ write_datagram()

void PaletteGroup::write_datagram ( BamWriter writer,
Datagram datagram 
)
virtual

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 571 of file paletteGroup.cxx.

References Datagram::add_bool(), Datagram::add_int16(), Datagram::add_int32(), Datagram::add_string(), Datagram::add_uint32(), TypedWritable::write_datagram(), PaletteGroups::write_datagram(), and BamWriter::write_pointer().

◆ write_image_info()

void PaletteGroup::write_image_info ( std::ostream &  out,
int  indent_level = 0 
) const

Writes a list of the PaletteImages associated with this group, and all of their textures, to the indicated output stream.

Definition at line 460 of file paletteGroup.cxx.

References TexturePlacement::get_omit_reason(), and PalettePage::write_image_info().

Referenced by Palettizer::report_pi().


The documentation for this class was generated from the following files: