2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2019-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-vertex.hpp"
|
2022-08-29 10:29:44 +00:00
|
|
|
|
|
|
|
#include "warning-disable.hpp"
|
2019-09-04 00:59:04 +00:00
|
|
|
#include <stdexcept>
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-enable.hpp"
|
2018-01-19 01:58:57 +00:00
|
|
|
|
2023-05-13 12:35:46 +00:00
|
|
|
streamfx::obs::gs::vertex::vertex() : position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr)
|
2018-09-27 01:07:13 +00:00
|
|
|
{
|
2023-05-13 12:35:46 +00:00
|
|
|
_store = streamfx::util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4) * MAXIMUM_UVW_LAYERS);
|
2018-09-27 01:07:13 +00:00
|
|
|
|
2020-04-08 21:38:42 +00:00
|
|
|
std::size_t offset = 0;
|
2018-09-27 01:07:13 +00:00
|
|
|
|
2019-08-04 14:20:26 +00:00
|
|
|
position = reinterpret_cast<vec3*>(reinterpret_cast<char*>(_store) + offset);
|
2018-09-27 01:07:13 +00:00
|
|
|
offset += sizeof(vec3);
|
|
|
|
|
2019-08-04 14:20:26 +00:00
|
|
|
normal = reinterpret_cast<vec3*>(reinterpret_cast<char*>(_store) + offset);
|
2018-09-27 01:07:13 +00:00
|
|
|
offset += sizeof(vec3);
|
|
|
|
|
2019-08-04 14:20:26 +00:00
|
|
|
tangent = reinterpret_cast<vec3*>(reinterpret_cast<char*>(_store) + offset);
|
2018-09-27 01:07:13 +00:00
|
|
|
offset += sizeof(vec3);
|
|
|
|
|
2019-08-04 14:20:26 +00:00
|
|
|
color = reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(_store) + offset);
|
2018-09-27 01:07:13 +00:00
|
|
|
offset += sizeof(uint32_t);
|
|
|
|
|
2020-04-08 21:38:42 +00:00
|
|
|
for (std::size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
|
2019-08-04 14:20:26 +00:00
|
|
|
uv[n] = reinterpret_cast<vec4*>(reinterpret_cast<char*>(_store) + offset);
|
2018-09-27 01:07:13 +00:00
|
|
|
offset += sizeof(vec4);
|
2018-01-19 01:58:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
streamfx::obs::gs::vertex::~vertex()
|
2018-09-27 01:07:13 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
if (_has_store) {
|
2021-06-08 02:18:02 +00:00
|
|
|
streamfx::util::free_aligned(_store);
|
2018-09-27 01:07:13 +00:00
|
|
|
}
|
2018-01-19 01:58:57 +00:00
|
|
|
}
|
|
|
|
|
2023-05-13 12:35:46 +00:00
|
|
|
streamfx::obs::gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS]) : position(p), normal(n), tangent(t), color(col), _has_store(false)
|
2018-09-27 01:07:13 +00:00
|
|
|
{
|
2018-01-19 01:58:57 +00:00
|
|
|
if (uvs != nullptr) {
|
2020-04-08 21:38:42 +00:00
|
|
|
for (std::size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) {
|
2018-01-19 01:58:57 +00:00
|
|
|
this->uv[idx] = uvs[idx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|