History

more work on improved model picking

ZappoMan committed 11 years ago

Commit 37ffa481 parent 5ec9a9b3 files · +18 −377Browse files

Showing the changes to interface/src/renderer/Model.cpp (1 of 3 files). Show all

Unified · Split

interface/src/renderer/Model.cpp+7−0
@@ -536,6 +536,8 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 535 unmodified lines
536536 return intersectedSomething;
537537 }
538538
539+ qDebug() << "Model::findRayIntersectionAgainstSubMeshes()...";
540+
539541 // extents is the entity relative, scaled, centered extents of the entity
540542 glm::vec3 position = _translation;
541543 glm::mat4 rotation = glm::mat4_cast(_rotation);
@@ -544,11 +546,14 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 2 unmodified lines
544546 glm::mat4 worldToModelMatrix = glm::inverse(modelToWorldMatrix);
545547
546548 Extents modelExtents = getMeshExtents(); // NOTE: unrotated
549+ qDebug() << " modelExtents:" << modelExtents;
547550
548551 glm::vec3 dimensions = modelExtents.maximum - modelExtents.minimum;
549552 glm::vec3 corner = dimensions * -0.5f; // since we're going to do the ray picking in the model frame of reference
550553 AABox overlayFrameBox(corner, dimensions);
551554
555+ qDebug() << " overlayFrameBox:" << overlayFrameBox;
556+
552557 glm::vec3 modelFrameOrigin = glm::vec3(worldToModelMatrix * glm::vec4(origin, 1.0f));
553558 glm::vec3 modelFrameDirection = glm::vec3(worldToModelMatrix * glm::vec4(direction, 0.0f));
554559
@@ -560,11 +565,13 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g · 5 unmodified lines
560565 float distanceToSubMesh;
561566 BoxFace subMeshFace;
562567 int subMeshIndex = 0;
568+
563569
564570 // If we hit the models box, then consider the submeshes...
565571 foreach(const AABox& subMeshBox, _calculatedMeshBoxes) {
566572 const FBXGeometry& geometry = _geometry->getFBXGeometry();
567573
574+ qDebug() << "subMeshBox[" << subMeshIndex <<"]:" << subMeshBox;
568575 if (subMeshBox.findRayIntersection(origin, direction, distanceToSubMesh, subMeshFace)) {
569576 if (distanceToSubMesh < bestDistance) {
570577 bestDistance = distanceToSubMesh;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t