Fundamental issue: need to warp pyramid (I'll explain)

Download: WarpedRectange.rbxl (66.3 KB)
Just press play and mess around for a bit

Alright, on with the post:

This is what I see:


Notice in the bottom right, the selection box:
https://i.gyazo.com/94c983bbf9e8441fcde2795c717ac997.mp4

For each corner of the selection box, using camera:ScreenPointToRay(x,y) I create a long edge part that shows the corner of my view:



You’ll notice the black shape. That’s just a regular square-based pyramid made by union-ing four corner wedges. I then get the: center of the four ends, of those rays. that were the corners of selection box, get the camera’s position, and set the cframe to in between those two.

I thought this would work, but I didn’t anticipate the warping that happens:

the resulting “rectangle” as viewed from the top when flattened:

The reason I’m doing all this is because I want to create a selection tool for roblox, and the method I’ve decided to use is workspace:GetPartsInPart(). It’s the most performant option I’ve found, and I know it works because I used it for a digital camera in one of my projects. The camera was in the center, therefore no warping.

I’ve been suggested to create 8 corners for each part in the workspace, a workspace with models of potentially thousands of parts, and they constantly change, move, more get added, etc.
I just don’t see how that won’t cause me to run at 10 fps every time my selection tool is out.

Any other methods of selection I could potentially use? Maybe only doing the center of each part instead of 8 corners, or maybe I can create my view pyramid out of multiple parts somehow…

Either way, please leave suggestions.

Thanks!

I could wrap my pyramid in more corner wedges:


Then I’d have to remove all the children of all the returned parts, then I’d have to clear any duplicates, and only then will I have an array of parts to select. Mind you this is happening every time I move the mouse, so I believe frame drops are unavoidable.

Please, leave suggestions or ideas :pray:

You could just get a 2d position of all the parts and then run a check on what parts are within the selection box. That’s what most people do.

I want you to think about how what you’re doing is mathematically different from projecting the corners into the screen and checking them against a rectangle.