Refresh Viewport

 
 
 
Posted by:Vincentt
Data created:1 January 2015

Hello,

I’m trying to move vertices on a triMesh, but the viewport doesn’t seem to update. I’ve tried mutilple things, but none of them seem to work:

//iface.RedrawViews(iface.Time, RedrawFlags.Begin, null); //Option 2


...
var localPos = m_TempTriMesh.GetVert(vertexIndex);

localPos.X += 50;

m_TempTriMesh.SetVert(vertexIndex, localPos);

...

 

m_TempTriMesh.InvalidateGeomCache();
iface.ForceCompleteRedraw(true); //Option 1

iface.RedrawViews(iface.Time, RedrawFlags.Normal, null); //Option 3

//iface.RedrawViews(iface.Time, RedrawFlags.End, null); //Option 2

So the first thing I tried was: iface.ForceCompleteRedraw(true); Then I tried the ‘RedrawViews’ with ‘Begin’ and ‘End’ then as my final resort I just called RedrawViews with ‘Normal’ None of these things work. I know moving the vertex works, because when I click in the viewport I can suddenly see the result of the move.

So somehow my viewport isn’t getting refreshed correctly? Is there anything else I could be doing wrong?

 

Thanks!
Vin

Hi Vin,

Redrawing viewports properly can be tricky as I also ran into similar issues before. ForceCompleteRedraw function seems to be the only sure way to make everything redraw correcty. It should redraw the viewports as soon as you call it. RedrawViews function works sporadically, especially if you use the Begin/Update/End flags. You might have to pass in a reference to an IReferenceTarget into it to work properly, not sure.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hey Marsel,

I was missing triMesh.InvalidateTopologyCache(); adding it has fixed it, I just use ForceCompleteRedraw and none of the RedrawViews things :)

 

Thanks!

Sounds good :)

Marsel Khadiyev (Software Developer, EPHERE Inc.)