diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/newview/llworld.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llworld.cpp | 101 |
1 files changed, 58 insertions, 43 deletions
diff --git a/linden/indra/newview/llworld.cpp b/linden/indra/newview/llworld.cpp index 60312db..8c95260 100644 --- a/linden/indra/newview/llworld.cpp +++ b/linden/indra/newview/llworld.cpp | |||
@@ -61,7 +61,6 @@ | |||
61 | // | 61 | // |
62 | // Globals | 62 | // Globals |
63 | // | 63 | // |
64 | LLWorld* gWorldp = NULL; | ||
65 | U32 gAgentPauseSerialNum = 0; | 64 | U32 gAgentPauseSerialNum = 0; |
66 | 65 | ||
67 | // | 66 | // |
@@ -72,15 +71,19 @@ const S32 WORLD_PATCH_SIZE = 16; | |||
72 | 71 | ||
73 | extern LLColor4U MAX_WATER_COLOR; | 72 | extern LLColor4U MAX_WATER_COLOR; |
74 | 73 | ||
74 | const U32 LLWorld::mWidth = 256; | ||
75 | |||
76 | // meters/point, therefore mWidth * mScale = meters per edge | ||
77 | const F32 LLWorld::mScale = 1.f; | ||
78 | |||
79 | const F32 LLWorld::mWidthInMeters = mWidth * mScale; | ||
80 | |||
75 | // | 81 | // |
76 | // Functions | 82 | // Functions |
77 | // | 83 | // |
78 | 84 | ||
79 | // allocate the stack | 85 | // allocate the stack |
80 | LLWorld::LLWorld(const U32 grids_per_region, const F32 meters_per_grid) | 86 | LLWorld::LLWorld() |
81 | : mWidth(grids_per_region), | ||
82 | mScale(meters_per_grid), | ||
83 | mWidthInMeters( grids_per_region * meters_per_grid ) | ||
84 | { | 87 | { |
85 | mSpaceTimeUSec = 0; | 88 | mSpaceTimeUSec = 0; |
86 | mLastPacketsIn = 0; | 89 | mLastPacketsIn = 0; |
@@ -112,10 +115,15 @@ LLWorld::LLWorld(const U32 grids_per_region, const F32 meters_per_grid) | |||
112 | } | 115 | } |
113 | 116 | ||
114 | 117 | ||
115 | LLWorld::~LLWorld() | 118 | void LLWorld::destroyClass() |
116 | { | 119 | { |
117 | gObjectList.killAllObjects(); | 120 | gObjectList.destroy(); |
118 | for_each(mRegionList.begin(), mRegionList.end(), DeletePointer()); | 121 | for(region_list_t::iterator region_it = mRegionList.begin(); region_it != mRegionList.end(); ) |
122 | { | ||
123 | LLViewerRegion* region_to_delete = *region_it++; | ||
124 | removeRegion(region_to_delete->getHost()); | ||
125 | } | ||
126 | LLViewerPartSim::getInstance()->destroyClass(); | ||
119 | } | 127 | } |
120 | 128 | ||
121 | 129 | ||
@@ -523,6 +531,11 @@ F32 LLWorld::resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d | |||
523 | intersection.mdV[VZ] -= norm_dist_from_plane * segment_length; | 531 | intersection.mdV[VZ] -= norm_dist_from_plane * segment_length; |
524 | intersection_normal = foot_plane_normal; | 532 | intersection_normal = foot_plane_normal; |
525 | } | 533 | } |
534 | else | ||
535 | { | ||
536 | intersection = land_intersection; | ||
537 | intersection_normal = resolveLandNormalGlobal(land_intersection); | ||
538 | } | ||
526 | } | 539 | } |
527 | 540 | ||
528 | return normalized_land_distance; | 541 | return normalized_land_distance; |
@@ -556,9 +569,9 @@ LLVector3 LLWorld::resolveLandNormalGlobal(const LLVector3d &pos_global) | |||
556 | 569 | ||
557 | void LLWorld::updateVisibilities() | 570 | void LLWorld::updateVisibilities() |
558 | { | 571 | { |
559 | F32 cur_far_clip = gCamera->getFar(); | 572 | F32 cur_far_clip = LLViewerCamera::getInstance()->getFar(); |
560 | 573 | ||
561 | gCamera->setFar(mLandFarClip); | 574 | LLViewerCamera::getInstance()->setFar(mLandFarClip); |
562 | 575 | ||
563 | F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; | 576 | F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; |
564 | // Go through the culled list and check for visible regions | 577 | // Go through the culled list and check for visible regions |
@@ -570,7 +583,7 @@ void LLWorld::updateVisibilities() | |||
570 | F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); | 583 | F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); |
571 | F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); | 584 | F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); |
572 | if (!regionp->getLand().hasZData() | 585 | if (!regionp->getLand().hasZData() |
573 | || gCamera->sphereInFrustum(regionp->getCenterAgent(), radius)) | 586 | || LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) |
574 | { | 587 | { |
575 | mCulledRegionList.erase(curiter); | 588 | mCulledRegionList.erase(curiter); |
576 | mVisibleRegionList.push_back(regionp); | 589 | mVisibleRegionList.push_back(regionp); |
@@ -590,7 +603,7 @@ void LLWorld::updateVisibilities() | |||
590 | 603 | ||
591 | F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); | 604 | F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); |
592 | F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); | 605 | F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); |
593 | if (gCamera->sphereInFrustum(regionp->getCenterAgent(), radius)) | 606 | if (LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) |
594 | { | 607 | { |
595 | regionp->calculateCameraDistance(); | 608 | regionp->calculateCameraDistance(); |
596 | if (!gNoRender) | 609 | if (!gNoRender) |
@@ -608,7 +621,7 @@ void LLWorld::updateVisibilities() | |||
608 | // Sort visible regions | 621 | // Sort visible regions |
609 | mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); | 622 | mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); |
610 | 623 | ||
611 | gCamera->setFar(cur_far_clip); | 624 | LLViewerCamera::getInstance()->setFar(cur_far_clip); |
612 | } | 625 | } |
613 | 626 | ||
614 | void LLWorld::updateRegions(F32 max_update_time) | 627 | void LLWorld::updateRegions(F32 max_update_time) |
@@ -631,7 +644,7 @@ void LLWorld::updateRegions(F32 max_update_time) | |||
631 | 644 | ||
632 | void LLWorld::updateParticles() | 645 | void LLWorld::updateParticles() |
633 | { | 646 | { |
634 | mPartSim.updateSimulation(); | 647 | LLViewerPartSim::getInstance()->updateSimulation(); |
635 | } | 648 | } |
636 | 649 | ||
637 | void LLWorld::updateClouds(const F32 dt) | 650 | void LLWorld::updateClouds(const F32 dt) |
@@ -727,19 +740,19 @@ void LLWorld::updateNetStats() | |||
727 | 740 | ||
728 | S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); | 741 | S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); |
729 | S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); | 742 | S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); |
730 | gViewerStats->mActualInKBitStat.addValue(actual_in_bits/1024.f); | 743 | LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); |
731 | gViewerStats->mActualOutKBitStat.addValue(actual_out_bits/1024.f); | 744 | LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); |
732 | gViewerStats->mKBitStat.addValue(bits/1024.f); | 745 | LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); |
733 | gViewerStats->mPacketsInStat.addValue(packets_in); | 746 | LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); |
734 | gViewerStats->mPacketsOutStat.addValue(packets_out); | 747 | LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); |
735 | gViewerStats->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); | 748 | LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); |
736 | if (packets_in) | 749 | if (packets_in) |
737 | { | 750 | { |
738 | gViewerStats->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in)); | 751 | LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in)); |
739 | } | 752 | } |
740 | else | 753 | else |
741 | { | 754 | { |
742 | gViewerStats->mPacketsLostPercentStat.addValue(0.f); | 755 | LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f); |
743 | } | 756 | } |
744 | 757 | ||
745 | mLastPacketsIn = gMessageSystem->mPacketsIn; | 758 | mLastPacketsIn = gMessageSystem->mPacketsIn; |
@@ -771,8 +784,7 @@ void LLWorld::printPacketsLost() | |||
771 | 784 | ||
772 | void LLWorld::processCoarseUpdate(LLMessageSystem* msg, void** user_data) | 785 | void LLWorld::processCoarseUpdate(LLMessageSystem* msg, void** user_data) |
773 | { | 786 | { |
774 | if(!gWorldp) return; | 787 | LLViewerRegion* region = LLWorld::getInstance()->getRegion(msg->getSender()); |
775 | LLViewerRegion* region = gWorldp->getRegion(msg->getSender()); | ||
776 | if( region ) | 788 | if( region ) |
777 | { | 789 | { |
778 | region->updateCoarseLocations(msg); | 790 | region->updateCoarseLocations(msg); |
@@ -812,7 +824,7 @@ void LLWorld::updateWaterObjects() | |||
812 | S32 rwidth = 256; | 824 | S32 rwidth = 256; |
813 | 825 | ||
814 | // We only want to fill in water for stuff that's near us, say, within 256 or 512m | 826 | // We only want to fill in water for stuff that's near us, say, within 256 or 512m |
815 | S32 range = gCamera->getFar() > 256.f ? 512 : 256; | 827 | S32 range = LLViewerCamera::getInstance()->getFar() > 256.f ? 512 : 256; |
816 | 828 | ||
817 | LLViewerRegion* regionp = gAgent.getRegion(); | 829 | LLViewerRegion* regionp = gAgent.getRegion(); |
818 | from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); | 830 | from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); |
@@ -940,7 +952,7 @@ void LLWorld::shiftRegions(const LLVector3& offset) | |||
940 | region->updateRenderMatrix(); | 952 | region->updateRenderMatrix(); |
941 | } | 953 | } |
942 | 954 | ||
943 | mPartSim.shift(offset); | 955 | LLViewerPartSim::getInstance()->shift(offset); |
944 | } | 956 | } |
945 | 957 | ||
946 | LLViewerImage* LLWorld::getDefaultWaterTexture() | 958 | LLViewerImage* LLWorld::getDefaultWaterTexture() |
@@ -1022,8 +1034,7 @@ void process_enable_simulator(LLMessageSystem *msg, void **user_data) | |||
1022 | 1034 | ||
1023 | // Viewer trusts the simulator. | 1035 | // Viewer trusts the simulator. |
1024 | msg->enableCircuit(sim, TRUE); | 1036 | msg->enableCircuit(sim, TRUE); |
1025 | if(!gWorldp) return; | 1037 | LLWorld::getInstance()->addRegion(handle, sim); |
1026 | gWorldp->addRegion(handle, sim); | ||
1027 | 1038 | ||
1028 | // give the simulator a message it can use to get ip and port | 1039 | // give the simulator a message it can use to get ip and port |
1029 | llinfos << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << llendl; | 1040 | llinfos << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << llendl; |
@@ -1060,8 +1071,7 @@ public: | |||
1060 | 1071 | ||
1061 | LLHost sim(input["body"]["sim-ip-and-port"].asString()); | 1072 | LLHost sim(input["body"]["sim-ip-and-port"].asString()); |
1062 | 1073 | ||
1063 | if(!gWorldp) return; | 1074 | LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(sim); |
1064 | LLViewerRegion* regionp = gWorldp->getRegion(sim); | ||
1065 | if (!regionp) | 1075 | if (!regionp) |
1066 | { | 1076 | { |
1067 | llwarns << "Got EstablishAgentCommunication for unknown region " | 1077 | llwarns << "Got EstablishAgentCommunication for unknown region " |
@@ -1079,8 +1089,7 @@ void process_disable_simulator(LLMessageSystem *mesgsys, void **user_data) | |||
1079 | LLHost host = mesgsys->getSender(); | 1089 | LLHost host = mesgsys->getSender(); |
1080 | 1090 | ||
1081 | //llinfos << "Disabling simulator with message from " << host << llendl; | 1091 | //llinfos << "Disabling simulator with message from " << host << llendl; |
1082 | if(!gWorldp) return; | 1092 | LLWorld::getInstance()->removeRegion(host); |
1083 | gWorldp->removeRegion(host); | ||
1084 | 1093 | ||
1085 | mesgsys->disableCircuit(host); | 1094 | mesgsys->disableCircuit(host); |
1086 | } | 1095 | } |
@@ -1089,8 +1098,7 @@ void process_disable_simulator(LLMessageSystem *mesgsys, void **user_data) | |||
1089 | void process_region_handshake(LLMessageSystem* msg, void** user_data) | 1098 | void process_region_handshake(LLMessageSystem* msg, void** user_data) |
1090 | { | 1099 | { |
1091 | LLHost host = msg->getSender(); | 1100 | LLHost host = msg->getSender(); |
1092 | if(!gWorldp) return; | 1101 | LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(host); |
1093 | LLViewerRegion* regionp = gWorldp->getRegion(host); | ||
1094 | if (!regionp) | 1102 | if (!regionp) |
1095 | { | 1103 | { |
1096 | llwarns << "Got region handshake for unknown region " | 1104 | llwarns << "Got region handshake for unknown region " |
@@ -1104,8 +1112,10 @@ void process_region_handshake(LLMessageSystem* msg, void** user_data) | |||
1104 | 1112 | ||
1105 | void send_agent_pause() | 1113 | void send_agent_pause() |
1106 | { | 1114 | { |
1107 | // world not initialized yet | 1115 | // Note: used to check for LLWorld initialization before it became a singleton. |
1108 | if (!gWorldp) | 1116 | // Rather than just remove this check I'm changing it to assure that the message |
1117 | // system has been initialized. -MG | ||
1118 | if (!gMessageSystem) | ||
1109 | { | 1119 | { |
1110 | return; | 1120 | return; |
1111 | } | 1121 | } |
@@ -1118,8 +1128,8 @@ void send_agent_pause() | |||
1118 | gAgentPauseSerialNum++; | 1128 | gAgentPauseSerialNum++; |
1119 | gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); | 1129 | gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); |
1120 | 1130 | ||
1121 | for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); | 1131 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin(); |
1122 | iter != gWorldp->mActiveRegionList.end(); ++iter) | 1132 | iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter) |
1123 | { | 1133 | { |
1124 | LLViewerRegion* regionp = *iter; | 1134 | LLViewerRegion* regionp = *iter; |
1125 | gMessageSystem->sendReliable(regionp->getHost()); | 1135 | gMessageSystem->sendReliable(regionp->getHost()); |
@@ -1131,8 +1141,13 @@ void send_agent_pause() | |||
1131 | 1141 | ||
1132 | void send_agent_resume() | 1142 | void send_agent_resume() |
1133 | { | 1143 | { |
1134 | // world not initialized yet | 1144 | // Note: used to check for LLWorld initialization before it became a singleton. |
1135 | if (!gWorldp) return; | 1145 | // Rather than just remove this check I'm changing it to assure that the message |
1146 | // system has been initialized. -MG | ||
1147 | if (!gMessageSystem) | ||
1148 | { | ||
1149 | return; | ||
1150 | } | ||
1136 | 1151 | ||
1137 | gMessageSystem->newMessageFast(_PREHASH_AgentResume); | 1152 | gMessageSystem->newMessageFast(_PREHASH_AgentResume); |
1138 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); | 1153 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); |
@@ -1143,15 +1158,15 @@ void send_agent_resume() | |||
1143 | gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); | 1158 | gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); |
1144 | 1159 | ||
1145 | 1160 | ||
1146 | for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); | 1161 | for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin(); |
1147 | iter != gWorldp->mActiveRegionList.end(); ++iter) | 1162 | iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter) |
1148 | { | 1163 | { |
1149 | LLViewerRegion* regionp = *iter; | 1164 | LLViewerRegion* regionp = *iter; |
1150 | gMessageSystem->sendReliable(regionp->getHost()); | 1165 | gMessageSystem->sendReliable(regionp->getHost()); |
1151 | } | 1166 | } |
1152 | 1167 | ||
1153 | // Reset the FPS counter to avoid an invalid fps | 1168 | // Reset the FPS counter to avoid an invalid fps |
1154 | gViewerStats->mFPSStat.start(); | 1169 | LLViewerStats::getInstance()->mFPSStat.start(); |
1155 | } | 1170 | } |
1156 | 1171 | ||
1157 | 1172 | ||