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

Method PySetVertices

trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp:168–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args )
169{
170 auto pThis = BluePythonCast<Tr2Sprite2dLineTrace*>( self );
171 PyObject* pyPositions = nullptr;
172 PyObject* pyTransform = nullptr;
173 PyObject* pyColors = nullptr;
174 PyObject* pyNames = nullptr;
175
176 if( !PyArg_ParseTuple( args, "O|OOO", &pyPositions, &pyTransform, &pyColors, &pyNames ) )
177 {
178 return nullptr;
179 }
180
181 if( Py_None == pyPositions )
182 {
183 pyPositions = nullptr;
184 }
185 if( Py_None == pyColors )
186 {
187 pyColors = nullptr;
188 }
189 if( Py_None == pyNames )
190 {
191 pyNames = nullptr;
192 }
193
194 Vector2 position;
195 Color color;
196 std::string name;
197
198 Matrix transform( XMMatrixIdentity() );
199 if( Py_None == pyTransform || pyTransform == nullptr )
200 {
201 transform = XMMatrixIdentity();
202 }
203 else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 ||
204 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) ||
205 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) ||
206 !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) )
207 {
208 PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" );
209 return nullptr;
210 }
211
212 bool constPosition = true;
213 if( pyPositions )
214 {
215 constPosition = ToFloatTuple( pyPositions, 2, &position.x );
216 if( !constPosition && !PySequence_Check( pyPositions ) )
217 {
218 PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" );
219 return nullptr;
220 }
221 }
222 bool constColor = true;
223 if( pyColors )
224 {
225 constColor = ToFloatTuple( pyColors, 4, &color.r );

Callers

nothing calls this directly

Calls 4

IsPyStringFunction · 0.85
sizeMethod · 0.80
ToFloatTupleFunction · 0.70
SetDirtyMethod · 0.45

Tested by

no test coverage detected