mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-18 00:08:20 +01:00
Remove constexpr from readFloat
This commit is contained in:
parent
46148bbf61
commit
ffd5364533
@ -28,8 +28,15 @@ class BufferOffset
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferOffset(const std::vector<unsigned char>& buf,
|
BufferOffset(const std::vector<unsigned char>& buf,
|
||||||
const std::size_t offset) noexcept
|
const std::size_t offset)
|
||||||
: m_buf(buf), m_offset(offset)
|
: m_buf(buf)
|
||||||
|
, m_offset(offset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferOffset(const BufferOffset& other, const std::size_t fromOffset)
|
||||||
|
: m_buf(other.m_buf)
|
||||||
|
, m_offset(other.m_offset + fromOffset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +50,7 @@ private:
|
|||||||
std::size_t m_offset;
|
std::size_t m_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr float readFloat(const BufferOffset& readFrom) {
|
static float readFloat(const BufferOffset& readFrom) {
|
||||||
unsigned char d[4]{};
|
unsigned char d[4]{};
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
d[i] = readFrom.at(i);
|
d[i] = readFrom.at(i);
|
||||||
@ -51,6 +58,14 @@ static constexpr float readFloat(const BufferOffset& readFrom) {
|
|||||||
return *reinterpret_cast<float*>(d);
|
return *reinterpret_cast<float*>(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static core::vector3df readVector(const BufferOffset& readFrom) {
|
||||||
|
// glTF coordinates are right-handed, minetest ones are left-handed
|
||||||
|
return core::vector3df(
|
||||||
|
-readFloat(readFrom),
|
||||||
|
readFloat(BufferOffset(readFrom, sizeof(float))),
|
||||||
|
readFloat(BufferOffset(readFrom, 2 * sizeof(float))));
|
||||||
|
}
|
||||||
|
|
||||||
CGLTFMeshFileLoader::CGLTFMeshFileLoader()
|
CGLTFMeshFileLoader::CGLTFMeshFileLoader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -71,18 +86,12 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
|
|||||||
|
|
||||||
const auto& view = model.bufferViews[model.accessors[1].bufferView];
|
const auto& view = model.bufferViews[model.accessors[1].bufferView];
|
||||||
const auto& buffer = model.buffers[view.buffer];
|
const auto& buffer = model.buffers[view.buffer];
|
||||||
const core::vector3df v1(
|
const auto v1 = readVector(BufferOffset(
|
||||||
-readFloat(BufferOffset(buffer.data, view.byteOffset)),
|
buffer.data, view.byteOffset));
|
||||||
readFloat(BufferOffset(buffer.data, view.byteOffset + 4)),
|
const auto v2 = readVector(BufferOffset(
|
||||||
readFloat(BufferOffset(buffer.data, view.byteOffset + 8)));
|
buffer.data, view.byteOffset + (3 * sizeof(float))));
|
||||||
const core::vector3df v2(
|
const auto v3 = readVector(BufferOffset(
|
||||||
-readFloat(BufferOffset(buffer.data, view.byteOffset + 12)),
|
buffer.data, view.byteOffset + (6 * sizeof(float))));
|
||||||
readFloat(BufferOffset(buffer.data, view.byteOffset + 16)),
|
|
||||||
readFloat(BufferOffset(buffer.data, view.byteOffset + 20)));
|
|
||||||
const core::vector3df v3(
|
|
||||||
-readFloat(BufferOffset(buffer.data, view.byteOffset + 24)),
|
|
||||||
readFloat(BufferOffset(buffer.data, view.byteOffset + 28)),
|
|
||||||
readFloat(BufferOffset(buffer.data, view.byteOffset + 32)));
|
|
||||||
|
|
||||||
// sorry Bjarne
|
// sorry Bjarne
|
||||||
SMeshBuffer* meshbuf { new SMeshBuffer {} };
|
SMeshBuffer* meshbuf { new SMeshBuffer {} };
|
||||||
|
Loading…
Reference in New Issue
Block a user