Hi Patrick,

Similar to the change that Judson suggested for 'Add_new_point', the 
osg::Matrix and
osg::Vec3f you pass into the constructor should be 'const osg::Matrix&' (same 
for vector),
otherwise you are making a copy of the object every time.

The empty destructor is okay, as everything is contained in smart pointers and 
will be
properly cleaned up.  (Except for the original usage of 'Add_new_point'.)

Unless you need them for later modification, you don't have to have member 
variables for
the matrices, the osg::Geode, and the color/normal arrays.

Cheers,
/ulrich

On 10/05/13 23:57, Judson Weissert wrote:
> Hi Patrick,
> 
> On 5/9/2013 9:16 PM, Patrick Keenan wrote:
>>...
>> Code:
>>
>> osg::Vec3Array* line_pts = new osg::Vec3Array;
>>     line_pts->push_back(osg::Vec3(100, 0, 0));
>>     line_pts->push_back(osg::Vec3(0, 100, 500));
>>     line_pts->push_back(osg::Vec3(100, 100, 100));
>>     
>>
>>     lines_test = new 
>> M_OSG_line_strip(osg::Matrix::rotate(osg::inDegrees(0.0f), 0.0f,
>> 0.0f, 1.0f),
>>                                     osg::Matrix::translate(0.0f, 0.0f, 0.0f),
>>                                     
>> osg::Matrix::rotate(osg::inDegrees(0.0f), 0.0f,
>> 0.0f, 1.0f),
>>                                     line_pts,
>>                                     osg::Vec4(0.0f,1.0f,1.0f,1.0f)
>>                                     );
> 
> Memory leak if lines_test assignment line throws an exception (lines_pts will 
> leak). An
> osg::ref_ptr would solve this.
> 
>>...
>> Code:
>>
>> void M_frame::OnTestBtnClick(wxCommandEvent& WXUNUSED(event))
>> {
>>     osg::Vec3f* new_pt = new  osg::Vec3f(4000.0f, 2000.0f, 0.0f); // works
>>     lines_test->Add_new_point(new_pt);
>> }
>>
> Another memory leak for all points created since nobody is calling delete. I 
> suggest
> passing osg::Vec3 parameters by value or const reference.
> 
> Regards,
> 
> Judson

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to