Polyline in ImmediateMode gets updated even if not changed

Avatar
  • updated
  • Fixed

Using the polyline example from the documentation in immediate mode generates a new mesh every frame. Even if I reuse the polyline object.

I "fixed" it by adding a meshDirty check in PolylinePath.TryUpdateMesh()

void TryUpdateMesh( bool closed, PolylineJoins joins ) {
    lastUsedClosed = closed;
    lastUsedJoins = joins;
    // todo: be smarter about this, maybe don't mesh.clear but check point count and whatnot
    if(meshDirty) {
        ShapesMeshGen.GenPolylineMesh( base.mesh, path, closed, joins, flattenZ: false, useColors: true );
    }
    meshDirty = false;
}

Did I missed something?

Reporting a bug? please specify Unity version:
2020.2.2f
Reporting a bug? please specify Shapes version:
3.0.0
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Fixed

ah heck good catch, actually just forgot to read the dirty flags! this has now been fixed in 3.2.2

the proper fix is to do this in DisposableMesh.cs, since this would also apply to polygons

Avatar
Freya Holmér creator
  • Answer
  • Fixed

ah heck good catch, actually just forgot to read the dirty flags! this has now been fixed in 3.2.2

the proper fix is to do this in DisposableMesh.cs, since this would also apply to polygons