[osg-users] osg2.4 osgUtil::Tessellator bug,cause memory leak
heishuijing_2000
heishuijing_2000 at 126.com
Wed Jul 23 02:37:06 PDT 2008
Thanks , Robert ,i will follow what you said :)
在2008-07-23 17:00:31,"Robert Osfield" <robert.osfield at gmail.com> 写道:
>Hi Heishujing,
>
>If you think you have a bug fix could you please post the whole
>modified file to osg-submissions. You can subscribe to the list via:
>
> http://www.openscenegraph.org/projects/osg/wiki/MailingLists
>
>Also have a read through the notes on SubmissionsProtocol so you know
>the best way to submit changes for review/merging.
>
> http://www.openscenegraph.org/projects/osg/wiki/MailingLists/SubmissionsProtocol
>
>Also when posting could you provide your full name, as I credit all
>contributors in the svn commit messages (this is what the AUTHORS.txt)
>comes from.
>
>
>Thanks,
>Robert.
>
>On Wed, Jul 23, 2008 at 2:17 AM, heishuijing_2000
> geom = new osg::Geometry;
>> >>> geom->setVertexArray(vertices.get());
>> >>> geom->setNormalArray(pNormal.get());
>> >>> geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
>> >>> geom->addPrimitiveSet(new
>> >>> osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,vertices->size()));
>> >>> osg::ref_ptr< osgUtil::Tessellator > tes = new
>> osgUtil::Tessellator();
>> >>> tes->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
>> >>> tes->setBoundaryOnly(false);
>> >>> tes->setWindingType( osgUtil::Tessellator::TESS_WINDING_ODD);
>> >>> tes->retessellatePolygons(*geom);
>>
>> >>> osg::ref_ptr geode = new osg::Geode;
>> >>> geode->addDrawable(geom.get());
>> >>> osg::ref_ptr pGroup = new osg::Group;
>> >>> pGroup->addChild(geode.get());
>> >>> viewer.setSceneData( pGroup.get() );
>>
>> >>> I test this code in non-MFC project such as console project,that
>> works
>> >>> perfect.No memory leak is reported. But when i turn to osg MFC
>> project,the
>> >>> VS always reports memory leak . I notice that if the polygon is
>> >>> self-intersect ,there must be memory leak report in MFC project.
>>
>> >>> I really do not know how to do about it . I just want to find a
>> method to
>> >>> prevent the VS reprot false memory leak. Anyone help me? Thank you
>> ,:)
>>
>> Recently i trace this memory leak In VS with osg2.4 osgviewerMFC
>> project, i do find the problem.I modify the osg code:
>> void Tessellator::reset()
>> {
>> if (_tobj)
>> {
>> gluDeleteTess(_tobj);
>> _tobj = 0;
>> }
>> for (Vec3dList::iterator i = _coordData.begin(); i !=
>> _coordData.end(); ++i) {
>> delete (*i);
>> }
>> _coordData.clear();
>> _newVertexList.clear();
>> _primList.clear();
>> _errorCode = 0;
>> }
>> as below:
>>
>> void Tessellator::reset()
>> {
>> if (_tobj)
>> {
>> gluDeleteTess(_tobj);
>> _tobj = 0;
>> }
>> for (Vec3dList::iterator i = _coordData.begin(); i !=
>> _coordData.end(); ++i) {
>> delete (*i);
>> }
>> osg::Vec3* vertex = NULL;
>> for (NewVertexList::iterator j = _newVertexList.begin(); j !=
>> _newVertexList.end(); ++j) {
>> NewVertex& newVertex = (*j);
>> vertex = newVertex._vpos;
>> delete vertex;
>> newVertex._vpos = NULL;
>> }
>> vertex = NULL;
>> _coordData.clear();
>> _newVertexList.clear();
>> _primList.clear();
>> _errorCode = 0;
>> }
>>
>> Then the memory leak report disappears,and this does perfect. As
>> glu does, osgUtil::Tessalator can draw composite polygon containing concave
>> polygon and self-intersecting polygon.
>>
>>
>>
>> ________________________________
>> 卡卡上网安全助手6.0,震撼上市,绝杀木马!
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>_______________________________________________
>osg-users mailing list
>osg-users at lists.openscenegraph.org
>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/76cb11c5/attachment-0003.htm>
More information about the osg-users
mailing list