MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / onRender2D

Method onRender2D

Engine/source/forest/editor/forestSelectionTool.cpp:424–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422static Frustum gDragFrustum;
423
424void 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
469bool ForestSelectionTool::updateGuiInfo()
470{

Callers

nothing calls this directly

Calls 10

mTanFunction · 0.85
drawRectMethod · 0.80
getDrawUtilMethod · 0.80
clearMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
getPositionMethod · 0.45
setMethod · 0.45
getItemsMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected