Skip to content

Commit

Permalink
Misc fixse
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhonnyg committed Apr 3, 2024
1 parent 9061a00 commit ddfd566
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions defold-spine/commonsrc/vertices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <float.h> // using FLT_MAX
#include <dmsdk/dlib/math.h>

#include <stdio.h>

namespace dmSpine
{

Expand Down Expand Up @@ -148,14 +146,15 @@ uint32_t CalcVertexBufferSize(const spSkeleton* skeleton, uint32_t* out_max_tria
uint32_t CalcDrawDescCount(const spSkeleton* skeleton)
{
uint32_t count = 0;
for (int s = 0; s < skeleton->slotsCount; ++s, ++count)
for (int s = 0; s < skeleton->slotsCount; ++s)
{
spSlot* slot = skeleton->drawOrder[s];
spAttachment* attachment = slot->attachment;
if (!attachment)
{
continue;
}
count++;
}
return count;
}
Expand Down
16 changes: 8 additions & 8 deletions defold-spine/src/comp_spine_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extern "C" {
#include <spine/Bone.h>
#include <spine/Skeleton.h>
#include <spine/Slot.h>
#include <spine/SlotData.h>
#include <spine/AnimationState.h>
#include <spine/Attachment.h>
#include <spine/RegionAttachment.h>
Expand Down Expand Up @@ -78,7 +77,7 @@ namespace dmSpine
dmGraphics::HVertexDeclaration m_VertexDeclaration;
dmGraphics::HVertexBuffer m_VertexBuffer;
dmArray<dmSpine::SpineVertex> m_VertexBufferData;
dmArray<SpineDrawDesc> m_DrawDescs;
dmArray<SpineDrawDesc> m_DrawDescBuffer;
dmResource::HFactory m_Factory;
};

Expand Down Expand Up @@ -874,7 +873,8 @@ namespace dmSpine
uint32_t vertex_count = 0;
uint32_t draw_desc_buffer_count = 0;

world->m_DrawDescs.SetSize(0);
// This is a temporary scratch buffer just used for this batch call, so we make sure to reset it.
world->m_DrawDescBuffer.SetSize(0);

for (uint32_t *i = begin; i != end; ++i)
{
Expand All @@ -888,9 +888,9 @@ namespace dmSpine
}
}

if (draw_desc_buffer_count && draw_desc_buffer_count > world->m_DrawDescs.Capacity())
if (draw_desc_buffer_count && draw_desc_buffer_count > world->m_DrawDescBuffer.Capacity())
{
world->m_DrawDescs.SetCapacity(draw_desc_buffer_count);
world->m_DrawDescBuffer.SetCapacity(draw_desc_buffer_count);
}

if (vertex_count > world->m_VertexBufferData.Capacity())
Expand All @@ -903,17 +903,17 @@ namespace dmSpine
{
component_index = (uint32_t)buf[*i].m_UserData;
const SpineModelComponent* component = (const SpineModelComponent*) components[component_index];
vertex_count += dmSpine::GenerateVertexData(world->m_VertexBufferData, component->m_SkeletonInstance, component->m_World, use_inherit_blend ? &world->m_DrawDescs : 0);
vertex_count += dmSpine::GenerateVertexData(world->m_VertexBufferData, component->m_SkeletonInstance, component->m_World, use_inherit_blend ? &world->m_DrawDescBuffer : 0);
}

dmGraphics::HTexture texture = resource->m_SpineScene->m_TextureSet->m_Texture->m_Texture; // spine - texture set resource - texture resource - texture
dmRender::HMaterial material = GetMaterial(first);

if (use_inherit_blend)
{
uint32_t draw_desc_count = world->m_DrawDescs.Size();
uint32_t draw_desc_count = world->m_DrawDescBuffer.Size();
dmArray<SpineDrawDesc> scratch_draw_descs;
MergeDrawDescs(world->m_DrawDescs, 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();
Expand Down

0 comments on commit ddfd566

Please sign in to comment.