Hi!
I want to know if the method getCameraToViewportRay in the ogre camera is thread safe or not.
Thanks!!
Regards!!
getCameraToViewportRay method is thread safe?
-
- Halfling
- Posts: 53
- Joined: Mon Dec 05, 2011 9:43 pm
- x 1
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: getCameraToViewportRay method is thread safe?
Hi!
I just took a quick look, and no, unfortunately it's not thread safe
The routine calls getViewMatrix which ends up calling Frustum::isViewOutOfDate; and this in turn performs:
It's a shame, because a version that only uses cached values (cached view & projection matrices) if you guarantee the Camera is up to date and not touched while in another thread; it could be "safe".
If you really need this functionality the best I can recommend is to copy the code inside Camera::getCameraToViewportRay into your own routine; and use a cached view & projection matrix (that was grabbed from the main thread) and then your routine would be thread safe.
With the exception of getProjectionMatrix & getViewMatrix, everything else inside getCameraToViewportRay is pure math and local variables.
Cheers
I just took a quick look, and no, unfortunately it's not thread safe
The routine calls getViewMatrix which ends up calling Frustum::isViewOutOfDate; and this in turn performs:
Code: Select all
bool Frustum::isViewOutOfDate(void) const
{
// Attached to node?
if( mParentNode )
{
const Quaternion derivedOrient( mParentNode->_getDerivedOrientationUpdated() ); //----> Problematic
const Vector3 derivedPos( mParentNode->_getDerivedPosition() );
If you really need this functionality the best I can recommend is to copy the code inside Camera::getCameraToViewportRay into your own routine; and use a cached view & projection matrix (that was grabbed from the main thread) and then your routine would be thread safe.
With the exception of getProjectionMatrix & getViewMatrix, everything else inside getCameraToViewportRay is pure math and local variables.
Cheers
-
- Halfling
- Posts: 53
- Joined: Mon Dec 05, 2011 9:43 pm
- x 1
Re: getCameraToViewportRay method is thread safe?
Ok! I will copy the code then and cache the matrix, thanks!! =)
Regards!!
Regards!!