Hi all,
I have a custom brep object inherited from CustomBrepObject, and I override its OnDraw with custom DisplayMaterial.
I noticed that e.Display.DrawMeshShaded(mesh, material)
is invoked in every frame when I rotate the view. However it seems there is a caching mechanism within base.OnDraw(e)
that prevent Rhino “redraw” meshes for every frames.
I am testing an architectural model with more than 10,000 objects , and Rhino gets slow with following code.
protected override void OnDraw(DrawEventArgs e)
{
if (e.Display.DrawingSurfaces)
{
var material = new DisplayMaterial(Color.FromArgb(120, 75, 190));
var mesh = this.GetMeshes(MeshType.Default);
foreach (var item in mesh)
{
e.Display.DrawMeshShaded(item, material);
}
}
}
With Rhino’s "caching mechanism"
FPS is much better with following code. Rhino keeps e.Display.DrawingSurfaces
false which prevents it redraw meshes every frame when I replace my code with base.OnDraw(e)
. It is only involved when object is modified.
protected override void OnDraw(DrawEventArgs e)
{
if (e.Display.DrawingSurfaces)
{
//var material = new DisplayMaterial(Color.FromArgb(120, 75, 190));
//var mesh = this.GetMeshes(MeshType.Default);
//foreach (var item in mesh)
//{
// e.Display.DrawMeshShaded(item, material);
//}
base.OnDraw(e);
}
}
So my question is how can I enable this “caching mechanism” for my custom object to improve the FPS for a larger model?
Thanks in advance.
cc @dale