@@ -333,13 +333,14 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, std::shared_ptr<EasyMesh> | |||
VertexUsage::Color, | |||
VertexUsage::TexCoord)); | |||
std::vector<std::tuple<vec3, vec3, u8vec4, vec4>> vertexlist; | |||
struct vertex_def { vec3 pos, normal; u8vec4 color; vec4 uv; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
src_mesh->m_vert[i].m_normal, | |||
(u8vec4)(src_mesh->m_vert[i].m_color * 255.f), | |||
src_mesh->m_vert[i].m_texcoord)); | |||
src_mesh->m_vert[i].m_texcoord}); | |||
COPY_VBO; | |||
} | |||
else if (flagnb == 4 && has_position && has_normal && has_color && has_texcoord) | |||
@@ -351,25 +352,31 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, std::shared_ptr<EasyMesh> | |||
VertexUsage::Color, | |||
VertexUsage::TexCoord)); | |||
std::vector<std::tuple<vec3, vec3, u8vec4, vec2>> vertexlist; | |||
struct vertex_def { vec3 pos, normal; u8vec4 color; vec2 uv; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
src_mesh->m_vert[i].m_normal, | |||
u8vec4(src_mesh->m_vert[i].m_color * 255.f), | |||
vec2(src_mesh->m_vert[i].m_texcoord.xy))); | |||
vec2(src_mesh->m_vert[i].m_texcoord.xy)}); | |||
COPY_VBO; | |||
} | |||
else if (flagnb == 4 && has_position && has_color && has_texcoord && has_texcoordExt) | |||
{ | |||
new_vdecl = std::make_shared<VertexDeclaration>(VertexStream<vec3,vec4,vec4>(VertexUsage::Position, VertexUsage::Color, VertexUsage::TexCoord)); | |||
new_vdecl = std::make_shared<VertexDeclaration>( | |||
VertexStream<vec3,vec4,vec4>( | |||
VertexUsage::Position, | |||
VertexUsage::Color, | |||
VertexUsage::TexCoord)); | |||
std::vector<std::tuple<vec3, vec4, vec4>> vertexlist; | |||
struct vertex_def { vec3 pos; vec4 color; vec4 uv; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
src_mesh->m_vert[i].m_color, | |||
src_mesh->m_vert[i].m_texcoord)); | |||
src_mesh->m_vert[i].m_texcoord}); | |||
COPY_VBO; | |||
} | |||
else if (flagnb == 3 && has_position && has_normal && has_color) | |||
@@ -380,49 +387,62 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, std::shared_ptr<EasyMesh> | |||
VertexUsage::Normal, | |||
VertexUsage::Color)); | |||
std::vector<std::tuple<vec3,vec3,u8vec4>> vertexlist; | |||
struct vertex_def { vec3 pos, normal; u8vec4 color; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
src_mesh->m_vert[i].m_normal, | |||
(u8vec4)(src_mesh->m_vert[i].m_color * 255.f))); | |||
(u8vec4)(src_mesh->m_vert[i].m_color * 255.f)}); | |||
COPY_VBO; | |||
} | |||
else if (flagnb == 3 && has_position && has_texcoord && has_texcoordExt) | |||
{ | |||
new_vdecl = std::make_shared<VertexDeclaration>(VertexStream<vec3,vec4>(VertexUsage::Position, VertexUsage::TexCoord)); | |||
new_vdecl = std::make_shared<VertexDeclaration>( | |||
VertexStream<vec3,vec4>( | |||
VertexUsage::Position, | |||
VertexUsage::TexCoord)); | |||
std::vector<std::tuple<vec3, vec4>> vertexlist; | |||
struct vertex_def { vec3 pos; vec4 uv; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
src_mesh->m_vert[i].m_texcoord)); | |||
src_mesh->m_vert[i].m_texcoord}); | |||
COPY_VBO; | |||
} | |||
else if (flagnb == 2 && has_position && has_texcoord) | |||
{ | |||
new_vdecl = std::make_shared<VertexDeclaration>(VertexStream<vec3,vec2>(VertexUsage::Position, VertexUsage::TexCoord)); | |||
new_vdecl = std::make_shared<VertexDeclaration>( | |||
VertexStream<vec3,vec2>( | |||
VertexUsage::Position, | |||
VertexUsage::TexCoord)); | |||
std::vector<std::tuple<vec3, vec2>> vertexlist; | |||
struct vertex_def { vec3 pos; vec2 uv; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
vec2(src_mesh->m_vert[i].m_texcoord.xy))); | |||
vec2(src_mesh->m_vert[i].m_texcoord.xy)}); | |||
COPY_VBO; | |||
} | |||
else if (flagnb == 2 && has_position && has_color) | |||
{ | |||
new_vdecl = std::make_shared<VertexDeclaration>(VertexStream<vec3,u8vec4>(VertexUsage::Position, VertexUsage::Color)); | |||
new_vdecl = std::make_shared<VertexDeclaration>( | |||
VertexStream<vec3,u8vec4>( | |||
VertexUsage::Position, | |||
VertexUsage::Color)); | |||
std::vector<std::tuple<vec3, u8vec4>> vertexlist; | |||
struct vertex_def { vec3 pos; u8vec4 color; }; | |||
std::vector<vertex_def> vertexlist; | |||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||
vertexlist.push_back(std::make_tuple( | |||
vertexlist.push_back(vertex_def{ | |||
src_mesh->m_vert[i].m_coord, | |||
u8vec4(src_mesh->m_vert[i].m_color * 255.f))); | |||
u8vec4(src_mesh->m_vert[i].m_color * 255.f)}); | |||
COPY_VBO; | |||
} | |||
else | |||
ASSERT(0, "no Vertex Declaration combination for 0x%04x", vflags); | |||
ASSERT(0, "no known Vertex Declaration combination for 0x%04x", vflags); | |||
m_vdata.push(vflags, new_vdecl, new_vbo); | |||
} | |||
@@ -708,7 +708,7 @@ void Scene::render_lines(float seconds) | |||
if (!m_line_api.m_shader) | |||
m_line_api.m_shader = Shader::Create(LOLFX_RESOURCE_NAME(gpu_line)); | |||
std::vector<std::tuple<vec4, vec4, vec4, vec4>> buff; | |||
std::vector<std::array<vec4,4>> buff; | |||
buff.resize(linecount); | |||
int real_linecount = 0; | |||
mat4 const inv_view_proj = inverse(GetCamera()->GetProjection() * GetCamera()->GetView()); | |||
@@ -717,10 +717,10 @@ void Scene::render_lines(float seconds) | |||
{ | |||
if (m_line_api.m_lines[i].mask & m_line_api.m_debug_mask) | |||
{ | |||
std::get<0>(buff[real_linecount]) = vec4(m_line_api.m_lines[i].a, (float)m_line_api.m_lines[i].wtf1); | |||
std::get<1>(buff[real_linecount]) = m_line_api.m_lines[i].col; | |||
std::get<2>(buff[real_linecount]) = vec4(m_line_api.m_lines[i].b, (float)m_line_api.m_lines[i].wtf2); | |||
std::get<3>(buff[real_linecount]) = m_line_api.m_lines[i].col; | |||
buff[real_linecount][0] = vec4(m_line_api.m_lines[i].a, (float)m_line_api.m_lines[i].wtf1); | |||
buff[real_linecount][1] = m_line_api.m_lines[i].col; | |||
buff[real_linecount][2] = vec4(m_line_api.m_lines[i].b, (float)m_line_api.m_lines[i].wtf2); | |||
buff[real_linecount][3] = m_line_api.m_lines[i].col; | |||
real_linecount++; | |||
} | |||
m_line_api.m_lines[i].duration -= seconds; | |||
@@ -31,16 +31,16 @@ lolunit_declare_fixture(quaternion_test) | |||
void setup() | |||
{ | |||
/* Generate identity quaternions */ | |||
push_vector_pair(vec3::axis_x, vec3::axis_x); | |||
push_vector_pair(2.f * vec3::axis_x, 3.f * vec3::axis_x); | |||
m_vectorpairs.push_back({ vec3::axis_x, vec3::axis_x }); | |||
m_vectorpairs.push_back({ 2.f * vec3::axis_x, 3.f * vec3::axis_x }); | |||
/* Generate 90-degree rotations */ | |||
push_vector_pair(vec3::axis_x, vec3::axis_y); | |||
push_vector_pair(2.f * vec3::axis_x, 3.f * vec3::axis_y); | |||
m_vectorpairs.push_back({ vec3::axis_x, vec3::axis_y }); | |||
m_vectorpairs.push_back({ 2.f * vec3::axis_x, 3.f * vec3::axis_y }); | |||
/* Generate 180-degree rotations */ | |||
push_vector_pair(vec3::axis_x, -vec3::axis_x); | |||
push_vector_pair(2.f * vec3::axis_x, -3.f * vec3::axis_x); | |||
m_vectorpairs.push_back({ vec3::axis_x, -vec3::axis_x }); | |||
m_vectorpairs.push_back({ 2.f * vec3::axis_x, -3.f * vec3::axis_x }); | |||
/* Fill array with random test values */ | |||
for (int i = 0; i < 10000; ++i) | |||
@@ -49,7 +49,7 @@ lolunit_declare_fixture(quaternion_test) | |||
* vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); | |||
vec3 v2 = pow(10.f, rand(-5.f, 5.f)) | |||
* vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); | |||
push_vector_pair(v1, v2); | |||
m_vectorpairs.push_back({ v1, v2 }); | |||
} | |||
} | |||
@@ -212,8 +212,8 @@ lolunit_declare_fixture(quaternion_test) | |||
{ | |||
for (auto pair : m_vectorpairs) | |||
{ | |||
vec3 a0 = std::get<0>(pair); | |||
vec3 b0 = std::get<1>(pair); | |||
vec3 a0 = pair[0]; | |||
vec3 b0 = pair[1]; | |||
vec3 a = normalize(a0); | |||
vec3 b = normalize(b0); | |||
@@ -545,12 +545,7 @@ lolunit_declare_fixture(quaternion_test) | |||
} | |||
private: | |||
void push_vector_pair(vec3 p, vec3 q) | |||
{ | |||
m_vectorpairs.push_back(std::make_tuple(p, q)); | |||
} | |||
std::vector<std::tuple<vec3, vec3>> m_vectorpairs; | |||
std::vector<std::array<vec3,2>> m_vectorpairs; | |||
}; | |||
} /* namespace lol */ | |||
@@ -35,13 +35,19 @@ static entity_dict<TileSet> tileset_cache; | |||
* TileSet implementation class | |||
*/ | |||
struct tile_def | |||
{ | |||
ibox2 pixel_coords; | |||
box2 tex_coords; | |||
}; | |||
class TileSetData | |||
{ | |||
friend class TileSet; | |||
protected: | |||
/* Pixels, then texture coordinates */ | |||
std::vector<std::tuple<ibox2, box2>> m_tiles; | |||
std::vector<tile_def> m_tiles; | |||
ivec2 m_tile_size; | |||
}; | |||
@@ -192,9 +198,10 @@ void TileSet::clear_all() | |||
int TileSet::define_tile(ibox2 rect) | |||
{ | |||
m_tileset_data->m_tiles.push_back(std::make_tuple(rect, | |||
m_tileset_data->m_tiles.push_back(tile_def { | |||
rect, | |||
box2((vec2)rect.aa / (vec2)m_data->m_texture_size, | |||
(vec2)rect.bb / (vec2)m_data->m_texture_size))); | |||
(vec2)rect.bb / (vec2)m_data->m_texture_size) }); | |||
return int(m_tileset_data->m_tiles.size()) - 1; | |||
} | |||
@@ -223,17 +230,17 @@ int TileSet::GetTileCount() const | |||
ivec2 TileSet::GetTileSize(int tileid) const | |||
{ | |||
return std::get<0>(m_tileset_data->m_tiles[tileid]).extent(); | |||
return m_tileset_data->m_tiles[tileid].pixel_coords.extent(); | |||
} | |||
ibox2 TileSet::GetTilePixel(int tileid) const | |||
{ | |||
return std::get<0>(m_tileset_data->m_tiles[tileid]); | |||
return m_tileset_data->m_tiles[tileid].pixel_coords; | |||
} | |||
box2 TileSet::GetTileTexel(int tileid) const | |||
{ | |||
return std::get<1>(m_tileset_data->m_tiles[tileid]); | |||
return m_tileset_data->m_tiles[tileid].tex_coords; | |||
} | |||
//Palette --------------------------------------------------------------------- | |||
@@ -254,8 +261,8 @@ TileSet const* TileSet::GetPalette() const | |||
void TileSet::BlitTile(uint32_t id, mat4 model, vec3 *vertex, vec2 *texture) | |||
{ | |||
ibox2 pixels = std::get<0>(m_tileset_data->m_tiles[id]); | |||
box2 texels = std::get<1>(m_tileset_data->m_tiles[id]); | |||
ibox2 pixels = m_tileset_data->m_tiles[id].pixel_coords; | |||
box2 texels = m_tileset_data->m_tiles[id].tex_coords; | |||
float dtx = texels.extent().x; | |||
float dty = texels.extent().y; | |||
float tx = texels.aa.x; | |||