| 605 | }; |
| 606 | |
| 607 | void 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 | |
| 641 | void BitStream::readCompressedPoint(Point3F* p,F32 scale) |
| 642 | { |
no test coverage detected