Skip to content

Commit 8ece049

Browse files
author
Roberto De Ioris
committed
added world/local add offset/rotation
1 parent f270fdc commit 8ece049

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ static PyMethodDef ue_PyUObject_methods[] = {
285285
{ "set_actor_rotation", (PyCFunction)py_ue_set_actor_rotation, METH_VARARGS, "" },
286286
{ "set_actor_scale", (PyCFunction)py_ue_set_actor_scale, METH_VARARGS, "" },
287287

288+
{ "add_actor_world_offset", (PyCFunction)py_ue_add_actor_world_offset, METH_VARARGS, "" },
289+
{ "add_actor_local_offset", (PyCFunction)py_ue_add_actor_local_offset, METH_VARARGS, "" },
290+
{ "add_actor_world_rotation", (PyCFunction)py_ue_add_actor_world_rotation, METH_VARARGS, "" },
291+
{ "add_actor_local_rotation", (PyCFunction)py_ue_add_actor_local_rotation, METH_VARARGS, "" },
292+
288293

289294
{ "get_world_location", (PyCFunction)py_ue_get_world_location, METH_VARARGS, "" },
290295
{ "get_world_rotation", (PyCFunction)py_ue_get_world_rotation, METH_VARARGS, "" },

Source/UnrealEnginePython/Private/UEPyTransform.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,74 @@ PyObject *py_ue_set_actor_location(ue_PyUObject *self, PyObject * args) {
9494
return Py_None;
9595
}
9696

97+
PyObject *py_ue_add_actor_world_offset(ue_PyUObject *self, PyObject * args) {
98+
99+
ue_py_check(self);
100+
101+
FVector vec;
102+
if (!py_ue_vector_arg(args, vec))
103+
return NULL;
104+
105+
AActor *actor = ue_get_actor(self);
106+
if (!actor)
107+
PyErr_Format(PyExc_Exception, "uobject is not an actor or a component");
108+
109+
actor->AddActorWorldOffset(vec);
110+
111+
Py_INCREF(Py_None);
112+
return Py_None;
113+
}
114+
115+
PyObject *py_ue_add_actor_local_offset(ue_PyUObject *self, PyObject * args) {
116+
117+
ue_py_check(self);
118+
119+
FVector vec;
120+
if (!py_ue_vector_arg(args, vec))
121+
return NULL;
122+
123+
AActor *actor = ue_get_actor(self);
124+
if (!actor)
125+
PyErr_Format(PyExc_Exception, "uobject is not an actor or a component");
126+
127+
actor->AddActorLocalOffset(vec);
128+
129+
Py_INCREF(Py_None);
130+
return Py_None;
131+
}
132+
133+
PyObject *py_ue_add_actor_world_rotation(ue_PyUObject *self, PyObject * args) {
134+
135+
ue_py_check(self);
136+
137+
FRotator rot;
138+
if (!py_ue_rotator_arg(args, rot))
139+
return NULL;
140+
141+
AActor *actor = ue_get_actor(self);
142+
if (!actor)
143+
return PyErr_Format(PyExc_Exception, "uobject is not an actor or a component");
144+
actor->AddActorWorldRotation(rot);
145+
Py_INCREF(Py_None);
146+
return Py_None;
147+
}
148+
149+
PyObject *py_ue_add_actor_local_rotation(ue_PyUObject *self, PyObject * args) {
150+
151+
ue_py_check(self);
152+
153+
FRotator rot;
154+
if (!py_ue_rotator_arg(args, rot))
155+
return NULL;
156+
157+
AActor *actor = ue_get_actor(self);
158+
if (!actor)
159+
return PyErr_Format(PyExc_Exception, "uobject is not an actor or a component");
160+
actor->AddActorLocalRotation(rot);
161+
Py_INCREF(Py_None);
162+
return Py_None;
163+
}
164+
97165
PyObject *py_ue_set_actor_scale(ue_PyUObject *self, PyObject * args) {
98166

99167
ue_py_check(self);

Source/UnrealEnginePython/Private/UEPyTransform.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ PyObject *py_ue_set_actor_rotation(ue_PyUObject *, PyObject *);
1818
PyObject *py_ue_set_actor_location(ue_PyUObject *, PyObject *);
1919
PyObject *py_ue_set_actor_scale(ue_PyUObject *, PyObject *);
2020

21+
PyObject *py_ue_add_actor_world_offset(ue_PyUObject *, PyObject *);
22+
PyObject *py_ue_add_actor_local_offset(ue_PyUObject *, PyObject *);
23+
24+
PyObject *py_ue_add_actor_world_rotation(ue_PyUObject *, PyObject *);
25+
PyObject *py_ue_add_actor_local_rotation(ue_PyUObject *, PyObject *);
26+
2127

2228
PyObject *py_ue_get_world_location(ue_PyUObject *, PyObject *);
2329
PyObject *py_ue_get_world_rotation(ue_PyUObject *, PyObject *);

0 commit comments

Comments
 (0)