Abril
Member
|
[bug?] Physics.ray
Hi EE, we are expecting the physics.ray funciton to return the *closest* object hit by the ray. The documentation found in the header is not clear about that... Looking at RPG2 source code, seems like it is used assuming that returns the closest object (however there are very few physicalized actors in rpg2).
I'd like to have confirmation that physics.ray is returning in the physhit structure the actor closest to pos, not just any actor hit along the ray trajectory. Can you clarify that?
// if ray cuts with any actor on the scene ('groups'=group flag (ACTOR_GROUP) bit combination specifying which groups should be included in testing, use 'IndexToFlag' function)
static Bool ray(C Vec &pos, C Vec &move, PhysHit *phys_hit=NULL, UInt groups=~0);
From the comment in the headers, it kind of looks like is returning intersection with any object along the ray.
However in the rpg2 source code, in the functions
void Cursor::update()
and
void ActionCheck()
Physics.ray is used to highlight the object the player is pointing at.
There are no callbacks used in the rgp2 fucntion calls, so im wondering if the function is actually returning the closest one or it is just working out of luck in rpg2 because the physicalized actors are very few and far apart.
Need to know because this system won't work with higher objects density.
thanks...
(This post was last modified: 01-29-2012 11:12 AM by Abril.)
|
|
01-28-2012 07:51 PM |
|
fatcoder
Member
|
RE: [bug?] Physics.ray
In all tests I've done with it, it has always returned the first actor hit. Perhaps the comment on the function needs to be reworded to make it more clear.
|
|
01-29-2012 12:54 AM |
|
Abril
Member
|
RE: [bug?] Physics.ray
Thanks, good to know. Then one probably needs to use the callback to sort ojects properly.
|
|
01-29-2012 11:09 AM |
|
fatcoder
Member
|
RE: [bug?] Physics.ray
There is two ray() methods. The first one returns true if it hits something and stops at the first object it hits. The second one calls your custom callback function every time it hits an object. It keeps going through the scene up to the move distance and reports every hit.
|
|
01-29-2012 04:34 PM |
|
Abril
Member
|
RE: [bug?] Physics.ray
Yes, the second one with the callback is the one ive mentioned before from the first post, now we know that one has to to use the callback to sort objects properly by distance and not rely on the first physics.ray function.
If you have a situation with lets say a physicliazed weapon item behind a closed door, the rpg2 code could have randomly reported as selected by the player the item behind the door instead of selecting the closed door, depending on the first hit reported by the underlying physics system middleware. Apaprently never happens in rpg2 since you never have more than 1 physicalized object in the same spot (at least from what ive seen , not sure ive explored the entire map tho, but I havent seen any house with few objects inside, so to speak).
|
|
01-29-2012 11:44 PM |
|