MCPcopy Create free account
hub / github.com/carbonengine/trinity / PySetVertices

Method PySetVertices

trinity/Sprite2d/Tr2Sprite2dPolygon_Blue.cpp:212–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211
212PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args )
213{
214 auto pThis = BluePythonCast<Tr2Sprite2dPolygon*>( self );
215 PyObject* pyPositions = nullptr;
216 PyObject* pyTransform = nullptr;
217 PyObject* pyColors = nullptr;
218 PyObject* pyTexCoord0 = nullptr;
219 PyObject* pyTexCoord1 = nullptr;
220
221 if( !PyArg_ParseTuple( args, "O|OOOO", &pyPositions, &pyTransform, &pyColors, &pyTexCoord0, &pyTexCoord1 ) )
222 {
223 return nullptr;
224 }
225
226 if( Py_None == pyPositions )
227 {
228 pyPositions = nullptr;
229 }
230 if( Py_None == pyColors )
231 {
232 pyColors = nullptr;
233 }
234 if( Py_None == pyTexCoord0 )
235 {
236 pyTexCoord0 = nullptr;
237 }
238 if( Py_None == pyTexCoord1 )
239 {
240 pyTexCoord1 = nullptr;
241 }
242
243 Vector2 position;
244 Color color;
245 Vector2 texcoord0;
246 Vector2 texcoord1;
247
248 Matrix transform( XMMatrixIdentity() );
249 if( Py_None == pyTransform || pyTransform == nullptr )
250 {
251 transform = XMMatrixIdentity();
252 }
253 else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 ||
254 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) ||
255 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) ||
256 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) )
257 {
258 PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" );
259 return nullptr;
260 }
261
262 bool constPosition = true;
263 if( pyPositions )
264 {
265 constPosition = ToFloatTuple( pyPositions, 2, &position.x );
266 if( !constPosition && !PySequence_Check( pyPositions ) )
267 {
268 PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" );
269 return nullptr;

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
ToFloatTupleFunction · 0.70
SetDirtyMethod · 0.45

Tested by

no test coverage detected