summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-01-11 15:46:18 -0800
committerRichard Linden <none@none>2013-01-11 15:46:18 -0800
commitca21e13667a09a8ecdf1468995e38622867e907e (patch)
treee9163e324a66e84ae73bbce11dc35f572834b339 /indra/llmath
parent512d7381eca7bc53bb31e9528e5a7c5df189e82d (diff)
parent433d53ea5580b2cbb17e6397afe2ca008e466963 (diff)
Automated merge with file:///c:%5Ccode%5Cviewer-interesting-metrics
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llcamera.cpp50
-rw-r--r--indra/llmath/llcamera.h8
2 files changed, 52 insertions, 6 deletions
diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp
index 22ba26f99b..6551b52462 100644
--- a/indra/llmath/llcamera.cpp
+++ b/indra/llmath/llcamera.cpp
@@ -161,7 +161,7 @@ size_t LLCamera::readFrustumFromBuffer(const char *buffer)
// ---------------- test methods ----------------
-S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
+S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius, const LLPlane* planes)
{
static const LLVector4a scaler[] = {
LLVector4a(-1,-1,-1),
@@ -174,6 +174,12 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
LLVector4a( 1, 1, 1)
};
+ if(!planes)
+ {
+ //use agent space
+ planes = mAgentPlanes;
+ }
+
U8 mask = 0;
bool result = false;
LLVector4a rscale, maxp, minp;
@@ -183,7 +189,7 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
mask = mPlaneMask[i];
if (mask != 0xff)
{
- const LLPlane& p(mAgentPlanes[i]);
+ const LLPlane& p(planes[i]);
p.getAt<3>(d);
rscale.setMul(radius, scaler[mask]);
minp.setSub(center, rscale);
@@ -204,8 +210,14 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
return result?1:2;
}
+//exactly same as the function AABBInFrustum(...)
+//except uses mRegionPlanes instead of mAgentPlanes.
+S32 LLCamera::AABBInRegionFrustum(const LLVector4a& center, const LLVector4a& radius)
+{
+ return AABBInFrustum(center, radius, mRegionPlanes);
+}
-S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius)
+S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes)
{
static const LLVector4a scaler[] = {
LLVector4a(-1,-1,-1),
@@ -218,6 +230,12 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
LLVector4a( 1, 1, 1)
};
+ if(!planes)
+ {
+ //use agent space
+ planes = mAgentPlanes;
+ }
+
U8 mask = 0;
bool result = false;
LLVector4a rscale, maxp, minp;
@@ -227,7 +245,7 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
mask = mPlaneMask[i];
if ((i != 5) && (mask != 0xff))
{
- const LLPlane& p(mAgentPlanes[i]);
+ const LLPlane& p(planes[i]);
p.getAt<3>(d);
rscale.setMul(radius, scaler[mask]);
minp.setSub(center, rscale);
@@ -248,6 +266,13 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
return result?1:2;
}
+//exactly same as the function AABBInFrustumNoFarClip(...)
+//except uses mRegionPlanes instead of mAgentPlanes.
+S32 LLCamera::AABBInRegionFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius)
+{
+ return AABBInFrustumNoFarClip(center, radius, mRegionPlanes);
+}
+
int LLCamera::sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius)
{
LLVector3 dist = sphere_center-mFrustCenter;
@@ -584,6 +609,23 @@ void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
}
}
+//calculate regional planes from mAgentPlanes.
+//vector "shift" is the vector of the region origin in the agent space.
+void LLCamera::calcRegionFrustumPlanes(const LLVector3& shift)
+{
+ F32 d;
+ LLVector3 n;
+ for(S32 i = 0 ; i < 7; i++)
+ {
+ if (mPlaneMask[i] != 0xff)
+ {
+ n.setVec(mAgentPlanes[i][0], mAgentPlanes[i][1], mAgentPlanes[i][2]);
+ d = mAgentPlanes[i][3] - n * shift;
+ mRegionPlanes[i].setVec(n, d);
+ }
+ }
+}
+
void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom)
{
LLVector3 a, b, c;
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index 0b591be622..898d73ed7e 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -109,6 +109,7 @@ public:
private:
LL_ALIGN_16(LLPlane mAgentPlanes[7]); //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+ LL_ALIGN_16(LLPlane mRegionPlanes[7]); //frustum planes in a local region space, derived from mAgentPlanes
U8 mPlaneMask[8]; // 8 for alignment
F32 mView; // angle between top and bottom frustum planes in radians.
@@ -178,6 +179,7 @@ public:
// Return number of bytes copied.
size_t readFrustumFromBuffer(const char *buffer);
void calcAgentFrustumPlanes(LLVector3* frust);
+ void calcRegionFrustumPlanes(const LLVector3& shift); //calculate regional planes from mAgentPlanes.
void ignoreAgentFrustumPlane(S32 idx);
// Returns 1 if partly in, 2 if fully in.
@@ -186,8 +188,10 @@ public:
S32 sphereInFrustum(const LLVector3 &center, const F32 radius) const;
S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); }
S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); }
- S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius);
- S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
+ S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes = NULL);
+ S32 AABBInRegionFrustum(const LLVector4a& center, const LLVector4a& radius);
+ S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes = NULL);
+ S32 AABBInRegionFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
//does a quick 'n dirty sphere-sphere check
S32 sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius);