About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Edge cuts problem
Author Message
Zervox Offline
Silver Supporter

Post: #1
Edge cuts problem
The code below will always return true. as long as the box is in the direction of the edge not if the actual end point is in range of it. Is this how it's supposed to be?
Code:
Vec mpos,mdir;

ScreenToPosDir(Ms.pos(), mpos, mdir);

Edge edge(mpos,mpos+mdir*10);

if(Cuts(edge,Box(Vec(obj->pos().x-obj->rad(),obj->pos().y-obj->h()/2,obj->pos().z-obj->rad()),Vec(obj->pos()+obj->rad(),obj->pos().y+obj->h()/2,obj->pos().z+obj->rad()))){
    return true;
}
return false;
(This post was last modified: 09-24-2012 06:51 PM by Zervox.)
09-23-2012 10:45 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #2
RE: Edge cuts problem
1). Edge edge(mpos,mpos+mdir*30); moves from mpos to direction but infinity
2). Edge edge(mpos+mdir*30,mpos);reverse from above, but now the range from the camera is correct


however 2). has the issue of when I am behind the box, it will get selected because edge seems to travel into infinity instead of the pos+mdir or pos+mdir*range

EDIT: further testing shows me that doing 2). the range works but it works in both directions. eg

16.000, 0.000, 16.000
35.618, -22.307, 11.815

35.618, -22.307, 11.815
16.000, 0.000, 16.000

both returns the same vector just in reverse order, how come the very different results? I suspect there is something wrong in Cuts(Edge edge,Box box);
(This post was last modified: 09-24-2012 06:57 PM by Zervox.)
09-24-2012 06:44 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Edge cuts problem
You should get sample edge and box coordinates.
make simple app that draws only the edge and the box, rotate the camera to see if they intersect, then check if the result is consistent with the EE.Cuts function.
If it's not, please provide edge and box floating point coordinates.
09-26-2012 12:46 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #4
RE: Edge cuts problem
the hit is consistent the thing that isn't is that it checks in infinity in one direction while the other direction goes the offset pos+dir*range

Code:
Box box;
Edge edge;


   box.set(Vec(20, -5, -5), Vec(25,5,5));


   {
      Vec     start( 4,0,0), // starting position of ray
              end  (-4,0,0); // ending   position of ray
      edge.set(end-start,start);
      if(Cuts(edge,box)){
          edge.draw(RED);
          box.draw(RED);
      }else{
         edge.draw(YELLOW);
         box.draw(YELLOW);
      }
   }

changing the
Code:
edge.set(end-start,start)
to
Code:
edge.set(start,end-start)

will make them not detect as cutting each other

edge.set(end-start,start) makes them cut eachother even if they are not supposed to.
as the offset location is still the same.

Code:
box1.set(Vec(-25, -5, -5), Vec(-20,5,5));
setting another box on the other side of the ray will result in one of them no matter what order I use edge.set or Edge edge(vec,vec) will be cutting even if the edge should not be touching any of the two to begin with.
(This post was last modified: 09-26-2012 05:42 PM by Zervox.)
09-26-2012 05:03 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Edge cuts problem
Thank you, it's indeed a bug in the Cuts function, I'll fix that for next SDK.
09-26-2012 05:45 PM
Find all posts by this user Quote this message in a reply
Post Reply