#include "../game/q_shared.h"
#include "l_log.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_libvar.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_aas_def.h"
Include dependency graph for be_aas_reach.c:

Go to the source code of this file.
|
|
Definition at line 54 of file be_aas_reach.c. Referenced by AAS_SetupReachabilityHeap(). |
|
|
Definition at line 63 of file be_aas_reach.c. |
|
|
Definition at line 58 of file be_aas_reach.c. Referenced by AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), and AAS_Reachability_Swim(). |
|
|
Definition at line 59 of file be_aas_reach.c. Referenced by AAS_Reachability_EqualFloorHeight(), and AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(). |
|
|
Definition at line 60 of file be_aas_reach.c. Referenced by AAS_Reachability_EqualFloorHeight(), and AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(). |
|
|
Definition at line 61 of file be_aas_reach.c. Referenced by AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(). |
|
|
Definition at line 56 of file be_aas_reach.c. |
|
|
|
Definition at line 488 of file be_aas_reach.c. References AAS_Error, aas_lreachability_t, aas_lreachability_s::next, nextreachability, numlreachabilities, and r. Referenced by AAS_FindFaceReachabilities(), AAS_Reachability_Elevator(), AAS_Reachability_EqualFloorHeight(), AAS_Reachability_FuncBobbing(), AAS_Reachability_Grapple(), AAS_Reachability_Jump(), AAS_Reachability_JumpPad(), AAS_Reachability_Ladder(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_Swim(), AAS_Reachability_Teleport(), AAS_Reachability_WalkOffLedge(), and AAS_Reachability_WeaponJump(). 00489 {
00490 aas_lreachability_t *r;
00491
00492 if (!nextreachability) return NULL;
00493 //make sure the error message only shows up once
00494 if (!nextreachability->next) AAS_Error("AAS_MAX_REACHABILITYSIZE");
00495 //
00496 r = nextreachability;
00497 nextreachability = nextreachability->next;
00498 numlreachabilities++;
00499 return r;
00500 } //end of the function AAS_AllocReachability
|
|
|
Definition at line 754 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::contents. Referenced by AAS_Reachability_Jump(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), and AAS_Reachability_WalkOffLedge(). 00755 {
00756 return (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL);
00757 } //end of the function AAS_AreaClusterPortal
|
|
|
Definition at line 657 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::presencetype. Referenced by AAS_AreaTravelTime(), AAS_Reachability_EqualFloorHeight(), AAS_Reachability_Jump(), and AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(). 00658 {
00659 if (!(aasworld.areasettings[areanum].presencetype & PRESENCE_NORMAL)) return qtrue;
00660 else return qfalse;
00661 } //end of the function AAS_AreaCrouch
|
|
|
Definition at line 764 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::contents. Referenced by AAS_AreaRouteToGoalArea(), and BotGetReachabilityToGoal(). 00765 {
00766 return (aasworld.areasettings[areanum].contents & AREACONTENTS_DONOTENTER);
00767 } //end of the function AAS_AreaDoNotEnter
|
|
|
Definition at line 713 of file be_aas_reach.c. References aasworld, aas_areasettings_s::areaflags, and aas_s::areasettings. Referenced by AAS_BestReachableLinkArea(), AAS_NearbySolidOrGap(), AAS_Reachability_Elevator(), AAS_Reachability_EqualFloorHeight(), AAS_Reachability_Grapple(), AAS_Reachability_Jump(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_WalkOffLedge(), and AAS_Reachability_WeaponJump(). 00714 {
00715 return (aasworld.areasettings[areanum].areaflags & AREA_GROUNDED);
00716 } //end of the function AAS_AreaGround
|
|
|
Definition at line 539 of file be_aas_reach.c. References aas_area_t, aas_face_t, AAS_FaceArea(), aasworld, abs(), aas_s::areas, aas_face_s::faceflags, aas_s::faceindex, aas_s::faces, aas_area_s::firstface, i, and aas_area_s::numfaces. Referenced by AAS_RandomGoalArea(). 00540 {
00541 int i;
00542 float total;
00543 aas_area_t *area;
00544 aas_face_t *face;
00545
00546 total = 0;
00547 area = &aasworld.areas[areanum];
00548 for (i = 0; i < area->numfaces; i++)
00549 {
00550 face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];
00551 if (!(face->faceflags & FACE_GROUND)) continue;
00552 //
00553 total += AAS_FaceArea(face);
00554 } //end for
00555 return total;
00556 } //end of the function AAS_AreaGroundFaceArea
|
Here is the call graph for this function:

|
|
Definition at line 734 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::contents. Referenced by AAS_BestReachableFromJumpPadArea(), AAS_Reachability_Jump(), AAS_Reachability_JumpPad(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_Teleport(), AAS_Reachability_WalkOffLedge(), BotMoveToGoal(), and BotUpdateEntityItems(). 00735 {
00736 return (aasworld.areasettings[areanum].contents & AREACONTENTS_JUMPPAD);
00737 } //end of the function AAS_AreaJumpPad
|
|
|
Definition at line 724 of file be_aas_reach.c. References aasworld, aas_areasettings_s::areaflags, and aas_s::areasettings. Referenced by AAS_Reachability_Ladder(). 00725 {
00726 return (aasworld.areasettings[areanum].areaflags & AREA_LADDER);
00727 } //end of the function AAS_AreaLadder
|
|
|
Definition at line 692 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::contents. 00693 {
00694 return (aasworld.areasettings[areanum].contents & AREACONTENTS_LAVA);
00695 } //end of the function AAS_AreaLava
|
|
|
Definition at line 681 of file be_aas_reach.c. References aasworld, aas_areasettings_s::areaflags, and aas_s::areasettings. 00682 {
00683 if (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue;
00684 else return qfalse;
00685 } //end of the function AAS_AreaLiquid
|
|
|
Definition at line 523 of file be_aas_reach.c. References AAS_Error, aasworld, aas_s::areasettings, aas_s::numareas, and aas_areasettings_s::numreachableareas. Referenced by AAS_AlternativeRouteGoals(), AAS_BestReachableLinkArea(), AAS_CreateAllRoutingCache(), AAS_NumberClusterAreas(), AAS_PointReachabilityAreaIndex(), AAS_RandomGoalArea(), BotCheckBlocked(), BotChooseLTGItem(), BotChooseNBGItem(), BotFuzzyPointReachabilityArea(), BotMoveToGoal(), and BotReachabilityArea(). 00524 {
00525 if (areanum < 0 || areanum >= aasworld.numareas)
00526 {
00527 AAS_Error("AAS_AreaReachability: areanum %d out of range", areanum);
00528 return 0;
00529 } //end if
00530 return aasworld.areasettings[areanum].numreachableareas;
00531 } //end of the function AAS_AreaReachability
|
|
|
Definition at line 702 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::contents. 00703 {
00704 return (aasworld.areasettings[areanum].contents & AREACONTENTS_SLIME);
00705 } //end of the function AAS_AreaSlime
|
|
|
Definition at line 669 of file be_aas_reach.c. References aasworld, aas_areasettings_s::areaflags, and aas_s::areasettings. Referenced by AAS_AreaTravelTime(), AAS_BestReachableLinkArea(), AAS_NearbySolidOrGap(), AAS_RandomGoalArea(), AAS_Reachability_Elevator(), AAS_Reachability_Grapple(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_Swim(), AAS_Reachability_WalkOffLedge(), and AAS_Reachability_WeaponJump(). 00670 {
00671 if (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue;
00672 else return qfalse;
00673 } //end of the function AAS_AreaSwim
|
|
|
Definition at line 744 of file be_aas_reach.c. References aasworld, aas_s::areasettings, and aas_areasettings_s::contents. Referenced by AAS_Reachability_Teleport(). 00745 {
00746 return (aasworld.areasettings[areanum].contents & AREACONTENTS_TELEPORTER);
00747 } //end of the function AAS_AreaTeleporter
|
|
|
Definition at line 145 of file be_aas_reach.c. References a, aas_area_t, aas_edge_t, aas_face_t, AAS_FaceArea(), aas_plane_t, aasworld, abs(), aas_s::areas, aas_face_s::backarea, d, aas_plane_s::dist, DotProduct, aas_s::edgeindex, aas_s::edges, aas_s::faceindex, aas_s::faces, aas_face_s::firstedge, aas_area_s::firstface, i, aas_plane_s::normal, aas_area_s::numfaces, aas_face_s::planenum, aas_s::planes, aas_edge_s::v, vec3_t, vec_t, VectorCopy, and aas_s::vertexes. Referenced by AAS_BestReachableFromJumpPadArea(), and AAS_Reachability_Swim(). 00146 {
00147 int i, edgenum, facenum, side;
00148 vec_t d, a, volume;
00149 vec3_t corner;
00150 aas_plane_t *plane;
00151 aas_edge_t *edge;
00152 aas_face_t *face;
00153 aas_area_t *area;
00154
00155 area = &aasworld.areas[areanum];
00156 facenum = aasworld.faceindex[area->firstface];
00157 face = &aasworld.faces[abs(facenum)];
00158 edgenum = aasworld.edgeindex[face->firstedge];
00159 edge = &aasworld.edges[abs(edgenum)];
00160 //
00161 VectorCopy(aasworld.vertexes[edge->v[0]], corner);
00162
00163 //make tetrahedrons to all other faces
00164 volume = 0;
00165 for (i = 0; i < area->numfaces; i++)
00166 {
00167 facenum = abs(aasworld.faceindex[area->firstface + i]);
00168 face = &aasworld.faces[facenum];
00169 side = face->backarea != areanum;
00170 plane = &aasworld.planes[face->planenum ^ side];
00171 d = -(DotProduct (corner, plane->normal) - plane->dist);
00172 a = AAS_FaceArea(face);
00173 volume += d * a;
00174 } //end for
00175
00176 volume /= 3;
00177 return volume;
00178 } //end of the function AAS_AreaVolume
|
Here is the call graph for this function:

|
|
Definition at line 775 of file be_aas_reach.c. References aassettings, aas_settings_s::phys_gravity, and aas_settings_s::phys_jumpvel. 00776 {
00777 return aassettings.phys_jumpvel / (aassettings.phys_gravity * 0.1);
00778 } //end op the function AAS_BarrierJumpTravelTime
|
|
||||||||||||||||||||
|
Definition at line 360 of file be_aas_reach.c. References AAS_BestReachableLinkArea(), AAS_DrawPermanentCross(), aas_link_t, AAS_LinkEntityClientBBox(), AAS_PointAreaNum(), aas_trace_t, AAS_TraceClientBBox(), AAS_UnlinkFromAreas(), aasworld, botimport, aas_trace_s::endpos, i, j, k, l, LINECOLOR_RED, aas_s::loaded, Log_Write(), PRESENCE_CROUCH, PRT_ERROR, PRT_MESSAGE, aas_trace_s::startsolid, vec3_t, VectorAdd, and VectorCopy. Referenced by AAS_SetWeaponJumpAreaFlags(), BotInitLevelItems(), and BotUpdateEntityItems(). 00361 {
00362 int areanum, i, j, k, l;
00363 aas_link_t *areas;
00364 vec3_t absmins, absmaxs;
00365 //vec3_t bbmins, bbmaxs;
00366 vec3_t start, end;
00367 aas_trace_t trace;
00368
00369 if (!aasworld.loaded)
00370 {
00371 botimport.Print(PRT_ERROR, "AAS_BestReachableArea: aas not loaded\n");
00372 return 0;
00373 } //end if
00374 //find a point in an area
00375 VectorCopy(origin, start);
00376 areanum = AAS_PointAreaNum(start);
00377 //while no area found fudge around a little
00378 for (i = 0; i < 5 && !areanum; i++)
00379 {
00380 for (j = 0; j < 5 && !areanum; j++)
00381 {
00382 for (k = -1; k <= 1 && !areanum; k++)
00383 {
00384 for (l = -1; l <= 1 && !areanum; l++)
00385 {
00386 VectorCopy(origin, start);
00387 start[0] += (float) j * 4 * k;
00388 start[1] += (float) j * 4 * l;
00389 start[2] += (float) i * 4;
00390 areanum = AAS_PointAreaNum(start);
00391 } //end for
00392 } //end for
00393 } //end for
00394 } //end for
00395 //if an area was found
00396 if (areanum)
00397 {
00398 //drop client bbox down and try again
00399 VectorCopy(start, end);
00400 start[2] += 0.25;
00401 end[2] -= 50;
00402 trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);
00403 if (!trace.startsolid)
00404 {
00405 areanum = AAS_PointAreaNum(trace.endpos);
00406 VectorCopy(trace.endpos, goalorigin);
00407 //FIXME: cannot enable next line right now because the reachability
00408 // does not have to be calculated when the level items are loaded
00409 //if the origin is in an area with reachability
00410 //if (AAS_AreaReachability(areanum)) return areanum;
00411 if (areanum) return areanum;
00412 } //end if
00413 else
00414 {
00415 //it can very well happen that the AAS_PointAreaNum function tells that
00416 //a point is in an area and that starting a AAS_TraceClientBBox from that
00417 //point will return trace.startsolid qtrue
00418 #if 0
00419 if (AAS_PointAreaNum(start))
00420 {
00421 Log_Write("point %f %f %f in area %d but trace startsolid", start[0], start[1], start[2], areanum);
00422 AAS_DrawPermanentCross(start, 4, LINECOLOR_RED);
00423 } //end if
00424 botimport.Print(PRT_MESSAGE, "AAS_BestReachableArea: start solid\n");
00425 #endif
00426 VectorCopy(start, goalorigin);
00427 return areanum;
00428 } //end else
00429 } //end if
00430 //
00431 //AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bbmins, bbmaxs);
00432 //NOTE: the goal origin does not have to be in the goal area
00433 // because the bot will have to move towards the item origin anyway
00434 VectorCopy(origin, goalorigin);
00435 //
00436 VectorAdd(origin, mins, absmins);
00437 VectorAdd(origin, maxs, absmaxs);
00438 //add bounding box size
00439 //VectorSubtract(absmins, bbmaxs, absmins);
00440 //VectorSubtract(absmaxs, bbmins, absmaxs);
00441 //link an invalid (-1) entity
00442 areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);
00443 //get the reachable link arae
00444 areanum = AAS_BestReachableLinkArea(areas);
00445 //unlink the invalid entity
00446 AAS_UnlinkFromAreas(areas);
00447 //
00448 return areanum;
00449 } //end of the function AAS_BestReachableArea
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 290 of file be_aas_reach.c. References AAS_AreaJumpPad(), AAS_AreaVolume(), aas_clientmove_t, AAS_ClientMovementHitBBox(), AAS_GetJumpPadInfo(), aas_link_t, AAS_LinkEntityClientBBox(), AAS_NextBSPEntity(), AAS_UnlinkFromAreas(), AAS_ValueForBSPEpairKey(), aas_link_s::areanum, botimport, Com_Memset(), f, aas_clientmove_s::frames, LibVarValue(), MAX_EPAIRKEY, move(), aas_link_s::next_area, PRESENCE_CROUCH, PRESENCE_NORMAL, PRT_MESSAGE, qfalse, strcmp(), vec3_t, VectorAdd, and VectorSet. Referenced by BotInitLevelItems(). 00291 {
00292 int area2num, ent, bot_visualizejumppads, bestareanum;
00293 float volume, bestareavolume;
00294 vec3_t areastart, cmdmove, bboxmins, bboxmaxs;
00295 vec3_t absmins, absmaxs, velocity;
00296 aas_clientmove_t move;
00297 aas_link_t *areas, *link;
00298 char classname[MAX_EPAIRKEY];
00299
00300 #ifdef BSPC
00301 bot_visualizejumppads = 0;
00302 #else
00303 bot_visualizejumppads = LibVarValue("bot_visualizejumppads", "0");
00304 #endif
00305 VectorAdd(origin, mins, bboxmins);
00306 VectorAdd(origin, maxs, bboxmaxs);
00307 for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))
00308 {
00309 if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
00310 if (strcmp(classname, "trigger_push")) continue;
00311 //
00312 if (!AAS_GetJumpPadInfo(ent, areastart, absmins, absmaxs, velocity)) continue;
00313 //get the areas the jump pad brush is in
00314 areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);
00315 for (link = areas; link; link = link->next_area)
00316 {
00317 if (AAS_AreaJumpPad(link->areanum)) break;
00318 } //end for
00319 if (!link)
00320 {
00321 botimport.Print(PRT_MESSAGE, "trigger_push not in any jump pad area\n");
00322 AAS_UnlinkFromAreas(areas);
00323 continue;
00324 } //end if
00325 //
00326 //botimport.Print(PRT_MESSAGE, "found a trigger_push with velocity %f %f %f\n", velocity[0], velocity[1], velocity[2]);
00327 //
00328 VectorSet(cmdmove, 0, 0, 0);
00329 Com_Memset(&move, 0, sizeof(aas_clientmove_t));
00330 area2num = 0;
00331 AAS_ClientMovementHitBBox(&move, -1, areastart, PRESENCE_NORMAL, qfalse,
00332 velocity, cmdmove, 0, 30, 0.1f, bboxmins, bboxmaxs, bot_visualizejumppads);
00333 if (move.frames < 30)
00334 {
00335 bestareanum = 0;
00336 bestareavolume = 0;
00337 for (link = areas; link; link = link->next_area)
00338 {
00339 if (!AAS_AreaJumpPad(link->areanum)) continue;
00340 volume = AAS_AreaVolume(link->areanum);
00341 if (volume >= bestareavolume)
00342 {
00343 bestareanum = link->areanum;
00344 bestareavolume = volume;
00345 } //end if
00346 } //end if
00347 AAS_UnlinkFromAreas(areas);
00348 return bestareanum;
00349 } //end if
00350 AAS_UnlinkFromAreas(areas);
00351 } //end for
00352 return 0;
00353 } //end of the function AAS_BestReachableFromJumpPadArea
|
Here is the call graph for this function:

|
|
Definition at line 185 of file be_aas_reach.c. References AAS_AreaGrounded(), AAS_AreaReachability(), AAS_AreaSwim(), aas_link_t, aas_link_s::areanum, and aas_link_s::next_area. Referenced by AAS_BestReachableArea(), and AAS_BestReachableEntityArea(). 00186 {
00187 aas_link_t *link;
00188
00189 for (link = areas; link; link = link->next_area)
00190 {
00191 if (AAS_AreaGrounded(link->areanum) || AAS_AreaSwim(link->areanum))
00192 {
00193 return link->areanum;
00194 } //end if
00195 } //end for
00196 //
00197 for (link = areas; link; link = link->next_area)
00198 {
00199 if (link->areanum) return link->areanum;
00200 //FIXME: this is a bad idea when the reachability is not yet
00201 // calculated when the level items are loaded
00202 if (AAS_AreaReachability(link->areanum))
00203 return link->areanum;
00204 } //end for
00205 return 0;
00206 } //end of the function AAS_BestReachableLinkArea
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 1831 of file be_aas_reach.c. References aas_plane_t, aas_plane_s::dist, DotProduct, aas_plane_s::normal, p2, v1, v2, vec3_t, VectorBetweenVectors(), VectorCopy, VectorDistance(), and VectorSubtract. Referenced by AAS_FindFaceReachabilities(), and AAS_Reachability_Jump(). 01835 {
01836 vec3_t dir1, dir2, p1, p2, p3, p4;
01837 float a1, a2, b1, b2, dist, dist1, dist2;
01838 int founddist;
01839
01840 //edge vectors
01841 VectorSubtract(v2, v1, dir1);
01842 VectorSubtract(v4, v3, dir2);
01843 //get the horizontal directions
01844 dir1[2] = 0;
01845 dir2[2] = 0;
01846 //
01847 // p1 = point on an edge vector of area2 closest to v1
01848 // p2 = point on an edge vector of area2 closest to v2
01849 // p3 = point on an edge vector of area1 closest to v3
01850 // p4 = point on an edge vector of area1 closest to v4
01851 //
01852 if (dir2[0])
01853 {
01854 a2 = dir2[1] / dir2[0];
01855 b2 = v3[1] - a2 * v3[0];
01856 //point on the edge vector of area2 closest to v1
01857 p1[0] = (DotProduct(v1, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0];
01858 p1[1] = a2 * p1[0] + b2;
01859 //point on the edge vector of area2 closest to v2
01860 p2[0] = (DotProduct(v2, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0];
01861 p2[1] = a2 * p2[0] + b2;
01862 } //end if
01863 else
01864 {
01865 //point on the edge vector of area2 closest to v1
01866 p1[0] = v3[0];
01867 p1[1] = v1[1];
01868 //point on the edge vector of area2 closest to v2
01869 p2[0] = v3[0];
01870 p2[1] = v2[1];
01871 } //end else
01872 //
01873 if (dir1[0])
01874 {
01875 //
01876 a1 = dir1[1] / dir1[0];
01877 b1 = v1[1] - a1 * v1[0];
01878 //point on the edge vector of area1 closest to v3
01879 p3[0] = (DotProduct(v3, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0];
01880 p3[1] = a1 * p3[0] + b1;
01881 //point on the edge vector of area1 closest to v4
01882 p4[0] = (DotProduct(v4, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0];
01883 p4[1] = a1 * p4[0] + b1;
01884 } //end if
01885 else
01886 {
01887 //point on the edge vector of area1 closest to v3
01888 p3[0] = v1[0];
01889 p3[1] = v3[1];
01890 //point on the edge vector of area1 closest to v4
01891 p4[0] = v1[0];
01892 p4[1] = v4[1];
01893 } //end else
01894 //start with zero z-coordinates
01895 p1[2] = 0;
01896 p2[2] = 0;
01897 p3[2] = 0;
01898 p4[2] = 0;
01899 //calculate the z-coordinates from the ground planes
01900 p1[2] = (plane2->dist - DotProduct(plane2->normal, p1)) / plane2->normal[2];
01901 p2[2] = (plane2->dist - DotProduct(plane2->normal, p2)) / plane2->normal[2];
01902 p3[2] = (plane1->dist - DotProduct(plane1->normal, p3)) / plane1->normal[2];
01903 p4[2] = (plane1->dist - DotProduct(plane1->normal, p4)) / plane1->normal[2];
01904 //
01905 founddist = qfalse;
01906 //
01907 if (VectorBetweenVectors(p1, v3, v4))
01908 {
01909 dist = VectorDistance(v1, p1);
01910 if (dist > bestdist - 0.5 && dist < bestdist + 0.5)
01911 {
01912 dist1 = VectorDistance(beststart1, v1);
01913 dist2 = VectorDistance(beststart2, v1);
01914 if (dist1 > dist2)
01915 {
01916 if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart2);
01917 } //end if
01918 else
01919 {
01920 if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart1);
01921 } //end else
01922 dist1 = VectorDistance(bestend1, p1);
01923 dist2 = VectorDistance(bestend2, p1);
01924 if (dist1 > dist2)
01925 {
01926 if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend2);
01927 } //end if
01928 else
01929 {
01930 if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend1);
01931 } //end else
01932 } //end if
01933 else if (dist < bestdist)
01934 {
01935 bestdist = dist;
01936 VectorCopy(v1, beststart1);
01937 VectorCopy(v1, beststart2);
01938 VectorCopy(p1, bestend1);
01939 VectorCopy(p1, bestend2);
01940 } //end if
01941 founddist = qtrue;
01942 } //end if
01943 if (VectorBetweenVectors(p2, v3, v4))
01944 {
01945 dist = VectorDistance(v2, p2);
01946 if (dist > bestdist - 0.5 && dist < bestdist + 0.5)
01947 {
01948 dist1 = VectorDistance(beststart1, v2);
01949 dist2 = VectorDistance(beststart2, v2);
01950 if (dist1 > dist2)
01951 {
01952 if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart2);
01953 } //end if
01954 else
01955 {
01956 if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart1);
01957 } //end else
01958 dist1 = VectorDistance(bestend1, p2);
01959 dist2 = VectorDistance(bestend2, p2);
01960 if (dist1 > dist2)
01961 {
01962 if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend2);
01963 } //end if
01964 else
01965 {
01966 if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend1);
01967 } //end else
01968 } //end if
01969 else if (dist < bestdist)
01970 {
01971 bestdist = dist;
01972 VectorCopy(v2, beststart1);
01973 VectorCopy(v2, beststart2);
01974 VectorCopy(p2, bestend1);
01975 VectorCopy(p2, bestend2);
01976 } //end if
01977 founddist = qtrue;
01978 } //end else if
01979 if (VectorBetweenVectors(p3, v1, v2))
01980 {
01981 dist = VectorDistance(v3, p3);
01982 if (dist > bestdist - 0.5 && dist < bestdist + 0.5)
01983 {
01984 dist1 = VectorDistance(beststart1, p3);
01985 dist2 = VectorDistance(beststart2, p3);
01986 if (dist1 > dist2)
01987 {
01988 if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart2);
01989 } //end if
01990 else
01991 {
01992 if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart1);
01993 } //end else
01994 dist1 = VectorDistance(bestend1, v3);
01995 dist2 = VectorDistance(bestend2, v3);
01996 if (dist1 > dist2)
01997 {
01998 if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend2);
01999 } //end if
02000 else
02001 {
02002 if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend1);
02003 } //end else
02004 } //end if
02005 else if (dist < bestdist)
02006 {
02007 bestdist = dist;
02008 VectorCopy(p3, beststart1);
02009 VectorCopy(p3, beststart2);
02010 VectorCopy(v3, bestend1);
02011 VectorCopy(v3, bestend2);
02012 } //end if
02013 founddist = qtrue;
02014 } //end else if
02015 if (VectorBetweenVectors(p4, v1, v2))
02016 {
02017 dist = VectorDistance(v4, p4);
02018 if (dist > bestdist - 0.5 && dist < bestdist + 0.5)
02019 {
02020 dist1 = VectorDistance(beststart1, p4);
02021 dist2 = VectorDistance(beststart2, p4);
02022 if (dist1 > dist2)
02023 {
02024 if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart2);
02025 } //end if
02026 else
02027 {
02028 if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart1);
02029 } //end else
02030 dist1 = VectorDistance(bestend1, v4);
02031 dist2 = VectorDistance(bestend2, v4);
02032 if (dist1 > dist2)
02033 {
02034 if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend2);
02035 } //end if
02036 else
02037 {
02038 if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend1);
02039 } //end else
02040 } //end if
02041 else if (dist < bestdist)
02042 {
02043 |