mtasa-blue
mtasa-blue copied to clipboard
processLineOfSight enhancement
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
- [x] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
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.
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).
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
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).
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?
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
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.