mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
allow swizzling of higher-dimension vectors from lower-dimension ones (eg vec2.xyxy)
This commit is contained in:
parent
0703e32d6f
commit
53835b541d
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#ifndef CPPPARSER
|
#ifndef CPPPARSER
|
||||||
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
|
||||||
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
|
||||||
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -85,6 +87,21 @@ __getattr__, const string &attr_name) {
|
|||||||
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
|
||||||
|
|
||||||
|
} else if (attr_name.size() == 3) {
|
||||||
|
FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
|
||||||
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
|
||||||
|
|
||||||
|
} else if (attr_name.size() == 4) {
|
||||||
|
FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
|
||||||
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
|
vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
|
||||||
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -170,4 +187,3 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#ifndef CPPPARSER
|
#ifndef CPPPARSER
|
||||||
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
|
||||||
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
|
||||||
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -94,6 +95,14 @@ __getattr__, const string &attr_name) {
|
|||||||
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
|
||||||
|
|
||||||
|
} else if (attr_name.size() == 4) {
|
||||||
|
FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
|
||||||
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
|
vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
|
||||||
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#ifndef CPPPARSER
|
#ifndef CPPPARSER
|
||||||
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
|
||||||
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
|
||||||
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -51,6 +53,21 @@ __getattr__, const string &attr_name) {
|
|||||||
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
|
||||||
|
|
||||||
|
} else if (attr_name.size() == 3) {
|
||||||
|
FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
|
||||||
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
|
||||||
|
|
||||||
|
} else if (attr_name.size() == 4) {
|
||||||
|
FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
|
||||||
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
|
vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
|
||||||
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -67,4 +84,3 @@ INLINE int EXT_METHOD_ARGS(FLOATNAME(LVector2),
|
|||||||
__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
|
__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
|
||||||
return CALL_EXT_METHOD(FLOATNAME(LVecBase2), __setattr__, this, self, attr_name, assign);
|
return CALL_EXT_METHOD(FLOATNAME(LVecBase2), __setattr__, this, self, attr_name, assign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#ifndef CPPPARSER
|
#ifndef CPPPARSER
|
||||||
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
|
||||||
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
|
||||||
|
IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -60,6 +61,14 @@ __getattr__, const string &attr_name) {
|
|||||||
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
|
||||||
|
|
||||||
|
} else if (attr_name.size() == 4) {
|
||||||
|
FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
|
||||||
|
vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
|
||||||
|
vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
|
||||||
|
vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
|
||||||
|
vec->_v.v._3 = this->_v.data[attr_name[3] - 'x'];
|
||||||
|
return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user