The box function in Ue4

Source: Internet
Author: User

1 voidAhud::getactorsinselectionrectangle (tsubclassof<classAactor> Classfilter,Constfvector2d& Firstpoint,Constfvector2d& Secondpoint, tarray<aactor*>& outactors,BOOLBincludenoncollidingcomponents,BOOLbactormustbefullyenclosed)2 {3     //Because This is a HUD function it's likely to get called each tick,4     //So make sure any previous contents of the An Out actor array has been cleared!5 outactors.empty ();6 7     //Create Selection Rectangle from Points8Fbox2d Selectionrectangle (0);9 Ten     //This method ensures a appropriate rectangle is generated, One     //no matter what is the coordinates of first and second point actually is. ASelectionrectangle + =Firstpoint; -Selectionrectangle + =Secondpoint; -  the  -     //The Actor Bounds point Mapping -     ConstFvector boundspointmapping[8] = -     { +Fvector (1,1,1), -Fvector (1,1, -1), +Fvector (1, -1,1), AFvector (1, -1, -1), atFvector (-1,1,1), -Fvector (-1,1, -1), -Fvector (-1, -1,1), -Fvector (-1, -1, -1) -     }; -  in     //~~~ -  to     //For each Actor of the Class Filter Type +      for(Tactoriterator<aactor> Itr (Getworld (), classfilter); ITR; ++Itr) -     { theaactor* eachactor = *Itr; *  $         //Get Actor Bounds//casting to base class, checked by template in the. hPanax Notoginseng         ConstFbox eachactorbounds = cast<aactor> (eachactor)->getcomponentsboundingbox (bIncludeNonCollidingComponents) ;/*All components ?*/ -  the         //Center +         ConstFvector Boxcenter =Eachactorbounds.getcenter (); A  the         //extents +         ConstFvector boxextents =eachactorbounds.getextent (); -  $         //Build 2D bounding box of actor in screen space $Fbox2d actorbox2d (0); -          for(Uint8 Boundspointitr =0; Boundspointitr <8; boundspointitr++) -         { the             //Project vert into screen space. -             ConstFvector projectedworldlocation = Project (Boxcenter + (BOUNDSPOINTMAPPING[BOUNDSPOINTITR] *boxextents));Wuyi             //Add to 2D bounding box theactorbox2d + =fvector2d (projectedworldlocation.x, PROJECTEDWORLDLOCATION.Y); -         } Wu  -         //Selection Box must fully enclose the projected Actor Bounds About         if(bactormustbefullyenclosed) $         { -             if(Selectionrectangle.isinside (actorbox2d)) -             { -Outactors.add (cast<aactor>(Eachactor)); A             } +         } the         //Partial intersection with projected Actor Bounds -         Else $         { the             if(Selectionrectangle.intersect (actorbox2d)) the             { theOutactors.add (cast<aactor>(Eachactor)); the             } -         } in     } the}

The box function in Ue4

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.