Quick question.
Like the title says. How much do they cost?
I have a few in my project, and i plan to add some more. Linetraces are extremely useful. Especially those that fire on tick, every frame.
I want to have as many as possible.
Quick question.
Like the title says. How much do they cost?
I have a few in my project, and i plan to add some more. Linetraces are extremely useful. Especially those that fire on tick, every frame.
I want to have as many as possible.
17 cents.
Seriously though, it really depends what you mean by a lot. Tens, probably ok. Thousands, you need to find another way.
Tens are probably ok you say. Well thats good enough for me atm.
Thank you!
The cost of a line trace depends not only on “is it a line trace,” but also on how long the line is (10 units is much cheaper than 10000 units!) and how many objects “could” be hit (approximately, how many objects are in the axis-aligned bounding box of the line.)
So, long, diagonal, lines, across a battlefield: More expensive.
Short, straight down, lines, to find whether you have ground contact: Less expensive.
But, a long trace from the camera, to the sun, if the sun is above (and not on the horizon,) could be totally fine because there’s nothing to test against in the AABB.
In my head, I would estimate the cheapest line trace at 1 microsecond, and the most expensive reasonable line trace at 10 microsecond. If I want to spend 1 ms per frame on just line traces, then I can do 100 big traces, or 1000 small traces. I’m probably off by some factor, though, because I haven’t measured these things for many years, and, again, very long, very diagonal, traces through cluttered environments, are massively more expensive!
That makes perfekt sense. Fortunately most traces that I plan to do are wery short ones.
But I have to ask one thing. what is AABB?
Axis-Aligned Bounding Box.
Btw: I wonder if there’s a good reading list for “general game development concepts” with the basics of 3D math, rendering, and physics somewhere. There’s just tons of things that are not generally taught in computer science (unless you opt in,) that’s very helpful to know.
To start, I can recommend the Real-time Collision Detection book: Amazon.com
But there’s so much more …
Great rule of thumb