Skip to content

Commit 43970bb

Browse files
authored
Merge pull request 20tab#618 from dfb/pr_fvector2d
added FVector2D wrapper
2 parents 3be6b50 + b6d281e commit 43970bb

File tree

3 files changed

+421
-1
lines changed

3 files changed

+421
-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"
@@ -1657,6 +1658,7 @@ void unreal_engine_init_py_module()
16571658
}
16581659

16591660
ue_python_init_fvector(new_unreal_engine_module);
1661+
ue_python_init_fvector2d(new_unreal_engine_module);
16601662
ue_python_init_frotator(new_unreal_engine_module);
16611663
ue_python_init_ftransform(new_unreal_engine_module);
16621664
ue_python_init_fhitresult(new_unreal_engine_module);
@@ -2106,12 +2108,16 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer, int32 index)
21062108
{
21072109
if (auto casted_struct = Cast<UScriptStruct>(casted_prop->Struct))
21082110
{
2109-
// check for FVector
21102111
if (casted_struct == TBaseStructure<FVector>::Get())
21112112
{
21122113
FVector vec = *casted_prop->ContainerPtrToValuePtr<FVector>(buffer, index);
21132114
return py_ue_new_fvector(vec);
21142115
}
2116+
if (casted_struct == TBaseStructure<FVector2D>::Get())
2117+
{
2118+
FVector2D vec = *casted_prop->ContainerPtrToValuePtr<FVector2D>(buffer, index);
2119+
return py_ue_new_fvector2d(vec);
2120+
}
21152121
if (casted_struct == TBaseStructure<FRotator>::Get())
21162122
{
21172123
FRotator rot = *casted_prop->ContainerPtrToValuePtr<FRotator>(buffer, index);
@@ -2517,6 +2523,19 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer, in
25172523
return false;
25182524
}
25192525

2526+
if (ue_PyFVector2D *py_vec = py_ue_is_fvector2d(py_obj))
2527+
{
2528+
if (auto casted_prop = Cast<UStructProperty>(prop))
2529+
{
2530+
if (casted_prop->Struct == TBaseStructure<FVector2D>::Get())
2531+
{
2532+
*casted_prop->ContainerPtrToValuePtr<FVector2D>(buffer, index) = py_vec->vec;
2533+
return true;
2534+
}
2535+
}
2536+
return false;
2537+
}
2538+
25202539
if (ue_PyFRotator *py_rot = py_ue_is_frotator(py_obj))
25212540
{
25222541
if (auto casted_prop = Cast<UStructProperty>(prop))
@@ -3172,6 +3191,12 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
31723191
prop_struct->Struct = TBaseStructure<FVector>::Get();
31733192
prop = prop_struct;
31743193
}
3194+
else if ((PyTypeObject *)value == &ue_PyFVector2DType)
3195+
{
3196+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3197+
prop_struct->Struct = TBaseStructure<FVector2D>::Get();
3198+
prop = prop_struct;
3199+
}
31753200
else if ((PyTypeObject *)value == &ue_PyFRotatorType)
31763201
{
31773202
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
@@ -3315,6 +3340,12 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
33153340
prop_struct->Struct = TBaseStructure<FVector>::Get();
33163341
prop = prop_struct;
33173342
}
3343+
else if ((PyTypeObject *)py_return_value == &ue_PyFVector2DType)
3344+
{
3345+
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);
3346+
prop_struct->Struct = TBaseStructure<FVector2D>::Get();
3347+
prop = prop_struct;
3348+
}
33183349
else if ((PyTypeObject *)py_return_value == &ue_PyFRotatorType)
33193350
{
33203351
UStructProperty *prop_struct = NewObject<UStructProperty>(function, UTF8_TO_TCHAR(p_name), RF_Public);

0 commit comments

Comments
 (0)