Jump to content
• Advertisement
• entries
235
• comments
509
• views
172552

# Camera Smoothness & AABB Culling

278 views

After checking out a preliminary promotional video, I noticed that the camera looked very stiff and unnatural, although I have camera smoothing code in the game.

After looking at the code, I realized it was probably the fact that the camera smoothing was not fps-independent and the recording was reducing the framerate, so I fixed the camera interpolation code to be shorter, simpler, faster and also fps-independent.

The other day I was revisiting AABB frustum culling for another purpose, and realized that in Ancient Galaxy, I was doing too much work in the frustum culling code.

There is a trick for AABB vs plane testing, in 2D ( as used in the Larrabee rasterizer ), and also in 3D ( used for frustum culling and BSP traversal ), where you take advantage of the axis-alignment of the box to only test a single point of the box to find out if the box is fully in back of the plane. You can also test the opposite point to find out if the box is fully in front of the plane.

Anyways, I saw that my code was always computing both points, to try to distinguish the Outside from Inside and Partial cases, although the code using this function was only checking for Outside or not. So, I made a new function that only does the Outside check.

It's possible doing & using the Inside check can speed up tests b/c once you are fully inside a plane, any children in a hierarchical tree won't have to be re-tested against that plane.

Here is the code for future reference :

bool Shapes::Frustum::Culled( const Shapes::AABox& aBox ) const{    // for each plane of the frustum    for ( size_t p = 0; p < Shapes::SidesCount; ++p )    {	D3DXVECTOR3 furthestPoint( aBox.Min );        if ( mPlanes[ p ].mNormal.x >= 0.0f ) { furthestPoint.x = aBox.Max.x; }         if ( mPlanes[ p ].mNormal.y >= 0.0f ) { furthestPoint.y = aBox.Max.y; }         if ( mPlanes[ p ].mNormal.z >= 0.0f ) { furthestPoint.z = aBox.Max.z; }         if ( mPlanes[ p ].GetClipStatus( furthestPoint ) == Outside )        {            return true;        }    }    return false;}

The idea is that if the furthest point on the box in the direction of the normal is behind the plane, then all closer points must be behind the plane as well. Sort of reminds me of the Separating Axis Test.

## Recommended Comments

There are no comments to display.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
• Advertisement
• Advertisement

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!