1

Closed

Possible problem in BoundingFrustum.GetCorners(float[])

description

While looking at the implementation of BoundingFrustum, I have found this method:
 
public void GetCorners(Vector3[] corners)
{
corners = this.corners;
}
 
In its current form, this method will never return the corners of the frustum. The statement corners=this.corners is only replacing the value of parameter corners INSIDE this method, as it is passed by value to the function. For this to work, it should be:
 
public void GetCorners(ref Vector3[] corners)
{
corners = this.corners;
}
 
-or-
 
public void GetCorners(Vector3[] corners)
{
if( corners.Length < BoundingFrustum.CornerCount )
    throw new InvalidOperationExceptio();
 
for(int i=0; i<BoundingFrustum.CornerCount; i++)
   corners[i] = this.corners[i];
}
Closed Jan 31, 2012 at 5:15 AM by Glatzemann
fixed in revision #13201

comments

Glatzemann wrote Jan 31, 2012 at 4:49 AM

Created unit tests to test the wrong behaviour and ensure, that everything is working in the future.

Now fixing this issue.