typedef & PascalCase for ALL structs and enums
This commit is contained in:
@ -9,42 +9,42 @@
|
||||
/* TODO: automatic handling of repeating textures */
|
||||
/* for that we could allocate a loner texture */
|
||||
void unfurl_triangle(const char *path,
|
||||
t_fvec3 v0,
|
||||
t_fvec3 v1,
|
||||
t_fvec3 v2,
|
||||
t_shvec2 uv0,
|
||||
t_shvec2 uv1,
|
||||
t_shvec2 uv2)
|
||||
Vec3 v0,
|
||||
Vec3 v1,
|
||||
Vec3 v2,
|
||||
Vec2sh uv0,
|
||||
Vec2sh uv1,
|
||||
Vec2sh uv2)
|
||||
{
|
||||
const t_texture_key texture_key = textures_get_key(&ctx.texture_cache, path);
|
||||
const TextureKey texture_key = textures_get_key(&ctx.texture_cache, path);
|
||||
|
||||
struct mesh_batch_item *batch_p = hmgetp_null(ctx.uncolored_mesh_batches, texture_key);
|
||||
struct MeshBatchItem *batch_p = hmgetp_null(ctx.uncolored_mesh_batches, texture_key);
|
||||
if (!batch_p) {
|
||||
struct mesh_batch item = {0};
|
||||
struct MeshBatch item = {0};
|
||||
hmput(ctx.uncolored_mesh_batches, texture_key, item);
|
||||
batch_p = &ctx.uncolored_mesh_batches[hmlenu(ctx.uncolored_mesh_batches) - 1]; /* TODO: can last index be used? */
|
||||
}
|
||||
|
||||
union uncolored_space_triangle triangle = { .primitive = {
|
||||
union UncoloredSpaceTriangle triangle = { .primitive = {
|
||||
.v0 = v0,
|
||||
.v1 = v1,
|
||||
.v2 = v2,
|
||||
.uv1 = m_to_fvec2(uv1),
|
||||
.uv0 = m_to_fvec2(uv0),
|
||||
.uv2 = m_to_fvec2(uv2),
|
||||
.uv1 = m_vec2_from(uv1),
|
||||
.uv0 = m_vec2_from(uv0),
|
||||
.uv2 = m_vec2_from(uv2),
|
||||
}};
|
||||
|
||||
union uncolored_space_triangle *triangles = (union uncolored_space_triangle *)batch_p->value.primitives;
|
||||
union UncoloredSpaceTriangle *triangles = (union UncoloredSpaceTriangle *)batch_p->value.primitives;
|
||||
|
||||
arrpush(triangles, triangle);
|
||||
batch_p->value.primitives = (uint8_t *)triangles;
|
||||
}
|
||||
|
||||
|
||||
void draw_uncolored_space_traingle_batch(struct mesh_batch *batch,
|
||||
t_texture_key texture_key)
|
||||
void draw_uncolored_space_traingle_batch(struct MeshBatch *batch,
|
||||
TextureKey texture_key)
|
||||
{
|
||||
static vertex_buffer vertex_array = 0;
|
||||
static VertexBuffer vertex_array = 0;
|
||||
if (vertex_array == 0)
|
||||
vertex_array = create_vertex_buffer();
|
||||
|
||||
@ -54,8 +54,8 @@ void draw_uncolored_space_traingle_batch(struct mesh_batch *batch,
|
||||
if (primitives_len == 0)
|
||||
return;
|
||||
|
||||
const t_frect srcrect = textures_get_srcrect(&ctx.texture_cache, texture_key);
|
||||
const t_frect dims = textures_get_dims(&ctx.texture_cache, texture_key);
|
||||
const Rect srcrect = textures_get_srcrect(&ctx.texture_cache, texture_key);
|
||||
const Rect dims = textures_get_dims(&ctx.texture_cache, texture_key);
|
||||
|
||||
const float wr = srcrect.w / dims.w;
|
||||
const float hr = srcrect.h / dims.h;
|
||||
@ -64,8 +64,8 @@ void draw_uncolored_space_traingle_batch(struct mesh_batch *batch,
|
||||
|
||||
/* update pixel-based uvs to correspond with texture atlases */
|
||||
for (size_t i = 0; i < primitives_len; ++i) {
|
||||
struct uncolored_space_triangle_payload *payload =
|
||||
&((union uncolored_space_triangle *)batch->primitives)[i].payload;
|
||||
struct UncoloredSpaceTrianglePayload *payload =
|
||||
&((union UncoloredSpaceTriangle *)batch->primitives)[i].payload;
|
||||
|
||||
payload->uv0.x = xr + ((float)payload->uv0.x / srcrect.w) * wr;
|
||||
payload->uv0.y = yr + ((float)payload->uv0.y / srcrect.h) * hr;
|
||||
@ -75,7 +75,7 @@ void draw_uncolored_space_traingle_batch(struct mesh_batch *batch,
|
||||
payload->uv2.y = yr + ((float)payload->uv2.y / srcrect.h) * hr;
|
||||
}
|
||||
|
||||
specify_vertex_buffer(vertex_array, batch->primitives, primitives_len * sizeof (struct uncolored_space_triangle_payload));
|
||||
specify_vertex_buffer(vertex_array, batch->primitives, primitives_len * sizeof (struct UncoloredSpaceTrianglePayload));
|
||||
|
||||
finally_draw_uncolored_space_traingle_batch(batch, texture_key, vertex_array);
|
||||
}
|
||||
|
Reference in New Issue
Block a user