22
33#include " Kismet/KismetSystemLibrary.h"
44
5- PyObject *py_ue_line_trace_single_by_channel (ue_PyUObject * self, PyObject * args) {
5+ PyObject *py_ue_line_trace_single_by_channel (ue_PyUObject * self, PyObject * args)
6+ {
67
78 ue_py_check (self);
89
@@ -15,7 +16,8 @@ PyObject *py_ue_line_trace_single_by_channel(ue_PyUObject * self, PyObject * arg
1516 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
1617
1718
18- if (!PyArg_ParseTuple (args, " OOi:line_trace_single_by_channel" , &py_obj_start, &py_obj_end, &channel)) {
19+ if (!PyArg_ParseTuple (args, " OOi:line_trace_single_by_channel" , &py_obj_start, &py_obj_end, &channel))
20+ {
1921 return NULL ;
2022 }
2123
@@ -29,16 +31,17 @@ PyObject *py_ue_line_trace_single_by_channel(ue_PyUObject * self, PyObject * arg
2931
3032 bool got_hit = world->LineTraceSingleByChannel (hit, start->vec , end->vec , (ECollisionChannel)channel);
3133
32- if (got_hit) {
34+ if (got_hit)
35+ {
3336 return py_ue_new_fhitresult (hit);
3437 }
3538
36- Py_INCREF (Py_None);
37- return Py_None;
39+ Py_RETURN_NONE;
3840
3941}
4042
41- PyObject *py_ue_line_trace_multi_by_channel (ue_PyUObject * self, PyObject * args) {
43+ PyObject *py_ue_line_trace_multi_by_channel (ue_PyUObject * self, PyObject * args)
44+ {
4245
4346 ue_py_check (self);
4447
@@ -51,7 +54,8 @@ PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject * self, PyObject * args
5154 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
5255
5356
54- if (!PyArg_ParseTuple (args, " OOOi:line_trace_multi_by_channel" , &py_obj_start, &py_obj_end, &channel)) {
57+ if (!PyArg_ParseTuple (args, " OOi:line_trace_multi_by_channel" , &py_obj_start, &py_obj_end, &channel))
58+ {
5559 return NULL ;
5660 }
5761
@@ -68,8 +72,10 @@ PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject * self, PyObject * args
6872
6973 bool got_hits = world->LineTraceMultiByChannel (hits, start->vec , end->vec , (ECollisionChannel)channel);
7074
71- if (got_hits) {
72- for (int i = 0 ; i < hits.Num (); i++) {
75+ if (got_hits)
76+ {
77+ for (int i = 0 ; i < hits.Num (); i++)
78+ {
7379 FHitResult hit = hits[i];
7480 PyList_Append (hits_list, py_ue_new_fhitresult (hit));
7581 }
@@ -78,26 +84,29 @@ PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject * self, PyObject * args
7884
7985}
8086
81- PyObject *py_ue_get_hit_result_under_cursor (ue_PyUObject * self, PyObject * args) {
87+ PyObject *py_ue_get_hit_result_under_cursor (ue_PyUObject * self, PyObject * args)
88+ {
8289
8390 ue_py_check (self);
8491
8592 int channel;
86- PyObject *trace_complex = NULL ;
93+ PyObject *trace_complex = nullptr ;
8794 int controller_id = 0 ;
8895
8996 UWorld *world = ue_get_uworld (self);
9097 if (!world)
9198 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
9299
93100
94- if (!PyArg_ParseTuple (args, " i|Oi:get_hit_result_under_cursor" , &channel, &trace_complex, &controller_id)) {
95- return NULL ;
101+ if (!PyArg_ParseTuple (args, " i|Oi:get_hit_result_under_cursor" , &channel, &trace_complex, &controller_id))
102+ {
103+ return nullptr ;
96104 }
97105
98106
99107 bool complex = false ;
100- if (trace_complex && PyObject_IsTrue (trace_complex)) {
108+ if (trace_complex && PyObject_IsTrue (trace_complex))
109+ {
101110 complex = true ;
102111 }
103112
@@ -109,30 +118,33 @@ PyObject *py_ue_get_hit_result_under_cursor(ue_PyUObject * self, PyObject * args
109118
110119 bool got_hit = controller->GetHitResultUnderCursor ((ECollisionChannel)channel, complex , hit);
111120
112- if (got_hit) {
121+ if (got_hit)
122+ {
113123 return py_ue_new_fhitresult (hit);
114124 }
115125
116- Py_INCREF (Py_None);
117- return Py_None;
126+ Py_RETURN_NONE;
118127
119128}
120129
121- PyObject *py_ue_draw_debug_line (ue_PyUObject * self, PyObject * args) {
130+ PyObject *py_ue_draw_debug_line (ue_PyUObject * self, PyObject * args)
131+ {
122132
123133 ue_py_check (self);
124134
125135 PyObject *py_obj_start;
126136 PyObject *py_obj_end;
127- uint8 r = 1 , g = 0 , b = 0 ;
137+ PyObject *py_color ;
128138 float duration = 0 ;
139+ float thickness = 0 ;
129140
130141 UWorld *world = ue_get_uworld (self);
131142 if (!world)
132143 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
133144
134145
135- if (!PyArg_ParseTuple (args, " OO|iiif:draw_debug_line" , &py_obj_start, &py_obj_end, &r, &g, &b, &duration)) {
146+ if (!PyArg_ParseTuple (args, " OOO|ff:draw_debug_line" , &py_obj_start, &py_obj_end, &py_color, &duration, &thickness))
147+ {
136148 return NULL ;
137149 }
138150
@@ -142,8 +154,11 @@ PyObject *py_ue_draw_debug_line(ue_PyUObject * self, PyObject * args) {
142154 if (!start || !end)
143155 return PyErr_Format (PyExc_Exception, " start and end location must be vectors" );
144156
145- UKismetSystemLibrary::DrawDebugLine (world, start->vec , end->vec , FColor (r, g, b), false , duration);
157+ ue_PyFLinearColor *py_linear_color = py_ue_is_flinearcolor (py_color);
158+ if (!py_linear_color)
159+ return PyErr_Format (PyExc_Exception, " argument is not a FLinearColor" );
160+
161+ UKismetSystemLibrary::DrawDebugLine (world, start->vec , end->vec , py_linear_color->color , duration, thickness);
146162
147- Py_INCREF (Py_None);
148- return Py_None;
163+ Py_RETURN_NONE;
149164}
0 commit comments