| 48 | |
| 49 | |
| 50 | PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) |
| 51 | { |
| 52 | auto pThis = BluePythonCast<Tr2Sprite2dPolygon*>( self ); |
| 53 | PyObject* pyPositions = nullptr; |
| 54 | PyObject* pyTransform = nullptr; |
| 55 | PyObject* pyColors = nullptr; |
| 56 | PyObject* pyTexCoord0 = nullptr; |
| 57 | PyObject* pyTexCoord1 = nullptr; |
| 58 | |
| 59 | if( !PyArg_ParseTuple( args, "OOO|OO", &pyPositions, &pyTransform, &pyColors, &pyTexCoord0, &pyTexCoord1 ) ) |
| 60 | { |
| 61 | return nullptr; |
| 62 | } |
| 63 | |
| 64 | Vector2 position; |
| 65 | Color color; |
| 66 | Vector2 texcoord0; |
| 67 | Vector2 texcoord1; |
| 68 | |
| 69 | Matrix transform( XMMatrixIdentity() ); |
| 70 | if( Py_None == pyTransform ) |
| 71 | { |
| 72 | transform = XMMatrixIdentity(); |
| 73 | } |
| 74 | else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || |
| 75 | !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || |
| 76 | !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || |
| 77 | !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) |
| 78 | { |
| 79 | PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); |
| 80 | return nullptr; |
| 81 | } |
| 82 | |
| 83 | bool constPosition = ToFloatTuple( pyPositions, 2, &position.x ); |
| 84 | if( !constPosition && !PySequence_Check( pyPositions ) ) |
| 85 | { |
| 86 | PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); |
| 87 | return nullptr; |
| 88 | } |
| 89 | bool constColor = ToFloatTuple( pyColors, 4, &color.r ); |
| 90 | if( !constColor && !PySequence_Check( pyColors ) ) |
| 91 | { |
| 92 | PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); |
| 93 | return nullptr; |
| 94 | } |
| 95 | bool constTexcoord0 = true; |
| 96 | if( pyTexCoord0 ) |
| 97 | { |
| 98 | constTexcoord0 = ToFloatTuple( pyTexCoord0, 2, &texcoord0.x ); |
| 99 | if( !constTexcoord0 && !PySequence_Check( pyTexCoord0 ) ) |
| 100 | { |
| 101 | PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); |
| 102 | return nullptr; |
| 103 | } |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | texcoord0[0] = 0.f; |
nothing calls this directly
no test coverage detected