Crystal Space: iCollideSystem Struct Reference (Crystal Space Public API Reference)

| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iCollideSystem Struct Reference

This is the Collide plug-in. More...

`#include <ivaria/collider.h>`

Inheritance diagram for iCollideSystem:

[legend]
List of all members.

## Public Member Functions
virtual bool | Collide (iCollider *collider1, const csReversibleTransform *trans1, iCollider *collider2, const csReversibleTransform *trans2)=0
| Test collision between two colliders.
virtual bool | CollideRay (iCollider *collider, const csReversibleTransform *trans, const csVector3 &start, const csVector3 &end)=0
| Collide a collider with a world space ray.
virtual bool | CollideSegment (iCollider *collider, const csReversibleTransform *trans, const csVector3 &start, const csVector3 &end)=0
| Collide a collider with a world space segment.
virtual csPtr< iCollider > | CreateCollider (iTerraFormer *mesh)=0
| Create a Collider from a terrain.
virtual csPtr< iCollider > | CreateCollider (iPolygonMesh *mesh)=0
| Create a iCollider for the given mesh geometry.
virtual size_t | GetCollisionPairCount ()=0
| Get number of collision pairs in array.
virtual csCollisionPair * | GetCollisionPairs ()=0
| Get pointer to current array of collision pairs.
virtual const csArray< csIntersectingTriangle > & | GetIntersectingTriangles () const =0
| Get the array of intersection points as returned by CollideRay().
virtual bool | GetOneHitOnly ()=0
| Return true if this CD system will only return the first hit that is found.
virtual void | ResetCollisionPairs ()=0
| Reset the array with collision pairs.
virtual void | SetOneHitOnly (bool o)=0
| Indicate if we are interested only in the first hit that is found.

## Detailed Description

This is the Collide plug-in.

This plugin is a factory for creating iCollider entities. A collider represents an entity in the collision detection world. It uses the geometry data as given by iPolygonMesh.

Main creators of instances implementing this interface:

- OPCODE plugin (crystalspace.collisiondetection.opcode)

Main ways to get pointers to this interface:

- csQueryRegistry()

Main users of this interface:

- csColliderWrapper
- csColliderHelper

Definition at line 103 of file collider.h.

## Member Function Documentation

virtual bool iCollideSystem::Collide | ( | iCollider * | collider1,
|  | const csReversibleTransform * | trans1,
|  | iCollider * | collider2,
|  | const csReversibleTransform * | trans2 |
| ) |  |  | `[pure virtual]`

Test collision between two colliders.

This is only supported for iCollider objects created by this plugin. Returns false if no collision or else true. The collisions will be added to the collision pair array that you can query with GetCollisionPairs and reset/clear with ResetCollisionPairs (very important! Do not forget this). Every call to Collide will add to that array.

Parameters:

  | collider1 | is the first collider as created by this same collide system (never pass in a collider created by another collide system).
  | trans1 | is the transform for the object represented by the first collider. If the collider belongs to a mesh object then you can get the transform by calling mesh->GetMovable ()->GetFullTransform().
  | collider2 | is the second collider.
  | trans2 | is the second transform.

Returns:
  true if there are triangles that intersect. The array with collision pairs will be updated.

virtual bool iCollideSystem::CollideRay | ( | iCollider * | collider,
|  | const csReversibleTransform * | trans,
|  | const csVector3 & | start,
|  | const csVector3 & | end |
| ) |  |  | `[pure virtual]`

Collide a collider with a world space ray.

Parameters:

  | collider | is the collider to test with.
  | trans | is the transform for the object represented by the collider. If the collider belongs to a mesh object then you can get the transform by calling mesh->GetMovable()->GetFullTransform().
  | start | is the start of the ray.
  | end | is the end of the ray.

Returns:
  true if there was a collision. The array with intersecting triangles will be updated (see GetIntersectingTriangles()).

virtual bool iCollideSystem::CollideSegment | ( | iCollider * | collider,
|  | const csReversibleTransform * | trans,
|  | const csVector3 & | start,
|  | const csVector3 & | end |
| ) |  |  | `[pure virtual]`

Collide a collider with a world space segment.

This will not return collisions with triangles behind the end of the segment.

Parameters:

  | collider | is the collider to test with.
  | trans | is the transform for the object represented by the collider. If the collider belongs to a mesh object then you can get the transform by calling mesh->GetMovable()->GetFullTransform().
  | start | is the start of the ray.
  | end | is the end of the ray.

Returns:
  true if there was a collision. The array with intersecting triangles will be updated (see GetIntersectingTriangles()).

virtual csPtr<iCollider> iCollideSystem::CreateCollider | ( | iTerraFormer * | mesh | ) | `[pure virtual]`

Create a Collider from a terrain.

This should be used instead of the iPolygonMesh version in case you have a landscape because this is a more optimal way to do.

virtual csPtr<iCollider> iCollideSystem::CreateCollider | ( | iPolygonMesh * | mesh | ) | `[pure virtual]`

Create a iCollider for the given mesh geometry.

Parameters:

  | mesh | is a structure describing the geometry from which the collider will be made. You can get such a mesh either by making your own subclass of iPolygonMesh, by getting a mesh from iMeshObject->GetObjectModel()->GetPolygonMeshColldet(), or else by using csPolygonMesh, or csPolygonMeshBox.

Returns:
  a reference to a collider that you have to store.

virtual size_t iCollideSystem::GetCollisionPairCount | ( |  | ) | `[pure virtual]`

Get number of collision pairs in array.

Returns:
  the number of collision pairs.

virtual csCollisionPair* iCollideSystem::GetCollisionPairs | ( |  | ) | `[pure virtual]`

Get pointer to current array of collision pairs.

This array will grow with every call to Collide until you clear it using 'ResetCollisionPairs'. Note that the triangles are in object space and not world space!

Returns:
  an array of collision pairs for all Collide() calls that occured between now and the call to ResetCollisionPairs().

virtual const csArray<csIntersectingTriangle>& iCollideSystem::GetIntersectingTriangles | ( |  | ) | const`[pure virtual]`

Get the array of intersection points as returned by CollideRay().

Note that the coordinates in the array of triangles is in object space of the collider object and not world space!

virtual bool iCollideSystem::GetOneHitOnly | ( |  | ) | `[pure virtual]`

Return true if this CD system will only return the first hit that is found.

For CD systems that support multiple hits this will return the value set by the SetOneHitOnly() function. For CD systems that support one hit only this will always return true.

Returns:
  true if there is only one hit recorder for every call to Collide().

virtual void iCollideSystem::ResetCollisionPairs | ( |  | ) | `[pure virtual]`

Reset the array with collision pairs.

It is very important to call this before collision detection. Otherwise the internal table of collision pairs will grow forever.

virtual void iCollideSystem::SetOneHitOnly | ( | bool | o | ) | `[pure virtual]`

Indicate if we are interested only in the first hit that is found.

This is only valid for CD algorithms that actually allow the detection of multiple CD hit points.

Parameters:

  | o | is true if you are only interested in one colliding triangle per call to Collide. By default this is 'false' unless the CD system only supports single hits.

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

- ivaria/collider.h