Sega Saturn Development > Project announcement

what p64 does

<< < (2/2)

ponut64:
In stumbling about with true box-to-box collision detection (rather than only points), I stumbled on an alternate way to test a point against a normal.
It's helpful to share this, because it's basically 16-bit.


--- Code: ---
Sint32 pt_col_plane(Sint16 planept[XYZ], Sint16 ptoffset[XYZ], Sint16 normal[XYZ], Sint16 offset[XYZ])
{
//Using a NORMAL OF A PLANE which is also a POINT ON THE PLANE and checking IF A POINT IS ON THAT PLANE

//the REAL POSITION of the normal, which is also a POINT ON THE PLANE, needs an actual position. WE FIND IT HERE.
Sint16 realNormal[XYZ] = {normal[X] - offset[X], normal[Y] - offset[Y], normal[Z] - offset[Z]};
Sint16 realpt[XYZ] = {planept[X] + ptoffset[X], planept[Y] + ptoffset[Y], planept[Z] + ptoffset[Z]};

//the DIFFERENCE between a POSSIBLE POINT ON THE PLANE, and a KNOWN POINT ON THE PLANE, must use the REAL POSITION of the NORMAL POINT.
Sint16 pNn[XYZ] = {realNormal[X] - realpt[X], realNormal[Y] - realpt[Y], realNormal[Z] - realpt[Z]};

//The NORMAL of the plane has NO REAL POSITION. it is FROM ORIGIN. We use the normal here.
//If the dot product here is zero, the point lies on the plane.
       //The dot product being negative or positive can be used to determine whether the point has passed the plane.
Sint32 dot;
dot = vectori_dot(pNn, normal);

return dot;
}

--- End code ---

If you're wondering what else I would use, its separating axis theorem, which while simple to explain is much more verbose in code so I'll not go into that much more.

Navigation

[0] Message Index

[*] Previous page

Sitemap 1 2 3 4 5 6 7 8 9 10 
Go to full version