void Vector_Decode( CBitRead &entityBitBuffer, const CSVCMsg_SendTable::sendprop_t *pSendProp, Vector &v )
{
	v.x = Float_Decode( entityBitBuffer, pSendProp );
	v.y = Float_Decode( entityBitBuffer, pSendProp );

	// Don't read in the third component for normals
	if ( ( pSendProp->flags() & SPROP_NORMAL ) == 0 )
	{
		v.z = Float_Decode( entityBitBuffer, pSendProp );
	}
	else
	{
		int signbit = entityBitBuffer.ReadOneBit();

		float v0v0v1v1 = v.x * v.x + v.y * v.y;
		if (v0v0v1v1 < 1.0f)
		{
			v.z = sqrtf( 1.0f - v0v0v1v1 );
		}
		else
		{
			v.z = 0.0f;
		}

		if (signbit)
		{
			v.z *= -1.0f;
		}
	}
}
Esempio n. 2
0
int64_t decode_int64(CBitRead& entityBitBuffer, const CSVCMsg_SendTable::sendprop_t* pSendProp) {
	if(pSendProp->flags() & SPROP_VARINT) {
		if(pSendProp->flags() & SPROP_UNSIGNED) {
			return (int64_t)entityBitBuffer.ReadVarInt64();
		} else {
			return entityBitBuffer.ReadSignedVarInt64();
		}
	} else {
		uint32_t highInt = 0;
		uint32_t lowInt = 0;
		bool bNeg = false;
		if(!(pSendProp->flags() & SPROP_UNSIGNED)) {
			bNeg = entityBitBuffer.ReadOneBit() != 0;
			lowInt = entityBitBuffer.ReadUBitLong(32);
			highInt = entityBitBuffer.ReadUBitLong(pSendProp->num_bits() - 32 - 1);
        } else {
			lowInt = entityBitBuffer.ReadUBitLong(32);
			highInt = entityBitBuffer.ReadUBitLong(pSendProp->num_bits() - 32);
		}

		int64_t temp;

		uint32_t* pInt = (uint32_t*)&temp;
		*pInt++ = lowInt;
		*pInt = highInt;

		if(bNeg) {
			temp = -temp;
		}

		return temp;
	}
}
Esempio n. 3
0
void decode_vector_xyz(CBitRead& entityBitBuffer, const CSVCMsg_SendTable::sendprop_t* pSendProp, vector_t& v) {
	v.x = decode_float(entityBitBuffer, pSendProp);
	v.y = decode_float(entityBitBuffer, pSendProp);

	//don't read in the third component for normals
	if(0 == (pSendProp->flags() & SPROP_NORMAL)) {
		v.z = decode_float(entityBitBuffer, pSendProp);
	} else {
		int signbit = entityBitBuffer.ReadOneBit();

		float v0v0v1v1 = v.x * v.x + v.y * v.y;
		if(v0v0v1v1 < 1.0f) {
			v.z = sqrtf(1.0f - v0v0v1v1);
		} else {
			v.z = 0.0f;
		}

		if(signbit) {
			v.z *= -1.0f;
		}
	}
}