Anonymous 9 years ago updated by anonymous 3 years ago 0
This discussion was imported from CodePlex

stfx wrote at 2012-03-03 07:44:

Hey there, long time no see ;)

You have been doing some great work here though I didnt check the code in detail yet.

One thing that has always been an issue though, not just with this awesome toolkit but rather WPF 3D in general, is performance (atleast compared to directx). Thats why we really need to optimize the code.

Like in HelixViewport3D.cs you should remove the this.Viewport.Children.Contains check in the Add(), Clear(), Remove() functions as this is something which should be checked by the overlaying code. In fact I would even remove them completely since we already have access to Viewport.Children and can add/remove/clear them just as easy (in windowsforms.listview you also add the items like listview1.items.add(...) and not listview1.add(...)).

Also it might we worth considering in general which code should be in the library and which could be added to the examples. For example the headlight seems like a really seldom used feature which slows the viewer down a bit. Probably not noticable but still why not add an handler for camerachanged and export it to the example code. Although I guess its easy enough for anyone to remove it from the code if they so wish.

There are probably more places where performance could be optimized - maybe its even possible that the models that use the same models could somehow not redundantly save the mesh .

Thanks and keep up the good work


EDIT: Just out of curiosity how do you compare the performance of the first revs to the current one? Also is your screen line implementation also quite slow compared to usual DirectX line drawings? This was always bothering me with WPF actually. Btw were there any improvements in .net 4.0 for WPF 3D?

EDIT2: I need to have a scene with many models and emissive simple meshes (sphere, box, plane) which can be seen on a screen here: http://code.google.com/p/freelancermodstudio/ which need to be selected (display a bounding box) and then translated, scaled, rotated. I know for a fact that its possible with this toolkit but Would you say using directX approach might be more suitable as in performance?

objo wrote at 2012-03-10 16:02:

Thanks for the feedback! I think you are right, the Add,Clear and Remove methods are not needed. See changelist a79030ea7c0e.

I have not run a profiler on this library lately, but I don't think the 'headlight' feature has any noticable performance impact. 

Using the HelixViewport3D to calculate the total number of triangles will have a performance impact, so this should be used with care.

The line implementation (LinesVisual3D) in this library is of course slow compared to using DirectX LineList primitive, but it should be faster that the other two WPF3D implementations shown in the PointsAndLinesDemo.

If you need to draw a lot of lines (more than 1000 segments) or more control of the shaders, I think you should go for DirectX. The SlimDX library includes a WPF example! 

stfx wrote at 2012-03-11 00:23:

Thanks for your answer.

Btw before I forget:

  • HelixViewport3D:OnApplyTemplate() ... last assert is incorrectly the same as the previous one
  • Viewport3DHelper:FindNearest() ... the 5 lines after
    // first transform the Model3D hierarchy
    seem to break correct detection of clicked visual for me


  • Also Resharper notices some small coding issues which might be worth looking into


Right now I am struggling to correctly use the LinesVisual3D class (cant seem to find out the correct points). I was delighted when I first noticed the  BoundingBoxVisual3D.cs file thinking that this one would create those screen space lines around an object until I found out that its just some tubes being aranged like a boundingbox :D

objo wrote at 2012-03-11 20:46:

OnApplyTemplate fixed, thanks!

Let me know if you find the bug in Viewport3DHelper:FindNearest!

Yes, I try to keep the Resharper/Stylecop status on 'green'. Viewport3DHelper and HelixViewport3D seems to be ok, but I am sure there are warnings in other classes. Please report if you see some bugs.

Yes, BoundingBoxVisual3D is using cylinders - I made that class before making the LinesVisual3D. Should add a property where you can select between lines or cylinders.

stfx wrote at 2012-03-11 22:23:

Well commenting out the 5 lines after that comment fixed the FindNearest function for me ;)

Hm I would rather replace the functionality in BoundingBoxVisual3D as I think nobody would use cylinders for something like that :P

Other than that I only found some code styling issues which dont affect anything like why are your comments in the functions in MeshBuilder.cs commented out twice? Also in MeshBuilder.AddTriangeStrip() the  wikipedia link exists twice.

objo wrote at 2012-04-05 02:08:

Could the error be in GetTransform(Visual3D, Model3D)? Can you create a small example model where the current implementation fails?

I have tested with the stick figure in ExportDemo (this contains lots of Model3D transforms), and it seems to work ok here (double click on the 'fingers', and you see the target point will be set correctly).

Bounding box with lines - I added this issue http://helixtoolkit.codeplex.com/workitem/9950

Thanks, the MeshBuilder wiki-link comments will be fixed in the next code push. I use "////" when I don't want resharper to reformat comment 'figures'.

peterthesaint wrote at 2014-07-25 12:44:

Hello !!!

It is my first post here. Thanks for your great work !!!

Previously in my model I was using ScreenLinesVisual3d.
Now I noticed new Helix version allows LinesVisual3d and I was wondering whether you have implemented changes suggested in this link: