Display instancing methods request

Hi, after taming the display conduit to my needs and trying to get the best out of it I found (if I’m not wrong) that there’s only one method which actually allows display instancing. It is based on RhinoObject and in my case it’s super limiting there is no other for meshes or point clouds. RhinoObject has to be part of RhinoDoc what in my case is absolutely unacceptable.

Is it possible to introduce something in that matter? Wasting GBs of RAM for keeping objects for display purposes is just not smart at all. Sorry, @dale for bothering but I’m not sure who I should ask about this. Would you mind marking appropriate person here?

1 Like

Is there any reason you can’t Push and Pop model transforms for the various meshes/point clouds? If you have a single mesh or point cloud that just needs to be drawn multiple times with a different transform that should be adequate. RhinoCommon keeps track of caches for meshes and point clouds automatically. When iterating over each of your “instances” you can push the model transform, draw the mesh/point cloud, and pop the model transform before moving onto the next one. @stevebaer also might have some good ideas.

@Joshua_Kennedy Thank you for your input!

Seems I don’t get how this works. In my understanding push/pop is like “save/restore” not having anything in common with instancing? (I don’t know whats inside so actually asking) Let’s say we have simple structure like Dict<PtCloud,Transform[]> now i should iterate over values of key value pair and redraw it using it like → push redraw pop? Not sure why but I have bad feeling that this would impact performance a lot.

I’m not sure what you mean by instancing, but that is exactly what I’m suggesting. I was under the impression you were trying to avoid keeping around several hundred copies of the transformed meshes/point clouds. My method would allow a single point cloud or mesh to kept and all the transforms applied during drawing. I guess in the context of your dictionary it would look like

foreach(var pair in dict)
    foreach(Transform transform in pair.Value)

Push and pop in this context is referring to a stack where the transform at the top is transforming whatever is currently being drawn in the pipeline. I believe this means the point cloud or mesh is being stored once on the GPU with the cache handle, and being drawn multiple times with the model transform being applied GPU side.

As for performance, you’ll have to let us know.

Yes, yes you understood my needs perfectly. I’m just bit like :open_mouth: I was completly blind or couldn’t manage it to work.

Yes exactly.

Will do. Now I have to prep couple of reasonable stress tests to compare batching vs push/pop.

Ah @Joshua_Kennedy as we are already inside the drawing loop. Is there any special advised way of aborting the current frame drawing? I mean sometimes I tackled AccessViolationException due to fact that objects were batched then drawn and while drawn I was already changing this batch to another. I established this using simple bool checking drawing and updating but i just wonder if there is any other way to prevent the risk of AccessViolationException while the RhinoCommon method is executed.

1 Like

I don’t believe there is any way to abort the current frame drawing. I would suggest queuing your changes and drawing again. I can’t say off the top of my head why the exception is occurring. I’d need a repeatable case to help diagnose this. It sounds like it’s coming from modifying your collection as you’re using/iterating it, but I can’t be sure.

Yes. Exactly from that reason thats why i asked if there is any advised way :slight_smile: I’ll keep experimenting :slight_smile: