We have found that some polylines sent by DrawEventArgs.Display.DrawPolyline() in our DisplayConduit are missing in Rendered mode when there is a layer (containing Brep, Curve, Point objects) also being visualised at the same time. In other modes such as wireframe and shaded there is no such problem.
The polylines will be displayed as expected if we turn off the layer or uncheck “Shadows On” in View->Display Options->Rendered->Shadows.
Is there a known problem in Rhino? And do you suggest any other workarounds to prevent this from happening?
Yes, PostDrawObjects() works in rendered mode. I investigated the reason that we use PreDrawObjects() instead and wonder if you can provide some suggestion for our use case:
We decided to use PreDrawObjects() because we also draw polylines in the area of stock mesh, which is not visible in the ghosted mode if we use PostDrawObjects() with the following code.
For fulfilling all use cases, We might use Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.DisplayMode.LocalName to decide using pre or post draw. Does it meet the conduit concept of Rhino? Or We can also check if the polylines are in the bounding box of the mesh object.
hmm, I don’t follow what you mean with that. What does ‘in the area of stock mesh’ mean?
If you want to be sure that what you draw gets in front, you could also use DrawForeground.
As mentioned on the docs for PostDrawObjects:
Called after all non-highlighted objects have been drawn. Depth writing and testing are still turned on. If you want to draw without depth writing/testing, see DrawForeground.
Hi, sorry to confuse you due to some imprecise term. I mean we are drawing polylines inside the bounding box of the model.( the red one in the screenshot, the model mentioned here is stock.3dm uploaded before)
Our expected behaviour is the polyline is blocked by the model, and we can only see it in ghosted display mode.To achieve it, we used PreDrawObjects().
For the unexpected behaviour in rendered mode, which is the first question in the discussion, we might use PostDrawObjects() to fix it, but we lose the polyline inside the model in this case.
To showing the checked cases in the screenshot below, my idea is that I can decide to draw polyines in PreDrawObjects/PostDrawObjects with the if condition using display mode. Or by checking if the polyline overlapped with the model. (I think the first idea makes more sense, but not quite sure if I missed anything from display conduit perspective and might cause any further issue)
I tried DrawForeground()/EnableDepthWriting(false), but the polyline is too clear that it is not that easy to tell that it is actually covered by the model.