ScopeTracker

Engine/source/util/scopeTracker.h

Helper class to track the position of a point in N-dimensional space relative to a collection of N-dimensional volumes.

More...

Scoping

_setScope(Object object)

Set the scoping state of the given object.

Tracking

Protected Types

enum
_Anonymous_ {
  MIN = 0
  MAX = 1
}

Public Types

ObjectType::TrackingNode
NodeType 
TypeTraits< Object >::BaseType
ObjectType 
Parent 

Protected Attributes

mBoundaryNodes [NUM_DIMENSIONS][2]

The reference object.

mTrackingList [NUM_DIMENSIONS][2]

Public Functions

Add a volume object to the world.

Remove a volume object from the world.

Update the position of the object in the world.

Detailed Description

Helper class to track the position of a point in N-dimensional space relative to a collection of N-dimensional volumes.

This class works by breaking the N-dimensional case down into N one-dimensional cases. By tracking objects independently along each of their axes, intersection testing becomes a trivial matter of doing point-on-line tests. The line segments can be conveniently represented as ordered linked lists along which the reference point is being moved.

To determine N-dimensional containment of the reference point, the result of each of the one-dimensional point-on-line tests simply has to be combined. If the point lies on each of N 1D segments of a given volume, then the point is fully contained in the volume.

This class may be used in places where otherwise a spatial subdivision scheme would be necessary in order to limit the number of containment tests triggered by each movement of the reference point. Once the tracker has been set up, each position change of an object or the reference center will result in a usually small number of incremental list updates.

Another advantage is that this class makes it easy to reduce 3D tracking to 2D tracking if tracking on the height axis isn't important.

The following interface must be implemented by the given "Object" type:

struct Object : public ScopeTrackerObject< NUM_DIMENSIONS >
{
   /// Return the position of the object in world-space.
   void getPosition( F32 pos[ NUM_DIMENSIONS ] ) const;

   /// If this object is the reference object, this method should return the world-space pivot
   /// point in the object that will be the world reference center.
   void getReferenceCenter( F32 pos[ NUM_DIMENSIONS ] ) const;

   /// Return the object's bounding box in world-space.
   void getBounds( F32 minBounds[ NUM_DIMENSIONS ], F32 maxBounds[ NUM_DIMENSIONS ] ) const;
};

Terminology:

  • "In Scope": A volume is in scope if it fully contains the reference center.

  • "Reference Object": Object that is the designated center of the world.

Parameters:

NUM_DIMENSIONS

Number of dimensions to track; must be <=4.

Object

Value type for objects tracked by the ScopeTracker. Must have pointer behavior.

Scoping

_onScopeIn(Object object)

Reimplemented by: SFXWorld

_onScopeOut(Object object)

Reimplemented by: SFXWorld

_setScope(Object object)

Set the scoping state of the given object.

Tracking

_insertTrackingNode(U32 dimension, NodeType * node)

_removeTrackingNode(U32 dimension, NodeType * node)

_moveTrackingNode(U32 dimension, NodeType * node, F32 newPos)

_initTracking()

_uninitTracking()

Protected Types

@218

Enumerator

MIN = 0
MAX = 1

Public Types

typedef ObjectType::TrackingNode NodeType 
typedef TypeTraits< Object >::BaseType ObjectType 
typedef void Parent 

Protected Attributes

NodeType mBoundaryNodes [NUM_DIMENSIONS][2]
Vector< Object > mPotentialScopeInObjects 
Object mReferenceObject 

The reference object.

This is the center relative to which all tracking occurs. Any other object is in scope when it contains the reference object.

NodeType * mTrackingList [NUM_DIMENSIONS][2]

Public Functions

ScopeTracker()

debugDump()

getReferenceObject()

registerObject(Object object)

Add a volume object to the world.

setReferenceObject(Object object)

note:

Switching reference centers is potentially costly.

unregisterObject(Object object)

Remove a volume object from the world.

updateObject(Object object)

Update the position of the object in the world.