From 83af23787ce1d940bcb1500c6351d2a9cf9211cc Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Wed, 30 Oct 2024 06:47:25 -0700 Subject: [PATCH] Revision to ActorMultiVertex changes Following the discovery of the underlying bugs in BitmapText causing issues with performance of Step Statistics, I wanted to revisit some changes I made to ActorMultiVertex in ae6d7cecb53db5cfa3f1afd11971fec27a62de6c. Some things were reverted to prefer original behavior. --- src/ActorMultiVertex.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index 05a777f692..7ad8a4e077 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -179,24 +179,15 @@ void ActorMultiVertex::SetNumVertices( size_t n ) AMV_start.vertices.resize( n ); } } - -void ActorMultiVertex::ResizeVertices(std::vector& vertices, int size) -{ - if (vertices.capacity() < static_cast(size)) - { - vertices.reserve(size); - } - vertices.resize(size); -} void ActorMultiVertex::AddVertex() { for( size_t i = 0; i < AMV_Tweens.size(); ++i ) { - AMV_Tweens[i].vertices.emplace_back( RageSpriteVertex() ); + AMV_Tweens[i].vertices.push_back( RageSpriteVertex() ); } - AMV_current.vertices.emplace_back( RageSpriteVertex() ); - AMV_start.vertices.emplace_back( RageSpriteVertex() ); + AMV_current.vertices.push_back( RageSpriteVertex() ); + AMV_start.vertices.push_back( RageSpriteVertex() ); } void ActorMultiVertex::AddVertices( int Add ) @@ -205,10 +196,10 @@ void ActorMultiVertex::AddVertices( int Add ) size += Add; for( size_t i = 0; i < AMV_Tweens.size(); ++i ) { - ResizeVertices(AMV_Tweens[i].vertices, size); + AMV_Tweens[i].vertices.resize( size ); } - ResizeVertices(AMV_current.vertices, size); - ResizeVertices(AMV_start.vertices, size); + AMV_current.vertices.resize( size ); + AMV_start.vertices.resize( size ); } void ActorMultiVertex::SetVertexPos( int index, float x, float y, float z ) @@ -638,11 +629,11 @@ void ActorMultiVertex::BeginTweening( float time, ITween *pTween ) if (!AMV_Tweens.empty()) // if there was already a TS on the stack { - AMV_Tweens.emplace_back(AMV_Tweens.back()); + AMV_Tweens.push_back( AMV_Tweens.back() ); } else { - AMV_Tweens.emplace_back(AMV_current); + AMV_Tweens.push_back( AMV_current ); } } @@ -1052,10 +1043,10 @@ public: { luaL_error(L, "The texture must be set before adding states."); } - const float width_pix = tex->GetImageToTexCoordsRatioX(); - const float height_pix = tex->GetImageToTexCoordsRatioY(); - const float width_ratio = width_pix != 0 ? 1.0f / width_pix : 0; - const float height_ratio = height_pix != 0 ? 1.0f / height_pix : 0; + const float width_pix= tex->GetImageToTexCoordsRatioX(); + const float height_pix= tex->GetImageToTexCoordsRatioY(); + const float width_ratio= 1.0f / tex->GetImageToTexCoordsRatioX(); + const float height_ratio= 1.0f / tex->GetImageToTexCoordsRatioY(); const ActorMultiVertex::State& state= p->GetStateData(ValidStateIndex(p, L, 1)); lua_createtable(L, 2, 0);