void LLFloaterWorldMap::onCommitSearchResult() { LLCtrlListInterface *list = childGetListInterface("search_results"); if (!list) return; LLSD selected_value = list->getSelectedValue(); std::string sim_name = selected_value.asString(); if (sim_name.empty()) { return; } LLStringUtil::toLower(sim_name); std::map<U64, LLSimInfo*>::const_iterator it; for (it = LLWorldMap::getInstance()->getRegionMap().begin(); it != LLWorldMap::getInstance()->getRegionMap().end(); ++it) { LLSimInfo* info = it->second; if (info->isName(sim_name)) { LLVector3d pos_global = info->getGlobalOrigin(); const F64 SIM_COORD_DEFAULT = 128.0; LLVector3 pos_local(SIM_COORD_DEFAULT, SIM_COORD_DEFAULT, 0.0f); // Did this value come from a trackURL() request? if (!mCompletingRegionPos.isExactlyZero()) { pos_local = mCompletingRegionPos; mCompletingRegionPos.clear(); } pos_global.mdV[VX] += (F64)pos_local.mV[VX]; pos_global.mdV[VY] += (F64)pos_local.mV[VY]; pos_global.mdV[VZ] = (F64)pos_local.mV[VZ]; childSetValue("location", sim_name); trackLocation(pos_global); setDefaultBtn("Teleport"); break; } } onShowTargetBtn(); }
LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y, BOOL rotated ) { x -= llround(getRect().getWidth() / 2 + mCurPanX); y -= llround(getRect().getHeight() / 2 + mCurPanY); LLVector3 pos_local( (F32)x, (F32)y, 0.f ); F32 radians = - atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); if( rotated ) { LLQuaternion rot(radians, LLVector3(0.f, 0.f, 1.f)); pos_local.rotVec( rot ); } pos_local *= ( LLWorld::getInstance()->getRegionWidthInMeters() / mScale ); LLVector3d pos_global; pos_global.setVec( pos_local ); pos_global += gAgent.getCameraPositionGlobal(); return pos_global; }
LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y ) { x -= llround(getRect().getWidth() / 2 + mCurPan.mV[VX]); y -= llround(getRect().getHeight() / 2 + mCurPan.mV[VY]); LLVector3 pos_local( (F32)x, (F32)y, 0 ); F32 radians = - atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); static LLUICachedControl<bool> rotate_map("MiniMapRotate", true); if( rotate_map ) { LLQuaternion rot(radians, LLVector3(0.f, 0.f, 1.f)); pos_local.rotVec( rot ); } pos_local *= ( LLWorld::getInstance()->getRegionWidthInMeters() / mScale ); LLVector3d pos_global; pos_global.setVec( pos_local ); pos_global += gAgentCamera.getCameraPositionGlobal(); return pos_global; }
int SubdivideExtrudedMesh(GModel *m) { // get all non-recombined extruded regions and vertices; also, // create a vector of quadToTri regions that have NOT been meshed // yet std::vector<GRegion*> regions, regions_quadToTri; MVertexRTree pos(CTX::instance()->geom.tolerance * CTX::instance()->lc); for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){ ExtrudeParams *ep = (*it)->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && !ep->mesh.Recombine){ regions.push_back(*it); insertAllVertices(*it, pos); } // create vector of valid quadToTri regions...not all will necessarily be meshed here. if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && ep->mesh.Recombine && ep->mesh.QuadToTri){ regions_quadToTri.push_back(*it); } } if(regions.empty()) return 0; Msg::Info("Subdividing extruded mesh"); // create edges on lateral sides of "prisms" std::set<std::pair<MVertex*, MVertex*> > edges; for(unsigned int i = 0; i < regions.size(); i++) phase1(regions[i], pos, edges); // swap lateral edges to make them "tet-compatible" int j = 0, swap; std::set<std::pair<MVertex*, MVertex*> > edges_swap; do { swap = 0; for(unsigned int i = 0; i < regions.size(); i++) phase2(regions[i], pos, edges, edges_swap, swap); Msg::Info("Swapping %d", swap); if(j && j == swap) { Msg::Error("Unable to subdivide extruded mesh: change surface mesh or"); Msg::Error("recombine extrusion instead"); return -1; } j = swap; } while(swap); // delete volume elements and create tetrahedra instead for(unsigned int i = 0; i < regions.size(); i++){ GRegion *gr = regions[i]; for(unsigned int i = 0; i < gr->tetrahedra.size(); i++) delete gr->tetrahedra[i]; gr->tetrahedra.clear(); for(unsigned int i = 0; i < gr->hexahedra.size(); i++) delete gr->hexahedra[i]; gr->hexahedra.clear(); for(unsigned int i = 0; i < gr->prisms.size(); i++) delete gr->prisms[i]; gr->prisms.clear(); for(unsigned int i = 0; i < gr->pyramids.size(); i++) delete gr->pyramids[i]; gr->pyramids.clear(); phase3(gr, pos, edges); // re-Extrude bounding surfaces using edges as constraint std::list<GFace*> faces = gr->faces(); for(std::list<GFace*>::iterator it = faces.begin(); it != faces.end(); it++){ ExtrudeParams *ep = (*it)->meshAttributes.extrude; if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && !ep->mesh.Recombine){ GFace *gf = *it; Msg::Info("Remeshing surface %d", gf->tag()); for(unsigned int i = 0; i < gf->triangles.size(); i++) delete gf->triangles[i]; gf->triangles.clear(); for(unsigned int i = 0; i < gf->quadrangles.size(); i++) delete gf->quadrangles[i]; gf->quadrangles.clear(); MeshExtrudedSurface(gf, &edges); } } } // now mesh the QuadToTri regions. Everything can be done locally // for each quadToTri region, but still use edge set from above just // to make sure laterals get remeshed properly ( // QuadToTriEdgeGenerator detects if the neighbor has been meshed or // if a lateral surface should remain static for any other reason). // If this function detects allNonGlobalSharedLaterals, it won't // mesh the region (should already be done in ExtrudeMesh). for(unsigned int i = 0; i < regions_quadToTri.size(); i++){ GRegion *gr = regions_quadToTri[i]; MVertexRTree pos_local(CTX::instance()->geom.tolerance * CTX::instance()->lc); insertAllVertices(gr, pos_local); meshQuadToTriRegionAfterGlobalSubdivide(gr, &edges, pos_local); } // carve holes if any // TODO: update extrusion information for(unsigned int i = 0; i < regions.size(); i++){ GRegion *gr = regions[i]; ExtrudeParams *ep = gr->meshAttributes.extrude; if(ep->mesh.Holes.size()){ std::map<int, std::pair<double, std::vector<int> > >::iterator it; for(it = ep->mesh.Holes.begin(); it != ep->mesh.Holes.end(); it++) carveHole(gr, it->first, it->second.first, it->second.second); } } for(unsigned int i = 0; i < regions_quadToTri.size(); i++){ GRegion *gr = regions_quadToTri[i]; ExtrudeParams *ep = gr->meshAttributes.extrude; if(ep->mesh.Holes.size()){ std::map<int, std::pair<double, std::vector<int> > >::iterator it; for(it = ep->mesh.Holes.begin(); it != ep->mesh.Holes.end(); it++) carveHole(gr, it->first, it->second.first, it->second.second); } } return 1; }