I'm using the orxObject_IsRendered(...) function and I'm not getting the result I expected. My first guess was that it would return true if the object was in the camera frustum and false otherwise. Is that correct?
In my case if I see the object on the screen, the orxObject_IsRendered returns true, ok. When I move the camera and the object is no longer on the screen, but is near its edge the orxObject_IsRendered still returns true. It returns false only when I move the camera a little more. Is that the correct behavior?
That was the intent when I first implemented it but it then got deprecated due to rendering changes and I never fixed it/removed it.
Right now it's completely broken (!) if you have more than one viewport and if you only have one, it'll return true if the object got past the render culling test which is a fast circle (squared distance) one based on the default graphic object (which is again not very precise for animated objects).
I'll refine it to do an actual OBB intersection if it's not too expensive and make sure it works with more than one viewport.
I'll try to do that tonight if you need it.
- Get the camera frustum
- Do Size = Frustum.BR - Frustum.TL
- Sets an orxOBOX with the camera world position, half size as pivot, its size as calculated above and its world rotation as angle
- Gets the object's orxOBOX
- Call orxOBox_ZAlignedTestIntersection
That should do the trick.
[EDIT] Missed some words when writing the first version, sorry.
But if you have time, I think it would be better if you refine the IsRendered function as you said.
Thanks a lot.
As for doing it this way in the render plugin, I'll probably wait a bit as it adds some complexity to the code as I have to take into account the camera zoom and the object's differential scrolling axes. It'll also have a negative impact on the performances. For now I think I might even remove this "feature" as it's both not precise and has some computation cost.