Update of /cvsroot/epfl/tgengine-0.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv963 Modified Files: boundingbox.cc glrenderer.cc md5instance.cc md5instance.h physicengine.cc physicengine.h physicnode.cc physicnode.h q3bsp.cc vector3.h Log Message: physic fixes Index: physicengine.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.cc,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** physicengine.cc 13 Nov 2004 23:35:40 -0000 1.23 --- physicengine.cc 15 Nov 2004 21:35:21 -0000 1.24 *************** *** 16,20 **** } ! #define MAXBUMPS 5 void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) --- 16,20 ---- } ! #define MAXBUMPS 10 void PhysicEngine::StepSlideMove(PhysicNode* n, float eTime, Vector3& vVelocity, Vector3 origin) *************** *** 35,42 **** { trace = pLevel->CheckRayMove(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax); if (trace.AllSolid) { - //vVelocity.Null(); vVelocity.y = 0; return; --- 35,43 ---- { trace = pLevel->CheckRayMove(origin, origin+vVelocity*time_left, n->GetBBox()->vMin, n->GetBBox()->vMax); + //on trace avec une sphere, les mouvements sembles plus 'lisses' + //trace = pLevel->CheckRayMove(origin+n->GetBBox()->vBSCenter, origin+n->GetBBox()->vBSCenter+vVelocity*time_left, TRACE_SPHERE, n->GetBBox()->fBSRadius); if (trace.AllSolid) { vVelocity.y = 0; return; *************** *** 101,105 **** Vector3 change = norm*backoff; vel -= change; ! //return (vel - change); } --- 102,160 ---- Vector3 change = norm*backoff; vel -= change; ! } ! ! #define BASE_HEIGHT 5 ! #define STEPSIZE 20 ! ! void PhysicEngine::_TryToStep (PhysicNode* n, float eTime) ! { ! //on essaie de faire monter les petits obstacles sur les y (escaliers, rebords) au joueur. Pour cela, on test si lorsqu'on monte le joueur de STEPSIZE, il arrive à avancer plus sur les x et les z (mais _pas_ les y) ! ////TODO: lorsqu'on monte les escaliers, ça se fait par petit saut (normal, on ajoute 10 a la position en un coup. ! //Il faudrait faire ça de manière à ce qu'on ait l'impression de glisser sur les escaliers ! Vector3 vVelocity = n->GetVelocity(); ! Vector3 vUpVelocity = n->GetVelocity(); ! Vector3 vPos = n->GetPosition(); ! Vector3 vNewPos = vPos; ! Vector3 vUpPos = n->GetPosition() + (Vector3::UNIT_Y*STEPSIZE); ! Vector3 vUpNewPos = vUpPos; ! float distx, distz; ! ! StepSlideMove (n, eTime, vVelocity, vPos); ! vNewPos += vVelocity*eTime; ! distx = (vNewPos.x - vPos.x); ! distx *= distx; ! distz = (vNewPos.z - vPos.z); ! distz *= distz; ! float dist = sqrt(distx+distz); ! ! StepSlideMove (n, eTime, vUpVelocity, vUpPos); ! vUpNewPos += vUpVelocity*eTime; ! distx = (vUpNewPos.x - vUpPos.x); ! distx *= distx; ! distz = (vUpNewPos.z - vUpPos.z); ! distz *= distz; ! float updist = sqrt(distx+distz); ! ! //on verifie que ca ne nous fasse pas rentrer dans le plafond ! BspCollisionResult trace = pLevel->CheckRayMove(vUpPos, vNewPos, n->GetBBox()->vMin, n->GetBBox()->vMax); ! if (trace.AllSolid) ! vUpNewPos = trace.EndPoint; ! ! if (updist > dist) //on passe l'obstacle ! { ! n->SetPosition(/*Vector3(vNewPos.x, vUpNewPos.y, vNewPos.z)*/vUpNewPos); ! } ! else //l'obstacle est trop haut ! { ! n->SetPosition(vNewPos); ! } ! ! //Classification de la position ! BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, n->GetBBox()->vMin, n->GetBBox()->vMax); ! //si on met le allsolid, ca foire les mouvements sur les y ! if (col.Fraction < 1.0f || col.AllSolid) ! n->SetOnGround(true); ! else ! n->SetOnGround(false); } *************** *** 112,117 **** //-> on différenci la taille du joueur et des autres objets pour être sur le sol - #define BASE_HEIGHT 15 - #define STEPSIZE 20*1/0.01 void PhysicEngine::Move (float eTime) { --- 167,170 ---- *************** *** 157,225 **** if (pLevel) { ! //on essaie de faire monter les petits obstacles sur les y (escaliers, rebords) au joueur. Pour cela, on test si lorsqu'on monte ! //le joueur de STEPSIZE, il arrive à avancer plus sur les x et les z (mais _pas_ les y) ! ////TODO: lorsqu'on monte les escaliers, ça se fait par petit saut (normal, on ajoute 10 a la position en un coup. ! //Il faudrait faire ça de manière à ce qu'on ait l'impression de glisser sur les escaliers ! Vector3 vVelocity = n->GetVelocity(); ! Vector3 vUpVelocity = n->GetVelocity(); ! Vector3 vPos = n->GetPosition(); ! Vector3 vNewPos = vPos; ! Vector3 vUpPos = n->GetPosition() + (Vector3::UNIT_Y*STEPSIZE*eTime); ! Vector3 vUpNewPos = vUpPos; ! float distx, distz; ! ! StepSlideMove (n, eTime, vVelocity, vPos); ! vNewPos += vVelocity*eTime; ! distx = (vNewPos.x - vPos.x); ! distx *= distx; ! distz = (vNewPos.z - vPos.z); ! distz *= distz; ! float dist = sqrt(distx+distz); ! ! StepSlideMove (n, eTime, vUpVelocity, vUpPos); ! vUpNewPos += vUpVelocity*eTime; ! distx = (vUpNewPos.x - vUpPos.x); ! distx *= distx; ! distz = (vUpNewPos.z - vUpPos.z); ! distz *= distz; ! float updist = sqrt(distx+distz); ! ! if (updist > dist) //on passe l'obstacle ! { ! //std::cout << "time : " << eTime << "\t" << vUpNewPos << std::endl; ! n->SetPosition(vUpNewPos); ! /*if (vUpVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) ! { ! //std::cout << "callback" << std::endl; ! //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback ! n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ ! } ! else //l'obstacle est trop haut ! { ! //std::cout << "time : " << eTime << "\t" << vNewPos << std::endl; ! n->SetPosition(vNewPos); ! /*if (vVelocity != n->GetVelocity() && n->GetPhysicCallBack() != NULL) ! { ! //std::cout << "callback" << std::endl; ! //ce ne sont pas les memes, donc il y a eu collision -> appelle de la callback ! n->GetPhysicCallBack()->Collide(NULL, Vector3(0,0,0), Vector3(0,0,0)); ! }*/ ! } ! ! //Classification de la position ! BspCollisionResult col = pLevel->CheckRayMove(n->GetPosition(), n->GetPosition()+Vector3::NEGATIVE_UNIT_Y*BASE_HEIGHT, ! n->GetBBox()->vMin, n->GetBBox()->vMax); ! //si on met le allsolid, ca foire les mouvements sur les y ! if (col.Fraction < 1.0f || col.AllSolid) ! n->SetOnGround(true); ! else ! n->SetOnGround(false); ! Quaternion q = n->GetRotationVelocity()*eTime; q.Normalize(); n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); } } --- 210,221 ---- if (pLevel) { ! _TryToStep(n, eTime); ! Quaternion q = n->GetRotationVelocity()*eTime; q.Normalize(); n->SetRotation(n->GetRotation()*q); ! n->UpdatePosition(); + } } *************** *** 246,250 **** continue; ! if (pNodes[i]->GetBBox()->TraceRay(Begin, End, colPoint, colNormal)) { result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); --- 242,246 ---- continue; ! if (pNodes[i]->TraceRay(Begin, End, colPoint, colNormal)) { result.pNode = pNodes[i]; d1 = (colPoint - Begin).Magnitude(); Index: physicnode.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** physicnode.cc 12 Nov 2004 12:11:36 -0000 1.7 --- physicnode.cc 15 Nov 2004 21:35:21 -0000 1.8 *************** *** 34,37 **** --- 34,46 ---- pBBox = vNodes[0]->GetBBox(); } + + bool PhysicNode::TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) + { + /*if (pBBox->TraceRay(begin, end, colPoint, colNormal)) + return vNodes[0]->Trace(begin, end, colPoint, colNormal); + else + return false;*/ + return pBBox->TraceRay(begin, end, colPoint, colNormal); + } } Index: physicengine.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicengine.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** physicengine.h 12 Nov 2004 12:11:36 -0000 1.6 --- physicengine.h 15 Nov 2004 21:35:21 -0000 1.7 *************** *** 51,54 **** --- 51,56 ---- CollisionResult Trace(Vector3 Begin, Vector3 End, PhysicNode* edict=NULL); protected: + void _TryToStep (PhysicNode*, float); + std::vector<PhysicNode*> pNodes; Q3Bsp* pLevel; Index: physicnode.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/physicnode.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** physicnode.h 12 Nov 2004 12:11:36 -0000 1.5 --- physicnode.h 15 Nov 2004 21:35:21 -0000 1.6 *************** *** 27,30 **** --- 27,32 ---- inline BoundingBox* GetBBox () { return pBBox; } + bool TraceRay(Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal); + /** * Retourne un pointeur sur la classe servant de callback en cas de collision Index: q3bsp.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/q3bsp.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** q3bsp.cc 13 Nov 2004 23:35:40 -0000 1.12 --- q3bsp.cc 15 Nov 2004 21:35:21 -0000 1.13 *************** *** 1236,1242 **** // If the brush has sides (is a convex volume) and is SOLID then check it out! ! /*TODO or FIXME: ! C'est vraiment bizarre.. Le nombre de brush SOLID est très réduit, certainement pour des questions d'optimisation... A voir s'il faut l'activer ou non ...*/ ! if ( brush->numOfBrushSides > 0 && pContents[brush->textureID] & 1/*&& (pTextures[brush->textureID].contents & 1)*/) { CheckTouchBrush( brush, traceType,radius ); --- 1236,1241 ---- // If the brush has sides (is a convex volume) and is SOLID then check it out! ! /*C'est vraiment bizarre.. Le nombre de brush SOLID est très réduit, certainement pour des questions d'optimisation... A voir s'il faut l'activer ou non ...*/ ! if ( brush->numOfBrushSides > 0 && pContents[brush->textureID] & 1) { CheckTouchBrush( brush, traceType,radius ); *************** *** 1253,1264 **** BspNode *node = &pNodes[nodeIndex]; BspPlane *plane = &pPlanes[node->plane]; ! /*float startDistance = plane->vNormal.x * Start.x + ! plane->vNormal.y * Start.y + ! plane->vNormal.z * Start.z - ! plane->d; ! float endDistance = plane->vNormal.x * End.x + ! plane->vNormal.y * End.y + ! plane->vNormal.z * End.z - ! plane->d;*/ float startDistance = plane->vNormal*Start - plane->d; float endDistance = plane->vNormal*End - plane->d; --- 1252,1256 ---- BspNode *node = &pNodes[nodeIndex]; BspPlane *plane = &pPlanes[node->plane]; ! float startDistance = plane->vNormal*Start - plane->d; float endDistance = plane->vNormal*End - plane->d; *************** *** 1284,1288 **** { CheckMoveByNode( node->front, startFraction, endFraction, Start, End, traceType,radius ); ! //return; } // If both points are in behind the plane (the negative side) pass the ray to the back --- 1276,1280 ---- { CheckMoveByNode( node->front, startFraction, endFraction, Start, End, traceType,radius ); ! return; } // If both points are in behind the plane (the negative side) pass the ray to the back *************** *** 1292,1296 **** { CheckMoveByNode( node->back, startFraction, endFraction, Start, End, traceType,radius ); ! //return; } --- 1284,1288 ---- { CheckMoveByNode( node->back, startFraction, endFraction, Start, End, traceType,radius ); ! return; } *************** *** 1310,1314 **** side2 = node->front; float inverseDistance = 1.0f / (startDistance - endDistance); // optimization ! fraction1 = (startDistance - EPSILON - offset) * inverseDistance; // compute fraction for the start-middle fraction2 = (startDistance + EPSILON + offset) * inverseDistance; // compute fraction for the middle-end } --- 1302,1306 ---- side2 = node->front; float inverseDistance = 1.0f / (startDistance - endDistance); // optimization ! fraction1 = (startDistance + EPSILON - offset) * inverseDistance; // compute fraction for the start-middle fraction2 = (startDistance + EPSILON + offset) * inverseDistance; // compute fraction for the middle-end } Index: md5instance.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** md5instance.h 12 Nov 2004 12:11:36 -0000 1.7 --- md5instance.h 15 Nov 2004 21:35:21 -0000 1.8 *************** *** 44,49 **** ! //bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); ! //bool TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal); --- 44,49 ---- ! /*bool Trace (Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal); ! bool TriangleTrace(Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal);*/ Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/glrenderer.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** glrenderer.cc 13 Nov 2004 23:35:39 -0000 1.19 --- glrenderer.cc 15 Nov 2004 21:35:21 -0000 1.20 *************** *** 1997,2003 **** } glEnd (); //BSphere ! glPushMatrix(); Vector3 vb = b->vWorldOrigin + b->vBSCenter; glTranslatef(vb.x, vb.y, vb.z); --- 1997,2004 ---- } glEnd (); + //BSphere ! /*glPushMatrix(); Vector3 vb = b->vWorldOrigin + b->vBSCenter; glTranslatef(vb.x, vb.y, vb.z); *************** *** 2005,2014 **** gluSphere(pQ, b->fBSRadius, 10, 10); gluDeleteQuadric(pQ); ! glPopMatrix(); if (!bWireFrame) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); ! //RenderBSphere (b->vWorldBSCenter, b->fBSRadius); } --- 2006,2031 ---- gluSphere(pQ, b->fBSRadius, 10, 10); gluDeleteQuadric(pQ); ! glPopMatrix();*/ if (!bWireFrame) glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); ! ! glColor3f(0,1,0); ! glLineWidth(3.0f); ! glBegin (GL_LINES); ! for (int i=0; i<6; i++) ! { ! Vector3 norm = b->pPlanes[i].vNormal; ! Vector3 v1 = b->pPlanes[i].v[0]+b->pPlanes[i].v[1]+b->pPlanes[i].v[2]; ! v1 /= 3; ! Vector3 v2 = v1+norm*10; ! glVertex3fv (&v1.x); ! glVertex3fv (&v2.x); ! } ! glEnd (); ! glLineWidth(1.0f); ! ! glColor3f(1,1,1); } Index: vector3.h =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/vector3.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** vector3.h 13 Nov 2004 23:35:40 -0000 1.5 --- vector3.h 15 Nov 2004 21:35:21 -0000 1.6 *************** *** 42,46 **** } ! inline float& operator [] (int n) { switch (n) { case 0: return x; case 1: return y; case 2: return z;}} inline bool operator != (const Vector3& v) { return (v.x==x&&v.y==y&&v.z==z); } --- 42,46 ---- } ! inline float& operator [] (int n) { switch (n) { case 0: return x; case 1: return y; case 2: return z; default: return x;}} inline bool operator != (const Vector3& v) { return (v.x==x&&v.y==y&&v.z==z); } Index: md5instance.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/md5instance.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** md5instance.cc 12 Nov 2004 12:11:36 -0000 1.11 --- md5instance.cc 15 Nov 2004 21:35:21 -0000 1.12 *************** *** 293,301 **** } return b;*/ ! if (/*pBBox->TraceRay(Begin, End, colPoint))*/pBBox->TraceSphereRay(Begin, End, colPoint)) ! return TriangleTrace(Begin, End, colPoint, colNormal); ! else ! return false; ! //return pBBox->TraceSphereRay(Begin, End, colPoint); } --- 293,297 ---- } return b;*/ ! return TriangleTrace(Begin, End, colPoint, colNormal); } *************** *** 318,327 **** } ! bool MD5Instance::TriangleTrace(const Vector3& Begin, const Vector3& End, Vector3& colPoint, Vector3& colNormal) { Plane p; colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; Vector3 cP; float d1, d2; /* next variables are unused --- 314,326 ---- } ! bool MD5Instance::TriangleTrace(Vector3 Begin, Vector3 End, Vector3& colPoint, Vector3& colNormal) { + Quaternion q(-90, Vector3(1,0,0)); Plane p; + Vector3 cPBack = colPoint; colPoint.x = colPoint.y = colPoint.z = TG_INFINITY; Vector3 cP; float d1, d2; + bool bCollide = false; /* next variables are unused *************** *** 339,342 **** --- 338,344 ---- points[1] = pVerticesListTab[j][f->pIndex[1]].vPosition+vPosition; points[2] = pVerticesListTab[j][f->pIndex[2]].vPosition+vPosition; + points[0] = q.Rotate(points[0]); + points[1] = q.Rotate(points[1]); + points[2] = q.Rotate(points[2]); p.SetFromPoints(points[0], points[1], points[2]); *************** *** 351,354 **** --- 353,357 ---- colPoint = cP; colNormal = p.GetNormal(); + bCollide = true; } } *************** *** 369,373 **** } } ! return true; } #endif --- 372,378 ---- } } ! if (!bCollide) ! colPoint = cPBack; ! return bCollide; } #endif Index: boundingbox.cc =================================================================== RCS file: /cvsroot/epfl/tgengine-0.1/boundingbox.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** boundingbox.cc 12 Nov 2004 12:11:36 -0000 1.6 --- boundingbox.cc 15 Nov 2004 21:35:21 -0000 1.7 *************** *** 137,144 **** } bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! return TraceSphereRay(begin, end, colPoint); /*int iB, iE; Vector3 cP; --- 137,189 ---- } + bool Clip (float fDenom, float fNumer, float& rfT0, + float& rfT1) + { + // Return value is 'true' if line segment intersects the current test + // plane. Otherwise 'false' is returned in which case the line segment + // is entirely clipped. + + if ( fDenom > 0.0 ) + { + if ( fNumer > fDenom*rfT1 ) + return false; + if ( fNumer > fDenom*rfT0 ) + rfT0 = fNumer/fDenom; + return true; + } + else if ( fDenom < 0.0 ) + { + if ( fNumer > fDenom*rfT0 ) + return false; + if ( fNumer > fDenom*rfT1 ) + rfT1 = fNumer/fDenom; + return true; + } + else + { + return fNumer <= 0.0; + } + } + //---------------------------------------------------------------------------- + bool MgcFindIntersection (const Vector3& rkOrigin, + const Vector3& rkDirection, const float afExtent[3], float& rfT0, + float& rfT1) + { + float fSaveT0 = rfT0, fSaveT1 = rfT1; + + bool bNotEntirelyClipped = + Clip(+rkDirection.x,-rkOrigin.x-afExtent[0],rfT0,rfT1) && + Clip(-rkDirection.x,+rkOrigin.x-afExtent[0],rfT0,rfT1) && + Clip(+rkDirection.y,-rkOrigin.y-afExtent[1],rfT0,rfT1) && + Clip(-rkDirection.y,+rkOrigin.y-afExtent[1],rfT0,rfT1) && + Clip(+rkDirection.z,-rkOrigin.z-afExtent[2],rfT0,rfT1) && + Clip(-rkDirection.z,+rkOrigin.z-afExtent[2],rfT0,rfT1); + + return bNotEntirelyClipped && ( rfT0 != fSaveT0 || rfT1 != fSaveT1 ); + } bool BoundingBox::TraceRay (Vector3 begin, Vector3 end, Vector3& colPoint, Vector3& colNormal) { ! //return TraceSphereRay(begin, end, colPoint); /*int iB, iE; Vector3 cP; *************** *** 149,153 **** if ((iB == iE) && (iB == POINT_IN_FRONT_OF_PLANE)) return false; ! else if (iB == iE) continue; if (pPlanes[i].IntersectRay(begin, end, cP)) --- 194,198 ---- if ((iB == iE) && (iB == POINT_IN_FRONT_OF_PLANE)) return false; ! if (iB == iE) continue; if (pPlanes[i].IntersectRay(begin, end, cP)) *************** *** 156,159 **** --- 201,267 ---- } return true;*/ + Vector3 kOrigin = begin - vWorldOrigin; + Vector3 kDirection = end - begin; + + float fT0 = 0.0, fT1 = 1.0; + int riQuantity; + Vector3 akPoint[2]; + float extents[3]; + extents[0] = (vMax.x-vMin.x); + extents[1] = (vMax.y-vMin.y); + extents[2] = (vMax.z-vMin.z); + bool bIntersects = MgcFindIntersection(kOrigin,kDirection,extents, + fT0,fT1); + + if ( bIntersects ) + { + if ( fT0 > 0.0 ) + { + if ( fT1 < 1.0 ) + { + riQuantity = 2; + akPoint[0] = kOrigin + fT0*kDirection; + akPoint[1] = kOrigin + fT1*kDirection; + } + else + { + riQuantity = 1; + akPoint[0] = kOrigin + fT0*kDirection; + } + } + else // fT0 == 0.0 + { + if ( fT1 < 1.0 ) + { + riQuantity = 1; + akPoint[0] = kOrigin + fT1*kDirection; + } + else // fT1 == 1.0 + { + // segment entirely in box + riQuantity = 0; + } + } + } + else + { + riQuantity = 0; + } + + if (riQuantity == 2) + { + float dist1 = (kOrigin - akPoint[0]).Magnitude(); + float dist2 = (kOrigin - akPoint[1]).Magnitude(); + + if (dist1 > dist2) + colPoint = akPoint[1]; + else + colPoint = akPoint[0]; + } + else if (riQuantity == 1) + colPoint = akPoint[0]; + colPoint += vWorldOrigin; + //std::cout << colPoint << std::endl; + return bIntersects; } |