| 514 | } |
| 515 | |
| 516 | void PhysicsShape::unpackUpdate( NetConnection *con, BitStream *stream ) |
| 517 | { |
| 518 | Parent::unpackUpdate( con, stream ); |
| 519 | |
| 520 | if ( stream->readFlag() ) // InitialUpdateMask |
| 521 | { |
| 522 | MatrixF mat; |
| 523 | stream->readAffineTransform( &mat ); |
| 524 | setTransform( mat ); |
| 525 | mPlayAmbient = stream->readFlag(); |
| 526 | |
| 527 | if ( isProperlyAdded() ) |
| 528 | _initAmbient(); |
| 529 | |
| 530 | if ( stream->readFlag() ) |
| 531 | { |
| 532 | if ( isProperlyAdded() ) |
| 533 | { |
| 534 | // Destroy immediately if we've already been added |
| 535 | // to the scene. |
| 536 | destroy(); |
| 537 | } |
| 538 | else |
| 539 | { |
| 540 | // Indicate the shape should be destroyed when the |
| 541 | // shape is added. |
| 542 | mDestroyed = true; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | if ( stream->readFlag() ) // StateMask |
| 550 | { |
| 551 | PhysicsState state; |
| 552 | |
| 553 | // Read the encoded and compressed position... commonly only 6.25 bytes. |
| 554 | stream->readCompressedPoint( &state.position ); |
| 555 | |
| 556 | // Read the compressed quaternion... 3.5 bytes. |
| 557 | stream->readQuat( &state.orientation, 9 ); |
| 558 | |
| 559 | state.sleeping = stream->readFlag(); |
| 560 | if ( !state.sleeping ) |
| 561 | { |
| 562 | stream->readVector( &state.linVelocity, 1000.0f, 16, 9 ); |
| 563 | stream->readVector( &state.angVelocity, 10.0f, 10, 9 ); |
| 564 | } |
| 565 | |
| 566 | if ( !smNoCorrections && mPhysicsRep && mPhysicsRep->isDynamic() && !mDestroyed ) |
| 567 | { |
| 568 | // Set the new state on the physics object immediately. |
| 569 | mPhysicsRep->applyCorrection( state.getTransform() ); |
| 570 | |
| 571 | mPhysicsRep->setSleeping( state.sleeping ); |
| 572 | if ( !state.sleeping ) |
| 573 | { |
nothing calls this directly
no test coverage detected