Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OrigMeshContainer Class Reference

Public Member Functions

 OrigMeshContainer ()
 
 OrigMeshContainer (Mesh *orig, float d, int passno)
 
bool operator< (const OrigMeshContainer &b) const
 
bool operator== (const OrigMeshContainer &b) const
 

Public Attributes

float d
 
Meshorig
 
int program
 
unsigned int transparent: 1
 
unsigned int zsort: 1
 
unsigned int passno: 14
 
int sequence: 16
 

Detailed Description

Definition at line 57 of file mesh_gfx.cpp.

Constructor & Destructor Documentation

OrigMeshContainer::OrigMeshContainer ( )
inline

Definition at line 69 of file mesh_gfx.cpp.

References orig.

70  {
71  orig = NULL;
72  }
OrigMeshContainer::OrigMeshContainer ( Mesh orig,
float  d,
int  passno 
)
inline

Definition at line 73 of file mesh_gfx.cpp.

References Mesh::blendDst, Mesh::blendSrc, d, Technique::Pass::Decal, Technique::Pass::Default, DESTCOLOR, ONE, orig, passno, program, sequence, Mesh::technique, transparent, ZERO, and zsort.

74  {
75  assert( passno < orig->technique->getNumPasses() );
76 
77  const Technique::Pass &pass = orig->technique->getPass( passno );
78  this->orig = orig;
79  this->d = -d;
80  this->passno = passno;
81  this->sequence = pass.sequence;
82  this->program = pass.getCompiledProgram();
83  this->transparent =
84  ( (pass.blendMode == Technique::Pass::Decal)
85  || ( (pass.blendMode == Technique::Pass::Default)
86  && (orig->blendDst == ZERO)
87  && (orig->blendSrc != DESTCOLOR) )
88  ) ? 0 : 1;
89  this->zsort = ( transparent && ( (pass.blendMode != Technique::Pass::Default) || (orig->blendDst != ONE) || (orig->blendSrc != ONE) ) ) ? 1 : 0;
90 
91  assert( this->passno == passno );
92  assert( this->sequence == pass.sequence );
93  }

Member Function Documentation

bool OrigMeshContainer::operator< ( const OrigMeshContainer b) const
inline

Definition at line 109 of file mesh_gfx.cpp.

References d, Technique::Pass::TextureUnit::Decal, Mesh::Decal, Technique::Pass::TextureUnit::File, Technique::Pass::getNumTextureUnits(), Technique::Pass::getTextureUnit(), i, orig, passno, PLESS, PLESSX, program, sequence, SLESS, SLESSX, Technique::Pass::TextureUnit::sourceIndex, Technique::Pass::TextureUnit::sourceType, Mesh::technique, Technique::Pass::TextureUnit::texture, transparent, and zsort.

110  {
111  SLESS( sequence ); //explicit sequence takes precedence
112  SLESS( transparent ); //then render opaques first
113  SLESS( zsort ); //And the ones that need z-sort last
114  if (zsort)
115  SLESS( d );
116  SLESS( passno ); //Make sure lesser passes render first
117  SLESS( program ); //group same program together (with fixed-fn at the beginning)
118  //Fixed-fn passes have program == 0
119  if (program == 0) {
120  //Fixed-fn passes sort by texture
121  SLESS( orig->Decal.size() );
122  if (orig->Decal.size() > 0)
123  PLESS( orig->Decal[0] );
124  } else {
125  //Shader passes sort by effective texture
126  const Technique::Pass &apass = orig->technique->getPass( passno );
127  const Technique::Pass &bpass = b.orig->technique->getPass( b.passno );
128 
129  SLESSX( apass.getNumTextureUnits(), bpass.getNumTextureUnits() );
130  for (size_t i = 0, n = apass.getNumTextureUnits(); i < n; ++i) {
131  const Technique::Pass::TextureUnit atu = apass.getTextureUnit( i );
132  const Technique::Pass::TextureUnit btu = bpass.getTextureUnit( i );
133  if (atu.sourceType == btu.sourceType) {
135  //Compare preloaded textures
136  SLESSX( *atu.texture, *btu.texture );
138  //Compare decal textures
139  const Texture *ta = ( atu.sourceIndex < static_cast<int>(orig->Decal.size()) ) ? orig->Decal[atu.sourceIndex] : NULL;
140  const Texture *tb = ( btu.sourceIndex < static_cast<int>(b.orig->Decal.size()) ) ? b.orig->Decal[btu.sourceIndex] : NULL;
141  PLESSX( ta, tb );
142  }
143  } else {
144  //Render file-type ones first
146  }
147  }
148  }
149  //They're equivalent!
150  return false;
151  }
bool OrigMeshContainer::operator== ( const OrigMeshContainer b) const
inline

Definition at line 158 of file mesh_gfx.cpp.

References b.

159  {
160  //TODO: Specialize operator==
161  return !(*this < b) && !(b < *this);
162  }

Member Data Documentation

float OrigMeshContainer::d

Definition at line 60 of file mesh_gfx.cpp.

Referenced by OrigMeshPainterSort::operator()(), operator<(), and OrigMeshContainer().

Mesh* OrigMeshContainer::orig

Definition at line 61 of file mesh_gfx.cpp.

Referenced by operator<(), and OrigMeshContainer().

unsigned int OrigMeshContainer::passno

Definition at line 66 of file mesh_gfx.cpp.

Referenced by operator<(), and OrigMeshContainer().

int OrigMeshContainer::program

Definition at line 62 of file mesh_gfx.cpp.

Referenced by operator<(), and OrigMeshContainer().

int OrigMeshContainer::sequence

Definition at line 67 of file mesh_gfx.cpp.

Referenced by operator<(), and OrigMeshContainer().

unsigned int OrigMeshContainer::transparent

Definition at line 64 of file mesh_gfx.cpp.

Referenced by operator<(), and OrigMeshContainer().

unsigned int OrigMeshContainer::zsort

Definition at line 65 of file mesh_gfx.cpp.

Referenced by operator<(), and OrigMeshContainer().


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