Hello,

I have found following using valgrind:

==24954== Conditional jump or move depends on uninitialised value(s)
==24954==    at 0x4B7A4E9: cos (in /lib/libm-2.19.so)
==24954==    by 0x4983E79: osg::Quat::makeRotate(double, double, double, 
double) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954==    by 0x4983F4A: osg::Quat::makeRotate(double, osg::Vec3d const&) (in 
/MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954==    by 0x4572498: osgSim::DirectionalSector::computeMatrix() (in 
/MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954==    by 0x45725D0: osgSim::DirectionalSector::setDirection(osg::Vec3f 
const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954==    by 0x457264E: 
osgSim::DirectionalSector::DirectionalSector(osg::Vec3f const&, float, float, 
float, float) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954==    by 0x41FA64F: LightPoint::addVertex(flt::Vertex&) 
(LightPointRecords.cpp:137)
==24954==    by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, 
flt::Document&) (VertexRecords.cpp:114)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, 
flt::Document&) (RecordInputStream.cpp:75)
==24954==    by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) 
(RecordInputStream.cpp:40)
==24954==    by 0x4211491: 
flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) 
(GeometryRecords.cpp:596)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, 
flt::Document&) (RecordInputStream.cpp:75)
==24954==  Uninitialised value was created by a heap allocation
==24954==    at 0x402A6CC: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-x86-linux.so)
==24954==    by 0x4276E72: operator new(unsigned int) (new_op.cc:52)
==24954==    by 0x41FA5DE: LightPoint::addVertex(flt::Vertex&) 
(LightPointRecords.cpp:137)
==24954==    by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, 
flt::Document&) (VertexRecords.cpp:114)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, 
flt::Document&) (RecordInputStream.cpp:75)
==24954==    by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) 
(RecordInputStream.cpp:40)
==24954==    by 0x4211491: 
flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) 
(GeometryRecords.cpp:596)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, 
flt::Document&) (RecordInputStream.cpp:75)
==24954==    by 0x42049FA: FLTReaderWriter::readNode(std::istream&, 
osgDB::Options const*) const (ReaderWriterFLT.cpp:401)
==24954==    by 0x420695C: FLTReaderWriter::readNode(std::string const&, 
osgDB::Options const*) const (ReaderWriterFLT.cpp:194)
==24954==    by 0x44B1B81: 
osgDB::Registry::ReadNodeFunctor::doRead(osgDB::ReaderWriter&) const (in 
/MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)
==24954==    by 0x44A95AE: osgDB::Registry::read(osgDB::Registry::ReadFunctor 
const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)

I believe, the message is created by

src/osgSim/Sector.cpp lines 220-247/363

The member _rollAngle is not intitialized then computeMatrix() is called after 
first call of

DirectionalSector::DirectionalSector(const osg::Vec3& direction,float 
horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle)

The issue may be fixed, if _rollAngle is initialized with lobeRollAngle in the 
constructor first.


DirectionalSector::DirectionalSector(const osg::Vec3& direction,float 
horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle):

            Sector()

{

    setDirection(direction);

    setHorizLobeAngle(horizLobeAngle);

    setVertLobeAngle(vertLobeAngle);

    setLobeRollAngle(lobeRollAngle);

    setFadeAngle(fadeAngle);

}



void DirectionalSector::computeMatrix()

{

  double heading = atan2(_direction[0], _direction[1]);

  double pitch   = atan2(_direction[2], sqrt(_direction[0]*_direction[0] + 
_direction[1]*_direction[1]));

  double roll    = _rollAngle;



  _local_to_LP.setRotate(osg::Quat(heading,osg::Vec3d(0.0, 0.0, -1.0)));

  _local_to_LP.preMultRotate(osg::Quat(pitch, osg::Vec3d(1.0, 0.0, 0.0)));

  _local_to_LP.preMultRotate(osg::Quat(roll, osg::Vec3d(0.0, 1.0, 0.0)));

}





void DirectionalSector::setDirection(const osg::Vec3& direction)

{

   _direction = direction ;

   computeMatrix() ;

}

[...]



void DirectionalSector::setLobeRollAngle(float angle)

{

    _rollAngle = angle ;

    computeMatrix() ;

}







Mit freundlichen Grüßen / Yours sincerely

Peter Sturm



Rheinmetall Defence Electronics GmbH
Brüggeweg 54
28309 Bremen / Germany

Sitz der Gesellschaft : Bremen
Amtsgericht Bremen HRB 9659

Geschäftsführung:
Helmut Möring
Thorsten Quade
Ulrich Sasse

Vorsitzender des Aufsichtsrats:
Gordon Hargreave

This email may contain confidential information. If you are not the intended 
addressee, or if the information provided in this email (including any 
attachments) is evidently not destined for you, kindly inform us promptly and 
delete the message received in error (including any attachments) by erasing it 
from all your computers and other storage devices or media and destroying any 
hard copies thereof. Any unauthorized processing, forwarding, disclosure, 
distribution, divulgation, storage, printout or other use of this message or 
its attachment is prohibited. If your system is infected or otherwise bugged by 
any virus that is carried by this email, we disclaim any liability whatsoever 
for the ensuing loss or damage unless caused by our intention or gross 
negligence.



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

Reply via email to