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

processLineOfSight enhancement #2610

Open
1 task done
borsuczyna opened this issue Apr 28, 2022 · 7 comments
Open
1 task done

processLineOfSight enhancement #2610

borsuczyna opened this issue Apr 28, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@borsuczyna
Copy link

borsuczyna commented Apr 28, 2022

Is your feature request related to a problem? Please describe.

It's not possible to pass multiple values to ignored element
Also, it's not possible to process line that hits only given elements

Describe the solution you'd like

Allow multiple elements for ignoredElements as table
Add new optional argument validElements that accepts element or table
Make processLineOfSight accept table with options (more in additional context)

Describe alternatives you've considered

No response

Additional context

processLineOfSight ( float startX, float startY, float startZ, 
float endX, float endY, float endZ, 
[ bool checkBuildings = true, 
bool checkVehicles = true, 
bool checkPlayers = true, 
bool checkObjects = true, 
bool checkDummies = true, 
bool seeThroughStuff = false, 
bool ignoreSomeObjectsForCamera = false, 
bool shootThroughStuff = false, 
element/table ignoredElement = nil,
bool includeWorldModelInformation = false,
bool bIncludeCarTyres,
element/table checkElements ] )
processLineOfSight(float startX, float startY, float startZ, float endX, float endY, float endZ, [ table options ] )

processLineOfSight(0, 0, 0, 321, 321, 321, {
   ignoreSomeObjectsForCamera = true,
   includeCarTyres = true,
   ignoredElement = myObject,
   checkObjects = true,
   checkVehicles = false
})

Security Policy

  • I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
@borsuczyna borsuczyna added the enhancement New feature or request label Apr 28, 2022
@Lpsd
Copy link
Member

Lpsd commented Apr 28, 2022

Allow multiple elements for ignoredElements as table

As mentioned on Discord, this already has a pending PR -> #2032

However yes, an additional argument to supply the elements to check, rather than ignore, would be reasonable. Supplying this argument should cause the ignoredElement argument to be ignored, if provided.

@Pirulax
Copy link
Contributor

Pirulax commented Apr 30, 2022

Hello!
You can use setElementCollisionEnabled. Before the call to processLOS set it to false for all entities to be ignored (after enable it all back).
This is what the PR does as well (IIRC).

@Pirulax Pirulax closed this as completed Apr 30, 2022
@Lpsd
Copy link
Member

Lpsd commented Apr 30, 2022

Which PR are you referring to? He's asking for the opposite feature. Not sure why this has been closed?

Add new optional argument validElements that accepts element or table

@Pirulax Pirulax reopened this May 1, 2022
@Pirulax
Copy link
Contributor

Pirulax commented May 1, 2022

Yes, you are right, excuse me.
My bad.
I only read the first line, and your comment, and thought he just wants a way to ignore more elements (Which is already in the works as you pointed out).

@Pirulax
Copy link
Contributor

Pirulax commented May 1, 2022

Okay.
So from my understanding if checkElements is given, only those should be checked, right?
The issue is that default GTA map objects aren't MTA elements, so you don't really have full control over it.
I guess one possible solution would be to continue LOS after it returns, from the hit point, if the hit element wasn't one of the given checkElements. But that would incur even more performance penalties.
Also it's a really nitche usecase. I can't imagine where it would be useful.
Could you provide an example?

@Lpsd
Copy link
Member

Lpsd commented May 1, 2022

You could do it currently using ignoredElements (with #2032) by providing every element except the one you want to check. As for GTA map objects/models -> includeWorldModelInformation = false

Probably the best way to do this on the Lua side would be to keep track of streamed-in elements in a table, then you would have a function to return a copy of that table excluding provided element(s) i.e

processLineOfSight(0, 0, 0, 100, 100, 100, ..., getAllElementsExcept(elementToCheck), false)
                                                 ^ ignoredElements arg

If there's a lot of streamed-in elements and you're doing this every frame it could be quite a big hit (you're looping the streamed-in table to remove the provided elements) - plus constantly sending a ton of data from Lua -> C++

Doing this on the C++ side might be more reasonable, would need to try it out. It's basically the inverse functionality of #2032

@tederis
Copy link
Collaborator

tederis commented May 3, 2022

The most common way to hide some of the objects from a raycaster is to use flags(or masks). You can mark objects with setElementViewMask(element, 0xFF00FF) and then processLineOfSight(..., 0xFF00FF) to process only the specified objects or processLineOfSight(..., 0x00FF00) to process all the rest. Fast, powerful, easy-to-use.

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

No branches or pull requests

4 participants