1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
41 template <class ParentT> inline
42 void StageHandlerMixin<ParentT>::changed(ConstFieldMaskArg whichField,
46 Inherited::changed(whichField, origin, details);
49 template <class ParentT> inline
50 typename StageHandlerMixin<ParentT>::ValidationStatus
51 StageHandlerMixin<ParentT>::validateOnEnter(
52 RenderActionBase *pAction)
54 TraversalValidator::ValidationStatus returnValue = Self::validate(pAction);
56 StageDataUnrecPtr pData =
57 pAction->template getData<StageData *>(this->_iDataSlotId);
61 pData = StageData::createLocal();
63 pAction->setData(pData, this->_iDataSlotId);
66 if(returnValue == TraversalValidator::Finished)
70 Int32 iPartBegin = pData->getPartitionRangeBegin();
71 Int32 iPartEnd = pData->getPartitionRangeEnd ();
73 while(iPartBegin <= iPartEnd)
75 pAction->readdPartitionByIndex(iPartBegin);
85 template <class ParentT> inline
86 typename StageHandlerMixin<ParentT>::ValidationStatus
87 StageHandlerMixin<ParentT>::validateOnLeave(
88 RenderActionBase *pAction)
90 return Self::validate(pAction);
93 template <class ParentT> inline
94 void StageHandlerMixin<ParentT>::pushPartition(
95 RenderActionBase *pAction,
97 RenderPartitionBase::Mode eMode)
100 pAction->template getData<StageData *>(this->_iDataSlotId);
102 pAction->pushPartition(uiCopyOnPush, eMode);
106 if(pData->getGroupMode() == NoPartitionGroup)
108 pData->setPartitionRangeBegin(pAction->getActivePartitionIdx());
114 template <class ParentT> inline
115 void StageHandlerMixin<ParentT>::popPartition(
116 RenderActionBase *pAction)
119 pAction->template getData<StageData *>(this->_iDataSlotId);
121 pAction->popPartition();
125 if(pData->getGroupMode() == NoPartitionGroup)
127 pData->setPartitionRangeEnd(pAction->getLastPartitionIdx());
132 template <class ParentT> inline
133 void StageHandlerMixin<ParentT>::beginPartitionGroup(
134 RenderActionBase *pAction)
137 pAction->template getData<StageData *>(this->_iDataSlotId);
141 pData->setGroupMode(InPartitionGroup);
144 pAction->beginPartitionGroup();
148 pData->setPartitionRangeBegin(pAction->getActivePartitionIdx());
152 template <class ParentT> inline
153 void StageHandlerMixin<ParentT>::endPartitionGroup(
154 RenderActionBase *pAction)
157 pAction->template getData<StageData *>(this->_iDataSlotId);
161 pData->setGroupMode(NoPartitionGroup);
164 pAction->endPartitionGroup();
168 pData->setPartitionRangeEnd(pAction->getLastPartitionIdx());
172 template <class ParentT> inline
173 void StageHandlerMixin<ParentT>::beginPartitions(
174 RenderActionBase *pAction)
177 pAction->template getData<StageData *>(this->_iDataSlotId);
181 pData->setGroupMode (InPartitionList );
182 pData->setPartitionRangeBegin(pAction->getLastPartitionIdx() + 1);
186 template <class ParentT> inline
187 void StageHandlerMixin<ParentT>::endPartitions(
188 RenderActionBase *pAction)
191 pAction->template getData<StageData *>(this->_iDataSlotId);
195 pData->setGroupMode (NoPartitionGroup );
196 pData->setPartitionRangeEnd(pAction->getLastPartitionIdx());
200 template <class ParentT> inline
201 void StageHandlerMixin<ParentT>::setData(
204 RenderActionBase *pAction)
206 StageData *pStoredData =
207 pAction->template getData<StageData *>(this->_iDataSlotId);
209 bool bCheckCallback = false;
211 OSG_ASSERT(iDataSlotId == this->_iDataSlotId);
213 if(pStoredData == NULL)
215 pAction->setData(pData, this->_iDataSlotId);
216 bCheckCallback = true;
218 else if(pStoredData != pData)
220 pData->copyFrom(pStoredData);
222 pAction->setData(pData, this->_iDataSlotId);
223 bCheckCallback = true;
226 if(bCheckCallback == true)
228 if(this->hasDestroyedFunctor(
229 boost::bind(&DataSlotHandler::clearData,
233 this->_iDataSlotId)) == false)
235 this->addDestroyedFunctor(
236 boost::bind(&DataSlotHandler::clearData,
237 static_cast<DataSlotHandler *>(pAction),
240 this->_iDataSlotId), "");
242 pAction->addDestroyedFunctorFor(
243 boost::bind(&Self::clearDestroyedFunctorFor,
251 this->addChangedFunctor(
252 boost::bind(&StageData::updateData,
259 pData->addChangedFunctor(
260 boost::bind(&Self::dataDestroyed,
267 if(pStoredData != NULL)
269 this->subChangedFunctor(
270 boost::bind(&StageData::updateData,
276 pStoredData->subChangedFunctor(
277 boost::bind(&Self::dataDestroyed,
286 /*-------------------------------------------------------------------------*/
289 /*-------------------------------------------------------------------------*/
292 /*-------------------------------------------------------------------------*/
296 /*-------------------------------------------------------------------------*/
299 template <class ParentT> inline
300 StageHandlerMixin<ParentT>::StageHandlerMixin(void) :
303 _tmpStatus = TraversalValidator::Finished;
306 template <class ParentT> inline
307 StageHandlerMixin<ParentT>::StageHandlerMixin(
308 const StageHandlerMixin &source) :
312 _tmpStatus = TraversalValidator::Finished;
315 template <class ParentT> inline
316 StageHandlerMixin<ParentT>::~StageHandlerMixin(void)
320 template <class ParentT> inline
321 void StageHandlerMixin<ParentT>::dataDestroyed(FieldContainer *pCore,
322 BitVector whichField,
325 if(whichField == 0x0000)
327 this->subChangedFunctor(
328 boost::bind(&StageData::updateData,
336 template <class ParentT> inline
337 void StageHandlerMixin<ParentT>::dump( UInt32 uiIndent,
338 const BitVector bvFlags ) const
342 /*-------------------------------------------------------------------------*/
345 /*-------------------------------------------------------------------------*/
348 template <class ParentT> inline
349 Action::ResultE StageHandlerMixin<ParentT>::recurseFromThis(Action *action)
351 Action::ResultE returnValue = Action::Continue;
353 Node *pActNode = action->getActNode ();
354 FieldContainer *pActParent = action->getActParent();
356 if(pActNode != pActParent)
358 OSG_ASSERT(pActParent == pActNode->getCore());
360 MultiCore *pCore = dynamic_cast<MultiCore *>(pActParent);
364 returnValue = action->recurseMultiCoreFrom(pActNode,
370 returnValue = action->recurseNoCallback(pActNode);
375 returnValue = action->recurseNoCallback(pActNode);
378 action->setActNode (pActNode );
379 action->setActParent(pActParent);
384 template <class ParentT> inline
385 Action::ResultE StageHandlerMixin<ParentT>::recurseFrom(Action *action,
388 Action::ResultE returnValue = Action::Continue;
390 Node *pActNode = action->getActNode ();
391 FieldContainer *pActParent = action->getActParent();
393 if(pActNode != pActParent)
395 OSG_ASSERT(pActParent == pActNode->getCore());
397 MultiCore *pCore = dynamic_cast<MultiCore *>(pActParent);
401 returnValue = action->recurseMultiCoreFrom(pActNode,
407 returnValue = action->recurseNoCallback(pActNode);
412 returnValue = action->recurseNoCallback(pActNode);
415 action->setActNode (pActNode );
416 action->setActParent(pActParent);
421 template <class ParentT> inline
422 Action::ResultE StageHandlerMixin<ParentT>::recurse(Action *action,
425 Node *pActNode = action->getActNode ();
426 FieldContainer *pActParent = action->getActParent();
428 Action::ResultE returnValue = action->recurse(node);
430 action->setActNode (pActNode );
431 action->setActParent(pActParent);
436 /*-------------------------------------------------------------------------*/