removing ScreenSpaceLines3D from viewport


if you remove a ScreenSpaceLines3D from the viewport, then the app crashes because the OnRender event is not removed, and the visual parent is missing then.
I fixed this for me locally (see attached file)
This is maybe not the best solution, but it works.

file attachments


Guille29 wrote Oct 6, 2011 at 6:27 PM

Hi, thanks for posting your source code. I've been searching everywhere, and it seems you are the only one who has done it. Thanks!
I pasted your code in mine, compiled the .dll and it works! I hope there are no memory leaks! I have read somewhere about memory leak problems associated to screenspacelines3d. Do you know something about that?

osre wrote Oct 7, 2011 at 8:53 AM

Hi, so far I did not notice any memory leaks. But the part of my program where I use the ScreenSpaceLines3D is used not verry often.

Guille29 wrote Oct 7, 2011 at 9:29 AM

I have tested it yesterday and seems to work fine. I use this class quite often, because in my project the user should be able to design the geometry of a 3D object by changing the mess when feeling like. I'm happy I can finally get rid of those lines I don't want to display anymore in a "decent way". I hope no co-lateral problems will appear! :) Thanks again for your help!

wrote Feb 22, 2013 at 12:05 AM

Lemurr wrote May 21, 2014 at 10:30 AM

For me the following fix worked for ALL removing elements in MathUtils.css:
public static Matrix3D TryWorldToCameraTransform(Viewport3DVisual visual, out bool success)
            success = false;
            Matrix3D result = Matrix3D.Identity;

            if (visual == null) // no check if null!
                return ZeroMatrix;
            [ ... ] 

JohannBescond wrote May 17, 2015 at 4:20 PM

Remove ScreenSpaceLines3D :
            foreach (ScreenSpaceLines3D line3D in lines3DList)
                lines3D.Points.Clear(); // Very importante