Cafu Engine
cf::ClipSys::CollisionModelStaticT Class Reference

This class represents a static collision model. More...

#include "CollisionModel_static.hpp"

Inheritance diagram for cf::ClipSys::CollisionModelStaticT:

Classes

class  BrushT
 This class describes a brush (convex polyhedron) within a CollisionModelStaticT collision shape. More...
 
class  BulletAdapterT
 This class provides an adapter for CollisionModelStaticT instances to be used as btConcaveShape instances. More...
 
class  InternalTraceSolidT
 This representation of a TraceSolidT is used in the implementation of CollisionModelStaticT as a performance optimization, allowing it to shortcut the frequent and expensive access to the TraceSolidT's virtual methods. More...
 
class  NodeT
 
class  PolygonT
 
class  TerrainRefT
 
class  TraceParamsT
 

Public Member Functions

 CollisionModelStaticT (std::istream &InFile, cf::SceneGraph::aux::PoolT &Pool, const ArrayT< TerrainRefT > &Terrains)
 Constructor for creating a collision model by loading it from a file. More...
 
 CollisionModelStaticT (const MapFileEntityT &Entity, const ArrayT< TerrainRefT > &Terrains, bool UseGenericBrushes, const double MAP_ROUND_EPSILON, const double MAP_MIN_VERTEX_DIST, const double BP_MAX_CURVE_ERROR, const double BP_MAX_CURVE_LENGTH, const double MIN_NODE_SIZE)
 Constructor for creating a collision model from the brushes and patches of a MapFileEntityT. More...
 
 CollisionModelStaticT (unsigned long Width, unsigned long Height, const ArrayT< Vector3dT > &Mesh, MaterialT *Material, const double MIN_NODE_SIZE)
 Constructor for creating a collision model from a regular mesh. More...
 
 ~CollisionModelStaticT ()
 The destructor. More...
 
BoundingBox3dT GetBoundingBox () const override
 Returns the bounding box of this collision model. More...
 
unsigned long GetContents () const override
 Returns the contents of this collision model. More...
 
void SaveToFile (std::ostream &OutFile, SceneGraph::aux::PoolT &Pool) const override
 Saves the model to OutFile. More...
 
void TraceConvexSolid (const TraceSolidT &TraceSolid, const Vector3dT &Start, const Vector3dT &Ray, unsigned long ClipMask, TraceResultT &Result) const override
 Traces the given TraceSolidT instance from Start along Ray (up to the input value of Result.Fraction) through the collision model, and reports the first collision, if any. More...
 
unsigned long GetContents (const Vector3dT &Point, double BoxRadius, unsigned long ContMask) const override
 Determines the volume contents of the model at the given point / in the given box. More...
 
btCollisionShape * GetBulletAdapter () const override
 Returns an adapter class for using CollisionModelT instances also as Bullet btCollisionShape instances. More...
 
- Public Member Functions inherited from cf::ClipSys::CollisionModelT
virtual ~CollisionModelT ()
 The (virtual) destructor. More...
 

Detailed Description

This class represents a static collision model.

Constructor & Destructor Documentation

CollisionModelStaticT::CollisionModelStaticT ( std::istream &  InFile,
cf::SceneGraph::aux::PoolT Pool,
const ArrayT< TerrainRefT > &  Terrains 
)

Constructor for creating a collision model by loading it from a file.

TODO 1: Name should probably be a part of the InFile data...? TODO 2: Review serialization/deser. of class hierarchies (e.g. compare to cf::SceneGraph)! Right now this is fixed and works for CollisionModelStaticTs only!!!

CollisionModelStaticT::CollisionModelStaticT ( const MapFileEntityT Entity,
const ArrayT< TerrainRefT > &  Terrains,
bool  UseGenericBrushes,
const double  MAP_ROUND_EPSILON,
const double  MAP_MIN_VERTEX_DIST,
const double  BP_MAX_CURVE_ERROR,
const double  BP_MAX_CURVE_LENGTH,
const double  MIN_NODE_SIZE 
)

Constructor for creating a collision model from the brushes and patches of a MapFileEntityT.

Parameters
EntityThe entity to create the collision model from.
TerrainsThe pool of references to shared terrain instances.
UseGenericBrushesWhether generic brushes should be used, or variants with precomputed bevel planes. When false, internally the same code that has been used in the Cafu engine for years (in the cf::SceneGraph::BspTreeNodeT class) is used, and is thus very fast, rock solid and battle proven. It also means that internally, only bounding-boxes (but not the true TraceSolidT objects) are traced against such created brushes with the BrushT::TraceBevelBB() method.
MAP_ROUND_EPSILONThe epsilon value used in roundoff error checks.
MAP_MIN_VERTEX_DISTThe minimum distance between two vertices.
BP_MAX_CURVE_ERRORThe maximum deviation of a segment against its true shape in an auto-segmented curve.
BP_MAX_CURVE_LENGTHThe maximum length of a segment in an auto-segmented curve.
MIN_NODE_SIZEThe minimum size (side length) that a node should not fall below.
CollisionModelStaticT::CollisionModelStaticT ( unsigned long  Width,
unsigned long  Height,
const ArrayT< Vector3dT > &  Mesh,
MaterialT Material,
const double  MIN_NODE_SIZE 
)

Constructor for creating a collision model from a regular mesh.

CollisionModelStaticT::~CollisionModelStaticT ( )

The destructor.

Member Function Documentation

BoundingBox3dT CollisionModelStaticT::GetBoundingBox ( ) const
overridevirtual

Returns the bounding box of this collision model.

Implements cf::ClipSys::CollisionModelT.

btCollisionShape * CollisionModelStaticT::GetBulletAdapter ( ) const
overridevirtual

Returns an adapter class for using CollisionModelT instances also as Bullet btCollisionShape instances.

Implements cf::ClipSys::CollisionModelT.

unsigned long CollisionModelStaticT::GetContents ( ) const
overridevirtual

Returns the contents of this collision model.

Implements cf::ClipSys::CollisionModelT.

unsigned long CollisionModelStaticT::GetContents ( const Vector3dT Point,
double  BoxRadius,
unsigned long  ContMask 
) const
overridevirtual

Determines the volume contents of the model at the given point / in the given box.

The function considers all brush volumes in the collision model that contain the given point or intersect the given box, and returns their combined ("or'ed") contents.

Parameters
PointThe point in model space at which the volume contents of this model is to be determined.
BoxRadiusWhen nonzero, this is the radius of an imaginary box around Point.
ContMaskOnly volumes whose contents matches this mask participate in the test. This is for optimization, because it allows the implementation to cull volumes that are not of interest early.
Returns
the combined volume content flags of the intersected volumes in the collision model.

Implements cf::ClipSys::CollisionModelT.

void CollisionModelStaticT::SaveToFile ( std::ostream &  OutFile,
SceneGraph::aux::PoolT Pool 
) const
overridevirtual

Saves the model to OutFile.

TODO: Review serialization/deser. of class hierarchies (e.g. compare to cf::SceneGraph)! Right now this is fixed and works for CollisionModelStaticTs only!!!

Implements cf::ClipSys::CollisionModelT.

void CollisionModelStaticT::TraceConvexSolid ( const TraceSolidT TraceSolid,
const Vector3dT Start,
const Vector3dT Ray,
unsigned long  ClipMask,
TraceResultT Result 
) const
overridevirtual

Traces the given TraceSolidT instance from Start along Ray (up to the input value of Result.Fraction) through the collision model, and reports the first collision, if any.

Parameters
TraceSolidThe TraceSolidT instance that is traced from Start along Ray.
StartThe start point in model space where the trace begins.
RayThe ray along which the trace is performed. Note that with F being the input value of Result.Fraction, the endpoint is at Start+Ray*F.
ClipMaskOnly surfaces whose clip flags match this mask participate in the test. This is for optimization, because it allows the implementation to cull surfaces that are not of interest early.
ResultThe start value of Fraction is input via this reference, and the result of the trace returned. Using an input/output parameter for returning the result, rather than a true return type, suggests itself because it makes cascaded calls to this function natural (i.e. from (possibly many) super-objects and to (possibly many) sub-objects).
See Also
TraceResultT

Implements cf::ClipSys::CollisionModelT.


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