[C++-sig] boost.python - C++ class overridden in python causes slicing
Jean-Sébastien Guay
jean-sebastien.guay at cm-labs.com
Tue Sep 8 21:41:03 CEST 2009
Hi again Troy,
> I was thinking of setting up a googlecode project for this work, because
> there is at least one other person who might be interested in working
> with me on it (Paul Melis). I'll see if I can do that soon.
It's done now, here:
http://code.google.com/p/osgboostpython/
Note that I do my work on Windows, I've tried to make my boost-build.jam
and Jamroot as platform-independent as possible but you may have to
tweak some things to make it build/run. You'll need OSG_ROOT and
BOOST_ROOT pointing at the right places for it to build.
Once the python modules are built, copy them into lib/osg, lib/osgGA,
lib/osgDB and lib/osgViewer (I've scripted that for Windows but I should
really make a "stage" rule in the jam script, feel free to do it if you
want).
Then run
python test/osg/test.py 9
(the 9 runs test #9 only, the file contains 10 different tests)
That will work, it will print the following:
python apply_Group - node name: g1
python apply_Group - node name: g2
python apply_Node - node name: n
You'll see the problem if you comment out the apply_Group method of the
DerivedVisitor class in test/osg/test.py. Then it will only print out:
python apply_Node - node name: g1
when it should print out:
python apply_Node - node name: g1
python apply_Node - node name: g2
python apply_Node - node name: n
which is what the C++ code attached does.
You'll also see in test/osgViewer/test.py the other test I was referring
to, the NodeCallback test. If you change the code to set the callback as
CullCallback instead of UpdateCallback, you'll see that the model will
no longer be displayed, even though traverse() is being called. The C++
code attached also demonstrates that this should not happen - the model
should still be displayed after setting a CullCallback as long as the
callback calls traverse(). (you can comment out traverse() in the
callback's operator() method to see that the model will no longer be
displayed).
I hope this helps you help me :-)
I just had a thought, maybe I need to wrap the traverse() methods in
osg::Node and osg::Group? Would that allow call_method to call the right
one and not slice off the argument? I had not wrapped them because in
general I don't think they'd be useful in python code, but maybe they're
necessary for this to work? I'll try that and see.
Thanks in advance,
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.guay at cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090908/7507e1a5/attachment.asc>
More information about the Cplusplus-sig
mailing list