本文整理汇总了C++中LLVector2::normVec方法的典型用法代码示例。如果您正苦于以下问题:C++ LLVector2::normVec方法的具体用法?C++ LLVector2::normVec怎么用?C++ LLVector2::normVec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLVector2
的用法示例。
在下文中一共展示了LLVector2::normVec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: angle_between
F32 angle_between(const LLVector2& a, const LLVector2& b)
{
LLVector2 an = a;
LLVector2 bn = b;
an.normVec();
bn.normVec();
F32 cosine = an * bn;
F32 angle = (cosine >= 1.0f) ? 0.0f :
(cosine <= -1.0f) ? F_PI :
acos(cosine);
return angle;
}
示例2: are_parallel
BOOL are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon)
{
LLVector2 an = a;
LLVector2 bn = b;
an.normVec();
bn.normVec();
F32 dot = an * bn;
if ( (1.0f - fabs(dot)) < epsilon)
{
return TRUE;
}
return FALSE;
}
示例3: updateAll
void LLHUDNameTag::updateAll()
{
// iterate over all text objects, calculate their restoration forces,
// and add them to the visible set if they are on screen and close enough
sVisibleTextObjects.clear();
TextObjectIterator text_it;
for (text_it = sTextObjects.begin(); text_it != sTextObjects.end(); ++text_it)
{
LLHUDNameTag* textp = (*text_it);
textp->mTargetPositionOffset.clearVec();
textp->updateSize();
textp->updateVisibility();
}
// sort back to front for rendering purposes
std::sort(sVisibleTextObjects.begin(), sVisibleTextObjects.end(), llhudnametag_further_away());
// iterate from front to back, and set LOD based on current screen coverage
F32 screen_area = (F32)(gViewerWindow->getWindowWidthScaled() * gViewerWindow->getWindowHeightScaled());
F32 current_screen_area = 0.f;
std::vector<LLPointer<LLHUDNameTag> >::reverse_iterator r_it;
for (r_it = sVisibleTextObjects.rbegin(); r_it != sVisibleTextObjects.rend(); ++r_it)
{
LLHUDNameTag* textp = (*r_it);
if (current_screen_area / screen_area > LOD_2_SCREEN_COVERAGE)
{
textp->setLOD(3);
}
else if (current_screen_area / screen_area > LOD_1_SCREEN_COVERAGE)
{
textp->setLOD(2);
}
else if (current_screen_area / screen_area > LOD_0_SCREEN_COVERAGE)
{
textp->setLOD(1);
}
else
{
textp->setLOD(0);
}
textp->updateSize();
// find on-screen position and initialize collision rectangle
textp->mTargetPositionOffset = textp->updateScreenPos(LLVector2::zero);
current_screen_area += (F32)(textp->mSoftScreenRect.getWidth() * textp->mSoftScreenRect.getHeight());
}
LLTrace::CountStatHandle<>* camera_vel_stat = LLViewerCamera::getVelocityStat();
F32 camera_vel = LLTrace::get_frame_recording().getLastRecording().getPerSec(*camera_vel_stat);
if (camera_vel > MAX_STABLE_CAMERA_VELOCITY)
{
return;
}
VisibleTextObjectIterator src_it;
for (S32 i = 0; i < NUM_OVERLAP_ITERATIONS; i++)
{
for (src_it = sVisibleTextObjects.begin(); src_it != sVisibleTextObjects.end(); ++src_it)
{
LLHUDNameTag* src_textp = (*src_it);
VisibleTextObjectIterator dst_it = src_it;
++dst_it;
for (; dst_it != sVisibleTextObjects.end(); ++dst_it)
{
LLHUDNameTag* dst_textp = (*dst_it);
if (src_textp->mSoftScreenRect.overlaps(dst_textp->mSoftScreenRect))
{
LLRectf intersect_rect = src_textp->mSoftScreenRect;
intersect_rect.intersectWith(dst_textp->mSoftScreenRect);
intersect_rect.stretch(-BUFFER_SIZE * 0.5f);
F32 src_center_x = src_textp->mSoftScreenRect.getCenterX();
F32 src_center_y = src_textp->mSoftScreenRect.getCenterY();
F32 dst_center_x = dst_textp->mSoftScreenRect.getCenterX();
F32 dst_center_y = dst_textp->mSoftScreenRect.getCenterY();
F32 intersect_center_x = intersect_rect.getCenterX();
F32 intersect_center_y = intersect_rect.getCenterY();
LLVector2 force = lerp(LLVector2(dst_center_x - intersect_center_x, dst_center_y - intersect_center_y),
LLVector2(intersect_center_x - src_center_x, intersect_center_y - src_center_y),
0.5f);
force.setVec(dst_center_x - src_center_x, dst_center_y - src_center_y);
force.normVec();
LLVector2 src_force = -1.f * force;
LLVector2 dst_force = force;
LLVector2 force_strength;
F32 src_mult = dst_textp->mMass / (dst_textp->mMass + src_textp->mMass);
F32 dst_mult = 1.f - src_mult;
F32 src_aspect_ratio = src_textp->mSoftScreenRect.getWidth() / src_textp->mSoftScreenRect.getHeight();
F32 dst_aspect_ratio = dst_textp->mSoftScreenRect.getWidth() / dst_textp->mSoftScreenRect.getHeight();
src_force.mV[VY] *= src_aspect_ratio;
src_force.normVec();
dst_force.mV[VY] *= dst_aspect_ratio;
dst_force.normVec();
src_force.mV[VX] *= llmin(intersect_rect.getWidth() * src_mult, intersect_rect.getHeight() * SPRING_STRENGTH);
//.........这里部分代码省略.........