diff options
Diffstat (limited to 'linden/indra/newview/llspatialpartition.cpp')
-rw-r--r-- | linden/indra/newview/llspatialpartition.cpp | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/linden/indra/newview/llspatialpartition.cpp b/linden/indra/newview/llspatialpartition.cpp index 9f5d115..6247686 100644 --- a/linden/indra/newview/llspatialpartition.cpp +++ b/linden/indra/newview/llspatialpartition.cpp | |||
@@ -46,6 +46,7 @@ | |||
46 | #include "pipeline.h" | 46 | #include "pipeline.h" |
47 | #include "llrender.h" | 47 | #include "llrender.h" |
48 | #include "lloctree.h" | 48 | #include "lloctree.h" |
49 | #include "llvoavatar.h" | ||
49 | 50 | ||
50 | const F32 SG_OCCLUSION_FUDGE = 1.01f; | 51 | const F32 SG_OCCLUSION_FUDGE = 1.01f; |
51 | #define SG_DISCARD_TOLERANCE 0.01f | 52 | #define SG_DISCARD_TOLERANCE 0.01f |
@@ -1624,7 +1625,7 @@ public: | |||
1624 | 1625 | ||
1625 | void drawBox(const LLVector3& c, const LLVector3& r) | 1626 | void drawBox(const LLVector3& c, const LLVector3& r) |
1626 | { | 1627 | { |
1627 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 1628 | gGL.begin(LLRender::TRIANGLE_STRIP); |
1628 | //left front | 1629 | //left front |
1629 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV); | 1630 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV); |
1630 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,1))).mV); | 1631 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,1))).mV); |
@@ -1643,7 +1644,7 @@ void drawBox(const LLVector3& c, const LLVector3& r) | |||
1643 | gGL.end(); | 1644 | gGL.end(); |
1644 | 1645 | ||
1645 | //bottom | 1646 | //bottom |
1646 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 1647 | gGL.begin(LLRender::TRIANGLE_STRIP); |
1647 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,1,-1))).mV); | 1648 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,1,-1))).mV); |
1648 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,-1,-1))).mV); | 1649 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,-1,-1))).mV); |
1649 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV); | 1650 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,-1))).mV); |
@@ -1651,7 +1652,7 @@ void drawBox(const LLVector3& c, const LLVector3& r) | |||
1651 | gGL.end(); | 1652 | gGL.end(); |
1652 | 1653 | ||
1653 | //top | 1654 | //top |
1654 | gGL.begin(LLVertexBuffer::TRIANGLE_STRIP); | 1655 | gGL.begin(LLRender::TRIANGLE_STRIP); |
1655 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,1,1))).mV); | 1656 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,1,1))).mV); |
1656 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,1))).mV); | 1657 | gGL.vertex3fv((c+r.scaledVec(LLVector3(-1,1,1))).mV); |
1657 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,-1,1))).mV); | 1658 | gGL.vertex3fv((c+r.scaledVec(LLVector3(1,-1,1))).mV); |
@@ -1666,7 +1667,7 @@ void drawBoxOutline(const LLVector3& pos, const LLVector3& size) | |||
1666 | LLVector3 v3 = size.scaledVec(LLVector3(-1,-1,1)); | 1667 | LLVector3 v3 = size.scaledVec(LLVector3(-1,-1,1)); |
1667 | LLVector3 v4 = size.scaledVec(LLVector3( 1,-1,1)); | 1668 | LLVector3 v4 = size.scaledVec(LLVector3( 1,-1,1)); |
1668 | 1669 | ||
1669 | gGL.begin(LLVertexBuffer::LINES); | 1670 | gGL.begin(LLRender::LINES); |
1670 | 1671 | ||
1671 | //top | 1672 | //top |
1672 | gGL.vertex3fv((pos+v1).mV); | 1673 | gGL.vertex3fv((pos+v1).mV); |
@@ -1814,7 +1815,7 @@ void pushVerts(LLDrawInfo* params, U32 mask) | |||
1814 | { | 1815 | { |
1815 | LLRenderPass::applyModelMatrix(*params); | 1816 | LLRenderPass::applyModelMatrix(*params); |
1816 | params->mVertexBuffer->setBuffer(mask); | 1817 | params->mVertexBuffer->setBuffer(mask); |
1817 | params->mVertexBuffer->drawRange(params->mParticle ? LLVertexBuffer::POINTS : LLVertexBuffer::TRIANGLES, | 1818 | params->mVertexBuffer->drawRange(params->mParticle ? LLRender::POINTS : LLRender::TRIANGLES, |
1818 | params->mStart, params->mEnd, params->mCount, params->mOffset); | 1819 | params->mStart, params->mEnd, params->mCount, params->mOffset); |
1819 | } | 1820 | } |
1820 | 1821 | ||
@@ -1843,7 +1844,7 @@ void pushVerts(LLFace* face, U32 mask) | |||
1843 | U16 end = start + face->getGeomCount()-1; | 1844 | U16 end = start + face->getGeomCount()-1; |
1844 | U32 count = face->getIndicesCount(); | 1845 | U32 count = face->getIndicesCount(); |
1845 | U16 offset = face->getIndicesStart(); | 1846 | U16 offset = face->getIndicesStart(); |
1846 | buffer->drawRange(LLVertexBuffer::TRIANGLES, start, end, count, offset); | 1847 | buffer->drawRange(LLRender::TRIANGLES, start, end, count, offset); |
1847 | } | 1848 | } |
1848 | 1849 | ||
1849 | } | 1850 | } |
@@ -1853,7 +1854,7 @@ void pushBufferVerts(LLVertexBuffer* buffer, U32 mask) | |||
1853 | if (buffer) | 1854 | if (buffer) |
1854 | { | 1855 | { |
1855 | buffer->setBuffer(mask); | 1856 | buffer->setBuffer(mask); |
1856 | buffer->drawRange(LLVertexBuffer::TRIANGLES, 0, buffer->getRequestedVerts()-1, buffer->getRequestedIndices(), 0); | 1857 | buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getRequestedVerts()-1, buffer->getRequestedIndices(), 0); |
1857 | } | 1858 | } |
1858 | } | 1859 | } |
1859 | 1860 | ||
@@ -1902,7 +1903,7 @@ void pushVertsColorCoded(LLSpatialGroup* group, U32 mask) | |||
1902 | LLRenderPass::applyModelMatrix(*params); | 1903 | LLRenderPass::applyModelMatrix(*params); |
1903 | glColor4f(colors[col].mV[0], colors[col].mV[1], colors[col].mV[2], 0.5f); | 1904 | glColor4f(colors[col].mV[0], colors[col].mV[1], colors[col].mV[2], 0.5f); |
1904 | params->mVertexBuffer->setBuffer(mask); | 1905 | params->mVertexBuffer->setBuffer(mask); |
1905 | params->mVertexBuffer->drawRange(params->mParticle ? LLVertexBuffer::POINTS : LLVertexBuffer::TRIANGLES, | 1906 | params->mVertexBuffer->drawRange(params->mParticle ? LLRender::POINTS : LLRender::TRIANGLES, |
1906 | params->mStart, params->mEnd, params->mCount, params->mOffset); | 1907 | params->mStart, params->mEnd, params->mCount, params->mOffset); |
1907 | col = (col+1)%col_count; | 1908 | col = (col+1)%col_count; |
1908 | } | 1909 | } |
@@ -1972,7 +1973,7 @@ void renderOctree(LLSpatialGroup* group) | |||
1972 | face->mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX); | 1973 | face->mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX); |
1973 | //drawBox((face->mExtents[0] + face->mExtents[1])*0.5f, | 1974 | //drawBox((face->mExtents[0] + face->mExtents[1])*0.5f, |
1974 | // (face->mExtents[1]-face->mExtents[0])*0.5f); | 1975 | // (face->mExtents[1]-face->mExtents[0])*0.5f); |
1975 | face->mVertexBuffer->draw(LLVertexBuffer::TRIANGLES, face->getIndicesCount(), face->getIndicesStart()); | 1976 | face->mVertexBuffer->draw(LLRender::TRIANGLES, face->getIndicesCount(), face->getIndicesStart()); |
1976 | } | 1977 | } |
1977 | } | 1978 | } |
1978 | 1979 | ||
@@ -2103,6 +2104,7 @@ void renderBoundingBox(LLDrawable* drawable) | |||
2103 | gGL.color4f(0.5f,0.5f,0.5f,1.0f); | 2104 | gGL.color4f(0.5f,0.5f,0.5f,1.0f); |
2104 | break; | 2105 | break; |
2105 | case LLViewerObject::LL_VO_PART_GROUP: | 2106 | case LLViewerObject::LL_VO_PART_GROUP: |
2107 | case LLViewerObject::LL_VO_HUD_PART_GROUP: | ||
2106 | gGL.color4f(0,0,1,1); | 2108 | gGL.color4f(0,0,1,1); |
2107 | break; | 2109 | break; |
2108 | case LLViewerObject::LL_VO_WATER: | 2110 | case LLViewerObject::LL_VO_WATER: |
@@ -2222,7 +2224,7 @@ void renderPoints(LLDrawable* drawablep) | |||
2222 | LLGLDepthTest depth(GL_FALSE, GL_FALSE); | 2224 | LLGLDepthTest depth(GL_FALSE, GL_FALSE); |
2223 | if (drawablep->getNumFaces()) | 2225 | if (drawablep->getNumFaces()) |
2224 | { | 2226 | { |
2225 | gGL.begin(LLVertexBuffer::POINTS); | 2227 | gGL.begin(LLRender::POINTS); |
2226 | gGL.color3f(1,1,1); | 2228 | gGL.color3f(1,1,1); |
2227 | LLVector3 center(drawablep->getPositionGroup()); | 2229 | LLVector3 center(drawablep->getPositionGroup()); |
2228 | for (S32 i = 0; i < drawablep->getNumFaces(); i++) | 2230 | for (S32 i = 0; i < drawablep->getNumFaces(); i++) |
@@ -2298,9 +2300,17 @@ void renderRaycast(LLDrawable* drawablep) | |||
2298 | LLGLEnable blend(GL_BLEND); | 2300 | LLGLEnable blend(GL_BLEND); |
2299 | gGL.color4f(0,1,1,0.5f); | 2301 | gGL.color4f(0,1,1,0.5f); |
2300 | 2302 | ||
2301 | for (S32 i = 0; i < drawablep->getNumFaces(); i++) | 2303 | if (drawablep->getVOVolume() && gDebugRaycastFaceHit != -1) |
2302 | { | 2304 | { |
2303 | pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX); | 2305 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
2306 | pushVerts(drawablep->getFace(gDebugRaycastFaceHit), LLVertexBuffer::MAP_VERTEX); | ||
2307 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||
2308 | } | ||
2309 | else if (drawablep->isAvatar()) | ||
2310 | { | ||
2311 | LLGLDepthTest depth(GL_FALSE); | ||
2312 | LLVOAvatar* av = (LLVOAvatar*) drawablep->getVObj().get(); | ||
2313 | av->renderCollisionVolumes(); | ||
2304 | } | 2314 | } |
2305 | 2315 | ||
2306 | // draw intersection point | 2316 | // draw intersection point |
@@ -2468,7 +2478,7 @@ void LLSpatialPartition::renderDebug() | |||
2468 | LLGLDisable cullface(GL_CULL_FACE); | 2478 | LLGLDisable cullface(GL_CULL_FACE); |
2469 | LLGLEnable blend(GL_BLEND); | 2479 | LLGLEnable blend(GL_BLEND); |
2470 | gGL.setSceneBlendType(LLRender::BT_ALPHA); | 2480 | gGL.setSceneBlendType(LLRender::BT_ALPHA); |
2471 | LLImageGL::unbindTexture(0); | 2481 | gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); |
2472 | gPipeline.disableLights(); | 2482 | gPipeline.disableLights(); |
2473 | 2483 | ||
2474 | LLSpatialBridge* bridge = asBridge(); | 2484 | LLSpatialBridge* bridge = asBridge(); |
@@ -2508,8 +2518,9 @@ public: | |||
2508 | LLVector3 *mNormal; | 2518 | LLVector3 *mNormal; |
2509 | LLVector3 *mBinormal; | 2519 | LLVector3 *mBinormal; |
2510 | LLDrawable* mHit; | 2520 | LLDrawable* mHit; |
2511 | 2521 | BOOL mPickTransparent; | |
2512 | LLOctreeIntersect(LLVector3 start, LLVector3 end, | 2522 | |
2523 | LLOctreeIntersect(LLVector3 start, LLVector3 end, BOOL pick_transparent, | ||
2513 | S32* face_hit, LLVector3* intersection, LLVector2* tex_coord, LLVector3* normal, LLVector3* binormal) | 2524 | S32* face_hit, LLVector3* intersection, LLVector2* tex_coord, LLVector3* normal, LLVector3* binormal) |
2514 | : mStart(start), | 2525 | : mStart(start), |
2515 | mEnd(end), | 2526 | mEnd(end), |
@@ -2518,14 +2529,15 @@ public: | |||
2518 | mTexCoord(tex_coord), | 2529 | mTexCoord(tex_coord), |
2519 | mNormal(normal), | 2530 | mNormal(normal), |
2520 | mBinormal(binormal), | 2531 | mBinormal(binormal), |
2521 | mHit(NULL) | 2532 | mHit(NULL), |
2533 | mPickTransparent(pick_transparent) | ||
2522 | { | 2534 | { |
2523 | } | 2535 | } |
2524 | 2536 | ||
2525 | virtual void visit(const LLSpatialGroup::OctreeNode* branch) | 2537 | virtual void visit(const LLSpatialGroup::OctreeNode* branch) |
2526 | { | 2538 | { |
2527 | for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i) | 2539 | for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i) |
2528 | { | 2540 | { |
2529 | check(*i); | 2541 | check(*i); |
2530 | } | 2542 | } |
2531 | } | 2543 | } |
@@ -2570,25 +2582,35 @@ public: | |||
2570 | 2582 | ||
2571 | virtual bool check(LLDrawable* drawable) | 2583 | virtual bool check(LLDrawable* drawable) |
2572 | { | 2584 | { |
2585 | LLVector3 local_start = mStart; | ||
2586 | LLVector3 local_end = mEnd; | ||
2587 | |||
2588 | if (!gPipeline.hasRenderType(drawable->getRenderType()) || !drawable->isVisible()) | ||
2589 | { | ||
2590 | return false; | ||
2591 | } | ||
2592 | |||
2573 | if (drawable->isSpatialBridge()) | 2593 | if (drawable->isSpatialBridge()) |
2574 | { | 2594 | { |
2575 | LLSpatialPartition *part = drawable->asPartition(); | 2595 | LLSpatialPartition *part = drawable->asPartition(); |
2576 | 2596 | LLSpatialBridge* bridge = part->asBridge(); | |
2577 | check(part->mOctree); | 2597 | if (bridge && gPipeline.hasRenderType(bridge->mDrawableType)) |
2578 | } | 2598 | { |
2579 | 2599 | check(part->mOctree); | |
2600 | } | ||
2601 | } | ||
2580 | else | 2602 | else |
2581 | { | 2603 | { |
2582 | LLViewerObject* vobj = drawable->getVObj(); | 2604 | LLViewerObject* vobj = drawable->getVObj(); |
2583 | 2605 | ||
2584 | if (vobj) | 2606 | if (vobj) |
2585 | { | 2607 | { |
2586 | LLVector3 intersection; | 2608 | LLVector3 intersection; |
2587 | if (vobj->lineSegmentIntersect(mStart, mEnd, -1, mFaceHit, &intersection, mTexCoord, mNormal, mBinormal)) | 2609 | if (vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mFaceHit, &intersection, mTexCoord, mNormal, mBinormal)) |
2588 | { | 2610 | { |
2589 | mEnd = intersection; // shorten ray so we only find CLOSER hits | 2611 | mEnd = intersection; // shorten ray so we only find CLOSER hits |
2590 | if (mIntersection) | 2612 | if (mIntersection) |
2591 | { | 2613 | { |
2592 | *mIntersection = intersection; | 2614 | *mIntersection = intersection; |
2593 | } | 2615 | } |
2594 | 2616 | ||
@@ -2596,12 +2618,13 @@ public: | |||
2596 | } | 2618 | } |
2597 | } | 2619 | } |
2598 | } | 2620 | } |
2599 | 2621 | ||
2600 | return false; | 2622 | return false; |
2601 | } | 2623 | } |
2602 | }; | 2624 | }; |
2603 | 2625 | ||
2604 | LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, | 2626 | LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, |
2627 | BOOL pick_transparent, | ||
2605 | S32* face_hit, // return the face hit | 2628 | S32* face_hit, // return the face hit |
2606 | LLVector3* intersection, // return the intersection point | 2629 | LLVector3* intersection, // return the intersection point |
2607 | LLVector2* tex_coord, // return the texture coordinates of the intersection point | 2630 | LLVector2* tex_coord, // return the texture coordinates of the intersection point |
@@ -2610,7 +2633,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector3& start, con | |||
2610 | ) | 2633 | ) |
2611 | 2634 | ||
2612 | { | 2635 | { |
2613 | LLOctreeIntersect intersect(start, end, face_hit, intersection, tex_coord, normal, bi_normal); | 2636 | LLOctreeIntersect intersect(start, end, pick_transparent, face_hit, intersection, tex_coord, normal, bi_normal); |
2614 | LLDrawable* drawable = intersect.check(mOctree); | 2637 | LLDrawable* drawable = intersect.check(mOctree); |
2615 | 2638 | ||
2616 | return drawable; | 2639 | return drawable; |