Skip to content

Commit de7f156

Browse files
committed
added FVector2D wrapper
1 parent 56a6f30 commit de7f156

File tree

3 files changed

+403
-1
lines changed

3 files changed

+403
-1
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "Wrappers/UEPyESlateEnums.h"
5252

5353
#include "Wrappers/UEPyFVector.h"
54+
#include "Wrappers/UEPyFVector2D.h"
5455
#include "Wrappers/UEPyFHitResult.h"
5556
#include "Wrappers/UEPyFRotator.h"
5657
#include "Wrappers/UEPyFTransform.h"
@@ -1656,6 +1657,7 @@ void unreal_engine_init_py_module()
16561657
}
16571658

16581659
ue_python_init_fvector(new_unreal_engine_module);
1660+
ue_python_init_fvector2d(new_unreal_engine_module);
16591661
ue_python_init_frotator(new_unreal_engine_module);
16601662
ue_python_init_ftransform(new_unreal_engine_module);
16611663
ue_python_init_fhitresult(new_unreal_engine_module);
@@ -2105,12 +2107,16 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer, int32 index)
21052107
{
21062108
if (auto casted_struct = Cast<UScriptStruct>(casted_prop->Struct))
21072109
{
2108-
// check for FVector
21092110
if (casted_struct == TBaseStructure<FVector>::Get())
21102111
{
21112112
FVector vec = *casted_prop->ContainerPtrToValuePtr<FVector>(buffer, index);
21122113
return py_ue_new_fvector(vec);
21132114
}
2115+
if (casted_struct == TBaseStructure<FVector2D>::Get())
2116+
{
2117+
FVector2D vec = *casted_prop->ContainerPtrToValuePtr<FVector2D>(buffer, index);
2118+
return py_ue_new_fvector2d(vec);
2119+
}
21142120
if (casted_struct == TBaseStructure<FRotator>::Get())
21152121
{
21162122
FRotator rot = *casted_prop->ContainerPtrToValuePtr<FRotator>(buffer, index);
@@ -2516,6 +2522,19 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer, in
25162522
return false;
25172523
}
25182524

2525+
if (ue_PyFVector2D *py_vec = py_ue_is_fvector2d(py_obj))
2526+
{
2527+
if (auto casted_prop = Cast<UStructProperty>(prop))
2528+
{
2529+
if (casted_prop->Struct == TBaseStructure<FVector2D>::Get())
2530+
{
2531+
*casted_prop->ContainerPtrToValuePtr<FVector2D>(buffer, index) = py_vec->vec;
2532+
return true;
2533+
}
2534+
}
2535+
return false;
2536+
}
2537+
25192538
if (ue_PyFRotator *py_rot = py_ue_is_frotator(py_obj))
25202539
{
25212540
if (auto casted_prop = Cast<UStructProperty>(prop))
@@ -3171,6 +3190,12 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
31713190
prop_struct->Struct = TBaseStructure<FVector>::Get();
31723191
prop = prop_struct;
31733192
}
3193+
else if ((PyTypeObject *)value == &ue_PyFVector2DType)
3194+
{
3195+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3196+
prop_struct->Struct = TBaseStructure<FVector2D>::Get();
3197+
prop = prop_struct;
3198+
}
31743199
else if ((PyTypeObject *)value == &ue_PyFRotatorType)
31753200
{
31763201
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
@@ -3314,6 +3339,12 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
33143339
prop_struct->Struct = TBaseStructure<FVector>::Get();
33153340
prop = prop_struct;
33163341
}
3342+
else if ((PyTypeObject *)py_return_value == &ue_PyFVector2DType)
3343+
{
3344+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3345+
prop_struct->Struct = TBaseStructure<FVector2D>::Get();
3346+
prop = prop_struct;
3347+
}
33173348
else if ((PyTypeObject *)py_return_value == &ue_PyFRotatorType)
33183349
{
33193350
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);

0 commit comments

Comments
 (0)