本文整理汇总了C++中LLViewerRegion::getPosRegionFromGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ LLViewerRegion::getPosRegionFromGlobal方法的具体用法?C++ LLViewerRegion::getPosRegionFromGlobal怎么用?C++ LLViewerRegion::getPosRegionFromGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLViewerRegion
的用法示例。
在下文中一共展示了LLViewerRegion::getPosRegionFromGlobal方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
// 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;
}
}
示例2: resolveRegionGlobal
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;
}
示例3: resolveRegionAgent
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;
}
示例4: modifyLandInSelectionGlobal
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;
//.........这里部分代码省略.........
示例5: modifyLandAtPointGlobal
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());
}
}
示例6: uploadSnapshot
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));
}
示例7: updateText
//.........这里部分代码省略.........
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;
示例8: raycastForNewObjPos
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;
}
示例9: updateText
//.........这里部分代码省略.........
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;
示例10: raycastForNewObjPos
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;
}
示例11: if
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));
}
示例12: if
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));
}
示例13: if
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));
}