Random Chitchat 2012-2016
Your printing doubles as integers. use %f
Thanks given by: NiLSPACE
You should do a ray-sphere (or box) intersection for this.
Thanks given by:
FakeTruth Wrote:You should do a ray-sphere (or box) intersection for this.

Are you sure? I think this is much faster then using rays in a sphere.
Thanks given by:
Depends on how many endermen there are. If there are few endermen then this method is faster as its O(E*P) but with a lower constant factor. However if there are more endermen then players than doing a ray sphere intersection from a players look vector will be O(P).
Thanks given by:
(05-29-2014, 10:52 PM)STR_Warrior Wrote:
FakeTruth Wrote:You should do a ray-sphere (or box) intersection for this.

Are you sure? I think this is much faster then using rays in a sphere.

Either way ray-sphere intersection is really fast too (ever heard of raytracers?), you should not worry about the performance with thatTongue

If you don't feel like doing that, you could try using a dot product between the direction and look vector, a dot product's result will always be "how much the two vectors are similar" so if they are going in exactly the same direction you get 1, and if they are perpendicular you get 0.
Thanks given by:
I think that the non ray-sphere method is probably better, as ray tracing is slow and we're not expecting 10000 endermen per player area.
Thanks given by:
Raytracers are fast but we don't currently have access to that sort of hardware (I'm working on it, I want to use GPU cores for lighting calcs) and doing it on a CPU is slow. The dot product however is probably a good idea.
Thanks given by:
But isn't that almost the exact thing as what I'm currently doing? I'm checking the difference between two vectors. If the difference is too big then the player is ignored.
Thanks given by:
(05-30-2014, 02:36 AM)bearbin Wrote: I think that the non ray-sphere method is probably better, as ray tracing is slow and we're not expecting 10000 endermen per player area.
Ray tracing is NOT slow. Ray tracing 1920x1080 pixels at 60 frames per second is only difficult because of the sheer amount of traces necessary. Gazillions of sphere intersection calculations can be done per second.

(05-30-2014, 02:58 AM)STR_Warrior Wrote: But isn't that almost the exact thing as what I'm currently doing? I'm checking the difference between two vectors. If the difference is too big then the player is ignored.
Yes I think it's pretty much the same, but you're doing the dot product without explicitly doing a dot productTongue Also you need to scale it somehow by the distance, otherwise it won't be perspectively correct.
Thanks given by:
No, the dot product would be x1*x2 + y1*y2 + z1*z2 and for normalized vectors is equal to the cosine of the angle. What your doing is (x1-x2)2 + (y1-y2)2 + (z1-z2)2 and I don't know what that is.
Thanks given by:




Users browsing this thread: 78 Guest(s)