Added back-pointers to referenced entities

This commit is contained in:
Cirilo Bernardo 2016-02-06 09:38:03 +11:00
parent b7a8661a03
commit f52744b29c
7 changed files with 36 additions and 9 deletions

View File

@ -460,6 +460,7 @@ bool WRL1NODE::AddRefNode( WRL1NODE* aNode )
// the same level; for example a Coordinate3 node can be recalled
// at any time to set the current coordinate set.
m_Refs.push_back( aNode );
aNode->addNodeRef( this );
addItem( aNode );
return true;

View File

@ -140,9 +140,18 @@ WRL2NODE::~WRL2NODE()
++sBP;
}
std::list< WRL2NODE* >::iterator sC = m_Refs.begin();
std::list< WRL2NODE* >::iterator eC = m_Refs.end();
while( sC != eC )
{
(*sC)->delNodeRef( this );
++sC;
}
m_Refs.clear();
std::list< WRL2NODE* >::iterator sC = m_Children.begin();
std::list< WRL2NODE* >::iterator eC = m_Children.end();
sC = m_Children.begin();
eC = m_Children.end();
while( sC != eC )
{
@ -416,6 +425,7 @@ bool WRL2NODE::AddRefNode( WRL2NODE* aNode )
}
m_Refs.push_back( aNode );
aNode->addNodeRef( this );
return true;
}

View File

@ -195,19 +195,24 @@ bool WRL2SWITCH::AddRefNode( WRL2NODE* aNode )
return false;
}
if( !WRL2NODE::AddRefNode( aNode ) )
return false;
// take possession if the node is dangling WRL2_SHAPE
if( WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() )
{
WRL2NODE* np = aNode->GetParent();
if( NULL != np )
aNode->SetParent( this );
if( !WRL2NODE::AddChildNode( aNode ) )
{
aNode->SetParent( NULL );
return false;
}
}
if( !WRL2NODE::AddRefNode( aNode ) )
return false;
return true;
}

View File

@ -293,9 +293,6 @@ bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode )
return false;
}
if( !WRL2NODE::AddRefNode( aNode ) )
return false;
// take possession if the node is dangling WRL2_SHAPE
if( WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() )
@ -304,8 +301,18 @@ bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode )
if( NULL != np )
aNode->SetParent( this );
if( !WRL2NODE::AddChildNode( aNode ) )
{
aNode->SetParent( NULL );
return false;
}
}
if( !WRL2NODE::AddRefNode( aNode ) )
return false;
return true;
}

View File

@ -228,6 +228,7 @@ bool X3DIFACESET::AddRefNode( X3DNODE* aNode )
return false;
m_Refs.push_back( aNode );
aNode->addNodeRef( this );
coord = aNode;
return true;
}

View File

@ -219,6 +219,7 @@ bool X3DSHAPE::AddRefNode( X3DNODE* aNode )
if( NULL == appearance )
{
m_Refs.push_back( aNode );
aNode->addNodeRef( this );
appearance = aNode;
}
else
@ -229,6 +230,7 @@ bool X3DSHAPE::AddRefNode( X3DNODE* aNode )
if( NULL == geometry )
{
m_Refs.push_back( aNode );
aNode->addNodeRef( this );
geometry = aNode;
}
else

View File

@ -247,6 +247,7 @@ bool X3DTRANSFORM::AddRefNode( X3DNODE* aNode )
}
m_Refs.push_back( aNode );
aNode->addNodeRef( this );
return true;
}