@@ -6,22 +6,28 @@ PyObject *py_ue_line_trace_single_by_channel(ue_PyUObject * self, PyObject * arg
66
77 ue_py_check (self);
88
9- float x1 = 0 , y1 = 0 , z1 = 0 ;
10- float x2 = 0 , y2 = 0 , z2 = 0 ;
9+ PyObject *py_obj_start ;
10+ PyObject *py_obj_end ;
1111 int channel;
1212
1313 UWorld *world = ue_get_uworld (self);
1414 if (!world)
1515 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
1616
1717
18- if (!PyArg_ParseTuple (args, " ffffffi :line_trace_single_by_channel" , &x1 , &y1, &z1, &x2, &y2, &z2 , &channel)) {
18+ if (!PyArg_ParseTuple (args, " OOi :line_trace_single_by_channel" , &py_obj_start , &py_obj_end , &channel)) {
1919 return NULL ;
2020 }
2121
22+ ue_PyFVector *start = py_ue_is_fvector (py_obj_start);
23+ ue_PyFVector *end = py_ue_is_fvector (py_obj_end);
24+
25+ if (!start || !end)
26+ return PyErr_Format (PyExc_Exception, " start and end location must be vectors" );
27+
2228 FHitResult hit;
2329
24- bool got_hit = world->LineTraceSingleByChannel (hit, FVector (x1, y1, z1), FVector (x2, y2, z2) , (ECollisionChannel)channel);
30+ bool got_hit = world->LineTraceSingleByChannel (hit, start-> vec , end-> vec , (ECollisionChannel)channel);
2531
2632 if (got_hit) {
2733 return py_ue_new_fhitresult (hit);
@@ -36,25 +42,31 @@ PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject * self, PyObject * args
3642
3743 ue_py_check (self);
3844
39- float x1 = 0 , y1 = 0 , z1 = 0 ;
40- float x2 = 0 , y2 = 0 , z2 = 0 ;
45+ PyObject *py_obj_start ;
46+ PyObject *py_obj_end ;
4147 int channel;
4248
4349 UWorld *world = ue_get_uworld (self);
4450 if (!world)
4551 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
4652
4753
48- if (!PyArg_ParseTuple (args, " ffffffi :line_trace_multi_by_channel" , &x1 , &y1, &z1, &x2, &y2, &z2 , &channel)) {
54+ if (!PyArg_ParseTuple (args, " OOOi :line_trace_multi_by_channel" , &py_obj_start , &py_obj_end , &channel)) {
4955 return NULL ;
5056 }
5157
58+ ue_PyFVector *start = py_ue_is_fvector (py_obj_start);
59+ ue_PyFVector *end = py_ue_is_fvector (py_obj_end);
60+
61+ if (!start || !end)
62+ return PyErr_Format (PyExc_Exception, " start and end location must be vectors" );
63+
5264 TArray<struct FHitResult > hits;
5365 hits.Reset ();
5466
5567 PyObject *hits_list = PyList_New (0 );
5668
57- bool got_hits = world->LineTraceMultiByChannel (hits, FVector (x1, y1, z1), FVector (x2, y2, z2) , (ECollisionChannel)channel);
69+ bool got_hits = world->LineTraceMultiByChannel (hits, start-> vec , end-> vec , (ECollisionChannel)channel);
5870
5971 if (got_hits) {
6072 for (int i = 0 ; i < hits.Num (); i++) {
@@ -110,8 +122,8 @@ PyObject *py_ue_draw_debug_line(ue_PyUObject * self, PyObject * args) {
110122
111123 ue_py_check (self);
112124
113- float x1 = 0 , y1 = 0 , z1 = 0 ;
114- float x2 = 0 , y2 = 0 , z2 = 0 ;
125+ PyObject *py_obj_start ;
126+ PyObject *py_obj_end ;
115127 uint8 r = 1 , g = 0 , b = 0 ;
116128 float duration = 0 ;
117129
@@ -120,11 +132,17 @@ PyObject *py_ue_draw_debug_line(ue_PyUObject * self, PyObject * args) {
120132 return PyErr_Format (PyExc_Exception, " unable to retrieve UWorld from uobject" );
121133
122134
123- if (!PyArg_ParseTuple (args, " ffffff |iiif:draw_debug_line" , &x1 , &y1, &z1, &x2, &y2, &z2 , &r, &g, &b, &duration)) {
135+ if (!PyArg_ParseTuple (args, " OO |iiif:draw_debug_line" , &py_obj_start , &py_obj_end , &r, &g, &b, &duration)) {
124136 return NULL ;
125137 }
126138
127- UKismetSystemLibrary::DrawDebugLine (world, FVector (x1, y1, z1), FVector (x2, y2, z2), FColor (r, g, b), false , duration);
139+ ue_PyFVector *start = py_ue_is_fvector (py_obj_start);
140+ ue_PyFVector *end = py_ue_is_fvector (py_obj_end);
141+
142+ if (!start || !end)
143+ return PyErr_Format (PyExc_Exception, " start and end location must be vectors" );
144+
145+ UKismetSystemLibrary::DrawDebugLine (world, start->vec , end->vec , FColor (r, g, b), false , duration);
128146
129147 Py_INCREF (Py_None);
130148 return Py_None;
0 commit comments