Emerging Technologies for Games Spatial Partitioning 2 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Emerging Technologies for Games Spatial Partitioning 2

Description:

To cull unseen partitions. Such visibility techniques also useful for AI entities ... When doing frustum culling. Removes hot-spot problem ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 18
Provided by: lauren80
Category:

less

Transcript and Presenter's Notes

Title: Emerging Technologies for Games Spatial Partitioning 2


1
Emerging Technologies for GamesSpatial
Partitioning 2
  • CO3303
  • Week 11-12

2
Contents
  • Introduction
  • Binary Space Partitioning
  • Quad-Trees / Oct-Trees
  • Other Partitioning Schemes
  • Rabin p456 onwards

3
Introduction / Recap
  • Dividing a game world into partitions has many
    uses
  • Have looked at PVS portal systems
  • To cull unseen partitions
  • Such visibility techniques also useful for AI
    entities
  • Here we introduce a range of tree-based
    partitions
  • BSP / Quad / Oct trees

4
Binary Space Partitioning
  • A Binary Space Partition (BSP) is a hierarchical
    division of space
  • A tree structure that represents the entire space
  • Partitions separated by
  • Lines in 2D
  • Planes in 3D
  • Recursively divide each partition into two
    smaller ones with a line / plane
  • Creates a binary tree

5
Creating a BSP
  • Repeatedly divide space in two
  • Stop when
  • Maximum of X elements in each partition (X 1
    here)
  • Partitions are small enough
  • Tree reaches certain depth
  • Choice depends on application

6
Locating a Point in a BSP
  • Given a point, easy to find which partition it is
    in
  • Start at root of tree
  • Find which side of the dividing line/plane the
    point is on
  • Follow appropriate edge
  • Repeat until find leaf partition
  • Example here
  • Check P against X
  • Not in A, follow other edge
  • Check P against Y
  • Not in B, follow other edge, etc.

7
Recap Which Side of a Plane?
  • A plane is defined by
  • A vertex on the plane P
  • A vector / normal N at right angles to the plane
  • To find which side of the plane a vertex A is on
  • d N PA N PA cos a
  • A will be on the side pointed at by the vector N
    if
  • N PA is a simple operation
  • Dont need to calculate a

8
BSP for Solid/Hollow Spaces
  • Can use the polygons in the scene as the division
    planes
  • Choose a polygon as a plane
  • All other polygons placed on one or other side of
    plane
  • Polygons crossing the planes are split
  • BSP splits space into hollow / solid volumes
  • All polygons / entities placed in hollow ones

9
BSP / Brush Modelling
  • This kind of BSP is often used for FPS games
  • First appeared in Doom (original version)
  • Often used in conjunction with a PVS
  • Can also be used to render partitions in a strict
    back to front order
  • Lends itself to a unique form of 3D modelling
    called brush modelling Rabin p690
  • Start with a entirely solid world
  • Cut out primitives (boxes, cylinders etc.)
  • Entities placed in hollowed out areas
  • Like "digging out" the level
  • See Counter-Strike, Unreal, Quake III editors

10
BSP Pros / Cons
  • BSP trees are well established technique
  • Used for rendering / collision / ray-tracing
  • Can be generated automatically
  • Fully classify space
  • Easy to find which partition a point is in
  • Need good algorithm to choose dividing planes
  • Try to balance tree
  • Hollow/solid BSP generates extra polygons due to
    splitting

11
Quadtrees / Octrees
  • Quadtrees and Octrees can be seen as specific
    kinds of BSP tree
  • A hierarchy / tree
  • Classifies all of space
  • Formed by recursive subdivision
  • Unlike a BSP the division scheme is very specific
  • Quadtrees are in 2D, octrees are in 3D
  • Otherwise the same

12
Creating a Quadtree
  • Root node is entire space
  • Usually square
  • Divide into four equal quadrants
  • These are the children nodes
  • Repeat with each quadrant
  • Until some condition is met
  • Maximum depth
  • An empty node
  • Only one entity contained
  • Etc. - application dependent

13
Location in a Quadtree
  • Simple to find which node a point is in
  • Start at root node
  • Find the quadrant the point is in
  • Just two comparisons
  • Repeat process on this quadrant
  • Can be optimised
  • Have world space as square
  • Power of 2 in size (e.g. 2048)
  • Centred on origin
  • Can use bitwise integer math
  • See Rabin

14
Quadtrees for Visibility Culling
  • Use for frustum culling
  • Traverse quadtree from root
  • Cull entire nodes outside frustum
  • Along with all entities and all child nodes in
    them
  • Reject many entities at once
  • Nodes are AABB
  • Viewing frustum is 6 planes
  • To test if a node is visible
  • Six AABB lt-gt plane tests
  • Several approaches, see

www.lighthouse3d.com/opengl/viewfrustum/index.php
15
Quadtree Problem
  • Problem
  • Entities arent points
  • May overlap a node boundary
  • In this case the entity needs to be in a larger
    parent node
  • E.g. Entity overlaps origin
  • Can fit in any node except root
  • Even a tiny entity
  • Lose possibility to cull
  • Hot-spots like this around the boundaries of
    larger nodes

16
Loose Quadtrees
  • Solution Loose Quadtrees
  • Have nodes overlap
  • Entities will then fit in original node area
  • Potentially with their bounding sphere
    overlapping adjacent nodes
  • Few changes to algorithms
  • Just increase node size
  • When inserting entities
  • When doing frustum culling
  • Removes hot-spot problem
  • At the expense of larger nodes at the same level

17
Quadtrees for Collision Detection
  • We saw intersection of viewing frustum with
    quadtree
  • Fairly easy to find intersection of other
    primitives
  • Spheres, cuboids, rays, capsules
  • Find the set of nodes intersected
  • And hence the set of entities that are candidates
    for collision
  • Basis for collision detection / ray casting /
    physics systems
  • Helps to add adjacency info to the tree
Write a Comment
User Comments (0)
About PowerShow.com