Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old osg::Object::clone() has changed so that it now requires a Cloner as paramter. This is passed on to the copy constructor to help control the shallow vs deep copying. The old functionality of clone() which was clone of type has been renamed to cloneType(). Updated all of the OSG to work with these new conventions, implemention all the required copy constructors etc. A couple of areas will do shallow copies by design, a couple of other still need to be updated to do either shallow or deep. Neither of the shallow or deep copy operations have been tested yet, only the old functionality of the OSG has been checked so far, such running the viewer on various demo datasets. Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which was not checking that Group didn't have have any attached StateSet's, Callbacks or UserData. These checks have now been added, which fixes a bug which was revealled by the new osgscribe demo, this related to removal of group acting as state decorator. method
This commit is contained in:
@@ -49,6 +49,97 @@ GeoSet::GeoSet()
|
||||
|
||||
}
|
||||
|
||||
|
||||
GeoSet::GeoSet(const GeoSet& geoset,const Cloner& cloner):
|
||||
Drawable(geoset,cloner)
|
||||
{
|
||||
// ensure that the num of vertices etc have been set up before we copy.
|
||||
geoset.computeNumVerts();
|
||||
|
||||
_adf = geoset._adf;
|
||||
|
||||
_numprims = geoset._numprims;
|
||||
_primtype = geoset._primtype;
|
||||
_needprimlen = geoset._needprimlen;
|
||||
_oglprimtype = geoset._oglprimtype;
|
||||
_primlength = geoset._primlength;
|
||||
_flat_shaded_skip = geoset._flat_shaded_skip;
|
||||
if (geoset._primLengths)
|
||||
{
|
||||
_primLengths = new int [_primlength];
|
||||
memcpy(_primLengths,geoset._primLengths,_primlength);
|
||||
}
|
||||
else
|
||||
{
|
||||
_primLengths = 0L;
|
||||
}
|
||||
|
||||
_numcoords = geoset._numcoords;
|
||||
_cindex = geoset._cindex;
|
||||
if (geoset._coords)
|
||||
{
|
||||
_coords = new Vec3 [_numcoords];
|
||||
memcpy(_coords,geoset._coords,_numcoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
_coords = 0L;
|
||||
}
|
||||
|
||||
_normal_binding = geoset._normal_binding;
|
||||
_numnormals = geoset._numnormals;
|
||||
_nindex = geoset._nindex;
|
||||
if (geoset._normals)
|
||||
{
|
||||
_normals = new Vec3 [_numnormals];
|
||||
memcpy(_normals,geoset._normals,_numnormals);
|
||||
}
|
||||
else
|
||||
{
|
||||
_normals = 0L;
|
||||
}
|
||||
|
||||
_color_binding = geoset._color_binding;
|
||||
_numcolors = geoset._numcolors;
|
||||
_colindex = geoset._colindex;
|
||||
if (geoset._colors)
|
||||
{
|
||||
_colors = new Vec4 [_numcolors];
|
||||
memcpy(_colors,geoset._colors,_numcolors);
|
||||
}
|
||||
else
|
||||
{
|
||||
_colors = 0L;
|
||||
}
|
||||
|
||||
_texture_binding = geoset._texture_binding;
|
||||
_numtcoords = geoset._numtcoords;
|
||||
_tindex = geoset._tindex;
|
||||
if (geoset._tcoords)
|
||||
{
|
||||
_tcoords = new Vec2 [_numtcoords];
|
||||
memcpy(_tcoords,geoset._tcoords,_numtcoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tcoords = 0L;
|
||||
}
|
||||
|
||||
_iaindex = geoset._iaindex;
|
||||
_iaformat = geoset._iaformat;
|
||||
_ogliaformat = geoset._ogliaformat;
|
||||
_fast_path = geoset._fast_path;
|
||||
if (geoset._iarray)
|
||||
{
|
||||
_iarray = 0L;
|
||||
osg::notify(osg::WARN)<<"Warning :: GeoSet copy constructor error, copying of interleaved arrays unsupported."<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
_iarray = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
#define INDEX_ARRAY_DELETE(A) if (A._is_ushort) ushortList.insert(A._ptr._ushort); else uintList.insert(A._ptr._uint);
|
||||
|
||||
void GeoSet::AttributeDeleteFunctor::operator() (GeoSet* gset)
|
||||
|
||||
Reference in New Issue
Block a user