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

Function PySetElementLayout

trinity/Tr2RuntimeInstanceData_Blue.cpp:11–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10#if BLUE_WITH_PYTHON
11static PyObject* PySetElementLayout( PyObject* self, PyObject* args )
12{
13 Tr2RuntimeInstanceData* pThis = BluePythonCast<Tr2RuntimeInstanceData*>( self );
14
15 PyObject* pyDecl;
16 if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pyDecl ) )
17 {
18 return nullptr;
19 }
20
21 Tr2VertexDefinition def;
22 for( int i = 0; i < PyList_GET_SIZE( pyDecl ); ++i )
23 {
24 PyObject* el = PyList_GetItem( pyDecl, i );
25 if( !PyTuple_Check( el ) || PyTuple_GET_SIZE( el ) != 3 )
26 {
27 PyErr_SetString( PyExc_TypeError, "Argument 1 needs to be a list of 3-element tuples of numbers" );
28 return nullptr;
29 }
30 PyObject* pyUsage = PyTuple_GetItem( el, 0 );
31 if( !PyNumber_Check( pyUsage ) )
32 {
33 PyErr_SetString( PyExc_TypeError, "Argument 1 needs to be a list of 3-element tuples of numbers" );
34 return nullptr;
35 }
36 int usage = int( PyNumber_AsSsize_t( pyUsage, nullptr ) );
37 if( usage < 0 || usage > Tr2ParticleElementDeclarationName::CUSTOM )
38 {
39 PyErr_SetString( PyExc_TypeError, "Invalid element usage" );
40 return nullptr;
41 }
42 PyObject* pyUsageIndex = PyTuple_GetItem( el, 1 );
43 if( !PyNumber_Check( pyUsageIndex ) )
44 {
45 PyErr_SetString( PyExc_TypeError, "Argument 1 needs to be a list of 3-element tuples of numbers" );
46 return nullptr;
47 }
48 int usageIndex = int( PyNumber_AsSsize_t( pyUsageIndex, nullptr ) );
49 if( usageIndex < 0 || usageIndex > 7 )
50 {
51 PyErr_SetString( PyExc_TypeError, "Invalid element usage index" );
52 return nullptr;
53 }
54 PyObject* pyType = PyTuple_GetItem( el, 2 );
55 if( !PyNumber_Check( pyType ) )
56 {
57 PyErr_SetString( PyExc_TypeError, "Argument 1 needs to be a list of 3-element tuples of numbers" );
58 return nullptr;
59 }
60 int type = int( PyNumber_AsSsize_t( pyType, nullptr ) );
61 if( type <= 0 || type > 4 )
62 {
63 PyErr_SetString( PyExc_TypeError, "Invalid element type" );
64 return nullptr;
65 }
66
67 def.Add(
68 Tr2VertexDefinition::DataType( Tr2VertexDefinition::DT_FLOAT32 | ( ( type - 1 ) << Tr2VertexDefinition::DT_SIZE_OFFSET ) ),

Callers

nothing calls this directly

Calls 6

DataTypeEnum · 0.85
GetD3DUsageMethod · 0.80
TypeEnum · 0.50
AddMethod · 0.45
SetLayoutMethod · 0.45

Tested by

no test coverage detected