Skip to content

Commit 3ff694e

Browse files
author
David
committed
Added define for FRotator argument order if really want original UnrealEnginePython order.
1 parent bfdea2a commit 3ff694e

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "UEPyFRotator.h"
22

3+
4+
// use this definition if want original argument order for FRotator
5+
//#define USE_UNREALENGINEPYTHON_ORDER 1
6+
7+
38
static PyObject *py_ue_frotator_get_vector(ue_PyFRotator *self, PyObject * args) {
49
FVector vec = self->rot.Vector();
510
return py_ue_new_fvector(vec);
@@ -89,8 +94,14 @@ static PyGetSetDef ue_PyFRotator_getseters[] = {
8994

9095
static PyObject *ue_PyFRotator_str(ue_PyFRotator *self)
9196
{
97+
#ifdef USE_UNREALENGINEPYTHON_ORDER
98+
return PyUnicode_FromFormat("<unreal_engine.FRotator {'roll': %S, 'pitch': %S, 'yaw': %S}>",
99+
PyFloat_FromDouble(self->rot.Roll), PyFloat_FromDouble(self->rot.Pitch), PyFloat_FromDouble(self->rot.Yaw));
100+
101+
#else
92102
return PyUnicode_FromFormat("<unreal_engine.FRotator {'pitch': %S, 'yaw': %S, 'roll': %S}>",
93103
PyFloat_FromDouble(self->rot.Pitch), PyFloat_FromDouble(self->rot.Yaw), PyFloat_FromDouble(self->rot.Roll));
104+
#endif
94105
}
95106

96107
PyTypeObject ue_PyFRotatorType = {
@@ -210,12 +221,22 @@ static Py_ssize_t ue_py_frotator_seq_length(ue_PyFRotator *self) {
210221

211222
static PyObject *ue_py_frotator_seq_item(ue_PyFRotator *self, Py_ssize_t i) {
212223
switch (i) {
224+
225+
#ifdef USE_UNREALENGINEPYTHON_ORDER
226+
case 0:
227+
return PyFloat_FromDouble(self->rot.Roll);
228+
case 1:
229+
return PyFloat_FromDouble(self->rot.Pitch);
230+
case 2:
231+
return PyFloat_FromDouble(self->rot.Yaw);
232+
#else
213233
case 0:
214234
return PyFloat_FromDouble(self->rot.Pitch);
215235
case 1:
216236
return PyFloat_FromDouble(self->rot.Yaw);
217237
case 2:
218238
return PyFloat_FromDouble(self->rot.Roll);
239+
#endif
219240
}
220241
return PyErr_Format(PyExc_IndexError, "FRotator has only 3 items");
221242
}
@@ -232,8 +253,13 @@ static int ue_py_frotator_init(ue_PyFRotator *self, PyObject *args, PyObject *kw
232253
}
233254
}
234255

256+
#ifdef USE_UNREALENGINEPYTHON_ORDER
257+
if (!PyArg_ParseTuple(args, "|fff", &roll, &pitch, &yaw))
258+
return -1;
259+
#else
235260
if (!PyArg_ParseTuple(args, "|fff", &pitch, &yaw, &roll))
236261
return -1;
262+
#endif
237263

238264
if (PyTuple_Size(args) == 1) {
239265
yaw = pitch;
@@ -297,8 +323,13 @@ bool py_ue_rotator_arg(PyObject *args, FRotator &rot) {
297323
}
298324

299325
float pitch, yaw, roll;
326+
#ifdef USE_UNREALENGINEPYTHON_ORDER
327+
if (!PyArg_ParseTuple(args, "fff", &roll, &pitch, &yaw))
328+
return false;
329+
#else
300330
if (!PyArg_ParseTuple(args, "fff", &pitch, &yaw, &roll))
301331
return false;
332+
#endif
302333
rot.Pitch = pitch;
303334
rot.Yaw = yaw;
304335
rot.Roll = roll;

0 commit comments

Comments
 (0)