05-29-2014, 09:10 PM
Your printing doubles as integers. use %f
Random Chitchat 2012-2016
|
05-29-2014, 10:27 PM
You should do a ray-sphere (or box) intersection for this.
05-29-2014, 10:52 PM
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.
05-30-2014, 01:17 AM
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).
05-30-2014, 01:32 AM
(05-29-2014, 10:52 PM)STR_Warrior Wrote:FakeTruth Wrote:You should do a ray-sphere (or box) intersection for this. Either way ray-sphere intersection is really fast too (ever heard of raytracers?), you should not worry about the performance with that 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.
05-30-2014, 02:36 AM
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.
05-30-2014, 02:45 AM
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.
05-30-2014, 02:58 AM
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.
(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 product Also you need to scale it somehow by the distance, otherwise it won't be perspectively correct.
05-30-2014, 03:08 AM
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.
|
« Next Oldest | Next Newest »
|