Skip to content

Commit

Permalink
Rewritten mtx data export
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed Aug 25, 2024
1 parent 54b9066 commit 6666482
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions src/factories/MtxFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ std::optional<std::shared_ptr<IParsedData>> MtxFactory::parse(std::vector<uint8_
std::vector<MtxRaw> matrix;

#define FIXTOF(x) ((float)((x) / 65536.0f))
#define M(id) ((i##id << 16) | f##id, (i##id << 16) | f##id, (i##id << 16) | f##id, (i##id << 16) | f##id)

// Reads the inteer portion, the fractional portion, puts each together into a fixed-point value, and finally converts to float.
for(size_t i = 0; i < 1; i++) {
Expand Down Expand Up @@ -193,22 +194,15 @@ std::optional<std::shared_ptr<IParsedData>> MtxFactory::parse(std::vector<uint8_
m13, m14, m15, m16,
},
.mt = MtxS {{
{
{ i1, i2, i3, i4 },
{ i5, i6, i7, i8 },
{ i9, i10, i11, i12 },
{ i13, i14, i15, i16 },
},
{
{ f1, f2, f3, f4 },
{ f5, f6, f7, f8 },
{ f9, f10, f11, f12 },
{ f13, f14, f15, f16 },
}
{ M(1), M(2), M(3), M(4) },
{ M(5), M(6), M(7), M(8) },
{ M(9), M(10), M(11), M(12) },
{ M(13), M(14), M(15), M(16) }
}}
}));
}

#undef M
#undef FIXTOF

return std::make_shared<MtxData>(matrix);
Expand Down
2 changes: 1 addition & 1 deletion src/factories/MtxFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include "BaseFactory.h"

union MtxS {
int32_t mint[4][4];
struct {
uint16_t intPart[4][4];
uint16_t fracPart[4][4];
};
int32_t mint[4][4];
long long int forc_structure_alignment;
};

Expand Down

0 comments on commit 6666482

Please sign in to comment.