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

Method PyTransformLocators

trinity/Eve/SpaceObject/EveSpaceObject2_Blue.cpp:68–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68PyObject* EveSpaceObject2::PyTransformLocators( PyObject* self, PyObject* args )
69{
70 auto pThis = BluePythonCast<EveSpaceObject2*>( self );
71 PyObject* pyLocators = nullptr;
72 if( !PyArg_ParseTuple( args, "O", &pyLocators ) )
73 {
74 return nullptr;
75 }
76
77 auto modelTranslationCurve = pThis->GetModelTranslationCurve();
78 auto modelRotationCurve = pThis->GetModelRotationCurve();
79
80 if( auto locators = BluePythonCast<LocatorStructureList*>( pyLocators ) )
81 {
82 PyObject* result = PyList_New( ssize_t( locators->GetSize() ) );
83 for( size_t i = 0; i < locators->GetSize(); ++i )
84 {
85 auto& locator = ( *locators )[i];
86
87 Vector3 position = locator.position;
88 Quaternion rotation = locator.direction;
89
90 TransformLocator( position, rotation, locator.boneIndex, pThis->m_animationUpdater );
91 if( modelTranslationCurve || modelRotationCurve )
92 ApplyModelTransform( position, rotation, modelTranslationCurve, modelRotationCurve );
93
94 PyObject* tuple = PyTuple_New( 3 );
95 PyTuple_SetItem( tuple, 0, Py_BuildValue( "(fff)", position.x, position.y, position.z ) );
96 PyTuple_SetItem( tuple, 1, Py_BuildValue( "(ffff)", rotation.x, rotation.y, rotation.z, rotation.w ) );
97 PyTuple_SetItem( tuple, 2, ToPython( locator.boneIndex ) );
98 PyList_SetItem( result, ssize_t( i ), tuple );
99 }
100 return result;
101 }
102 else if( PySequence_Check( pyLocators ) )
103 {
104 PyObject* result = PyList_New( PySequence_Size( pyLocators ) );
105 for( ssize_t i = 0;; ++i )
106 {
107 auto item = PySequence_GetItem( pyLocators, i );
108 if( !item )
109 {
110 PyErr_Clear();
111 break;
112 }
113 Vector3 position;
114 Quaternion rotation;
115
116 if( !PyTuple_Check( item ) || !BlueExtractVector( PyTuple_GET_ITEM( item, 0 ), &position.x, 3 ) ||
117 !BlueExtractVector( PyTuple_GET_ITEM( item, 1 ), &rotation.x, 4 ) || !PyLong_Check( PyTuple_GET_ITEM( item, 2 ) ) )
118 {
119 Py_DECREF( item );
120 PyErr_SetString( PyExc_TypeError, "arument must be a sequence of (position, rotation, boneIndex) tuples" );
121 return nullptr;
122 }
123 int boneIndex = int( PyLong_AsLong( PyTuple_GET_ITEM( item, 2 ) ) );
124
125 TransformLocator( position, rotation, boneIndex, pThis->m_animationUpdater );

Callers

nothing calls this directly

Calls 4

TransformLocatorFunction · 0.85
ApplyModelTransformFunction · 0.85
ToPythonFunction · 0.85
GetSizeMethod · 0.45

Tested by

no test coverage detected