Prototype/Source/Prototype/Private/Task_UpdateMap.cpp
/* Adds grid holding location gridLoc into map. Increments confidence value if grid already exists.
*
*   @param gridLoc Location to add to map.
*   @param dist Distance between agent and location to add.
*   @return The map index the grid was added to or found at.
*/
Adds grid holding location gridLoc into map. Increments confidence value if grid already exists.
Adds grid holding location gridLoc into map . Increments confidence value if grid already exists .
FGridStruct* AUSARAgent::AddGrid(FVector loc, bool occupied)
{
    float x = SnapToGrid(loc.X);
    float y = SnapToGrid(loc.Y);
    float z = SnapToGrid(loc.Z);
    float conf = CONF_INCR * FVector::Dist(GetActorLocation(), loc) / VISION_RADIUS;
    FGridStruct gridToAdd = FGridStruct(x, y, z, conf, GetWorld()->GetTimeSeconds());
    gridToAdd.occupied = occupied;
    bool isNewGrid;
    FGridStruct* grid = gridToAdd.InsertInMap(envMap, isNewGrid);
    if (!isNewGrid) {
        grid->Combine(gridToAdd);
    }
    else {
        gridsExplored = envMap.Num();
    }
    return grid;
}
FGridStruct * AUSARAgent :: AddGrid ( FVector loc , bool occupied ) { float x = SnapToGrid ( loc . X ) ; float y = SnapToGrid ( loc . Y ) ; float z = SnapToGrid ( loc . Z ) ; float conf = CONF_INCR * FVector :: Dist ( GetActorLocation ( ) , loc ) / VISION_RADIUS ; FGridStruct gridToAdd = FGridStruct ( x , y , z , conf , GetWorld ( ) -> GetTimeSeconds ( ) ) ; gridToAdd . occupied = occupied ; bool isNewGrid ; FGridStruct * grid = gridToAdd . InsertInMap ( envMap , isNewGrid ) ; if ( ! isNewGrid ) { grid -> Combine ( gridToAdd ) ; } else { gridsExplored = envMap . Num ( ) ; } return grid ; }
Adds grid holding location gridLoc into map.
Adds grid holding location gridLoc into map .
/*DEBUGGING*/ //if (showDebug) { //    FVector dbgPt = FVector(grid->x, grid->y, grid->z); //    float ptSize = 3.5; //    FColor c = FColor::Green; //    if (occupied) { //        ptSize = 7; //        c = FColor::Orange; //    } //    DrawDebugPoint(GetWorld(), dbgPt, ptSize, c, false, RATE_MAP_UPDATE); //} /*DEBUGGING*/