Skip to content

Commit

Permalink
Merge branch 'new-renderer' of github.com:defold/extension-rive into …
Browse files Browse the repository at this point in the history
…new-renderer
  • Loading branch information
Jhonnyg committed Nov 17, 2023
2 parents 8dc49c2 + beda584 commit 90a411d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions defold-rive/src/comp_rive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,12 +1265,14 @@ namespace dmRive

static rive::Vec2D WorldToLocal(RiveComponent* component, float x, float y)
{
float scale = g_DisplayFactor;

rive::AABB bounds = component->m_ArtboardInstance->bounds();
Matrix4 world_inv = dmVMath::Inverse(component->m_World);
Vector4 local = world_inv * Point3(x, y, 0);
Vector4 local = (world_inv * Point3(x*scale, y*scale, 0));
float bounds_width_half = bounds.width() * 0.5f;
float bounds_height_half = bounds.height() * 0.5f;
rive::Vec2D p(local.getX() + bounds_width_half, bounds_height_half - local.getY());
rive::Vec2D p((local.getX() + bounds.width()) / scale, (bounds.height() - local.getY()) / scale);
return p;
}

Expand Down

0 comments on commit 90a411d

Please sign in to comment.