#include <OSGState.h>
Inheritance diagram for osg::State:

Public Types | |
| typedef StatePtr | Ptr |
Enums | |
| enum | { AutoSlot = -1, AutoSlotReplace = -2 } |
Public Member Functions | |
Sync | |
| *virtual void | changed (BitVector whichField, UInt32 origin) |
Output | |
| *virtual void | dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const |
OpenGL State Management | |
| *void | activate (DrawActionBase *action) |
| void | changeFrom (DrawActionBase *action, State *old) |
| void | deactivate (DrawActionBase *action) |
Access | |
| *StateChunkPtr | getChunk (UInt32 id) |
| bool | chunkPresent (UInt32 id) |
| bool | chunkPresent (StateChunkPtr chunk) |
| bool | addChunk (StateChunkPtr chunk, Int32 index=AutoSlotReplace) |
| bool | subChunk (StateChunkPtr chunk) |
| bool | subChunk (UInt32 classid, Int32 index) |
| void | clearChunks (void) |
Comparison | |
| *virtual Real32 | switchCost (State *state) |
| virtual bool | operator< (const State &other) const |
| virtual bool | operator== (const State &other) const |
| virtual bool | operator!= (const State &other) const |
FieldContainer Get | |
| *virtual FieldContainerType & | getType (void) |
| virtual const FieldContainerType & | getType (void) const |
| virtual UInt32 | getContainerSize (void) const |
Field Get | |
| *MFStateChunkPtr * | getMFChunks (void) |
| Get the State::_mfChunks field. | |
| StateChunkPtr & | getChunks (const UInt32 index) |
| Get the value of the index element the State::_mfChunks field. | |
| MFStateChunkPtr & | getChunks (void) |
| Get the State::_mfChunks field. | |
| const MFStateChunkPtr & | getChunks (void) const |
| Get the State::_mfChunks field. | |
Binary Access | |
| *virtual UInt32 | getBinSize (const BitVector &whichField) |
| virtual void | copyToBin (BinaryDataHandler &pMem, const BitVector &whichField) |
| virtual void | copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField) |
Copy | |
| *virtual FieldContainerPtr | shallowCopy (void) const |
Static Public Member Functions | |
Class Get | |
| *static const char * | getClassname (void) |
Class Get | |
| *static FieldContainerType & | getClassType (void) |
| access the type of the class | |
| static UInt32 | getClassTypeId (void) |
| access the numerical type of the class | |
Construction | |
| *static StatePtr | create (void) |
| create a new instance of the class | |
| static StatePtr | createEmpty (void) |
| create an empty new instance of the class, do not copy the prototype | |
Static Public Attributes | |
| static const osg::BitVector | ChunksFieldMask |
| static const osg::BitVector | MTInfluenceMask |
| static const BitVector | NextFieldMask |
Protected Member Functions | |
MT Destruction | |
| *virtual void | onDestroy (void) |
MT Destruction | |
| *virtual void | onDestroy (void) |
MT Destruction | |
| *virtual void | onDestroy (void) |
Constructors | |
| * | State (void) |
| State (const State &source) | |
Destructors | |
| *virtual | ~State (void) |
Sync | |
| *void | executeSyncImpl (StateBase *pOther, const BitVector &whichField) |
| virtual void | executeSync (FieldContainer &other, const BitVector &whichField) |
MT Destruction | |
| *virtual void | onDestroy (void) |
Protected Attributes | |
Fields | |
| *MFStateChunkPtr | _mfChunks |
Private Types | |
| typedef StateBase | Inherited |
Private Member Functions | |
| void | operator= (const State &source) |
Static Private Member Functions | |
| static void | initMethod (void) |
Static Private Attributes | |
| static char | cvsid [] = "@(#)$Id: $" |
Friends | |
| class | FieldContainer |
| class | StateBase |
Definition at line 56 of file OSGState.h.
|
|
Reimplemented from osg::StateBase. Definition at line 156 of file OSGState.h. |
|
|
Definition at line 90 of file OSGStateBase.h. |
|
|
Reimplemented from osg::StateBase. Definition at line 99 of file OSGState.h. 00099 { AutoSlot = -1, AutoSlotReplace = -2 };
|
|
|
Definition at line 123 of file OSGState.cpp. 00123 : 00124 Inherited() 00125 { 00126 }
|
|
|
Definition at line 128 of file OSGState.cpp. 00128 : 00129 Inherited(source) 00130 { 00131 }
|
|
|
Definition at line 133 of file OSGState.cpp. References clearChunks(). 00134 { 00135 clearChunks(); 00136 }
|
|
|
Definition at line 65 of file OSGState.h.
|
|
||||||||||||
|
Reimplemented from osg::FieldContainer. Definition at line 139 of file OSGState.cpp. References osg::FieldContainer::changed(). 00140 { 00141 Inherited::changed(whichField, origin); 00142 }
|
|
||||||||||||
|
Implements osg::FieldContainer. Definition at line 146 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::end(), osg::getName(), and osg::NullFC. 00148 { 00149 std::cerr << "State at " << this << std::endl; 00150 00151 MFStateChunkPtr::const_iterator it; 00152 UInt32 cind; 00153 00154 for(it = _mfChunks.begin(), cind = 0; it != _mfChunks.end(); it++, cind++) 00155 { 00156 std::cerr << StateChunkClass::getName(cind) << "\t"; 00157 if(*it == NullFC) 00158 std::cerr << "NullChunk" << std::endl; 00159 else 00160 std::cerr << *it << std::endl; 00161 } 00162 }
|
|
|
Activate (i.e. call all their OpenGL commands) the current set of StateChunks. Activate will simply overwrite whatever was set before. Definition at line 170 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::end(), osg::StateChunkClass::getNumSlots(), and osg::NullFC. Referenced by osg::RenderAction::draw(). 00171 { 00172 MFStateChunkPtr::iterator it; 00173 Int32 ind = 0; 00174 UInt32 cind; 00175 00176 for(it = _mfChunks.begin(), cind = 0; it != _mfChunks.end(); 00177 ++it, ++cind) 00178 { 00179 if(*it != NullFC) 00180 { 00181 (*it)->activate(action, UInt32(ind)); 00182 } 00183 if(++ind >= StateChunkClass::getNumSlots(cind)) 00184 ind = 0; 00185 } 00186 }
|
|
||||||||||||
|
Switch to this state from the given old State. The chunks will try to optimize the transition. Definition at line 193 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::end(), getChunk(), osg::StateBase::getChunks(), osg::AttachmentPtr::getCPtr(), osg::StateChunkClass::getNumSlots(), and osg::NullFC. Referenced by osg::RenderAction::draw(). 00194 { 00195 MFStateChunkPtr::iterator it; 00196 Int32 ind = 0; 00197 UInt32 i; 00198 UInt32 cind; 00199 00200 for(it = _mfChunks.begin(), cind = 0; it != _mfChunks.end(); 00201 ++it, ++cind) 00202 { 00203 StateChunkPtr o = old->getChunk(cind); 00204 StateChunkPtr n = *it; 00205 00206 if(n != NullFC) 00207 { 00208 if(o != NullFC) 00209 n->changeFrom(action, o.getCPtr(), UInt32(ind)); 00210 else 00211 n->activate(action, UInt32(ind)); 00212 } 00213 else if(o != NullFC) 00214 o->deactivate(action, UInt32(ind)); 00215 00216 if(++ind >= StateChunkClass::getNumSlots(cind)) 00217 ind = 0; 00218 } 00219 00220 if(ind >= StateChunkClass::getNumSlots(cind)) 00221 ind = 0; 00222 00223 for(i = cind; i < old->getChunks().size(); ++i) 00224 { 00225 StateChunkPtr o = old->getChunk(i); 00226 00227 if(o != NullFC) 00228 { 00229 o->deactivate(action, UInt32(ind)); 00230 } 00231 00232 if(++ind >= StateChunkClass::getNumSlots(i)) 00233 { 00234 ind = 0; 00235 } 00236 } 00237 }
|
|
|
Deactivate the current set of StateChunks, i.e. switch everything back to the default state for the OpenGL state covered by the given chunks. Definition at line 244 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), osg::MField< FieldTypeT, fieldNameSpace >::end(), osg::StateChunkClass::getNumSlots(), and osg::NullFC. Referenced by osg::RenderAction::draw(), and osg::RenderAction::stop(). 00245 { 00246 MFStateChunkPtr::iterator it; 00247 Int32 ind = 0; 00248 UInt32 cind; 00249 00250 for(it = _mfChunks.begin(), cind = 0; it != _mfChunks.end(); 00251 ++it, ++cind) 00252 { 00253 if(*it != NullFC) 00254 (*it)->deactivate(action, UInt32(ind)); 00255 if(++ind >= StateChunkClass::getNumSlots(cind)) 00256 ind = 0; 00257 } 00258 }
|
|
|
Return the chunk with the given id. Returns NullFC if no such chunk is in the State. Definition at line 51 of file OSGState.inl. References osg::StateBase::_mfChunks, osg::NullFC, and osg::MField< FieldTypeT, fieldNameSpace >::size(). Referenced by changeFrom(). 00052 { 00053 if(id < _mfChunks.size()) 00054 return _mfChunks[id]; 00055 00056 return NullFC; 00057 }
|
|
|
Checks if a chunk with the given id is in the current state. Definition at line 63 of file OSGState.inl. References osg::StateBase::_mfChunks, osg::NullFC, and osg::MField< FieldTypeT, fieldNameSpace >::size(). Referenced by chunkPresent().
|
|
|
Checks if a chunk of the same type like the given one is in the current state. Definition at line 74 of file OSGState.inl. References chunkPresent(), osg::StateChunkClass::getId(), and osg::StateChunkClass::getNumSlots(). 00075 { 00076 const StateChunkClass * cls = chunk->getClass(); 00077 00078 for(UInt16 i = 0; i < cls->getNumSlots(); ++i) 00079 { 00080 if(chunkPresent(cls->getId() + i)) 00081 return true; 00082 } 00083 00084 return false; 00085 }
|
|
||||||||||||
|
Add the given chunk to the State. The index defines the behaviour, especially for multi-slot chunks. If it is set to AutoSlotReplace (the default), addChunk will try to find an empty slot for the chunk class, if it doesn't find one the last one will be replaced with the new entry. This is also useful for chunk classes with only a single slot, as it will override an old instance of the chunk class, which is usually the desired behaviour. If it is set to AutoSlot, the new chunk will only be added to the State if there is a free slot. If there is no free slot true will be returned, in all other cases it will be false. If the index is explicitly given (i.e. it is >=0) the chunk will be set into the given slot, possibly overwriting an old entry. If the index is larger than the number of slots for the given chunck class true will be returned. Definition at line 282 of file OSGState.cpp. References osg::StateBase::_mfChunks, AutoSlot, AutoSlotReplace, osg::NullFC, osg::MField< FieldTypeT, fieldNameSpace >::resize(), osg::setRefdCP(), osg::MField< FieldTypeT, fieldNameSpace >::size(), and SWARNING. 00283 { 00284 if(index > 0 && index > chunk->getClass()->getNumSlots()) 00285 { 00286 SWARNING << "addChunk: index " 00287 << index 00288 << " > Numslots " 00289 << chunk->getClass()->getNumSlots() 00290 << ", ignored!" 00291 << std::endl; 00292 return true; 00293 } 00294 00295 UInt32 cindex = chunk->getClassId(); 00296 UInt32 csize = _mfChunks.size(); 00297 00298 // special case: find empty slot automatically 00299 if(index == AutoSlot || index == AutoSlotReplace) 00300 { 00301 UInt8 nslots = chunk->getClass()->getNumSlots(); 00302 UInt8 ci; 00303 00304 for(ci = cindex; ci < cindex + nslots && ci < csize; ++ci) 00305 { 00306 if(_mfChunks[ci] == NullFC) 00307 { 00308 break; 00309 } 00310 } 00311 00312 if(ci >= cindex + nslots) // no free slot found 00313 { 00314 if(index == AutoSlot) 00315 { 00316 SWARNING << "addChunk: no free slot found for " 00317 << chunk->getClass()->getName() 00318 << " class, ignored!" << std::endl; 00319 return true; 00320 } 00321 // use last slot 00322 --ci; 00323 } 00324 00325 cindex = ci; 00326 } 00327 else 00328 { 00329 cindex += index; 00330 } 00331 00332 // add the chunk to the state at cindex 00333 if(cindex >= csize) 00334 { 00335 UInt32 oldsize = csize; 00336 UInt32 newsize = cindex + 1; 00337 00338 _mfChunks.resize(newsize); 00339 00340 for(UInt32 i = oldsize; i < newsize; i++) 00341 { 00342 _mfChunks[i] = NullFC; 00343 } 00344 } 00345 00346 setRefdCP(_mfChunks[cindex], chunk); 00347 00348 return false; 00349 }
|
|
|
Remove the given chunk from the State. Returns false if successful, true if the chunk wasn't found. Definition at line 355 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::NullFC, osg::MField< FieldTypeT, fieldNameSpace >::size(), osg::subRefCP(), and SWARNING. 00356 { 00357 if(chunk == NullFC) 00358 return true; 00359 00360 UInt32 cindex = chunk->getClassId(); 00361 UInt32 csize = _mfChunks.size(); 00362 00363 // special case: find it in the slots 00364 UInt8 nslots = chunk->getClass()->getNumSlots(); 00365 UInt8 ci; 00366 00367 for(ci = cindex; ci < cindex + nslots && ci < csize; ci++) 00368 { 00369 if(_mfChunks[ci] == chunk) 00370 { 00371 break; 00372 } 00373 } 00374 00375 if(ci >= cindex + nslots) // chunk not found 00376 { 00377 SWARNING << "subChunk: chunk " 00378 << chunk 00379 << " of class " 00380 << chunk->getClass()->getName() 00381 << " not found!" 00382 << std::endl; 00383 return true; 00384 } 00385 00386 // remove the chunk from the state 00387 00388 subRefCP(_mfChunks[ci]); 00389 00390 _mfChunks[ci] = NullFC; 00391 00392 return false; 00393 }
|
|
||||||||||||
|
Remove the chunk defined by the class id and the slot index from the State. Returns false if successful, true if the chunk wasn't found. Definition at line 400 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::StateChunkClass::getNumSlots(), osg::NullFC, osg::subRefCP(), and SWARNING. 00401 { 00402 if(index < 0 || index > StateChunkClass::getNumSlots(classid)) 00403 { 00404 SWARNING << "subChunk: index " << index << " > Numslots " 00405 << StateChunkClass::getNumSlots(classid) 00406 << ", ignored!" << std::endl; 00407 return true; 00408 } 00409 00410 if(_mfChunks[classid + index] == NullFC) 00411 return true; 00412 00413 // remove the chunk from the state 00414 00415 subRefCP(_mfChunks[classid + index]); 00416 00417 _mfChunks[classid + index] = NullFC; 00418 00419 return false; 00420 }
|
|
|
Remove all chunks from the state Definition at line 425 of file OSGState.cpp. References osg::StateBase::_mfChunks, osg::MField< FieldTypeT, fieldNameSpace >::begin(), and osg::MField< FieldTypeT, fieldNameSpace >::end(). Referenced by ~State(). 00426 { 00427 std::transform(_mfChunks.begin(), 00428 _mfChunks.end (), 00429 _mfChunks.begin(), 00430 ClearSlot()); 00431 }
|
|
|
Calculate the switch cost for the whole state, which is the sum of the switch cost of all its chunks. Right now it's always 0. Definition at line 440 of file OSGState.cpp.
|
|
|
Calculate the switch cost for the whole state, which is the sum of the switch cost of all its chunks. Right now it's always 0. Definition at line 445 of file OSGState.cpp.
|
|
|
Compare the two states. Not implemented yet, always false. Definition at line 453 of file OSGState.cpp.
|
|
|
Calculate the switch cost for the whole state, which is the sum of the switch cost of all its chunks. Right now it's always 0. Definition at line 458 of file OSGState.cpp.
|
|
|
Definition at line 108 of file OSGState.cpp.
|
|
|
|
|
|
Reimplemented from osg::FieldContainer. Definition at line 58 of file OSGStateBase.inl. References osg::StateBase::_type. Referenced by osg::StateBase::create(). 00059 { 00060 return _type; 00061 }
|
|
|
Reimplemented from osg::FieldContainer. Definition at line 65 of file OSGStateBase.inl. References osg::StateBase::_type, and osg::TypeBase::getId(). 00066 { 00067 return _type.getId(); 00068 }
|
|
|
Reimplemented from osg::FieldContainer. Definition at line 106 of file OSGStateBase.cpp. References osg::StateBase::_type. 00107 { 00108 return _type; 00109 }
|
|
|
Reimplemented from osg::FieldContainer. Definition at line 111 of file OSGStateBase.cpp. References osg::StateBase::_type. 00112 { 00113 return _type; 00114 }
|
|
|
Implements osg::FieldContainer. Definition at line 126 of file OSGStateBase.cpp. 00127 { 00128 return sizeof(State); 00129 }
|
|
|
Definition at line 101 of file OSGStateBase.inl. References osg::StateBase::_mfChunks. 00102 { 00103 return &_mfChunks; 00104 }
|
|
|
Definition at line 110 of file OSGStateBase.inl. References osg::StateBase::_mfChunks. Referenced by changeFrom(). 00111 { 00112 return _mfChunks[index]; 00113 }
|
|
|
Definition at line 117 of file OSGStateBase.inl. References osg::StateBase::_mfChunks. 00118 { 00119 return _mfChunks; 00120 }
|
|
|
Definition at line 124 of file OSGStateBase.inl. References osg::StateBase::_mfChunks. 00125 { 00126 return _mfChunks; 00127 }
|
|
|
Reimplemented from osg::FieldContainer. Definition at line 189 of file OSGStateBase.cpp. References osg::StateBase::_mfChunks, osg::StateBase::ChunksFieldMask, osg::MField< FieldTypeT, fieldNameSpace >::getBinSize(), osg::FieldContainer::getBinSize(), and osg::FieldBits::NoField. 00190 { 00191 UInt32 returnValue = Inherited::getBinSize(whichField); 00192 00193 if(FieldBits::NoField != (ChunksFieldMask & whichField)) 00194 { 00195 returnValue += _mfChunks.getBinSize(); 00196 } 00197 00198 00199 return returnValue; 00200 }
|
|
||||||||||||
|
Reimplemented from osg::FieldContainer. Definition at line 202 of file OSGStateBase.cpp. References osg::StateBase::_mfChunks, osg::StateBase::ChunksFieldMask, osg::MField< FieldTypeT, fieldNameSpace >::copyToBin(), osg::FieldContainer::copyToBin(), and osg::FieldBits::NoField. 00204 { 00205 Inherited::copyToBin(pMem, whichField); 00206 00207 if(FieldBits::NoField != (ChunksFieldMask & whichField)) 00208 { 00209 _mfChunks.copyToBin(pMem); 00210 } 00211 00212 00213 }
|
|
||||||||||||
|
Reimplemented from osg::FieldContainer. Definition at line 215 of file OSGStateBase.cpp. References osg::StateBase::_mfChunks, osg::StateBase::ChunksFieldMask, osg::MField< FieldTypeT, fieldNameSpace >::copyFromBin(), osg::FieldContainer::copyFromBin(), and osg::FieldBits::NoField. 00217 { 00218 Inherited::copyFromBin(pMem, whichField); 00219 00220 if(FieldBits::NoField != (ChunksFieldMask & whichField)) 00221 { 00222 _mfChunks.copyFromBin(pMem); 00223 } 00224 00225 00226 }
|
|
|
Definition at line 72 of file OSGStateBase.inl. References osg::StateBase::getClassType(), osg::FieldContainerType::getPrototype(), osg::NullFC, and osg::StateBase::shallowCopy(). Referenced by osg::SimpleMaterial::makeState(), osg::PhongMaterial::makeState(), osg::FresnelMaterial::makeState(), osg::ChunkMaterial::makeState(), osg::SimpleMaterial::rebuildState(), osg::PhongMaterial::rebuildState(), osg::FresnelMaterial::rebuildState(), and osg::ChunkMaterial::rebuildState(). 00073 { 00074 StatePtr fc; 00075 00076 if(getClassType().getPrototype() != OSG::NullFC) 00077 { 00078 fc = StatePtr::dcast( 00079 getClassType().getPrototype()-> shallowCopy()); 00080 } 00081 00082 return fc; 00083 }
|
|
|
Definition at line 87 of file OSGStateBase.inl. References osg::FieldContainer::newPtr(). 00088 { 00089 StatePtr returnValue; 00090 00091 newPtr(returnValue); 00092 00093 return returnValue; 00094 }
|
|
|
Implements osg::FieldContainer. Definition at line 117 of file OSGStateBase.cpp. References osg::FieldContainer::newPtr(). Referenced by osg::StateBase::create(). 00118 { 00119 StatePtr returnValue; 00120 00121 newPtr(returnValue, dynamic_cast<const State *>(this)); 00122 00123 return returnValue; 00124 }
|
|
||||||||||||
|
Definition at line 229 of file OSGStateBase.cpp. References osg::StateBase::_mfChunks, osg::StateBase::ChunksFieldMask, osg::FieldContainer::executeSyncImpl(), osg::FieldBits::NoField, and osg::MField< FieldTypeT, fieldNameSpace >::syncWith(). Referenced by osg::StateBase::executeSync(). 00231 { 00232 00233 Inherited::executeSyncImpl(pOther, whichField); 00234 00235 if(FieldBits::NoField != (ChunksFieldMask & whichField)) 00236 _mfChunks.syncWith(pOther->_mfChunks); 00237 00238 00239 }
|
|
||||||||||||
|
Definition at line 333 of file OSGFieldContainerImpl.inl. Referenced by osg::StateBase::executeSyncImpl(), osg::DVRShaderBase::executeSyncImpl(), osg::DVRClipGeometryBase::executeSyncImpl(), osg::AttachmentContainer::executeSyncImpl(), and osg::Attachment::executeSyncImpl().
|
|
||||||||||||
|
Implements osg::FieldContainer. Definition at line 133 of file OSGStateBase.cpp. References osg::StateBase::executeSyncImpl(). 00135 { 00136 this->executeSyncImpl((StateBase *) &other, whichField); 00137 }
|
|
|
Definition at line 71 of file OSGFieldContainerImpl.inl. References osg::FieldContainer::_type, and osg::FieldContainerType::getGroupId(). 00072 { 00073 return _type.getGroupId(); 00074 }
|
|
|
Definition at line 77 of file OSGFieldContainerImpl.inl. References osg::TypeBase::getId(), and osg::FieldContainer::getType(). Referenced by osg::TextureChunk::changeFrom(), and osg::CubeTextureChunk::changeFrom(). 00078 { 00079 return getType().getId(); 00080 }
|
|
|
Definition at line 83 of file OSGFieldContainerImpl.inl. References osg::FieldContainerType::getGroupId(), and osg::FieldContainer::getType(). Referenced by osg::Image::setAttachmentField(). 00084 { 00085 return getType().getGroupId(); 00086 }
|
|
|