diff options
author | Dave Parks <davep@lindenlab.com> | 2010-05-29 19:55:13 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2010-05-29 19:55:13 -0500 |
commit | 9a869d630162292864e01fdd1707efc609fbd6b4 (patch) | |
tree | 8b8f69709f181e6dc64324d4ab1cdaf21dd6b19f /indra/newview | |
parent | 0e7f4dc5cef8a97cb1dd08aa2f79538ced267888 (diff) |
Octree triven raycast works, time to profile.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 28 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 21 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.h | 6 |
3 files changed, 44 insertions, 11 deletions
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 60e704d360..355173772b 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -38,6 +38,7 @@ #include "llviewerobjectlist.h" #include "llvovolume.h" #include "llvolume.h" +#include "llvolumeoctree.h" #include "llviewercamera.h" #include "llface.h" #include "llviewercontrol.h" @@ -2769,17 +2770,26 @@ void renderLights(LLDrawable* drawablep) } } -class LLRenderOctree : public LLOctreeTraveler<LLVolumeFace::Triangle> +class LLRenderOctreeRaycast : public LLOctreeTriangleRayIntersect { public: + + LLRenderOctreeRaycast(const LLVector3& start, const LLVector3& end) + { + mStart.load3(start.mV); + mEnd.load3(end.mV); + mDir.setSub(mEnd, mStart); + } + void visit(const LLOctreeNode<LLVolumeFace::Triangle>* branch) { - const LLVector3d& c = branch->getCenter(); - const LLVector3d& s = branch->getSize(); + LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) branch->getListener(0); - LLVector3 pos((F32) c.mdV[0], (F32) c.mdV[1], (F32) c.mdV[2]); - LLVector3 size((F32) s.mdV[0], (F32) s.mdV[1], (F32) s.mdV[2]); - drawBoxOutline(pos, size); + LLVector3 center, size; + center.set(vl->mBounds[0].getF32()); + size.set(vl->mBounds[1].getF32()); + + drawBoxOutline(center, size); } }; @@ -2813,7 +2823,11 @@ void renderRaycast(LLDrawable* drawablep) gGL.pushMatrix(); glMultMatrixf((F32*) vobj->getRelativeXform().mMatrix); - LLRenderOctree render; + LLVector3 start, end; + start = vobj->agentPositionToVolume(gDebugRaycastStart); + end = vobj->agentPositionToVolume(gDebugRaycastEnd); + + LLRenderOctreeRaycast render(start, end); render.traverse(face.mOctree); gGL.popMatrix(); } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2422995288..0564f02ce5 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -231,6 +231,8 @@ LLVector2 gDebugRaycastTexCoord; LLVector3 gDebugRaycastNormal; LLVector3 gDebugRaycastBinormal; S32 gDebugRaycastFaceHit; +LLVector3 gDebugRaycastStart; +LLVector3 gDebugRaycastEnd; // HUD display lines in lower right BOOL gDisplayWindInfo = FALSE; @@ -2529,7 +2531,9 @@ void LLViewerWindow::updateUI() &gDebugRaycastIntersection, &gDebugRaycastTexCoord, &gDebugRaycastNormal, - &gDebugRaycastBinormal); + &gDebugRaycastBinormal, + &gDebugRaycastStart, + &gDebugRaycastEnd); } updateMouseDelta(); @@ -3445,7 +3449,9 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de LLVector3 *intersection, LLVector2 *uv, LLVector3 *normal, - LLVector3 *binormal) + LLVector3 *binormal, + LLVector3* start, + LLVector3* end) { S32 x = mouse_x; S32 y = mouse_y; @@ -3477,7 +3483,16 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de LLVector3 mouse_world_start = mouse_point_global; LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth; - + if (start) + { + *start = mouse_world_start; + } + + if (end) + { + *end = mouse_world_end; + } + LLViewerObject* found = NULL; if (this_object) // check only this object diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 410445d97f..156a1ff8ad 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -361,7 +361,9 @@ public: LLVector3 *intersection = NULL, LLVector2 *uv = NULL, LLVector3 *normal = NULL, - LLVector3 *binormal = NULL); + LLVector3 *binormal = NULL, + LLVector3* start = NULL, + LLVector3* end = NULL); // Returns a pointer to the last object hit @@ -507,6 +509,8 @@ extern LLVector2 gDebugRaycastTexCoord; extern LLVector3 gDebugRaycastNormal; extern LLVector3 gDebugRaycastBinormal; extern S32 gDebugRaycastFaceHit; +extern LLVector3 gDebugRaycastStart; +extern LLVector3 gDebugRaycastEnd; extern S32 CHAT_BAR_HEIGHT; |