Skip to content

Commit

Permalink
Fix crash when using inherit blending mode and the draw descriptor bu…
Browse files Browse the repository at this point in the history
…ffer is empty (#172)

* Fix crash

* Updated libs
  • Loading branch information
Jhonnyg authored May 15, 2024
1 parent 9070380 commit 7e8fd9f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
5 changes: 5 additions & 0 deletions defold-spine/commonsrc/vertices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ void MergeDrawDescs(const dmArray<SpineDrawDesc>& src, dmArray<SpineDrawDesc>& d
dst.SetCapacity(src.Size());
dst.SetSize(src.Size());

if (src.Size() == 0)
{
return;
}

SpineDrawDesc* current_draw_desc = dst.Begin();
*current_draw_desc = src[0];

Expand Down
Binary file modified defold-spine/plugins/lib/arm64-osx/libSpineExt.dylib
Binary file not shown.
Binary file modified defold-spine/plugins/lib/x86_64-linux/libSpineExt.so
Binary file not shown.
Binary file modified defold-spine/plugins/lib/x86_64-osx/libSpineExt.dylib
Binary file not shown.
Binary file modified defold-spine/plugins/lib/x86_64-win32/libSpineExt.dll
Binary file not shown.
Binary file modified defold-spine/plugins/share/pluginSpineExt.jar
Binary file not shown.
27 changes: 15 additions & 12 deletions defold-spine/src/comp_spine_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,20 +912,23 @@ namespace dmSpine
if (use_inherit_blend)
{
uint32_t draw_desc_count = world->m_DrawDescBuffer.Size();
dmArray<SpineDrawDesc> scratch_draw_descs;
MergeDrawDescs(world->m_DrawDescBuffer, scratch_draw_descs);
if (draw_desc_count > 0)
{
dmArray<SpineDrawDesc> scratch_draw_descs;
MergeDrawDescs(world->m_DrawDescBuffer, scratch_draw_descs);

uint32_t merged_size = scratch_draw_descs.Size();
uint32_t ro_count_begin = world->m_RenderObjects.Size();
world->m_RenderObjects.SetSize(world->m_RenderObjects.Size() + merged_size);
uint32_t merged_size = scratch_draw_descs.Size();
uint32_t ro_count_begin = world->m_RenderObjects.Size();
world->m_RenderObjects.SetSize(world->m_RenderObjects.Size() + merged_size);

for (int i = 0; i < merged_size; ++i)
{
dmRender::RenderObject& ro = world->m_RenderObjects[ro_count_begin + i];
FillRenderObject(world, render_context, ro, first->m_RenderConstants, texture, material,
SpineBlendModeToRenderBlendMode((spBlendMode) scratch_draw_descs[i].m_BlendMode),
scratch_draw_descs[i].m_VertexStart,
scratch_draw_descs[i].m_VertexCount);
for (int i = 0; i < merged_size; ++i)
{
dmRender::RenderObject& ro = world->m_RenderObjects[ro_count_begin + i];
FillRenderObject(world, render_context, ro, first->m_RenderConstants, texture, material,
SpineBlendModeToRenderBlendMode((spBlendMode) scratch_draw_descs[i].m_BlendMode),
scratch_draw_descs[i].m_VertexStart,
scratch_draw_descs[i].m_VertexCount);
}
}
}
else
Expand Down

0 comments on commit 7e8fd9f

Please sign in to comment.