mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
Merge pull request #107 from devZoGok/bf-106-ray-casting
bf-106-ray-casting
This commit is contained in:
+11
-7
@@ -78,13 +78,17 @@ namespace vb01{
|
||||
|
||||
if((distance <= rayLength && rayLength != .0) || rayLength == .0){
|
||||
Vector3 contactPoint = rayPos + rayDir.norm() * distance;
|
||||
float angleA = (pointB - pointA).norm().getAngleBetween((pointC - pointA).norm());
|
||||
float angleB = (pointA - pointB).norm().getAngleBetween((pointC - pointB).norm());
|
||||
float angleC = (pointB - pointC).norm().getAngleBetween((pointA - pointC).norm());
|
||||
Vector3 bisecAVec = ((pointB - pointA) + (pointC - pointA));
|
||||
Vector3 bisecBVec = ((pointA - pointB) + (pointC - pointB));
|
||||
Vector3 bisecCVec = ((pointB - pointC) + (pointA - pointC));
|
||||
float eps = .1;
|
||||
Vector3 vAB = (pointB - pointA);
|
||||
Vector3 vBC = (pointC - pointB);
|
||||
Vector3 vAC = (pointC - pointA);
|
||||
|
||||
float angleA = vAB.norm().getAngleBetween(vAC.norm());
|
||||
float angleB = (-vAB.norm()).getAngleBetween(vBC.norm());
|
||||
float angleC = (-vBC.norm()).getAngleBetween(-vAC.norm());
|
||||
Vector3 bisecAVec = (vAB * vAC.getLength() + vAC * vAB.getLength()).norm();
|
||||
Vector3 bisecBVec = (vBC * vAB.getLength() - vAB * vBC.getLength()).norm();
|
||||
Vector3 bisecCVec = (-vAC * vBC.getLength() - vBC * vAC.getLength()).norm();
|
||||
float eps = .001;
|
||||
bool withinBisecA = ((contactPoint - pointA).norm().getAngleBetween(bisecAVec.norm()) - angleA / 2) <= eps;
|
||||
bool withinBisecB = ((contactPoint - pointB).norm().getAngleBetween(bisecBVec.norm()) - angleB / 2) <= eps;
|
||||
bool withinBisecC = ((contactPoint - pointC).norm().getAngleBetween(bisecCVec.norm()) - angleC / 2) <= eps;
|
||||
|
||||
Reference in New Issue
Block a user