Hello Gerrit,
Gerrit Voß wrote:
On Mon, 2010-08-16 at 13:54 -0500, Carsten Neumann wrote:
Gerrit Voß wrote:
I just wanted
to collect all side effects before committing, at least I expect these
changes to break the compat SHL version of the shaders. But I'm still
verifying this though.
ouch, sorry, I had not considered those. Do you want me to back out r2478?
not for now I have to fix it sooner than later so it hopefully should be
fine.
ok, thanks.
[1] a related question is why StateChunk derives from Attachment in the
first place? Does anyone remember?
not sure anymore, I don't know if we ever used them as attachments.
hm, attachment adds two fields (parents, internal) that are mostly not
used for StateChunks, so it seems to make sense to change them to derive
from FieldContainer, or perhaps AttachmentContainer?
They are already a weird combination of being both attachments and
attachment containers (naming them needs the container part, and the
VRML/X3D worshippers want that ;)). So maybe we should really get rid of
them being attachments. I put it onto my think about list ;)
ok, AttachmentContainer makes sense (in fact all Attachments are AC as
well these days). Attached is a patch that makes the change (I don't
plan to commit this before you've found time to think about it ;) ).
Biggest concern is perhaps OSB, but the now missing _sfInternal should
just be skipped by the reader.
Cheers,
Carsten
diff --git a/Source/System/FileIO/OSB/OSGOSBTextureChunkElement.cpp b/Source/System/FileIO/OSB/OSGOSBTextureChunkElement.cpp
index 860dfef..3f60537 100644
--- a/Source/System/FileIO/OSB/OSGOSBTextureChunkElement.cpp
+++ b/Source/System/FileIO/OSB/OSGOSBTextureChunkElement.cpp
@@ -119,11 +119,13 @@ OSBTextureChunkElement::read(const std::string &typeName)
}
else if(fieldName == "internal")
{
- bool fieldValue;
- rh->getValue(fieldValue);
+ rh->skip(fieldSize);
+
+// bool fieldValue;
+// rh->getValue(fieldValue);
- _pTexObj->setInternal(fieldValue);
- _pTexEnv->setInternal(fieldValue);
+// _pTexObj->setInternal(fieldValue);
+// _pTexEnv->setInternal(fieldValue);
}
else if(fieldName == "ignore")
{
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.fcd b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.fcd
index d2c3d1e..2a7f0f0 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.fcd
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.fcd
@@ -1,56 +1,65 @@
<?xml version="1.0"?>
<FieldContainer
- name="GeoProperty"
- parent="StateChunk"
- library="Drawable"
- pointerfieldtypes="both"
- structure="abstract"
- systemcomponent="true"
- parentsystemcomponent="true"
- decoratable="false"
- >
- <Field
- name="useVBO"
- type="bool"
- cardinality="single"
- visibility="external"
- defaultValue="false"
- access="public"
+ name="GeoProperty"
+ parent="StateChunk"
+ library="Drawable"
+ pointerfieldtypes="both"
+ structure="abstract"
+ systemcomponent="true"
+ parentsystemcomponent="true"
+ decoratable="false"
>
- The id used to register with the Window, 0 if not set up yet.
- </Field>
- <Field
- name="usage"
- type="UInt32"
- cardinality="single"
- visibility="external"
- defaultValue="0"
- access="public"
- >
- Provides information about the semantics of this property. Valid values
- are the GeoProperty::Usage... constants.
- </Field>
- <Field
- name="GLId"
- type="UInt32"
- cardinality="single"
- visibility="internal"
- defaultValue="0"
- access="protected"
- fieldFlags="FClusterLocal"
- >
- The id used to register with the Window, 0 if not set up yet.
- </Field>
- <Field
- name="vboUsage"
- type="Int32"
- cardinality="single"
- visibility="internal"
- defaultValue="GL_STATIC_DRAW_ARB"
- defaultHeader=""OSGGLEXT.h""
- access="public"
- >
- The usage pattern, only valid for VBO use.
- </Field>
+ <Field
+ name="useVBO"
+ type="bool"
+ cardinality="single"
+ visibility="external"
+ defaultValue="false"
+ access="public"
+ >
+ Use a VBO to store this property in GPU memory.
+ </Field>
+ <Field
+ name="usage"
+ type="UInt32"
+ cardinality="single"
+ visibility="external"
+ defaultValue="0"
+ access="public"
+ >
+ Provides information about the semantics of this property. Valid values
+ are the GeoProperty::Usage... constants.
+ </Field>
+ <Field
+ name="GLId"
+ type="UInt32"
+ cardinality="single"
+ visibility="internal"
+ defaultValue="0"
+ access="protected"
+ fieldFlags="FClusterLocal"
+ >
+ The id used to register with the Window, 0 if not set up yet.
+ </Field>
+ <Field
+ name="vboUsage"
+ type="Int32"
+ cardinality="single"
+ visibility="internal"
+ defaultValue="GL_STATIC_DRAW_ARB"
+ defaultHeader=""OSGGLEXT.h""
+ access="public"
+ >
+ The usage pattern, only valid for VBO use.
+ </Field>
+ <Field
+ name="Parents"
+ category="parentpointer"
+ type="FieldContainer"
+ cardinality="multi"
+ access="none"
+ visibility="internal"
+ >
+ </Field>
</FieldContainer>
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.h b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.h
index 1de20fa..0202e02 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.h
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.h
@@ -155,7 +155,10 @@ class OSG_DRAWABLE_DLLMAPPING GeoProperty : public GeoPropertyBase
/*! \name Limited Access */
/*! \{ */
- UInt32 getGLId(void) const;
+ UInt32 getGLId (void) const;
+
+ const MFParentFieldContainerPtr &getParents (void) const;
+ const MFParentFieldContainerPtr *getMFParents(void) const;
/*! \} */
/*---------------------------------------------------------------------*/
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.inl b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.inl
index 5ed5473..91af279 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.inl
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoProperty.inl
@@ -84,4 +84,16 @@ UInt32 GeoProperty::getGLId(void) const
return _sfGLId.getValue();
}
+inline
+const MFParentFieldContainerPtr &GeoProperty::getParents(void) const
+{
+ return _mfParents;
+}
+
+inline
+const MFParentFieldContainerPtr *GeoProperty::getMFParents(void) const
+{
+ return &_mfParents;
+}
+
OSG_END_NAMESPACE
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.cpp b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.cpp
index 617e29d..56fc228 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.cpp
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.cpp
@@ -59,6 +59,7 @@
#include "OSGGLEXT.h" // VboUsage default header
+#include "OSGFieldContainer.h" // Parents Class
#include "OSGGeoPropertyBase.h"
#include "OSGGeoProperty.h"
@@ -84,7 +85,7 @@ OSG_BEGIN_NAMESPACE
\***************************************************************************/
/*! \var bool GeoPropertyBase::_sfUseVBO
- The id used to register with the Window, 0 if not set up yet.
+ Use a VBO to store this property in GPU memory.
*/
/*! \var UInt32 GeoPropertyBase::_sfUsage
@@ -100,6 +101,10 @@ OSG_BEGIN_NAMESPACE
The usage pattern, only valid for VBO use.
*/
+/*! \var FieldContainer * GeoPropertyBase::_mfParents
+
+*/
+
/***************************************************************************\
* FieldType/FieldTrait Instantiation *
@@ -131,7 +136,7 @@ void GeoPropertyBase::classDescInserter(TypeObject &oType)
pDesc = new SFBool::Description(
SFBool::getClassType(),
"useVBO",
- "The id used to register with the Window, 0 if not set up yet.\n",
+ "Use a VBO to store this property in GPU memory.\n",
UseVBOFieldId, UseVBOFieldMask,
false,
(Field::SFDefaultFlags | Field::FStdAccess),
@@ -176,6 +181,18 @@ void GeoPropertyBase::classDescInserter(TypeObject &oType)
static_cast<FieldGetMethodSig >(&GeoProperty::getHandleVboUsage));
oType.addInitialDesc(pDesc);
+
+ pDesc = new MFParentFieldContainerPtr::Description(
+ MFParentFieldContainerPtr::getClassType(),
+ "Parents",
+ "",
+ ParentsFieldId, ParentsFieldMask,
+ true,
+ (Field::MFDefaultFlags | Field::FStdAccess),
+ static_cast <FieldEditMethodSig>(&GeoProperty::invalidEditField),
+ static_cast <FieldGetMethodSig >(&GeoProperty::invalidGetField));
+
+ oType.addInitialDesc(pDesc);
}
@@ -193,58 +210,67 @@ GeoPropertyBase::TypeObject GeoPropertyBase::_type(
"<?xml version=\"1.0\"?>\n"
"\n"
"<FieldContainer\n"
- " name=\"GeoProperty\"\n"
- " parent=\"StateChunk\"\n"
- " library=\"Drawable\"\n"
- " pointerfieldtypes=\"both\"\n"
- " structure=\"abstract\"\n"
- " systemcomponent=\"true\"\n"
- " parentsystemcomponent=\"true\"\n"
- " decoratable=\"false\"\n"
- " >\n"
- " <Field\n"
- " name=\"useVBO\"\n"
- " type=\"bool\"\n"
- " cardinality=\"single\"\n"
- " visibility=\"external\"\n"
- " defaultValue=\"false\"\n"
- " access=\"public\"\n"
- " >\n"
- " The id used to register with the Window, 0 if not set up yet.\n"
- " </Field>\n"
- " <Field\n"
- " name=\"usage\"\n"
- " type=\"UInt32\"\n"
- " cardinality=\"single\"\n"
- " visibility=\"external\"\n"
- " defaultValue=\"0\"\n"
- " access=\"public\"\n"
- " >\n"
- " Provides information about the semantics of this property. Valid values\n"
- " are the GeoProperty::Usage... constants. \n"
- " </Field>\n"
- " <Field\n"
- " name=\"GLId\"\n"
- " type=\"UInt32\"\n"
- " cardinality=\"single\"\n"
- " visibility=\"internal\"\n"
- " defaultValue=\"0\"\n"
- " access=\"protected\"\n"
- " fieldFlags=\"FClusterLocal\"\n"
+ " name=\"GeoProperty\"\n"
+ " parent=\"StateChunk\"\n"
+ " library=\"Drawable\"\n"
+ " pointerfieldtypes=\"both\"\n"
+ " structure=\"abstract\"\n"
+ " systemcomponent=\"true\"\n"
+ " parentsystemcomponent=\"true\"\n"
+ " decoratable=\"false\"\n"
" >\n"
- " The id used to register with the Window, 0 if not set up yet.\n"
- " </Field>\n"
- " <Field\n"
- " name=\"vboUsage\"\n"
- " type=\"Int32\"\n"
- " cardinality=\"single\"\n"
- " visibility=\"internal\"\n"
- " defaultValue=\"GL_STATIC_DRAW_ARB\"\n"
- " defaultHeader=\""OSGGLEXT.h"\"\n"
- " access=\"public\"\n"
- " >\n"
- " The usage pattern, only valid for VBO use.\n"
- " </Field>\n"
+ " <Field\n"
+ " name=\"useVBO\"\n"
+ " type=\"bool\"\n"
+ " cardinality=\"single\"\n"
+ " visibility=\"external\"\n"
+ " defaultValue=\"false\"\n"
+ " access=\"public\"\n"
+ " >\n"
+ " Use a VBO to store this property in GPU memory.\n"
+ " </Field>\n"
+ " <Field\n"
+ " name=\"usage\"\n"
+ " type=\"UInt32\"\n"
+ " cardinality=\"single\"\n"
+ " visibility=\"external\"\n"
+ " defaultValue=\"0\"\n"
+ " access=\"public\"\n"
+ " >\n"
+ " Provides information about the semantics of this property. Valid values\n"
+ " are the GeoProperty::Usage... constants. \n"
+ " </Field>\n"
+ " <Field\n"
+ " name=\"GLId\"\n"
+ " type=\"UInt32\"\n"
+ " cardinality=\"single\"\n"
+ " visibility=\"internal\"\n"
+ " defaultValue=\"0\"\n"
+ " access=\"protected\"\n"
+ " fieldFlags=\"FClusterLocal\"\n"
+ " >\n"
+ " The id used to register with the Window, 0 if not set up yet.\n"
+ " </Field>\n"
+ " <Field\n"
+ " name=\"vboUsage\"\n"
+ " type=\"Int32\"\n"
+ " cardinality=\"single\"\n"
+ " visibility=\"internal\"\n"
+ " defaultValue=\"GL_STATIC_DRAW_ARB\"\n"
+ " defaultHeader=\""OSGGLEXT.h"\"\n"
+ " access=\"public\"\n"
+ " >\n"
+ " The usage pattern, only valid for VBO use.\n"
+ " </Field>\n"
+ " <Field\n"
+ " name=\"Parents\"\n"
+ " category=\"parentpointer\"\n"
+ " type=\"FieldContainer\"\n"
+ " cardinality=\"multi\"\n"
+ " access=\"none\"\n"
+ " visibility=\"internal\"\n"
+ " >\n"
+ " </Field>\n"
"</FieldContainer>\n",
""
);
@@ -325,6 +351,7 @@ const SFInt32 *GeoPropertyBase::getSFVboUsage(void) const
+
/*------------------------------ access -----------------------------------*/
UInt32 GeoPropertyBase::getBinSize(ConstFieldMaskArg whichField)
@@ -347,6 +374,10 @@ UInt32 GeoPropertyBase::getBinSize(ConstFieldMaskArg whichField)
{
returnValue += _sfVboUsage.getBinSize();
}
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ {
+ returnValue += _mfParents.getBinSize();
+ }
return returnValue;
}
@@ -372,6 +403,10 @@ void GeoPropertyBase::copyToBin(BinaryDataHandler &pMem,
{
_sfVboUsage.copyToBin(pMem);
}
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ {
+ _mfParents.copyToBin(pMem);
+ }
}
void GeoPropertyBase::copyFromBin(BinaryDataHandler &pMem,
@@ -399,6 +434,11 @@ void GeoPropertyBase::copyFromBin(BinaryDataHandler &pMem,
editSField(VboUsageFieldMask);
_sfVboUsage.copyFromBin(pMem);
}
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ {
+ editMField(ParentsFieldMask, _mfParents);
+ _mfParents.copyFromBin(pMem);
+ }
}
@@ -411,7 +451,8 @@ GeoPropertyBase::GeoPropertyBase(void) :
_sfUseVBO (bool(false)),
_sfUsage (UInt32(0)),
_sfGLId (UInt32(0)),
- _sfVboUsage (Int32(GL_STATIC_DRAW_ARB))
+ _sfVboUsage (Int32(GL_STATIC_DRAW_ARB)),
+ _mfParents ()
{
}
@@ -420,7 +461,8 @@ GeoPropertyBase::GeoPropertyBase(const GeoPropertyBase &source) :
_sfUseVBO (source._sfUseVBO ),
_sfUsage (source._sfUsage ),
_sfGLId (source._sfGLId ),
- _sfVboUsage (source._sfVboUsage )
+ _sfVboUsage (source._sfVboUsage ),
+ _mfParents ()
{
}
@@ -430,6 +472,68 @@ GeoPropertyBase::GeoPropertyBase(const GeoPropertyBase &source) :
GeoPropertyBase::~GeoPropertyBase(void)
{
}
+/*-------------------------------------------------------------------------*/
+/* Parent linking */
+
+bool GeoPropertyBase::linkParent(
+ FieldContainer * const pParent,
+ UInt16 const childFieldId,
+ UInt16 const parentFieldId )
+{
+ if(parentFieldId == ParentsFieldId)
+ {
+ FieldContainer * pTypedParent =
+ dynamic_cast< FieldContainer * >(pParent);
+
+ if(pTypedParent != NULL)
+ {
+ editMField(ParentsFieldMask, _mfParents);
+
+ _mfParents.push_back(pParent, childFieldId);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ return Inherited::linkParent(pParent, childFieldId, parentFieldId);
+}
+
+bool GeoPropertyBase::unlinkParent(
+ FieldContainer * const pParent,
+ UInt16 const parentFieldId)
+{
+ if(parentFieldId == ParentsFieldId)
+ {
+ FieldContainer * pTypedParent =
+ dynamic_cast< FieldContainer * >(pParent);
+
+ if(pTypedParent != NULL)
+ {
+ Int32 iParentIdx = _mfParents.findIndex(pParent);
+
+ if(iParentIdx != -1)
+ {
+ editMField(ParentsFieldMask, _mfParents);
+
+ _mfParents.erase(iParentIdx);
+
+ return true;
+ }
+
+ FWARNING(("GeoPropertyBase::unlinkParent: "
+ "Child <-> Parent link inconsistent.\n"));
+
+ return false;
+ }
+
+ return false;
+ }
+
+ return Inherited::unlinkParent(pParent, parentFieldId);
+}
+
GetFieldHandlePtr GeoPropertyBase::getHandleUseVBO (void) const
@@ -532,6 +636,20 @@ EditFieldHandlePtr GeoPropertyBase::editHandleVboUsage (void)
return returnValue;
}
+GetFieldHandlePtr GeoPropertyBase::getHandleParents (void) const
+{
+ MFParentFieldContainerPtr::GetHandlePtr returnValue;
+
+ return returnValue;
+}
+
+EditFieldHandlePtr GeoPropertyBase::editHandleParents (void)
+{
+ EditFieldHandlePtr returnValue;
+
+ return returnValue;
+}
+
#ifdef OSG_MT_CPTR_ASPECT
void GeoPropertyBase::execSyncV( FieldContainer &oFrom,
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.h b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.h
index e9c44c3..8f723eb 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.h
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.h
@@ -66,6 +66,7 @@
#include "OSGStateChunk.h" // Parent
#include "OSGSysFields.h" // UseVBO type
+#include "OSGFieldContainerFields.h" // Parents type
#include "OSGGeoPropertyFields.h"
@@ -97,7 +98,8 @@ class OSG_DRAWABLE_DLLMAPPING GeoPropertyBase : public StateChunk
UsageFieldId = UseVBOFieldId + 1,
GLIdFieldId = UsageFieldId + 1,
VboUsageFieldId = GLIdFieldId + 1,
- NextFieldId = VboUsageFieldId + 1
+ ParentsFieldId = VboUsageFieldId + 1,
+ NextFieldId = ParentsFieldId + 1
};
static const OSG::BitVector UseVBOFieldMask =
@@ -108,6 +110,8 @@ class OSG_DRAWABLE_DLLMAPPING GeoPropertyBase : public StateChunk
(TypeTraits<BitVector>::One << GLIdFieldId);
static const OSG::BitVector VboUsageFieldMask =
(TypeTraits<BitVector>::One << VboUsageFieldId);
+ static const OSG::BitVector ParentsFieldMask =
+ (TypeTraits<BitVector>::One << ParentsFieldId);
static const OSG::BitVector NextFieldMask =
(TypeTraits<BitVector>::One << NextFieldId);
@@ -115,6 +119,7 @@ class OSG_DRAWABLE_DLLMAPPING GeoPropertyBase : public StateChunk
typedef SFUInt32 SFUsageType;
typedef SFUInt32 SFGLIdType;
typedef SFInt32 SFVboUsageType;
+ typedef MFParentFieldContainerPtr MFParentsType;
/*---------------------------------------------------------------------*/
/*! \name Class Get */
@@ -203,6 +208,7 @@ class OSG_DRAWABLE_DLLMAPPING GeoPropertyBase : public StateChunk
SFUInt32 _sfUsage;
SFUInt32 _sfGLId;
SFInt32 _sfVboUsage;
+ MFParentFieldContainerPtr _mfParents;
/*! \} */
/*---------------------------------------------------------------------*/
@@ -227,6 +233,17 @@ class OSG_DRAWABLE_DLLMAPPING GeoPropertyBase : public StateChunk
/*! \} */
/*---------------------------------------------------------------------*/
+ /*! \name Parent linking */
+ /*! \{ */
+
+ virtual bool linkParent (FieldContainer * const pParent,
+ UInt16 const childFieldId,
+ UInt16 const parentFieldId);
+ virtual bool unlinkParent(FieldContainer * const pParent,
+ UInt16 const parentFieldId);
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
/*! \name Generic Field Access */
/*! \{ */
@@ -238,6 +255,8 @@ class OSG_DRAWABLE_DLLMAPPING GeoPropertyBase : public StateChunk
EditFieldHandlePtr editHandleGLId (void);
GetFieldHandlePtr getHandleVboUsage (void) const;
EditFieldHandlePtr editHandleVboUsage (void);
+ GetFieldHandlePtr getHandleParents (void) const;
+ EditFieldHandlePtr editHandleParents (void);
/*! \} */
/*---------------------------------------------------------------------*/
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.inl b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.inl
index f01718d..fa21ff4 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.inl
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGGeoPropertyBase.inl
@@ -196,6 +196,12 @@ void GeoPropertyBase::execSync ( GeoPropertyBase *pFrom,
if(FieldBits::NoField != (VboUsageFieldMask & whichField))
_sfVboUsage.syncWith(pFrom->_sfVboUsage);
+
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ _mfParents.syncWith(pFrom->_mfParents,
+ syncMode,
+ uiSyncInfo,
+ oOffsets);
}
#endif
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoIntegralProperty.inl b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoIntegralProperty.inl
index d8b452c..f992b11 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoIntegralProperty.inl
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoIntegralProperty.inl
@@ -127,7 +127,7 @@ void TypedGeoIntegralProperty<GeoPropertyDesc>::changed(
UInt32 origin,
BitVector details)
{
- typedef typename Inherited::ParentField PFieldT;
+ typedef typename Inherited::MFParentsType PFieldT;
const Self *pThis = this;
diff --git a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoVectorProperty.inl b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoVectorProperty.inl
index e41ab77..7f13d4f 100644
--- a/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoVectorProperty.inl
+++ b/Source/System/NodeCores/Drawables/Geometry/Properties/OSGTypedGeoVectorProperty.inl
@@ -125,7 +125,7 @@ void TypedGeoVectorProperty<GeoPropertyDesc>::changed(
UInt32 origin ,
BitVector details)
{
- typedef typename Inherited::ParentField PFieldT;
+ typedef typename Inherited::MFParentsType PFieldT;
const Self *pThis = this;
diff --git a/Source/System/State/Base/OSGStateChunk.fcd b/Source/System/State/Base/OSGStateChunk.fcd
index 1495896..2934a72 100644
--- a/Source/System/State/Base/OSGStateChunk.fcd
+++ b/Source/System/State/Base/OSGStateChunk.fcd
@@ -2,7 +2,7 @@
<FieldContainer
name="StateChunk"
- parent="Attachment"
+ parent="AttachmentContainer"
library="System"
structure="abstract"
pointerfieldtypes="both"
diff --git a/Source/System/State/Base/OSGStateChunkBase.cpp b/Source/System/State/Base/OSGStateChunkBase.cpp
index 6287cd0..f4c4fe0 100644
--- a/Source/System/State/Base/OSGStateChunkBase.cpp
+++ b/Source/System/State/Base/OSGStateChunkBase.cpp
@@ -92,7 +92,7 @@ OSG_BEGIN_NAMESPACE
\***************************************************************************/
#if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
-DataType FieldTraits<StateChunk *>::_type("StateChunkPtr", "AttachmentPtr");
+DataType FieldTraits<StateChunk *>::_type("StateChunkPtr", "AttachmentContainerPtr");
#endif
OSG_FIELDTRAITS_GETTYPE(StateChunk *)
@@ -131,7 +131,7 @@ void StateChunkBase::classDescInserter(TypeObject &oType)
StateChunkBase::TypeObject StateChunkBase::_type(
StateChunkBase::getClassname(),
Inherited::getClassname(),
- "StateChunk",
+ "NULL",
0,
NULL,
StateChunk::initMethod,
@@ -143,7 +143,7 @@ StateChunkBase::TypeObject StateChunkBase::_type(
"\n"
"<FieldContainer\n"
" name=\"StateChunk\"\n"
- " parent=\"Attachment\"\n"
+ " parent=\"AttachmentContainer\"\n"
" library=\"System\"\n"
" structure=\"abstract\"\n"
" pointerfieldtypes=\"both\"\n"
diff --git a/Source/System/State/Base/OSGStateChunkBase.h b/Source/System/State/Base/OSGStateChunkBase.h
index 88a59ca..2e6bab9 100644
--- a/Source/System/State/Base/OSGStateChunkBase.h
+++ b/Source/System/State/Base/OSGStateChunkBase.h
@@ -63,7 +63,7 @@
//#include "OSGBaseTypes.h"
-#include "OSGAttachment.h" // Parent
+#include "OSGAttachmentContainer.h" // Parent
#include "OSGSysFields.h" // Ignore type
@@ -75,12 +75,12 @@ class StateChunk;
//! \brief StateChunk Base Class.
-class OSG_SYSTEM_DLLMAPPING StateChunkBase : public Attachment
+class OSG_SYSTEM_DLLMAPPING StateChunkBase : public AttachmentContainer
{
public:
- typedef Attachment Inherited;
- typedef Attachment ParentContainer;
+ typedef AttachmentContainer Inherited;
+ typedef AttachmentContainer ParentContainer;
typedef Inherited::TypeObject TypeObject;
typedef TypeObject::InitPhase InitPhase;
diff --git a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunk.fcd b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunk.fcd
index 815fb3d..6d1ff70 100644
--- a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunk.fcd
+++ b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunk.fcd
@@ -1,37 +1,49 @@
<?xml version="1.0"?>
<FieldContainer
- name="ShaderProgramVariableChunk"
- parent="StateChunk"
- library="System"
- pointerfieldtypes="both"
- structure="concrete"
- systemcomponent="true"
- parentsystemcomponent="true"
- decoratable="false"
- useLocalIncludes="false"
- docGroupBase="GrpSystemShader"
- >
- <Field
- name="variables"
- type="ShaderProgramVariables"
- cardinality="single"
- visibility="external"
- access="public"
- category="childpointer"
- childParentType="FieldContainer"
- linkParentField="Parents"
+ name="ShaderProgramVariableChunk"
+ parent="StateChunk"
+ library="System"
+ pointerfieldtypes="both"
+ structure="concrete"
+ systemcomponent="true"
+ parentsystemcomponent="true"
+ decoratable="false"
+ useLocalIncludes="false"
+ docGroupBase="GrpSystemShader"
>
- </Field>
+ <Field
+ name="variables"
+ type="ShaderProgramVariables"
+ cardinality="single"
+ visibility="external"
+ access="public"
+ category="childpointer"
+ childParentType="FieldContainer"
+ linkParentField="Parents"
+ >
+ </Field>
+
+ <Field
+ name="destroyedFunctors"
+ type="ChangedFunctorCallback"
+ cardinality="multi"
+ visibility="internal"
+ access="none"
+ defaultHeader="OSGChangedFunctorMFields.h"
+ fieldFlags="FClusterLocal"
+ >
+ </Field>
+
+ <Field
+ name="parents"
+ type="FieldContainer"
+ cardinality="multi"
+ visibility="internal"
+ access="none"
+ category="parentpointer"
+ fieldFlags="FClusterLocal"
+ >
+ </Field>
- <Field
- name="destroyedFunctors"
- type="ChangedFunctorCallback"
- cardinality="multi"
- visibility="internal"
- access="none"
- defaultHeader="OSGChangedFunctorMFields.h"
- fieldFlags="FClusterLocal"
- >
- </Field>
</FieldContainer>
diff --git a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.cpp b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.cpp
index 428f233..13f9800 100644
--- a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.cpp
+++ b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.cpp
@@ -60,6 +60,7 @@
#include "OSGChangedFunctorMFields.h" // DestroyedFunctors default header
#include "OSGShaderProgramVariables.h" // Variables Class
+#include "OSGFieldContainer.h" // Parents Class
#include "OSGShaderProgramVariableChunkBase.h"
#include "OSGShaderProgramVariableChunk.h"
@@ -92,6 +93,10 @@ OSG_BEGIN_NAMESPACE
*/
+/*! \var FieldContainer * ShaderProgramVariableChunkBase::_mfParents
+
+*/
+
/***************************************************************************\
* FieldType/FieldTrait Instantiation *
@@ -143,6 +148,18 @@ void ShaderProgramVariableChunkBase::classDescInserter(TypeObject &oType)
static_cast <FieldGetMethodSig >(&ShaderProgramVariableChunk::invalidGetField));
oType.addInitialDesc(pDesc);
+
+ pDesc = new MFParentFieldContainerPtr::Description(
+ MFParentFieldContainerPtr::getClassType(),
+ "parents",
+ "",
+ ParentsFieldId, ParentsFieldMask,
+ true,
+ (Field::FClusterLocal),
+ static_cast <FieldEditMethodSig>(&ShaderProgramVariableChunk::invalidEditField),
+ static_cast <FieldGetMethodSig >(&ShaderProgramVariableChunk::invalidGetField));
+
+ oType.addInitialDesc(pDesc);
}
@@ -160,39 +177,51 @@ ShaderProgramVariableChunkBase::TypeObject ShaderProgramVariableChunkBase::_type
"<?xml version=\"1.0\"?>\n"
"\n"
"<FieldContainer\n"
- " name=\"ShaderProgramVariableChunk\"\n"
- " parent=\"StateChunk\"\n"
- " library=\"System\"\n"
- " pointerfieldtypes=\"both\"\n"
- " structure=\"concrete\"\n"
- " systemcomponent=\"true\"\n"
- " parentsystemcomponent=\"true\"\n"
- " decoratable=\"false\"\n"
- " useLocalIncludes=\"false\"\n"
- " docGroupBase=\"GrpSystemShader\"\n"
- " >\n"
- " <Field\n"
- " name=\"variables\"\n"
- " type=\"ShaderProgramVariables\"\n"
- " cardinality=\"single\"\n"
- " visibility=\"external\"\n"
- " access=\"public\"\n"
- " category=\"childpointer\"\n"
- " childParentType=\"FieldContainer\"\n"
- " linkParentField=\"Parents\"\n"
+ " name=\"ShaderProgramVariableChunk\"\n"
+ " parent=\"StateChunk\"\n"
+ " library=\"System\"\n"
+ " pointerfieldtypes=\"both\"\n"
+ " structure=\"concrete\"\n"
+ " systemcomponent=\"true\"\n"
+ " parentsystemcomponent=\"true\"\n"
+ " decoratable=\"false\"\n"
+ " useLocalIncludes=\"false\"\n"
+ " docGroupBase=\"GrpSystemShader\"\n"
" >\n"
- " </Field>\n"
+ " <Field\n"
+ " name=\"variables\"\n"
+ " type=\"ShaderProgramVariables\"\n"
+ " cardinality=\"single\"\n"
+ " visibility=\"external\"\n"
+ " access=\"public\"\n"
+ " category=\"childpointer\"\n"
+ " childParentType=\"FieldContainer\"\n"
+ " linkParentField=\"Parents\"\n"
+ " >\n"
+ " </Field>\n"
+ "\n"
+ " <Field\n"
+ " name=\"destroyedFunctors\"\n"
+ " type=\"ChangedFunctorCallback\"\n"
+ " cardinality=\"multi\"\n"
+ " visibility=\"internal\"\n"
+ " access=\"none\"\n"
+ " defaultHeader=\"OSGChangedFunctorMFields.h\"\n"
+ " fieldFlags=\"FClusterLocal\"\n"
+ " >\n"
+ " </Field> \n"
+ "\n"
+ " <Field\n"
+ " name=\"parents\"\n"
+ " type=\"FieldContainer\"\n"
+ " cardinality=\"multi\"\n"
+ " visibility=\"internal\"\n"
+ " access=\"none\"\n"
+ " category=\"parentpointer\"\n"
+ " fieldFlags=\"FClusterLocal\"\n"
+ " >\n"
+ " </Field>\n"
"\n"
- " <Field\n"
- " name=\"destroyedFunctors\"\n"
- " type=\"ChangedFunctorCallback\"\n"
- " cardinality=\"multi\"\n"
- " visibility=\"internal\"\n"
- " access=\"none\"\n"
- " defaultHeader=\"OSGChangedFunctorMFields.h\"\n"
- " fieldFlags=\"FClusterLocal\"\n"
- " >\n"
- " </Field> \n"
"</FieldContainer>\n",
""
);
@@ -235,6 +264,7 @@ SFUnrecChildShaderProgramVariablesPtr *ShaderProgramVariableChunkBase::editSFVar
+
/*------------------------------ access -----------------------------------*/
UInt32 ShaderProgramVariableChunkBase::getBinSize(ConstFieldMaskArg whichField)
@@ -249,6 +279,10 @@ UInt32 ShaderProgramVariableChunkBase::getBinSize(ConstFieldMaskArg whichField)
{
returnValue += _mfDestroyedFunctors.getBinSize();
}
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ {
+ returnValue += _mfParents.getBinSize();
+ }
return returnValue;
}
@@ -266,6 +300,10 @@ void ShaderProgramVariableChunkBase::copyToBin(BinaryDataHandler &pMem,
{
_mfDestroyedFunctors.copyToBin(pMem);
}
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ {
+ _mfParents.copyToBin(pMem);
+ }
}
void ShaderProgramVariableChunkBase::copyFromBin(BinaryDataHandler &pMem,
@@ -283,6 +321,11 @@ void ShaderProgramVariableChunkBase::copyFromBin(BinaryDataHandler &pMem,
editMField(DestroyedFunctorsFieldMask, _mfDestroyedFunctors);
_mfDestroyedFunctors.copyFromBin(pMem);
}
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ {
+ editMField(ParentsFieldMask, _mfParents);
+ _mfParents.copyFromBin(pMem);
+ }
}
//! create a new instance of the class
@@ -411,7 +454,8 @@ ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(void) :
_sfVariables (this,
VariablesFieldId,
ShaderProgramVariables::ParentsFieldId),
- _mfDestroyedFunctors ()
+ _mfDestroyedFunctors (),
+ _mfParents ()
{
}
@@ -420,7 +464,8 @@ ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(const ShaderProgr
_sfVariables (this,
VariablesFieldId,
ShaderProgramVariables::ParentsFieldId),
- _mfDestroyedFunctors (source._mfDestroyedFunctors )
+ _mfDestroyedFunctors (source._mfDestroyedFunctors ),
+ _mfParents ()
{
}
@@ -430,6 +475,68 @@ ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(const ShaderProgr
ShaderProgramVariableChunkBase::~ShaderProgramVariableChunkBase(void)
{
}
+/*-------------------------------------------------------------------------*/
+/* Parent linking */
+
+bool ShaderProgramVariableChunkBase::linkParent(
+ FieldContainer * const pParent,
+ UInt16 const childFieldId,
+ UInt16 const parentFieldId )
+{
+ if(parentFieldId == ParentsFieldId)
+ {
+ FieldContainer * pTypedParent =
+ dynamic_cast< FieldContainer * >(pParent);
+
+ if(pTypedParent != NULL)
+ {
+ editMField(ParentsFieldMask, _mfParents);
+
+ _mfParents.push_back(pParent, childFieldId);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ return Inherited::linkParent(pParent, childFieldId, parentFieldId);
+}
+
+bool ShaderProgramVariableChunkBase::unlinkParent(
+ FieldContainer * const pParent,
+ UInt16 const parentFieldId)
+{
+ if(parentFieldId == ParentsFieldId)
+ {
+ FieldContainer * pTypedParent =
+ dynamic_cast< FieldContainer * >(pParent);
+
+ if(pTypedParent != NULL)
+ {
+ Int32 iParentIdx = _mfParents.findIndex(pParent);
+
+ if(iParentIdx != -1)
+ {
+ editMField(ParentsFieldMask, _mfParents);
+
+ _mfParents.erase(iParentIdx);
+
+ return true;
+ }
+
+ FWARNING(("ShaderProgramVariableChunkBase::unlinkParent: "
+ "Child <-> Parent link inconsistent.\n"));
+
+ return false;
+ }
+
+ return false;
+ }
+
+ return Inherited::unlinkParent(pParent, parentFieldId);
+}
+
/*-------------------------------------------------------------------------*/
/* Child linking */
@@ -521,6 +628,20 @@ EditFieldHandlePtr ShaderProgramVariableChunkBase::editHandleDestroyedFunctors(v
return returnValue;
}
+GetFieldHandlePtr ShaderProgramVariableChunkBase::getHandleParents (void) const
+{
+ MFParentFieldContainerPtr::GetHandlePtr returnValue;
+
+ return returnValue;
+}
+
+EditFieldHandlePtr ShaderProgramVariableChunkBase::editHandleParents (void)
+{
+ EditFieldHandlePtr returnValue;
+
+ return returnValue;
+}
+
#ifdef OSG_MT_CPTR_ASPECT
void ShaderProgramVariableChunkBase::execSyncV( FieldContainer &oFrom,
diff --git a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.h b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.h
index e3521fb..ca40fa3 100644
--- a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.h
+++ b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.h
@@ -67,6 +67,7 @@
#include "OSGShaderProgramVariablesFields.h" // Variables type
#include "OSGChangedFunctorCallbackFields.h" // DestroyedFunctors type
+#include "OSGFieldContainerFields.h" // Parents type
#include "OSGShaderProgramVariableChunkFields.h"
@@ -96,18 +97,22 @@ class OSG_SYSTEM_DLLMAPPING ShaderProgramVariableChunkBase : public StateChunk
{
VariablesFieldId = Inherited::NextFieldId,
DestroyedFunctorsFieldId = VariablesFieldId + 1,
- NextFieldId = DestroyedFunctorsFieldId + 1
+ ParentsFieldId = DestroyedFunctorsFieldId + 1,
+ NextFieldId = ParentsFieldId + 1
};
static const OSG::BitVector VariablesFieldMask =
(TypeTraits<BitVector>::One << VariablesFieldId);
static const OSG::BitVector DestroyedFunctorsFieldMask =
(TypeTraits<BitVector>::One << DestroyedFunctorsFieldId);
+ static const OSG::BitVector ParentsFieldMask =
+ (TypeTraits<BitVector>::One << ParentsFieldId);
static const OSG::BitVector NextFieldMask =
(TypeTraits<BitVector>::One << NextFieldId);
typedef SFUnrecChildShaderProgramVariablesPtr SFVariablesType;
typedef MFChangedFunctorCallback MFDestroyedFunctorsType;
+ typedef MFParentFieldContainerPtr MFParentsType;
/*---------------------------------------------------------------------*/
/*! \name Class Get */
@@ -210,6 +215,7 @@ class OSG_SYSTEM_DLLMAPPING ShaderProgramVariableChunkBase : public StateChunk
SFUnrecChildShaderProgramVariablesPtr _sfVariables;
MFChangedFunctorCallback _mfDestroyedFunctors;
+ MFParentFieldContainerPtr _mfParents;
/*! \} */
/*---------------------------------------------------------------------*/
@@ -235,6 +241,17 @@ class OSG_SYSTEM_DLLMAPPING ShaderProgramVariableChunkBase : public StateChunk
/*! \} */
/*---------------------------------------------------------------------*/
+ /*! \name Parent linking */
+ /*! \{ */
+
+ virtual bool linkParent (FieldContainer * const pParent,
+ UInt16 const childFieldId,
+ UInt16 const parentFieldId);
+ virtual bool unlinkParent(FieldContainer * const pParent,
+ UInt16 const parentFieldId);
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
/*! \name Child linking */
/*! \{ */
@@ -250,6 +267,8 @@ class OSG_SYSTEM_DLLMAPPING ShaderProgramVariableChunkBase : public StateChunk
EditFieldHandlePtr editHandleVariables (void);
GetFieldHandlePtr getHandleDestroyedFunctors (void) const;
EditFieldHandlePtr editHandleDestroyedFunctors(void);
+ GetFieldHandlePtr getHandleParents (void) const;
+ EditFieldHandlePtr editHandleParents (void);
/*! \} */
/*---------------------------------------------------------------------*/
diff --git a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.inl b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.inl
index 15a182b..87602da 100644
--- a/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.inl
+++ b/Source/System/State/Shader/Chunks/OSGShaderProgramVariableChunkBase.inl
@@ -109,6 +109,12 @@ void ShaderProgramVariableChunkBase::execSync ( ShaderProgramVariableChunkB
syncMode,
uiSyncInfo,
oOffsets);
+
+ if(FieldBits::NoField != (ParentsFieldMask & whichField))
+ _mfParents.syncWith(pFrom->_mfParents,
+ syncMode,
+ uiSyncInfo,
+ oOffsets);
}
#endif
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core