MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Encode

Method Encode

engine/Poseidon/Network/NetworkMsg.cpp:597–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595 const float coef = 1.0 / MaxAbsInt16;
596 return x * coef;
597}
598
599void EncodedMatrix3::Encode(const Matrix3& m)
600{
601 // encoding is quite simple
602 _01c = EncodeFloat16(m(0, 1));
603 _11c = EncodeFloat16(m(1, 1));
604 // note: abs. value can be deduced from previous value, sign not
605 _21sign = m(2, 1) >= 0 ? 1 : -1;
606 _02c = EncodeFloat16(m(0, 2));
607 _12c = EncodeFloat16(m(1, 2));
608 _22sign = m(2, 2) >= 0 ? 1 : -1;
609// verify matrix is orthogonal
610#if _DEBUG
611 float m21_sq = 1 - m(0, 1) * m(0, 1) - m(1, 1) * m(1, 1);
612 float m21 = (m21_sq >= 0 ? sqrt(m21_sq) : 0) * _21sign;
613 NET_ERROR(fabs(m21 - m(2, 1)) < 1e-3);
614 float m22_sq = 1 - m(0, 2) * m(0, 2) - m(1, 2) * m(1, 2);
615 float m22 = (m22_sq >= 0 ? sqrt(m22_sq) : 0) * _22sign;
616 NET_ERROR(fabs(m22 - m(2, 2)) < 1e-3);
617 Vector3 mAside = m.DirectionUp().CrossProduct(m.Direction());
618 NET_ERROR(mAside.Distance2(m.DirectionAside()) < 1e-6);
619#endif
620}
621

Callers 1

PutMethod · 0.45

Calls 7

EncodeFloat16Function · 0.85
sqrtFunction · 0.85
fabsFunction · 0.85
DirectionUpMethod · 0.80
CrossProductMethod · 0.45
DirectionMethod · 0.45
Distance2Method · 0.45

Tested by

no test coverage detected