Hello Gerrit and/or Carsten,

On 26.10.2015 13:57, Johannes Brunen wrote:
>
> Is it possible to a allow a subtractive
> MaterialChunkOverrideGroup core.
>
> Is that possible and can I get some support in realizing that?
>
I have made a first implementation of what I have in mind. Attached you
can find my solution. Could you take a look at it and give me some
feedback. I would like to see something like this in OpenSG 2 :-)

Best,
Johannes

P.S.: Files.azip is just a simple zip file. I uses this extension because the mail server filters *.zip files :-(

Attachment: Files.azip
Description: Binary data

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.h
 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.h
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.h
 2015-10-09 14:25:58.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.h
     2015-10-27 10:49:50.750921100 +0100
@@ -157,6 +157,8 @@ class OSG_SYSTEM_DLLMAPPING RenderAction
 

           void           addOverride        (UInt32      uiSlot, 

                                              StateChunk *pChunk);

+          void           removeOverride     (UInt32      uiSlot, 

+                                             StateChunk *pChunk);

 

     const StateOverride *getCurrentOverrides(void              ) const;

 

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.inl
 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.inl
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.inl
       2015-10-09 14:25:58.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderAction.inl
   2015-10-27 10:50:17.646459500 +0100
@@ -114,6 +114,12 @@ void RenderAction::addOverride(UInt32 ui
 }

 

 inline

+void RenderAction::removeOverride(UInt32 uiSlot, StateChunk *pChunk)

+{

+    _pActivePartition->removeOverride(uiSlot, pChunk);

+}

+

+inline

 const StateOverride *RenderAction::getCurrentOverrides(void) const

 {

     return _pActivePartition->getCurrentOverrides();

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.h
 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.h
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.h
      2015-10-09 14:25:58.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.h
  2015-10-27 10:10:17.008150800 +0100
@@ -307,6 +307,9 @@ class OSG_SYSTEM_DLLMAPPING RenderPartit
           void           addOverride        (UInt32      uiSlot, 

                                              StateChunk *pChunk);

 

+          void           removeOverride     (UInt32      uiSlot, 

+                                             StateChunk *pChunk);

+

     const StateOverride *getCurrentOverrides(void              ) const;

 

     /*-------------------------- comparison ---------------------------------*/

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.inl
 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.inl
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.inl
    2015-10-09 14:25:58.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/Action/RenderAction/OSGRenderPartition.inl
        2015-10-27 10:10:45.370773000 +0100
@@ -386,6 +386,12 @@ void RenderPartition::addOverride(UInt32
 }

 

 inline

+void RenderPartition::removeOverride(UInt32 uiSlot, StateChunk *pChunk)

+{

+    _sStateOverrides.top()->removeOverride(uiSlot, pChunk);

+}

+

+inline

 const StateOverride *RenderPartition::getCurrentOverrides(void) const

 {

     return _sStateOverrides.top();

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.cpp
 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.cpp
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.cpp
       2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.cpp
   2015-10-27 10:50:54.831586300 +0100
@@ -224,7 +224,10 @@ Action::ResultE ChunkOverrideGroup::rend
         while(chIt != chEnd)

         {

             if(*chIt != NULL && (*chIt)->getIgnore() == false)

-                pAction->addOverride(uiSlot, *chIt);

+                if (getRemoveOverride())

+                    pAction->removeOverride(uiSlot, *chIt);

+                else

+                    pAction->addOverride(uiSlot, *chIt);

             

             ++uiSlot;

             ++chIt;

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.fcd
 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.fcd
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.fcd
       2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroup.fcd
   2015-10-27 10:29:37.398521300 +0100
@@ -25,5 +25,16 @@
         access="public"

         >

   </Field>

+

+<Field

+        name="removeOverride"

+        type="bool"

+        cardinality="single"

+        visibility="external"

+        defaultValue="false"

+        access="public"

+        >

+</Field>

+

 </FieldContainer>

 

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.cpp
 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.cpp
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.cpp
   2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.cpp
       2015-10-27 10:42:17.396990800 +0100
@@ -75,9 +75,9 @@ OSG_BEGIN_NAMESPACE
 \***************************************************************************/

 

 /*! \class OSG::ChunkOverrideGroup

-    ChunkOverrideGroup is a simple group node that allows for material chunks

-    to be set that will override all chunks stored in materials in the entire 

-    subtree. Currently the last chunk override wins (note the difference to

+    ChunkOverrideGroup is a simple group node that allows for material chunks
+    to be set that will override all chunks stored in materials in the entire 
+    subtree. Currently the last chunk override wins (note the difference to
     the material group). This might change in future

  */

 

@@ -89,6 +89,10 @@ OSG_BEGIN_NAMESPACE
     

 */

 

+/*! \var bool            ChunkOverrideGroupBase::_sfRemoveOverride

+    

+*/

+

 

 /***************************************************************************\

  *                      FieldType/FieldTrait Instantiation                 *

@@ -132,6 +136,18 @@ void ChunkOverrideGroupBase::classDescIn
         static_cast<FieldGetMethodSig 
>(&ChunkOverrideGroup::getHandleFallbackChunkBlock));

 

     oType.addInitialDesc(pDesc);

+

+    pDesc = new SFBool::Description(

+        SFBool::getClassType(),

+        "removeOverride",

+        "",

+        RemoveOverrideFieldId, RemoveOverrideFieldMask,

+        false,

+        (Field::SFDefaultFlags | Field::FStdAccess),

+        
static_cast<FieldEditMethodSig>(&ChunkOverrideGroup::editHandleRemoveOverride),

+        static_cast<FieldGetMethodSig 
>(&ChunkOverrideGroup::getHandleRemoveOverride));

+

+    oType.addInitialDesc(pDesc);

 }

 

 

@@ -146,38 +162,49 @@ ChunkOverrideGroupBase::TypeObject Chunk
     
reinterpret_cast<InitalInsertDescFunc>(&ChunkOverrideGroup::classDescInserter),

     false,

     0,

-    "<?xml version=\"1.0\"?>\n"

-    "\n"

-    "<FieldContainer\n"

-    "   name=\"ChunkOverrideGroup\"\n"

-    "   parent=\"Group\"\n"

-    "   library=\"System\"\n"

-    "   pointerfieldtypes=\"both\"\n"

-    "   structure=\"concrete\"\n"

-    "   systemcomponent=\"true\"\n"

-    "   parentsystemcomponent=\"true\"\n"

-    "   isNodeCore=\"true\"\n"

-    "   docGroupBase=\"GrpSystemNodeCoreGroups\"\n"

-    "   >\n"

-    "\n"

-    "  ChunkOverrideGroup is a simple group node that allows for material 
chunks\n"

-    "  to be set that will override all chunks stored in materials in the 
entire \n"

-    "  subtree. Currently the last chunk override wins (note the difference 
to\n"

-    "  the material group). This might change in future\n"

-    "\n"

-    "  <Field\n"

-    "\t name=\"fallbackChunkBlock\"\n"

-    "\t type=\"ChunkBlockPtr\"\n"

-    "\t cardinality=\"single\"\n"

-    "\t visibility=\"external\"\n"

-    "\t access=\"public\"\n"

-    "\t >\n"

-    "  </Field>\n"

-    "</FieldContainer>\n"

+    "<?xml version=\"1.0\"?>\n"
+    "\n"
+    "<FieldContainer\n"
+    "   name=\"ChunkOverrideGroup\"\n"
+    "   parent=\"Group\"\n"
+    "   library=\"System\"\n"
+    "   pointerfieldtypes=\"both\"\n"
+    "   structure=\"concrete\"\n"
+    "   systemcomponent=\"true\"\n"
+    "   parentsystemcomponent=\"true\"\n"
+    "   isNodeCore=\"true\"\n"
+    "   docGroupBase=\"GrpSystemNodeCoreGroups\"\n"
+    "   >\n"
+    "\n"
+    "  ChunkOverrideGroup is a simple group node that allows for material 
chunks\n"
+    "  to be set that will override all chunks stored in materials in the 
entire \n"
+    "  subtree. Currently the last chunk override wins (note the difference 
to\n"
+    "  the material group). This might change in future\n"
+    "\n"
+    "  <Field\n"
+    "\t name=\"fallbackChunkBlock\"\n"
+    "\t type=\"ChunkBlockPtr\"\n"
+    "\t cardinality=\"single\"\n"
+    "\t visibility=\"external\"\n"
+    "\t access=\"public\"\n"
+    "\t >\n"
+    "  </Field>\n"
+    "\n"
+    "<Field\n"
+    "        name=\"removeOverride\"\n"
+    "        type=\"bool\"\n"
+    "        cardinality=\"single\"\n"
+    "        visibility=\"external\"\n"
+    "        defaultValue=\"false\"\n"
+    "        access=\"public\"\n"
+    "\t >\n"
+    "</Field>\n"
+    "\n"
+    "</FieldContainer>\n"
     "\n",

-    "ChunkOverrideGroup is a simple group node that allows for material 
chunks\n"

-    "to be set that will override all chunks stored in materials in the entire 
\n"

-    "subtree. Currently the last chunk override wins (note the difference to\n"

+    "ChunkOverrideGroup is a simple group node that allows for material 
chunks\n"
+    "to be set that will override all chunks stored in materials in the entire 
\n"
+    "subtree. Currently the last chunk override wins (note the difference to\n"
     "the material group). This might change in future\n"

     );

 

@@ -229,6 +256,19 @@ void ChunkOverrideGroupBase::setFallback
 }

 

 

+SFBool *ChunkOverrideGroupBase::editSFRemoveOverride(void)

+{

+    editSField(RemoveOverrideFieldMask);

+

+    return &_sfRemoveOverride;

+}

+

+const SFBool *ChunkOverrideGroupBase::getSFRemoveOverride(void) const

+{

+    return &_sfRemoveOverride;

+}

+

+

 

 

 

@@ -243,6 +283,10 @@ SizeT ChunkOverrideGroupBase::getBinSize
     {

         returnValue += _sfFallbackChunkBlock.getBinSize();

     }

+    if(FieldBits::NoField != (RemoveOverrideFieldMask & whichField))

+    {

+        returnValue += _sfRemoveOverride.getBinSize();

+    }

 

     return returnValue;

 }

@@ -256,6 +300,10 @@ void ChunkOverrideGroupBase::copyToBin(B
     {

         _sfFallbackChunkBlock.copyToBin(pMem);

     }

+    if(FieldBits::NoField != (RemoveOverrideFieldMask & whichField))

+    {

+        _sfRemoveOverride.copyToBin(pMem);

+    }

 }

 

 void ChunkOverrideGroupBase::copyFromBin(BinaryDataHandler &pMem,

@@ -268,6 +316,11 @@ void ChunkOverrideGroupBase::copyFromBin
         editSField(FallbackChunkBlockFieldMask);

         _sfFallbackChunkBlock.copyFromBin(pMem);

     }

+    if(FieldBits::NoField != (RemoveOverrideFieldMask & whichField))

+    {

+        editSField(RemoveOverrideFieldMask);

+        _sfRemoveOverride.copyFromBin(pMem);

+    }

 }

 

 //! create a new instance of the class

@@ -393,13 +446,15 @@ FieldContainerTransitPtr ChunkOverrideGr
 

 ChunkOverrideGroupBase::ChunkOverrideGroupBase(void) :

     Inherited(),

-    _sfFallbackChunkBlock     (NULL)

+    _sfFallbackChunkBlock     (NULL),

+    _sfRemoveOverride         (bool(false))

 {

 }

 

 ChunkOverrideGroupBase::ChunkOverrideGroupBase(const ChunkOverrideGroupBase 
&source) :

     Inherited(source),

-    _sfFallbackChunkBlock     (NULL)

+    _sfFallbackChunkBlock     (NULL),

+    _sfRemoveOverride         (source._sfRemoveOverride         )

 {

 }

 

@@ -449,6 +504,31 @@ EditFieldHandlePtr ChunkOverrideGroupBas
 

     return returnValue;

 }

+

+GetFieldHandlePtr ChunkOverrideGroupBase::getHandleRemoveOverride  (void) const

+{

+    SFBool::GetHandlePtr returnValue(

+        new  SFBool::GetHandle(

+             &_sfRemoveOverride,

+             this->getType().getFieldDesc(RemoveOverrideFieldId),

+             const_cast<ChunkOverrideGroupBase *>(this)));

+

+    return returnValue;

+}

+

+EditFieldHandlePtr ChunkOverrideGroupBase::editHandleRemoveOverride (void)

+{

+    SFBool::EditHandlePtr returnValue(

+        new  SFBool::EditHandle(

+             &_sfRemoveOverride,

+             this->getType().getFieldDesc(RemoveOverrideFieldId),

+             this));

+

+

+    editSField(RemoveOverrideFieldMask);

+

+    return returnValue;

+}

 

 

 #ifdef OSG_MT_CPTR_ASPECT

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.h
 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.h
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.h
     2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.h
 2015-10-27 10:42:17.402991100 +0100
@@ -66,6 +66,7 @@
 #include "OSGGroup.h" // Parent

 

 #include "OSGChunkBlockFields.h"        // FallbackChunkBlock type

+#include "OSGSysFields.h"               // RemoveOverride type

 

 #include "OSGChunkOverrideGroupFields.h"

 

@@ -95,15 +96,19 @@ class OSG_SYSTEM_DLLMAPPING ChunkOverrid
     enum

     {

         FallbackChunkBlockFieldId = Inherited::NextFieldId,

-        NextFieldId = FallbackChunkBlockFieldId + 1

+        RemoveOverrideFieldId = FallbackChunkBlockFieldId + 1,

+        NextFieldId = RemoveOverrideFieldId + 1

     };

 

     static const OSG::BitVector FallbackChunkBlockFieldMask =

         (TypeTraits<BitVector>::One << FallbackChunkBlockFieldId);

+    static const OSG::BitVector RemoveOverrideFieldMask =

+        (TypeTraits<BitVector>::One << RemoveOverrideFieldId);

     static const OSG::BitVector NextFieldMask =

         (TypeTraits<BitVector>::One << NextFieldId);

         

     typedef SFUnrecChunkBlockPtr SFFallbackChunkBlockType;

+    typedef SFBool            SFRemoveOverrideType;

 

     /*---------------------------------------------------------------------*/

     /*! \name                    Class Get                                 */

@@ -131,15 +136,22 @@ class OSG_SYSTEM_DLLMAPPING ChunkOverrid
             const SFUnrecChunkBlockPtr *getSFFallbackChunkBlock(void) const;

                   SFUnrecChunkBlockPtr *editSFFallbackChunkBlock(void);

 

+                  SFBool              *editSFRemoveOverride (void);

+            const SFBool              *getSFRemoveOverride  (void) const;

+

 

                   ChunkBlock * getFallbackChunkBlock(void) const;

 

+                  bool                &editRemoveOverride (void);

+                  bool                 getRemoveOverride  (void) const;

+

     /*! \}                                                                 */

     /*---------------------------------------------------------------------*/

     /*! \name                    Field Set                                 */

     /*! \{                                                                 */

 

             void setFallbackChunkBlock(ChunkBlock * const value);

+            void setRemoveOverride (const bool value);

 

     /*! \}                                                                 */

     /*---------------------------------------------------------------------*/

@@ -205,6 +217,7 @@ class OSG_SYSTEM_DLLMAPPING ChunkOverrid
     /*! \{                                                                 */

 

     SFUnrecChunkBlockPtr _sfFallbackChunkBlock;

+    SFBool            _sfRemoveOverride;

 

     /*! \}                                                                 */

     /*---------------------------------------------------------------------*/

@@ -235,6 +248,8 @@ class OSG_SYSTEM_DLLMAPPING ChunkOverrid
 

      GetFieldHandlePtr  getHandleFallbackChunkBlock (void) const;

      EditFieldHandlePtr editHandleFallbackChunkBlock(void);

+     GetFieldHandlePtr  getHandleRemoveOverride  (void) const;

+     EditFieldHandlePtr editHandleRemoveOverride (void);

 

     /*! \}                                                                 */

     /*---------------------------------------------------------------------*/

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.inl
 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.inl
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.inl
   2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/NodeCores/Groups/Base/OSGChunkOverrideGroupBase.inl
       2015-10-27 10:42:17.398990900 +0100
@@ -74,6 +74,31 @@ OSG::UInt16 ChunkOverrideGroupBase::getC
 

 /*------------------------------ get -----------------------------------*/

 

+//! Get the value of the ChunkOverrideGroup::_sfRemoveOverride field.

+

+inline

+bool &ChunkOverrideGroupBase::editRemoveOverride(void)

+{

+    editSField(RemoveOverrideFieldMask);

+

+    return _sfRemoveOverride.getValue();

+}

+

+//! Get the value of the ChunkOverrideGroup::_sfRemoveOverride field.

+inline

+      bool  ChunkOverrideGroupBase::getRemoveOverride(void) const

+{

+    return _sfRemoveOverride.getValue();

+}

+

+//! Set the value of the ChunkOverrideGroup::_sfRemoveOverride field.

+inline

+void ChunkOverrideGroupBase::setRemoveOverride(const bool value)

+{

+    editSField(RemoveOverrideFieldMask);

+

+    _sfRemoveOverride.setValue(value);

+}

 

 

 #ifdef OSG_MT_CPTR_ASPECT

@@ -88,6 +113,9 @@ void ChunkOverrideGroupBase::execSync (
 

     if(FieldBits::NoField != (FallbackChunkBlockFieldMask & whichField))

         _sfFallbackChunkBlock.syncWith(pFrom->_sfFallbackChunkBlock);

+

+    if(FieldBits::NoField != (RemoveOverrideFieldMask & whichField))

+        _sfRemoveOverride.syncWith(pFrom->_sfRemoveOverride);

 }

 #endif

 

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.cpp
 
d:/_xxx/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.cpp
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.cpp
       2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.cpp
   2015-10-27 11:55:05.029443100 +0100
@@ -295,3 +295,154 @@ void StateOverride::addOverride(UInt32 u
         this->addOverride(uiSlot, pSPChunk);

     }

 }

+

+

+//

+// remove...

+//

+void StateOverride::removeOverride(UInt32 uiSlot, ShaderProgramChunk *pChunk)

+{

+    if(pChunk == NULL)

+    {

+        return;

+    }

+

+    ShaderProgramChunk::MFVertexShaderType::const_iterator sIt  = 

+        pChunk->getMFVertexShader()->begin();

+

+    ShaderProgramChunk::MFVertexShaderType::const_iterator sEnd = 

+        pChunk->getMFVertexShader()->end();

+

+

+    for(; sIt != sEnd; ++sIt)

+    {

+        UInt16    uiProgId = (*sIt)->getProgramId();

+

+        std::pair<IdStoreIt, IdStoreIt> pairIt 

+            = std::equal_range(_vProgIds.begin(),

+                               _vProgIds.end  (),

+                               uiProgId         );

+

+        if(pairIt.first != pairIt.second)

+        {

+            _vProgIds.erase(pairIt.first);

+        }

+    }

+

+    sIt  = pChunk->getMFGeometryShader()->begin();

+    sEnd = pChunk->getMFGeometryShader()->end  ();

+

+    for(; sIt != sEnd; ++sIt)

+    {

+        UInt16    uiProgId = (*sIt)->getProgramId();

+

+        std::pair<IdStoreIt, IdStoreIt> pairIt 

+            = std::equal_range(_vProgIds.begin(),

+                               _vProgIds.end  (),

+                               uiProgId         );

+

+        if(pairIt.first != pairIt.second)

+        {

+            _vProgIds.erase(pairIt.first);

+        }

+    }

+

+    sIt  = pChunk->getMFFragmentShader()->begin();

+    sEnd = pChunk->getMFFragmentShader()->end  ();

+

+    for(; sIt != sEnd; ++sIt)

+    {

+        UInt16    uiProgId = (*sIt)->getProgramId();

+

+        std::pair<IdStoreIt, IdStoreIt> pairIt 

+            = std::equal_range(_vProgIds.begin(),

+                               _vProgIds.end  (),

+                               uiProgId         );

+

+        if(pairIt.first != pairIt.second)

+        {

+            _vProgIds.erase(pairIt.first);

+        }

+    }

+

+    ProgramChunkStore::const_iterator sIt2 = std::find(_vProgChunks.begin(), 
_vProgChunks.end(), pChunk);

+    if (sIt2 != _vProgChunks.end())

+        _vProgChunks.erase(sIt2);

+}

+

+void StateOverride::removeOverride(UInt32                      uiSlot, 

+                                   ShaderProgramVariableChunk *pChunk)

+{

+    if(pChunk == NULL)

+    {

+        return;

+    }

+

+    UInt16    uiVarId = pChunk->getVariableId();

+

+

+    std::pair<IdStoreIt, IdStoreIt> pairIt 

+            = std::equal_range(_vProgVarIds.begin(),

+                               _vProgVarIds.end  (),

+                               uiVarId             );

+

+        

+    if(pairIt.first != pairIt.second)

+    {

+        _vProgVarIds.erase(pairIt.first);

+    }

+

+    ProgramVarChunkStore::const_iterator sIt2 = 
std::find(_vProgVarChunks.begin(), _vProgVarChunks.end(), pChunk);

+    if (sIt2 != _vProgVarChunks.end())

+        _vProgVarChunks.erase(sIt2);

+}

+

+void StateOverride::removeOverride(UInt32          uiSlot, 

+                                SimpleSHLChunk *pChunk)

+{

+    eraseOverride(uiSlot, pChunk);

+}

+

+void StateOverride::eraseOverride(UInt32      uiSlot, 

+                                  StateChunk *pChunk)

+{

+    ChunkElement newElem(uiSlot, pChunk);

+

+    

+    std::pair<ChunkStoreIt, ChunkStoreIt> pairIt

+                     = std::equal_range(_vChunks.begin(),

+                                        _vChunks.end  (),

+                                         newElem        );

+

+    for (; pairIt.first != pairIt.second; ++pairIt.first)

+    {

+        if (pairIt.first->first == uiSlot) {

+            _vChunks.erase(pairIt.first);

+            break;

+        }

+    }

+}

+

+void StateOverride::removeOverride(UInt32 uiSlot, StateChunk *pChunk)

+{

+    ShaderProgramChunk *pSPChunk = dynamic_cast<ShaderProgramChunk *>(pChunk);

+

+    if(pSPChunk == NULL)

+    {

+        ShaderProgramVariableChunk *pSPVChunk = 

+            dynamic_cast<ShaderProgramVariableChunk *>(pChunk);

+

+        if(pSPVChunk == NULL)

+        {

+            eraseOverride(uiSlot, pChunk);

+        }

+        else

+        {

+            this->removeOverride(uiSlot, pSPVChunk);

+        }

+    }

+    else

+    {

+        this->removeOverride(uiSlot, pSPChunk);

+    }

+}

diff -rupN 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.h
 d:/_xxx/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.h
--- 
d:/cpp_xxx_/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.h
 2015-10-09 14:26:00.000000000 +0200
+++ 
d:/_xxx/Comp/builder/support/opensg/Source/System/State/Base/OSGStateOverride.h 
    2015-10-27 09:36:23.820912100 +0100
@@ -148,6 +148,17 @@ class OSG_SYSTEM_DLLMAPPING StateOverrid
     void addOverride  (UInt32                      uiSlot, 

                        ShaderProgramVariableChunk *pChunk);

 

+

+    void removeOverride (UInt32                      uiSlot, 

+                         StateChunk                 *pChunk);

+    void removeOverride (UInt32                      uiSlot, 

+                         SimpleSHLChunk             *pChunk);

+    void removeOverride (UInt32                      uiSlot, 

+                         ShaderProgramChunk         *pChunk);

+    void removeOverride (UInt32                      uiSlot, 

+                         ShaderProgramVariableChunk *pChunk);

+

+

     bool empty        (void                      );

 

     bool isTransparent(void                      );

@@ -214,6 +225,9 @@ class OSG_SYSTEM_DLLMAPPING StateOverrid
     void insertOverride(UInt32      uiSlot, 

                         StateChunk *pChunk);

 

+    void eraseOverride (UInt32      uiSlot, 

+                        StateChunk *pChunk);

+

     /*! \}                                                                 */

     /*==========================  PRIVATE  ================================*/

 

------------------------------------------------------------------------------
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to