-
Notifications
You must be signed in to change notification settings - Fork 123
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 Spring.GetProjectilesInSphere #1990
base: master
Are you sure you want to change the base?
Add Spring.GetProjectilesInSphere #1990
Conversation
Tested with this.
Steps:
Result: Both echoes shows the same. |
Hmm I'm not sure the implementation is correct. |
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.
local a = Spring.GetProjectilesInRectangle(xmin, zmin, xmax, zmax) local b = Spring.GetProjectilesInSphere(x, y, z, radius) Spring.Echo(tprint(a)) Spring.Echo(tprint(b))
Test result: Both echoes shows the same.
That sounds incorrect because surely a sphere and a rectangle can't overlap perfectly.
Perhaps spawn some sort of 3D grid of lingering (speed=0 and gravity=0? whatever makes it easy to work with) projectiles, call GetProjectilesInSphere and delete anything that wasn't returned, and compare visually if the remaining projectiles form a sphere.
@@ -3652,14 +3630,75 @@ int LuaSyncedRead::GetProjectilesInRectangle(lua_State* L) | |||
if (!LuaUtils::IsProjectileVisible(L, pro)) | |||
continue; | |||
|
|||
lua_pushnumber(L, pro->id); | |||
lua_rawseti(L, -2, arrayIndex++); | |||
lua_pushnumber(L, static_cast<lua_Number>(pro->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.
I dislike these casts. Perhaps we should update the build process to enable some sort of "ignore warnings" flag for these?
Just a note, maybe the issue submitter meant a cylinder instead of a sphere. I commented on #1662 (comment) asking about this.
Edit: Motivation for use in a real game scenario indeed is Sphere, as commented here, feel free to proceed. |
@lhog @sprunk Long story short I overthink it based on current usage. |
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.
Looks alright
Fixes #1662.