diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llagent.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llagent.cpp')
-rw-r--r-- | linden/indra/newview/llagent.cpp | 158 |
1 files changed, 45 insertions, 113 deletions
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp index 77e743d..2dab8ff 100644 --- a/linden/indra/newview/llagent.cpp +++ b/linden/indra/newview/llagent.cpp | |||
@@ -463,7 +463,6 @@ void LLAgent::cleanup() | |||
463 | mPointAt = NULL; | 463 | mPointAt = NULL; |
464 | mRegionp = NULL; | 464 | mRegionp = NULL; |
465 | setFocusObject(NULL); | 465 | setFocusObject(NULL); |
466 | mFadeObjects.clear(); | ||
467 | } | 466 | } |
468 | 467 | ||
469 | //----------------------------------------------------------------------------- | 468 | //----------------------------------------------------------------------------- |
@@ -833,20 +832,18 @@ void LLAgent::setRegion(LLViewerRegion *regionp) | |||
833 | 832 | ||
834 | setPositionAgent(getPositionAgent() - delta); | 833 | setPositionAgent(getPositionAgent() - delta); |
835 | LLVector3 camera_position_agent = gCamera->getOrigin(); | 834 | LLVector3 camera_position_agent = gCamera->getOrigin(); |
835 | |||
836 | gCamera->setOrigin(camera_position_agent - delta); | 836 | gCamera->setOrigin(camera_position_agent - delta); |
837 | 837 | ||
838 | // Update all of the regions. | 838 | // Update all of the regions. |
839 | gWorldPointer->updateAgentOffset(agent_offset_global); | 839 | gWorldPointer->updateAgentOffset(agent_offset_global); |
840 | 840 | ||
841 | // Hack to keep sky in the agent's region, otherwise it may get deleted - DJS 08/02/02 | 841 | // Hack to keep sky in the agent's region, otherwise it may get deleted - DJS 08/02/02 |
842 | // *TODO: possibly refactor into gSky->setAgentRegion(regionp)? -Brad | ||
842 | if (gSky.mVOSkyp) | 843 | if (gSky.mVOSkyp) |
843 | { | 844 | { |
844 | gSky.mVOSkyp->setRegion(regionp); | 845 | gSky.mVOSkyp->setRegion(regionp); |
845 | } | 846 | } |
846 | if (gSky.mVOStarsp) | ||
847 | { | ||
848 | gSky.mVOStarsp->setRegion(regionp); | ||
849 | } | ||
850 | if (gSky.mVOGroundp) | 847 | if (gSky.mVOGroundp) |
851 | { | 848 | { |
852 | gSky.mVOGroundp->setRegion(regionp); | 849 | gSky.mVOGroundp->setRegion(regionp); |
@@ -969,12 +966,12 @@ void LLAgent::sendReliableMessage() | |||
969 | { | 966 | { |
970 | if (gDisconnected) | 967 | if (gDisconnected) |
971 | { | 968 | { |
972 | llwarns << "Trying to send message when disconnected!" << llendl; | 969 | lldebugs << "Trying to send message when disconnected!" << llendl; |
973 | return; | 970 | return; |
974 | } | 971 | } |
975 | if (!mRegionp) | 972 | if (!mRegionp) |
976 | { | 973 | { |
977 | llwarns << "LLAgent::sendReliableMessage No region for agent yet, not sending message!" << llendl; | 974 | lldebugs << "LLAgent::sendReliableMessage No region for agent yet, not sending message!" << llendl; |
978 | return; | 975 | return; |
979 | } | 976 | } |
980 | gMessageSystem->sendReliable(mRegionp->getHost()); | 977 | gMessageSystem->sendReliable(mRegionp->getHost()); |
@@ -1390,12 +1387,6 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1390 | if (!is_avatar) | 1387 | if (!is_avatar) |
1391 | { | 1388 | { |
1392 | //unproject relative clicked coordinate from window coordinate using GL | 1389 | //unproject relative clicked coordinate from window coordinate using GL |
1393 | glPushMatrix(); | ||
1394 | glMatrixMode(GL_PROJECTION); | ||
1395 | glLoadMatrixf((const GLfloat*) gCamera->getProjection().mMatrix); | ||
1396 | glMatrixMode(GL_MODELVIEW); | ||
1397 | glLoadMatrixf((const GLfloat*) gCamera->getModelview().mMatrix); | ||
1398 | glMultMatrixf((const GLfloat*) obj_matrix.mMatrix); | ||
1399 | 1390 | ||
1400 | GLint viewport[4]; | 1391 | GLint viewport[4]; |
1401 | GLdouble modelview[16]; | 1392 | GLdouble modelview[16]; |
@@ -1403,8 +1394,16 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1403 | GLfloat winX, winY, winZ; | 1394 | GLfloat winX, winY, winZ; |
1404 | GLdouble posX, posY, posZ; | 1395 | GLdouble posX, posY, posZ; |
1405 | 1396 | ||
1406 | glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); | 1397 | // convert our matrices to something that has a multiply that works |
1407 | glGetDoublev( GL_PROJECTION_MATRIX, projection ); | 1398 | glh::matrix4f newModel((F32*)gCamera->getModelview().mMatrix); |
1399 | glh::matrix4f tmpObjMat((F32*)obj_matrix.mMatrix); | ||
1400 | newModel *= tmpObjMat; | ||
1401 | |||
1402 | for(U32 i = 0; i < 16; ++i) | ||
1403 | { | ||
1404 | modelview[i] = newModel.m[i]; | ||
1405 | projection[i] = gCamera->getProjection().mMatrix[i/4][i%4]; | ||
1406 | } | ||
1408 | glGetIntegerv( GL_VIEWPORT, viewport ); | 1407 | glGetIntegerv( GL_VIEWPORT, viewport ); |
1409 | 1408 | ||
1410 | winX = ((F32)x) * gViewerWindow->getDisplayScale().mV[VX]; | 1409 | winX = ((F32)x) * gViewerWindow->getDisplayScale().mV[VX]; |
@@ -1413,14 +1412,12 @@ LLVector3d LLAgent::calcFocusOffset(LLViewerObject *object, S32 x, S32 y) | |||
1413 | 1412 | ||
1414 | gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); | 1413 | gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); |
1415 | 1414 | ||
1416 | glPopMatrix(); | 1415 | LLVector3 obj_rel((F32)posX, (F32)posY, (F32)posZ); |
1417 | 1416 | obj_rel = obj_rel * object->getRenderMatrix(); | |
1418 | LLVector3 obj_rel = LLVector3((F32)posX, (F32)posY, (F32)posZ); | 1417 | obj_rel -= object->getRenderPosition(); |
1419 | LLVector3 obj_center = LLVector3(0, 0, 0); | ||
1420 | obj_rel = obj_rel * object->getRenderMatrix(); //mDrawable->getWorldMatrix(); | ||
1421 | obj_center = obj_center * object->getRenderMatrix();//mDrawable->getWorldMatrix(); | ||
1422 | obj_rel -= object->getRenderPosition();//mDrawable->getWorldPosition(); | ||
1423 | 1418 | ||
1419 | LLVector3 obj_center = LLVector3(0, 0, 0) * object->getRenderMatrix(); | ||
1420 | |||
1424 | //now that we have the object relative position, we should bias toward the center of the object | 1421 | //now that we have the object relative position, we should bias toward the center of the object |
1425 | //based on the distance of the camera to the focus point vs. the distance of the camera to the focus | 1422 | //based on the distance of the camera to the focus point vs. the distance of the camera to the focus |
1426 | 1423 | ||
@@ -3151,74 +3148,6 @@ void LLAgent::updateCamera() | |||
3151 | mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); | 3148 | mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); |
3152 | camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); | 3149 | camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); |
3153 | 3150 | ||
3154 | // do alpha fade on focus object | ||
3155 | F32 fade_increment = mFocusObjectFadeTimer.getElapsedTimeAndResetF32(); | ||
3156 | |||
3157 | if (mFocusObject.notNull() && !mFocusObject->isAttachment() && mFocusObject->mDrawable.notNull()) | ||
3158 | { | ||
3159 | F32 increment = fade_increment; | ||
3160 | if (mFocusObjectDist < -0.2f) | ||
3161 | { | ||
3162 | increment *= -1.f; | ||
3163 | } | ||
3164 | |||
3165 | if (mFocusObject->getVObjRadius() > MIN_RADIUS_ALPHA_SIZZLE) | ||
3166 | { | ||
3167 | S32 num_faces = mFocusObject->mDrawable->getNumFaces(); | ||
3168 | for (S32 i = 0; i < num_faces; i++) | ||
3169 | { | ||
3170 | LLFace* facep = mFocusObject->mDrawable->getFace(i); | ||
3171 | F32 fade = facep->mAlphaFade; | ||
3172 | fade = llclamp(fade + increment, 0.f, 1.f); | ||
3173 | facep->mAlphaFade = fade; | ||
3174 | } | ||
3175 | } | ||
3176 | } | ||
3177 | |||
3178 | // do alpha fade in on fade objects | ||
3179 | std::set< LLPointer<LLViewerObject> >::iterator fade_object_it; | ||
3180 | for (fade_object_it = mFadeObjects.begin(); fade_object_it != mFadeObjects.end(); ) | ||
3181 | { | ||
3182 | LLViewerObject* fade_object = *fade_object_it; | ||
3183 | if (fade_object->isDead()) | ||
3184 | { | ||
3185 | // remove from list | ||
3186 | mFadeObjects.erase(fade_object_it++); | ||
3187 | } | ||
3188 | else | ||
3189 | { | ||
3190 | LLDrawable* drawablep = fade_object->mDrawable; | ||
3191 | if (drawablep && fade_object->getVObjRadius() > MIN_RADIUS_ALPHA_SIZZLE) | ||
3192 | { | ||
3193 | S32 num_faces = drawablep->getNumFaces(); | ||
3194 | BOOL fade_done = TRUE; | ||
3195 | for (S32 i = 0; i < num_faces; i++) | ||
3196 | { | ||
3197 | LLFace* facep = drawablep->getFace(i); | ||
3198 | F32 fade = facep->mAlphaFade; | ||
3199 | fade = llclamp(fade - fade_increment, 0.f, 1.f); | ||
3200 | facep->mAlphaFade = fade; | ||
3201 | if (fade > 0.f) | ||
3202 | { | ||
3203 | fade_done = FALSE; | ||
3204 | } | ||
3205 | } | ||
3206 | if (fade_done) | ||
3207 | { | ||
3208 | mFadeObjects.erase(fade_object_it++); | ||
3209 | } | ||
3210 | else | ||
3211 | { | ||
3212 | fade_object_it++; | ||
3213 | } | ||
3214 | } | ||
3215 | else | ||
3216 | { | ||
3217 | fade_object_it++; | ||
3218 | } | ||
3219 | } | ||
3220 | } | ||
3221 | |||
3222 | mShowAvatar = TRUE; // can see avatar by default | 3151 | mShowAvatar = TRUE; // can see avatar by default |
3223 | 3152 | ||
3224 | // Adjust position for animation | 3153 | // Adjust position for animation |
@@ -3373,10 +3302,11 @@ void LLAgent::updateCamera() | |||
3373 | 3302 | ||
3374 | mAvatarObject->mRoot.updateWorldMatrixChildren(); | 3303 | mAvatarObject->mRoot.updateWorldMatrixChildren(); |
3375 | 3304 | ||
3376 | for(LLViewerJointAttachment *attachment = mAvatarObject->mAttachmentPoints.getFirstData(); | 3305 | for (LLVOAvatar::attachment_map_t::iterator iter = mAvatarObject->mAttachmentPoints.begin(); |
3377 | attachment; | 3306 | iter != mAvatarObject->mAttachmentPoints.end(); ) |
3378 | attachment = mAvatarObject->mAttachmentPoints.getNextData()) | ||
3379 | { | 3307 | { |
3308 | LLVOAvatar::attachment_map_t::iterator curiter = iter++; | ||
3309 | LLViewerJointAttachment* attachment = curiter->second; | ||
3380 | LLViewerObject *attached_object = attachment->getObject(); | 3310 | LLViewerObject *attached_object = attachment->getObject(); |
3381 | if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull()) | 3311 | if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull()) |
3382 | { | 3312 | { |
@@ -4315,19 +4245,6 @@ void LLAgent::clearFocusObject() | |||
4315 | 4245 | ||
4316 | void LLAgent::setFocusObject(LLViewerObject* object) | 4246 | void LLAgent::setFocusObject(LLViewerObject* object) |
4317 | { | 4247 | { |
4318 | if (mFocusObject.notNull() && | ||
4319 | mFocusObject->mDrawable.notNull() && | ||
4320 | mFocusObject->getPCode() == LL_PCODE_VOLUME && | ||
4321 | mFocusObject != object) | ||
4322 | { | ||
4323 | LLPointer<LLViewerObject> fade_object_ptr(mFocusObject); | ||
4324 | |||
4325 | if (fade_object_ptr.notNull() && mFadeObjects.find(fade_object_ptr) == mFadeObjects.end()) | ||
4326 | { | ||
4327 | mFadeObjects.insert(fade_object_ptr); | ||
4328 | } | ||
4329 | } | ||
4330 | |||
4331 | mFocusObject = object; | 4248 | mFocusObject = object; |
4332 | } | 4249 | } |
4333 | 4250 | ||
@@ -5749,6 +5666,19 @@ bool LLAgent::teleportCore(bool is_local) | |||
5749 | return false; | 5666 | return false; |
5750 | } | 5667 | } |
5751 | 5668 | ||
5669 | // Stop all animation before actual teleporting | ||
5670 | LLVOAvatar* avatarp = gAgent.getAvatarObject(); | ||
5671 | if (avatarp) | ||
5672 | { | ||
5673 | for ( LLVOAvatar::AnimIterator anim_it= avatarp->mPlayingAnimations.begin() | ||
5674 | ; anim_it != avatarp->mPlayingAnimations.end() | ||
5675 | ; anim_it++) | ||
5676 | { | ||
5677 | avatarp->stopMotion(anim_it->first); | ||
5678 | } | ||
5679 | avatarp->processAnimationStateChanges(); | ||
5680 | } | ||
5681 | |||
5752 | // Don't call LLFirstUse::useTeleport because we don't know | 5682 | // Don't call LLFirstUse::useTeleport because we don't know |
5753 | // yet if the teleport will succeed. Look in | 5683 | // yet if the teleport will succeed. Look in |
5754 | // process_teleport_location_reply | 5684 | // process_teleport_location_reply |
@@ -5769,6 +5699,9 @@ bool LLAgent::teleportCore(bool is_local) | |||
5769 | { | 5699 | { |
5770 | gTeleportDisplay = TRUE; | 5700 | gTeleportDisplay = TRUE; |
5771 | gAgent.setTeleportState( LLAgent::TELEPORT_START ); | 5701 | gAgent.setTeleportState( LLAgent::TELEPORT_START ); |
5702 | |||
5703 | //release geometry from old location | ||
5704 | gPipeline.resetVertexBuffers(); | ||
5772 | } | 5705 | } |
5773 | make_ui_sound("UISndTeleportOut"); | 5706 | make_ui_sound("UISndTeleportOut"); |
5774 | 5707 | ||
@@ -6830,11 +6763,10 @@ void LLAgent::makeNewOutfit( | |||
6830 | { | 6763 | { |
6831 | BOOL msg_started = FALSE; | 6764 | BOOL msg_started = FALSE; |
6832 | LLMessageSystem* msg = gMessageSystem; | 6765 | LLMessageSystem* msg = gMessageSystem; |
6833 | S32 i; | 6766 | for( S32 i = 0; i < attachments_to_include.count(); i++ ) |
6834 | for( i = 0; i < attachments_to_include.count(); i++ ) | ||
6835 | { | 6767 | { |
6836 | S32 attachment_pt = attachments_to_include[i]; | 6768 | S32 attachment_pt = attachments_to_include[i]; |
6837 | LLViewerJointAttachment* attachment = mAvatarObject->mAttachmentPoints.getIfThere( attachment_pt ); | 6769 | LLViewerJointAttachment* attachment = get_if_there(mAvatarObject->mAttachmentPoints, attachment_pt, (LLViewerJointAttachment*)NULL ); |
6838 | if(!attachment) continue; | 6770 | if(!attachment) continue; |
6839 | LLViewerObject* attached_object = attachment->getObject(); | 6771 | LLViewerObject* attached_object = attachment->getObject(); |
6840 | if(!attached_object) continue; | 6772 | if(!attached_object) continue; |
@@ -7454,11 +7386,11 @@ void LLAgent::userRemoveAllAttachments( void* userdata ) | |||
7454 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); | 7386 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); |
7455 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | 7387 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); |
7456 | 7388 | ||
7457 | LLViewerJointAttachment* attachment; | 7389 | for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); |
7458 | for (attachment = avatarp->mAttachmentPoints.getFirstData(); | 7390 | iter != avatarp->mAttachmentPoints.end(); ) |
7459 | attachment; | ||
7460 | attachment = avatarp->mAttachmentPoints.getNextData()) | ||
7461 | { | 7391 | { |
7392 | LLVOAvatar::attachment_map_t::iterator curiter = iter++; | ||
7393 | LLViewerJointAttachment* attachment = curiter->second; | ||
7462 | LLViewerObject* objectp = attachment->getObject(); | 7394 | LLViewerObject* objectp = attachment->getObject(); |
7463 | if (objectp) | 7395 | if (objectp) |
7464 | { | 7396 | { |