Skip to content

Commit f35299f

Browse files
author
Roberto De Ioris
committed
added preliminary VisualLogger api
1 parent c0f7b85 commit f35299f

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "UEPyEngine.h"
66
#include "UEPyTimer.h"
77
#include "UEPyTicker.h"
8+
#include "UEPyVisualLogger.h"
89

910
#include "UObject/UEPyObject.h"
1011
#include "UObject/UEPyActor.h"
@@ -450,6 +451,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
450451
{ "can_modify", (PyCFunction)py_ue_can_modify, METH_VARARGS, "" },
451452
#endif
452453

454+
453455
{ "set_name", (PyCFunction)py_ue_set_name, METH_VARARGS, "" },
454456

455457
{ "bind_event", (PyCFunction)py_ue_bind_event, METH_VARARGS, "" },
@@ -541,6 +543,9 @@ static PyMethodDef ue_PyUObject_methods[] = {
541543
{ "add_anim_composite_section", (PyCFunction)py_ue_add_anim_composite_section, METH_VARARGS, "" },
542544
#endif
543545

546+
// VisualLogger
547+
{ "vlog", (PyCFunction)py_ue_vlog, METH_VARARGS, "" },
548+
{ "vlog_cylinder", (PyCFunction)py_ue_vlog_cylinder, METH_VARARGS, "" },
544549

545550
// StaticMesh
546551
#if WITH_EDITOR
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "UnrealEnginePythonPrivatePCH.h"
2+
3+
#include "Runtime/Engine/Public/VisualLogger/VisualLogger.h"
4+
5+
PyObject *py_ue_vlog(ue_PyUObject *self, PyObject * args)
6+
{
7+
8+
ue_py_check(self);
9+
10+
char *category;
11+
char *text;
12+
int verbosity = ELogVerbosity::Log;
13+
14+
if (!PyArg_ParseTuple(args, "ss|i:vlog", &category, &text, &verbosity))
15+
return nullptr;
16+
#if ENABLE_VISUAL_LOG
17+
if (FVisualLogger::IsRecording())
18+
{
19+
FVisualLogger::CategorizedLogf(self->ue_object,
20+
FLogCategoryBase(UTF8_TO_TCHAR(category), (ELogVerbosity::Type)verbosity, (ELogVerbosity::Type)verbosity),
21+
(ELogVerbosity::Type)verbosity, TEXT("%s"), UTF8_TO_TCHAR(text));
22+
}
23+
#endif
24+
Py_RETURN_NONE;
25+
}
26+
27+
PyObject *py_ue_vlog_cylinder(ue_PyUObject *self, PyObject * args)
28+
{
29+
30+
ue_py_check(self);
31+
32+
char *category;
33+
PyObject *py_start;
34+
PyObject *py_end;
35+
float radius;
36+
37+
PyObject *py_color = nullptr;
38+
char *text = (char*)"";
39+
int verbosity = ELogVerbosity::Log;
40+
41+
if (!PyArg_ParseTuple(args, "sOOf|Osi:vlog_cylinder", &category, &py_start, &py_end, &radius, &py_color, &text, &verbosity))
42+
return nullptr;
43+
44+
ue_PyFVector *py_vec_start = py_ue_is_fvector(py_start);
45+
if (!py_vec_start)
46+
return PyErr_Format(PyExc_Exception, "argument is not a FVector");
47+
48+
ue_PyFVector *py_vec_end = py_ue_is_fvector(py_end);
49+
if (!py_vec_end)
50+
return PyErr_Format(PyExc_Exception, "argument is not a FVector");
51+
52+
FColor color = FColor::White;
53+
54+
if (py_color)
55+
{
56+
ue_PyFColor *py_fcolor = py_ue_is_fcolor(py_color);
57+
if (!py_fcolor)
58+
return PyErr_Format(PyExc_Exception, "argument is not a FColor");
59+
color = py_fcolor->color;
60+
}
61+
62+
#if ENABLE_VISUAL_LOG
63+
if (FVisualLogger::IsRecording())
64+
{
65+
FVisualLogger::GeometryShapeLogf(self->ue_object,
66+
FLogCategoryBase(UTF8_TO_TCHAR(category), (ELogVerbosity::Type)verbosity, (ELogVerbosity::Type)verbosity),
67+
(ELogVerbosity::Type)verbosity,
68+
py_vec_start->vec, py_vec_end->vec, radius, color,
69+
TEXT("%s"), UTF8_TO_TCHAR(text));
70+
}
71+
#endif
72+
Py_RETURN_NONE;
73+
}
74+
75+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
4+
5+
#include "UnrealEnginePython.h"
6+
7+
PyObject *py_ue_vlog(ue_PyUObject *, PyObject *);
8+
PyObject *py_ue_vlog_cylinder(ue_PyUObject *, PyObject *);
9+

0 commit comments

Comments
 (0)