| 37 | } |
| 38 | |
| 39 | tLoadStatus PathLoader::Load(tChunkFile* f, tEntityStore* store) |
| 40 | { |
| 41 | // parse number of points (must be at least 2 points) |
| 42 | unsigned long int nPoints = f->GetUInt(); |
| 43 | rAssert( nPoints >= 2 ); |
| 44 | |
| 45 | int nSegments = nPoints-1; |
| 46 | |
| 47 | // Get path from PathManager, who keeps a list of Paths |
| 48 | // The manager should be a singleton, so do GetInstance |
| 49 | PathManager* pm = PathManager::GetInstance(); |
| 50 | rAssert( pm != NULL ); |
| 51 | |
| 52 | // Get a free path & set up its segments |
| 53 | Path* path = pm->GetFreePath(); |
| 54 | rAssert( path != NULL ); |
| 55 | |
| 56 | path->AllocateSegments( nSegments ); |
| 57 | |
| 58 | |
| 59 | |
| 60 | PathSegment* ps = NULL; |
| 61 | rmt::Vector first, start, end; |
| 62 | |
| 63 | start.x = f->GetFloat(); |
| 64 | start.y = f->GetFloat(); |
| 65 | start.z = f->GetFloat(); |
| 66 | |
| 67 | first = start; |
| 68 | |
| 69 | float myEpsilon = 0.001f; |
| 70 | |
| 71 | long int i; |
| 72 | for( i=0; i<nSegments; i++ ) |
| 73 | { |
| 74 | end.x = f->GetFloat(); |
| 75 | end.y = f->GetFloat(); |
| 76 | end.z = f->GetFloat(); |
| 77 | |
| 78 | // make sure that the points span a tangible distance |
| 79 | rAssert( !rmt::Epsilon( start.x, end.x, myEpsilon ) || |
| 80 | !rmt::Epsilon( start.y, end.y, myEpsilon ) || |
| 81 | !rmt::Epsilon( start.z, end.z, myEpsilon ) ); |
| 82 | |
| 83 | ps = path->GetPathSegmentByIndex( i ); |
| 84 | ps->Initialize( path, i, start, end ); |
| 85 | |
| 86 | // DSG stuff |
| 87 | mpListenerCB->OnChunkLoaded( ps, mUserData, SRR2::ChunkID::PED_PATH_SEGMENT ); |
| 88 | start = end; |
| 89 | |
| 90 | sNumPathSegmentsLoaded++; |
| 91 | } |
| 92 | /* |
| 93 | int counter = 0; |
| 94 | long int i; |
| 95 | for( i=0; i<(nSegments-1); i = i+2 ) |
| 96 | { |
no test coverage detected