15 #include "textureStageCollection.h"
18 #include "indirectLess.h"
26 TextureStageCollection::
27 TextureStageCollection() {
35 TextureStageCollection::
37 _texture_stages(copy._texture_stages)
46 void TextureStageCollection::
48 _texture_stages = copy._texture_stages;
63 if (_texture_stages.get_ref_count() > 1) {
64 TextureStages old_texture_stages = _texture_stages;
65 _texture_stages = TextureStages::empty_array(0);
66 _texture_stages.v() = old_texture_stages.v();
69 _texture_stages.push_back(node_texture_stage);
81 int texture_stage_index = -1;
82 for (
int i = 0; texture_stage_index == -1 && i < (int)_texture_stages.size(); i++) {
83 if (_texture_stages[i] == node_texture_stage) {
84 texture_stage_index = i;
88 if (texture_stage_index == -1) {
98 if (_texture_stages.get_ref_count() > 1) {
99 TextureStages old_texture_stages = _texture_stages;
100 _texture_stages = TextureStages::empty_array(0);
101 _texture_stages.v() = old_texture_stages.v();
104 _texture_stages.erase(_texture_stages.begin() + texture_stage_index);
119 for (
int i = 0; i < other_num_texture_stages; i++) {
133 TextureStages new_texture_stages;
135 for (
int i = 0; i < num_texture_stages; i++) {
138 new_texture_stages.push_back(texture_stage);
141 _texture_stages = new_texture_stages;
154 TextureStages new_texture_stages;
157 for (
int i = 0; i < num_texture_stages; i++) {
159 bool duplicated =
false;
161 for (
int j = 0; j < i && !duplicated; j++) {
166 new_texture_stages.push_back(texture_stage);
170 _texture_stages = new_texture_stages;
196 _texture_stages.clear();
209 for (
int i = 0; i < num_texture_stages; i++) {
211 if (texture_stage->
get_name() == name) {
212 return texture_stage;
225 return _texture_stages.size();
235 nassertr(index >= 0 && index < (
int)_texture_stages.size(), NULL);
237 return _texture_stages[index];
249 nassertr(index >= 0 && index < (
int)_texture_stages.size(), NULL);
251 return _texture_stages[index];
263 return _texture_stages.size();
274 ::sort(_texture_stages.begin(), _texture_stages.end(),
275 CompareTextureStageSort());
287 out <<
"1 TextureStage";
300 write(ostream &out,
int indent_level)
const {
void add_texture_stage(TextureStage *node_texture_stage)
Adds a new TextureStage to the collection.
void clear()
Removes all TextureStages from the collection.
int get_num_texture_stages() const
Returns the number of TextureStages in the collection.
int size() const
Returns the number of texture stages in the collection.
const string & get_name() const
Returns the name of this texture stage.
bool has_texture_stage(TextureStage *texture_stage) const
Returns true if the indicated TextureStage appears in this collection, false otherwise.
void remove_duplicate_texture_stages()
Removes any duplicate entries of the same TextureStages on this collection.
void add_texture_stages_from(const TextureStageCollection &other)
Adds all the TextureStages indicated in the other collection to this texture_stage.
TextureStage * get_texture_stage(int index) const
Returns the nth TextureStage in the collection.
bool remove_texture_stage(TextureStage *node_texture_stage)
Removes the indicated TextureStage from the collection.
void remove_texture_stages_from(const TextureStageCollection &other)
Removes from this collection all of the TextureStages listed in the other collection.
TextureStage * find_texture_stage(const string &name) const
Returns the texture_stage in the collection with the indicated name, if any, or NULL if no texture_st...
void output(ostream &out) const
Writes a brief one-line description of the TextureStageCollection to the indicated output stream...
void write(ostream &out, int indent_level=0) const
Writes a complete multi-line description of the TextureStageCollection to the indicated output stream...
TextureStage * operator[](int index) const
Returns the nth TextureStage in the collection.
void sort()
Sorts the TextureStages in this collection into order by TextureStage::sort(), from lowest to highest...
Defines the properties of a named stage of the multitexture pipeline.