MCPcopy Create free account
hub / github.com/cinder/Cinder / update

Method update

samples/FrustumCulling/src/FrustumCullingApp.cpp:157–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void FrustumCullingReduxApp::update()
158{
159 // Calculate elapsed time.
160 double elapsed = getElapsedSeconds() - mCurrentSeconds;
161 mCurrentSeconds += elapsed;
162
163 // perform frustum culling **********************************************************************************
164
165 // Save the current culling field of view. If mShowRevealingFov = true,
166 // this will narrow the camera's FOV so that you can see the culling effect.
167 float originalFov = mRenderCam.getFov();
168 mRenderCam.setFov( mCullingFov );
169
170 // Obtain the camera's view frustum, allowing us to perform frustum culling.
171 Frustumf visibleWorld( mRenderCam );
172
173 // Restore FOV to original
174 mRenderCam.setFov( originalFov );
175
176 for( auto & obj : mObjects ) {
177 // Update object (so it rotates slowly around its axis).
178 obj->update( elapsed );
179
180 if( !mPerformCulling ) {
181 // Don't cull the object. All objects will be drawn,
182 // even if they are outside the camera's view frustum.
183 obj->setCulled( false );
184 }
185 else if( mCullWithSpheres ) {
186 // Use the object's bounding sphere, converted to world space.
187 Sphere worldBoundingSphere = mObjectBoundingSphere.transformed( obj->getTransform() );
188
189 // Check if the bounding sphere intersects the camera's view frustum.
190 obj->setCulled( !visibleWorld.intersects( worldBoundingSphere ) );
191 }
192 else {
193 // Use the object's bounding box, converted to world space.
194 AxisAlignedBox worldBoundingBox = mObjectBoundingBox.transformed( obj->getTransform() );
195
196 // Check if the bounding box intersects the camera's view frustum.
197 obj->setCulled( !visibleWorld.intersects( worldBoundingBox ) );
198 }
199 }
200
201 // Update window title.
202 if( getElapsedFrames() % 60 == 0 )
203 getWindow()->setTitle( "Frustum Culling Redux - " + toString( (int) getAverageFps() ) + " FPS" );
204}
205
206void FrustumCullingReduxApp::draw()
207{

Callers

nothing calls this directly

Calls 9

getElapsedFramesFunction · 0.85
getAverageFpsFunction · 0.85
setCulledMethod · 0.80
getElapsedSecondsFunction · 0.50
getWindowFunction · 0.50
toStringFunction · 0.50
transformedMethod · 0.45
intersectsMethod · 0.45
setTitleMethod · 0.45

Tested by

no test coverage detected