| 406 | } |
| 407 | |
| 408 | void BoxBrush::rebuild() |
| 409 | { |
| 410 | PROFILE_SCOPE( TerrainEditor_BoxBrush_Rebuild ); |
| 411 | |
| 412 | reset(); |
| 413 | |
| 414 | const F32 squareSize = mGridPoint.terrainBlock->getSquareSize(); |
| 415 | |
| 416 | mRenderList.setSize(mSize.x*mSize.y); |
| 417 | |
| 418 | Point3F center( F32(mSize.x - 1) / 2.0f * squareSize, F32(mSize.y - 1) / 2.0f * squareSize, 0.0f ); |
| 419 | |
| 420 | Filter filter; |
| 421 | filter.set(1, &mTerrainEditor->mSoftSelectFilter); |
| 422 | |
| 423 | const Point3F mousePos = mTerrainEditor->getMousePos(); |
| 424 | |
| 425 | F32 xFactorScale = center.x / ( center.x + 0.5f ); |
| 426 | F32 yFactorScale = center.y / ( center.y + 0.5f ); |
| 427 | |
| 428 | const F32 softness = mTerrainEditor->getBrushSoftness(); |
| 429 | const F32 pressure = mTerrainEditor->getBrushPressure(); |
| 430 | |
| 431 | Point3F posw( 0,0,0 ); |
| 432 | Point2I posg( 0,0 ); |
| 433 | Vector<GridInfo> infos; |
| 434 | |
| 435 | for ( S32 x = 0; x < mSize.x; x++ ) |
| 436 | { |
| 437 | for(S32 y = 0; y < mSize.y; y++) |
| 438 | { |
| 439 | F32 xFactor = 0.0f; |
| 440 | if ( center.x > 0 ) |
| 441 | xFactor = mAbs( center.x - x ) / center.x * xFactorScale; |
| 442 | |
| 443 | F32 yFactor = 0.0f; |
| 444 | if ( center.y > 0 ) |
| 445 | yFactor = mAbs( center.y - y ) / center.y * yFactorScale; |
| 446 | |
| 447 | S32 &rl = mRenderList[x*mSize.x+y]; |
| 448 | |
| 449 | posw.x = mousePos.x + (F32)x * squareSize - center.x; |
| 450 | posw.y = mousePos.y + (F32)y * squareSize - center.y; |
| 451 | // round to grid coords |
| 452 | GridPoint gridPoint = mGridPoint; |
| 453 | mTerrainEditor->worldToGrid( posw, gridPoint ); |
| 454 | |
| 455 | // Check that the grid point is valid within the terrain. This assumes |
| 456 | // that there is no wrap around past the edge of the terrain. |
| 457 | if(!mTerrainEditor->isPointInTerrain(gridPoint)) |
| 458 | { |
| 459 | rl = -1; |
| 460 | continue; |
| 461 | } |
| 462 | |
| 463 | infos.clear(); |
| 464 | mTerrainEditor->getGridInfos( gridPoint, infos ); |
| 465 |
no test coverage detected