I have a custom data type as a class in Visual Studio, lets say “CustomMesh”. It is essentially a mesh, but with more data behind (more points). Inside CustomMesh class I have implemented a DrawViewportMeshes as follows:
where dispMesh is a very simple light version of the real full mesh laying behind. Only for rendering and drawing purposes.
Now, I have created a custom Parameter, where I have IGH_PreviewObject implemented as:
public void DrawViewportWires(IGH_PreviewArgs args)
{
Preview_DrawWires(args);
}
Although dispMesh is a very very simple mesh, and I can view it in the viewport, when handling Rhino things are veeeery slow and general performance decreaces.
Any idea why is this happening? if I convert my “CustomMesh” to a normal GH Mesh, things speed up again. So I feel Im doing something wrong either in my parameter drawing, or in my CustomMesh class drawing.
Try to store dispMesh as a cache/ internal variable inside the class and only build it (calling DisplaySimpleMesh()) when your input data changes. Perhaps creating that lightweight mesh every time rhino renders the viewport is the cause of the delay.
Hi Dani, thanks for the answer, I think you are right.
Do you know how I can call my fuction DisplaySimpleMesh inside the parameter? Is it inside DrawViewportWires section from the parameter? Im struggling to access the object inside the parameter in order to call my function DisplaySimpleMesh()…help is most welcome!
Its basically a high order tetrahedral mesh. In the data type there is a list of Nodes (id, x, y, z), list of tetra elements (each tetra is a mesh of 4 faces). So yea they can be in the order of thousands of meshes inside the data type. DisplaySimpleMesh is a function inside the class just returning a mesh around the volume, only for rendering the shape. I dont want to render each tetra element. Do you have any example for doing this caching?