Skip to content

Commit

Permalink
Fixing issue with mesh system not properly handling submeshes
Browse files Browse the repository at this point in the history
  • Loading branch information
Honeybunch committed Oct 19, 2023
1 parent 6e6246e commit 53debde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
13 changes: 13 additions & 0 deletions source/cimgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,21 @@
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#include "./imgui_internal.h"

#ifdef __clang__
#pragma clang diagnostic push
#if __has_warning("-Wreserved-identifier")
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
#endif
#endif

#include "cimgui.h"

#ifdef __clang__
#pragma clang diagnostic pop
#endif

CIMGUI_API ImVec2 *ImVec2_ImVec2_Nil(void) { return IM_NEW(ImVec2)(); }
CIMGUI_API void ImVec2_destroy(ImVec2 *self) { IM_DELETE(self); }
CIMGUI_API ImVec2 *ImVec2_ImVec2_Float(float _x, float _y) {
Expand Down
16 changes: 8 additions & 8 deletions source/meshsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ void mesh_draw_tick2(ecs_iter_t *it) {
// Run query to determine how many meshes so we can pre-allocate space for
// batches
ecs_iter_t mesh_it = ecs_query_iter(ecs, mesh_sys->mesh_query);
const int32_t mesh_count = ecs_iter_count(&mesh_it);
const uint32_t max_mesh_count = ecs_iter_count(&mesh_it) * TB_SUBMESH_MAX;
mesh_it = ecs_query_iter(ecs, mesh_sys->mesh_query);

// Init arrays on an allocator with a fast allocation
Expand All @@ -2429,14 +2429,14 @@ void mesh_draw_tick2(ecs_iter_t *it) {
DrawBatchList trans_batches = {0};
PrimitiveBatchList opaque_prim_batches = {0};
PrimitiveBatchList trans_prim_batches = {0};
TB_DYN_ARR_RESET(opaque_batches, tmp_alloc, mesh_count);
TB_DYN_ARR_RESET(trans_batches, tmp_alloc, mesh_count);
TB_DYN_ARR_RESET(opaque_prim_batches, tmp_alloc, mesh_count);
TB_DYN_ARR_RESET(trans_prim_batches, tmp_alloc, mesh_count);
TB_DYN_ARR_RESET(opaque_batches, tmp_alloc, max_mesh_count);
TB_DYN_ARR_RESET(trans_batches, tmp_alloc, max_mesh_count);
TB_DYN_ARR_RESET(opaque_prim_batches, tmp_alloc, max_mesh_count);
TB_DYN_ARR_RESET(trans_prim_batches, tmp_alloc, max_mesh_count);
PrimitiveTransformLists opaque_prim_trans = {0};
PrimitiveTransformLists trans_prim_trans = {0};
TB_DYN_ARR_RESET(opaque_prim_trans, tmp_alloc, mesh_count);
TB_DYN_ARR_RESET(trans_prim_trans, tmp_alloc, mesh_count);
TB_DYN_ARR_RESET(opaque_prim_trans, tmp_alloc, max_mesh_count);
TB_DYN_ARR_RESET(trans_prim_trans, tmp_alloc, max_mesh_count);
TracyCZoneN(ctx2, "Iterate Meshes", true);
while (ecs_query_next(&mesh_it)) {
MeshComponent *meshes = ecs_field(&mesh_it, MeshComponent, 1);
Expand Down Expand Up @@ -2515,7 +2515,7 @@ void mesh_draw_tick2(ecs_iter_t *it) {
if (batch == NULL) {
// Worst case batch count is one batch having to carry every
// mesh with the maximum number of possible submeshes
const uint32_t max_draw_count = mesh_count * TB_SUBMESH_MAX;
const uint32_t max_draw_count = max_mesh_count;
DrawBatch db = {
.pipeline = pipeline,
.layout = layout,
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
{
"name": "mimalloc",
"version": "2.1.1"
"version": "2.0.7"
},
{
"name": "sdl2",
Expand Down

0 comments on commit 53debde

Please sign in to comment.