Kigs Framework
Doc version 0.8
Open source multi purpose Rapid Application Development framework
|
#include <CollisionManager.h>
Classes | |
class | MeshCollisionInfo |
Public Member Functions | |
bool | GetRayIntersection (Hit &hit, const Point3D &start, const Vector3D &dir, unsigned int a_itemCategory=ALL, bool ignore_is_collidable=false) |
intersect a ray with all objects in the collision manager More... | |
void | GetAllRayIntersection (const Point3D &start, const Vector3D &dir, std::vector< Hit > &hits, unsigned int a_itemCategory=ALL, bool ignore_is_collidable=false) |
intersect a ray with all objects in the collision manager More... | |
void | GetPlaneIntersection (const Point3D &o, const Vector3D &n, PlaneIntersectionInfoStruct &result, unsigned int a_itemCategory=ALL, const BBox *Zone=nullptr) |
intersect a plane with all (triangles) objects in the collision manager More... | |
CoreModifiable * | GetSphereIntersection (const Point3D &start, const Vector3D &dir, const kfloat Radius, kdouble &Distance, Vector3D &normal, Point3D &intersectP, unsigned int a_itemCategory=ALL) |
intersect a sphere with all objects in the collision manager More... | |
bool | GetAltitude (kfloat x, kfloat y, kfloat z, kfloat &alt) |
return altitude for the current point More... | |
void | setCollisionCategories (CoreModifiable *a_Item, unsigned int a_Category=0) |
set collision mask for a specific mItem | |
void | setActiveMask (unsigned int a_mask) |
set collision mask for all the next items that will be added to the collision manager (should be reset to NONE(0) when we have finish). | |
Public Member Functions inherited from CoreModifiable | |
void | Init () |
Modifiable managmenent. | |
void | EmptyItemList () |
remove all items (sons) | |
CMSP | GetInstanceByPath (const std::string &path) |
return the instance corresponding to the given path in sons tree | |
std::string | GetRuntimeID () const |
ID. | |
CoreModifiableAttribute * | getAttribute (KigsID labelid) const |
Attribute management. | |
u32 | getNbArrayElements (KigsID attributeLabel) const |
return element count for an array type attribute | |
template<typename attribute_type , typename value_type > | |
attribute_type * | AddDynamicAttribute (KigsID ID, const value_type &value) |
Dynamic attribute management. | |
const kigs::unordered_map< KigsID, ModifiableMethodStruct > * | GetMethods () |
Method management. | |
bool | aggregateWith (CMSP &item, ItemPosition pos=Last) |
Aggregate management. | |
void | flagAsNotificationCenterRegistered () |
Flags. | |
void | InitParametersFromList (const std::vector< CoreModifiableAttribute * > *params) |
Utility. More... | |
virtual void | UninitModifiable () |
called when InitModifiable has failled : reset read/write flag on all init params More... | |
virtual void | ProtectedDestroy () |
Destroy method decrement refcounter and delete instance if no more used. More... | |
virtual void | addUser (CoreModifiable *user) |
add the given parent to list | |
virtual void | removeUser (CoreModifiable *user) |
remove user (parent) | |
virtual bool | addItem (const CMSP &item, ItemPosition pos=Last) |
add item at first or last position | |
virtual bool | removeItem (const CMSP &item) |
remove item (son) | |
Protected Member Functions | |
void | InitModifiable () override |
default modifiable init : set all initparams to readonly and set initflag to true More... | |
void | CreateCollisionObject (CoreModifiable *item, unsigned int ColMask) |
bool | GetLocalRayIntersection (Hit &hit, const Point3D &start, const Vector3D &dir, const CollisionBaseObject *pCollisionObject) |
recursive internal method return true if itersection found More... | |
bool | GetLocalSphereIntersection (Hit &hit, const Point3D &start, const Vector3D &dir, const kfloat &Radius, CollisionBaseObject *pCollisionObject) |
recursive internal method More... | |
bool | RecursiveSearchRayIntersection (CoreModifiable *lastCollideNode, Node3D *lastNode, CoreModifiable *currentitem, Point3D start, Vector3D dir, Hit &hit, unsigned int lastNodeCategory, unsigned int a_itemCategory=ALL, bool ignore_is_collidable=false) |
recursive internal method More... | |
void | RecursiveSearchAllRayIntersection (CoreModifiable *lastCollideNode, Node3D *lastNode, CoreModifiable *currentitem, const Point3D &start, const Vector3D &dir, std::vector< Hit > &hits, unsigned int lastNodeCategory, unsigned int a_itemCategory=ALL, bool ignore_is_collidable=false) |
void | RecursiveSearchPlaneIntersection (Node3D *lastNode, CoreModifiable *currentitem, const Point3D &o, const Vector3D &n, const BBox *Zone, PlaneIntersectionInfoStruct &result, unsigned int lastNodeCategory, unsigned int a_itemCategory=ALL) |
bool | RecursiveSearchSphereIntersection (Hit &hit, CoreModifiable *currentitem, const Point3D &start, const Vector3D &dir, const kfloat &Radius, unsigned int a_itemCategory=ALL) |
recursive internal method More... | |
CoreModifiable * | RecursiveSearchSphereIntersection (OctreeSubNode *currentNode, const Point3D &start, const Vector3D &dir, const kfloat &Radius, const Point3D &lstart, const Vector3D &ldir, const kfloat &lRadius, kdouble &Distance, Vector3D &normal, Point3D &intersectP, bool recurse=true, unsigned int a_itemCategory=ALL) |
recursive internal method More... | |
bool | GetLocalSphereIntersectionWithRay (Hit &hit, const Point3D &start, const Vector3D &dir, const kfloat &Radius, CollisionBaseObject *pCollisionObject, unsigned int a_itemCategory=ALL) |
recursive internal method | |
Protected Member Functions inherited from CoreModifiable | |
void | UpdateAggregates (const Timer &timer, void *addParam) |
Internals. | |
void | Export (std::vector< CoreModifiable * > &savedList, XMLNode *currentNode, bool recursive, ExportSettings *settings) |
Export. More... | |
CoreModifiableAttribute * | GenericCreateDynamicAttribute (CoreModifiable::ATTRIBUTE_TYPE type, KigsID ID) |
create and add dynamic attribute except arrays | |
Additional Inherited Members | |
Static Public Member Functions inherited from CoreModifiable | |
static std::vector< CMSP > | GetRootInstances (const KigsID &cid, bool exactTypeOnly=false) |
static method : return the set of all root instances of the given type | |
static void | Append (std::string &XMLString, const std::list< CoreModifiable * > &toexport, bool recursive, ExportSettings *settings=nullptr) |
static method to export the several CoreModifiable to an XML file. if recursive flag is set to true, export also all sons tree More... | |
static void | Export (const std::string &filename, CoreModifiable *toexport, bool recursive=false, ExportSettings *settings=nullptr) |
static method to export the given CoreModifiable to an XML file. if recursive flag is set to true, export also all sons tree More... | |
static XMLNode * | ExportToXMLNode (CoreModifiable *toexport, XML *owner_xml_file, bool recursive, ExportSettings *settings=nullptr) |
static method to export the given CoreModifiable to an XML Node. if recursive flag is set to true, export also all sons tree More... | |
static std::string | ExportToXMLString (CoreModifiable *toexport, bool recursive, ExportSettings *settings=nullptr) |
static method to export the given CoreModifiable to an XML file. if recursive flag is set to true, export also all sons tree More... | |
static void | Export (std::string &XMLString, const std::list< CoreModifiable * > &toexport, bool recursive, ExportSettings *settings=nullptr) |
static method to export the several CoreModifiable to an XML file. if recursive flag is set to true, export also all sons tree More... | |
static CMSP | Import (const std::string &filename, bool noInit=false, bool keepImportFileName=false, ImportState *state=nullptr, const std::string &override_name="") |
return an new CoreModifiable instance using the description found in XML file given by name | |
static CMSP | GetInstanceByGlobalPath (const std::string &path) |
static method : return the instance corresponding to the given path, and given search start | |
static void | debugPrintfFullTree (int maxindent=3) |
Editor. More... | |
Static Protected Member Functions inherited from CoreModifiable | |
template<typename StringType > | |
static CMSP | Import (XMLNodeTemplate< StringType > *currentNode, CoreModifiable *currentModifiable, ImportState &importState) |
recusrive method to add sons and attributes found in the XML file | |
Manager class to manage collision.
intersect a ray with all objects in the collision manager search an intersection between a Ray (point and direction), and all the objects in the manager call the recursive method : RecursiveSearchRayIntersection
return altitude for the current point compute "altitude" = vertical distance from the given point to any object in the collision manager
|
protected |
for each mItem in the list search if this mItem is already managed by the collision manager
else, construct its AABBTree if it is a mesh and add it to the collision map
void CollisionManager::GetAllRayIntersection | ( | const Point3D & | start, |
const Vector3D & | dir, | ||
std::vector< Hit > & | hits, | ||
unsigned int | a_itemCategory = ALL , |
||
bool | ignore_is_collidable = false |
||
) |
intersect a ray with all objects in the collision manager
search an intersection between a Ray (point and direction), and all the objects in the manager call the recursive method : RecursiveSearchRayIntersection
bool CollisionManager::GetAltitude | ( | kfloat | x, |
kfloat | y, | ||
kfloat | z, | ||
kfloat & | alt | ||
) |
return altitude for the current point
compute "altitude" = vertical distance from the given point to any object in the collision manager
|
protected |
recursive internal method return true if itersection found
compute intersection between a ray and a mesh in the local mesh coordinate system
|
protected |
recursive internal method
Utility method used by recursive intersection search
void CollisionManager::GetPlaneIntersection | ( | const Point3D & | o, |
const Vector3D & | n, | ||
PlaneIntersectionInfoStruct & | result, | ||
unsigned int | a_itemCategory = ALL , |
||
const BBox * | Zone = nullptr |
||
) |
intersect a plane with all (triangles) objects in the collision manager
intersect a plane with all (triangles) objects in the collision manager
bool CollisionManager::GetRayIntersection | ( | Hit & | hit, |
const Point3D & | start, | ||
const Vector3D & | dir, | ||
unsigned int | a_itemCategory = ALL , |
||
bool | ignore_is_collidable = false |
||
) |
intersect a ray with all objects in the collision manager
search an intersection between a Ray (point and direction), and all the objects in the manager call the recursive method : RecursiveSearchRayIntersection
CoreModifiable * CollisionManager::GetSphereIntersection | ( | const Point3D & | start, |
const Vector3D & | dir, | ||
const kfloat | Radius, | ||
kdouble & | Distance, | ||
Vector3D & | normal, | ||
Point3D & | intersectP, | ||
unsigned int | a_itemCategory = ALL |
||
) |
intersect a sphere with all objects in the collision manager
compute intersection between a moving sphere and all the objects in the collision manager return the nearest intersection if at least one is found
first compute moving sphere BBox in local space
ensure the node is up to date (matrix, bbox...)
|
overrideprotectedvirtual |
default modifiable init : set all initparams to readonly and set initflag to true
already done ? then return
Reimplemented from CoreModifiable.
|
protected |
search an intersection between a Ray (point and direction), and the current CoreModifiable this method is recursive
on Node3D, mark as last seen node au recurse to sons
transform Ray in local mesh coordinate system if needed
for each son of the current mItem, if the son is a Mesh
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
|
protected |
|
protected |
recursive internal method
recursive internal method
recurse in the Node3D hierarchy to find meshes and BSpheres. this method is recursive
void CollisionManager::RescursiveSearchMesh(CoreModifiable currentitem, std::vector<CoreModifiable>& list) { if ((currentitem->isSubType(Mesh::mClassID)) || (currentitem->isSubType(ModernMeshItemGroup::mClassID)) || (currentitem->isSubType(DrawVertice::mClassID)) || (currentitem->isSubType(Plane::mClassID)) || (currentitem->isSubType(BSphere::mClassID))) { list.push_back(currentitem); } else if (currentitem->isUserFlagSet(UserFlagNode3D) || currentitem->isSubType(ModernMesh::mClassID)) { bool needCollision = true;
! recurse only if NeedCollision flag is true CoreModifiableAttribute *pNeedCollisionAttribute = getAttribute("NeedCollision"); if (pNeedCollisionAttribute) pNeedCollisionAttribute->getValue(needCollision); if (needCollision) { std::vector<ModifiableItemStruct>::const_iterator it; for (it = currentitem->getItems().begin(); it != currentitem->getItems().end(); ++it) { RescursiveSearchMesh((*it).mItem, list); } } } }
search an intersection between a Ray (point and direction), and the current CoreModifiable this method is recursive
on Node3D, mark as last seen node au recurse to sons
transform Ray in local mesh coordinate system if needed
for each son of the current mItem, if the son is a Mesh
then check intersection between ray (local) and mesh
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
if intersection found, go back to global coordinates and test if this intersection is the best one (nearest)
|
protected |
recursive internal method
Recursive method to search for intersection of a moving sphere in an Node3D
|
protected |
recursive internal method
Recursive method to search for intersection of a moving sphere in an octree