Skip to content

Commit cc7db8b

Browse files
author
Roberto De Ioris
committed
improved viewport client api
1 parent 80a8e1a commit cc7db8b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,74 @@ static PyObject *py_ue_feditor_viewport_client_tick(ue_PyFEditorViewportClient *
2626
Py_RETURN_NONE;
2727
}
2828

29+
static PyObject *py_ue_feditor_viewport_client_get_look_at_location(ue_PyFEditorViewportClient *self, PyObject * args)
30+
{
31+
return py_ue_new_fvector(self->editor_viewport_client->GetLookAtLocation());
32+
}
33+
34+
static PyObject *py_ue_feditor_viewport_client_get_view_location(ue_PyFEditorViewportClient *self, PyObject * args)
35+
{
36+
return py_ue_new_fvector(self->editor_viewport_client->GetViewLocation());
37+
}
38+
39+
static PyObject *py_ue_feditor_viewport_client_get_camera_speed(ue_PyFEditorViewportClient *self, PyObject * args)
40+
{
41+
return PyFloat_FromDouble(self->editor_viewport_client->GetCameraSpeed());
42+
}
43+
44+
static PyObject *py_ue_feditor_viewport_client_get_viewport_dimensions(ue_PyFEditorViewportClient *self, PyObject * args)
45+
{
46+
FIntPoint origin;
47+
FIntPoint size;
48+
self->editor_viewport_client->GetViewportDimensions(origin, size);
49+
return Py_BuildValue((char *)"(ii)(ii)", origin.X, origin.Y, size.X, size.Y);
50+
}
51+
52+
static PyObject *py_ue_feditor_viewport_client_is_visible(ue_PyFEditorViewportClient *self, PyObject * args)
53+
{
54+
if (self->editor_viewport_client->IsVisible())
55+
Py_RETURN_TRUE;
56+
Py_RETURN_FALSE;
57+
}
58+
59+
static PyObject *py_ue_feditor_viewport_client_get_scene_depth_at_location(ue_PyFEditorViewportClient *self, PyObject * args)
60+
{
61+
int x;
62+
int y;
63+
if (!PyArg_ParseTuple(args, "ii:get_scene_depth_at_location", &x, &y))
64+
return nullptr;
65+
return PyFloat_FromDouble(self->editor_viewport_client->GetSceneDepthAtLocation(x, y));
66+
}
67+
68+
static PyObject *py_ue_feditor_viewport_client_set_look_at_location(ue_PyFEditorViewportClient *self, PyObject * args)
69+
{
70+
FVector vec;
71+
if (!py_ue_vector_arg(args, vec))
72+
return PyErr_Format(PyExc_Exception, "argument is not a FVector");
73+
self->editor_viewport_client->SetLookAtLocation(vec);
74+
Py_RETURN_NONE;
75+
}
76+
77+
static PyObject *py_ue_feditor_viewport_client_set_view_location(ue_PyFEditorViewportClient *self, PyObject * args)
78+
{
79+
FVector vec;
80+
if (!py_ue_vector_arg(args, vec))
81+
return PyErr_Format(PyExc_Exception, "argument is not a FVector");
82+
self->editor_viewport_client->SetViewLocation(vec);
83+
Py_RETURN_NONE;
84+
}
85+
2986
static PyMethodDef ue_PyFEditorViewportClient_methods[] = {
3087
{ "take_high_res_screen_shot", (PyCFunction)py_ue_feditor_viewport_client_take_high_res_screen_shot, METH_VARARGS, "" },
3188
{ "tick", (PyCFunction)py_ue_feditor_viewport_client_tick, METH_VARARGS, "" },
89+
{ "get_look_at_location", (PyCFunction)py_ue_feditor_viewport_client_get_look_at_location, METH_VARARGS, "" },
90+
{ "get_view_location", (PyCFunction)py_ue_feditor_viewport_client_get_view_location, METH_VARARGS, "" },
91+
{ "get_camera_speed", (PyCFunction)py_ue_feditor_viewport_client_get_camera_speed, METH_VARARGS, "" },
92+
{ "get_viewport_dimensions", (PyCFunction)py_ue_feditor_viewport_client_get_viewport_dimensions, METH_VARARGS, "" },
93+
{ "is_visible", (PyCFunction)py_ue_feditor_viewport_client_is_visible, METH_VARARGS, "" },
94+
{ "get_scene_depth_at_location", (PyCFunction)py_ue_feditor_viewport_client_get_scene_depth_at_location, METH_VARARGS, "" },
95+
{ "set_look_at_location", (PyCFunction)py_ue_feditor_viewport_client_set_look_at_location, METH_VARARGS, "" },
96+
{ "set_view_location", (PyCFunction)py_ue_feditor_viewport_client_set_view_location, METH_VARARGS, "" },
3297
{ nullptr } /* Sentinel */
3398
};
3499

0 commit comments

Comments
 (0)