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

Function PyWrapVariable

trinity/Tr2VariableStore_Blue.cpp:13–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12#if BLUE_WITH_PYTHON
13static PyObject* PyWrapVariable( TriVariable* variable )
14{
15 if( variable == NULL )
16 {
17 PyErr_SetString( PyExc_KeyError, "Variable store variable is not set." );
18 return NULL;
19 }
20 switch( variable->GetType() )
21 {
22 case TRIVARIABLE_INVALID:
23 case TRIVARIABLE_UNKNOWN_FLOAT: {
24 Py_RETURN_NONE;
25 }
26 case TRIVARIABLE_TEXTURE_RES: {
27 ITr2TextureProvider* res = NULL;
28 variable->GetValue( res );
29
30 return PyOS->WrapBlueObject( res );
31 }
32 case TRIVARIABLE_GPUBUFFER: {
33 ITr2GpuBuffer* res = NULL;
34 variable->GetValue( res );
35
36 return PyOS->WrapBlueObject( res );
37 }
38 case TRIVARIABLE_INT: {
39 int value;
40 variable->GetValue( value );
41 return Py_BuildValue( "i", value );
42 }
43 case TRIVARIABLE_FLOAT: {
44 float value;
45 variable->GetValue( value );
46 return Py_BuildValue( "f", value );
47 }
48 case TRIVARIABLE_FLOAT2: {
49 Vector2 value;
50 variable->GetValue( value );
51 return Py_BuildValue( "ff", value.x, value.y );
52 }
53 case TRIVARIABLE_FLOAT3: {
54 Vector3 value;
55 variable->GetValue( value );
56 return Py_BuildValue( "(fff)", value.x, value.y, value.z );
57 }
58 case TRIVARIABLE_FLOAT4: {
59 Vector4 value;
60 variable->GetValue( value );
61 return Py_BuildValue( "(ffff)", value.x, value.y, value.z, value.w );
62 }
63 case TRIVARIABLE_FLOAT4X4: {
64 Matrix value;
65 variable->GetValue( value );
66
67 PyObject* ret = PyTuple_New( 4 );
68
69 // Start of floating point of array so we can iterate simply over the data
70 const float* array = &value._11;

Callers 5

PyRegisterVariableFunction · 0.85
PyFindVariableFunction · 0.85
PyFindLocalVariableFunction · 0.85
PyGetVariableFunction · 0.85
PyGetLocalVariableFunction · 0.85

Calls 2

GetTypeMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected