Raycasting on Parts that don't Exist

I want to perform raycasts on parts that don’t exist. I have all of the data for these parts (CFrame, Size, anything else you might want) but the actual part objects don’t exist.

What I need to do is run a raycast on these “Fake” parts, this means making my own raycast code. I mostly understand how raycasting works, you split the ray into points (smaller intervals == higher accuracy) and you check if the point is inside the object.

All of that is great, but the main issue I have, is I don’t know how to find out if a point is inside a part, just from the part’s CFrame and Size.

“Why don’t you just instance it?”
Instancing is slow for what I need to do, and doesn’t work well with the rest of my system.

this can be achieved with the formula origin + direction * range

an example of this:

local rayCastResult = --your raycast
local pos = rayCastResult ~= nil and rayCastResult.Position or origin + direction

on a side note, why exactly cant you instance it?

I can’t instance it, because I’m doing serverside bullet hitreg with this, and there are too many bullets to instance in the parts I would need to raycast against.