So I debugged this and realised that before the second elements where added to
the ValueList the lists were cleared and reset to empty lists. So when the next
element is added the list is set to the default value which is true. It appears
in subsequent rounds of adding new children to the list they are again cleared.
I have added a debug trace to show where the list is cleared and on the next
iteration where the lists are all set to true. I'm not sure how to fix this as
the code makes a call to osgSim::MultiSwitch::removeChild which clears the
list. Not sure why the code is calling removeChild.
Some of the line numbers may not align with current OpenSceneGraph 3.4.0
version as I have added some logging into it.
Tony V
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65931#65931
MultiSwitch.cpp
Description: Binary data
(gdb) n
77 if (_children.size()>values.size())
(gdb) n
72 for(SwitchSetList::iterator itr=_values.begin();
(gdb) n
89 }
(gdb) p _values
$63 = std::vector of length 2, capacity 2 = {
std::vector of length 1, capacity 32 = {1},
std::vector of length 1, capacity 32 = {0}}
(gdb) n
flt::Switch::addChild (this=0x806ccc8, child=...)
at
/home/avasile/src/OpenSceneGraph-3.4.0/src/osgPlugins/OpenFlight/PrimaryRecords.cpp:619
619 }
(gdb) n
flt::Group::readRecord (this=0x806d388, in=..., document=...)
at
/home/avasile/src/OpenSceneGraph-3.4.0/src/osgPlugins/OpenFlight/PrimaryRecords.cpp:239
239 _parent->addChild(*_group);
(gdb) c
Continuing.
Breakpoint 4, osgSim::MultiSwitch::addChild (this=0x8071ea0, child=0x80815b0)
at /home/avasile/src/OpenSceneGraph-3.4.0/src/osgSim/MultiSwitch.cpp:69
69 dump("addChild " + getName(), _values);
(gdb) p _values
$64 = std::vector of length 2, capacity 2 = {
std::vector of length 0, capacity 32,
std::vector of length 0, capacity 32}
(gdb) p -r _values
No symbol "r" in current context.
(gdb) p /r _values
$65 = { >,
std::allocator > > >> = {
_M_impl = { > >> =
{<__gnu_cxx::new_allocator > >> = {}, }, _M_start = 0x8071f58, _M_finish = 0x8071f80,
_M_end_of_storage = 0x8071f80}}, }
(gdb) p _values._M_impl._M_start
$66 = (std::vector > *) 0x8071f58
(gdb) p *_values._M_impl._M_start
$67 = std::vector of length 0, capacity 32
(gdb) p /r *_values._M_impl._M_start
$68 = { >> = {
_M_impl = {> =
{<__gnu_cxx::new_allocator> = {}, },
_M_start = { =
{> =
{},
_M_p = 0x8072028, _M_offset = 0}, },
_M_finish = { =
{> =
{},
_M_p = 0x8072028, _M_offset = 0}, },
_M_end_of_storage = 0x807202c}}, }
(gdb) p /r *_values._M_impl._M_start._M_impl
No symbol "operator*" in current context.
(gdb) p /r _values._M_impl._M_start._M_impl
$69 = {> = {<__gnu_cxx::new_allocator> = {}, },
_M_start = { =
{> =
{}, _M_p = 0x8072028,
_M_offset = 0}, },
_M_finish = { =
{> =
{}, _M_p = 0x8072028,
_M_offset = 0}, }, _M_end_of_storage = 0x807202c}
(gdb) p /r _values._M_impl._M_start._M_impl._M_p
There is no member or method named _M_p.
(gdb) p /r _values._M_impl._M_start._M_impl._M_start
$70 = { =
{> =
{}, _M_p = 0x8072028,
_M_offset = 0}, }
(gdb) p /r _values._M_impl._M_start._M_impl._M_start+1
$71 = { =
{> =
{}, _M_p = 0x8072028,
_M_offset = 1}, }
(gdb) p /r _values._M_impl._M_start._M_impl._M_start+0
$72 = { =
{> =
{}, _M_p = 0x8072028,
_M_offset = 0}, }
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/avasile/src/junk/f1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Breakpoint 1, main (argc=1, argv=0xb254) at f.C:36
36 osg::ref_ptr loadedModel =
osgDB::readNodeFile("radar.flt");
(gdb) c
Continuing.
Id = damSw18
Current Mask = 0
Number of Mask = 2
Words in Mask = 1
Mask Word[0] = 4294967293
Mask Word[1] = 2
Number of Children = 0
nMaskBit = 0
nMaskWord = 0
Which = damSw18
Switch set = 0
Pos = 0
Value = 1
Breakpoint 3, osgSim::MultiSwitch::setValue (this=0x806cda8, switchSet=0,
pos=0, value=true)
at /home/avasile/src/OpenSceneGraph-3.4.0/src/osgSim/MultiSwitch.cpp:140
140 dump("setValue before expand ", _values);
(gdb) c
Continuing.
setValue before expand
===
After expand
values[0]
===
After Assign damSw18
values[0]
list[0] = 1
===
nMaskBit = 0
nMaskWord = 1
Which = damSw18
Switch set = 1
Pos = 0
Value = 0
Breakpoint 3, osgSim::MultiSwitch::setValue (this=0x806cda8, switchSet=1,
pos=0, value=false)
at /home/avasile/src/OpenSceneGraph-3.4.0/src/osgSim/MultiSwitch.cpp:140
140 dump("setValue before expand ", _values);
(gdb) c
Continuing.
setValue before expand
values[0]
list[0] = 1
===
After expand
values[0]
list[0] = 1
values[1]
===
After Assign damSw18
values[0]