-
-
Notifications
You must be signed in to change notification settings - Fork 678
Speed up hit test
Each hit test needs to traversing the scene graph and do the hit test on each model. If model do not allow hit test, set IsHitTestVisible = false
on model property to avoid unnecessary hit test.
A better way to is using a GroupModel3D to group models do not allow hit test, and set IsHitTestVisible = false
on this GroupModel3D.
Each geometry model can create its own static octree with function Geometry3D.UpdateOctree
. By default, octree is not used and not getting created. User needs to manually call UpdateOctree
once the geometry3D is created or updated by user. The suggested approach is using a task or another thread to create the geometry and call UpdateOctree
, then post the geometry model back to the UI thread to update the visual model.
Viewport3DX contains a property AutoUpdateOctree
, once set to true, the render host will spin off a task during rendering and try to call UpdateOctree
in each model if the octree needs to be updated. However, I personally still prefer using previous approach to manually control the model creation and octree update.
Viewport3DX is doing hit test for each mouse click(both left/right mouse click). To manually control when to do and which button to do hit test, set Viewport3DX.EnableMouseButtonHitTest = false
. This will disable Viewport automatic hit test. And user can use Viewport3DX.FindHits
with mouse events to implement manual hit test. To get the screen point for viewport, use MouseEventArgs.GetPosition(Viewport3DX)
.