| 320 | } |
| 321 | |
| 322 | void NetConnection::ghostWritePacket(BitStream *bstream, PacketNotify *notify) |
| 323 | { |
| 324 | #ifdef TORQUE_DEBUG_NET |
| 325 | bstream->writeInt(DebugChecksum, 32); |
| 326 | #endif |
| 327 | |
| 328 | notify->ghostList = NULL; |
| 329 | |
| 330 | if(!isGhostingFrom()) |
| 331 | return; |
| 332 | |
| 333 | if(!bstream->writeFlag(mGhosting)) |
| 334 | return; |
| 335 | |
| 336 | // fill a packet (or two) with ghosting data |
| 337 | |
| 338 | // first step is to check all our polled ghosts: |
| 339 | |
| 340 | // 1. Scope query - find if any new objects have come into |
| 341 | // scope and if any have gone out. |
| 342 | // 2. call scoped objects' priority functions if the flag set is nonzero |
| 343 | // A removed ghost is assumed to have a high priority |
| 344 | // 3. call updates based on sorted priority until the packet is |
| 345 | // full. set flags to zero for all updated objects |
| 346 | |
| 347 | CameraScopeQuery camInfo; |
| 348 | |
| 349 | camInfo.camera = NULL; |
| 350 | camInfo.pos.set(0,0,0); |
| 351 | camInfo.orientation.set(0,1,0); |
| 352 | camInfo.visibleDistance = 1; |
| 353 | camInfo.fov = (F32)(3.1415f / 4.0f); |
| 354 | camInfo.sinFov = 0.7071f; |
| 355 | camInfo.cosFov = 0.7071f; |
| 356 | |
| 357 | GhostInfo *walk; |
| 358 | |
| 359 | // only need to worry about the ghosts that have update masks set... |
| 360 | S32 maxIndex = 0; |
| 361 | S32 i; |
| 362 | for(i = 0; i < mGhostZeroUpdateIndex; i++) |
| 363 | { |
| 364 | // increment the updateSkip for everyone... it's all good |
| 365 | walk = mGhostArray[i]; |
| 366 | walk->updateSkipCount++; |
| 367 | if(!(walk->flags & (GhostInfo::ScopeAlways | GhostInfo::ScopeLocalAlways))) |
| 368 | walk->flags &= ~GhostInfo::InScope; |
| 369 | } |
| 370 | |
| 371 | if( mScopeObject ) |
| 372 | mScopeObject->onCameraScopeQuery( this, &camInfo ); |
| 373 | doneScopingScene(); |
| 374 | |
| 375 | for(i = mGhostZeroUpdateIndex - 1; i >= 0; i--) |
| 376 | { |
| 377 | // [rene, 07-Mar-11] Killing ghosts depending on the camera scope queries |
| 378 | // seems like a bad thing to me and something that definitely has the potential |
| 379 | // of causing scoping to eat into bandwidth rather than preserve it. As soon |
nothing calls this directly
no test coverage detected