29 #include "../../idlib/precompiled.h"
34 #define SUBSAMPLE_WALK_PATH 1
35 #define SUBSAMPLE_FLY_PATH 0
69 split = v1 + (d1 / (d1 - d2)) * (v2 -
v1);
82 int i,
j, faceNum, edgeNum;
96 for ( i = 0; i < area->
numFaces; i++ ) {
104 for ( j = 0; j < face->
numEdges; j++ ) {
110 dist = frontPlane.
Distance( split );
112 if ( dist >= -0.1
f && dist < bestDist ) {
117 if ( dist > bestDist ) {
128 return ( bestDist > -0.1
f );
140 int curAreaNum, lastAreaNum, lastAreas[4], lastAreaIndex;
141 idPlane pathPlane, frontPlane, farPlane;
152 lastAreas[0] = lastAreas[1] = lastAreas[2] = lastAreas[3] = areaNum;
159 frontPlane.
SetNormal( goalOrigin - origin );
166 curAreaNum = areaNum;
167 lastAreaNum = curAreaNum;
177 if ( farPlane.
Distance( endPos ) > -0.5f ) {
182 if ( curAreaNum == goalAreaNum ) {
190 for ( reach = area->
reach; reach; reach = reach->
next ) {
224 dir = endPos - p - dir;
225 if ( dir.LengthSqr() >
Square( 0.2
f ) ) {
236 lastAreas[lastAreaIndex] = curAreaNum;
237 lastAreaIndex = ( lastAreaIndex + 1 ) & 3;
242 endAreaNum = curAreaNum;
253 int i, numSamples, curAreaNum;
254 idVec3 dir, point, nextPoint, endPos;
260 for ( i = 1; i < numSamples; i++ ) {
261 nextPoint = start + dir * ((
float) i / numSamples);
269 endAreaNum = curAreaNum;
282 int i, travelTime, curAreaNum, lastAreas[4], lastAreaIndex, endAreaNum;
292 if (
file ==
NULL || areaNum == goalAreaNum ) {
297 lastAreas[0] = lastAreas[1] = lastAreas[2] = lastAreas[3] = areaNum;
300 curAreaNum = areaNum;
313 if ( areaNum != curAreaNum ) {
316 #if SUBSAMPLE_WALK_PATH
323 #if SUBSAMPLE_WALK_PATH
346 #if SUBSAMPLE_WALK_PATH
356 lastAreas[lastAreaIndex] = curAreaNum;
357 lastAreaIndex = ( lastAreaIndex + 1 ) & 3;
361 if ( curAreaNum == lastAreas[0] || curAreaNum == lastAreas[1] ||
362 curAreaNum == lastAreas[2] || curAreaNum == lastAreas[3] ) {
363 common->
Warning(
"idAASLocal::WalkPathToGoal: local routing minimum going from area %d to area %d", areaNum, goalAreaNum );
411 file->
Trace( trace, origin, goalOrigin );
429 int i, numSamples, curAreaNum;
430 idVec3 dir, point, nextPoint, endPos;
436 for ( i = 1; i < numSamples; i++ ) {
437 nextPoint = start + dir * ((
float) i / numSamples);
445 endAreaNum = curAreaNum;
458 int i, travelTime, curAreaNum, lastAreas[4], lastAreaIndex, endAreaNum;
468 if (
file ==
NULL || areaNum == goalAreaNum ) {
473 lastAreas[0] = lastAreas[1] = lastAreas[2] = lastAreas[3] = areaNum;
476 curAreaNum = areaNum;
489 if ( areaNum != curAreaNum ) {
491 #if SUBSAMPLE_FLY_PATH
498 #if SUBSAMPLE_FLY_PATH
517 #if SUBSAMPLE_FLY_PATH
527 lastAreas[lastAreaIndex] = curAreaNum;
528 lastAreaIndex = ( lastAreaIndex + 1 ) & 3;
532 if ( curAreaNum == lastAreas[0] || curAreaNum == lastAreas[1] ||
533 curAreaNum == lastAreas[2] || curAreaNum == lastAreas[3] ) {
534 common->
Warning(
"idAASLocal::FlyPathToGoal: local routing minimum going from area %d to area %d", areaNum, goalAreaNum );
558 int i,
j, k, numSequences;
559 wallEdge_t **sequenceFirst, **sequenceLast, *wallEdges, *wallEdge;
565 for ( i = 0; i < numEdges; i++ ) {
569 sequenceFirst[
i] = &wallEdges[
i];
570 sequenceLast[
i] = &wallEdges[
i];
572 numSequences = numEdges;
574 for ( i = 0; i < numSequences; i++ ) {
575 for ( j = i+1; j < numSequences; j++ ) {
576 if ( sequenceFirst[i]->
verts[0] == sequenceLast[j]->
verts[1] ) {
577 sequenceLast[
j]->
next = sequenceFirst[
i];
578 sequenceFirst[
i] = sequenceFirst[
j];
581 if ( sequenceLast[i]->
verts[1] == sequenceFirst[j]->
verts[0] ) {
582 sequenceLast[
i]->
next = sequenceFirst[
j];
586 if ( j < numSequences ) {
588 for ( k = j; k < numSequences; k++ ) {
589 sequenceFirst[k] = sequenceFirst[k+1];
590 sequenceLast[k] = sequenceLast[k+1];
597 for ( i = 0; i < numSequences; i++ ) {
598 for ( wallEdge = sequenceFirst[i]; wallEdge; wallEdge = wallEdge->
next ) {
599 edges[k++] = wallEdge->
edgeNum;
610 int i,
j, k,
l, face1Num, face2Num, edge1Num, edge2Num, numEdges, absEdge1Num;
611 int *areaQueue, curArea, queueStart, queueEnd;
629 areaQueue[0] = areaNum;
630 areasVisited[areaNum] =
true;
632 for ( curArea = areaNum; queueStart < queueEnd; curArea = areaQueue[++queueStart] ) {
636 for ( i = 0; i < area->
numFaces; i++ ) {
644 for ( j = 0; j < face1->
numEdges; j++ ) {
646 absEdge1Num = abs( edge1Num );
649 for ( k = 0; k < area->
numFaces; k++ ) {
660 for ( l = 0; l < face2->
numEdges; l++ ) {
662 if ( edge2Num == absEdge1Num ) {
666 if ( l < face2->numEdges ) {
670 if ( k < area->numFaces ) {
675 for ( reach = area->
reach; reach; reach = reach->
next ) {
677 if ( reach->
edgeNum == absEdge1Num ) {
687 for ( k = 0; k < numEdges; k++ ) {
688 if ( edge1Num == edges[k] ) {
692 if ( k < numEdges ) {
697 edges[numEdges++] = edge1Num;
698 if ( numEdges >= maxEdges ) {
705 for ( reach = area->
reach; reach; reach = reach->
next ) {
709 areaQueue[queueEnd++] = reach->
toAreaNum;
virtual bool Trace(aasTrace_t &trace, const idVec3 &start, const idVec3 &end) const =0
const idAASSettings & GetSettings(void) const
const idVec3 & Normal(void) const
idVec3 SubSampleFlyPath(int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum) const
const float walkPathSampleDistance
const aasEdge_t & GetEdge(int index) const
const aasFace_t & GetFace(int index) const
idVec3 SubSampleWalkPath(int areaNum, const idVec3 &origin, const idVec3 &start, const idVec3 &end, int travelFlags, int &endAreaNum) const
float Distance(const idVec3 &v) const
virtual bool FlyPathValid(int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum) const
const aasVertex_t & GetVertex(int index) const
const int maxWalkPathIterations
const int maxFlyPathIterations
void SetNormal(const idVec3 &normal)
const aasIndex_t & GetEdgeIndex(int index) const
virtual void GetEdgeVertexNumbers(int edgeNum, int verts[2]) const
bool EdgeSplitPoint(idVec3 &split, int edgeNum, const idPlane &plane) const
GLfloat GLfloat GLfloat v2
#define FLOATSIGNBITSET(f)
void SetDist(const float dist)
virtual bool WalkPathValid(int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum) const
virtual bool RouteToGoalArea(int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach) const
const idReachability * reachability
const float maxWalkPathDistance
const aasIndex_t & GetFaceIndex(int index) const
int GetNumAreas(void) const
struct wallEdge_s wallEdge_t
bool FloorEdgeSplitPoint(idVec3 &split, int areaNum, const idPlane &splitPlane, const idPlane &frontPlane, bool closest) const
virtual bool FlyPathToGoal(aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags) const
float LengthSqr(void) const
float Normalize(bool fixDegenerate=true)
const float maxFlyPathDistance
virtual void SortWallEdges(int *edges, int numEdges) const
virtual bool WalkPathToGoal(aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags) const
const float flyPathSampleDistance
bool IntersectsBounds(const idBounds &a) const
virtual int GetWallEdges(int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges) const
const aasArea_t & GetArea(int index)
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
void FitThroughPoint(const idVec3 &p)