//-------------------------------------------------------------- #region Creation & Cleanup //-------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Scene"/> class. /// </summary> public Scene() { Children = new SceneNodeCollection(); if ((GlobalSettings.ValidationLevelInternal & GlobalSettings.ValidationLevelUserHighExpensive) != 0) { SceneChanged += OnSceneChangedValidation; } // Create a default collision filter. var filter = new SceneNodeCollisionFilter(this); filter.Set(1, 1, false); // Ignore camera vs. camera. filter.Set(2, 3, false); // Ignore light vs. lens flare. filter.Set(3, 3, false); // Ignore lens flare vs. lens flare. filter.Set(3, 4, false); // Ignore lens flare vs. mesh. filter.Set(4, 4, false); // Ignore mesh vs. mesh. _filter = filter; _collisionObjectFilter = new SceneCollisionObjectFilter(filter); var collisionDetection = new CollisionDetection { CollisionFilter = null, }; // DualPartition is better for frustum culling. _collisionDomain = new CollisionDomain(collisionDetection) { BroadPhase = new DualPartition <CollisionObject> { Filter = _collisionObjectFilter }, }; }
/// <summary> /// Initializes a new instance of the <see cref="SceneCollisionObjectFilter"/> class. /// </summary> /// <param name="filter">The filter.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="filter"/> is <see langword="null"/>. /// </exception> public SceneCollisionObjectFilter(IPairFilter <SceneNode> filter) { if (filter == null) { throw new ArgumentNullException("filter"); } _filter = filter; _filter.Changed += OnChanged; }
/// <summary> /// Recursively gets all scene nodes and adds them to the specified collection in depth-first /// order. (Scene node filtering is applied, EmptyShapes are ignored.) /// </summary> /// <param name="node">The root node.</param> /// <param name="referenceNode">The reference node.</param> /// <param name="filter">The scene node filter.</param> /// <param name="list">The collection to which all scene nodes are added.</param> private static void GetSceneNodes(SceneNode node, SceneNode referenceNode, IPairFilter <SceneNode> filter, List <SceneNode> list) { if (node.IsEnabled) { if (!(node.Shape is EmptyShape) && filter.Filter(new Pair <SceneNode>(node, referenceNode))) { list.Add(node); } if (node.Children != null) { foreach (var child in node.Children) { GetSceneNodes(child, referenceNode, filter, list); } } } }