bool seg:: extendBy ( const vec3& pt ) { // TODO: This only handles cases where the point is along the "positive" direction // of travel. If it were along the "negative", we should move pos and extend length. // vec3 ptDir = pt - pos; vec3 ptDir ( pt ); ptDir -= pos; ptDir.normalize (); vec3 tDir ( dir ); tDir.normalize (); if ( ! tDir.equal ( ptDir ) ) { return false; } length = pt.dist ( pos ); return true; }
// OPTIMIZE: NON-OPTIMAL int seg:: contains ( const vec3& pt ) const { // TODO: There are some expensive calls in here. Find a more optimal means of doing this. if ( pt.equal ( pos ) ) return containsResult::AllIn; vec3 endPt ( dir ); endPt *= length; endPt += pos; if ( pt.equal ( endPt ) ) return containsResult::AllIn; // vec3 ptDir = pt - pos; vec3 ptDir ( pt ); ptDir -= pos; vec3 a = ptDir; a.normalize (); // Direction vectors the same? if ( ! a.equal ( dir ) ) { // Nope. We're not in/on the segment. return containsResult::NoneIn; } // The direction vectors are the same, so what is our distance from the endpoint? if ( ptDir.length () <= length ) { return containsResult::AllIn; } return containsResult::NoneIn; }
void VisitorLandsideBehavior::setDestination( const ARCVector3& p ,MobDir emWalk ) { //destination is equal to current location ASSERT(m_pPerson->getType().GetTypeIndex() != 0); //carrion that defines relative position should use own relative position PaxOnboardBaseBehavior* spCarrionBehavior = m_pPerson->getOnboardBehavior(); //ASSERT(spCarrionBehavior); if (!m_pPerson->m_pGroupInfo->IsFollower()) { PaxVisitor* pVisitor = (PaxVisitor*)m_pPerson; Passenger* pOwner = pVisitor->GetOwner(); if (pOwner && pOwner->GetVisitorItemByType(pVisitor->getType().GetTypeIndex()))//does not separate with passenger { CGroupLeaderInfo* pGroupLeader = (CGroupLeaderInfo*)(m_pPerson->m_pGroupInfo); if (pGroupLeader->isInGroup())//separate with group { LandsideBaseBehavior* spOwnerBehavior = pOwner->getLandsideBehavior(); ASSERT(spOwnerBehavior); ARCVector3 _OwnerPreLocation = spOwnerBehavior->location; ARCVector3 OwnerLocation = spOwnerBehavior->m_ptDestination; if (_OwnerPreLocation == OwnerLocation && spOwnerBehavior->getState() != EntryLandside)//can not calculate direction of passenger and current location { m_ptDestination = p; SetFollowerDestination(location,m_ptDestination,Person::m_pRotation); return; } ARCVector3 paxDirection(_OwnerPreLocation, OwnerLocation); ARCVector3 paxLogPoint = _OwnerPreLocation; Point ptDir(paxDirection[VX],paxDirection[VY],paxDirection[VZ]); Point ptCenter(paxLogPoint.n[VX],paxLogPoint.n[VY],paxLogPoint.n[VZ]); CNonPaxRelativePosSpec* pNonPaxRelPosSpec = pVisitor->GetTerminal()->GetNonPaxRelativePosSpec(); ASSERT(pNonPaxRelPosSpec); CPoint2008 ptRelatePos; ARCVector4 rotation; bool bRes = pNonPaxRelPosSpec->GetNonPaxRelatePosition(ptRelatePos, rotation, pVisitor->getType().GetTypeIndex()); if (bRes) { Point vectorLat( ptRelatePos.getX(),ptRelatePos.getY(), 0.0); double dAngle = GetRotateAngle(emWalk); Point dir(paxDirection.n[VX],paxDirection.n[VY],paxDirection.n[VZ]); Point ptRotate(paxLogPoint.n[VX],paxLogPoint.n[VY],paxLogPoint.n[VZ]); dir.rotate(dAngle); dir.Normalize(); vectorLat.rotate(dir, ptRotate); ARCVector3 vectorPt; vectorPt.n[VX] = vectorLat.getX(); vectorPt.n[VY] = vectorLat.getY(); vectorPt.n[VZ] = paxLogPoint.n[VZ]; setLocation(vectorPt); SetRelativePosition(ptDir,ptCenter,emWalk); return; } } } m_ptDestination = p; SetFollowerDestination(location,m_ptDestination,Person::m_pRotation); } //separate with passenger or not in group m_ptDestination = p; }
BOOL scanDir( LPTSTR tDir, List* resList, Item* parentItem, BOOL fstLevel, BOOL dbg ) { TCHAR dirStr[ MAX_PATH ] = { 0 }; HANDLE hFind = INVALID_HANDLE_VALUE; Item currentItem = { 0 }; LARGE_INTEGER parentSize = { 0 }; LARGE_INTEGER currentSize = { 0 }; // Prepare string for use with FindFile functions. First, copy the // string to a buffer, then append '\*' to the directory name. wcscpy_s( dirStr, MAX_PATH, tDir ); if ( dirStr[ wcslen( dirStr ) - 1 ] == TEXT( '\\' ) ) wcscat_s( dirStr, MAX_PATH, TEXT( "*" ) ); else wcscat_s( dirStr, MAX_PATH, TEXT( "\\*" ) ); // Find the first file in the directory. hFind = FindFirstFile( dirStr, ¤tItem.findInfo ); // Validate search handle if ( INVALID_HANDLE_VALUE == hFind ) { // Only report error if different from 'Access Denied'. // For example, system symbolic links report 'access denied'. // If a handle is obtained and the size is requested, // Win32 reports 0 bytes. // See results using '..\progsDev\others\TestGetFileSizeEx\' if ( GetLastError() != ERROR_ACCESS_DENIED ) ReportError( TEXT( "FindFirstFile failed." ), 0, TRUE ); // Exit in any case return FALSE; } // List all the files/subdirs in the directory do { // Do not follow symbolic links // Symbolic links are listed but, // they do not affect dirs nor files count // Their size (0 bytes) and date are taken into account if ( !( currentItem.findInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT ) ) { // Subdirectory found ? if ( currentItem.findInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { // Dir found // Skip '.' or '..' if ( ptDir( currentItem.findInfo.cFileName ) ) continue; // Increment dirs count of parent ++parentItem->dirsCount.QuadPart; // Prepare the recursive call wcscpy_s( dirStr, MAX_PATH, tDir ); wcscat_s( dirStr, MAX_PATH, TEXT( "\\" ) ); wcscat_s( dirStr, MAX_PATH, currentItem.findInfo.cFileName ); // Debug output if ( dbg ) wprintf_s( TEXT( " %s\n" ), dirStr ); // Scan subdir scanDir( dirStr, resList, ¤tItem, FALSE, dbg ); // Update dirs count of parent using found subdirs parentItem->dirsCount.QuadPart += currentItem.dirsCount.QuadPart; // Update files count of parent using found files parentItem->filesCount.QuadPart += currentItem.filesCount.QuadPart; } else { // File found // Increment files count of parent ++parentItem->filesCount.QuadPart; // Current item has one file currentItem.filesCount.QuadPart = 1; } } // Update last write time information of the parent. // Is current item's LastWriteTime later // than parent's LastWriteTime ? if ( CompareFileTime( ¤tItem.findInfo.ftLastWriteTime, &parentItem->findInfo.ftLastWriteTime ) == 1 ) { // Parent gets the LastWriteTime from current item parentItem->findInfo.ftLastWriteTime = currentItem.findInfo.ftLastWriteTime; } // Get size of current found file(s) currentSize.LowPart = currentItem.findInfo.nFileSizeLow; currentSize.HighPart = currentItem.findInfo.nFileSizeHigh; // Get size of parent so far parentSize.LowPart = parentItem->findInfo.nFileSizeLow; parentSize.HighPart = parentItem->findInfo.nFileSizeHigh; // Add current size to parent size (64-bit addition) parentSize.QuadPart += currentSize.QuadPart; // Update parent file size parentItem->findInfo.nFileSizeLow = parentSize.LowPart; parentItem->findInfo.nFileSizeHigh = parentSize.HighPart; // Update list if ( fstLevel ) { // Append current item to results list if ( AddItem( currentItem, resList ) == false ) { wprintf_s( TEXT( "Problem allocating memory\n" ) ); return FALSE; } } // Reset current item memset( ¤tItem, 0, sizeof( Item ) ); } while ( FindNextFile( hFind, ¤tItem.findInfo ) != 0 ); // Validate end of search if ( GetLastError() != ERROR_NO_MORE_FILES ) { ReportError( TEXT( "\nFindNextFile failed.\n" ), 0, TRUE ); return FALSE; } // Close search handle FindClose( hFind ); return TRUE; }