summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llbbox.cpp22
-rw-r--r--indra/llmath/llbbox.h4
-rw-r--r--indra/llmath/llvolume.cpp41
-rw-r--r--indra/llmath/llvolume.h1
4 files changed, 65 insertions, 3 deletions
diff --git a/indra/llmath/llbbox.cpp b/indra/llmath/llbbox.cpp
index b46a6e03d2..3e2c05a6e6 100644
--- a/indra/llmath/llbbox.cpp
+++ b/indra/llmath/llbbox.cpp
@@ -89,6 +89,19 @@ void LLBBox::addBBoxAgent(const LLBBox& b)
}
}
+LLBBox LLBBox::getAxisAligned() const
+{
+ // no rotation = axis aligned rotation
+ LLBBox aligned(mPosAgent, LLQuaternion(), LLVector3(), LLVector3());
+
+ // add the center point so that it's not empty
+ aligned.addPointAgent(mPosAgent);
+
+ // add our BBox
+ aligned.addBBoxAgent(*this);
+
+ return aligned;
+}
void LLBBox::expand( F32 delta )
{
@@ -147,6 +160,15 @@ BOOL LLBBox::containsPointAgent(const LLVector3& p) const
return containsPointLocal(point_local);
}
+LLVector3 LLBBox::getMinAgent() const
+{
+ return localToAgent(mMinLocal);
+}
+
+LLVector3 LLBBox::getMaxAgent() const
+{
+ return localToAgent(mMaxLocal);
+}
/*
LLBBox operator*(const LLBBox &a, const LLMatrix4 &b)
diff --git a/indra/llmath/llbbox.h b/indra/llmath/llbbox.h
index 5b911793f0..28e69b75e1 100644
--- a/indra/llmath/llbbox.h
+++ b/indra/llmath/llbbox.h
@@ -51,9 +51,11 @@ public:
const LLVector3& getPositionAgent() const { return mPosAgent; }
const LLQuaternion& getRotation() const { return mRotation; }
+ LLVector3 getMinAgent() const;
const LLVector3& getMinLocal() const { return mMinLocal; }
void setMinLocal( const LLVector3& min ) { mMinLocal = min; }
+ LLVector3 getMaxAgent() const;
const LLVector3& getMaxLocal() const { return mMaxLocal; }
void setMaxLocal( const LLVector3& max ) { mMaxLocal = max; }
@@ -80,6 +82,8 @@ public:
LLVector3 localToAgentBasis(const LLVector3& v) const;
LLVector3 agentToLocalBasis(const LLVector3& v) const;
+ // Get the smallest possible axis aligned bbox that contains this bbox
+ LLBBox getAxisAligned() const;
// friend LLBBox operator*(const LLBBox& a, const LLMatrix4& b);
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 14e1ca8d43..71b92962fb 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4406,19 +4406,54 @@ std::ostream& operator<<(std::ostream &s, const LLVolume *volumep)
BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
{
+ BOOL ret = FALSE ;
if (mTypeMask & CAP_MASK)
{
- return createCap(volume, partial_build);
+ ret = createCap(volume, partial_build);
}
else if ((mTypeMask & END_MASK) || (mTypeMask & SIDE_MASK))
{
- return createSide(volume, partial_build);
+ ret = createSide(volume, partial_build);
}
else
{
llerrs << "Unknown/uninitialized face type!" << llendl;
- return FALSE;
}
+
+ //update the range of the texture coordinates
+ if(ret)
+ {
+ mTexCoordExtents[0].setVec(1.f, 1.f) ;
+ mTexCoordExtents[1].setVec(0.f, 0.f) ;
+
+ U32 end = mVertices.size() ;
+ for(U32 i = 0 ; i < end ; i++)
+ {
+ if(mTexCoordExtents[0].mV[0] > mVertices[i].mTexCoord.mV[0])
+ {
+ mTexCoordExtents[0].mV[0] = mVertices[i].mTexCoord.mV[0] ;
+ }
+ if(mTexCoordExtents[1].mV[0] < mVertices[i].mTexCoord.mV[0])
+ {
+ mTexCoordExtents[1].mV[0] = mVertices[i].mTexCoord.mV[0] ;
+ }
+
+ if(mTexCoordExtents[0].mV[1] > mVertices[i].mTexCoord.mV[1])
+ {
+ mTexCoordExtents[0].mV[1] = mVertices[i].mTexCoord.mV[1] ;
+ }
+ if(mTexCoordExtents[1].mV[1] < mVertices[i].mTexCoord.mV[1])
+ {
+ mTexCoordExtents[1].mV[1] = mVertices[i].mTexCoord.mV[1] ;
+ }
+ }
+ mTexCoordExtents[0].mV[0] = llmax(0.f, mTexCoordExtents[0].mV[0]) ;
+ mTexCoordExtents[0].mV[1] = llmax(0.f, mTexCoordExtents[0].mV[1]) ;
+ mTexCoordExtents[1].mV[0] = llmin(1.f, mTexCoordExtents[1].mV[0]) ;
+ mTexCoordExtents[1].mV[1] = llmin(1.f, mTexCoordExtents[1].mV[1]) ;
+ }
+
+ return ret ;
}
void LerpPlanarVertex(LLVolumeFace::VertexData& v0,
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index d48a79ee46..28b9895ff3 100644
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -831,6 +831,7 @@ public:
S32 mNumT;
LLVector3 mExtents[2]; //minimum and maximum point of face
+ LLVector2 mTexCoordExtents[2]; //minimum and maximum of texture coordinates of the face.
std::vector<VertexData> mVertices;
std::vector<U16> mIndices;