Skip to content

Commit 2ac5906

Browse files
author
Roberto De Ioris
committed
added collision api
1 parent afa7a79 commit 2ac5906

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,13 @@ static PyMethodDef ue_PyUObject_methods[] = {
10121012
{ "static_mesh_set_collision_for_lod", (PyCFunction)py_ue_static_mesh_set_collision_for_lod, METH_VARARGS, "" },
10131013
{ "static_mesh_set_shadow_for_lod", (PyCFunction)py_ue_static_mesh_set_shadow_for_lod, METH_VARARGS, "" },
10141014
{ "get_raw_mesh", (PyCFunction)py_ue_static_mesh_get_raw_mesh, METH_VARARGS, "" },
1015+
1016+
{ "static_mesh_generate_kdop10x", (PyCFunction)py_ue_static_mesh_generate_kdop10x, METH_VARARGS, "" },
1017+
{ "static_mesh_generate_kdop10y", (PyCFunction)py_ue_static_mesh_generate_kdop10y, METH_VARARGS, "" },
1018+
{ "static_mesh_generate_kdop10z", (PyCFunction)py_ue_static_mesh_generate_kdop10z, METH_VARARGS, "" },
1019+
{ "static_mesh_generate_kdop18", (PyCFunction)py_ue_static_mesh_generate_kdop18, METH_VARARGS, "" },
1020+
{ "static_mesh_generate_kdop26", (PyCFunction)py_ue_static_mesh_generate_kdop26, METH_VARARGS, "" },
1021+
10151022
#endif
10161023

10171024
// Viewport

Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,62 @@
55

66
#include "Engine/StaticMesh.h"
77
#include "Wrappers/UEPyFRawMesh.h"
8+
#include "Editor/UnrealEd/Private/GeomFitUtils.h"
9+
10+
static PyObject *generate_kdop(ue_PyUObject *self, const FVector *directions, uint32 num_directions)
11+
{
12+
UStaticMesh *mesh = ue_py_check_type<UStaticMesh>(self);
13+
if (!mesh)
14+
return PyErr_Format(PyExc_Exception, "uobject is not a UStaticMesh");
15+
16+
TArray<FVector> DirArray;
17+
for (uint32 i = 0; i < num_directions; i++)
18+
{
19+
DirArray.Add(directions[i]);
20+
}
21+
22+
if (GenerateKDopAsSimpleCollision(mesh, DirArray) == INDEX_NONE)
23+
{
24+
return PyErr_Format(PyExc_Exception, "unable to generate KDop vectors");
25+
}
26+
27+
PyObject *py_list = PyList_New(0);
28+
for (FVector v : DirArray)
29+
{
30+
PyList_Append(py_list, py_ue_new_fvector(v));
31+
}
32+
return py_list;
33+
}
34+
35+
PyObject *py_ue_static_mesh_generate_kdop10x(ue_PyUObject *self, PyObject * args)
36+
{
37+
ue_py_check(self);
38+
return generate_kdop(self, KDopDir10X, 10);
39+
}
40+
41+
PyObject *py_ue_static_mesh_generate_kdop10y(ue_PyUObject *self, PyObject * args)
42+
{
43+
ue_py_check(self);
44+
return generate_kdop(self, KDopDir10Y, 10);
45+
}
46+
47+
PyObject *py_ue_static_mesh_generate_kdop10z(ue_PyUObject *self, PyObject * args)
48+
{
49+
ue_py_check(self);
50+
return generate_kdop(self, KDopDir10Z, 10);
51+
}
52+
53+
PyObject *py_ue_static_mesh_generate_kdop18(ue_PyUObject *self, PyObject * args)
54+
{
55+
ue_py_check(self);
56+
return generate_kdop(self, KDopDir18, 18);
57+
}
58+
59+
PyObject *py_ue_static_mesh_generate_kdop26(ue_PyUObject *self, PyObject * args)
60+
{
61+
ue_py_check(self);
62+
return generate_kdop(self, KDopDir26, 26);
63+
}
864

965
PyObject *py_ue_static_mesh_build(ue_PyUObject *self, PyObject * args)
1066
{

Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@
88
PyObject *py_ue_static_mesh_build(ue_PyUObject *, PyObject *);
99
PyObject *py_ue_static_mesh_create_body_setup(ue_PyUObject *, PyObject *);
1010
PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *, PyObject *);
11+
12+
PyObject *py_ue_static_mesh_generate_kdop10x(ue_PyUObject *, PyObject *);
13+
PyObject *py_ue_static_mesh_generate_kdop10y(ue_PyUObject *, PyObject *);
14+
PyObject *py_ue_static_mesh_generate_kdop10z(ue_PyUObject *, PyObject *);
15+
PyObject *py_ue_static_mesh_generate_kdop18(ue_PyUObject *, PyObject *);
16+
PyObject *py_ue_static_mesh_generate_kdop26(ue_PyUObject *, PyObject *);
1117
#endif

0 commit comments

Comments
 (0)