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

Method writeCompressedPoint

Engine/source/core/stream/bitStream.cpp:550–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548};
549
550void BitStream::writeCompressedPoint(const Point3F& p,F32 scale)
551{
552 // Same # of bits for all axis
553 Point3F vec;
554 F32 invScale = 1 / scale;
555 U32 type;
556 vec = p - mCompressPoint;
557 F32 dist = vec.len() * invScale;
558 if(dist < (1 << 15))
559 type = 0;
560 else if(dist < (1 << 17))
561 type = 1;
562 else if(dist < (1 << 19))
563 type = 2;
564 else
565 type = 3;
566
567 writeInt(type, 2);
568
569 if (type != 3)
570 {
571 type = gBitCounts[type];
572 writeSignedInt(S32(vec.x * invScale + 0.5f),type);
573 writeSignedInt(S32(vec.y * invScale + 0.5f),type);
574 writeSignedInt(S32(vec.z * invScale + 0.5f),type);
575 }
576 else
577 {
578 write(p.x);
579 write(p.y);
580 write(p.z);
581 }
582}
583
584void BitStream::readCompressedPoint(Point3F* p,F32 scale)
585{

Callers 9

writePacketDataMethod · 0.80
packUpdateMethod · 0.80
packUpdateMethod · 0.80
packUpdateMethod · 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