-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing Graphic.validateNow to work as a pre-cacher of StrokeVertices? #60
Comments
Hey, I'm not able to see how or why the stroke class would do its work twice in a frame. The validateNow() function only calls buildGeometry() if 'isInvalid == true'. How are reproducing this? |
The thing I was trying out was to avoid having the geometry generated during the render phase, However, since the "isInvalid" is only set to false in the render phase, this isn't possible. So, even if I call validateNow in the initialization stage, the geometry will be re-generated during the first call to render(), and that can cause frame-rate hickups. Maybe I was being unclear about the "being called twice"-reasoning, but I hope this explains the issue better? |
Gotcha - seems like a bug to me (it really shouldn't be validating the geometry again if you've already called validateNow()). Will take a look in a few days (out of the country at the moment) |
It's a no-brainer, really, to implement. I could throw something together if you prefer. All it needs is a boolean flag to check if the geometry has been built already.:) |
A fix for this has been checked in. Please see separate issue for explanation of what changed. |
As I was checking through the Stroke code tonight, I saw that calling validateNow
will calculate the vertex data etc for the Graphic, BUT it will run twice in a frame.
As a frame rate fiend, I like to be able to pre-calculate everything in a shape, before it renders. The way validateNow , and the building of vertices is run today, there is no way to do that, since validateNow will run within the render method, and re-generate the vertices even if no change has occured since the last time validateNow was run.
So I would suggest adding a member variable, something like:
protected var hasBeenValidatedButNeedsRender:Boolean = false;
that gets set to true after running through validateNow, regardless of where it is called from.
and, in render, we would check this flag, before running into validateNow.
override public function render( renderSupport:RenderSupport, parentAlpha:Number ):void
{
if ( hasBeenValidatedButNeedsRender == false )
validateNow();
This would allow us to precalculate everything in a Graphic class, and the only thing render would actually do would be to push the triangles to the hardware.
Doesn't that sound like a very pleasant option?
The text was updated successfully, but these errors were encountered: