コード例 #1
0
void Level::WorldToGrid(const std::vector<DOUBLE2>& worldPath, std::vector<PathFinder::SimpleNode>& gridPath)
{
	gridPath.clear();

	for (std::vector<DOUBLE2>::const_iterator it = worldPath.cbegin(); it != worldPath.cend(); ++it)
	{
		gridPath.push_back(WorldToGrid(*it));
	}
}
コード例 #2
0
ファイル: win_tests.cpp プロジェクト: MrGurken/Babbalaur
TEST( Space, WorldToGridSpace )
{
    v2 worldPos = MAKE_v2( 16.0f, 16.0f );

    p2 gridPoint = WorldToGrid( worldPos );
    EXPECT_EQ( 0, gridPoint.x );
    EXPECT_EQ( 0, gridPoint.y );

    worldPos.x = 48.0f;
    
    gridPoint = WorldToGrid( worldPos );
    EXPECT_EQ( 1, gridPoint.x );
    EXPECT_EQ( 0, gridPoint.y );

    worldPos.y = 72.0f;

    gridPoint = WorldToGrid( worldPos );
    EXPECT_EQ( 1, gridPoint.x );
    EXPECT_EQ( 2, gridPoint.y );
}