17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 10:59:20 +02:00
Files
maszyna/utilities/Float3d.cpp
maj00r 2896c2dd60 add the C library headers MSVC needs
Unqualified uint8_t/size_t and friends were reaching 24 units through
some other header on libstdc++; MSVC's STL does not do that, which broke
gl/ubo.cppm (and made its UBS_PAD macro look like garbage). Also
silences C5244, MSVC's counterpart to the clang warning about glm being
included in the module purview, which is deliberate here.
2026-09-10 00:10:52 +02:00

54 lines
1.4 KiB
C++

module;
#include <cstddef>
#include <istream>
#include <ostream>
module eu07.utilities.float3d;
import eu07.scene.sn_utils;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
//---------------------------------------------------------------------------
void float4x4::deserialize_float32(std::istream &s)
{
for (size_t i = 0; i < 16; i++)
e[i] = sn_utils::ld_float32(s);
}
void float4x4::deserialize_float64(std::istream &s)
{
for (size_t i = 0; i < 16; i++)
e[i] = (float)sn_utils::ld_float64(s);
}
void float4x4::serialize_float32(std::ostream &s)
{
for (size_t i = 0; i < 16; i++)
sn_utils::ls_float32(s, e[i]);
}
void float4x4::Quaternion(float4 *q)
{ // konwersja kwaternionu obrotu na macierz obrotu
float xx = q->x * q->x, yy = q->y * q->y, zz = q->z * q->z;
float xy = q->x * q->y, xz = q->x * q->z, yz = q->y * q->z;
float wx = q->w * q->x, wy = q->w * q->y, wz = q->w * q->z;
e[0] = 1.0f - yy - yy - zz - zz;
e[1] = xy + xy + wz + wz;
e[2] = xz + xz - wy - wy;
e[4] = xy + xy - wz - wz;
e[5] = 1.0f - xx - xx - zz - zz;
e[6] = yz + yz + wx + wx;
e[8] = xz + xz + wy + wy;
e[9] = yz + yz - wx - wx;
e[10] = 1.0f - xx - xx - yy - yy;
// czwartej kolumny i czwartego wiersza nie ruszamy
};