MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / writeCompressedPoint

Method writeCompressedPoint

Engine/source/core/stream/bitStream.cpp:607–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605};
606
607void BitStream::writeCompressedPoint(const Point3F& p,F32 scale)
608{
609 // Same # of bits for all axis
610 Point3F vec;
611 F32 invScale = 1 / scale;
612 U32 type;
613 vec = p - mCompressPoint;
614 F32 dist = vec.len() * invScale;
615 if(dist < (1 << 15))
616 type = 0;
617 else if(dist < (1 << 17))
618 type = 1;
619 else if(dist < (1 << 19))
620 type = 2;
621 else
622 type = 3;
623
624 writeInt(type, 2);
625
626 if (type != 3)
627 {
628 type = gBitCounts[type];
629 writeSignedInt(S32(vec.x * invScale + 0.5f),type);
630 writeSignedInt(S32(vec.y * invScale + 0.5f),type);
631 writeSignedInt(S32(vec.z * invScale + 0.5f),type);
632 }
633 else
634 {
635 write(p.x);
636 write(p.y);
637 write(p.z);
638 }
639}
640
641void BitStream::readCompressedPoint(Point3F* p,F32 scale)
642{

Callers 8

packUpdateMethod · 0.80
writePacketDataMethod · 0.80
writePacketDataMethod · 0.80
packUpdateMethod · 0.80
packUpdateMethod · 0.80
packMethod · 0.80
packUpdateMethod · 0.80
packUpdateMethod · 0.80

Calls 2

writeFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected