Ticket #2025: pathfind_test_banch_vanilla_update.patch
File pathfind_test_banch_vanilla_update.patch, 3.5 KB (added by , 11 years ago) |
---|
-
source/simulation2/components/tests/test_Pathfinder.h
68 68 CMapReader* mapReader = new CMapReader(); // it'll call "delete this" itself 69 69 70 70 LDR_BeginRegistering(); 71 mapReader->LoadMap(L"maps/scenarios/Median Oasis .pmp", &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL,71 mapReader->LoadMap(L"maps/scenarios/Median Oasis 01.pmp", &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 72 72 &sim2, &sim2.GetSimContext(), -1, false); 73 73 LDR_EndRegistering(); 74 74 TS_ASSERT_OK(LDR_NonprogressiveLoad()); … … 90 90 printf("%d: %f %f\n", (int)i, path.m_Waypoints[i].x.ToDouble(), path.m_Waypoints[i].z.ToDouble()); 91 91 #endif 92 92 93 double t = timer_Time();94 93 95 94 srand(1234); 95 96 std::vector<ICmpPathfinder::Goal> goals; 97 98 std::vector<entity_pos_t> x0s; 99 std::vector<entity_pos_t> z0s; 96 100 for (size_t j = 0; j < 1024*2; ++j) 97 101 { 98 102 entity_pos_t x0 = entity_pos_t::FromInt(rand() % 512); … … 100 104 entity_pos_t x1 = x0 + entity_pos_t::FromInt(rand() % 64); 101 105 entity_pos_t z1 = z0 + entity_pos_t::FromInt(rand() % 64); 102 106 ICmpPathfinder::Goal goal = { ICmpPathfinder::Goal::POINT, x1, z1 }; 107 x0s.push_back(x0); 108 z0s.push_back(z0); 109 goals.push_back(goal); 110 } 103 111 104 ICmpPathfinder::Path path; 105 cmp->ComputePath(x0, z0, goal, cmp->GetPassabilityClass("default"), cmp->GetCostClass("default"), path); 112 double t = timer_Time(); 113 114 115 ICmpPathfinder::Path path; 116 for (size_t j = 0; j < 1024*2; ++j) 117 { 118 cmp->ComputePath(x0s[j], z0s[j], goals[j], cmp->GetPassabilityClass("default"), cmp->GetCostClass("default"), path); 106 119 } 107 120 108 121 t = timer_Time() - t; 109 printf(" [%f]", t);122 printf("\nTestCmpPathfinder ComputePath[%f]", t); 110 123 } 111 124 112 125 void test_performance_short_DISABLED() … … 124 137 CmpPtr<ICmpPathfinder> cmpPathfinder(sim2, SYSTEM_ENTITY); 125 138 126 139 srand(0); 140 127 141 for (size_t i = 0; i < 200; ++i) 128 142 { 129 143 fixed x = fixed::FromFloat(1.5f*range.ToFloat() * rand()/(float)RAND_MAX); … … 131 145 // printf("# %f %f\n", x.ToFloat(), z.ToFloat()); 132 146 cmpObstructionMan->AddUnitShape(INVALID_ENTITY, x, z, fixed::FromInt(2), 0, INVALID_ENTITY); 133 147 } 148 149 double t = timer_Time(); 134 150 135 NullObstructionFilter filter; 136 ICmpPathfinder::Goal goal = { ICmpPathfinder::Goal::POINT, range, range }; 137 ICmpPathfinder::Path path; 138 cmpPathfinder->ComputeShortPath(filter, range/3, range/3, fixed::FromInt(2), range, goal, 0, path); 139 for (size_t i = 0; i < path.m_Waypoints.size(); ++i) 140 printf("# %d: %f %f\n", (int)i, path.m_Waypoints[i].x.ToFloat(), path.m_Waypoints[i].z.ToFloat()); 151 for (size_t j = 0; j < 1024*2; ++j) 152 { 153 154 NullObstructionFilter filter; 155 ICmpPathfinder::Goal goal = { ICmpPathfinder::Goal::POINT, range, range }; 156 ICmpPathfinder::Path path; 157 158 cmpPathfinder->ComputeShortPath(filter, range/3, range/3, fixed::FromInt(2), range, goal, 0, path); 159 } 160 161 t = timer_Time() - t; 162 163 printf("\nTestCmpPathfinder ComputeShortPath[%f]\n", t); 164 { 165 NullObstructionFilter filter; 166 ICmpPathfinder::Goal goal = { ICmpPathfinder::Goal::POINT, range, range }; 167 ICmpPathfinder::Path path; 168 169 cmpPathfinder->ComputeShortPath(filter, range/3, range/3, fixed::FromInt(2), range, goal, 0, path); 170 for (size_t i = 0; i < path.m_Waypoints.size(); ++i) 171 printf("# %d: %f %f\n", (int)i, path.m_Waypoints[i].x.ToFloat(), path.m_Waypoints[i].z.ToFloat()); 172 } 141 173 } 142 174 };