Skip to content

Commit 2f72762

Browse files
committed
added support for FVector, FRotator, FLinearColor, FColor, FTransform, and FQuat to Python methods that are UFUNCTIONs
1 parent 1043b33 commit 2f72762

File tree

13 files changed

+62
-14
lines changed

13 files changed

+62
-14
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3151,6 +3151,42 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
31513151
{
31523152
prop = NewObject<UIntProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
31533153
}
3154+
else if ((PyTypeObject *)value == &ue_PyFVectorType)
3155+
{
3156+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3157+
prop_struct->Struct = TBaseStructure<FVector>::Get();
3158+
prop = prop_struct;
3159+
}
3160+
else if ((PyTypeObject *)value == &ue_PyFRotatorType)
3161+
{
3162+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3163+
prop_struct->Struct = TBaseStructure<FRotator>::Get();
3164+
prop = prop_struct;
3165+
}
3166+
else if ((PyTypeObject *)value == &ue_PyFLinearColorType)
3167+
{
3168+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3169+
prop_struct->Struct = TBaseStructure<FLinearColor>::Get();
3170+
prop = prop_struct;
3171+
}
3172+
else if ((PyTypeObject *)value == &ue_PyFColorType)
3173+
{
3174+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3175+
prop_struct->Struct = TBaseStructure<FColor>::Get();
3176+
prop = prop_struct;
3177+
}
3178+
else if ((PyTypeObject *)value == &ue_PyFTransformType)
3179+
{
3180+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3181+
prop_struct->Struct = TBaseStructure<FTransform>::Get();
3182+
prop = prop_struct;
3183+
}
3184+
else if ((PyTypeObject *)value == &ue_PyFQuatType)
3185+
{
3186+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3187+
prop_struct->Struct = TBaseStructure<FQuat>::Get();
3188+
prop = prop_struct;
3189+
}
31543190
}
31553191
else if (ue_PyUObject *py_obj = ue_is_pyuobject(value))
31563192
{
@@ -3179,7 +3215,7 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
31793215
}
31803216
}
31813217
}
3182-
// TODO add native types (like vectors, rotators...)
3218+
31833219
if (prop)
31843220
{
31853221
prop->SetPropertyFlags(CPF_Parm);

Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static PyObject *ue_PyFColor_str(ue_PyFColor *self)
103103
self->color.R, self->color.G, self->color.B, self->color.A);
104104
}
105105

106-
static PyTypeObject ue_PyFColorType = {
106+
PyTypeObject ue_PyFColorType = {
107107
PyVarObject_HEAD_INIT(NULL, 0)
108108
"unreal_engine.FColor", /* tp_name */
109109
sizeof(ue_PyFColor), /* tp_basicsize */

Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ typedef struct
1111
FColor color;
1212
} ue_PyFColor;
1313

14+
extern PyTypeObject ue_PyFColorType;
15+
1416
PyObject *py_ue_new_fcolor(FColor);
1517
ue_PyFColor *py_ue_is_fcolor(PyObject *);
1618

1719
void ue_python_init_fcolor(PyObject *);
1820

1921
bool py_ue_color_arg(PyObject *, FColor &);
2022

21-
bool py_ue_get_fcolor(PyObject *, FColor &);
23+
bool py_ue_get_fcolor(PyObject *, FColor &);

Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static PyObject *ue_PyFLinearColor_str(ue_PyFLinearColor *self)
106106
PyFloat_FromDouble(self->color.A));
107107
}
108108

109-
static PyTypeObject ue_PyFLinearColorType = {
109+
PyTypeObject ue_PyFLinearColorType = {
110110
PyVarObject_HEAD_INIT(NULL, 0)
111111
"unreal_engine.FLinearColor", /* tp_name */
112112
sizeof(ue_PyFLinearColor), /* tp_basicsize */

Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ typedef struct
1111
FLinearColor color;
1212
} ue_PyFLinearColor;
1313

14+
extern PyTypeObject ue_PyFLinearColorType;
15+
1416
PyObject *py_ue_new_flinearcolor(FLinearColor);
1517
ue_PyFLinearColor *py_ue_is_flinearcolor(PyObject *);
1618

1719
void ue_python_init_flinearcolor(PyObject *);
1820

1921
bool py_ue_linearcolor_arg(PyObject *, FLinearColor &);
2022

21-
bool py_ue_get_flinearcolor(PyObject *, FLinearColor &);
23+
bool py_ue_get_flinearcolor(PyObject *, FLinearColor &);

Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static PyObject *ue_PyFQuat_str(ue_PyFQuat *self)
152152
PyFloat_FromDouble(self->quat.X), PyFloat_FromDouble(self->quat.Y), PyFloat_FromDouble(self->quat.Z), PyFloat_FromDouble(self->quat.W));
153153
}
154154

155-
static PyTypeObject ue_PyFQuatType = {
155+
PyTypeObject ue_PyFQuatType = {
156156
PyVarObject_HEAD_INIT(NULL, 0)
157157
"unreal_engine.FQuat", /* tp_name */
158158
sizeof(ue_PyFQuat), /* tp_basicsize */

Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ typedef struct
1111
FQuat quat;
1212
} ue_PyFQuat;
1313

14+
extern PyTypeObject ue_PyFQuatType;
15+
1416
PyObject *py_ue_new_fquat(FQuat);
1517
ue_PyFQuat *py_ue_is_fquat(PyObject *);
1618

1719
void ue_python_init_fquat(PyObject *);
1820

19-
bool py_ue_quat_arg(PyObject *, FQuat &);
21+
bool py_ue_quat_arg(PyObject *, FQuat &);

Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static PyObject *ue_PyFRotator_str(ue_PyFRotator *self)
9393
PyFloat_FromDouble(self->rot.Roll), PyFloat_FromDouble(self->rot.Pitch), PyFloat_FromDouble(self->rot.Yaw));
9494
}
9595

96-
static PyTypeObject ue_PyFRotatorType = {
96+
PyTypeObject ue_PyFRotatorType = {
9797
PyVarObject_HEAD_INIT(NULL, 0)
9898
"unreal_engine.FRotator", /* tp_name */
9999
sizeof(ue_PyFRotator), /* tp_basicsize */

Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ typedef struct {
1010
FRotator rot;
1111
} ue_PyFRotator;
1212

13+
extern PyTypeObject ue_PyFRotatorType;
14+
1315
PyObject *py_ue_new_frotator(FRotator);
1416
ue_PyFRotator *py_ue_is_frotator(PyObject *);
1517

1618
void ue_python_init_frotator(PyObject *);
1719

18-
bool py_ue_rotator_arg(PyObject *, FRotator &);
20+
bool py_ue_rotator_arg(PyObject *, FRotator &);

Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static PyObject *ue_PyFTransform_str(ue_PyFTransform *self)
220220
}
221221

222222

223-
static PyTypeObject ue_PyFTransformType = {
223+
PyTypeObject ue_PyFTransformType = {
224224
PyVarObject_HEAD_INIT(NULL, 0)
225225
"unreal_engine.FTransform", /* tp_name */
226226
sizeof(ue_PyFTransform), /* tp_basicsize */
@@ -435,4 +435,4 @@ bool py_ue_transform_arg(PyObject *args, FTransform &t)
435435
t.SetRotation(FRotator(pitch, yaw, roll).Quaternion());
436436
t.SetScale3D(FVector(sx, sy, sz));
437437
return true;
438-
}
438+
}

0 commit comments

Comments
 (0)