-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TraceRay Lua Functions #1624
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, but I didn't test it
rts/Lua/LuaSyncedRead.cpp
Outdated
@@ -39,6 +39,7 @@ | |||
#include "Sim/Misc/QuadField.h" | |||
#include "Sim/Misc/TeamHandler.h" | |||
#include "Sim/Misc/Wind.h" | |||
#include "Sim//Misc/CollisionHandler.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two slashes
rts/Lua/LuaSyncedRead.cpp
Outdated
|
||
int LuaSyncedRead::TraceRayUnits(lua_State* L) //returns the list of units that an raytrace has hit | ||
{ | ||
float3 pos((double)luaL_checknumber(L, 1), (double)luaL_checknumber(L, 2), (double)luaL_checknumber(L, 3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a luaL_checkfloat
rts/Lua/LuaSyncedRead.cpp
Outdated
*/ | ||
int LuaSyncedRead::TraceRayFeatures(lua_State* L) //returns the list of features that an raytrace has hit | ||
{ | ||
float3 pos((double)luaL_checknumber(L, 1), (double)luaL_checknumber(L, 2), (double)luaL_checknumber(L, 3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an extra space at the start of these lines
rts/Lua/LuaSyncedRead.cpp
Outdated
*/ | ||
int LuaSyncedRead::TraceRayGround(lua_State* L) | ||
{ | ||
float3 pos((double)luaL_checknumber(L, 1), (double)luaL_checknumber(L, 2), (double)luaL_checknumber(L, 3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra space on the start of these lines too
rts/Lua/LuaSyncedRead.cpp
Outdated
* @number dirY | ||
* @number dirZ | ||
* @number traceLength | ||
* @treturn {{len, Id},...} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return type for doc wrong
rts/Lua/LuaSyncedRead.cpp
Outdated
for (const int quadIdx : *qfQuery.quads) { | ||
const CQuadField::Quad& quad = quadField.GetQuad(quadIdx); | ||
|
||
for (CUnit* u : quad.units) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good if the returned list was sorted in order of distance, from the closest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not reverse it in lua?
rts/Lua/LuaSyncedRead.cpp
Outdated
if (traceLength > groundLength && groundLength > 0.0f) { | ||
traceLength = groundLength; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the ray fails to intersect ground the function should probably return nil.
ping @sprunk |
…et it to follow LOS rules.
I found some time to spare and extracted the ground traceray to a separate PR after some finishing touches #1706. |
What should I do regarding the other two functions then? TraceRayUnits and TraceRayFeatures specifically? |
For now the only task is to test them, I'll do that when I have some more free time. |
Regarding my test of this branch, imo needs some work since it's pretty awkward to work with, and has the classic bug regarding radar dots too. My concerns:
|
Hey, created a test widget for this: dbg_gui_test_rays.lua.
|
This is for mechanics like chain lightning so none of these is applicable.
Sounds bad.
Perhaps input |
Or Rather Finished the implementation of Lua functions that deemed relevant.
cc @sprunk