changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Base / OSGChunkOverrideGroup.cpp
blobdd48fb58ab4ddb8d1867b83ffef2ea91fa10af6d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGChunkOverrideGroup.h"
49 #include "OSGRenderAction.h"
50 #include "OSGChunkBlock.h"
51 #include "OSGStateChunk.h"
53 OSG_BEGIN_NAMESPACE
55 // Documentation for this class is emitted in the
56 // OSGChunkOverrideGroupBase.cpp file.
57 // To modify it, please change the .fcd file (OSGChunkOverrideGroup.fcd) and
58 // regenerate the base file.
60 /***************************************************************************\
61 * Class variables *
62 \***************************************************************************/
64 /***************************************************************************\
65 * Class methods *
66 \***************************************************************************/
68 void ChunkOverrideGroup::classDescInserter(TypeObject &oType)
70 Inherited::classDescInserter(oType);
73 void ChunkOverrideGroup::initMethod(InitPhase ePhase)
75 Inherited::initMethod(ePhase);
77 if(ePhase == TypeObject::SystemPost)
79 RenderAction::registerEnterDefault(
80 ChunkOverrideGroup::getClassType(),
81 reinterpret_cast<Action::Callback>(
82 &ChunkOverrideGroup::renderEnter));
84 RenderAction::registerLeaveDefault(
85 ChunkOverrideGroup::getClassType(),
86 reinterpret_cast<Action::Callback>(
87 &ChunkOverrideGroup::renderLeave));
92 /***************************************************************************\
93 * Instance methods *
94 \***************************************************************************/
96 /*-------------------------------------------------------------------------*\
97 - private -
98 \*-------------------------------------------------------------------------*/
100 /*----------------------- constructors & destructors ----------------------*/
102 ChunkOverrideGroup::ChunkOverrideGroup(void) :
103 Inherited()
107 ChunkOverrideGroup::ChunkOverrideGroup(const ChunkOverrideGroup &source) :
108 Inherited(source)
112 ChunkOverrideGroup::~ChunkOverrideGroup(void)
116 /*----------------------------- class specific ----------------------------*/
118 bool ChunkOverrideGroup::addChunk(StateChunk *chunk,
119 Int32 slot)
121 ChunkBlockUnrecPtr pBlock = this->finalize(0x0000);
123 if(pBlock == NULL)
125 pBlock = ChunkBlock::create();
127 this->addChunkBlock(pBlock, 0x0000);
130 return pBlock->addChunk(chunk, slot);
133 bool ChunkOverrideGroup::subChunk(StateChunk *chunk,
134 Int32 slot)
136 if(chunk == NULL)
137 return false;
139 ChunkBlock *pBlock = this->finalize(0x0000);
141 if(pBlock != NULL)
143 return pBlock->subChunk(chunk, slot);
146 return false;
149 Int32 ChunkOverrideGroup::find(StateChunk *chunk)
151 ChunkBlock *pBlock = this->finalize(0x0000);
153 if(pBlock != NULL)
155 return pBlock->find(chunk);
158 return -1;
161 StateChunk *ChunkOverrideGroup::find(const StateChunkClass &type,
162 Int32 slot)
164 ChunkBlock *pBlock = this->finalize(0x0000);
166 if(pBlock != NULL)
168 return pBlock->find(type, slot);
171 return NULL;
174 /*-------------------------------------------------------------------------*/
175 /* Binary access */
177 void ChunkOverrideGroup::addChunkBlock(ChunkBlock * const pBlock,
178 ChunkBlockMapKey key)
180 Inherited::addElement(pBlock, key);
184 void ChunkOverrideGroup::subChunkBlock(ChunkBlockMapKey key)
186 Inherited::subElement(key);
189 const SFChunkBlockPtrMap *ChunkOverrideGroup::getSFChunkBlockStore(void) const
191 return Inherited::getMapCacheField();
194 void ChunkOverrideGroup::changed(ConstFieldMaskArg whichField,
195 UInt32 origin,
196 BitVector details)
198 Inherited::changed(whichField, origin, details);
201 void ChunkOverrideGroup::dump( UInt32 ,
202 const BitVector ) const
204 SLOG << "Dump ChunkOverrideGroup NI" << std::endl;
207 Action::ResultE ChunkOverrideGroup::renderEnter(Action *action)
209 RenderAction *pAction = dynamic_cast<RenderAction *>(action);
211 if(pAction != NULL)
213 pAction->pushState();
215 ChunkBlock *pBlock = this->finalize(pAction->getRenderProperties());
217 if(pBlock == NULL)
218 return Inherited::renderEnter(action);
220 MFUnrecStateChunkPtr::const_iterator chIt = pBlock->beginChunks();
221 MFUnrecStateChunkPtr::const_iterator chEnd = pBlock->endChunks ();
222 UInt32 uiSlot = 0;
224 while(chIt != chEnd)
226 if(*chIt != NULL && (*chIt)->getIgnore() == false)
228 if (getSubOverride())
230 pAction->subOverride(uiSlot, *chIt);
232 else
234 pAction->addOverride(uiSlot, *chIt);
238 ++uiSlot;
239 ++chIt;
243 return Inherited::renderEnter(action);
246 Action::ResultE ChunkOverrideGroup::renderLeave(Action *action)
248 RenderAction *pAction =
249 dynamic_cast<RenderAction *>(action);
251 if(pAction != NULL)
253 pAction->popState();
257 return Inherited::renderLeave(action);
260 OSG_END_NAMESPACE