Exemple #1
0
static int pyPlane3___init__(pyPlane3* self, PyObject* args, PyObject* kwds) {
    float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
    PyObject* init = NULL;
    static char* kwlist[] = { "X", "Y", "Z", "W", NULL };
    static char* kwlist2[] = { "Plane", NULL };

    if (PyArg_ParseTupleAndKeywords(args, kwds, "ffff", kwlist, &x, &y, &z, &w)) {
        (*self->fThis) = hsPlane3(hsVector3(x, y, z), w);
    } else if (PyErr_Clear(), PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist2, &init)) {
        if (init == NULL) {
            (*self->fThis) = hsPlane3();
            return 0;
        }
        if (pyPlane3_Check(init)) {
            (*self->fThis) = (*((pyPlane3*)init)->fThis);
        } else {
            PyErr_SetString(PyExc_TypeError, "__init__ expects a Plane");
            return -1;
        }
    } else {
        return -1;
    }

    return 0;
}
static int pyBoundsOriented_setPlanes(pyBoundsOriented* self, PyObject* value, void*) {
    if (value == NULL) {
        self->fThis->setPlanes(0, NULL);
        return 0;
    } else if (PyList_Check(value)) {
        size_t numPlanes = PyList_Size(value);
        hsPlane3* planes = new hsPlane3[numPlanes];
        for (size_t i=0; i<numPlanes; i++) {
            if (!pyPlane3_Check(PyList_GetItem(value, i))) {
                PyErr_SetString(PyExc_TypeError, "planes should be a list of hsPlane3 objects");
                return -1;
            }
            planes[i] = *((pyPlane3*)PyList_GetItem(value, i))->fThis;
        }
        self->fThis->setPlanes(numPlanes, planes);
        return 0;
    } else {
        PyErr_SetString(PyExc_TypeError, "planes should be a list of hsPlane3 objects");
        return -1;
    }
}