// Draw the area that will be affected. void LLToolBrushLand::render() { if(mGotHover) { //llinfos << "LLToolBrushLand::render()" << llendl; LLVector3d spot; if(gViewerWindow->mousePointOnLandGlobal(mMouseX, mMouseY, &spot)) { spot.mdV[VX] = floor( spot.mdV[VX] + 0.5 ); spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 ); mBrushSize = gSavedSettings.getF32("LandBrushSize"); region_list_t regions; determineAffectedRegions(regions, spot); // Now, for each region, render the overlay LLVector3 pos_world = gAgent.getRegion()->getPosRegionFromGlobal(spot); for(region_list_t::iterator iter = regions.begin(); iter != regions.end(); ++iter) { LLViewerRegion* region = *iter; renderOverlay(region->getLand(), region->getPosRegionFromGlobal(spot), pos_world); } } mGotHover = FALSE; } }
LLViewerRegion* LLWorld::resolveRegionGlobal(LLVector3 &pos_region, const LLVector3d &pos_global) { LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global); if (regionp) { pos_region = regionp->getPosRegionFromGlobal(pos_global); return regionp; } return NULL; }
LLViewerRegion* LLWorld::resolveRegionAgent(LLVector3 &pos_region, const LLVector3 &pos_agent) { LLVector3d pos_global = gAgent.getPosGlobalFromAgent(pos_agent); LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global); if (regionp) { pos_region = regionp->getPosRegionFromGlobal(pos_global); return regionp; } return NULL; }
void LLToolBrushLand::modifyLandInSelectionGlobal() { if (LLViewerParcelMgr::getInstance()->selectionEmpty()) { return; } if (LLToolMgr::getInstance()->getCurrentTool() == LLToolSelectLand::getInstance()) { // selecting land, don't do anything return; } LLVector3d min; LLVector3d max; LLViewerParcelMgr::getInstance()->getSelection(min, max); S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); mLastAffectedRegions.clear(); determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], min.mdV[VY], 0)); determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], max.mdV[VY], 0)); determineAffectedRegions(mLastAffectedRegions, LLVector3d(max.mdV[VX], min.mdV[VY], 0)); determineAffectedRegions(mLastAffectedRegions, LLVector3d(max.mdV[VX], max.mdV[VY], 0)); LLRegionPosition mid_point_region((min + max) * 0.5); LLViewerRegion* center_region = mid_point_region.getRegion(); if (center_region) { LLVector3 pos_region = mid_point_region.getPositionRegion(); U32 grids = center_region->getLand().mGridsPerEdge; S32 i = llclamp( (S32)pos_region.mV[VX], 0, (S32)grids ); S32 j = llclamp( (S32)pos_region.mV[VY], 0, (S32)grids ); mStartingZ = center_region->getLand().getZ(i+j*grids); } else { mStartingZ = 0.f; } // Stop if our selection include a no-terraform region for(region_list_t::iterator iter = mLastAffectedRegions.begin(); iter != mLastAffectedRegions.end(); ++iter) { LLViewerRegion* regionp = *iter; if (!canTerraform(regionp)) { alertNoTerraform(regionp); return; } } for(region_list_t::iterator iter = mLastAffectedRegions.begin(); iter != mLastAffectedRegions.end(); ++iter) { LLViewerRegion* regionp = *iter; //BOOL is_changed = FALSE; LLVector3 min_region = regionp->getPosRegionFromGlobal(min); LLVector3 max_region = regionp->getPosRegionFromGlobal(max); min_region.clamp(0.f, regionp->getWidth()); max_region.clamp(0.f, regionp->getWidth()); F32 seconds = gSavedSettings.getF32("LandBrushForce"); LLSurface &land = regionp->getLand(); char action = E_LAND_LEVEL; switch (radioAction) { case 0: // // average toward mStartingZ action = E_LAND_LEVEL; seconds *= 0.25f; break; case 1: action = E_LAND_RAISE; seconds *= 0.25f; break; case 2: action = E_LAND_LOWER; seconds *= 0.25f; break; case 3: action = E_LAND_SMOOTH; seconds *= 5.0f; break; case 4: action = E_LAND_NOISE; seconds *= 0.5f; break; case 5: action = E_LAND_REVERT; seconds = 0.5f; break; default: //action = E_LAND_INVALID; //seconds = 0.0f; return; break; } // Don't send a message to the region if nothing changed. //if(!is_changed) continue; // Now to update the patch information so it will redraw correctly. LLSurfacePatch *patchp= land.resolvePatchRegion(min_region); if (patchp) { patchp->dirtyZ(); } // Also force the property lines to update, normals to recompute, etc. regionp->forceUpdate(); // tell the simulator what we've done LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ModifyLand); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ModifyBlock); msg->addU8Fast(_PREHASH_Action, (U8)action); msg->addU8Fast(_PREHASH_BrushSize, getBrushIndex()); msg->addF32Fast(_PREHASH_Seconds, seconds); msg->addF32Fast(_PREHASH_Height, mStartingZ); BOOL parcel_selected = LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected(); LLParcel* selected_parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); if (parcel_selected && selected_parcel) { msg->nextBlockFast(_PREHASH_ParcelData); msg->addS32Fast(_PREHASH_LocalID, selected_parcel->getLocalID()); msg->addF32Fast(_PREHASH_West, min_region.mV[VX] ); msg->addF32Fast(_PREHASH_South, min_region.mV[VY] ); msg->addF32Fast(_PREHASH_East, max_region.mV[VX] ); msg->addF32Fast(_PREHASH_North, max_region.mV[VY] ); } else { msg->nextBlockFast(_PREHASH_ParcelData); msg->addS32Fast(_PREHASH_LocalID, -1); msg->addF32Fast(_PREHASH_West, min_region.mV[VX] ); msg->addF32Fast(_PREHASH_South, min_region.mV[VY] ); msg->addF32Fast(_PREHASH_East, max_region.mV[VX] ); msg->addF32Fast(_PREHASH_North, max_region.mV[VY] ); } msg->nextBlock("ModifyBlockExtended"); msg->addF32("BrushSize", mBrushSize); msg->sendMessage(regionp->getHost()); } }
void LLToolBrushLand::modifyLandAtPointGlobal(const LLVector3d &pos_global, MASK mask) { S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); mLastAffectedRegions.clear(); determineAffectedRegions(mLastAffectedRegions, pos_global); for(region_list_t::iterator iter = mLastAffectedRegions.begin(); iter != mLastAffectedRegions.end(); ++iter) { LLViewerRegion* regionp = *iter; //BOOL is_changed = FALSE; LLVector3 pos_region = regionp->getPosRegionFromGlobal(pos_global); LLSurface &land = regionp->getLand(); char action = E_LAND_LEVEL; switch (radioAction) { case 0: // // average toward mStartingZ action = E_LAND_LEVEL; break; case 1: action = E_LAND_RAISE; break; case 2: action = E_LAND_LOWER; break; case 3: action = E_LAND_SMOOTH; break; case 4: action = E_LAND_NOISE; break; case 5: action = E_LAND_REVERT; break; default: action = E_LAND_INVALID; break; } // Don't send a message to the region if nothing changed. //if(!is_changed) continue; // Now to update the patch information so it will redraw correctly. LLSurfacePatch *patchp= land.resolvePatchRegion(pos_region); if (patchp) { patchp->dirtyZ(); } // Also force the property lines to update, normals to recompute, etc. regionp->forceUpdate(); // tell the simulator what we've done F32 seconds = (1.0f / gFPSClamped) * gSavedSettings.getF32("LandBrushForce"); F32 x_pos = (F32)pos_region.mV[VX]; F32 y_pos = (F32)pos_region.mV[VY]; LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ModifyLand); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ModifyBlock); msg->addU8Fast(_PREHASH_Action, (U8)action); msg->addU8Fast(_PREHASH_BrushSize, getBrushIndex()); msg->addF32Fast(_PREHASH_Seconds, seconds); msg->addF32Fast(_PREHASH_Height, mStartingZ); msg->nextBlockFast(_PREHASH_ParcelData); msg->addS32Fast(_PREHASH_LocalID, -1); msg->addF32Fast(_PREHASH_West, x_pos ); msg->addF32Fast(_PREHASH_South, y_pos ); msg->addF32Fast(_PREHASH_East, x_pos ); msg->addF32Fast(_PREHASH_North, y_pos ); msg->nextBlock("ModifyBlockExtended"); msg->addF32("BrushSize", mBrushSize); msg->sendMessage(regionp->getHost()); } }
void KVFloaterFlickrUpload::uploadSnapshot() { mTitle = childGetValue("title_form").asString(); LLSD params; params["title"] = childGetValue("title_form"); params["safety_level"] = childGetValue("rating_combo"); std::string tags = childGetValue("tags_form"); std::string description = childGetValue("description_form"); if(childGetValue("show_position_check").asBoolean()) { // Work out where this was taken. LLVector3d clamped_global = LLWorld::getInstance()->clipToVisibleRegions(gAgent.getPositionGlobal(), mPosTakenGlobal); LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(clamped_global); if(!region) { // Clamping failed? Shouldn't happen. // Use the agent's position instead; if the region the agent is in doesn't exist we have some serious issues, // and crashing is an entirely reasonable thing to do. region = gAgent.getRegion(); clamped_global = gAgent.getPositionGlobal(); } std::string region_name = region->getName(); LLVector3 region_pos = region->getPosRegionFromGlobal(clamped_global); std::ostringstream region_tags; region_tags << " \"secondlife:region=" << region_name << "\""; region_tags << " secondlife:x=" << llround(region_pos[VX]); region_tags << " secondlife:y=" << llround(region_pos[VY]); region_tags << " secondlife:z=" << llround(region_pos[VZ]); // Now let's give some precise camera values. region_tags << " secondlife:camera_pos_x=" << (mPosTakenGlobal[VX] - region->getOriginGlobal()[VX]); region_tags << " secondlife:camera_pos_y=" << (mPosTakenGlobal[VY] - region->getOriginGlobal()[VY]); region_tags << " secondlife:camera_pos_z=" << mPosTakenGlobal[VZ]; tags += region_tags.str(); // Include an SLurl in the description, too (maybe). if(gSavedSettings.getBOOL("KittyFlickrIncludeSLURL")) { LLSLURL url(region_name, region_pos); std::ostringstream region_desc; region_desc << "<em><a href='" << url.getSLURLString() << "'>"; region_desc << "Taken at " << region_name << " ("; region_desc << llround(region_pos[VX]) << ", "; region_desc << llround(region_pos[VY]) << ", "; region_desc << llround(region_pos[VZ]) << ")"; region_desc << "</a></em>"; if(description != "") { description += "\n\n"; } description += region_desc.str(); } } params["tags"] = tags; params["description"] = description; LL_INFOS("FlickrAPI") << "Uploading snapshot with metadata: " << params << LL_ENDL; params["auth_token"] = gSavedPerAccountSettings.getLLSD("KittyFlickrToken"); LLUploadDialog::modalUploadDialog(getString("uploading")); KVFlickrRequest::uploadPhoto(params, mCompressedImage, boost::bind(&KVFloaterFlickrUpload::imageUploaded, this, _1, _2)); }
void LLHoverView::updateText() { LLViewerObject* hit_object = getLastHoverObject(); std::string line; mText.clear(); if ( hit_object ) { if ( hit_object->isHUDAttachment() ) { // no hover tips for HUD elements, since they can obscure // what the HUD is displaying return; } if ( hit_object->isAttachment() ) { // get root of attachment then parent, which is avatar LLViewerObject* root_edit = hit_object->getRootEdit(); if (!root_edit) { // Strange parenting issue, don't show any text return; } hit_object = (LLViewerObject*)root_edit->getParent(); if (!hit_object) { // another strange parenting issue, bail out return; } } line.clear(); if (hit_object->isAvatar()) { LLNameValue* title = hit_object->getNVPair("Title"); LLNameValue* firstname = hit_object->getNVPair("FirstName"); LLNameValue* lastname = hit_object->getNVPair("LastName"); if (firstname && lastname) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { line = RlvStrings::getAnonym(line.append(firstname->getString()).append(1, ' ').append(lastname->getString())); } else { // [/RLVa:KB] if (title) { line.append(title->getString()); line.append(1, ' '); } line.append(firstname->getString()); line.append(1, ' '); line.append(lastname->getString()); // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) } // [/RLVa:KB] } else { line.append(LLTrans::getString("TooltipPerson")); } mText.push_back(line); } else { // // We have hit a regular object (not an avatar or attachment) // // // Default prefs will suppress display unless the object is interactive // BOOL suppressObjectHoverDisplay = !gSavedSettings.getBOOL("ShowAllObjectHoverTip"); LLSelectNode *nodep = LLSelectMgr::getInstance()->getHoverNode();; if (nodep) { line.clear(); if (nodep->mName.empty()) { line.append(LLTrans::getString("TooltipNoName")); } else { line.append( nodep->mName ); } mText.push_back(line); if (!nodep->mDescription.empty() && nodep->mDescription != DEFAULT_DESC) { mText.push_back( nodep->mDescription ); } // Line: "Owner: James Linden" line.clear(); line.append(LLTrans::getString("TooltipOwner") + " "); if (nodep->mValid) { LLUUID owner; std::string name; if (!nodep->mPermissions->isGroupOwned()) { owner = nodep->mPermissions->getOwner(); if (LLUUID::null == owner) { line.append(LLTrans::getString("TooltipPublic")); } else if(gCacheName->getFullName(owner, name)) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { name = RlvStrings::getAnonym(name); } // [/RLVa:KB] line.append(name); } else { line.append(LLTrans::getString("RetrievingData")); } } else { std::string name; owner = nodep->mPermissions->getGroup(); if (gCacheName->getGroupName(owner, name)) { line.append(name); line.append(LLTrans::getString("TooltipIsGroup")); } else { line.append(LLTrans::getString("RetrievingData")); } } } else { line.append(LLTrans::getString("RetrievingData")); } mText.push_back(line); // Build a line describing any special properties of this object. LLViewerObject *object = hit_object; LLViewerObject *parent = (LLViewerObject *)object->getParent(); if (object && (object->usePhysics() || object->flagScripted() || object->flagHandleTouch() || (parent && parent->flagHandleTouch()) || object->flagTakesMoney() || (parent && parent->flagTakesMoney()) || object->flagAllowInventoryAdd() || object->flagTemporary() || object->flagPhantom()) ) { line.clear(); if (object->flagScripted()) { line.append(LLTrans::getString("TooltipFlagScript") + " "); } if (object->usePhysics()) { line.append(LLTrans::getString("TooltipFlagPhysics") + " "); } if (object->flagHandleTouch() || (parent && parent->flagHandleTouch()) ) { line.append(LLTrans::getString("TooltipFlagTouch") + " "); suppressObjectHoverDisplay = FALSE; // Show tip } if (object->flagTakesMoney() || (parent && parent->flagTakesMoney()) ) { line.append(LLTrans::getString("TooltipFlagL$") + " "); suppressObjectHoverDisplay = FALSE; // Show tip } if (object->flagAllowInventoryAdd()) { line.append(LLTrans::getString("TooltipFlagDropInventory") + " "); suppressObjectHoverDisplay = FALSE; // Show tip } if (object->flagPhantom()) { line.append(LLTrans::getString("TooltipFlagPhantom") + " "); } if (object->flagTemporary()) { line.append(LLTrans::getString("TooltipFlagTemporary") + " "); } if (object->usePhysics() || object->flagHandleTouch() || (parent && parent->flagHandleTouch()) ) { line.append(LLTrans::getString("TooltipFlagRightClickMenu") + " "); } mText.push_back(line); } // Free to copy / For Sale: L$ line.clear(); if (nodep->mValid) { BOOL for_copy = nodep->mPermissions->getMaskEveryone() & PERM_COPY && object->permCopy(); BOOL for_sale = nodep->mSaleInfo.isForSale() && nodep->mPermissions->getMaskOwner() & PERM_TRANSFER && (nodep->mPermissions->getMaskOwner() & PERM_COPY || nodep->mSaleInfo.getSaleType() != LLSaleInfo::FS_COPY); if (for_copy) { line.append(LLTrans::getString("TooltipFreeToCopy")); suppressObjectHoverDisplay = FALSE; // Show tip } else if (for_sale) { LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d", nodep->mSaleInfo.getSalePrice()); line.append(LLTrans::getString("TooltipForSaleL$", args)); suppressObjectHoverDisplay = FALSE; // Show tip } else { // Nothing if not for sale // line.append("Not for sale"); } } else { LLStringUtil::format_map_t args; args["[MESSAGE]"] = LLTrans::getString("RetrievingData"); line.append(LLTrans::getString("TooltipForSaleMsg", args)); } mText.push_back(line); } line.clear(); S32 prim_count = LLSelectMgr::getInstance()->getHoverObjects()->getObjectCount(); line.append(llformat("Prims: %d", prim_count)); mText.push_back(line); line.clear(); line.append("Position: "); LLViewerRegion *region = gAgent.getRegion(); LLVector3 position = region->getPosRegionFromGlobal(hit_object->getPositionGlobal());//regionp->getOriginAgent(); LLVector3 mypos = region->getPosRegionFromGlobal(gAgent.getPositionGlobal()); LLVector3 delta = position - mypos; F32 distance = (F32)delta.magVec(); line.append(llformat("<%.02f,%.02f,%.02f>",position.mV[0],position.mV[1],position.mV[2])); mText.push_back(line); line.clear(); line.append(llformat("Distance: %.02fm",distance)); mText.push_back(line); // If the hover tip shouldn't be shown, delete all the object text if (suppressObjectHoverDisplay) { mText.clear(); } } } else if ( mHoverLandGlobal != LLVector3d::zero ) { // // Do not show hover for land unless prefs are set to allow it. // if (!gSavedSettings.getBOOL("ShowLandHoverTip")) return; // Didn't hit an object, but since we have a land point we // must be hovering over land. LLParcel* hover_parcel = LLViewerParcelMgr::getInstance()->getHoverParcel(); LLUUID owner; S32 width = 0; S32 height = 0; if ( hover_parcel ) { owner = hover_parcel->getOwnerID(); width = S32(LLViewerParcelMgr::getInstance()->getHoverParcelWidth()); height = S32(LLViewerParcelMgr::getInstance()->getHoverParcelHeight()); } // Line: "Land" line.clear(); line.append(LLTrans::getString("TooltipLand")); if (hover_parcel) { // [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | Added: RLVa-0.2.0b line.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? hover_parcel->getName() : RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL) ); // [/RLVa:KB] //line.append(hover_parcel->getName()); } mText.push_back(line); // Line: "Owner: James Linden" line.clear(); line.append(LLTrans::getString("TooltipOwner") + " "); if ( hover_parcel ) { std::string name; if (LLUUID::null == owner) { line.append(LLTrans::getString("TooltipPublic")); } else if (hover_parcel->getIsGroupOwned()) { if (gCacheName->getGroupName(owner, name)) { line.append(name); line.append(LLTrans::getString("TooltipIsGroup")); } else { line.append(LLTrans::getString("RetrievingData")); } } else if(gCacheName->getFullName(owner, name)) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) | Added: RLVa-0.2.0b line.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? name : RlvStrings::getAnonym(name)); // [/RLVa:KB] //line.append(name); } else { line.append(LLTrans::getString("RetrievingData")); } } else { line.append(LLTrans::getString("RetrievingData")); } mText.push_back(line); // Line: "no fly, not safe, no build" // Don't display properties for your land. This is just // confusing, because you can do anything on your own land. if ( hover_parcel && owner != gAgent.getID() ) { S32 words = 0; line.clear(); // JC - Keep this in the same order as the checkboxes // on the land info panel if ( !hover_parcel->getAllowModify() ) { if ( hover_parcel->getAllowGroupModify() ) { line.append(LLTrans::getString("TooltipFlagGroupBuild")); } else { line.append(LLTrans::getString("TooltipFlagNoBuild")); } words++; } if ( !hover_parcel->getAllowTerraform() ) { if (words) line.append(", "); line.append(LLTrans::getString("TooltipFlagNoEdit")); words++; } if ( hover_parcel->getAllowDamage() ) { if (words) line.append(", "); line.append(LLTrans::getString("TooltipFlagNotSafe")); words++; } // Maybe we should reflect the estate's block fly bit here as well? DK 12/1/04 if ( !hover_parcel->getAllowFly() ) { if (words) line.append(", "); line.append(LLTrans::getString("TooltipFlagNoFly")); words++; } if ( !hover_parcel->getAllowOtherScripts() ) { if (words) line.append(", "); if ( hover_parcel->getAllowGroupScripts() ) { line.append(LLTrans::getString("TooltipFlagGroupScripts")); } else { line.append(LLTrans::getString("TooltipFlagNoScripts")); } words++; } if (words) { mText.push_back(line); } } // Line: "Size: 1x4" // Only show for non-public land /* if ( hover_parcel && LLUUID::null != owner) { line = llformat("Size: %dx%d", width, height ); mText.push_back(line); } */ if (hover_parcel && hover_parcel->getParcelFlag(PF_FOR_SALE)) { LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d", hover_parcel->getSalePrice()); line = LLTrans::getString("TooltipForSaleL$", args); mText.push_back(line); } } }
BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj, S32* hit_face, BOOL* b_hit_land, LLVector3* ray_start_region, LLVector3* ray_end_region, LLViewerRegion** region ) { F32 max_dist_from_camera = gSavedSettings.getF32( "MaxSelectDistance" ) - 1.f; // Viewer-side pick to find the right sim to create the object on. // First find the surface the object will be created on. gViewerWindow->hitObjectOrLandGlobalImmediate(x, y, NULL, FALSE); // Note: use the frontmost non-flora version because (a) plants usually have lots of alpha and (b) pants' Havok // representations (if any) are NOT the same as their viewer representation. *hit_obj = gObjectList.findObject( gLastHitNonFloraObjectID ); *hit_face = gLastHitNonFloraObjectFace; *b_hit_land = !(*hit_obj) && !gLastHitNonFloraPosGlobal.isExactlyZero(); LLVector3d land_pos_global = gLastHitNonFloraPosGlobal; // Make sure there's a surface to place the new object on. BOOL bypass_sim_raycast = FALSE; LLVector3d surface_pos_global; if (*b_hit_land) { surface_pos_global = land_pos_global; bypass_sim_raycast = TRUE; } else if (*hit_obj) { surface_pos_global = (*hit_obj)->getPositionGlobal(); } else { return FALSE; } // Make sure the surface isn't too far away. LLVector3d ray_start_global = gAgent.getCameraPositionGlobal(); F32 dist_to_surface_sq = (F32)((surface_pos_global - ray_start_global).magVecSquared()); if( dist_to_surface_sq > (max_dist_from_camera * max_dist_from_camera) ) { return FALSE; } // Find the sim where the surface lives. LLViewerRegion *regionp = gWorldp->getRegionFromPosGlobal(surface_pos_global); if (!regionp) { llwarns << "Trying to add object outside of all known regions!" << llendl; return FALSE; } // Find the simulator-side ray that will be used to place the object accurately LLVector3d mouse_direction; mouse_direction.setVec( gViewerWindow->mouseDirectionGlobal( x, y ) ); *region = regionp; *ray_start_region = regionp->getPosRegionFromGlobal( ray_start_global ); F32 near_clip = gCamera->getNear() + 0.01f; // Include an epsilon to avoid rounding issues. *ray_start_region += gCamera->getAtAxis() * near_clip; if( bypass_sim_raycast ) { // Hack to work around Havok's inability to ray cast onto height fields *ray_end_region = regionp->getPosRegionFromGlobal( surface_pos_global ); // ray end is the viewer's intersection point } else { LLVector3d ray_end_global = ray_start_global + (1.f + max_dist_from_camera) * mouse_direction; // add an epsilon to the sim version of the ray to avoid rounding problems. *ray_end_region = regionp->getPosRegionFromGlobal( ray_end_global ); } return TRUE; }
void LLHoverView::updateText() { LLViewerObject* hit_object = getLastHoverObject(); std::string line; //<singu> if (hit_object == mLastTextHoverObject && !(mLastTextHoverObjectTimer.getStarted() && mLastTextHoverObjectTimer.hasExpired())) { // mText is already up to date. return; } mLastTextHoverObject = hit_object; mLastTextHoverObjectTimer.stop(); bool retrieving_data = false; //</singu> mText.clear(); if ( hit_object ) { if ( hit_object->isHUDAttachment() ) { // no hover tips for HUD elements, since they can obscure // what the HUD is displaying return; } if ( hit_object->isAttachment() ) { // get root of attachment then parent, which is avatar LLViewerObject* root_edit = hit_object->getRootEdit(); if (!root_edit) { // Strange parenting issue, don't show any text return; } hit_object = (LLViewerObject*)root_edit->getParent(); if (!hit_object) { // another strange parenting issue, bail out return; } } line.clear(); if (hit_object->isAvatar()) { LLNameValue* title = hit_object->getNVPair("Title"); LLNameValue* firstname = hit_object->getNVPair("FirstName"); LLNameValue* lastname = hit_object->getNVPair("LastName"); if (firstname && lastname) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { line = RlvStrings::getAnonym(line.append(firstname->getString()).append(1, ' ').append(lastname->getString())); } else { // [/RLVa:KB] std::string complete_name; if (!LLAvatarNameCache::getNSName(hit_object->getID(), complete_name)) complete_name = firstname->getString() + std::string(" ") + lastname->getString(); if (title) { line.append(title->getString()); line.append(1, ' '); } line += complete_name; // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) } // [/RLVa:KB] } else { line.append(LLTrans::getString("TooltipPerson")); } mText.push_back(line); } else { // // We have hit a regular object (not an avatar or attachment) // // // Default prefs will suppress display unless the object is interactive // BOOL suppressObjectHoverDisplay = !gSavedSettings.getBOOL("ShowAllObjectHoverTip"); LLSelectNode *nodep = LLSelectMgr::getInstance()->getHoverNode(); if (nodep) { line.clear(); bool for_copy = nodep->mValid && nodep->mPermissions->getMaskEveryone() & PERM_COPY && hit_object && hit_object->permCopy(); bool for_sale = nodep->mValid && for_sale_selection(nodep); bool has_media = false; bool is_time_based_media = false; bool is_web_based_media = false; bool is_media_playing = false; bool is_media_displaying = false; // Does this face have media? const LLTextureEntry* tep = hit_object ? hit_object->getTE(mLastPickInfo.mObjectFace) : NULL; if(tep) { has_media = tep->hasMedia(); const LLMediaEntry* mep = has_media ? tep->getMediaData() : NULL; if (mep) { viewer_media_t media_impl = LLViewerMedia::getMediaImplFromTextureID(mep->getMediaID()); LLPluginClassMedia* media_plugin = NULL; if (media_impl.notNull() && (media_impl->hasMedia())) { is_media_displaying = true; //LLStringUtil::format_map_t args; media_plugin = media_impl->getMediaPlugin(); if(media_plugin) { if(media_plugin->pluginSupportsMediaTime()) { is_time_based_media = true; is_web_based_media = false; //args["[CurrentURL]"] = media_impl->getMediaURL(); is_media_playing = media_impl->isMediaPlaying(); } else { is_time_based_media = false; is_web_based_media = true; //args["[CurrentURL]"] = media_plugin->getLocation(); } //tooltip_msg.append(LLTrans::getString("CurrentURL", args)); } } } } // Avoid showing tip over media that's displaying unless it's for sale // also check the primary node since sometimes it can have an action even though // the root node doesn't if(!suppressObjectHoverDisplay || !is_media_displaying || for_sale) { if (nodep->mName.empty()) { line.append(LLTrans::getString("TooltipNoName")); } else { line.append( nodep->mName ); } mText.push_back(line); if (!nodep->mDescription.empty() && nodep->mDescription != DEFAULT_DESC) { mText.push_back( nodep->mDescription ); } // Line: "Owner: James Linden" line.clear(); line.append(LLTrans::getString("TooltipOwner") + " "); if (nodep->mValid) { LLUUID owner; std::string name; if (!nodep->mPermissions->isGroupOwned()) { owner = nodep->mPermissions->getOwner(); if (LLUUID::null == owner) { line.append(LLTrans::getString("TooltipPublic")); } else if (LLAvatarNameCache::getNSName(owner, name)) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) { name = RlvStrings::getAnonym(name); } // [/RLVa:KB] line.append(name); } else { line.append(LLTrans::getString("RetrievingData")); retrieving_data = true; } } else { std::string name; owner = nodep->mPermissions->getGroup(); if (gCacheName->getGroupName(owner, name)) { line.append(name); line.append(LLTrans::getString("TooltipIsGroup")); } else { line.append(LLTrans::getString("RetrievingData")); retrieving_data = true; } } } else { line.append(LLTrans::getString("RetrievingData")); retrieving_data = true; } mText.push_back(line); // Build a line describing any special properties of this object. LLViewerObject *object = hit_object; LLViewerObject *parent = (LLViewerObject *)object->getParent(); if (object && (object->flagUsePhysics() || object->flagScripted() || object->flagHandleTouch() || (parent && parent->flagHandleTouch()) || object->flagTakesMoney() || (parent && parent->flagTakesMoney()) || object->flagAllowInventoryAdd() || object->flagTemporary() || object->flagPhantom()) ) { line.clear(); if (object->flagScripted()) { line.append(LLTrans::getString("TooltipFlagScript") + " "); } if (object->flagUsePhysics()) { line.append(LLTrans::getString("TooltipFlagPhysics") + " "); } if (object->flagHandleTouch() || (parent && parent->flagHandleTouch()) ) { line.append(LLTrans::getString("TooltipFlagTouch") + " "); suppressObjectHoverDisplay = FALSE; // Show tip } if (object->flagTakesMoney() || (parent && parent->flagTakesMoney()) ) { line.append(gHippoGridManager->getConnectedGrid()->getCurrencySymbol() + " "); suppressObjectHoverDisplay = FALSE; // Show tip } if (object->flagAllowInventoryAdd()) { line.append(LLTrans::getString("TooltipFlagDropInventory") + " "); suppressObjectHoverDisplay = FALSE; // Show tip } if (object->flagPhantom()) { line.append(LLTrans::getString("TooltipFlagPhantom") + " "); } if (object->flagTemporary()) { line.append(LLTrans::getString("TooltipFlagTemporary") + " "); } if (object->flagUsePhysics() || object->flagHandleTouch() || (parent && parent->flagHandleTouch()) ) { line.append(LLTrans::getString("TooltipFlagRightClickMenu") + " "); } mText.push_back(line); } // Free to copy / For Sale: L$ line.clear(); if (nodep->mValid) { if (for_copy) { line.append(LLTrans::getString("TooltipFreeToCopy")); suppressObjectHoverDisplay = FALSE; // Show tip } else if (for_sale) { LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d", nodep->mSaleInfo.getSalePrice()); line.append(LLTrans::getString("TooltipForSaleL$", args)); suppressObjectHoverDisplay = FALSE; // Show tip } else { // Nothing if not for sale // line.append("Not for sale"); } } else { LLStringUtil::format_map_t args; args["[MESSAGE]"] = LLTrans::getString("RetrievingData"); retrieving_data = true; line.append(LLTrans::getString("TooltipForSaleMsg", args)); } mText.push_back(line); line.clear(); S32 prim_count = LLSelectMgr::getInstance()->getHoverObjects()->getObjectCount(); line.append(llformat("Prims: %d", prim_count)); mText.push_back(line); line.clear(); line.append("Position: "); LLViewerRegion *region = gAgent.getRegion(); LLVector3 position = region->getPosRegionFromGlobal(hit_object->getPositionGlobal());//regionp->getOriginAgent(); LLVector3 mypos = region->getPosRegionFromGlobal(gAgent.getPositionGlobal()); LLVector3 delta = position - mypos; F32 distance = (F32)delta.magVec(); line.append(llformat("<%.02f,%.02f,%.02f>",position.mV[0],position.mV[1],position.mV[2])); mText.push_back(line); line.clear(); line.append(llformat("Distance: %.02fm",distance)); mText.push_back(line); } else { suppressObjectHoverDisplay = TRUE; } // If the hover tip shouldn't be shown, delete all the object text if (suppressObjectHoverDisplay) { mText.clear(); } } } } else if ( mHoverLandGlobal != LLVector3d::zero ) { // // Do not show hover for land unless prefs are set to allow it. // if (!gSavedSettings.getBOOL("ShowLandHoverTip")) return; // Didn't hit an object, but since we have a land point we // must be hovering over land. LLParcel* hover_parcel = LLViewerParcelMgr::getInstance()->getHoverParcel(); LLUUID owner; if ( hover_parcel ) { owner = hover_parcel->getOwnerID(); } // Line: "Land" line.clear(); line.append(LLTrans::getString("TooltipLand")); if (hover_parcel) { // [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) | Added: RLVa-0.2.0b line.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? hover_parcel->getName() : RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL) ); // [/RLVa:KB] //line.append(hover_parcel->getName()); } mText.push_back(line); // Line: "Owner: James Linden" line.clear(); line.append(LLTrans::getString("TooltipOwner") + " "); if ( hover_parcel ) { std::string name; if (LLUUID::null == owner) { line.append(LLTrans::getString("TooltipPublic")); } else if (hover_parcel->getIsGroupOwned()) { if (gCacheName->getGroupName(owner, name)) { line.append(name); line.append(LLTrans::getString("TooltipIsGroup")); } else { line.append(LLTrans::getString("RetrievingData")); retrieving_data = true; } } else if(gCacheName->getFullName(owner, name)) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) | Added: RLVa-0.2.0b line.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? name : RlvStrings::getAnonym(name)); // [/RLVa:KB] //line.append(name); } else { line.append(LLTrans::getString("RetrievingData")); retrieving_data = true; } } else { line.append(LLTrans::getString("RetrievingData")); retrieving_data = true; } mText.push_back(line); // Line: "no fly, not safe, no build" // Don't display properties for your land. This is just // confusing, because you can do anything on your own land. if ( hover_parcel && owner != gAgent.getID() ) { S32 words = 0; line.clear(); // JC - Keep this in the same order as the checkboxes // on the land info panel if ( !hover_parcel->getAllowModify() ) { if ( hover_parcel->getAllowGroupModify() ) { line.append(LLTrans::getString("TooltipFlagGroupBuild")); } else { line.append(LLTrans::getString("TooltipFlagNoBuild")); } words++; } if ( !hover_parcel->getAllowTerraform() ) { if (words) line.append(", "); line.append(LLTrans::getString("TooltipFlagNoEdit")); words++; } if ( hover_parcel->getAllowDamage() ) { if (words) line.append(", "); line.append(LLTrans::getString("TooltipFlagNotSafe")); words++; } // Maybe we should reflect the estate's block fly bit here as well? DK 12/1/04 if ( !hover_parcel->getAllowFly() ) { if (words) line.append(", "); line.append(LLTrans::getString("TooltipFlagNoFly")); words++; } if ( !hover_parcel->getAllowOtherScripts() ) { if (words) line.append(", "); if ( hover_parcel->getAllowGroupScripts() ) { line.append(LLTrans::getString("TooltipFlagGroupScripts")); } else { line.append(LLTrans::getString("TooltipFlagNoScripts")); } words++; } if (words) { mText.push_back(line); } } if (hover_parcel && hover_parcel->getParcelFlag(PF_FOR_SALE)) { LLStringUtil::format_map_t args; args["[AMOUNT]"] = llformat("%d", hover_parcel->getSalePrice()); line = LLTrans::getString("TooltipForSaleL$", args); mText.push_back(line); } } //<singu> if (retrieving_data) { // Keep doing this twice per second, until all data was retrieved. mLastTextHoverObjectTimer.start(DELAY_BEFORE_REFRESH_TIP); } //</singu> }
BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj, S32* hit_face, BOOL* b_hit_land, LLVector3* ray_start_region, LLVector3* ray_end_region, LLViewerRegion** region ) { F32 max_dist_from_camera = gSavedSettings.getF32( "MaxSelectDistance" ) - 1.f; // Viewer-side pick to find the right sim to create the object on. // First find the surface the object will be created on. LLPickInfo pick = gViewerWindow->pickImmediate(x, y, FALSE); // Note: use the frontmost non-flora version because (a) plants usually have lots of alpha and (b) pants' Havok // representations (if any) are NOT the same as their viewer representation. if (pick.mPickType == LLPickInfo::PICK_FLORA) { *hit_obj = NULL; *hit_face = -1; } else { *hit_obj = pick.getObject(); *hit_face = pick.mObjectFace; } *b_hit_land = !(*hit_obj) && !pick.mPosGlobal.isExactlyZero(); LLVector3d land_pos_global = pick.mPosGlobal; // Make sure there's a surface to place the new object on. BOOL bypass_sim_raycast = FALSE; LLVector3d surface_pos_global; if (*b_hit_land) { surface_pos_global = land_pos_global; bypass_sim_raycast = TRUE; } else if (*hit_obj) { surface_pos_global = (*hit_obj)->getPositionGlobal(); } else { return FALSE; } // Make sure the surface isn't too far away. LLVector3d ray_start_global = gAgentCamera.getCameraPositionGlobal(); F32 dist_to_surface_sq = (F32)((surface_pos_global - ray_start_global).magVecSquared()); if( dist_to_surface_sq > (max_dist_from_camera * max_dist_from_camera) ) { return FALSE; } // [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) | Modified: RLVa-0.2.0f // NOTE: don't use surface_pos_global since for prims it will be the center of the prim while we need center + offset if ( (gRlvHandler.hasBehaviour(RLV_BHVR_FARTOUCH)) && (dist_vec_squared(gAgent.getPositionGlobal(), pick.mPosGlobal) > 1.5f * 1.5f) ) { return FALSE; } // [/RLVa:KB] // Find the sim where the surface lives. LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(surface_pos_global); if (!regionp) { llwarns << "Trying to add object outside of all known regions!" << llendl; return FALSE; } // Find the simulator-side ray that will be used to place the object accurately LLVector3d mouse_direction; mouse_direction.setVec( gViewerWindow->mouseDirectionGlobal( x, y ) ); *region = regionp; *ray_start_region = regionp->getPosRegionFromGlobal( ray_start_global ); F32 near_clip = LLViewerCamera::getInstance()->getNear() + 0.01f; // Include an epsilon to avoid rounding issues. *ray_start_region += LLViewerCamera::getInstance()->getAtAxis() * near_clip; if( bypass_sim_raycast ) { // Hack to work around Havok's inability to ray cast onto height fields *ray_end_region = regionp->getPosRegionFromGlobal( surface_pos_global ); // ray end is the viewer's intersection point } else { LLVector3d ray_end_global = ray_start_global + (1.f + max_dist_from_camera) * mouse_direction; // add an epsilon to the sim version of the ray to avoid rounding problems. *ray_end_region = regionp->getPosRegionFromGlobal( ray_end_global ); } return TRUE; }
LLVector3d LLWorld::clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos) { if (positionRegionValidGlobal(end_pos)) { return end_pos; } LLViewerRegion* regionp = getRegionFromPosGlobal(start_pos); if (!regionp) { return start_pos; } LLVector3d delta_pos = end_pos - start_pos; LLVector3d delta_pos_abs; delta_pos_abs.setVec(delta_pos); delta_pos_abs.abs(); LLVector3 region_coord = regionp->getPosRegionFromGlobal(end_pos); F64 clip_factor = 1.0; F32 region_width = regionp->getWidth(); if (region_coord.mV[VX] < 0.f) { if (region_coord.mV[VY] < region_coord.mV[VX]) { // clip along y - clip_factor = -(region_coord.mV[VY] / delta_pos_abs.mdV[VY]); } else { // clip along x - clip_factor = -(region_coord.mV[VX] / delta_pos_abs.mdV[VX]); } } else if (region_coord.mV[VX] > region_width) { if (region_coord.mV[VY] > region_coord.mV[VX]) { // clip along y + clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY]; } else { //clip along x + clip_factor = (region_coord.mV[VX] - region_width) / delta_pos_abs.mdV[VX]; } } else if (region_coord.mV[VY] < 0.f) { // clip along y - clip_factor = -(region_coord.mV[VY] / delta_pos_abs.mdV[VY]); } else if (region_coord.mV[VY] > region_width) { // clip along y + clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY]; } // clamp to within region dimensions LLVector3d final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor); final_region_pos.mdV[VX] = llclamp(final_region_pos.mdV[VX], 0.0, (F64)(region_width - F_ALMOST_ZERO)); final_region_pos.mdV[VY] = llclamp(final_region_pos.mdV[VY], 0.0, (F64)(region_width - F_ALMOST_ZERO)); final_region_pos.mdV[VZ] = llclamp(final_region_pos.mdV[VZ], 0.0, (F64)(LLWorld::getInstance()->getRegionMaxHeight() - F_ALMOST_ZERO)); return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos)); }
LLVector3d LLWorld::clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos) { if (positionRegionValidGlobal(end_pos)) { return end_pos; } LLViewerRegion* regionp = getRegionFromPosGlobal(start_pos); if (!regionp) { return start_pos; } LLVector3d delta_pos = end_pos - start_pos; LLVector3d delta_pos_abs; delta_pos_abs.setVec(delta_pos); delta_pos_abs.abs(); LLVector3 region_coord = regionp->getPosRegionFromGlobal(end_pos); F64 clip_factor = 1.0; F32 region_width = regionp->getWidth(); if (region_coord.mV[VX] < 0.f) { if (region_coord.mV[VY] < region_coord.mV[VX]) { // clip along y - clip_factor = -(region_coord.mV[VY] / delta_pos_abs.mdV[VY]); } else { // clip along x - clip_factor = -(region_coord.mV[VX] / delta_pos_abs.mdV[VX]); } } else if (region_coord.mV[VX] > region_width) { if (region_coord.mV[VY] > region_coord.mV[VX]) { // clip along y + clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY]; } else { //clip along x + clip_factor = (region_coord.mV[VX] - region_width) / delta_pos_abs.mdV[VX]; } } else if (region_coord.mV[VY] < 0.f) { // clip along y - clip_factor = -(region_coord.mV[VY] / delta_pos_abs.mdV[VY]); } else if (region_coord.mV[VY] > region_width) { // clip along y + clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY]; } // clamp to < 256 to stay in sim LLVector3d final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor); final_region_pos.clamp(0.0, 255.999); return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos)); }
LLVector3d LLWorld::clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos) { if (positionRegionValidGlobal(end_pos)) { return end_pos; } LLViewerRegion* regionp = getRegionFromPosGlobal(start_pos); if (!regionp) { return start_pos; } LLVector3d delta_pos = end_pos - start_pos; LLVector3d delta_pos_abs; delta_pos_abs.setVec(delta_pos); delta_pos_abs.abs(); LLVector3 region_coord = regionp->getPosRegionFromGlobal(end_pos); F64 clip_factor = 1.0; F32 region_width = regionp->getWidth(); if (region_coord.mV[VX] < 0.f) { if (region_coord.mV[VY] < region_coord.mV[VX]) { // clip along y - clip_factor = -(region_coord.mV[VY] / delta_pos_abs.mdV[VY]); } else { // clip along x - clip_factor = -(region_coord.mV[VX] / delta_pos_abs.mdV[VX]); } } else if (region_coord.mV[VX] > region_width) { if (region_coord.mV[VY] > region_coord.mV[VX]) { // clip along y + clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY]; } else { //clip along x + clip_factor = (region_coord.mV[VX] - region_width) / delta_pos_abs.mdV[VX]; } } else if (region_coord.mV[VY] < 0.f) { // clip along y - clip_factor = -(region_coord.mV[VY] / delta_pos_abs.mdV[VY]); } else if (region_coord.mV[VY] > region_width) { // clip along y + clip_factor = (region_coord.mV[VY] - region_width) / delta_pos_abs.mdV[VY]; } // clamp to < 256 to stay in sim LLVector3d final_region_pos = LLVector3d(region_coord) - (delta_pos * clip_factor); // clamp x, y to [0,256[ and z to [0,REGION_HEIGHT_METERS] (the clamp function cannot be used here) if (final_region_pos.mdV[VX] < 0) final_region_pos.mdV[VX] = 0.0; if (final_region_pos.mdV[VY] < 0) final_region_pos.mdV[VY] = 0.0; if (final_region_pos.mdV[VZ] < 0) final_region_pos.mdV[VZ] = 0.0; if (final_region_pos.mdV[VX] > 255.999) final_region_pos.mdV[VX] = 255.999; if (final_region_pos.mdV[VY] > 255.999) final_region_pos.mdV[VY] = 255.999; if (final_region_pos.mdV[VZ] > REGION_HEIGHT_METERS) final_region_pos.mdV[VZ] = REGION_HEIGHT_METERS; //final_region_pos.clamp(0.0, 255.999); return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos)); }