Skip to content

Commit

Permalink
[WIP] fix: invalidate rvalue instead of curr instance
Browse files Browse the repository at this point in the history
Also, use props from `Transform` instead of from `SpriteRenderer`.
  • Loading branch information
iWas-Coder committed Oct 7, 2024
1 parent 5e7493e commit 7ba24dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Renderer/Sprite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace volt::renderer {
{
// NOTE: leave the rvalue Sprite object in an invalid state (id <= 0), so when it gets destroyed (after it's moved)
// it doesn't get unloaded from GPU's VRAM (i.e. leave the moved-from object as a hollow object (empty state)).
m_width = 0;
m_height = 0;
s.m_width = 0;
s.m_height = 0;
s.m_data = {};
m_name.clear();
s.m_name.clear();
}

Sprite::~Sprite(void) {
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/Scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace volt::runtime {
m_worldID = b2CreateWorld(&worldDef);
}
ForAll<TransformComponent, Rigidbody2DComponent, renderer::SpriteRendererComponent>([this](auto e, auto &t, auto &rb, auto &sr) {
rb.SetExtent({sr.scale * sr.sprite.width() * 0.5f, sr.scale * sr.sprite.height() * 0.5f});
rb.SetExtent({t.scale * sr.sprite.width() * 0.5f, t.scale * sr.sprite.height() * 0.5f});
b2BodyDef bodyDef { b2DefaultBodyDef() };
bodyDef.type = static_cast<b2BodyType>(rb.type);
bodyDef.gravityScale = rb.gravityScale;
Expand Down

0 comments on commit 7ba24dd

Please sign in to comment.