Harry
Member
|
Different results when using Physics.ray with callback and without it
Hi,
I check these two codes:
Code:
PhysHit bd;
if(Physics.ray(start, end-start,&bd)){
D.dot(RED,PosToScreen(bd.plane.pos));
D.line(GREEN,posi,bd.plane.pos);
}
BulletDetection bd2;
Physics.ray(start, end-start, bd2);
if(!bd2.sky){ // if hitted any objet
D.dot(YELLOW,PosToScreen(bd2.phys_hit.plane.pos));
D.line(BLUE,posi,bd2.phys_hit.plane.pos);
}
where BulletDetection:
Code:
struct BulletDetection :PhysHitCallback
{
PhysHit phys_hit;
Bool sky;
virtual Bool hit(PhysHit &phys_hit);
BulletDetection(){sky=true;}
};
When hit is called i save phys_hit informations for further use and set sky to false. These two codes give me different result when I aim objects embedded into terrain what ou can see on screenshot: http://i46.tinypic.com/2nlws9c.jpg
Did I understand something wrong or it is bug in engine? I think that using callback for detecting which type of object bullet hits is better solution than using Physics.ray without callback?
|
|
01-05-2013 10:38 PM |
|
Esenthel
Administrator
|
RE: Different results when using Physics.ray with callback and without it
callback version reports all contacts, not just first one
|
|
01-06-2013 10:48 PM |
|
Harry
Member
|
RE: Different results when using Physics.ray with callback and without it
|
|
01-07-2013 03:26 PM |
|
Esenthel
Administrator
|
RE: Different results when using Physics.ray with callback and without it
Quote:only first contact?
first contact in the callback does not need to be the closest one
(they're not sorted in the callback)
|
|
01-12-2013 03:47 PM |
|
Harry
Member
|
RE: Different results when using Physics.ray with callback and without it
So if I want only detect first collision I should use PhysHit instead of callback?
|
|
01-13-2013 01:18 PM |
|
fatcoder
Member
|
RE: Different results when using Physics.ray with callback and without it
Yes, that is correct.
(This post was last modified: 01-14-2013 06:19 AM by fatcoder.)
|
|
01-14-2013 06:17 AM |
|