MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / packUpdate

Method packUpdate

Engine/source/T3D/player.cpp:6163–6237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6161}
6162
6163U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
6164{
6165 U32 retMask = Parent::packUpdate(con, mask, stream);
6166
6167 if (stream->writeFlag((mask & ImpactMask) && !(mask & InitialUpdateMask)))
6168 stream->writeInt(mImpactSound, PlayerData::ImpactBits);
6169
6170 if (stream->writeFlag(mask & ActionMask &&
6171 mActionAnimation.action != PlayerData::NullAnimation &&
6172 mActionAnimation.action >= PlayerData::NumTableActionAnims)) {
6173 stream->writeInt(mActionAnimation.action,PlayerData::ActionAnimBits);
6174 stream->writeFlag(mActionAnimation.holdAtEnd);
6175 stream->writeFlag(mActionAnimation.atEnd);
6176 stream->writeFlag(mActionAnimation.firstPerson);
6177 if (!mActionAnimation.atEnd) {
6178 // If somewhere in middle on initial update, must send position-
6179 F32 where = mShapeInstance->getPos(mActionAnimation.thread);
6180 if (stream->writeFlag((mask & InitialUpdateMask) != 0 && where > 0))
6181 stream->writeSignedFloat(where, 6);
6182 }
6183 }
6184
6185 if (stream->writeFlag(mask & ActionMask &&
6186 mArmAnimation.action != PlayerData::NullAnimation &&
6187 (!(mask & InitialUpdateMask) ||
6188 mArmAnimation.action != mDataBlock->lookAction))) {
6189 stream->writeInt(mArmAnimation.action,PlayerData::ActionAnimBits);
6190 }
6191
6192 // The rest of the data is part of the control object packet update.
6193 // If we're controlled by this client, we don't need to send it.
6194 // we only need to send it if this is the initial update - in that case,
6195 // the client won't know this is the control object yet.
6196 if(stream->writeFlag(getControllingClient() == con && !(mask & InitialUpdateMask)))
6197 return(retMask);
6198
6199 if (stream->writeFlag(mask & MoveMask))
6200 {
6201 stream->writeFlag(mFalling);
6202
6203 stream->writeFlag(mSwimming);
6204 stream->writeFlag(mJetting);
6205 stream->writeInt(mPose, NumPoseBits);
6206
6207 stream->writeInt(mState,NumStateBits);
6208 if (stream->writeFlag(mState == RecoverState))
6209 stream->writeInt(mRecoverTicks,PlayerData::RecoverDelayBits);
6210
6211 Point3F pos;
6212 getTransform().getColumn(3,&pos);
6213 stream->writeCompressedPoint(pos);
6214 F32 len = mVelocity.len();
6215 if(stream->writeFlag(len > 0.02f))
6216 {
6217 Point3F outVel = mVelocity;
6218 outVel *= 1.0f/len;
6219 stream->writeNormalVector(outVel, 10);
6220 len *= 32.0f; // 5 bits of fraction

Callers

nothing calls this directly

Calls 10

writeIntMethod · 0.80
writeSignedFloatMethod · 0.80
getColumnMethod · 0.80
writeCompressedPointMethod · 0.80
writeNormalVectorMethod · 0.80
writeFloatMethod · 0.80
writeFlagMethod · 0.45
getPosMethod · 0.45
lenMethod · 0.45
packMethod · 0.45

Tested by

no test coverage detected