I noticed that it is possible to create a VecX object using tuples, e.g. v = Vec2( (1,1) ), but it’s not possible to do the same for VBaseX classes.
I tried to add the tuple initialization functionality into the VBase classes and ran into some problems.
- I couldn’t find a constructor in any of the lvector*_src.h’s that explicitly initialized the class using a tuple; Is interrogate magically unpacking tuples behind the scene and then calling c++ constructors such as
INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
- Undeterred, I add an explicit pyobject constructor for VBase2,3,4
INLINE_LINMATH FLOATNAME(LVecBase*)(PyObject *objTuple);
When doing this, I had to explicitly expand
INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE fill_value);
into
INLINE_LINMATH FLOATNAME(LVecBase3)(bool fill_value);
INLINE_LINMATH FLOATNAME(LVecBase3)(float fill_value);
INLINE_LINMATH FLOATNAME(LVecBase3)(double fill_value);
to dodge some function overloading mismatches.
These adjustments seems to work for VBase3 and VBase4, and I can init them with tuples, VBase3( (1,1,1) ). But for unknown reasons, these changes refuse to work with VBase2. Calling VBase2( (1,1) ) seems to completely skip the new pyobject* constructor code and the object is always initialized to x,y =1. Any ideas on why this is happening?
Zhao