Skip to content

Commit 85d9660

Browse files
committed
added get_static_mesh_bounds method
1 parent 56a6f30 commit 85d9660

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
751751
{ "vlog_cylinder", (PyCFunction)py_ue_vlog_cylinder, METH_VARARGS, "" },
752752

753753
// StaticMesh
754+
{ "get_static_mesh_bounds", (PyCFunction)py_ue_static_mesh_get_bounds, METH_VARARGS, "" },
754755
#if WITH_EDITOR
755756
{ "static_mesh_build", (PyCFunction)py_ue_static_mesh_build, METH_VARARGS, "" },
756757
{ "static_mesh_create_body_setup", (PyCFunction)py_ue_static_mesh_create_body_setup, METH_VARARGS, "" },

Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
#include "UEPyStaticMesh.h"
2+
#include "Engine/StaticMesh.h"
23

4+
PyObject *py_ue_static_mesh_get_bounds(ue_PyUObject *self, PyObject * args)
5+
{
6+
ue_py_check(self);
7+
UStaticMesh *mesh = ue_py_check_type<UStaticMesh>(self);
8+
if (!mesh)
9+
return PyErr_Format(PyExc_Exception, "uobject is not a UStaticMesh");
10+
11+
FBoxSphereBounds bounds = mesh->GetBounds();
12+
UScriptStruct *u_struct = FindObject<UScriptStruct>(ANY_PACKAGE, UTF8_TO_TCHAR("BoxSphereBounds"));
13+
if (!u_struct)
14+
{
15+
return PyErr_Format(PyExc_Exception, "unable to get BoxSphereBounds struct");
16+
}
17+
return py_ue_new_owned_uscriptstruct(u_struct, (uint8 *)&bounds);
18+
}
319

420
#if WITH_EDITOR
521

6-
#include "Engine/StaticMesh.h"
722
#include "Wrappers/UEPyFRawMesh.h"
823
#include "Editor/UnrealEd/Private/GeomFitUtils.h"
924
#include "FbxMeshUtils.h"
@@ -137,4 +152,4 @@ PyObject *py_ue_static_mesh_import_lod(ue_PyUObject *self, PyObject * args)
137152
Py_RETURN_FALSE;
138153
}
139154

140-
#endif
155+
#endif

Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "UEPyModule.h"
66

7+
PyObject *py_ue_static_mesh_get_bounds(ue_PyUObject *self, PyObject * args);
8+
79
#if WITH_EDITOR
810
PyObject *py_ue_static_mesh_build(ue_PyUObject *, PyObject *);
911
PyObject *py_ue_static_mesh_create_body_setup(ue_PyUObject *, PyObject *);
@@ -15,4 +17,4 @@ PyObject *py_ue_static_mesh_generate_kdop10z(ue_PyUObject *, PyObject *);
1517
PyObject *py_ue_static_mesh_generate_kdop18(ue_PyUObject *, PyObject *);
1618
PyObject *py_ue_static_mesh_generate_kdop26(ue_PyUObject *, PyObject *);
1719
PyObject *py_ue_static_mesh_import_lod(ue_PyUObject *, PyObject *);
18-
#endif
20+
#endif

0 commit comments

Comments
 (0)