Skip to content

Commit

Permalink
fix bounds calculation ahead of time
Browse files Browse the repository at this point in the history
this PR handles marking a shape bounds as dirty after it has updated.
This is needed because pointer events can trigger before a new draw update, which would consume the change flag before the shape has properly updated.

Diffs=
085f5bd2d fix bounds calculation ahead of time (#7380)

Co-authored-by: hernan <hernan@rive.app>
  • Loading branch information
bodymovin and bodymovin committed Jun 6, 2024
1 parent 41a6932 commit dd5cc31
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dde676085908d492af545660cbbb19ee0d10d91d
085f5bd2dce2d25561b00eebc5f7118a2c8769eb
5 changes: 5 additions & 0 deletions include/rive/shapes/shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class Shape : public ShapeBase, public ShapePaintContainer
}
return m_WorldBounds;
}
void markBoundsDirty()
{
drawableFlags(drawableFlags() &
~static_cast<unsigned short>(DrawableFlag::WorldBoundsClean));
}

AABB computeWorldBounds(const Mat2D* xform = nullptr) const;
AABB computeLocalBounds() const;
Expand Down
1 change: 1 addition & 0 deletions src/shapes/path_composer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void PathComposer::update(ComponentDirt value)
}
}
}
m_Shape->markBoundsDirty();
}
}

Expand Down
1 change: 0 additions & 1 deletion src/shapes/shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ bool Shape::collapse(bool value)

void Shape::pathChanged()
{
drawableFlags(drawableFlags() & ~static_cast<unsigned short>(DrawableFlag::WorldBoundsClean));
m_PathComposer.addDirt(ComponentDirt::Path, true);
for (auto constraint : constraints())
{
Expand Down

0 comments on commit dd5cc31

Please sign in to comment.