Custom drawn grips are randomly disappearing (C++)

Is there some “bounding region” mechanism or clipping behavior inside CRhinoMeshObject that causes custom grips to be clipped? I’m seeing my lines and points randomly disappear when dragged far away from the “source” object. I’m assuming there’s some bounding region I need to update?

Rendering code for my grips below:

void CRhinoMyObjectGrips::Draw(CRhinoDrawGripsSettings &dgs)
{
  UpdateMyObject();

  if(auto ccModel = controlCage.lock())
  {
	auto editInds = ccModel->getEditMeshTriangles();
	auto editIndsQuad = ccModel->getEditMeshQuads();
	uint3 *triData = (uint3 *)editInds->getData();
	uint4 *quadData = editIndsQuad ? (uint4 *)editIndsQuad->getData() : nullptr;
	int numTris = editInds->getCount()/3;
	int numQuads = editIndsQuad ? editIndsQuad->getCount()/4 : 0;

	for(int i = 0; i < numQuads; i++)
	{
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].x].GripLocation(), m_MyObject_grips[quadData[i].y].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].y].GripLocation(), m_MyObject_grips[quadData[i].z].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].z].GripLocation(), m_MyObject_grips[quadData[i].w].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[quadData[i].w].GripLocation(), m_MyObject_grips[quadData[i].x].GripLocation());
	}

	for(int i = 0; i < numTris; i++)
	{
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[triData[i].x].GripLocation(), m_MyObject_grips[triData[i].y].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[triData[i].y].GripLocation(), m_MyObject_grips[triData[i].z].GripLocation());
	  dgs.m_dp.DrawDottedLine(m_MyObject_grips[triData[i].z].GripLocation(), m_MyObject_grips[triData[i].x].GripLocation());
	}
  }

  CRhinoObjectGrips::Draw(dgs); //grip points are disappearing too
}

Hi @gccdragoonkain,

Your custom object’s CRhinoObject::BoundingBox overides should take the displsy of grips into account.

Also, rather than draw your own grips, the SDK allows you to add your own custom grips. Here is an example:

– Dale

Thanks Dale! I’ll give this a try first thing tomorrow.

I had exactly the same issue. It appears only when some grips are far in space from the parent object. This display conduit by Dale in this thread solves the issue:

May this be a bug @dale?

OK, let me clarify this.

If you are creating custom grips, as demonstrated by the sample SDK project I’ve referenced, then your custom object needs to return a bounding box that takes these grip locations into account.

If you are drawing your grips in a conduit, which is the incorrect approach in my opinion, then your conduit will need to subscribe to the SC_CALCBOUNDINGBOX channel. When the overrride CRhinoDisplayConduit::ExecConduit overide is called, check for the SC_CALCBOUNDINGBOX and grow the channel attribute’s bounding box if needed.

bool CTestConduit::ExecConduit(CRhinoDisplayPipeline& dp, UINT nActiveChannel, bool& bTerminateChannel)
{
  switch (nActiveChannel)
  {
  case CSupportChannels::SC_CALCBOUNDINGBOX:
  {
    // Make sure our geometry is not clipped
    m_pChannelAttrs->m_BoundingBox.Union(...);
  }

– Dale