Drag[en]gine Game Engine  1.0
decCollisionFilter Class Reference

Defines a collision filter using layer masks. More...

#include <decCollisionFilter.h>

Public Member Functions

Constructors and Destructors
 decCollisionFilter ()
 Creates a new collision filter. More...
 
 decCollisionFilter (const decLayerMask &mask)
 Creates a new collision filter with category and filter set to the same mask. More...
 
 decCollisionFilter (const decLayerMask &category, const decLayerMask &filter)
 Creates a new collision filter from a set of layer masks. More...
 
 decCollisionFilter (const decCollisionFilter &other)
 Creates a copy of a collision filter. More...
 
 ~decCollisionFilter ()
 Cleans up the collision filter. More...
 
Management
decLayerMaskGetCategory ()
 Retrieves the category layer mask. More...
 
const decLayerMaskGetCategory () const
 
decLayerMaskGetFilter ()
 Retrieves the filter layer mask. More...
 
const decLayerMaskGetFilter () const
 
bool Collides (const decCollisionFilter &other) const
 Determines if two collision filters can collide. More...
 
bool CollidesNot (const decCollisionFilter &other) const
 Determines if two collision filters can not collide. More...
 
bool CanCollide () const
 Determines if the collision filters can collide with another collision filter. More...
 
bool CanNotCollide () const
 Determines if the collision filters can never collide with another collision filter. More...
 
Operators
bool operator== (const decCollisionFilter &other) const
 Determines if collision filters are equal. More...
 
bool operator!= (const decCollisionFilter &other) const
 Determines if collision filters are not equal. More...
 
decCollisionFilteroperator= (const decCollisionFilter &other)
 Sets this collision filter from another one. More...
 

Detailed Description

Defines a collision filter using layer masks.

Composes of a category and filter layer mask. Category is usually a single bit and the filter one or more bits. In special cases this can be different. Two collision filters collide with each other if A.category.Matches(B.filter) and B.category.Matches(A.filter). For simple layer mask matching without filtering set both category and filter to the same value. Otherwise category is usually set to the object category and the filter to all categories the object is allowed to collide with.

Author
Pl├╝ss Roland
Version
1.0
Date
2015

Constructor & Destructor Documentation

◆ decCollisionFilter() [1/4]

decCollisionFilter::decCollisionFilter ( )

Creates a new collision filter.

Category is set empty and filter set filled.

◆ decCollisionFilter() [2/4]

decCollisionFilter::decCollisionFilter ( const decLayerMask mask)

Creates a new collision filter with category and filter set to the same mask.

◆ decCollisionFilter() [3/4]

decCollisionFilter::decCollisionFilter ( const decLayerMask category,
const decLayerMask filter 
)

Creates a new collision filter from a set of layer masks.

◆ decCollisionFilter() [4/4]

decCollisionFilter::decCollisionFilter ( const decCollisionFilter other)

Creates a copy of a collision filter.

◆ ~decCollisionFilter()

decCollisionFilter::~decCollisionFilter ( )

Cleans up the collision filter.

Member Function Documentation

◆ CanCollide()

bool decCollisionFilter::CanCollide ( ) const

Determines if the collision filters can collide with another collision filter.

Returns true if the both the category and filter layer mask are not empty. Can be used to test if collision calculations are required for the collision filter.

Referenced by GetFilter().

◆ CanNotCollide()

bool decCollisionFilter::CanNotCollide ( ) const

Determines if the collision filters can never collide with another collision filter.

Returns true if the category and/or the filter is empty. Can be used to avoid collision calculations if a collision filter has no chance to ever collide.

Referenced by GetFilter().

◆ Collides()

bool decCollisionFilter::Collides ( const decCollisionFilter other) const

Determines if two collision filters can collide.

Tests if for both collision filters the category matches the other filter. Hence the result is this.filter.Matches(other.category) and other.filter.Matches(this.category).

Referenced by GetFilter().

◆ CollidesNot()

bool decCollisionFilter::CollidesNot ( const decCollisionFilter other) const

Determines if two collision filters can not collide.

Tests if for any of both collision filters the category matches not the other filter. Hence the result is this.filter.MatchesNot(other.category) or other.filter.MatchesNot(this.category).

Referenced by GetFilter().

◆ GetCategory() [1/2]

decLayerMask& decCollisionFilter::GetCategory ( )
inline

Retrieves the category layer mask.

◆ GetCategory() [2/2]

const decLayerMask& decCollisionFilter::GetCategory ( ) const
inline

◆ GetFilter() [1/2]

decLayerMask& decCollisionFilter::GetFilter ( )
inline

Retrieves the filter layer mask.

◆ GetFilter() [2/2]

const decLayerMask& decCollisionFilter::GetFilter ( ) const
inline

◆ operator!=()

bool decCollisionFilter::operator!= ( const decCollisionFilter other) const

Determines if collision filters are not equal.

Referenced by GetFilter().

◆ operator=()

decCollisionFilter& decCollisionFilter::operator= ( const decCollisionFilter other)

Sets this collision filter from another one.

Referenced by GetFilter().

◆ operator==()

bool decCollisionFilter::operator== ( const decCollisionFilter other) const

Determines if collision filters are equal.

Referenced by GetFilter().


The documentation for this class was generated from the following file: