diff options
Diffstat (limited to 'linden/indra/newview/llviewercamera.cpp')
-rw-r--r-- | linden/indra/newview/llviewercamera.cpp | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/linden/indra/newview/llviewercamera.cpp b/linden/indra/newview/llviewercamera.cpp index 62fa0ef..598046a 100644 --- a/linden/indra/newview/llviewercamera.cpp +++ b/linden/indra/newview/llviewercamera.cpp | |||
@@ -138,7 +138,8 @@ void LLViewerCamera::calcProjection(const F32 far_distance) const | |||
138 | 138 | ||
139 | LLMatrix4 gProjectionMat; | 139 | LLMatrix4 gProjectionMat; |
140 | 140 | ||
141 | void LLViewerCamera::updateFrustumPlanes() | 141 | //static |
142 | void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho) | ||
142 | { | 143 | { |
143 | GLint viewport[4]; | 144 | GLint viewport[4]; |
144 | GLdouble model[16]; | 145 | GLdouble model[16]; |
@@ -159,23 +160,26 @@ void LLViewerCamera::updateFrustumPlanes() | |||
159 | frust[2].setVec((F32)objX,(F32)objY,(F32)objZ); | 160 | frust[2].setVec((F32)objX,(F32)objY,(F32)objZ); |
160 | gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); | 161 | gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); |
161 | frust[3].setVec((F32)objX,(F32)objY,(F32)objZ); | 162 | frust[3].setVec((F32)objX,(F32)objY,(F32)objZ); |
162 | /*gluUnProject(viewport[0],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); | ||
163 | frust[4].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
164 | gluUnProject(viewport[0]+viewport[2],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); | ||
165 | frust[5].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
166 | gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); | ||
167 | frust[6].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
168 | gluUnProject(viewport[0],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); | ||
169 | frust[7].setVec((F32)objX,(F32)objY,(F32)objZ);*/ | ||
170 | 163 | ||
171 | for (U32 i = 0; i < 4; i++) | 164 | if (ortho) |
172 | { | 165 | { |
173 | LLVector3 vec = frust[i] - getOrigin(); | 166 | LLVector3 far_shift = LLVector3(camera.getFar()*2.0f,0,0); |
174 | vec.normVec(); | 167 | for (U32 i = 0; i < 4; i++) |
175 | frust[i+4] = getOrigin() + vec*getFar()*2.0; | 168 | { |
169 | frust[i+4] = frust[i] + far_shift; | ||
170 | } | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | for (U32 i = 0; i < 4; i++) | ||
175 | { | ||
176 | LLVector3 vec = frust[i] - camera.getOrigin(); | ||
177 | vec.normVec(); | ||
178 | frust[i+4] = camera.getOrigin() + vec*camera.getFar()*2.0f; | ||
179 | } | ||
176 | } | 180 | } |
177 | 181 | ||
178 | calcAgentFrustumPlanes(frust); | 182 | camera.calcAgentFrustumPlanes(frust); |
179 | } | 183 | } |
180 | 184 | ||
181 | void LLViewerCamera::setPerspective(BOOL for_selection, | 185 | void LLViewerCamera::setPerspective(BOOL for_selection, |
@@ -274,7 +278,7 @@ void LLViewerCamera::setPerspective(BOOL for_selection, | |||
274 | glGetIntegerv(GL_VIEWPORT, (GLint*)gGLViewport); | 278 | glGetIntegerv(GL_VIEWPORT, (GLint*)gGLViewport); |
275 | } | 279 | } |
276 | 280 | ||
277 | updateFrustumPlanes(); | 281 | updateFrustumPlanes(*this); |
278 | 282 | ||
279 | if (gSavedSettings.getBOOL("CameraOffset")) | 283 | if (gSavedSettings.getBOOL("CameraOffset")) |
280 | { | 284 | { |
@@ -602,22 +606,34 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts) | |||
602 | return FALSE; | 606 | return FALSE; |
603 | } | 607 | } |
604 | 608 | ||
605 | num_faces = drawablep->getNumFaces(); | 609 | LLVolume* volume = volumep->getVolume(); |
610 | if (!volume) | ||
611 | { | ||
612 | return FALSE; | ||
613 | } | ||
614 | |||
615 | LLVOVolume* vo_volume = (LLVOVolume*) volumep; | ||
616 | |||
617 | vo_volume->updateRelativeXform(); | ||
618 | LLMatrix4 mat = vo_volume->getRelativeXform(); | ||
619 | |||
620 | LLMatrix4 render_mat(vo_volume->getRenderRotation(), LLVector4(vo_volume->getRenderPosition())); | ||
621 | |||
622 | num_faces = volume->getNumFaces(); | ||
606 | for (i = 0; i < num_faces; i++) | 623 | for (i = 0; i < num_faces; i++) |
607 | { | 624 | { |
608 | LLStrider<LLVector3> vertices; | 625 | const LLVolumeFace& face = volume->getVolumeFace(i); |
609 | LLFace* face = drawablep->getFace(i); | 626 | |
610 | face->getVertices(vertices); | 627 | for (U32 v = 0; v < face.mVertices.size(); v++) |
611 | |||
612 | for (S32 v = 0; v < (S32)drawablep->getFace(i)->getGeomCount(); v++) | ||
613 | { | 628 | { |
614 | LLVector3 vec = vertices[v]; | 629 | LLVector4 vec = LLVector4(face.mVertices[v].mPosition) * mat; |
615 | if (!face->isState(LLFace::GLOBAL)) | 630 | |
631 | if (drawablep->isActive()) | ||
616 | { | 632 | { |
617 | vec = vec*face->getRenderMatrix(); | 633 | vec = vec * render_mat; |
618 | } | 634 | } |
619 | 635 | ||
620 | BOOL in_frustum = pointInFrustum(vec) > 0; | 636 | BOOL in_frustum = pointInFrustum(LLVector3(vec)) > 0; |
621 | 637 | ||
622 | if ( !in_frustum && all_verts || | 638 | if ( !in_frustum && all_verts || |
623 | in_frustum && !all_verts) | 639 | in_frustum && !all_verts) |