本文整理汇总了C++中dist_vec函数的典型用法代码示例。如果您正苦于以下问题:C++ dist_vec函数的具体用法?C++ dist_vec怎么用?C++ dist_vec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dist_vec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSpeaker
void LLLocalSpeakerMgr::updateSpeakerList()
{
// pull speakers from voice channel
LLSpeakerMgr::updateSpeakerList();
// add non-voice speakers in chat range
std::vector< LLCharacter* >::iterator avatar_it;
for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it)
{
LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it;
if (!avatarp->isDead() && dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= CHAT_NORMAL_RADIUS)
{
setSpeaker(avatarp->getID());
}
}
// check if text only speakers have moved out of chat range
for (speaker_map_t::iterator speaker_it = mSpeakers.begin(); speaker_it != mSpeakers.end(); ++speaker_it)
{
LLUUID speaker_id = speaker_it->first;
LLSpeaker* speakerp = speaker_it->second;
if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY)
{
LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id);
if (!avatarp || avatarp->isDead() || dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS)
{
speakerp->mStatus = LLSpeaker::STATUS_NOT_IN_CHANNEL;
speakerp->mDotColor = INACTIVE_COLOR;
speakerp->mActivityTimer.resetWithExpiry(SPEAKER_TIMEOUT);
}
}
}
}
示例2:
RealGradient
SmoothSuperellipsoidBaseIC::computeSuperellipsoidGradient(const Point & p, const Point & center, const Real & a, const Real & b, const Real & /*c*/, const Real & n)
{
Point l_center = center;
Point l_p = p;
//Compute the distance between the current point and the center
Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
//Compute the distance r from the center of the superellipsoid to its outside edge
//along the vector from the center to the current point
//This uses the equation for a superellipse in polar coordinates and substitutes
//distances for sin, cos functions
Point dist_vec = _mesh.minPeriodicVector(_var.number(), center, p);
//First calculate rmn = r^(-n)
Real rmn = (std::pow(std::abs(dist_vec(0)/dist/a), n) + std::pow(std::abs(dist_vec(1)/dist/b), n));
//Then calculate r
Real r = std::pow(rmn, (-1.0/n));
Real DvalueDr = 0.0;
if (dist < r + _int_width/2.0 && dist > r - _int_width/2.0)
{
Real int_pos = (dist - r + _int_width / 2.0) / _int_width;
Real Dint_posDr = 1.0 / _int_width;
DvalueDr = Dint_posDr * (_invalue - _outvalue) * (-std::sin(int_pos * libMesh::pi) * libMesh::pi) / 2.0;
}
//Set gradient over the smooth interface
if (dist != 0.0)
return dist_vec * (DvalueDr / dist);
else
return 0.0;
}
示例3: dist_vec
void QToolAlign::computeManipulatorSize()
{
if (LLSelectMgr::getInstance()->getSelection()->getSelectType() == SELECT_TYPE_HUD)
{
mManipulatorSize = MANIPULATOR_SIZE / (LLViewerCamera::getInstance()->getViewHeightInPixels() *
gAgentCamera.mHUDCurZoom);
}
else
{
F32 distance = dist_vec(gAgentCamera.getCameraPositionAgent(), mBBox.getCenterAgent());
if (distance > 0.001f)
{
// range != zero
F32 fraction_of_fov = MANIPULATOR_SIZE /LLViewerCamera::getInstance()->getViewHeightInPixels();
F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView(); // radians
mManipulatorSize = MANIPULATOR_SIZE * distance * tan(apparent_angle);
}
else
{
// range == zero
mManipulatorSize = MANIPULATOR_SIZE;
}
}
}
示例4: Vec3f
void FEdgeXDetector::preProcessFace(WXFace *iFace)
{
Vec3f firstPoint = iFace->GetVertex(0)->GetVertex();
Vec3f N = iFace->GetNormal();
// Compute the dot product between V (=_Viewpoint - firstPoint) and N:
Vec3f V;
if (_orthographicProjection) {
V = Vec3f(0.0f, 0.0f, _Viewpoint.z() - firstPoint.z());
}
else {
V = Vec3f(_Viewpoint - firstPoint);
}
N.normalize();
V.normalize();
iFace->setDotP(N * V);
// compute the distance between the face center and the viewpoint:
if (_orthographicProjection) {
iFace->setZ(iFace->center().z() - _Viewpoint.z());
}
else {
Vec3f dist_vec(iFace->center() - _Viewpoint);
iFace->setZ(dist_vec.norm());
}
}
示例5: unpackLocalToGlobalPosition
void LLWorld::getAvatars(std::vector<LLUUID>* avatar_ids, std::vector<LLVector3d>* positions, const LLVector3d& relative_to, F32 radius) const
{
if(avatar_ids != NULL)
{
avatar_ids->clear();
}
if(positions != NULL)
{
positions->clear();
}
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
LLViewerRegion* regionp = *iter;
const LLVector3d& origin_global = regionp->getOriginGlobal();
S32 count = regionp->mMapAvatars.count();
for (S32 i = 0; i < count; i++)
{
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars.get(i), origin_global);
if(dist_vec(pos_global, relative_to) <= radius)
{
if(positions != NULL)
{
positions->push_back(pos_global);
}
if(avatar_ids != NULL)
{
avatar_ids->push_back(regionp->mMapAvatarIDs.get(i));
}
}
}
}
}
示例6: switch
//static
void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color)
{
if(chat.mMuted)
{
r_color= LLUIColorTable::instance().getColor("LtGray");
}
else
{
switch(chat.mSourceType)
{
case CHAT_SOURCE_SYSTEM:
r_color = LLUIColorTable::instance().getColor("SystemChatColor");
break;
case CHAT_SOURCE_AGENT:
if (chat.mFromID.isNull() || SYSTEM_FROM == chat.mFromName)
{
r_color = LLUIColorTable::instance().getColor("SystemChatColor");
}
else
{
if(gAgentID == chat.mFromID)
{
r_color = LLUIColorTable::instance().getColor("UserChatColor");
}
else
{
r_color = LLUIColorTable::instance().getColor("AgentChatColor");
}
}
break;
case CHAT_SOURCE_OBJECT:
if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
{
r_color = LLUIColorTable::instance().getColor("ScriptErrorColor");
}
else if ( chat.mChatType == CHAT_TYPE_OWNER )
{
r_color = LLUIColorTable::instance().getColor("llOwnerSayChatColor");
}
else
{
r_color = LLUIColorTable::instance().getColor("ObjectChatColor");
}
break;
default:
r_color.setToWhite();
}
if (!chat.mPosAgent.isExactlyZero())
{
LLVector3 pos_agent = gAgent.getPositionAgent();
F32 distance = dist_vec(pos_agent, chat.mPosAgent);
if (distance > gAgent.getNearChatRadius())
{
// diminish far-off chat
r_color.mV[VALPHA] = 0.8f;
}
}
}
}
示例7: setSpeaker
void LLLocalSpeakerMgr::updateSpeakerList()
{
// pull speakers from voice channel
LLSpeakerMgr::updateSpeakerList();
if (gDisconnected)//the world is cleared.
{
return ;
}
// pick up non-voice speakers in chat range
uuid_vec_t avatar_ids;
std::vector<LLVector3d> positions;
LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgent.getPositionGlobal(), CHAT_NORMAL_RADIUS);
for(U32 i=0; i<avatar_ids.size(); i++)
{
setSpeaker(avatar_ids[i]);
}
// check if text only speakers have moved out of chat range
for (speaker_map_t::iterator speaker_it = mSpeakers.begin(); speaker_it != mSpeakers.end(); ++speaker_it)
{
LLUUID speaker_id = speaker_it->first;
LLSpeaker* speakerp = speaker_it->second;
if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY)
{
LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id);
if (!avatarp || dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS)
{
setSpeakerNotInChannel(speakerp);
}
}
}
}
示例8: setLookAt
//-----------------------------------------------------------------------------
// setLookAt()
// called by agent logic to set look at behavior locally, and propagate to sim
//-----------------------------------------------------------------------------
BOOL LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
{
if (!mSourceObject)
{
return FALSE;
}
if (target_type >= LOOKAT_NUM_TARGETS)
{
llwarns << "Bad target_type " << (int)target_type << " - ignoring." << llendl;
return FALSE;
}
// must be same or higher priority than existing effect
if ((*mAttentions)[target_type].mPriority < (*mAttentions)[mTargetType].mPriority)
{
return FALSE;
}
F32 current_time = mTimer.getElapsedTimeF32();
// type of lookat behavior or target object has changed
BOOL lookAtChanged = (target_type != mTargetType) || (object != mTargetObject);
// lookat position has moved a certain amount and we haven't just sent an update
lookAtChanged = lookAtChanged || ((dist_vec(position, mLastSentOffsetGlobal) > MIN_DELTAPOS_FOR_UPDATE) &&
((current_time - mLastSendTime) > (1.f / MAX_SENDS_PER_SEC)));
if (lookAtChanged)
{
mLastSentOffsetGlobal = position;
F32 timeout = (*mAttentions)[target_type].mTimeout;
setDuration(timeout);
setNeedsSendToSim(TRUE);
}
if (target_type == LOOKAT_TARGET_CLEAR)
{
clearLookAtTarget();
}
else
{
mTargetType = target_type;
mTargetObject = object;
if (object)
{
mTargetOffsetGlobal.setVec(position);
}
else
{
mTargetOffsetGlobal = gAgent.getPosGlobalFromAgent(position);
}
mKillTime = mTimer.getElapsedTimeF32() + mDuration;
update();
}
return TRUE;
}
示例9: find
void LLFloaterHUD::find() // Scanner activated by Scan button
{
if(mHalt) return; // this basically checks if the scan has been toggled on or off otherwise llvoavatar calls the scan on avatar activity
mListNames->deleteAllItems(); //Clear the list
std::vector< LLCharacter* >::iterator avatar_it;
for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it)
{
LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it;
if (avatarp->isDead() || avatarp->isSelf()) //Dont show the user!
{
continue;
}
if (dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= SCAN_MAX_RADIUS) //Scanner radius set in indra constants.
{
// Pull in that avatar data!
std::string name = avatarp->getFullname();
LLVector3d position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition());
LLUUID avid = avatarp->getID();
// Work out distance relative to user!
LLVector3d mypos = gAgent.getPositionGlobal();
LLVector3d delta = position - mypos;
F32 distance = (F32)delta.magVec();
//Build the list
LLSD element;
element["id"] = avid;
element["columns"][LIST_AVATAR_NAME]["column"] = "name";
element["columns"][LIST_AVATAR_NAME]["value"] = name;
element["columns"][LIST_DISTANCE]["column"] = "distance";
element["columns"][LIST_DISTANCE]["value"] = distance;
mListNames->addElement(element);
mListNames->sortByColumn("distance", TRUE);
mListNames->setCallbackUserData(this);
}
}
return;
}
示例10: vec4
void v4math_object::test<19>()
{
F32 x1 =-2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, y2 = 1.f, z2 = 1.f;
F32 val1,val2;
LLVector4 vec4(x1,y1,z1),vec4a(x2,y2,z2);
val1 = dist_vec(vec4,vec4a);
val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
ensure_equals("dist_vec: Fail ",val2, val1);
val1 = dist_vec_squared(vec4,vec4a);
val2 =((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
ensure_equals("dist_vec_squared: Fail ",val2, val1);
}
示例11: V
void FEdgeXDetector::preProcessFace(WXFace *iFace){
Vec3r firstPoint = iFace->GetVertex(0)->GetVertex();
Vec3r N = iFace->GetNormal();
// Compute the dot product between V (=_Viewpoint - firstPoint) and N:
Vec3r V(_Viewpoint - firstPoint);
N.normalize();
V.normalize();
iFace->SetDotP(N * V);
// compute the distance between the face center and the viewpoint:
Vec3r dist_vec(iFace->center() - _Viewpoint);
iFace->SetZ(dist_vec.norm());
}
示例12: if
Real
SmoothSuperellipsoidBaseIC::computeSuperellipsoidValue(const Point & p, const Point & center, const Real & a, const Real & b, const Real & c, const Real & n)
{
Point l_center = center;
Point l_p = p;
//Compute the distance between the current point and the center
Real dist = _mesh.minPeriodicDistance(_var.number(), l_p, l_center);
//When dist is 0 we are exactly at the center of the superellipsoid so return _invalue
//Handle this case independently because we cannot calculate polar angles at this point
if (dist == 0.0) return _invalue;
//Compute the distance r from the center of the superellipsoid to its outside edge
//along the vector from the center to the current point
//This uses the equation for a superellipse in polar coordinates and substitutes
//distances for sin, cos functions
Point dist_vec = _mesh.minPeriodicVector(_var.number(), center, p);
//First calculate rmn = r^(-n), replacing sin, cos functions with distances
Real rmn = (std::pow(std::abs(dist_vec(0) / dist / a), n)
+ std::pow(std::abs(dist_vec(1) / dist / b), n)
+ std::pow(std::abs(dist_vec(2) / dist / c), n) );
//Then calculate r from rmn
Real r = std::pow(rmn, (-1.0/n));
Real value = _outvalue; //Outside superellipsoid
if (dist <= r - _int_width/2.0) //Inside superellipsoid
value = _invalue;
else if (dist < r + _int_width/2.0) //Smooth interface
{
Real int_pos = (dist - r + _int_width/2.0)/_int_width;
value = _outvalue + (_invalue - _outvalue) * (1.0 + std::cos(int_pos * libMesh::pi)) / 2.0;
}
return value;
}
示例13: WXFaceLayer
void FEdgeXDetector::ProcessSilhouetteFace(WXFace *iFace, bool meshSilhouettes)
{
real NdotVepsilonHack = 0;// 0.05; //0.1; //0.01; //0.1;
// SILHOUETTE LAYER
// Compute the dot products between View direction and N at each vertex
// of the face:
Vec3r point;
int closestPointId = 0;
real dist, minDist = FLT_MAX;
int numVertices = iFace->numberOfVertices();
WXFaceLayer * faceLayer = new WXFaceLayer(iFace, Nature::SILHOUETTE, true);
Vec3r normal;
if(meshSilhouettes){
// Use per face normal
normal = (iFace->GetVertex(2)->GetVertex() - iFace->GetVertex(0)->GetVertex()) ^ (iFace->GetVertex(1)->GetVertex() - iFace->GetVertex(0)->GetVertex());
normal.normalize();
}
for(int i=0; i<numVertices; i++){
point = iFace->GetVertex(i)->GetVertex();
if(!meshSilhouettes){
// Use per vertex normal
normal = iFace->GetVertexNormal(i);
normal.normalize();
}
Vec3r V(_Viewpoint - point);
V.normalize();
real d = normal * V + NdotVepsilonHack;
faceLayer->PushDotP(d);
// Find the point the closest to the viewpoint
Vec3r dist_vec(point - _Viewpoint);
dist = dist_vec.norm();
if(dist < minDist) {
minDist = dist;
closestPointId = i;
}
// store ndotv at the vertex for use in the region-based visibility
// assert(dynamic_cast<WXVertex*>(iFace->GetVertex(i))!=NULL);
((WXVertex*)iFace->GetVertex(i))->setNdotV(d);
}
// Set the closest point id:
faceLayer->SetClosestPointIndex(closestPointId);
// Add this layer to the face:
iFace->AddSmoothLayer(faceLayer);
}
示例14: vec3
void v3math_object::test<31>()
{
F32 x1 =-2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, y2 = 1.f, z2 = 1.f;
F32 val1,val2;
LLVector3 vec3(x1,y1,z1),vec3a(x2,y2,z2);
val1 = dist_vec(vec3,vec3a);
val2 = fsqrtf((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
ensure_equals("1:dist_vec: Fail ",val2, val1);
val1 = dist_vec_squared(vec3,vec3a);
val2 =((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2) + (z1 - z2)* (z1 -z2));
ensure_equals("2:dist_vec_squared: Fail ",val2, val1);
val1 = dist_vec_squared2D(vec3, vec3a);
val2 =(x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2);
ensure_equals("3:dist_vec_squared2D: Fail ",val2, val1);
}
示例15: colorf
void lggBeamMaps::fireCurrentBeams(LLPointer<LLHUDEffectSpiral> mBeam, const LLColor4U& rgb)
{
if (mScale == 0.0f)
{
return;
}
static LLCachedControl<std::string> colorf(gSavedSettings, "FSBeamColorFile");
bool colorsDisabled = (colorf().empty());
for (std::vector<lggBeamData>::iterator it = mDots.begin(); it != mDots.end(); ++it)
{
LLColor4U myColor = rgb;
if (colorsDisabled)
{
myColor = (*it).c;
}
F32 distanceAdjust = dist_vec(mBeam->getPositionGlobal(), gAgent.getPositionGlobal());
F32 pulse = (F32)(.75f + sinf(gFrameTimeSeconds * 1.0f) * 0.25f);
LLVector3d offset = (*it).p;
offset.mdV[VY] *= -1.f;
offset *= pulse * mScale * distanceAdjust * 0.1f;
LLVector3 beamLine = LLVector3( mBeam->getPositionGlobal() - gAgent.getPositionGlobal());
LLVector3 beamLineFlat = beamLine;
beamLineFlat.mV[VZ]= 0.0f;
LLVector3 newDirFlat = LLVector3::x_axis;
beamLine.normalize();
beamLineFlat.normalize();
LLQuaternion change;
change.shortestArc(newDirFlat, beamLineFlat);
offset.rotVec(change);
newDirFlat.rotVec(change);
change.shortestArc(newDirFlat, beamLine);
offset.rotVec(change);
LLPointer<LLHUDEffectSpiral> myBeam = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM);
myBeam->setPositionGlobal(mBeam->getPositionGlobal() + offset + (LLVector3d(beamLine) * sinf(gFrameTimeSeconds * 2.0f) * 0.2f));
myBeam->setColor(myColor);
myBeam->setTargetObject(mBeam->getTargetObject());
myBeam->setSourceObject(mBeam->getSourceObject());
myBeam->setNeedsSendToSim(mBeam->getNeedsSendToSim());
myBeam->setDuration(mDuration * 1.2f);
}
}