From: Ondrej H. <tan...@us...> - 2005-03-16 21:40:54
|
Update of /cvsroot/planeshift/planeshift/src/npcclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32263/src/npcclient Modified Files: walkpoly.h Log Message: - Work on generator of walkable polygons maps, and generator of A* maps. Index: walkpoly.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/npcclient/walkpoly.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** walkpoly.h 5 Mar 2005 18:22:02 -0000 1.2 --- walkpoly.h 16 Mar 2005 21:40:39 -0000 1.3 *************** *** 26,30 **** #include <csutil/csstring.h> #include <csutil/list.h> ! void Dump3(const char * name, const csVector3 & p); --- 26,30 ---- #include <csutil/csstring.h> #include <csutil/list.h> ! #include "pathfind.h" void Dump3(const char * name, const csVector3 & p); *************** *** 52,55 **** --- 52,57 ---- class iSector; class CelBase; + class iDocumentNode; + class iVFS; /************************************************************************** *************** *** 154,157 **** --- 156,161 ---- csString info; // debug only + bool stuck; + psWalkPolyVert() { } psWalkPolyVert(const csVector3 & pos) *************** *** 172,175 **** --- 176,181 ---- friend class psWalkPoly; public: + psWalkPolyMap(iObjectRegistry * objReg); + psWalkPolyMap(); /** Adds new polygon to map */ *************** *** 181,190 **** --- 187,211 ---- void Generate(CelBase * cel, const csVector3 & start, iSector * sector); + void CalcConts(); + csString DumpPolys(); + void BuildBasicAMap(psAMap & AMap); + + void LoadFromXML(iDocumentNode * node); + bool LoadFromString(const csString & str); + bool LoadFromFile(const csString & path); + + void SaveToString(csString & str); + bool SaveToFile(const csString & path); + + protected: csList<psWalkPoly*> polys; psSpatialIndex index; + + iObjectRegistry * objReg; + csRef<iVFS> vfs; }; *************** *** 198,201 **** --- 219,223 ---- class psWalkPoly { + friend class psWalkPolyMap; public: psWalkPoly(); *************** *** 204,215 **** - vertices must be added CLOCKWISE ! */ void AddVert(const csVector3 & pos, int beforeIndex=-1); ! void SetSector(iSector * sector); ! /** Calculates additional information from polygon vertices. ! Must be called after adding all vertices, before the polygon is used for calculations */ ! void Precalculate(psWalkPolyMap & map); - csBox3 & GetBox() { return box; } /** Moves 'point' (which must be within our polygon) towards 'goal' until it reaches --- 226,235 ---- - vertices must be added CLOCKWISE ! */ void AddVert(const csVector3 & pos, int beforeIndex=-1); + int GetNumVerts() { return verts.Length(); } ! void AddNode(psANode * node); ! void SetSector(iSector * sector); /** Moves 'point' (which must be within our polygon) towards 'goal' until it reaches *************** *** 231,235 **** void DumpJS(const char * name); void DumpPureJS(); ! void DumpPolyJS(); int Stretch(psMapWalker & walker, psWalkPolyMap & map, float stepSize); --- 251,255 ---- void DumpJS(const char * name); void DumpPureJS(); ! void DumpPolyJS(const char * name); int Stretch(psMapWalker & walker, psWalkPolyMap & map, float stepSize); *************** *** 237,244 **** float GetBoxSize(); float GetArea(); float GetLengthOfEdges(); void GetShape(float & min, float & max); ! void PruneUnimportantVerts(); /** returns true if it moved at least a bit */ --- 257,269 ---- float GetBoxSize(); float GetArea(); + float GetTriangleArea(int vertNum); float GetLengthOfEdges(); void GetShape(float & min, float & max); + float GetNarrowness(); ! void PruneUnboundVerts(psMapWalker & walker); ! void PruneUnimportantVerts(float dist); ! ! bool IsNearWalls(psMapWalker & walker, int vertNum); /** returns true if it moved at least a bit */ *************** *** 249,252 **** --- 274,278 ---- /** Calculates box of polygon */ void CalcBox(); + csBox3 & GetBox() { return box; } bool IsInLine(); *************** *** 254,262 **** void ClearInfo(); ! protected: ! void RecalcEdges(int vertNum); void RecalcAllEdges(); /** Finds contact of this polygon with another polygon that is at given point and edge */ --- 280,299 ---- void ClearInfo(); ! bool CollidesWithPolys(psWalkPolyMap & map, csList<psWalkPoly*> * polys); ! void SaveToString(csString & str); ! void LoadFromXML(iDocumentNode * node); ! ! /** Populates the 'conts' array */ ! void CalcConts(psWalkPolyMap & map); ! void RecalcAllEdges(); + void ConnectNodeToPoly(psANode * node, bool bidirectional); + + protected: + + void RecalcEdges(int vertNum); + /** Finds contact of this polygon with another polygon that is at given point and edge */ *************** *** 266,270 **** our polygon (some point on polygon border). 'edgeNum' is number of the edge where the new point is */ ! void MoveToBorder(const csVector3 & goal, csVector3 & point, int & edgeNum); --- 303,307 ---- our polygon (some point on polygon border). 'edgeNum' is number of the edge where the new point is */ ! bool MoveToBorder(const csVector3 & goal, csVector3 & point, int & edgeNum); *************** *** 272,277 **** void CalcEdges(); - /** Populates the 'conts' array */ - void AddConts(psWalkPolyMap & map); int GetNeighbourIndex(int vertNum, int offset) const; --- 309,312 ---- *************** *** 284,287 **** --- 319,324 ---- iSector * sector; csBox3 box; /** box around polygon - taller than the real poly */ + + csArray<psANode*> nodes; }; |