changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Light / Shadow / Base / OSGShadowMapEngineBase.cpp
blob039f0e169fa1c5637d1fef2338dafb5e8686751f
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ShadowMapEngine!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGTextureObjChunk.h" // ShadowTexChunk Class
67 #include "OSGShadowMapEngineBase.h"
68 #include "OSGShadowMapEngine.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::ShadowMapEngine
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var TextureObjChunk * ShadowMapEngineBase::_sfShadowTexChunk
87 Holds the generated shadow texture. If you leave this field empty an
88 appropriate object will be created the first time the engine runs.
91 /*! \var Int32 ShadowMapEngineBase::_sfWidth
95 /*! \var Int32 ShadowMapEngineBase::_sfHeight
99 /*! \var Real32 ShadowMapEngineBase::_sfOffsetBias
103 /*! \var Real32 ShadowMapEngineBase::_sfOffsetFactor
107 /*! \var UInt32 ShadowMapEngineBase::_sfShadowTravMask
108 Traversal mask when generating the shadow map.
112 /***************************************************************************\
113 * FieldType/FieldTrait Instantiation *
114 \***************************************************************************/
116 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
117 PointerType FieldTraits<ShadowMapEngine *, nsOSG>::_type(
118 "ShadowMapEnginePtr",
119 "LightEnginePtr",
120 ShadowMapEngine::getClassType(),
121 nsOSG);
122 #endif
124 OSG_FIELDTRAITS_GETTYPE_NS(ShadowMapEngine *, nsOSG)
126 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
127 ShadowMapEngine *,
128 nsOSG)
130 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
131 ShadowMapEngine *,
132 nsOSG)
134 /***************************************************************************\
135 * Field Description *
136 \***************************************************************************/
138 void ShadowMapEngineBase::classDescInserter(TypeObject &oType)
140 Inherited::classDescInserter(oType);
142 FieldDescriptionBase *pDesc = NULL;
145 pDesc = new SFUnrecTextureObjChunkPtr::Description(
146 SFUnrecTextureObjChunkPtr::getClassType(),
147 "shadowTexChunk",
148 "Holds the generated shadow texture. If you leave this field empty an\n"
149 "appropriate object will be created the first time the engine runs.\n",
150 ShadowTexChunkFieldId, ShadowTexChunkFieldMask,
151 false,
152 (Field::SFDefaultFlags | Field::FStdAccess),
153 static_cast<FieldEditMethodSig>(&ShadowMapEngine::editHandleShadowTexChunk),
154 static_cast<FieldGetMethodSig >(&ShadowMapEngine::getHandleShadowTexChunk));
156 oType.addInitialDesc(pDesc);
158 pDesc = new SFInt32::Description(
159 SFInt32::getClassType(),
160 "width",
162 WidthFieldId, WidthFieldMask,
163 false,
164 (Field::SFDefaultFlags | Field::FStdAccess),
165 static_cast<FieldEditMethodSig>(&ShadowMapEngine::editHandleWidth),
166 static_cast<FieldGetMethodSig >(&ShadowMapEngine::getHandleWidth));
168 oType.addInitialDesc(pDesc);
170 pDesc = new SFInt32::Description(
171 SFInt32::getClassType(),
172 "height",
174 HeightFieldId, HeightFieldMask,
175 false,
176 (Field::SFDefaultFlags | Field::FStdAccess),
177 static_cast<FieldEditMethodSig>(&ShadowMapEngine::editHandleHeight),
178 static_cast<FieldGetMethodSig >(&ShadowMapEngine::getHandleHeight));
180 oType.addInitialDesc(pDesc);
182 pDesc = new SFReal32::Description(
183 SFReal32::getClassType(),
184 "offsetBias",
186 OffsetBiasFieldId, OffsetBiasFieldMask,
187 false,
188 (Field::SFDefaultFlags | Field::FStdAccess),
189 static_cast<FieldEditMethodSig>(&ShadowMapEngine::editHandleOffsetBias),
190 static_cast<FieldGetMethodSig >(&ShadowMapEngine::getHandleOffsetBias));
192 oType.addInitialDesc(pDesc);
194 pDesc = new SFReal32::Description(
195 SFReal32::getClassType(),
196 "offsetFactor",
198 OffsetFactorFieldId, OffsetFactorFieldMask,
199 false,
200 (Field::SFDefaultFlags | Field::FStdAccess),
201 static_cast<FieldEditMethodSig>(&ShadowMapEngine::editHandleOffsetFactor),
202 static_cast<FieldGetMethodSig >(&ShadowMapEngine::getHandleOffsetFactor));
204 oType.addInitialDesc(pDesc);
206 pDesc = new SFUInt32::Description(
207 SFUInt32::getClassType(),
208 "shadowTravMask",
209 "Traversal mask when generating the shadow map. \n",
210 ShadowTravMaskFieldId, ShadowTravMaskFieldMask,
211 false,
212 (Field::SFDefaultFlags | Field::FStdAccess),
213 static_cast<FieldEditMethodSig>(&ShadowMapEngine::editHandleShadowTravMask),
214 static_cast<FieldGetMethodSig >(&ShadowMapEngine::getHandleShadowTravMask));
216 oType.addInitialDesc(pDesc);
220 ShadowMapEngineBase::TypeObject ShadowMapEngineBase::_type(
221 ShadowMapEngineBase::getClassname(),
222 Inherited::getClassname(),
223 "NULL",
224 nsOSG, //Namespace
225 NULL,
226 reinterpret_cast<InitContainerF>(&ShadowMapEngine::initMethod),
227 reinterpret_cast<ExitContainerF>(&ShadowMapEngine::exitMethod),
228 reinterpret_cast<InitalInsertDescFunc>(
229 reinterpret_cast<void *>(&ShadowMapEngine::classDescInserter)),
230 false,
232 "<?xml version=\"1.0\" ?>\n"
233 "\n"
234 "<FieldContainer\n"
235 " name=\"ShadowMapEngine\"\n"
236 " parent=\"LightEngine\"\n"
237 " mixinparent=\"ShadowMapEngineParent\"\n"
238 " library=\"Group\"\n"
239 " structure=\"abstract\"\n"
240 " pointerfieldtypes=\"both\"\n"
241 " systemcomponent=\"true\"\n"
242 " parentsystemcomponent=\"true\"\n"
243 " isNodeCore=\"false\"\n"
244 " docGroupBase=\"GrpGroupLightShadowBase\"\n"
245 " >\n"
246 " <Field\n"
247 " name=\"shadowTexChunk\"\n"
248 " category=\"pointer\"\n"
249 " type=\"TextureObjChunk\"\n"
250 " cardinality=\"single\"\n"
251 " visibility=\"external\"\n"
252 " defaultValue=\"NULL\"\n"
253 " access=\"public\"\n"
254 " >\n"
255 " Holds the generated shadow texture. If you leave this field empty an\n"
256 " appropriate object will be created the first time the engine runs.\n"
257 " </Field>\n"
258 " <Field\n"
259 "\t name=\"width\"\n"
260 "\t type=\"Int32\"\n"
261 "\t cardinality=\"single\"\n"
262 "\t visibility=\"external\"\n"
263 "\t defaultValue=\"512\"\n"
264 "\t access=\"public\"\n"
265 "\t >\n"
266 " </Field>\n"
267 " <Field\n"
268 "\t name=\"height\"\n"
269 "\t type=\"Int32\"\n"
270 "\t cardinality=\"single\"\n"
271 "\t visibility=\"external\"\n"
272 "\t defaultValue=\"512\"\n"
273 "\t access=\"public\"\n"
274 "\t >\n"
275 " </Field>\n"
276 " <Field\n"
277 "\t name=\"offsetBias\"\n"
278 "\t type=\"Real32\"\n"
279 "\t cardinality=\"single\"\n"
280 "\t visibility=\"external\"\n"
281 "\t defaultValue=\"4.f\"\n"
282 "\t access=\"public\"\n"
283 "\t >\n"
284 " </Field>\n"
285 " <Field\n"
286 "\t name=\"offsetFactor\"\n"
287 "\t type=\"Real32\"\n"
288 "\t cardinality=\"single\"\n"
289 "\t visibility=\"external\"\n"
290 "\t defaultValue=\"10.f\"\n"
291 "\t access=\"public\"\n"
292 "\t >\n"
293 " </Field>\n"
294 " <Field\n"
295 " name=\"shadowTravMask\"\n"
296 " type=\"UInt32\"\n"
297 " cardinality=\"single\"\n"
298 " visibility=\"external\"\n"
299 " defaultValue=\"TypeTraits&lt;UInt32&gt;::BitsSet\"\n"
300 " access=\"public\"\n"
301 " >\n"
302 " Traversal mask when generating the shadow map. \n"
303 " </Field>\n"
304 "</FieldContainer>\n",
308 /*------------------------------ get -----------------------------------*/
310 FieldContainerType &ShadowMapEngineBase::getType(void)
312 return _type;
315 const FieldContainerType &ShadowMapEngineBase::getType(void) const
317 return _type;
320 UInt32 ShadowMapEngineBase::getContainerSize(void) const
322 return sizeof(ShadowMapEngine);
325 /*------------------------- decorator get ------------------------------*/
328 //! Get the ShadowMapEngine::_sfShadowTexChunk field.
329 const SFUnrecTextureObjChunkPtr *ShadowMapEngineBase::getSFShadowTexChunk(void) const
331 return &_sfShadowTexChunk;
334 SFUnrecTextureObjChunkPtr *ShadowMapEngineBase::editSFShadowTexChunk (void)
336 editSField(ShadowTexChunkFieldMask);
338 return &_sfShadowTexChunk;
341 //! Get the value of the ShadowMapEngine::_sfShadowTexChunk field.
342 TextureObjChunk * ShadowMapEngineBase::getShadowTexChunk(void) const
344 return _sfShadowTexChunk.getValue();
347 //! Set the value of the ShadowMapEngine::_sfShadowTexChunk field.
348 void ShadowMapEngineBase::setShadowTexChunk(TextureObjChunk * const value)
350 editSField(ShadowTexChunkFieldMask);
352 _sfShadowTexChunk.setValue(value);
356 SFInt32 *ShadowMapEngineBase::editSFWidth(void)
358 editSField(WidthFieldMask);
360 return &_sfWidth;
363 const SFInt32 *ShadowMapEngineBase::getSFWidth(void) const
365 return &_sfWidth;
369 SFInt32 *ShadowMapEngineBase::editSFHeight(void)
371 editSField(HeightFieldMask);
373 return &_sfHeight;
376 const SFInt32 *ShadowMapEngineBase::getSFHeight(void) const
378 return &_sfHeight;
382 SFReal32 *ShadowMapEngineBase::editSFOffsetBias(void)
384 editSField(OffsetBiasFieldMask);
386 return &_sfOffsetBias;
389 const SFReal32 *ShadowMapEngineBase::getSFOffsetBias(void) const
391 return &_sfOffsetBias;
395 SFReal32 *ShadowMapEngineBase::editSFOffsetFactor(void)
397 editSField(OffsetFactorFieldMask);
399 return &_sfOffsetFactor;
402 const SFReal32 *ShadowMapEngineBase::getSFOffsetFactor(void) const
404 return &_sfOffsetFactor;
408 SFUInt32 *ShadowMapEngineBase::editSFShadowTravMask(void)
410 editSField(ShadowTravMaskFieldMask);
412 return &_sfShadowTravMask;
415 const SFUInt32 *ShadowMapEngineBase::getSFShadowTravMask(void) const
417 return &_sfShadowTravMask;
425 /*------------------------------ access -----------------------------------*/
427 SizeT ShadowMapEngineBase::getBinSize(ConstFieldMaskArg whichField)
429 SizeT returnValue = Inherited::getBinSize(whichField);
431 if(FieldBits::NoField != (ShadowTexChunkFieldMask & whichField))
433 returnValue += _sfShadowTexChunk.getBinSize();
435 if(FieldBits::NoField != (WidthFieldMask & whichField))
437 returnValue += _sfWidth.getBinSize();
439 if(FieldBits::NoField != (HeightFieldMask & whichField))
441 returnValue += _sfHeight.getBinSize();
443 if(FieldBits::NoField != (OffsetBiasFieldMask & whichField))
445 returnValue += _sfOffsetBias.getBinSize();
447 if(FieldBits::NoField != (OffsetFactorFieldMask & whichField))
449 returnValue += _sfOffsetFactor.getBinSize();
451 if(FieldBits::NoField != (ShadowTravMaskFieldMask & whichField))
453 returnValue += _sfShadowTravMask.getBinSize();
456 return returnValue;
459 void ShadowMapEngineBase::copyToBin(BinaryDataHandler &pMem,
460 ConstFieldMaskArg whichField)
462 Inherited::copyToBin(pMem, whichField);
464 if(FieldBits::NoField != (ShadowTexChunkFieldMask & whichField))
466 _sfShadowTexChunk.copyToBin(pMem);
468 if(FieldBits::NoField != (WidthFieldMask & whichField))
470 _sfWidth.copyToBin(pMem);
472 if(FieldBits::NoField != (HeightFieldMask & whichField))
474 _sfHeight.copyToBin(pMem);
476 if(FieldBits::NoField != (OffsetBiasFieldMask & whichField))
478 _sfOffsetBias.copyToBin(pMem);
480 if(FieldBits::NoField != (OffsetFactorFieldMask & whichField))
482 _sfOffsetFactor.copyToBin(pMem);
484 if(FieldBits::NoField != (ShadowTravMaskFieldMask & whichField))
486 _sfShadowTravMask.copyToBin(pMem);
490 void ShadowMapEngineBase::copyFromBin(BinaryDataHandler &pMem,
491 ConstFieldMaskArg whichField)
493 Inherited::copyFromBin(pMem, whichField);
495 if(FieldBits::NoField != (ShadowTexChunkFieldMask & whichField))
497 editSField(ShadowTexChunkFieldMask);
498 _sfShadowTexChunk.copyFromBin(pMem);
500 if(FieldBits::NoField != (WidthFieldMask & whichField))
502 editSField(WidthFieldMask);
503 _sfWidth.copyFromBin(pMem);
505 if(FieldBits::NoField != (HeightFieldMask & whichField))
507 editSField(HeightFieldMask);
508 _sfHeight.copyFromBin(pMem);
510 if(FieldBits::NoField != (OffsetBiasFieldMask & whichField))
512 editSField(OffsetBiasFieldMask);
513 _sfOffsetBias.copyFromBin(pMem);
515 if(FieldBits::NoField != (OffsetFactorFieldMask & whichField))
517 editSField(OffsetFactorFieldMask);
518 _sfOffsetFactor.copyFromBin(pMem);
520 if(FieldBits::NoField != (ShadowTravMaskFieldMask & whichField))
522 editSField(ShadowTravMaskFieldMask);
523 _sfShadowTravMask.copyFromBin(pMem);
530 /*------------------------- constructors ----------------------------------*/
532 ShadowMapEngineBase::ShadowMapEngineBase(void) :
533 Inherited(),
534 _sfShadowTexChunk (NULL),
535 _sfWidth (Int32(512)),
536 _sfHeight (Int32(512)),
537 _sfOffsetBias (Real32(4.f)),
538 _sfOffsetFactor (Real32(10.f)),
539 _sfShadowTravMask (UInt32(TypeTraits<UInt32>::BitsSet))
543 ShadowMapEngineBase::ShadowMapEngineBase(const ShadowMapEngineBase &source) :
544 Inherited(source),
545 _sfShadowTexChunk (NULL),
546 _sfWidth (source._sfWidth ),
547 _sfHeight (source._sfHeight ),
548 _sfOffsetBias (source._sfOffsetBias ),
549 _sfOffsetFactor (source._sfOffsetFactor ),
550 _sfShadowTravMask (source._sfShadowTravMask )
555 /*-------------------------- destructors ----------------------------------*/
557 ShadowMapEngineBase::~ShadowMapEngineBase(void)
561 void ShadowMapEngineBase::onCreate(const ShadowMapEngine *source)
563 Inherited::onCreate(source);
565 if(source != NULL)
567 ShadowMapEngine *pThis = static_cast<ShadowMapEngine *>(this);
569 pThis->setShadowTexChunk(source->getShadowTexChunk());
573 GetFieldHandlePtr ShadowMapEngineBase::getHandleShadowTexChunk (void) const
575 SFUnrecTextureObjChunkPtr::GetHandlePtr returnValue(
576 new SFUnrecTextureObjChunkPtr::GetHandle(
577 &_sfShadowTexChunk,
578 this->getType().getFieldDesc(ShadowTexChunkFieldId),
579 const_cast<ShadowMapEngineBase *>(this)));
581 return returnValue;
584 EditFieldHandlePtr ShadowMapEngineBase::editHandleShadowTexChunk (void)
586 SFUnrecTextureObjChunkPtr::EditHandlePtr returnValue(
587 new SFUnrecTextureObjChunkPtr::EditHandle(
588 &_sfShadowTexChunk,
589 this->getType().getFieldDesc(ShadowTexChunkFieldId),
590 this));
592 returnValue->setSetMethod(
593 boost::bind(&ShadowMapEngine::setShadowTexChunk,
594 static_cast<ShadowMapEngine *>(this), _1));
596 editSField(ShadowTexChunkFieldMask);
598 return returnValue;
601 GetFieldHandlePtr ShadowMapEngineBase::getHandleWidth (void) const
603 SFInt32::GetHandlePtr returnValue(
604 new SFInt32::GetHandle(
605 &_sfWidth,
606 this->getType().getFieldDesc(WidthFieldId),
607 const_cast<ShadowMapEngineBase *>(this)));
609 return returnValue;
612 EditFieldHandlePtr ShadowMapEngineBase::editHandleWidth (void)
614 SFInt32::EditHandlePtr returnValue(
615 new SFInt32::EditHandle(
616 &_sfWidth,
617 this->getType().getFieldDesc(WidthFieldId),
618 this));
621 editSField(WidthFieldMask);
623 return returnValue;
626 GetFieldHandlePtr ShadowMapEngineBase::getHandleHeight (void) const
628 SFInt32::GetHandlePtr returnValue(
629 new SFInt32::GetHandle(
630 &_sfHeight,
631 this->getType().getFieldDesc(HeightFieldId),
632 const_cast<ShadowMapEngineBase *>(this)));
634 return returnValue;
637 EditFieldHandlePtr ShadowMapEngineBase::editHandleHeight (void)
639 SFInt32::EditHandlePtr returnValue(
640 new SFInt32::EditHandle(
641 &_sfHeight,
642 this->getType().getFieldDesc(HeightFieldId),
643 this));
646 editSField(HeightFieldMask);
648 return returnValue;
651 GetFieldHandlePtr ShadowMapEngineBase::getHandleOffsetBias (void) const
653 SFReal32::GetHandlePtr returnValue(
654 new SFReal32::GetHandle(
655 &_sfOffsetBias,
656 this->getType().getFieldDesc(OffsetBiasFieldId),
657 const_cast<ShadowMapEngineBase *>(this)));
659 return returnValue;
662 EditFieldHandlePtr ShadowMapEngineBase::editHandleOffsetBias (void)
664 SFReal32::EditHandlePtr returnValue(
665 new SFReal32::EditHandle(
666 &_sfOffsetBias,
667 this->getType().getFieldDesc(OffsetBiasFieldId),
668 this));
671 editSField(OffsetBiasFieldMask);
673 return returnValue;
676 GetFieldHandlePtr ShadowMapEngineBase::getHandleOffsetFactor (void) const
678 SFReal32::GetHandlePtr returnValue(
679 new SFReal32::GetHandle(
680 &_sfOffsetFactor,
681 this->getType().getFieldDesc(OffsetFactorFieldId),
682 const_cast<ShadowMapEngineBase *>(this)));
684 return returnValue;
687 EditFieldHandlePtr ShadowMapEngineBase::editHandleOffsetFactor (void)
689 SFReal32::EditHandlePtr returnValue(
690 new SFReal32::EditHandle(
691 &_sfOffsetFactor,
692 this->getType().getFieldDesc(OffsetFactorFieldId),
693 this));
696 editSField(OffsetFactorFieldMask);
698 return returnValue;
701 GetFieldHandlePtr ShadowMapEngineBase::getHandleShadowTravMask (void) const
703 SFUInt32::GetHandlePtr returnValue(
704 new SFUInt32::GetHandle(
705 &_sfShadowTravMask,
706 this->getType().getFieldDesc(ShadowTravMaskFieldId),
707 const_cast<ShadowMapEngineBase *>(this)));
709 return returnValue;
712 EditFieldHandlePtr ShadowMapEngineBase::editHandleShadowTravMask (void)
714 SFUInt32::EditHandlePtr returnValue(
715 new SFUInt32::EditHandle(
716 &_sfShadowTravMask,
717 this->getType().getFieldDesc(ShadowTravMaskFieldId),
718 this));
721 editSField(ShadowTravMaskFieldMask);
723 return returnValue;
727 #ifdef OSG_MT_CPTR_ASPECT
728 void ShadowMapEngineBase::execSyncV( FieldContainer &oFrom,
729 ConstFieldMaskArg whichField,
730 AspectOffsetStore &oOffsets,
731 ConstFieldMaskArg syncMode,
732 const UInt32 uiSyncInfo)
734 ShadowMapEngine *pThis = static_cast<ShadowMapEngine *>(this);
736 pThis->execSync(static_cast<ShadowMapEngine *>(&oFrom),
737 whichField,
738 oOffsets,
739 syncMode,
740 uiSyncInfo);
742 #endif
746 void ShadowMapEngineBase::resolveLinks(void)
748 Inherited::resolveLinks();
750 static_cast<ShadowMapEngine *>(this)->setShadowTexChunk(NULL);
756 OSG_END_NAMESPACE