Repository navigation
Expand file tree
/
Copy pathUEPyFGeometry.cpp
More file actions
87 lines (76 loc) · 2.89 KB
/
Copy pathUEPyFGeometry.cpp
File metadata and controls
87 lines (76 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "UnrealEnginePythonPrivatePCH.h"
#include "UEPyFGeometry.h"
static PyObject *py_ue_fgeometry_get_local_size(ue_PyFGeometry *self, PyObject * args)
{
FVector2D size = self->geometry.GetLocalSize();
return Py_BuildValue("(ff)", size.X, size.Y);
}
static PyObject *py_ue_fgeometry_absolute_to_local(ue_PyFGeometry *self, PyObject * args)
{
float x, y;
if (!PyArg_ParseTuple(args, "(ff)", &x, &y))
return nullptr;
FVector2D absolute(x, y);
FVector2D local = self->geometry.AbsoluteToLocal(absolute);
return Py_BuildValue((char *)"(ff)", local.X, local.Y);
}
static PyMethodDef ue_PyFGeometry_methods[] = {
{ "get_local_size", (PyCFunction)py_ue_fgeometry_get_local_size, METH_VARARGS, "" },
{ "absolute_to_local", (PyCFunction)py_ue_fgeometry_absolute_to_local, METH_VARARGS, "" },
{ NULL } /* Sentinel */
};
static PyObject *ue_PyFGeometry_str(ue_PyFGeometry *self)
{
return PyUnicode_FromFormat("<unreal_engine.FGeometry '%s'>",
TCHAR_TO_UTF8(*self->geometry.ToString()));
}
static PyTypeObject ue_PyFGeometryType = {
PyVarObject_HEAD_INIT(NULL, 0)
"unreal_engine.FGeometry", /* tp_name */
sizeof(ue_PyFGeometry), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
(reprfunc)ue_PyFGeometry_str, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"Unreal Engine FGeometry", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
ue_PyFGeometry_methods, /* tp_methods */
};
void ue_python_init_fgeometry(PyObject *ue_module)
{
ue_PyFGeometryType.tp_new = PyType_GenericNew;
if (PyType_Ready(&ue_PyFGeometryType) < 0)
return;
Py_INCREF(&ue_PyFGeometryType);
PyModule_AddObject(ue_module, "FGeometry", (PyObject *)&ue_PyFGeometryType);
}
ue_PyFGeometry *py_ue_is_fgeometry(PyObject *obj)
{
if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFGeometryType))
return nullptr;
return (ue_PyFGeometry *)obj;
}
PyObject *py_ue_new_fgeometry(FGeometry geometry)
{
ue_PyFGeometry *ret = (ue_PyFGeometry *)PyObject_New(ue_PyFGeometry, &ue_PyFGeometryType);
ret->geometry = geometry;
return (PyObject *)ret;
}