Hi everyone,
I’m fighting with CustomMeshObject, trying to keep its base geometry as a single mesh object, but draw it separately for distinct colors - tree trunk and crown. The idea seems to be straightforward and should be fairly easy to achieve, but I’m getting weird results in the viewport when selecting the item, it looks like the object is somehow “flipped” when selected.
Here’s my OnDraw override:
protected override void OnDraw(DrawEventArgs e)
{
EnsureSplitMeshes(); // Method that makes sure if cached elements are ready
if (_cachedTrunk != null && _cachedCrown != null)
{
e.Display.DrawMeshShaded(_cachedTrunk, TrunkMat);
e.Display.DrawMeshShaded(_cachedCrown, CrownMat);
}
// Just to keep Rhino selection highlight
if (IsSelected(false) > 0)
{
base.OnDraw(e); // with it or without it i get "hollow" selection result
}
}
Here’s how it behaves in three variants:
Without base.OnDraw(e)
With it for the highlight feature:
And plain passthrough without any additional tweaks in the OnDraw override - so without “double colored” mesh - the only one that behaves as expected.
And the last one 4th actually, when in custom display mode - suddenly I see a reflection on a simple diffuse mat - those are set like this:
private static readonly DisplayMaterial TrunkMat = new DisplayMaterial(Color.FromArgb(152, 128, 92));
private static readonly DisplayMaterial CrownMat = new DisplayMaterial(Color.FromArgb(102, 192, 56));
Does anyone have a hint on how to avoid such glitches and show the same result as without selection (when with selection)?

