| 422 | static Frustum gDragFrustum; |
| 423 | |
| 424 | void ForestSelectionTool::onRender2D() |
| 425 | { |
| 426 | // Draw drag selection rect. |
| 427 | if ( mDragSelect && mDragRect.extent.x > 1 && mDragRect.extent.y > 1 ) |
| 428 | GFX->getDrawUtil()->drawRect( mDragRect, mDragRectColor ); |
| 429 | |
| 430 | // update what is in the selection |
| 431 | if ( mDragSelect ) |
| 432 | mDragSelection.clear(); |
| 433 | |
| 434 | // Determine selected objects based on the drag box touching |
| 435 | // a mesh if a drag operation has begun. |
| 436 | if ( mDragSelect && mDragRect.extent.x > 1 && mDragRect.extent.y > 1 ) |
| 437 | { |
| 438 | // Build the drag frustum based on the rect |
| 439 | F32 wwidth; |
| 440 | F32 wheight; |
| 441 | F32 aspectRatio = F32(mEditor->getWidth()) / F32(mEditor->getHeight()); |
| 442 | |
| 443 | const CameraQuery &lastCameraQuery = mEditor->getLastCameraQuery(); |
| 444 | if(!lastCameraQuery.ortho) |
| 445 | { |
| 446 | wheight = lastCameraQuery.nearPlane * mTan(lastCameraQuery.fov / 2); |
| 447 | wwidth = aspectRatio * wheight; |
| 448 | } |
| 449 | else |
| 450 | { |
| 451 | wheight = lastCameraQuery.fov; |
| 452 | wwidth = aspectRatio * wheight; |
| 453 | } |
| 454 | |
| 455 | F32 hscale = wwidth * 2 / F32(mEditor->getWidth()); |
| 456 | F32 vscale = wheight * 2 / F32(mEditor->getHeight()); |
| 457 | |
| 458 | Point2I editorPosition = mEditor->getPosition(); |
| 459 | F32 left = (mDragRect.point.x - editorPosition.x) * hscale - wwidth; |
| 460 | F32 right = (mDragRect.point.x - editorPosition.x + mDragRect.extent.x) * hscale - wwidth; |
| 461 | F32 top = wheight - vscale * (mDragRect.point.y - editorPosition.y); |
| 462 | F32 bottom = wheight - vscale * (mDragRect.point.y - editorPosition.y + mDragRect.extent.y); |
| 463 | gDragFrustum.set(lastCameraQuery.ortho, left, right, top, bottom, lastCameraQuery.nearPlane, lastCameraQuery.farPlane, lastCameraQuery.cameraMatrix ); |
| 464 | |
| 465 | mForest->getData()->getItems( gDragFrustum, &mDragSelection ); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | bool ForestSelectionTool::updateGuiInfo() |
| 470 | { |
nothing calls this directly
no test coverage detected