Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

12345swordy
Copy link
Contributor

Or Rather Finished the implementation of Lua functions that deemed relevant.

cc @sprunk

Copy link
Collaborator

@loveridge loveridge left a 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

@@ -39,6 +39,7 @@
#include "Sim/Misc/QuadField.h"
#include "Sim/Misc/TeamHandler.h"
#include "Sim/Misc/Wind.h"
#include "Sim//Misc/CollisionHandler.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two slashes


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));
Copy link
Collaborator

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

*/
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));
Copy link
Collaborator

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

*/
int LuaSyncedRead::TraceRayGround(lua_State* L)
{
float3 pos((double)luaL_checknumber(L, 1), (double)luaL_checknumber(L, 2), (double)luaL_checknumber(L, 3));
Copy link
Collaborator

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

* @number dirY
* @number dirZ
* @number traceLength
* @treturn {{len, Id},...}
Copy link
Collaborator

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

Comment on lines 8546 to 8549
for (const int quadIdx : *qfQuery.quads) {
const CQuadField::Quad& quad = quadField.GetQuad(quadIdx);

for (CUnit* u : quad.units) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Comment on lines 8630 to 8632
if (traceLength > groundLength && groundLength > 0.0f) {
traceLength = groundLength;
}
Copy link
Collaborator

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.

@12345swordy
Copy link
Contributor Author

ping @sprunk

rts/Lua/LuaSyncedRead.cpp Outdated Show resolved Hide resolved
rts/Lua/LuaSyncedRead.cpp Outdated Show resolved Hide resolved
rts/Lua/LuaSyncedRead.cpp Outdated Show resolved Hide resolved
rts/Lua/LuaSyncedRead.cpp Outdated Show resolved Hide resolved
rts/Lua/LuaSyncedRead.cpp Outdated Show resolved Hide resolved
rts/Lua/LuaSyncedRead.cpp Outdated Show resolved Hide resolved
@sprunk
Copy link
Collaborator

sprunk commented Sep 29, 2024

I found some time to spare and extracted the ground traceray to a separate PR after some finishing touches #1706.

@12345swordy
Copy link
Contributor Author

What should I do regarding the other two functions then? TraceRayUnits and TraceRayFeatures specifically?

@sprunk
Copy link
Collaborator

sprunk commented Oct 2, 2024

For now the only task is to test them, I'll do that when I have some more free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants