This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| int | AAS_AreaCluster (int areanum) |
| int | AAS_AreaInfo (int areanum, aas_areainfo_t *info) |
| int | AAS_AreaPresenceType (int areanum) |
| int | AAS_BBoxAreas (vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas) |
| void | AAS_FacePlane (int facenum, vec3_t normal, float *dist) |
| int | AAS_PointAreaNum (vec3_t point) |
| int | AAS_PointPresenceType (vec3_t point) |
| int | AAS_PointReachabilityAreaIndex (vec3_t point) |
| void | AAS_PresenceTypeBoundingBox (int presencetype, vec3_t mins, vec3_t maxs) |
| int | AAS_TraceAreas (vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas) |
| aas_trace_t | AAS_TraceClientBBox (vec3_t start, vec3_t end, int presencetype, int passent) |
|
|
Definition at line 308 of file be_aas_sample.c. References aasworld, aas_s::areasettings, botimport, aas_areasettings_s::cluster, aas_s::numareas, and PRT_ERROR. Referenced by AAS_FloodAreas(), AAS_FloodAreas_r(), and BotExportTest(). 00309 {
00310 if (areanum <= 0 || areanum >= aasworld.numareas)
00311 {
00312 botimport.Print(PRT_ERROR, "AAS_AreaCluster: invalid area number\n");
00313 return 0;
00314 } //end if
00315 return aasworld.areasettings[areanum].cluster;
00316 } //end of the function AAS_AreaCluster
|
|
||||||||||||
|
|
Definition at line 324 of file be_aas_sample.c. References aasworld, aas_s::areasettings, botimport, aas_s::loaded, aas_s::numareas, aas_areasettings_s::presencetype, and PRT_ERROR. Referenced by AAS_Reachability_Grapple(), and BotTravel_Walk(). 00325 {
00326 if (!aasworld.loaded) return 0;
00327 if (areanum <= 0 || areanum >= aasworld.numareas)
00328 {
00329 botimport.Print(PRT_ERROR, "AAS_AreaPresenceType: invalid area number\n");
00330 return 0;
00331 } //end if
00332 return aasworld.areasettings[areanum].presencetype;
00333 } //end of the function AAS_AreaPresenceType
|
|
||||||||||||||||||||
|
Definition at line 1340 of file be_aas_sample.c. References AAS_AASLinkEntity(), aas_link_t, AAS_UnlinkFromAreas(), aas_link_s::areanum, and aas_link_s::next_area. 01341 {
01342 aas_link_t *linkedareas, *link;
01343 int num;
01344
01345 linkedareas = AAS_AASLinkEntity(absmins, absmaxs, -1);
01346 num = 0;
01347 for (link = linkedareas; link; link = link->next_area)
01348 {
01349 areas[num] = link->areanum;
01350 num++;
01351 if (num >= maxareas)
01352 break;
01353 } //end for
01354 AAS_UnlinkFromAreas(linkedareas);
01355 return num;
01356 } //end of the function AAS_BBoxAreas
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1052 of file be_aas_sample.c. References aas_plane_t, aasworld, aas_plane_s::dist, aas_s::faces, aas_plane_s::normal, aas_face_s::planenum, aas_s::planes, and VectorCopy. 01053 {
01054 aas_plane_t *plane;
01055
01056 plane = &aasworld.planes[aasworld.faces[facenum].planenum];
01057 VectorCopy(plane->normal, normal);
01058 *dist = plane->dist;
01059 } //end of the function AAS_FacePlane
|
|
|
Definition at line 213 of file be_aas_sample.c. References aas_node_t, aas_plane_t, aasworld, botimport, aas_node_s::children, aas_plane_s::dist, DotProduct, aas_s::loaded, aas_s::nodes, aas_plane_s::normal, aas_s::numnodes, aas_s::numplanes, aas_node_s::planenum, aas_s::planes, point, PRT_ERROR, PRT_MESSAGE, and vec_t. Referenced by AAS_AgainstLadder(), AAS_BestReachableArea(), AAS_ClientMovementPrediction(), AAS_FloodAreas(), AAS_NearbySolidOrGap(), AAS_PointPresenceType(), AAS_PointReachabilityAreaIndex(), AAS_RandomGoalArea(), AAS_Reachability_Elevator(), AAS_Reachability_FuncBobbing(), AAS_Reachability_Grapple(), AAS_Reachability_Ladder(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_Teleport(), AAS_Reachability_WalkOffLedge(), AAS_Reachability_WeaponJump(), BotFuzzyPointReachabilityArea(), BotInitInfoEntities(), BotTravel_Grapple(), and BotTravel_Jump(). 00214 {
00215 int nodenum;
00216 vec_t dist;
00217 aas_node_t *node;
00218 aas_plane_t *plane;
00219
00220 if (!aasworld.loaded)
00221 {
00222 botimport.Print(PRT_ERROR, "AAS_PointAreaNum: aas not loaded\n");
00223 return 0;
00224 } //end if
00225
00226 //start with node 1 because node zero is a dummy used for solid leafs
00227 nodenum = 1;
00228 while (nodenum > 0)
00229 {
00230 // botimport.Print(PRT_MESSAGE, "[%d]", nodenum);
00231 #ifdef AAS_SAMPLE_DEBUG
00232 if (nodenum >= aasworld.numnodes)
00233 {
00234 botimport.Print(PRT_ERROR, "nodenum = %d >= aasworld.numnodes = %d\n", nodenum, aasworld.numnodes);
00235 return 0;
00236 } //end if
00237 #endif //AAS_SAMPLE_DEBUG
00238 node = &aasworld.nodes[nodenum];
00239 #ifdef AAS_SAMPLE_DEBUG
00240 if (node->planenum < 0 || node->planenum >= aasworld.numplanes)
00241 {
00242 botimport.Print(PRT_ERROR, "node->planenum = %d >= aasworld.numplanes = %d\n", node->planenum, aasworld.numplanes);
00243 return 0;
00244 } //end if
00245 #endif //AAS_SAMPLE_DEBUG
00246 plane = &aasworld.planes[node->planenum];
00247 dist = DotProduct(point, plane->normal) - plane->dist;
00248 if (dist > 0) nodenum = node->children[0];
00249 else nodenum = node->children[1];
00250 } //end while
00251 if (!nodenum)
00252 {
00253 #ifdef AAS_SAMPLE_DEBUG
00254 botimport.Print(PRT_MESSAGE, "in solid\n");
00255 #endif //AAS_SAMPLE_DEBUG
00256 return 0;
00257 } //end if
00258 return -nodenum;
00259 } //end of the function AAS_PointAreaNum
|
|
|
Definition at line 341 of file be_aas_sample.c. References AAS_PointAreaNum(), aasworld, aas_s::areasettings, aas_s::loaded, point, and aas_areasettings_s::presencetype. Referenced by AAS_ClientMovementPrediction(), and BotExportTest(). 00342 {
00343 int areanum;
00344
00345 if (!aasworld.loaded) return 0;
00346
00347 areanum = AAS_PointAreaNum(point);
00348 if (!areanum) return PRESENCE_NONE;
00349 return aasworld.areasettings[areanum].presencetype;
00350 } //end of the function AAS_PointPresenceType
|
Here is the call graph for this function:

|
|
Definition at line 266 of file be_aas_sample.c. References AAS_AreaReachability(), AAS_PointAreaNum(), aasworld, aas_s::areasettings, aas_areasettings_s::cluster, aas_portal_s::clusterareanum, aas_areasettings_s::clusterareanum, aas_s::clusters, aas_portal_s::frontcluster, i, aas_s::initialized, aas_s::numclusters, aas_cluster_s::numreachabilityareas, and aas_s::portals. 00267 {
00268 int areanum, cluster, i, index;
00269
00270 if (!aasworld.initialized)
00271 return 0;
00272
00273 if ( !origin )
00274 {
00275 index = 0;
00276 for (i = 0; i < aasworld.numclusters; i++)
00277 {
00278 index += aasworld.clusters[i].numreachabilityareas;
00279 } //end for
00280 return index;
00281 } //end if
00282
00283 areanum = AAS_PointAreaNum( origin );
00284 if ( !areanum || !AAS_AreaReachability(areanum) )
00285 return 0;
00286 cluster = aasworld.areasettings[areanum].cluster;
00287 areanum = aasworld.areasettings[areanum].clusterareanum;
00288 if (cluster < 0)
00289 {
00290 cluster = aasworld.portals[-cluster].frontcluster;
00291 areanum = aasworld.portals[-cluster].clusterareanum[0];
00292 } //end if
00293
00294 index = 0;
00295 for (i = 0; i < cluster; i++)
00296 {
00297 index += aasworld.clusters[i].numreachabilityareas;
00298 } //end for
00299 index += areanum;
00300 return index;
00301 } //end of the function AAS_PointReachabilityAreaIndex
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 73 of file be_aas_sample.c. References botimport, PRT_FATAL, vec3_t, and VectorCopy. Referenced by AAS_AreaEntityCollision(), AAS_ClipToBBox(), AAS_LinkEntityClientBBox(), BotCheckBlocked(), BotOnTopOfEntity(), BotReachabilityArea(), and BotTouchingGoal(). 00074 {
00075 int index;
00076 //bounding box size for each presence type
00077 vec3_t boxmins[3] = {{0, 0, 0}, {-15, -15, -24}, {-15, -15, -24}};
00078 vec3_t boxmaxs[3] = {{0, 0, 0}, { 15, 15, 32}, { 15, 15, 8}};
00079
00080 if (presencetype == PRESENCE_NORMAL) index = 1;
00081 else if (presencetype == PRESENCE_CROUCH) index = 2;
00082 else
00083 {
00084 botimport.Print(PRT_FATAL, "AAS_PresenceTypeBoundingBox: unknown presence type\n");
00085 index = 2;
00086 } //end if
00087 VectorCopy(boxmins[index], mins);
00088 VectorCopy(boxmaxs[index], maxs);
00089 } //end of the function AAS_PresenceTypeBoundingBox
|
|
||||||||||||||||||||||||
|
Definition at line 726 of file be_aas_sample.c. 00727 {
00728 int side, nodenum, tmpplanenum;
00729 int numareas;
00730 float front, back, frac;
00731 vec3_t cur_start, cur_end, cur_mid;
00732 aas_tracestack_t tracestack[127];
00733 aas_tracestack_t *tstack_p;
00734 aas_node_t *aasnode;
00735 aas_plane_t *plane;
00736
00737 numareas = 0;
00738 areas[0] = 0;
00739 if (!aasworld.loaded) return numareas;
00740
00741 tstack_p = tracestack;
00742 //we start with the whole line on the stack
00743 VectorCopy(start, tstack_p->start);
00744 VectorCopy(end, tstack_p->end);
00745 tstack_p->planenum = 0;
00746 //start with node 1 because node zero is a dummy for a solid leaf
00747 tstack_p->nodenum = 1; //starting at the root of the tree
00748 tstack_p++;
00749
00750 while (1)
00751 {
00752 //pop up the stack
00753 tstack_p--;
00754 //if the trace stack is empty (ended up with a piece of the
00755 //line to be traced in an area)
00756 if (tstack_p < tracestack)
00757 {
00758 return numareas;
00759 } //end if
00760 //number of the current node to test the line against
00761 nodenum = tstack_p->nodenum;
00762 //if it is an area
00763 if (nodenum < 0)
00764 {
00765 #ifdef AAS_SAMPLE_DEBUG
00766 if (-nodenum > aasworld.numareasettings)
00767 {
00768 botimport.Print(PRT_ERROR, "AAS_TraceAreas: -nodenum = %d out of range\n", -nodenum);
00769 return numareas;
00770 } //end if
00771 #endif //AAS_SAMPLE_DEBUG
00772 //botimport.Print(PRT_MESSAGE, "areanum = %d, must be %d\n", -nodenum, AAS_PointAreaNum(start));
00773 areas[numareas] = -nodenum;
00774 if (points) VectorCopy(tstack_p->start, points[numareas]);
00775 numareas++;
00776 if (numareas >= maxareas) return numareas;
00777 continue;
00778 } //end if
00779 //if it is a solid leaf
00780 if (!nodenum)
00781 {
00782 continue;
00783 } //end if
00784 #ifdef AAS_SAMPLE_DEBUG
00785 if (nodenum > aasworld.numnodes)
00786 {
00787 botimport.Print(PRT_ERROR, "AAS_TraceAreas: nodenum out of range\n");
00788 return numareas;
00789 } //end if
00790 #endif //AAS_SAMPLE_DEBUG
00791 //the node to test against
00792 aasnode = &aasworld.nodes[nodenum];
00793 //start point of current line to test against node
00794 VectorCopy(tstack_p->start, cur_start);
00795 //end point of the current line to test against node
00796 VectorCopy(tstack_p->end, cur_end);
00797 //the current node plane
00798 plane = &aasworld.planes[aasnode->planenum];
00799
00800 switch(plane->type)
00801 {/*FIXME: wtf doesn't this work? obviously the node planes aren't always facing positive!!!
00802 //check for axial planes
00803 case PLANE_X:
00804 {
00805 front = cur_start[0] - plane->dist;
00806 back = cur_end[0] - plane->dist;
00807 break;
00808 } //end case
00809 case PLANE_Y:
00810 {
00811 front = cur_start[1] - plane->dist;
00812 back = cur_end[1] - plane->dist;
00813 break;
00814 } //end case
00815 case PLANE_Z:
00816 {
00817 front = cur_start[2] - plane->dist;
00818 back = cur_end[2] - plane->dist;
00819 break;
00820 } //end case*/
00821 default: //gee it's not an axial plane
00822 {
00823 front = DotProduct(cur_start, plane->normal) - plane->dist;
00824 back = DotProduct(cur_end, plane->normal) - plane->dist;
00825 break;
00826 } //end default
00827 } //end switch
00828
00829 //if the whole to be traced line is totally at the front of this node
00830 //only go down the tree with the front child
00831 if (front > 0 && back > 0)
00832 {
00833 //keep the current start and end point on the stack
00834 //and go down the tree with the front child
00835 tstack_p->nodenum = aasnode->children[0];
00836 tstack_p++;
00837 if (tstack_p >= &tracestack[127])
00838 {
00839 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00840 return numareas;
00841 } //end if
00842 } //end if
00843 //if the whole to be traced line is totally at the back of this node
00844 //only go down the tree with the back child
00845 else if (front <= 0 && back <= 0)
00846 {
00847 //keep the current start and end point on the stack
00848 //and go down the tree with the back child
00849 tstack_p->nodenum = aasnode->children[1];
00850 tstack_p++;
00851 if (tstack_p >= &tracestack[127])
00852 {
00853 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00854 return numareas;
00855 } //end if
00856 } //end if
00857 //go down the tree both at the front and back of the node
00858 else
00859 {
00860 tmpplanenum = tstack_p->planenum;
00861 //calculate the hitpoint with the node (split point of the line)
00862 //put the crosspoint TRACEPLANE_EPSILON pixels on the near side
00863 if (front < 0) frac = (front)/(front-back);
00864 else frac = (front)/(front-back);
00865 if (frac < 0) frac = 0;
00866 else if (frac > 1) frac = 1;
00867 //frac = front / (front-back);
00868 //
00869 cur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac;
00870 cur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac;
00871 cur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac;
00872
00873 // AAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED);
00874 //side the front part of the line is on
00875 side = front < 0;
00876 //first put the end part of the line on the stack (back side)
00877 VectorCopy(cur_mid, tstack_p->start);
00878 //not necesary to store because still on stack
00879 //VectorCopy(cur_end, tstack_p->end);
00880 tstack_p->planenum = aasnode->planenum;
00881 tstack_p->nodenum = aasnode->children[!side];
00882 tstack_p++;
00883 if (tstack_p >= &tracestack[127])
00884 {
00885 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00886 return numareas;
00887 } //end if
00888 //now put the part near the start of the line on the stack so we will
00889 //continue with thats part first. This way we'll find the first
00890 //hit of the bbox
00891 VectorCopy(cur_start, tstack_p->start);
00892 VectorCopy(cur_mid, tstack_p->end);
00893 tstack_p->planenum = tmpplanenum;
00894 tstack_p->nodenum = aasnode->children[side];
00895 tstack_p++;
00896 if (tstack_p >= &tracestack[127])
00897 {
00898 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00899 return numareas;
00900 } //end if
00901 } //end else
00902 } //end while
00903 // return numareas;
00904 } //end of the function AAS_TraceAreas
|
|
||||||||||||||||||||
|
Definition at line 449 of file be_aas_sample.c. References AAS_AreaEntityCollision(), aas_node_t, aas_plane_t, aas_trace_t, aas_tracestack_t, aasworld, aas_trace_s::area, aas_s::areasettings, botimport, aas_node_s::children, Com_Memset(), aas_plane_s::dist, DotProduct, aas_tracestack_s::end, aas_trace_s::endpos, aas_trace_s::ent, aas_trace_s::fraction, aas_trace_s::lastarea, aas_s::loaded, aas_tracestack_s::nodenum, aas_s::nodes, aas_plane_s::normal, aas_s::numareasettings, aas_s::numnodes, ON_EPSILON, aas_node_s::planenum, aas_trace_s::planenum, aas_tracestack_s::planenum, aas_s::planes, aas_areasettings_s::presencetype, PRT_ERROR, aas_tracestack_s::start, aas_trace_s::startsolid, aas_plane_s::type, v1, v2, vec3_t, VectorClear, VectorCopy, VectorLength(), VectorMA, VectorNormalize(), and VectorSubtract. Referenced by AAS_BestReachableArea(), AAS_ClientMovementPrediction(), AAS_GetJumpPadInfo(), AAS_OnGround(), AAS_RandomGoalArea(), AAS_Reachability_Elevator(), AAS_Reachability_Grapple(), AAS_Reachability_Jump(), AAS_Reachability_Ladder(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_Teleport(), AAS_Reachability_WalkOffLedge(), AAS_Reachability_WeaponJump(), BotCheckBarrierJump(), BotGapDistance(), and BotReachabilityArea(). 00451 {
00452 int side, nodenum, tmpplanenum;
00453 float front, back, frac;
00454 vec3_t cur_start, cur_end, cur_mid, v1, v2;
00455 aas_tracestack_t tracestack[127];
00456 aas_tracestack_t *tstack_p;
00457 aas_node_t *aasnode;
00458 aas_plane_t *plane;
00459 aas_trace_t trace;
00460
00461 //clear the trace structure
00462 Com_Memset(&trace, 0, sizeof(aas_trace_t));
00463
00464 if (!aasworld.loaded) return trace;
00465
00466 tstack_p = tracestack;
00467 //we start with the whole line on the stack
00468 VectorCopy(start, tstack_p->start);
00469 VectorCopy(end, tstack_p->end);
00470 tstack_p->planenum = 0;
00471 //start with node 1 because node zero is a dummy for a solid leaf
00472 tstack_p->nodenum = 1; //starting at the root of the tree
00473 tstack_p++;
00474
00475 while (1)
00476 {
00477 //pop up the stack
00478 tstack_p--;
00479 //if the trace stack is empty (ended up with a piece of the
00480 //line to be traced in an area)
00481 if (tstack_p < tracestack)
00482 {
00483 tstack_p++;
00484 //nothing was hit
00485 trace.startsolid = qfalse;
00486 trace.fraction = 1.0;
00487 //endpos is the end of the line
00488 VectorCopy(end, trace.endpos);
00489 //nothing hit
00490 trace.ent = 0;
00491 trace.area = 0;
00492 trace.planenum = 0;
00493 return trace;
00494 } //end if
00495 //number of the current node to test the line against
00496 nodenum = tstack_p->nodenum;
00497 //if it is an area
00498 if (nodenum < 0)
00499 {
00500 #ifdef AAS_SAMPLE_DEBUG
00501 if (-nodenum > aasworld.numareasettings)
00502 {
00503 botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: -nodenum out of range\n");
00504 return trace;
00505 } //end if
00506 #endif //AAS_SAMPLE_DEBUG
00507 //botimport.Print(PRT_MESSAGE, "areanum = %d, must be %d\n", -nodenum, AAS_PointAreaNum(start));
00508 //if can't enter the area because it hasn't got the right presence type
00509 if (!(aasworld.areasettings[-nodenum].presencetype & presencetype))
00510 {
00511 //if the start point is still the initial start point
00512 //NOTE: no need for epsilons because the points will be
00513 //exactly the same when they're both the start point
00514 if (tstack_p->start[0] == start[0] &&
00515 tstack_p->start[1] == start[1] &&
00516 tstack_p->start[2] == start[2])
00517 {
00518 trace.startsolid = qtrue;
00519 trace.fraction = 0.0;
00520 VectorClear(v1);
00521 } //end if
00522 else
00523 {
00524 trace.startsolid = qfalse;
00525 VectorSubtract(end, start, v1);
00526 VectorSubtract(tstack_p->start, start, v2);
00527 trace.fraction = VectorLength(v2) / VectorNormalize(v1);
00528 VectorMA(tstack_p->start, -0.125, v1, tstack_p->start);
00529 } //end else
00530 VectorCopy(tstack_p->start, trace.endpos);
00531 trace.ent = 0;
00532 trace.area = -nodenum;
00533 // VectorSubtract(end, start, v1);
00534 trace.planenum = tstack_p->planenum;
00535 //always take the plane with normal facing towards the trace start
00536 plane = &aasworld.planes[trace.planenum];
00537 if (DotProduct(v1, plane->normal) > 0) trace.planenum ^= 1;
00538 return trace;
00539 } //end if
00540 else
00541 {
00542 if (passent >= 0)
00543 {
00544 if (AAS_AreaEntityCollision(-nodenum, tstack_p->start,
00545 tstack_p->end, presencetype, passent,
00546 &trace))
00547 {
00548 if (!trace.startsolid)
00549 {
00550 VectorSubtract(end, start, v1);
00551 VectorSubtract(trace.endpos, start, v2);
00552 trace.fraction = VectorLength(v2) / VectorLength(v1);
00553 } //end if
00554 return trace;
00555 } //end if
00556 } //end if
00557 } //end else
00558 trace.lastarea = -nodenum;
00559 continue;
00560 } //end if
00561 //if it is a solid leaf
00562 if (!nodenum)
00563 {
00564 //if the start point is still the initial start point
00565 //NOTE: no need for epsilons because the points will be
00566 //exactly the same when they're both the start point
00567 if (tstack_p->start[0] == start[0] &&
00568 tstack_p->start[1] == start[1] &&
00569 tstack_p->start[2] == start[2])
00570 {
00571 trace.startsolid = qtrue;
00572 trace.fraction = 0.0;
00573 VectorClear(v1);
00574 } //end if
00575 else
00576 {
00577 trace.startsolid = qfalse;
00578 VectorSubtract(end, start, v1);
00579 VectorSubtract(tstack_p->start, start, v2);
00580 trace.fraction = VectorLength(v2) / VectorNormalize(v1);
00581 VectorMA(tstack_p->start, -0.125, v1, tstack_p->start);
00582 } //end else
00583 VectorCopy(tstack_p->start, trace.endpos);
00584 trace.ent = 0;
00585 trace.area = 0; //hit solid leaf
00586 // VectorSubtract(end, start, v1);
00587 trace.planenum = tstack_p->planenum;
00588 //always take the plane with normal facing towards the trace start
00589 plane = &aasworld.planes[trace.planenum];
00590 if (DotProduct(v1, plane->normal) > 0) trace.planenum ^= 1;
00591 return trace;
00592 } //end if
00593 #ifdef AAS_SAMPLE_DEBUG
00594 if (nodenum > aasworld.numnodes)
00595 {
00596 botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: nodenum out of range\n");
00597 return trace;
00598 } //end if
00599 #endif //AAS_SAMPLE_DEBUG
00600 //the node to test against
00601 aasnode = &aasworld.nodes[nodenum];
00602 //start point of current line to test against node
00603 VectorCopy(tstack_p->start, cur_start);
00604 //end point of the current line to test against node
00605 VectorCopy(tstack_p->end, cur_end);
00606 //the current node plane
00607 plane = &aasworld.planes[aasnode->planenum];
00608
00609 switch(plane->type)
00610 {/*FIXME: wtf doesn't this work? obviously the axial node planes aren't always facing positive!!!
00611 //check for axial planes
00612 case PLANE_X:
00613 {
00614 front = cur_start[0] - plane->dist;
00615 back = cur_end[0] - plane->dist;
00616 break;
00617 } //end case
00618 case PLANE_Y:
00619 {
00620 front = cur_start[1] - plane->dist;
00621 back = cur_end[1] - plane->dist;
00622 break;
00623 } //end case
00624 case PLANE_Z:
00625 {
00626 front = cur_start[2] - plane->dist;
00627 back = cur_end[2] - plane->dist;
00628 break;
00629 } //end case*/
00630 default: //gee it's not an axial plane
00631 {
00632 front = DotProduct(cur_start, plane->normal) - plane->dist;
00633 back = DotProduct(cur_end, plane->normal) - plane->dist;
00634 break;
00635 } //end default
00636 } //end switch
00637 // bk010221 - old location of FPE hack and divide by zero expression
00638 //if the whole to be traced line is totally at the front of this node
00639 //only go down the tree with the front child
00640 if ((front >= -ON_EPSILON && back >= -ON_EPSILON))
00641 {
00642 //keep the current start and end point on the stack
00643 //and go down the tree with the front child
00644 tstack_p->nodenum = aasnode->children[0];
00645 tstack_p++;
00646 if (tstack_p >= &tracestack[127])
00647 {
00648 botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n");
00649 return trace;
00650 } //end if
00651 } //end if
00652 //if the whole to be traced line is totally at the back of this node
00653 //only go down the tree with the back child
00654 else if ((front < ON_EPSILON && back < ON_EPSILON))
00655 {
00656 //keep the current start and end point on the stack
00657 //and go down the tree with the back child
00658 tstack_p->nodenum = aasnode->children[1];
00659 tstack_p++;
00660 if (tstack_p >= &tracestack[127])
00661 {
00662 botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n");
00663 return trace;
00664 } //end if
00665 } //end if
00666 //go down the tree both at the front and back of the node
00667 else
00668 {
00669 tmpplanenum = tstack_p->planenum;
00670 // bk010221 - new location of divide by zero (see above)
00671 if ( front == back ) front -= 0.001f; // bk0101022 - hack/FPE
00672 //calculate the hitpoint with the node (split point of the line)
00673 //put the crosspoint TRACEPLANE_EPSILON pixels on the near side
00674 if (front < 0) frac = (front + TRACEPLANE_EPSILON)/(front-back);
00675 else frac = (front - TRACEPLANE_EPSILON)/(front-back); // bk010221
00676 //
00677 if (frac < 0)
00678 frac = 0.001f; //0
00679 else if (frac > 1)
00680 frac = 0.999f; //1
00681 //frac = front / (front-back);
00682 //
00683 cur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac;
00684 cur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac;
00685 cur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac;
00686
00687 // AAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED);
00688 //side the front part of the line is on
00689 side = front < 0;
00690 //first put the end part of the line on the stack (back side)
00691 VectorCopy(cur_mid, tstack_p->start);
00692 //not necesary to store because still on stack
00693 //VectorCopy(cur_end, tstack_p->end);
00694 tstack_p->planenum = aasnode->planenum;
00695 tstack_p->nodenum = aasnode->children[!side];
00696 tstack_p++;
00697 if (tstack_p >= &tracestack[127])
00698 {
00699 botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n");
00700 return trace;
00701 } //end if
00702 //now put the part near the start of the line on the stack so we will
00703 //continue with thats part first. This way we'll find the first
00704 //hit of the bbox
00705 VectorCopy(cur_start, tstack_p->start);
00706 VectorCopy(cur_mid, tstack_p->end);
00707 tstack_p->planenum = tmpplanenum;
00708 tstack_p->nodenum = aasnode->children[side];
00709 tstack_p++;
00710 if (tstack_p >= &tracestack[127])
00711 {
00712 botimport.Print(PRT_ERROR, "AAS_TraceBoundingBox: stack overflow\n");
00713 return trace;
00714 } //end if
00715 } //end else
00716 } //end while
00717 // return trace;
00718 } //end of the function AAS_TraceClientBBox
|
Here is the call graph for this function:

1.3.9.1