changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Skeleton / OSGSkinnedGeometryBase.cpp
blobfe280818f88d2487e77239a618eaf7c4fbbe2b18
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 SkinnedGeometry!
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 "OSGSkeleton.h" // Skeleton Class
66 #include "OSGSkinningAlgorithm.h" // SkinningAlgorithm Class
68 #include "OSGSkinnedGeometryBase.h"
69 #include "OSGSkinnedGeometry.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::SkinnedGeometry
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var Skeleton * SkinnedGeometryBase::_sfSkeleton
88 The Skeleton that deforms this geometry.
91 /*! \var Matrix SkinnedGeometryBase::_sfBindShapeMatrix
92 Matrix that is applied to the vertices of the mesh before deformation.
93 It transforms the vertices into bind space.
96 /*! \var Int16 SkinnedGeometryBase::_mfJointIds
97 List of jointIds that are used by this SkinnedGeometry.
100 /*! \var UInt16 SkinnedGeometryBase::_sfJointIndexProperty
101 Index of the property that stores the joint indices that influence
102 a vertex.
105 /*! \var UInt16 SkinnedGeometryBase::_sfJointWeightProperty
106 Index of the property that stores the joint weights that influence
107 a vertex.
110 /*! \var UInt32 SkinnedGeometryBase::_sfRenderMode
111 Mode used to render this skinned geometry, one of the RenderModeE
112 enums values. Effectively selects the SkinningAlgorithm to use.
115 /*! \var SkinningAlgorithm * SkinnedGeometryBase::_sfSkinningAlgorithm
120 /***************************************************************************\
121 * FieldType/FieldTrait Instantiation *
122 \***************************************************************************/
124 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
125 PointerType FieldTraits<SkinnedGeometry *, nsOSG>::_type(
126 "SkinnedGeometryPtr",
127 "GeometryPtr",
128 SkinnedGeometry::getClassType(),
129 nsOSG);
130 #endif
132 OSG_FIELDTRAITS_GETTYPE_NS(SkinnedGeometry *, nsOSG)
134 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
135 SkinnedGeometry *,
136 nsOSG)
138 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
139 SkinnedGeometry *,
140 nsOSG)
142 DataType &FieldTraits<SkinnedGeometry *, nsOSG + 1 >::getType(void)
144 return FieldTraits<SkinnedGeometry *, nsOSG>::getType();
148 OSG_SFIELDTYPE_INST(ParentPointerSField,
149 SkinnedGeometry *,
150 NoRefCountPolicy,
151 nsOSG + 1);
153 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
154 SkinnedGeometry *,
155 NoRefCountPolicy,
156 nsOSG + 1)
159 OSG_MFIELDTYPE_INST(ParentPointerMField,
160 SkinnedGeometry *,
161 NoRefCountPolicy,
164 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField,
165 SkinnedGeometry *,
166 NoRefCountPolicy,
170 /***************************************************************************\
171 * Field Description *
172 \***************************************************************************/
174 void SkinnedGeometryBase::classDescInserter(TypeObject &oType)
176 FieldDescriptionBase *pDesc = NULL;
179 pDesc = new SFUnrecSkeletonPtr::Description(
180 SFUnrecSkeletonPtr::getClassType(),
181 "skeleton",
182 "The Skeleton that deforms this geometry.\n",
183 SkeletonFieldId, SkeletonFieldMask,
184 false,
185 (Field::SFDefaultFlags | Field::FStdAccess),
186 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleSkeleton),
187 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleSkeleton));
189 oType.addInitialDesc(pDesc);
191 pDesc = new SFMatrix::Description(
192 SFMatrix::getClassType(),
193 "bindShapeMatrix",
194 "Matrix that is applied to the vertices of the mesh before deformation.\n"
195 "It transforms the vertices into bind space.\n",
196 BindShapeMatrixFieldId, BindShapeMatrixFieldMask,
197 false,
198 (Field::SFDefaultFlags | Field::FStdAccess),
199 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleBindShapeMatrix),
200 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleBindShapeMatrix));
202 oType.addInitialDesc(pDesc);
204 pDesc = new MFInt16::Description(
205 MFInt16::getClassType(),
206 "jointIds",
207 "List of jointIds that are used by this SkinnedGeometry.\n",
208 JointIdsFieldId, JointIdsFieldMask,
209 false,
210 (Field::MFDefaultFlags | Field::FStdAccess),
211 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleJointIds),
212 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleJointIds));
214 oType.addInitialDesc(pDesc);
216 pDesc = new SFUInt16::Description(
217 SFUInt16::getClassType(),
218 "jointIndexProperty",
219 "Index of the property that stores the joint indices that influence\n"
220 "a vertex.\n",
221 JointIndexPropertyFieldId, JointIndexPropertyFieldMask,
222 false,
223 (Field::SFDefaultFlags | Field::FStdAccess),
224 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleJointIndexProperty),
225 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleJointIndexProperty));
227 oType.addInitialDesc(pDesc);
229 pDesc = new SFUInt16::Description(
230 SFUInt16::getClassType(),
231 "jointWeightProperty",
232 "Index of the property that stores the joint weights that influence\n"
233 "a vertex.\n",
234 JointWeightPropertyFieldId, JointWeightPropertyFieldMask,
235 false,
236 (Field::SFDefaultFlags | Field::FStdAccess),
237 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleJointWeightProperty),
238 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleJointWeightProperty));
240 oType.addInitialDesc(pDesc);
242 pDesc = new SFUInt32::Description(
243 SFUInt32::getClassType(),
244 "renderMode",
245 "Mode used to render this skinned geometry, one of the RenderModeE\n"
246 "enums values. Effectively selects the SkinningAlgorithm to use.\n",
247 RenderModeFieldId, RenderModeFieldMask,
248 false,
249 (Field::SFDefaultFlags | Field::FStdAccess),
250 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleRenderMode),
251 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleRenderMode));
253 oType.addInitialDesc(pDesc);
255 pDesc = new SFUnrecChildSkinningAlgorithmPtr::Description(
256 SFUnrecChildSkinningAlgorithmPtr::getClassType(),
257 "skinningAlgorithm",
259 SkinningAlgorithmFieldId, SkinningAlgorithmFieldMask,
260 false,
261 (Field::SFDefaultFlags | Field::FStdAccess),
262 static_cast<FieldEditMethodSig>(&SkinnedGeometry::editHandleSkinningAlgorithm),
263 static_cast<FieldGetMethodSig >(&SkinnedGeometry::getHandleSkinningAlgorithm));
265 oType.addInitialDesc(pDesc);
269 SkinnedGeometryBase::TypeObject SkinnedGeometryBase::_type(
270 SkinnedGeometryBase::getClassname(),
271 Inherited::getClassname(),
272 "NULL",
273 nsOSG, //Namespace
274 reinterpret_cast<PrototypeCreateF>(&SkinnedGeometryBase::createEmptyLocal),
275 reinterpret_cast<InitContainerF>(&SkinnedGeometry::initMethod),
276 reinterpret_cast<ExitContainerF>(&SkinnedGeometry::exitMethod),
277 reinterpret_cast<InitalInsertDescFunc>(
278 reinterpret_cast<void *>(&SkinnedGeometry::classDescInserter)),
279 false,
281 "<?xml version=\"1.0\"?>\n"
282 "\n"
283 "<FieldContainer\n"
284 " name=\"SkinnedGeometry\"\n"
285 " parent=\"Geometry\"\n"
286 " library=\"Dynamics\"\n"
287 " pointerfieldtypes=\"both\"\n"
288 " structure=\"concrete\"\n"
289 " systemcomponent=\"true\"\n"
290 " parentsystemcomponent=\"true\"\n"
291 " decoratable=\"false\"\n"
292 " childFields=\"none\"\n"
293 " parentFields=\"both\"\n"
294 ">\n"
295 "\n"
296 " <Field\n"
297 " name=\"skeleton\"\n"
298 " type=\"Skeleton\"\n"
299 " category=\"pointer\"\n"
300 " cardinality=\"single\"\n"
301 " visibility=\"external\"\n"
302 " access=\"public\"\n"
303 " >\n"
304 " The Skeleton that deforms this geometry.\n"
305 " </Field>\n"
306 "\n"
307 " <Field\n"
308 " name=\"bindShapeMatrix\"\n"
309 " type=\"Matrix\"\n"
310 " category=\"data\"\n"
311 " cardinality=\"single\"\n"
312 " visibility=\"external\"\n"
313 " access=\"public\"\n"
314 " >\n"
315 " Matrix that is applied to the vertices of the mesh before deformation.\n"
316 " It transforms the vertices into bind space.\n"
317 " </Field>\n"
318 "\n"
319 " <Field\n"
320 " name=\"jointIds\"\n"
321 " type=\"Int16\"\n"
322 " category=\"data\"\n"
323 " cardinality=\"multi\"\n"
324 " visibility=\"external\"\n"
325 " access=\"public\"\n"
326 " >\n"
327 " List of jointIds that are used by this SkinnedGeometry.\n"
328 " </Field>\n"
329 "\n"
330 " <Field\n"
331 " name=\"jointIndexProperty\"\n"
332 " type=\"UInt16\"\n"
333 " category=\"data\"\n"
334 " cardinality=\"single\"\n"
335 " visibility=\"external\"\n"
336 " access=\"public\"\n"
337 " defaultValue=\"TypeTraits&lt;UInt16&gt;::getMax()\"\n"
338 " >\n"
339 " Index of the property that stores the joint indices that influence\n"
340 " a vertex.\n"
341 " </Field>\n"
342 " \n"
343 " <Field\n"
344 " name=\"jointWeightProperty\"\n"
345 " type=\"UInt16\"\n"
346 " category=\"data\"\n"
347 " cardinality=\"single\"\n"
348 " visibility=\"external\"\n"
349 " access=\"public\"\n"
350 " defaultValue=\"TypeTraits&lt;UInt16&gt;::getMax()\"\n"
351 " >\n"
352 " Index of the property that stores the joint weights that influence\n"
353 " a vertex.\n"
354 " </Field>\n"
355 "\n"
356 " <Field\n"
357 " name=\"renderMode\"\n"
358 " type=\"UInt32\"\n"
359 " category=\"data\"\n"
360 " cardinality=\"single\"\n"
361 " visibility=\"external\"\n"
362 " access=\"public\"\n"
363 " defaultValue=\"0\"\n"
364 " >\n"
365 " Mode used to render this skinned geometry, one of the RenderModeE\n"
366 " enums values. Effectively selects the SkinningAlgorithm to use.\n"
367 " </Field>\n"
368 "\n"
369 " <Field\n"
370 " name=\"skinningAlgorithm\"\n"
371 " type=\"SkinningAlgorithm\"\n"
372 " category=\"childpointer\"\n"
373 " linkParentField=\"Skin\"\n"
374 " cardinality=\"single\"\n"
375 " visibility=\"external\"\n"
376 " access=\"protected\"\n"
377 " defaultValue=\"NULL\"\n"
378 " >\n"
379 " </Field>\n"
380 "\n"
381 "</FieldContainer>\n",
385 /*------------------------------ get -----------------------------------*/
387 FieldContainerType &SkinnedGeometryBase::getType(void)
389 return _type;
392 const FieldContainerType &SkinnedGeometryBase::getType(void) const
394 return _type;
397 UInt32 SkinnedGeometryBase::getContainerSize(void) const
399 return sizeof(SkinnedGeometry);
402 /*------------------------- decorator get ------------------------------*/
405 //! Get the SkinnedGeometry::_sfSkeleton field.
406 const SFUnrecSkeletonPtr *SkinnedGeometryBase::getSFSkeleton(void) const
408 return &_sfSkeleton;
411 SFUnrecSkeletonPtr *SkinnedGeometryBase::editSFSkeleton (void)
413 editSField(SkeletonFieldMask);
415 return &_sfSkeleton;
418 //! Get the value of the SkinnedGeometry::_sfSkeleton field.
419 Skeleton * SkinnedGeometryBase::getSkeleton(void) const
421 return _sfSkeleton.getValue();
424 //! Set the value of the SkinnedGeometry::_sfSkeleton field.
425 void SkinnedGeometryBase::setSkeleton(Skeleton * const value)
427 editSField(SkeletonFieldMask);
429 _sfSkeleton.setValue(value);
433 SFMatrix *SkinnedGeometryBase::editSFBindShapeMatrix(void)
435 editSField(BindShapeMatrixFieldMask);
437 return &_sfBindShapeMatrix;
440 const SFMatrix *SkinnedGeometryBase::getSFBindShapeMatrix(void) const
442 return &_sfBindShapeMatrix;
446 MFInt16 *SkinnedGeometryBase::editMFJointIds(void)
448 editMField(JointIdsFieldMask, _mfJointIds);
450 return &_mfJointIds;
453 const MFInt16 *SkinnedGeometryBase::getMFJointIds(void) const
455 return &_mfJointIds;
459 SFUInt16 *SkinnedGeometryBase::editSFJointIndexProperty(void)
461 editSField(JointIndexPropertyFieldMask);
463 return &_sfJointIndexProperty;
466 const SFUInt16 *SkinnedGeometryBase::getSFJointIndexProperty(void) const
468 return &_sfJointIndexProperty;
472 SFUInt16 *SkinnedGeometryBase::editSFJointWeightProperty(void)
474 editSField(JointWeightPropertyFieldMask);
476 return &_sfJointWeightProperty;
479 const SFUInt16 *SkinnedGeometryBase::getSFJointWeightProperty(void) const
481 return &_sfJointWeightProperty;
485 SFUInt32 *SkinnedGeometryBase::editSFRenderMode(void)
487 editSField(RenderModeFieldMask);
489 return &_sfRenderMode;
492 const SFUInt32 *SkinnedGeometryBase::getSFRenderMode(void) const
494 return &_sfRenderMode;
498 //! Get the SkinnedGeometry::_sfSkinningAlgorithm field.
499 const SFUnrecChildSkinningAlgorithmPtr *SkinnedGeometryBase::getSFSkinningAlgorithm(void) const
501 return &_sfSkinningAlgorithm;
504 SFUnrecChildSkinningAlgorithmPtr *SkinnedGeometryBase::editSFSkinningAlgorithm(void)
506 editSField(SkinningAlgorithmFieldMask);
508 return &_sfSkinningAlgorithm;
511 //! Get the value of the SkinnedGeometry::_sfSkinningAlgorithm field.
512 SkinningAlgorithm * SkinnedGeometryBase::getSkinningAlgorithm(void) const
514 return _sfSkinningAlgorithm.getValue();
517 //! Set the value of the SkinnedGeometry::_sfSkinningAlgorithm field.
518 void SkinnedGeometryBase::setSkinningAlgorithm(SkinningAlgorithm * const value)
520 editSField(SkinningAlgorithmFieldMask);
522 _sfSkinningAlgorithm.setValue(value);
530 /*------------------------------ access -----------------------------------*/
532 SizeT SkinnedGeometryBase::getBinSize(ConstFieldMaskArg whichField)
534 SizeT returnValue = Inherited::getBinSize(whichField);
536 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
538 returnValue += _sfSkeleton.getBinSize();
540 if(FieldBits::NoField != (BindShapeMatrixFieldMask & whichField))
542 returnValue += _sfBindShapeMatrix.getBinSize();
544 if(FieldBits::NoField != (JointIdsFieldMask & whichField))
546 returnValue += _mfJointIds.getBinSize();
548 if(FieldBits::NoField != (JointIndexPropertyFieldMask & whichField))
550 returnValue += _sfJointIndexProperty.getBinSize();
552 if(FieldBits::NoField != (JointWeightPropertyFieldMask & whichField))
554 returnValue += _sfJointWeightProperty.getBinSize();
556 if(FieldBits::NoField != (RenderModeFieldMask & whichField))
558 returnValue += _sfRenderMode.getBinSize();
560 if(FieldBits::NoField != (SkinningAlgorithmFieldMask & whichField))
562 returnValue += _sfSkinningAlgorithm.getBinSize();
565 return returnValue;
568 void SkinnedGeometryBase::copyToBin(BinaryDataHandler &pMem,
569 ConstFieldMaskArg whichField)
571 Inherited::copyToBin(pMem, whichField);
573 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
575 _sfSkeleton.copyToBin(pMem);
577 if(FieldBits::NoField != (BindShapeMatrixFieldMask & whichField))
579 _sfBindShapeMatrix.copyToBin(pMem);
581 if(FieldBits::NoField != (JointIdsFieldMask & whichField))
583 _mfJointIds.copyToBin(pMem);
585 if(FieldBits::NoField != (JointIndexPropertyFieldMask & whichField))
587 _sfJointIndexProperty.copyToBin(pMem);
589 if(FieldBits::NoField != (JointWeightPropertyFieldMask & whichField))
591 _sfJointWeightProperty.copyToBin(pMem);
593 if(FieldBits::NoField != (RenderModeFieldMask & whichField))
595 _sfRenderMode.copyToBin(pMem);
597 if(FieldBits::NoField != (SkinningAlgorithmFieldMask & whichField))
599 _sfSkinningAlgorithm.copyToBin(pMem);
603 void SkinnedGeometryBase::copyFromBin(BinaryDataHandler &pMem,
604 ConstFieldMaskArg whichField)
606 Inherited::copyFromBin(pMem, whichField);
608 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
610 editSField(SkeletonFieldMask);
611 _sfSkeleton.copyFromBin(pMem);
613 if(FieldBits::NoField != (BindShapeMatrixFieldMask & whichField))
615 editSField(BindShapeMatrixFieldMask);
616 _sfBindShapeMatrix.copyFromBin(pMem);
618 if(FieldBits::NoField != (JointIdsFieldMask & whichField))
620 editMField(JointIdsFieldMask, _mfJointIds);
621 _mfJointIds.copyFromBin(pMem);
623 if(FieldBits::NoField != (JointIndexPropertyFieldMask & whichField))
625 editSField(JointIndexPropertyFieldMask);
626 _sfJointIndexProperty.copyFromBin(pMem);
628 if(FieldBits::NoField != (JointWeightPropertyFieldMask & whichField))
630 editSField(JointWeightPropertyFieldMask);
631 _sfJointWeightProperty.copyFromBin(pMem);
633 if(FieldBits::NoField != (RenderModeFieldMask & whichField))
635 editSField(RenderModeFieldMask);
636 _sfRenderMode.copyFromBin(pMem);
638 if(FieldBits::NoField != (SkinningAlgorithmFieldMask & whichField))
640 editSField(SkinningAlgorithmFieldMask);
641 _sfSkinningAlgorithm.copyFromBin(pMem);
645 //! create a new instance of the class
646 SkinnedGeometryTransitPtr SkinnedGeometryBase::createLocal(BitVector bFlags)
648 SkinnedGeometryTransitPtr fc;
650 if(getClassType().getPrototype() != NULL)
652 FieldContainerTransitPtr tmpPtr =
653 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
655 fc = dynamic_pointer_cast<SkinnedGeometry>(tmpPtr);
658 return fc;
661 //! create a new instance of the class, copy the container flags
662 SkinnedGeometryTransitPtr SkinnedGeometryBase::createDependent(BitVector bFlags)
664 SkinnedGeometryTransitPtr fc;
666 if(getClassType().getPrototype() != NULL)
668 FieldContainerTransitPtr tmpPtr =
669 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
671 fc = dynamic_pointer_cast<SkinnedGeometry>(tmpPtr);
674 return fc;
677 //! create a new instance of the class
678 SkinnedGeometryTransitPtr SkinnedGeometryBase::create(void)
680 SkinnedGeometryTransitPtr fc;
682 if(getClassType().getPrototype() != NULL)
684 FieldContainerTransitPtr tmpPtr =
685 getClassType().getPrototype()-> shallowCopy();
687 fc = dynamic_pointer_cast<SkinnedGeometry>(tmpPtr);
690 return fc;
693 SkinnedGeometry *SkinnedGeometryBase::createEmptyLocal(BitVector bFlags)
695 SkinnedGeometry *returnValue;
697 newPtr<SkinnedGeometry>(returnValue, bFlags);
699 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
701 return returnValue;
704 //! create an empty new instance of the class, do not copy the prototype
705 SkinnedGeometry *SkinnedGeometryBase::createEmpty(void)
707 SkinnedGeometry *returnValue;
709 newPtr<SkinnedGeometry>(returnValue, Thread::getCurrentLocalFlags());
711 returnValue->_pFieldFlags->_bNamespaceMask &=
712 ~Thread::getCurrentLocalFlags();
714 return returnValue;
718 FieldContainerTransitPtr SkinnedGeometryBase::shallowCopyLocal(
719 BitVector bFlags) const
721 SkinnedGeometry *tmpPtr;
723 newPtr(tmpPtr, dynamic_cast<const SkinnedGeometry *>(this), bFlags);
725 FieldContainerTransitPtr returnValue(tmpPtr);
727 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
729 return returnValue;
732 FieldContainerTransitPtr SkinnedGeometryBase::shallowCopyDependent(
733 BitVector bFlags) const
735 SkinnedGeometry *tmpPtr;
737 newPtr(tmpPtr, dynamic_cast<const SkinnedGeometry *>(this), ~bFlags);
739 FieldContainerTransitPtr returnValue(tmpPtr);
741 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
743 return returnValue;
746 FieldContainerTransitPtr SkinnedGeometryBase::shallowCopy(void) const
748 SkinnedGeometry *tmpPtr;
750 newPtr(tmpPtr,
751 dynamic_cast<const SkinnedGeometry *>(this),
752 Thread::getCurrentLocalFlags());
754 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
756 FieldContainerTransitPtr returnValue(tmpPtr);
758 return returnValue;
764 /*------------------------- constructors ----------------------------------*/
766 SkinnedGeometryBase::SkinnedGeometryBase(void) :
767 Inherited(),
768 _sfSkeleton (NULL),
769 _sfBindShapeMatrix (),
770 _mfJointIds (),
771 _sfJointIndexProperty (UInt16(TypeTraits<UInt16>::getMax())),
772 _sfJointWeightProperty (UInt16(TypeTraits<UInt16>::getMax())),
773 _sfRenderMode (UInt32(0)),
774 _sfSkinningAlgorithm (this,
775 SkinningAlgorithmFieldId,
776 SkinningAlgorithm::SkinFieldId)
780 SkinnedGeometryBase::SkinnedGeometryBase(const SkinnedGeometryBase &source) :
781 Inherited(source),
782 _sfSkeleton (NULL),
783 _sfBindShapeMatrix (source._sfBindShapeMatrix ),
784 _mfJointIds (source._mfJointIds ),
785 _sfJointIndexProperty (source._sfJointIndexProperty ),
786 _sfJointWeightProperty (source._sfJointWeightProperty ),
787 _sfRenderMode (source._sfRenderMode ),
788 _sfSkinningAlgorithm (this,
789 SkinningAlgorithmFieldId,
790 SkinningAlgorithm::SkinFieldId)
795 /*-------------------------- destructors ----------------------------------*/
797 SkinnedGeometryBase::~SkinnedGeometryBase(void)
801 /*-------------------------------------------------------------------------*/
802 /* Child linking */
804 bool SkinnedGeometryBase::unlinkChild(
805 FieldContainer * const pChild,
806 UInt16 const childFieldId)
808 if(childFieldId == SkinningAlgorithmFieldId)
810 SkinningAlgorithm * pTypedChild =
811 dynamic_cast<SkinningAlgorithm *>(pChild);
813 if(pTypedChild != NULL)
815 if(_sfSkinningAlgorithm.getValue() == pTypedChild)
817 editSField(SkinningAlgorithmFieldMask);
819 _sfSkinningAlgorithm.setValue(NULL);
821 return true;
824 SWARNING << "Parent ([" << this
825 << "] id [" << this->getId()
826 << "] type [" << this->getType().getCName()
827 << "] childFieldId [" << childFieldId
828 << "]) - Child ([" << pChild
829 << "] id [" << pChild->getId()
830 << "] type [" << pChild->getType().getCName()
831 << "]): link inconsistent!"
832 << std::endl;
834 return false;
837 return false;
841 return Inherited::unlinkChild(pChild, childFieldId);
844 void SkinnedGeometryBase::onCreate(const SkinnedGeometry *source)
846 Inherited::onCreate(source);
848 if(source != NULL)
850 SkinnedGeometry *pThis = static_cast<SkinnedGeometry *>(this);
852 pThis->setSkeleton(source->getSkeleton());
854 pThis->setSkinningAlgorithm(source->getSkinningAlgorithm());
858 GetFieldHandlePtr SkinnedGeometryBase::getHandleSkeleton (void) const
860 SFUnrecSkeletonPtr::GetHandlePtr returnValue(
861 new SFUnrecSkeletonPtr::GetHandle(
862 &_sfSkeleton,
863 this->getType().getFieldDesc(SkeletonFieldId),
864 const_cast<SkinnedGeometryBase *>(this)));
866 return returnValue;
869 EditFieldHandlePtr SkinnedGeometryBase::editHandleSkeleton (void)
871 SFUnrecSkeletonPtr::EditHandlePtr returnValue(
872 new SFUnrecSkeletonPtr::EditHandle(
873 &_sfSkeleton,
874 this->getType().getFieldDesc(SkeletonFieldId),
875 this));
877 returnValue->setSetMethod(
878 boost::bind(&SkinnedGeometry::setSkeleton,
879 static_cast<SkinnedGeometry *>(this), _1));
881 editSField(SkeletonFieldMask);
883 return returnValue;
886 GetFieldHandlePtr SkinnedGeometryBase::getHandleBindShapeMatrix (void) const
888 SFMatrix::GetHandlePtr returnValue(
889 new SFMatrix::GetHandle(
890 &_sfBindShapeMatrix,
891 this->getType().getFieldDesc(BindShapeMatrixFieldId),
892 const_cast<SkinnedGeometryBase *>(this)));
894 return returnValue;
897 EditFieldHandlePtr SkinnedGeometryBase::editHandleBindShapeMatrix(void)
899 SFMatrix::EditHandlePtr returnValue(
900 new SFMatrix::EditHandle(
901 &_sfBindShapeMatrix,
902 this->getType().getFieldDesc(BindShapeMatrixFieldId),
903 this));
906 editSField(BindShapeMatrixFieldMask);
908 return returnValue;
911 GetFieldHandlePtr SkinnedGeometryBase::getHandleJointIds (void) const
913 MFInt16::GetHandlePtr returnValue(
914 new MFInt16::GetHandle(
915 &_mfJointIds,
916 this->getType().getFieldDesc(JointIdsFieldId),
917 const_cast<SkinnedGeometryBase *>(this)));
919 return returnValue;
922 EditFieldHandlePtr SkinnedGeometryBase::editHandleJointIds (void)
924 MFInt16::EditHandlePtr returnValue(
925 new MFInt16::EditHandle(
926 &_mfJointIds,
927 this->getType().getFieldDesc(JointIdsFieldId),
928 this));
931 editMField(JointIdsFieldMask, _mfJointIds);
933 return returnValue;
936 GetFieldHandlePtr SkinnedGeometryBase::getHandleJointIndexProperty (void) const
938 SFUInt16::GetHandlePtr returnValue(
939 new SFUInt16::GetHandle(
940 &_sfJointIndexProperty,
941 this->getType().getFieldDesc(JointIndexPropertyFieldId),
942 const_cast<SkinnedGeometryBase *>(this)));
944 return returnValue;
947 EditFieldHandlePtr SkinnedGeometryBase::editHandleJointIndexProperty(void)
949 SFUInt16::EditHandlePtr returnValue(
950 new SFUInt16::EditHandle(
951 &_sfJointIndexProperty,
952 this->getType().getFieldDesc(JointIndexPropertyFieldId),
953 this));
956 editSField(JointIndexPropertyFieldMask);
958 return returnValue;
961 GetFieldHandlePtr SkinnedGeometryBase::getHandleJointWeightProperty (void) const
963 SFUInt16::GetHandlePtr returnValue(
964 new SFUInt16::GetHandle(
965 &_sfJointWeightProperty,
966 this->getType().getFieldDesc(JointWeightPropertyFieldId),
967 const_cast<SkinnedGeometryBase *>(this)));
969 return returnValue;
972 EditFieldHandlePtr SkinnedGeometryBase::editHandleJointWeightProperty(void)
974 SFUInt16::EditHandlePtr returnValue(
975 new SFUInt16::EditHandle(
976 &_sfJointWeightProperty,
977 this->getType().getFieldDesc(JointWeightPropertyFieldId),
978 this));
981 editSField(JointWeightPropertyFieldMask);
983 return returnValue;
986 GetFieldHandlePtr SkinnedGeometryBase::getHandleRenderMode (void) const
988 SFUInt32::GetHandlePtr returnValue(
989 new SFUInt32::GetHandle(
990 &_sfRenderMode,
991 this->getType().getFieldDesc(RenderModeFieldId),
992 const_cast<SkinnedGeometryBase *>(this)));
994 return returnValue;
997 EditFieldHandlePtr SkinnedGeometryBase::editHandleRenderMode (void)
999 SFUInt32::EditHandlePtr returnValue(
1000 new SFUInt32::EditHandle(
1001 &_sfRenderMode,
1002 this->getType().getFieldDesc(RenderModeFieldId),
1003 this));
1006 editSField(RenderModeFieldMask);
1008 return returnValue;
1011 GetFieldHandlePtr SkinnedGeometryBase::getHandleSkinningAlgorithm (void) const
1013 SFUnrecChildSkinningAlgorithmPtr::GetHandlePtr returnValue(
1014 new SFUnrecChildSkinningAlgorithmPtr::GetHandle(
1015 &_sfSkinningAlgorithm,
1016 this->getType().getFieldDesc(SkinningAlgorithmFieldId),
1017 const_cast<SkinnedGeometryBase *>(this)));
1019 return returnValue;
1022 EditFieldHandlePtr SkinnedGeometryBase::editHandleSkinningAlgorithm(void)
1024 SFUnrecChildSkinningAlgorithmPtr::EditHandlePtr returnValue(
1025 new SFUnrecChildSkinningAlgorithmPtr::EditHandle(
1026 &_sfSkinningAlgorithm,
1027 this->getType().getFieldDesc(SkinningAlgorithmFieldId),
1028 this));
1030 returnValue->setSetMethod(
1031 boost::bind(&SkinnedGeometry::setSkinningAlgorithm,
1032 static_cast<SkinnedGeometry *>(this), _1));
1034 editSField(SkinningAlgorithmFieldMask);
1036 return returnValue;
1040 #ifdef OSG_MT_CPTR_ASPECT
1041 void SkinnedGeometryBase::execSyncV( FieldContainer &oFrom,
1042 ConstFieldMaskArg whichField,
1043 AspectOffsetStore &oOffsets,
1044 ConstFieldMaskArg syncMode,
1045 const UInt32 uiSyncInfo)
1047 SkinnedGeometry *pThis = static_cast<SkinnedGeometry *>(this);
1049 pThis->execSync(static_cast<SkinnedGeometry *>(&oFrom),
1050 whichField,
1051 oOffsets,
1052 syncMode,
1053 uiSyncInfo);
1055 #endif
1058 #ifdef OSG_MT_CPTR_ASPECT
1059 FieldContainer *SkinnedGeometryBase::createAspectCopy(
1060 const FieldContainer *pRefAspect) const
1062 SkinnedGeometry *returnValue;
1064 newAspectCopy(returnValue,
1065 dynamic_cast<const SkinnedGeometry *>(pRefAspect),
1066 dynamic_cast<const SkinnedGeometry *>(this));
1068 return returnValue;
1070 #endif
1072 void SkinnedGeometryBase::resolveLinks(void)
1074 Inherited::resolveLinks();
1076 static_cast<SkinnedGeometry *>(this)->setSkeleton(NULL);
1078 static_cast<SkinnedGeometry *>(this)->setSkinningAlgorithm(NULL);
1080 #ifdef OSG_MT_CPTR_ASPECT
1081 AspectOffsetStore oOffsets;
1083 _pAspectStore->fillOffsetArray(oOffsets, this);
1084 #endif
1086 #ifdef OSG_MT_CPTR_ASPECT
1087 _mfJointIds.terminateShare(Thread::getCurrentAspect(),
1088 oOffsets);
1089 #endif
1093 OSG_END_NAMESPACE