mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-07-03 17:11:59 -05:00
I've also created DegToRad/RadToDeg utility functions since there was a lot of repeated code
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
// Copyright 2009 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <cstddef>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
#include "Common/MathUtil.h"
|
|
#include "Common/Matrix.h"
|
|
|
|
struct InputVertexData
|
|
{
|
|
u8 posMtx;
|
|
std::array<u8, 8> texMtx;
|
|
|
|
Common::Vec3 position;
|
|
std::array<Common::Vec3, 3> normal;
|
|
std::array<std::array<u8, 4>, 2> color;
|
|
std::array<Common::Vec2, 8> texCoords;
|
|
};
|
|
|
|
struct OutputVertexData
|
|
{
|
|
// components in color channels
|
|
enum
|
|
{
|
|
RED_C,
|
|
GRN_C,
|
|
BLU_C,
|
|
ALP_C
|
|
};
|
|
|
|
Common::Vec3 mvPosition = {};
|
|
Common::Vec4 projectedPosition = {};
|
|
Common::Vec3 screenPosition = {};
|
|
std::array<Common::Vec3, 3> normal{};
|
|
std::array<std::array<u8, 4>, 2> color{};
|
|
std::array<Common::Vec3, 8> texCoords{};
|
|
|
|
void Lerp(float t, const OutputVertexData* a, const OutputVertexData* b)
|
|
{
|
|
mvPosition = MathUtil::Lerp(a->mvPosition, b->mvPosition, t);
|
|
|
|
projectedPosition.x = MathUtil::Lerp(a->projectedPosition.x, b->projectedPosition.x, t);
|
|
projectedPosition.y = MathUtil::Lerp(a->projectedPosition.y, b->projectedPosition.y, t);
|
|
projectedPosition.z = MathUtil::Lerp(a->projectedPosition.z, b->projectedPosition.z, t);
|
|
projectedPosition.w = MathUtil::Lerp(a->projectedPosition.w, b->projectedPosition.w, t);
|
|
|
|
for (std::size_t i = 0; i < normal.size(); ++i)
|
|
{
|
|
normal[i] = MathUtil::Lerp(a->normal[i], b->normal[i], t);
|
|
}
|
|
|
|
for (std::size_t i = 0; i < color[0].size(); ++i)
|
|
{
|
|
color[0][i] = static_cast<u8>(MathUtil::Lerp(a->color[0][i], b->color[0][i], t));
|
|
color[1][i] = static_cast<u8>(MathUtil::Lerp(a->color[1][i], b->color[1][i], t));
|
|
}
|
|
|
|
for (std::size_t i = 0; i < texCoords.size(); ++i)
|
|
{
|
|
texCoords[i] = MathUtil::Lerp(a->texCoords[i], b->texCoords[i], t);
|
|
}
|
|
}
|
|
};
|