-
-
Notifications
You must be signed in to change notification settings - Fork 463
Add texture hit info to processLineOfSight
#3099
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
Conversation
Take an account that often collision is not the same as model ( as documentation note ) what mean that if i raycast i can get texture of for example collisionless leaves. What if for example there is no collision hit, but raycast went through some collisionless mesh? |
It would be nice to get normals as well. Because a collision does not always match the actual surface of a mesh and normals can point in a completely different direction. Sometimes it's important to have "real" normals. |
Dies it work for rotated objects? And maybe its better to make standalone function to raycast mesh rather bloat process line of sight? |
Yeah, perhaps adding a new function would make more sense, to give the scripter more freedom [And room to optimize], in case they want to do a raycasting against a given entity. The return arguments would be:
Last three I'm not sure about, but one might find them useful, so might as well add it. |
Good point.
Yes it does work for rotated objects too, as it uses the entity's inverse matrix to transform world position points into object [model] space. |
this is i'm working on, to get dff atomics, geometry ect. now if you add index instead of userdata what i'm planning, it may cause compatibility problem on my or your side. I think it should be separete function, raycast against atomic/clump(dff) |
raycast agianst a clump |
The problem is now you are doing the work twice: raycast against a collision mesh and DFF geometry after it. There is a lot of unnecessary heavy calculations. I think you should get rid of a standart collision processing part and write a simple ray casting procedure against AABBs. It's not as difficult as it might seem, because this part of game is already reversed and most of the code can be reused. |
I guess with enough parallelization the mesh raycast will be ultimately faster than the mesh one And yeah, writing a simple line/triangle collision test function is quite easy at this point [and I do have experience with it too] As for the function to raycast against a specific element ( @CrosRoad95 ) instead of adding it to PLOS. Also, I ran into a problem. |
Okay, so it's kinda working. |
Maybe there is something that I overlooked, but I can't find a transformation of atomics in your code. It seems like all parts(except the chassis) are in the zero position(or in the vehicle's origin). This may very well be the cause of this erroneous behavior. |
Yeah, that would explain the issue, since all frames can have a different transform. Okay, so, the transforms were missing indeed, but the situation is still pretty much the same. |
@tederis you're a genius dude, ly |
for (auto i = 2 + 1 + 1 + 3; i-- > 0;) { | ||
lua_pushnil(L); | ||
} | ||
} | ||
return 11; | ||
|
||
return 11 + 8 + 7; |
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.
Maybe use variables instead? I don't expect anyone to change this code in the foreseeable time, but this seems odd.
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.
For the number of args?
Despite the fact that it works the efficiency of an algorithm is terrible. Given that it's expected to be used with vehicles, it's important to notice that those vehicles are often replaced with custom ones which have much more triangles. It definetely requires a parallelization and SIMD optimizations of operations with matrices and vectors (I think SIMD is even more important than a parallelization). |
Yeah I do agree that the algorithm's performance isn't really all that good. |
b1d0d70
to
3c850d6
Compare
Unfortunately, the quality of vectorization is insufficient in today's compilers(even with -O3 and enabled vectorization). You can easily see it by the inspection of an assembly. That's why you can find SIMD intrinsics in every math library(including game engine math libs): Eigen, glm, numpy(scipy), UE linear algebra, CryEngine math, and many others. |
Yes I know it's not perfect, but it's better than plain old x87 arithmetic. |
x87 for what? SSE for example has nothing to do with x87. SSE intrinsics (see Intel® Intrinsics Guide) are necessary for any math library(including MTA's one). It's not possible to write an efficient and performant math without it. |
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.
How heavy is the performance hit?
Co-authored-by: Marek Kulik <[email protected]>
There's no performance hit to PLOS unless this feature is enabled, otherwise it depends on the complexity of the mesh. [Obviously, the more complex, the slower it is]. |
Wiki page added |
Fixes #645
This PR aims to add texture related info to hits [Such as hit texture UV, and name], and a more precise "clump hit" position [that is the intersection point of the clump and the line segment]
It uses the hit entity's clump to do so [As it contains all the necessary UV information]