RigsofRods
Soft-body Physics Simulation
|
#include <Collisions.h>
Data Structures | |
struct | hash_coll_element_t |
Public Types | |
enum | SurfaceType { FX_NONE, FX_HARD, FX_DUSTY, FX_CLUMPY, FX_PARTICLE } |
typedef std::vector< collision_box_t > | CollisionBoxVec |
Public Member Functions | |
Collisions (Ogre::Vector3 terrn_size) | |
~Collisions () | |
Ogre::Vector3 | getPosition (const Ogre::String &inst, const Ogre::String &box) |
Ogre::Quaternion | getDirection (const Ogre::String &inst, const Ogre::String &box) |
collision_box_t * | getBox (const Ogre::String &inst, const Ogre::String &box) |
std::pair< bool, Ogre::Real > | intersectsTris (Ogre::Ray ray) |
float | getSurfaceHeight (float x, float z) |
float | getSurfaceHeightBelow (float x, float z, float height) |
bool | collisionCorrect (Ogre::Vector3 *refpos, bool envokeScriptCallbacks=true) |
bool | groundCollision (node_t *node, float dt) |
bool | isInside (Ogre::Vector3 pos, const Ogre::String &inst, const Ogre::String &box, float border=0) |
bool | isInside (Ogre::Vector3 pos, collision_box_t *cbox, float border=0) |
bool | nodeCollision (node_t *node, float dt) |
void | envokeScriptCallback (collision_box_t *cbox, node_t *node=0) |
void | findPotentialEventBoxes (Actor *actor, CollisionBoxPtrVec &out_boxes) |
void | finishLoadingTerrain () |
int | addCollisionBox (bool rotating, bool virt, Ogre::Vector3 pos, Ogre::Vector3 rot, Ogre::Vector3 l, Ogre::Vector3 h, Ogre::Vector3 sr, const Ogre::String &eventname, const Ogre::String &instancename, bool forcecam, Ogre::Vector3 campos, Ogre::Vector3 sc=Ogre::Vector3::UNIT_SCALE, Ogre::Vector3 dr=Ogre::Vector3::ZERO, CollisionEventFilter event_filter=EVENT_ALL, int scripthandler=-1) |
void | addCollisionMesh (Ogre::String const &srcname, Ogre::String const &meshname, Ogre::Vector3 const &pos, Ogre::Quaternion const &q, Ogre::Vector3 const &scale, ground_model_t *gm=0, std::vector< int > *collTris=0) |
generate collision tris from existing mesh resource More... | |
void | registerCollisionMesh (Ogre::String const &srcname, Ogre::String const &meshname, Ogre::Vector3 const &pos, Ogre::AxisAlignedBox bounding_box, ground_model_t *gm, int ctri_start, int ctri_count) |
Mark already generated collision tris as belonging to (virtual) mesh. More... | |
int | addCollisionTri (Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, ground_model_t *gm) |
void | createCollisionDebugVisualization (Ogre::SceneNode *root_node, Ogre::AxisAlignedBox const &area_limit, std::vector< Ogre::SceneNode * > &out_nodes) |
void | removeCollisionBox (int number) |
void | removeCollisionTri (int number) |
void | clearEventCache () |
Ogre::AxisAlignedBox | getCollisionAAB () |
int | loadDefaultModels () |
int | loadGroundModelsConfigFile (Ogre::String filename) |
std::map< Ogre::String, ground_model_t > * | getGroundModels () |
void | setupLandUse (const char *configfile) |
ground_model_t * | getGroundModelByString (const Ogre::String name) |
void | getMeshInformation (Ogre::Mesh *mesh, size_t &vertex_count, Ogre::Vector3 *&vertices, size_t &index_count, unsigned *&indices, const Ogre::Vector3 &position=Ogre::Vector3::ZERO, const Ogre::Quaternion &orient=Ogre::Quaternion::IDENTITY, const Ogre::Vector3 &scale=Ogre::Vector3::UNIT_SCALE) |
eventsource_t & | getEventSource (int pos) |
CollisionBoxVec const & | getCollisionBoxes () const |
CollisionMeshVec const & | getCollisionMeshes () const |
CollisionTriVec const & | getCollisionTriangles () const |
Data Fields | |
bool | forcecam |
Ogre::Vector3 | forcecampos |
ground_model_t * | defaultgm |
ground_model_t * | defaultgroundgm |
Static Public Attributes | |
static const int | CELL_BLOCKSIZE = 126 |
Private Member Functions | |
bool | permitEvent (Actor *actor, CollisionEventFilter filter) |
void | hash_add (int cell_x, int cell_z, int value, float h) |
int | hash_find (int cell_x, int cell_z) |
unsigned int | hashfunc (unsigned int cellid) |
Returns index to 'hashtable'. More... | |
void | parseGroundConfig (Ogre::ConfigFile *cfg, Ogre::String groundModel="") |
Ogre::Vector3 | calcCollidedSide (const Ogre::Vector3 &pos, const Ogre::Vector3 &lo, const Ogre::Vector3 &hi) |
Private Attributes | |
CollisionBoxVec | m_collision_boxes |
std::vector< collision_box_t * > | m_last_called_cboxes |
CollisionTriVec | m_collision_tris |
CollisionMeshVec | m_collision_meshes |
Ogre::AxisAlignedBox | m_collision_aab |
std::array< float, HASH_SIZE > | hashtable_height |
std::vector< hash_coll_element_t > | hashtable [HASH_SIZE] |
std::map< Ogre::String, ground_model_t > | ground_models |
eventsource_t | eventsources [MAX_EVENT_SOURCE] |
int | free_eventsource |
Landusemap * | landuse |
int | collision_version |
unsigned int | hashmask |
const Ogre::Vector3 | m_terrain_size |
Static Private Attributes | |
static const int | LATEST_GROUND_MODEL_VERSION = 3 |
static const int | MAX_EVENT_SOURCE = 500 |
static const int | HASH_POWER = 20 |
static const int | HASH_SIZE = 1 << HASH_POWER |
static const int | CELL_SIZE = 2.0 |
static const int | MAXIMUM_CELL = 0x7FFF |
Definition at line 80 of file Collisions.h.
typedef std::vector<collision_box_t> RoR::Collisions::CollisionBoxVec |
Definition at line 84 of file Collisions.h.
Enumerator | |
---|---|
FX_NONE | |
FX_HARD | |
FX_DUSTY | |
FX_CLUMPY | |
FX_PARTICLE |
Definition at line 86 of file Collisions.h.
Collisions::Collisions | ( | Ogre::Vector3 | terrn_size | ) |
Collisions::~Collisions | ( | ) |
Definition at line 140 of file Collisions.cpp.
int Collisions::addCollisionBox | ( | bool | rotating, |
bool | virt, | ||
Ogre::Vector3 | pos, | ||
Ogre::Vector3 | rot, | ||
Ogre::Vector3 | l, | ||
Ogre::Vector3 | h, | ||
Ogre::Vector3 | sr, | ||
const Ogre::String & | eventname, | ||
const Ogre::String & | instancename, | ||
bool | forcecam, | ||
Ogre::Vector3 | campos, | ||
Ogre::Vector3 | sc = Ogre::Vector3::UNIT_SCALE , |
||
Ogre::Vector3 | dr = Ogre::Vector3::ZERO , |
||
CollisionEventFilter | event_filter = EVENT_ALL , |
||
int | scripthandler = -1 |
||
) |
Definition at line 401 of file Collisions.cpp.
void Collisions::addCollisionMesh | ( | Ogre::String const & | srcname, |
Ogre::String const & | meshname, | ||
Ogre::Vector3 const & | pos, | ||
Ogre::Quaternion const & | q, | ||
Ogre::Vector3 const & | scale, | ||
ground_model_t * | gm = 0 , |
||
std::vector< int > * | collTris = 0 |
||
) |
generate collision tris from existing mesh resource
Definition at line 1408 of file Collisions.cpp.
int Collisions::addCollisionTri | ( | Ogre::Vector3 | p1, |
Ogre::Vector3 | p2, | ||
Ogre::Vector3 | p3, | ||
ground_model_t * | gm | ||
) |
Definition at line 551 of file Collisions.cpp.
|
private |
|
inline |
bool Collisions::collisionCorrect | ( | Ogre::Vector3 * | refpos, |
bool | envokeScriptCallbacks = true |
||
) |
Definition at line 766 of file Collisions.cpp.
void Collisions::createCollisionDebugVisualization | ( | Ogre::SceneNode * | root_node, |
Ogre::AxisAlignedBox const & | area_limit, | ||
std::vector< Ogre::SceneNode * > & | out_nodes | ||
) |
Definition at line 1314 of file Collisions.cpp.
void Collisions::envokeScriptCallback | ( | collision_box_t * | cbox, |
node_t * | node = 0 |
||
) |
Definition at line 602 of file Collisions.cpp.
void Collisions::findPotentialEventBoxes | ( | Actor * | actor, |
CollisionBoxPtrVec & | out_boxes | ||
) |
Definition at line 1088 of file Collisions.cpp.
void Collisions::finishLoadingTerrain | ( | ) |
Definition at line 1585 of file Collisions.cpp.
collision_box_t * Collisions::getBox | ( | const Ogre::String & | inst, |
const Ogre::String & | box | ||
) |
|
inline |
Definition at line 203 of file Collisions.h.
|
inline |
Definition at line 218 of file Collisions.h.
|
inline |
Definition at line 219 of file Collisions.h.
|
inline |
Quaternion Collisions::getDirection | ( | const Ogre::String & | inst, |
const Ogre::String & | box | ||
) |
|
inline |
ground_model_t * Collisions::getGroundModelByString | ( | const Ogre::String | name | ) |
|
inline |
void Collisions::getMeshInformation | ( | Ogre::Mesh * | mesh, |
size_t & | vertex_count, | ||
Ogre::Vector3 *& | vertices, | ||
size_t & | index_count, | ||
unsigned *& | indices, | ||
const Ogre::Vector3 & | position = Ogre::Vector3::ZERO , |
||
const Ogre::Quaternion & | orient = Ogre::Quaternion::IDENTITY , |
||
const Ogre::Vector3 & | scale = Ogre::Vector3::UNIT_SCALE |
||
) |
Vector3 Collisions::getPosition | ( | const Ogre::String & | inst, |
const Ogre::String & | box | ||
) |
float Collisions::getSurfaceHeight | ( | float | x, |
float | z | ||
) |
Definition at line 671 of file Collisions.cpp.
float Collisions::getSurfaceHeightBelow | ( | float | x, |
float | z, | ||
float | height | ||
) |
Definition at line 676 of file Collisions.cpp.
bool Collisions::groundCollision | ( | node_t * | node, |
float | dt | ||
) |
Definition at line 1212 of file Collisions.cpp.
|
private |
Definition at line 384 of file Collisions.cpp.
|
private |
Definition at line 393 of file Collisions.cpp.
|
private |
Returns index to 'hashtable'.
Definition at line 373 of file Collisions.cpp.
std::pair< bool, Ogre::Real > Collisions::intersectsTris | ( | Ogre::Ray | ray | ) |
Definition at line 628 of file Collisions.cpp.
bool Collisions::isInside | ( | Ogre::Vector3 | pos, |
collision_box_t * | cbox, | ||
float | border = 0 |
||
) |
Definition at line 1176 of file Collisions.cpp.
bool Collisions::isInside | ( | Ogre::Vector3 | pos, |
const Ogre::String & | inst, | ||
const Ogre::String & | box, | ||
float | border = 0 |
||
) |
Definition at line 1169 of file Collisions.cpp.
int Collisions::loadDefaultModels | ( | ) |
Definition at line 145 of file Collisions.cpp.
int Collisions::loadGroundModelsConfigFile | ( | Ogre::String | filename | ) |
Definition at line 150 of file Collisions.cpp.
bool Collisions::nodeCollision | ( | node_t * | node, |
float | dt | ||
) |
Definition at line 926 of file Collisions.cpp.
|
private |
|
private |
void Collisions::registerCollisionMesh | ( | Ogre::String const & | srcname, |
Ogre::String const & | meshname, | ||
Ogre::Vector3 const & | pos, | ||
Ogre::AxisAlignedBox | bounding_box, | ||
ground_model_t * | gm, | ||
int | ctri_start, | ||
int | ctri_count | ||
) |
Mark already generated collision tris as belonging to (virtual) mesh.
Definition at line 1455 of file Collisions.cpp.
void Collisions::removeCollisionBox | ( | int | number | ) |
void Collisions::removeCollisionTri | ( | int | number | ) |
void Collisions::setupLandUse | ( | const char * | configfile | ) |
Definition at line 333 of file Collisions.cpp.
|
static |
Definition at line 170 of file Collisions.h.
|
staticprivate |
Definition at line 128 of file Collisions.h.
|
private |
Definition at line 155 of file Collisions.h.
ground_model_t* RoR::Collisions::defaultgm |
Definition at line 174 of file Collisions.h.
ground_model_t * RoR::Collisions::defaultgroundgm |
Definition at line 174 of file Collisions.h.
|
private |
Definition at line 149 of file Collisions.h.
bool RoR::Collisions::forcecam |
Definition at line 172 of file Collisions.h.
Ogre::Vector3 RoR::Collisions::forcecampos |
Definition at line 173 of file Collisions.h.
|
private |
Definition at line 150 of file Collisions.h.
|
private |
Definition at line 146 of file Collisions.h.
|
staticprivate |
Definition at line 124 of file Collisions.h.
|
staticprivate |
Definition at line 125 of file Collisions.h.
|
private |
Definition at line 156 of file Collisions.h.
|
private |
Definition at line 143 of file Collisions.h.
|
private |
Definition at line 142 of file Collisions.h.
|
private |
Definition at line 154 of file Collisions.h.
|
staticprivate |
Definition at line 120 of file Collisions.h.
|
private |
Definition at line 139 of file Collisions.h.
|
private |
Definition at line 132 of file Collisions.h.
|
private |
Definition at line 137 of file Collisions.h.
|
private |
Definition at line 136 of file Collisions.h.
|
private |
Definition at line 133 of file Collisions.h.
|
private |
Definition at line 158 of file Collisions.h.
|
staticprivate |
Definition at line 121 of file Collisions.h.
|
staticprivate |
Definition at line 129 of file Collisions.h.