29 _textures(copy._textures)
36 void TextureCollection::
38 _textures = copy._textures;
50 if (_textures.get_ref_count() > 1) {
51 Textures old_textures = _textures;
52 _textures = Textures::empty_array(0);
53 _textures.v() = old_textures.v();
56 _textures.push_back(texture);
65 int texture_index = -1;
66 for (
int i = 0; texture_index == -1 && i < (int)_textures.size(); i++) {
67 if (_textures[i] == texture) {
72 if (texture_index == -1) {
81 if (_textures.get_ref_count() > 1) {
82 Textures old_textures = _textures;
83 _textures = Textures::empty_array(0);
84 _textures.v() = old_textures.v();
87 _textures.erase(_textures.begin() + texture_index);
99 for (
int i = 0; i < other_num_textures; i++) {
111 Textures new_textures;
113 for (
int i = 0; i < num_textures; i++) {
116 new_textures.push_back(texture);
119 _textures = new_textures;
129 Textures new_textures;
132 for (
int i = 0; i < num_textures; i++) {
134 bool duplicated =
false;
136 for (
int j = 0; j < i && !duplicated; j++) {
141 new_textures.push_back(texture);
145 _textures = new_textures;
176 _textures.reserve(num);
186 for (
int i = 0; i < num_textures; i++) {
188 if (texture->get_name() == name) {
198 int TextureCollection::
199 get_num_textures()
const {
200 return _textures.size();
208 nassertr(index >= 0 && index < (
int)_textures.size(),
nullptr);
210 return _textures[index];
219 nassertr(index >= 0 && index < (
int)_textures.size(),
nullptr);
221 return _textures[index];
230 return _textures.size();
251 write(std::ostream &out,
int indent_level)
const {
int size() const
Returns the number of textures in the collection.
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of NodePaths,...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
void add_texture(Texture *texture)
Adds a new Texture to the collection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the TextureCollection to the indicated output stream.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Texture * operator [](int index) const
Returns the nth Texture in the collection.
Manages a list of Texture objects, as returned by TexturePool::find_all_textures().
Texture * find_texture(const std::string &name) const
Returns the texture in the collection with the indicated name, if any, or NULL if no texture has that...
get_num_textures
Returns the number of Textures in the collection.
void clear()
Removes all Textures from the collection.
void add_textures_from(const TextureCollection &other)
Adds all the Textures indicated in the other collection to this texture.
void remove_textures_from(const TextureCollection &other)
Removes from this collection all of the Textures listed in the other collection.
void output(std::ostream &out) const
Writes a brief one-line description of the TextureCollection to the indicated output stream.
bool remove_texture(Texture *texture)
Removes the indicated Texture from the collection.
void remove_duplicate_textures()
Removes any duplicate entries of the same Textures on this collection.
bool has_texture(Texture *texture) const
Returns true if the indicated Texture appears in this collection, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_texture
Returns the nth Texture in the collection.