| 548 | }; |
| 549 | |
| 550 | void 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 | |
| 584 | void BitStream::readCompressedPoint(Point3F* p,F32 scale) |
| 585 | { |
no test coverage detected