bool BotNavTrace( int botClientNum, botTrace_t *trace, const vec3_t start, const vec3_t end ) { dtPolyRef startRef; dtStatus status; rVec extents( 75, 96, 75 ); rVec spos = qVec( start ); rVec epos = qVec( end ); memset( trace, 0, sizeof( *trace ) ); Bot_t *bot = &agents[ botClientNum ]; status = bot->nav->query->findNearestPoly( spos, extents, &bot->nav->filter, &startRef, nullptr ); if ( dtStatusFailed( status ) || startRef == 0 ) { //try larger extents extents[ 1 ] += 500; status = bot->nav->query->findNearestPoly( spos, extents, &bot->nav->filter, &startRef, nullptr ); if ( dtStatusFailed( status ) || startRef == 0 ) { return false; } } status = bot->nav->query->raycast( startRef, spos, epos, &bot->nav->filter, &trace->frac, trace->normal, nullptr, nullptr, 0 ); if ( dtStatusFailed( status ) ) { return false; } recast2quake( trace->normal ); return true; }
botRouteTargetInternal::botRouteTargetInternal( const botRouteTarget_t &target ) : type( target.type ), pos( qVec( target.pos ) ), polyExtents( qVec( target.polyExtents ) ) { for ( int i = 0; i < 3; i++ ) { polyExtents[ i ] = ( polyExtents[ i ] < 0 ) ? -polyExtents[ i ] : polyExtents[ i ]; } }
bool GetPointPointedTo( NavData_t *nav, rVec &p ) { qVec forward; qVec end; rVec extents; rVec pos; trace_t trace; dtPolyRef nearRef; VectorSet( extents, 640, 96, 640 ); AngleVectors( cl.snap.ps.viewangles, forward, nullptr, nullptr ); VectorMA( cl.snap.ps.origin, 8096, forward, end ); CM_BoxTrace( &trace, cl.snap.ps.origin, end, nullptr, nullptr, 0, CONTENTS_SOLID | CONTENTS_PLAYERCLIP, 0, TT_AABB ); pos = qVec( trace.endpos ); if ( dtStatusFailed( nav->query->findNearestPoly( pos, extents, &nav->filter, &nearRef, p ) ) ) { return false; } return true; }
bool BotFindRandomPointInRadius( int botClientNum, const vec3_t origin, vec3_t point, float radius ) { rVec rorigin = qVec( origin ); rVec nearPoint; dtPolyRef nearPoly; VectorSet( point, 0, 0, 0 ); Bot_t *bot = &agents[ botClientNum ]; if ( !BotFindNearestPoly( bot, rorigin, &nearPoly, nearPoint ) ) { return false; } dtPolyRef randRef; dtStatus status = bot->nav->query->findRandomPointAroundCircle( nearPoly, rorigin, radius, &bot->nav->filter, frand, &randRef, nearPoint ); if ( dtStatusFailed( status ) ) { return false; } VectorCopy( nearPoint, point ); recast2quake( point ); return true; }
void eigen2quaternion( const Eigen::Matrix<T_evec,4,1> &qVec, Eigen::Quaternion<T_qt> &quat_Out ) { quat_Out = Eigen::Quaternion<T_qt>( T_qt(qVec(0)), T_qt(qVec(1)), T_qt(qVec(2)), T_qt(qVec(3)) ); };
void GetEntPosition( int num, rVec &pos ) { pos = qVec( SV_GentityNum( num )->s.origin ); }