Showing the changes to interface/src/renderer/Model.cpp (1 of 3 files). Show all
Unified · Split
| @@ -543,10 +543,10 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 542 unmodified lines | ||
| 543 | 543 | qDebug() << " modelExtents:" << modelExtents; |
| 544 | 544 | |
| 545 | 545 | glm::vec3 dimensions = modelExtents.maximum - modelExtents.minimum; |
| 546 | − glm::vec3 corner = dimensions * _registrationPoint; // since we're going to do the ray picking in the model frame of reference | |
| 547 | − AABox overlayFrameBox(corner, dimensions); | |
| 546 | + glm::vec3 corner = -(dimensions * _registrationPoint); // since we're going to do the ray picking in the model frame of reference | |
| 547 | + AABox modelFrameBox(corner, dimensions); | |
| 548 | 548 | |
| 549 | − qDebug() << " overlayFrameBox:" << overlayFrameBox; | |
| 549 | + qDebug() << " modelFrameBox:" << modelFrameBox; | |
| 550 | 550 | |
| 551 | 551 | glm::vec3 modelFrameOrigin = glm::vec3(worldToModelMatrix * glm::vec4(origin, 1.0f)); |
| 552 | 552 | glm::vec3 modelFrameDirection = glm::vec3(worldToModelMatrix * glm::vec4(direction, 0.0f)); |
| @@ -555,7 +555,9 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 2 unmodified lines | ||
| 555 | 555 | |
| 556 | 556 | // we can use the AABox's ray intersection by mapping our origin and direction into the model frame |
| 557 | 557 | // and testing intersection there. |
| 558 | − if (overlayFrameBox.findRayIntersection(modelFrameOrigin, modelFrameDirection, distance, face)) { | |
| 558 | + if (modelFrameBox.findRayIntersection(modelFrameOrigin, modelFrameDirection, distance, face)) { | |
| 559 | + | |
| 560 | + qDebug() << " modelFrameBox.findRayIntersection() HITS!!!"; | |
| 559 | 561 | |
| 560 | 562 | float bestDistance = std::numeric_limits<float>::max(); |
| 561 | 563 | float bestTriangleDistance = std::numeric_limits<float>::max(); |
| @@ -566,14 +568,21 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 4 unmodified lines | ||
| 566 | 568 | int subMeshIndex = 0; |
| 567 | 569 | |
| 568 | 570 | const FBXGeometry& geometry = _geometry->getFBXGeometry(); |
| 571 | + | |
| 572 | + qDebug() << " Checking mesh boxes...."; | |
| 569 | 573 | |
| 570 | 574 | // If we hit the models box, then consider the submeshes... |
| 571 | 575 | foreach(const AABox& subMeshBox, _calculatedMeshBoxes) { |
| 572 | 576 | |
| 573 | − qDebug() << "subMeshBox[" << subMeshIndex <<"]:" << subMeshBox; | |
| 577 | + qDebug() << " subMeshBox[" << subMeshIndex <<"]:" << subMeshBox; | |
| 574 | 578 | if (subMeshBox.findRayIntersection(origin, direction, distanceToSubMesh, subMeshFace)) { |
| 579 | + qDebug() << " subMeshBox[" << subMeshIndex <<"].findRayIntersection() HITS!"; | |
| 580 | + qDebug() << " subMeshBox[" << subMeshIndex <<"].distanceToSubMesh:" << distanceToSubMesh; | |
| 581 | + qDebug() << " bestDistance:" << bestDistance; | |
| 575 | 582 | if (distanceToSubMesh < bestDistance) { |
| 576 | 583 | |
| 584 | + qDebug() << " distanceToSubMesh < bestDistance !! looks like a good match!"; | |
| 585 | + | |
| 577 | 586 | if (pickAgainstTriangles) { |
| 578 | 587 | if (!_calculatedMeshTrianglesValid) { |
| 579 | 588 | recalcuateMeshBoxes(); |
| @@ -599,6 +608,8 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 19 unmodified lines | ||
| 599 | 608 | intersectedSomething = true; |
| 600 | 609 | face = subMeshFace; |
| 601 | 610 | extraInfo = geometry.getModelNameOfMesh(subMeshIndex); |
| 611 | + } else { | |
| 612 | + qDebug() << " distanceToSubMesh >= bestDistance !! TOO FAR AWAY!"; | |
| 602 | 613 | } |
| 603 | 614 | } |
| 604 | 615 | subMeshIndex++; |
| @@ -607,6 +618,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 2 unmodified lines | ||
| 607 | 618 | // if we were asked to pick against triangles, and we didn't hit one, then we |
| 608 | 619 | // do not consider this model to be hit at all. |
| 609 | 620 | if (pickAgainstTriangles && !someTriangleHit) { |
| 621 | + qDebug() << "pickAgainstTriangles && !someTriangleHit --- call it a NON-HIT!"; | |
| 610 | 622 | intersectedSomething = false; |
| 611 | 623 | } |
| 612 | 624 | qDebug() << "pickAgainstTriangles:" << pickAgainstTriangles; |
| @@ -626,6 +638,8 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 13 unmodified lines | ||
| 626 | 638 | } |
| 627 | 639 | |
| 628 | 640 | return intersectedSomething; |
| 641 | + } else { | |
| 642 | + qDebug() << "modelFrameBox.findRayIntersection()... DID NOT INTERSECT..."; | |
| 629 | 643 | } |
| 630 | 644 | |
| 631 | 645 | return intersectedSomething; |