private void PerformCollisionChecks() { for (int i = 0; i < _collidables.Count; i++) { var current = _collidables[i]; // TODO: currently we only compare against static collidables using the quadtree, if dynamic collision checks are required we will need something better than a list here var collisionTargets = _tree.GetIntersectingElements(current.BoundingBox); foreach (var ct in collisionTargets) { if (ct.Collides(current)) { // we have a collision current.CollisionResponse(ct); ct.CollisionResponse(current); } } } }
public void Render(IRenderContext renderContext, GameTime dt) { var cam = renderContext.RenderContext3D.Camera; var frustum = new BoundingFrustum(cam.View * cam.Projection); var visible = _quadtree.GetIntersectingElements(frustum); int vertices = 0; int visibleChunks = 0; foreach (var chunk in visible) { chunk.Render(renderContext, dt); visibleChunks++; vertices += chunk.Vertices; } _messageBuilder.AppendLine($"Total Vertices: {_totalVertices}"); _messageBuilder.AppendLine($"Visible Vertices: {vertices}"); _messageBuilder.AppendLine($"Total chunks: {_totalChunks}"); _messageBuilder.AppendLine($"Visible chunks: {visibleChunks}"); }