changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Skeleton / OSGSkeletonJointBase.cpp
blob085fb0ac38d9299b8bb6792e8420ec6b6ce7b9a4
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 SkeletonJoint!
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"
66 #include "OSGSkeletonJointBase.h"
67 #include "OSGSkeletonJoint.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::SkeletonJoint
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var Matrix SkeletonJointBase::_sfInvBindMatrix
86 Inverse of the bind matrix for this joint.
89 /*! \var Matrix SkeletonJointBase::_sfMatrix
90 Transformation matrix of this joint.
93 /*! \var Matrix SkeletonJointBase::_sfOffsetMatrix
94 Transformation matrix of this joint.
98 /***************************************************************************\
99 * FieldType/FieldTrait Instantiation *
100 \***************************************************************************/
102 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
103 PointerType FieldTraits<SkeletonJoint *, nsOSG>::_type(
104 "SkeletonJointPtr",
105 "BaseSkeletonJointPtr",
106 SkeletonJoint::getClassType(),
107 nsOSG);
108 #endif
110 OSG_FIELDTRAITS_GETTYPE_NS(SkeletonJoint *, nsOSG)
112 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
113 SkeletonJoint *,
114 nsOSG)
116 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
117 SkeletonJoint *,
118 nsOSG)
120 DataType &FieldTraits< SkeletonJoint *, nsOSG + 1 >::getType(void)
122 return FieldTraits<SkeletonJoint *, nsOSG>::getType();
126 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
127 SkeletonJoint *,
128 UnrecordedRefCountPolicy,
129 nsOSG + 1)
132 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
133 SkeletonJoint *,
134 UnrecordedRefCountPolicy,
135 nsOSG + 1)
138 DataType &FieldTraits<SkeletonJoint *, nsOSG + 2 >::getType(void)
140 return FieldTraits<SkeletonJoint *, nsOSG>::getType();
144 OSG_SFIELDTYPE_INST(ParentPointerSField,
145 SkeletonJoint *,
146 NoRefCountPolicy,
147 nsOSG + 2);
149 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
150 SkeletonJoint *,
151 NoRefCountPolicy,
152 nsOSG + 2)
155 OSG_MFIELDTYPE_INST(ParentPointerMField,
156 SkeletonJoint *,
157 NoRefCountPolicy,
160 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField,
161 SkeletonJoint *,
162 NoRefCountPolicy,
166 /***************************************************************************\
167 * Field Description *
168 \***************************************************************************/
170 void SkeletonJointBase::classDescInserter(TypeObject &oType)
172 FieldDescriptionBase *pDesc = NULL;
175 pDesc = new SFMatrix::Description(
176 SFMatrix::getClassType(),
177 "invBindMatrix",
178 "Inverse of the bind matrix for this joint.\n",
179 InvBindMatrixFieldId, InvBindMatrixFieldMask,
180 false,
181 (Field::SFDefaultFlags | Field::FStdAccess),
182 static_cast<FieldEditMethodSig>(&SkeletonJoint::editHandleInvBindMatrix),
183 static_cast<FieldGetMethodSig >(&SkeletonJoint::getHandleInvBindMatrix));
185 oType.addInitialDesc(pDesc);
187 pDesc = new SFMatrix::Description(
188 SFMatrix::getClassType(),
189 "matrix",
190 "Transformation matrix of this joint.\n",
191 MatrixFieldId, MatrixFieldMask,
192 false,
193 (Field::SFDefaultFlags | Field::FStdAccess),
194 static_cast<FieldEditMethodSig>(&SkeletonJoint::editHandleMatrix),
195 static_cast<FieldGetMethodSig >(&SkeletonJoint::getHandleMatrix));
197 oType.addInitialDesc(pDesc);
199 pDesc = new SFMatrix::Description(
200 SFMatrix::getClassType(),
201 "offsetMatrix",
202 "Transformation matrix of this joint.\n",
203 OffsetMatrixFieldId, OffsetMatrixFieldMask,
204 false,
205 (Field::SFDefaultFlags | Field::FStdAccess),
206 static_cast<FieldEditMethodSig>(&SkeletonJoint::editHandleOffsetMatrix),
207 static_cast<FieldGetMethodSig >(&SkeletonJoint::getHandleOffsetMatrix));
209 oType.addInitialDesc(pDesc);
213 SkeletonJointBase::TypeObject SkeletonJointBase::_type(
214 SkeletonJointBase::getClassname(),
215 Inherited::getClassname(),
216 "NULL",
217 nsOSG, //Namespace
218 reinterpret_cast<PrototypeCreateF>(&SkeletonJointBase::createEmptyLocal),
219 reinterpret_cast<InitContainerF>(&SkeletonJoint::initMethod),
220 reinterpret_cast<ExitContainerF>(&SkeletonJoint::exitMethod),
221 reinterpret_cast<InitalInsertDescFunc>(
222 reinterpret_cast<void *>(&SkeletonJoint::classDescInserter)),
223 false,
225 "<?xml version=\"1.0\"?>\n"
226 "\n"
227 "<FieldContainer\n"
228 " name=\"SkeletonJoint\"\n"
229 " parent=\"BaseSkeletonJoint\"\n"
230 " library=\"Dynamics\"\n"
231 " pointerfieldtypes=\"both\"\n"
232 " structure=\"concrete\"\n"
233 " systemcomponent=\"true\"\n"
234 " parentsystemcomponent=\"true\"\n"
235 " decoratable=\"false\"\n"
236 " isNodeCore=\"false\"\n"
237 " childFields=\"both\"\n"
238 " parentFields=\"both\"\n"
239 ">\n"
240 " <Field\n"
241 " name=\"invBindMatrix\"\n"
242 " type=\"Matrix\"\n"
243 " category=\"data\"\n"
244 " cardinality=\"single\"\n"
245 " visibility=\"external\"\n"
246 " access=\"public\"\n"
247 " >\n"
248 " Inverse of the bind matrix for this joint.\n"
249 " </Field>\n"
250 "\n"
251 " <Field\n"
252 " name=\"matrix\"\n"
253 " type=\"Matrix\"\n"
254 " category=\"data\"\n"
255 " cardinality=\"single\"\n"
256 " visibility=\"external\"\n"
257 " access=\"public\"\n"
258 " >\n"
259 " Transformation matrix of this joint.\n"
260 " </Field>\n"
261 "\n"
262 " <Field\n"
263 " name=\"offsetMatrix\"\n"
264 " type=\"Matrix\"\n"
265 " category=\"data\"\n"
266 " cardinality=\"single\"\n"
267 " visibility=\"external\"\n"
268 " access=\"public\"\n"
269 " >\n"
270 " Transformation matrix of this joint.\n"
271 " </Field>\n"
272 "\n"
273 "</FieldContainer>\n",
277 /*------------------------------ get -----------------------------------*/
279 FieldContainerType &SkeletonJointBase::getType(void)
281 return _type;
284 const FieldContainerType &SkeletonJointBase::getType(void) const
286 return _type;
289 UInt32 SkeletonJointBase::getContainerSize(void) const
291 return sizeof(SkeletonJoint);
294 /*------------------------- decorator get ------------------------------*/
297 SFMatrix *SkeletonJointBase::editSFInvBindMatrix(void)
299 editSField(InvBindMatrixFieldMask);
301 return &_sfInvBindMatrix;
304 const SFMatrix *SkeletonJointBase::getSFInvBindMatrix(void) const
306 return &_sfInvBindMatrix;
310 SFMatrix *SkeletonJointBase::editSFMatrix(void)
312 editSField(MatrixFieldMask);
314 return &_sfMatrix;
317 const SFMatrix *SkeletonJointBase::getSFMatrix(void) const
319 return &_sfMatrix;
323 SFMatrix *SkeletonJointBase::editSFOffsetMatrix(void)
325 editSField(OffsetMatrixFieldMask);
327 return &_sfOffsetMatrix;
330 const SFMatrix *SkeletonJointBase::getSFOffsetMatrix(void) const
332 return &_sfOffsetMatrix;
340 /*------------------------------ access -----------------------------------*/
342 SizeT SkeletonJointBase::getBinSize(ConstFieldMaskArg whichField)
344 SizeT returnValue = Inherited::getBinSize(whichField);
346 if(FieldBits::NoField != (InvBindMatrixFieldMask & whichField))
348 returnValue += _sfInvBindMatrix.getBinSize();
350 if(FieldBits::NoField != (MatrixFieldMask & whichField))
352 returnValue += _sfMatrix.getBinSize();
354 if(FieldBits::NoField != (OffsetMatrixFieldMask & whichField))
356 returnValue += _sfOffsetMatrix.getBinSize();
359 return returnValue;
362 void SkeletonJointBase::copyToBin(BinaryDataHandler &pMem,
363 ConstFieldMaskArg whichField)
365 Inherited::copyToBin(pMem, whichField);
367 if(FieldBits::NoField != (InvBindMatrixFieldMask & whichField))
369 _sfInvBindMatrix.copyToBin(pMem);
371 if(FieldBits::NoField != (MatrixFieldMask & whichField))
373 _sfMatrix.copyToBin(pMem);
375 if(FieldBits::NoField != (OffsetMatrixFieldMask & whichField))
377 _sfOffsetMatrix.copyToBin(pMem);
381 void SkeletonJointBase::copyFromBin(BinaryDataHandler &pMem,
382 ConstFieldMaskArg whichField)
384 Inherited::copyFromBin(pMem, whichField);
386 if(FieldBits::NoField != (InvBindMatrixFieldMask & whichField))
388 editSField(InvBindMatrixFieldMask);
389 _sfInvBindMatrix.copyFromBin(pMem);
391 if(FieldBits::NoField != (MatrixFieldMask & whichField))
393 editSField(MatrixFieldMask);
394 _sfMatrix.copyFromBin(pMem);
396 if(FieldBits::NoField != (OffsetMatrixFieldMask & whichField))
398 editSField(OffsetMatrixFieldMask);
399 _sfOffsetMatrix.copyFromBin(pMem);
403 //! create a new instance of the class
404 SkeletonJointTransitPtr SkeletonJointBase::createLocal(BitVector bFlags)
406 SkeletonJointTransitPtr fc;
408 if(getClassType().getPrototype() != NULL)
410 FieldContainerTransitPtr tmpPtr =
411 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
413 fc = dynamic_pointer_cast<SkeletonJoint>(tmpPtr);
416 return fc;
419 //! create a new instance of the class, copy the container flags
420 SkeletonJointTransitPtr SkeletonJointBase::createDependent(BitVector bFlags)
422 SkeletonJointTransitPtr fc;
424 if(getClassType().getPrototype() != NULL)
426 FieldContainerTransitPtr tmpPtr =
427 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
429 fc = dynamic_pointer_cast<SkeletonJoint>(tmpPtr);
432 return fc;
435 //! create a new instance of the class
436 SkeletonJointTransitPtr SkeletonJointBase::create(void)
438 SkeletonJointTransitPtr fc;
440 if(getClassType().getPrototype() != NULL)
442 FieldContainerTransitPtr tmpPtr =
443 getClassType().getPrototype()-> shallowCopy();
445 fc = dynamic_pointer_cast<SkeletonJoint>(tmpPtr);
448 return fc;
451 SkeletonJoint *SkeletonJointBase::createEmptyLocal(BitVector bFlags)
453 SkeletonJoint *returnValue;
455 newPtr<SkeletonJoint>(returnValue, bFlags);
457 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
459 return returnValue;
462 //! create an empty new instance of the class, do not copy the prototype
463 SkeletonJoint *SkeletonJointBase::createEmpty(void)
465 SkeletonJoint *returnValue;
467 newPtr<SkeletonJoint>(returnValue, Thread::getCurrentLocalFlags());
469 returnValue->_pFieldFlags->_bNamespaceMask &=
470 ~Thread::getCurrentLocalFlags();
472 return returnValue;
476 FieldContainerTransitPtr SkeletonJointBase::shallowCopyLocal(
477 BitVector bFlags) const
479 SkeletonJoint *tmpPtr;
481 newPtr(tmpPtr, dynamic_cast<const SkeletonJoint *>(this), bFlags);
483 FieldContainerTransitPtr returnValue(tmpPtr);
485 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
487 return returnValue;
490 FieldContainerTransitPtr SkeletonJointBase::shallowCopyDependent(
491 BitVector bFlags) const
493 SkeletonJoint *tmpPtr;
495 newPtr(tmpPtr, dynamic_cast<const SkeletonJoint *>(this), ~bFlags);
497 FieldContainerTransitPtr returnValue(tmpPtr);
499 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
501 return returnValue;
504 FieldContainerTransitPtr SkeletonJointBase::shallowCopy(void) const
506 SkeletonJoint *tmpPtr;
508 newPtr(tmpPtr,
509 dynamic_cast<const SkeletonJoint *>(this),
510 Thread::getCurrentLocalFlags());
512 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
514 FieldContainerTransitPtr returnValue(tmpPtr);
516 return returnValue;
522 /*------------------------- constructors ----------------------------------*/
524 SkeletonJointBase::SkeletonJointBase(void) :
525 Inherited(),
526 _sfInvBindMatrix (),
527 _sfMatrix (),
528 _sfOffsetMatrix ()
532 SkeletonJointBase::SkeletonJointBase(const SkeletonJointBase &source) :
533 Inherited(source),
534 _sfInvBindMatrix (source._sfInvBindMatrix ),
535 _sfMatrix (source._sfMatrix ),
536 _sfOffsetMatrix (source._sfOffsetMatrix )
541 /*-------------------------- destructors ----------------------------------*/
543 SkeletonJointBase::~SkeletonJointBase(void)
548 GetFieldHandlePtr SkeletonJointBase::getHandleInvBindMatrix (void) const
550 SFMatrix::GetHandlePtr returnValue(
551 new SFMatrix::GetHandle(
552 &_sfInvBindMatrix,
553 this->getType().getFieldDesc(InvBindMatrixFieldId),
554 const_cast<SkeletonJointBase *>(this)));
556 return returnValue;
559 EditFieldHandlePtr SkeletonJointBase::editHandleInvBindMatrix (void)
561 SFMatrix::EditHandlePtr returnValue(
562 new SFMatrix::EditHandle(
563 &_sfInvBindMatrix,
564 this->getType().getFieldDesc(InvBindMatrixFieldId),
565 this));
568 editSField(InvBindMatrixFieldMask);
570 return returnValue;
573 GetFieldHandlePtr SkeletonJointBase::getHandleMatrix (void) const
575 SFMatrix::GetHandlePtr returnValue(
576 new SFMatrix::GetHandle(
577 &_sfMatrix,
578 this->getType().getFieldDesc(MatrixFieldId),
579 const_cast<SkeletonJointBase *>(this)));
581 return returnValue;
584 EditFieldHandlePtr SkeletonJointBase::editHandleMatrix (void)
586 SFMatrix::EditHandlePtr returnValue(
587 new SFMatrix::EditHandle(
588 &_sfMatrix,
589 this->getType().getFieldDesc(MatrixFieldId),
590 this));
593 editSField(MatrixFieldMask);
595 return returnValue;
598 GetFieldHandlePtr SkeletonJointBase::getHandleOffsetMatrix (void) const
600 SFMatrix::GetHandlePtr returnValue(
601 new SFMatrix::GetHandle(
602 &_sfOffsetMatrix,
603 this->getType().getFieldDesc(OffsetMatrixFieldId),
604 const_cast<SkeletonJointBase *>(this)));
606 return returnValue;
609 EditFieldHandlePtr SkeletonJointBase::editHandleOffsetMatrix (void)
611 SFMatrix::EditHandlePtr returnValue(
612 new SFMatrix::EditHandle(
613 &_sfOffsetMatrix,
614 this->getType().getFieldDesc(OffsetMatrixFieldId),
615 this));
618 editSField(OffsetMatrixFieldMask);
620 return returnValue;
624 #ifdef OSG_MT_CPTR_ASPECT
625 void SkeletonJointBase::execSyncV( FieldContainer &oFrom,
626 ConstFieldMaskArg whichField,
627 AspectOffsetStore &oOffsets,
628 ConstFieldMaskArg syncMode,
629 const UInt32 uiSyncInfo)
631 SkeletonJoint *pThis = static_cast<SkeletonJoint *>(this);
633 pThis->execSync(static_cast<SkeletonJoint *>(&oFrom),
634 whichField,
635 oOffsets,
636 syncMode,
637 uiSyncInfo);
639 #endif
642 #ifdef OSG_MT_CPTR_ASPECT
643 FieldContainer *SkeletonJointBase::createAspectCopy(
644 const FieldContainer *pRefAspect) const
646 SkeletonJoint *returnValue;
648 newAspectCopy(returnValue,
649 dynamic_cast<const SkeletonJoint *>(pRefAspect),
650 dynamic_cast<const SkeletonJoint *>(this));
652 return returnValue;
654 #endif
656 void SkeletonJointBase::resolveLinks(void)
658 Inherited::resolveLinks();
664 OSG_END_NAMESPACE