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