本文整理汇总了C++中LLVector3::length方法的典型用法代码示例。如果您正苦于以下问题:C++ LLVector3::length方法的具体用法?C++ LLVector3::length怎么用?C++ LLVector3::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLVector3
的用法示例。
在下文中一共展示了LLVector3::length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lineSegmentIntersect
BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent)
{
if (!lineSegmentBoundingBox(start, end))
{
return FALSE;
}
LLVector4a da;
da.setSub(end, start);
LLVector3 delta(da.getF32ptr());
LLVector3 pdelta = delta;
pdelta.mV[2] = 0;
F32 plength = pdelta.length();
F32 tdelta = 1.f/plength;
LLVector3 v_start(start.getF32ptr());
LLVector3 origin = v_start - mRegionp->getOriginAgent();
if (mRegionp->getLandHeightRegion(origin) > origin.mV[2])
{
//origin is under ground, treat as no intersection
return FALSE;
}
//step one meter at a time until intersection point found
//VECTORIZE THIS
const LLVector4a* exta = mDrawable->getSpatialExtents();
LLVector3 ext[2];
ext[0].set(exta[0].getF32ptr());
ext[1].set(exta[1].getF32ptr());
F32 rad = (delta*tdelta).magVecSquared();
F32 t = 0.f;
while ( t <= 1.f)
{
LLVector3 sample = origin + delta*t;
if (AABBSphereIntersectR2(ext[0], ext[1], sample+mRegionp->getOriginAgent(), rad))
{
F32 height = mRegionp->getLandHeightRegion(sample);
if (height > sample.mV[2])
{ //ray went below ground, positive intersection
//quick and dirty binary search to get impact point
tdelta = -tdelta*0.5f;
F32 err_dist = 0.001f;
F32 dist = fabsf(sample.mV[2] - height);
while (dist > err_dist && tdelta*tdelta > 0.0f)
{
t += tdelta;
sample = origin+delta*t;
height = mRegionp->getLandHeightRegion(sample);
if ((tdelta < 0 && height < sample.mV[2]) ||
(height > sample.mV[2] && tdelta > 0))
{ //jumped over intersection point, go back
tdelta = -tdelta;
}
tdelta *= 0.5f;
dist = fabsf(sample.mV[2] - height);
}
if (intersection)
{
F32 height = mRegionp->getLandHeightRegion(sample);
if (fabsf(sample.mV[2]-height) < delta.length()*tdelta)
{
sample.mV[2] = mRegionp->getLandHeightRegion(sample);
}
intersection->load3((sample + mRegionp->getOriginAgent()).mV);
}
if (normal)
{
normal->load3((mRegionp->getLand().resolveNormalGlobal(mRegionp->getPosGlobalFromRegion(sample))).mV);
}
return TRUE;
}
}
t += tdelta;
if (t > 1 && t < 1.f+tdelta*0.99f)
{ //make sure end point is checked (saves vertical lines coming up negative)
t = 1.f;
}
}
return FALSE;
}