00001 /* 00002 SagaEngine library 00003 Copyright (c) 2002-2006 Skalden Studio AS 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to distribute the library under the terms of the 00010 Q Public License version 1.0. Be sure to read and understand the license 00011 before using the library. It should be included here, or you may read it 00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl 00013 00014 The original version of this library can be located at: 00015 http://www.sagaengine.com/ 00016 00017 Rune Myrland 00018 rune@skalden.com 00019 */ 00020 00021 00022 #ifndef engine_physics_CollisionAreaComponent_hpp 00023 #define engine_physics_CollisionAreaComponent_hpp 00024 00025 #include "comp/node/NodeComponent.hpp" 00026 #include "CollisionGrid.hpp" 00027 #include "CollisionComponent.hpp" 00028 #include "ContactInfo.hpp" 00029 #include "AreaEdge.hpp" 00030 #include "../area/Area.hpp" 00031 00032 namespace se_core { 00033 class _SeCoreExport Contact { 00034 public: 00035 ContactInfo ci1_; 00036 ContactInfo ci2_; 00037 coor_t radSum_; 00038 00039 bool doesGeometryCollide() const { 00040 bool res = (ci1_.bouncePoint_.xzDistanceSquared(ci1_.bouncePoint_) < radSum_ * radSum_); 00041 return res; 00042 } 00043 }; 00044 00045 00046 class _SeCoreExport CollisionAreaComponent : public NodeComponent { 00047 public: 00048 typedef ComponentPtr<CollisionAreaComponent, sct_COLLISION> Ptr; 00049 00052 CollisionAreaComponent(Composite* owner); 00053 ~CollisionAreaComponent(); 00054 00055 const char* name() const { return "CollisionArea"; } 00056 00057 CollisionGrid* collisionGrid() { 00058 return collisionGrid_; 00059 } 00060 00061 AreaEdge& areaEdge() { 00062 return *areaEdge_; 00063 } 00064 const AreaEdge& areaEdge() const { 00065 return *areaEdge_; 00066 } 00067 00068 void setActive(bool state); 00069 00070 void addCollideable(CollisionComponent& cc); 00071 void removeCollideable(CollisionComponent& cc); 00072 00073 void getContactList(Contact* list, short& count, int maxCollisions); 00074 coor_t farthestLineOfSight(const Point3& fromPoint, const Point3& toPoint) const; 00075 short _collisionCandidates(CollisionComponent *cc, const int MAX_THINGS, CollisionComponent *candidates[]); 00076 short _collisionCandidates2(CollisionComponent *cc, const int MAX_THINGS, CollisionComponent *candidates[]); 00077 void _testCollisionCandidates(CollisionComponent *cc, short candidateCount, CollisionComponent *candidates[], int maxCollisions, Contact *list, short& count); 00078 void _testCollisionCandidates2(CollisionComponent *cc, short candidateCount, CollisionComponent *candidates[], int maxCollisions, Contact *list, short& count); 00079 00080 private: 00087 void setCollisionGrid(CollisionGrid* grid); 00088 void resetCollisionGrid(); 00089 00090 00091 CollisionGrid* collisionGrid_; 00092 AreaEdge* areaEdge_; 00093 }; 00094 00095 } 00096 00097 00098 #endif 00099
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:11 2007 by Doxygen version 1.3.9.1.