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

Method PyAppendVertices

trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp:49–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48
49PyObject* Tr2Sprite2dLineTrace::PyAppendVertices( PyObject* self, PyObject* args )
50{
51 auto pThis = BluePythonCast<Tr2Sprite2dLineTrace*>( self );
52 PyObject* pyPositions = nullptr;
53 PyObject* pyTransform = nullptr;
54 PyObject* pyColors = nullptr;
55 PyObject* pyNames = nullptr;
56
57 if( !PyArg_ParseTuple( args, "OOO|O", &pyPositions, &pyTransform, &pyColors, &pyNames ) )
58 {
59 return nullptr;
60 }
61
62 Vector2 position;
63 Color color;
64 std::string name;
65
66 Matrix transform( XMMatrixIdentity() );
67 if( Py_None == pyTransform )
68 {
69 transform = XMMatrixIdentity();
70 }
71 else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 ||
72 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) ||
73 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) ||
74 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) )
75 {
76 PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" );
77 return nullptr;
78 }
79
80 bool constPosition = ToFloatTuple( pyPositions, 2, &position.x );
81 if( !constPosition && !PySequence_Check( pyPositions ) )
82 {
83 PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" );
84 return nullptr;
85 }
86 bool constColor = ToFloatTuple( pyColors, 4, &color.r );
87 if( !constColor && !PySequence_Check( pyColors ) )
88 {
89 PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" );
90 return nullptr;
91 }
92 if( pyNames )
93 {
94 if( !PySequence_Check( pyNames ) )
95 {
96 PyErr_SetString( PyExc_TypeError, "names parameter must be a sequence of strings" );
97 return nullptr;
98 }
99 }
100
101 for( ssize_t index = 0;; ++index )
102 {
103 if( !constPosition )
104 {
105 auto item = PySequence_GetItem( pyPositions, index );
106 if( !item )

Callers

nothing calls this directly

Calls 5

IsPyStringFunction · 0.85
CreateInstanceMethod · 0.80
AppendMethod · 0.80
ToFloatTupleFunction · 0.70
SetDirtyMethod · 0.45

Tested by

no test coverage detected