| 199 | } |
| 200 | |
| 201 | void LightManager::registerGlobalLights( const Frustum *frustum, bool staticLighting, bool enableZoneLightCulling) |
| 202 | { |
| 203 | PROFILE_SCOPE( LightManager_RegisterGlobalLights ); |
| 204 | |
| 205 | // TODO: We need to work this out... |
| 206 | // |
| 207 | // 1. Why do we register and unregister lights on every |
| 208 | // render when they don't often change... shouldn't we |
| 209 | // just register once and keep them? |
| 210 | // |
| 211 | // 2. If we do culling of lights should this happen as part |
| 212 | // of registration or somewhere else? |
| 213 | // |
| 214 | |
| 215 | // Grab the lights to process. |
| 216 | Vector<SceneObject*> activeLights; |
| 217 | const U32 lightMask = LightObjectType; |
| 218 | |
| 219 | if ( staticLighting || !frustum ) |
| 220 | { |
| 221 | // We're processing static lighting or want all the lights |
| 222 | // in the container registerd... so no culling. |
| 223 | getSceneManager()->getContainer()->findObjectList( lightMask, &activeLights ); |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | // Cull the lights using the frustum. |
| 228 | getSceneManager()->getContainer()->findObjectList(*frustum, lightMask, &activeLights); |
| 229 | /* |
| 230 | for (U32 i = 0; i < activeLights.size(); ++i) |
| 231 | { |
| 232 | for (U32 i = 0; i < activeLights.size(); ++i) |
| 233 | { |
| 234 | if (!getSceneManager()->mRenderedObjectsList.contains(activeLights[i])) |
| 235 | { |
| 236 | activeLights.erase(i); |
| 237 | --i; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | */ |
| 242 | // Store the culling position for sun placement |
| 243 | // later... see setSpecialLight. |
| 244 | mCullPos = frustum->getPosition(); |
| 245 | |
| 246 | // HACK: Make sure the control object always gets |
| 247 | // processed as lights mounted to it don't change |
| 248 | // the shape bounds and can often get culled. |
| 249 | |
| 250 | GameConnection *conn = GameConnection::getConnectionToServer(); |
| 251 | if (conn->getControlObject()) |
| 252 | { |
| 253 | GameBase *conObject = conn->getControlObject(); |
| 254 | activeLights.push_back_unique(conObject); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | // Let the lights register themselves. |
no test coverage detected