| 337 | } |
| 338 | |
| 339 | void NavPath::resize() |
| 340 | { |
| 341 | if(!mPoints.size()) |
| 342 | { |
| 343 | mObjBox.set(Point3F(-0.5f, -0.5f, -0.5f), |
| 344 | Point3F( 0.5f, 0.5f, 0.5f)); |
| 345 | resetWorldBox(); |
| 346 | setTransform(MatrixF(true)); |
| 347 | return; |
| 348 | } |
| 349 | |
| 350 | Point3F max(mPoints[0]), min(mPoints[0]), pos(0.0f); |
| 351 | for(U32 i = 1; i < mPoints.size(); i++) |
| 352 | { |
| 353 | Point3F p = mPoints[i]; |
| 354 | max.x = getMax(max.x, p.x); |
| 355 | max.y = getMax(max.y, p.y); |
| 356 | max.z = getMax(max.z, p.z); |
| 357 | min.x = getMin(min.x, p.x); |
| 358 | min.y = getMin(min.y, p.y); |
| 359 | min.z = getMin(min.z, p.z); |
| 360 | pos += p; |
| 361 | } |
| 362 | pos /= mPoints.size(); |
| 363 | min -= Point3F(0.5f, 0.5f, 0.5f); |
| 364 | max += Point3F(0.5f, 0.5f, 0.5f); |
| 365 | |
| 366 | mObjBox.set(min - pos, max - pos); |
| 367 | MatrixF mat = Parent::getTransform(); |
| 368 | mat.setPosition(pos); |
| 369 | Parent::setTransform(mat); |
| 370 | } |
| 371 | |
| 372 | bool NavPath::plan() |
| 373 | { |