A majority of vectorization done. Note that it's INCOMPLETE. LLVolumeFace and LLVertexBuffer haven't been updated, so it's very dirty(and buggy) at those transitions. Compiles on windoze.
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "llcriticaldamp.h"
|
||||
#include "llface.h"
|
||||
#include "lllightconstants.h"
|
||||
#include "llmatrix4a.h"
|
||||
#include "llsky.h"
|
||||
#include "llsurfacepatch.h"
|
||||
#include "llviewercamera.h"
|
||||
@@ -95,7 +96,7 @@ void LLDrawable::init()
|
||||
mRenderType = 0;
|
||||
mCurrentScale = LLVector3(1,1,1);
|
||||
mDistanceWRTCamera = 0.0f;
|
||||
mPositionGroup.clearVec();
|
||||
mPositionGroup.clear();
|
||||
mExtents[0].clear();
|
||||
mExtents[1].clear();
|
||||
mQuietCount = 0;
|
||||
@@ -705,7 +706,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
|
||||
{
|
||||
if (getSpatialGroup())
|
||||
{
|
||||
pos.set(getPositionGroup());
|
||||
pos.set(getPositionGroup().getF32ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -714,26 +715,28 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
|
||||
|
||||
if (isState(LLDrawable::HAS_ALPHA))
|
||||
{
|
||||
for (S32 i = 0; i < getNumFaces(); i++)
|
||||
{
|
||||
LLFace* facep = getFace(i);
|
||||
if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)
|
||||
for (S32 i = 0; i < getNumFaces(); i++)
|
||||
{
|
||||
LLVector3 box = (facep->mExtents[1] - facep->mExtents[0]) * 0.25f;
|
||||
LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
|
||||
LLFace* facep = getFace(i);
|
||||
if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)
|
||||
{
|
||||
LLVector4a box;
|
||||
box.setSub(facep->mExtents[1], facep->mExtents[0]);
|
||||
box.mul(0.25f);
|
||||
LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
|
||||
const LLVector3& at = camera.getAtAxis();
|
||||
for (U32 j = 0; j < 3; j++)
|
||||
{
|
||||
v.mV[j] -= box.mV[j] * at.mV[j];
|
||||
{
|
||||
v.mV[j] -= box[j] * at.mV[j];
|
||||
}
|
||||
facep->mDistance = v * camera.getAtAxis();
|
||||
}
|
||||
facep->mDistance = v * camera.getAtAxis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = LLVector3(getPositionGroup());
|
||||
pos = LLVector3(getPositionGroup().getF32ptr());
|
||||
}
|
||||
|
||||
pos -= camera.getOrigin();
|
||||
@@ -782,7 +785,7 @@ BOOL LLDrawable::updateGeometry(BOOL priority)
|
||||
return res;
|
||||
}
|
||||
|
||||
void LLDrawable::shiftPos(const LLVector3 &shift_vector)
|
||||
void LLDrawable::shiftPos(const LLVector4a &shift_vector)
|
||||
{
|
||||
if (isDead())
|
||||
{
|
||||
@@ -814,9 +817,9 @@ void LLDrawable::shiftPos(const LLVector3 &shift_vector)
|
||||
for (S32 i = 0; i < getNumFaces(); i++)
|
||||
{
|
||||
LLFace *facep = getFace(i);
|
||||
facep->mCenterAgent += shift_vector;
|
||||
facep->mExtents[0] += shift_vector;
|
||||
facep->mExtents[1] += shift_vector;
|
||||
facep->mCenterAgent += LLVector3(shift_vector.getF32ptr());
|
||||
facep->mExtents[0].add(shift_vector);
|
||||
facep->mExtents[1].add(shift_vector);
|
||||
|
||||
if (!volume && facep->hasGeometry())
|
||||
{
|
||||
@@ -824,9 +827,9 @@ void LLDrawable::shiftPos(const LLVector3 &shift_vector)
|
||||
}
|
||||
}
|
||||
|
||||
mExtents[0] += shift_vector;
|
||||
mExtents[1] += shift_vector;
|
||||
mPositionGroup += LLVector3d(shift_vector);
|
||||
mExtents[0].add(shift_vector);
|
||||
mExtents[1].add(shift_vector);
|
||||
mPositionGroup.add(shift_vector);
|
||||
}
|
||||
else if (mSpatialBridge)
|
||||
{
|
||||
@@ -834,9 +837,9 @@ void LLDrawable::shiftPos(const LLVector3 &shift_vector)
|
||||
}
|
||||
else if (isAvatar())
|
||||
{
|
||||
mExtents[0] += shift_vector;
|
||||
mExtents[1] += shift_vector;
|
||||
mPositionGroup += LLVector3d(shift_vector);
|
||||
mExtents[0].add(shift_vector);
|
||||
mExtents[1].add(shift_vector);
|
||||
mPositionGroup.add(shift_vector);
|
||||
}
|
||||
|
||||
mVObjp->onShift(shift_vector);
|
||||
@@ -848,21 +851,26 @@ const LLVector3& LLDrawable::getBounds(LLVector3& min, LLVector3& max) const
|
||||
return mXform.getPositionW();
|
||||
}
|
||||
|
||||
const LLVector3* LLDrawable::getSpatialExtents() const
|
||||
const LLVector4a* LLDrawable::getSpatialExtents() const
|
||||
{
|
||||
return mExtents;
|
||||
}
|
||||
|
||||
void LLDrawable::setSpatialExtents(LLVector3 min, LLVector3 max)
|
||||
void LLDrawable::setSpatialExtents(const LLVector3& min, const LLVector3& max)
|
||||
{
|
||||
LLVector3 size = max - min;
|
||||
mExtents[0] = min;
|
||||
mExtents[1] = max;
|
||||
mExtents[0].load3(min.mV);
|
||||
mExtents[1].load3(max.mV);
|
||||
}
|
||||
|
||||
void LLDrawable::setPositionGroup(const LLVector3d& pos)
|
||||
void LLDrawable::setSpatialExtents(const LLVector4a& min, const LLVector4a& max)
|
||||
{
|
||||
mExtents[0] = min;
|
||||
mExtents[1] = max;
|
||||
}
|
||||
|
||||
void LLDrawable::setPositionGroup(const LLVector4a& pos)
|
||||
{
|
||||
mPositionGroup.setVec(pos);
|
||||
mPositionGroup = pos;
|
||||
}
|
||||
|
||||
void LLDrawable::updateSpatialExtents()
|
||||
@@ -876,7 +884,7 @@ void LLDrawable::updateSpatialExtents()
|
||||
|
||||
if (mSpatialBridge.notNull())
|
||||
{
|
||||
mPositionGroup.setVec(0,0,0);
|
||||
mPositionGroup.splat(0.f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,59 +1107,72 @@ void LLSpatialBridge::updateSpatialExtents()
|
||||
root->rebound();
|
||||
}
|
||||
|
||||
LLXformMatrix* mat = mDrawable->getXform();
|
||||
|
||||
LLVector3 offset = root->mBounds[0];
|
||||
LLVector3 size = root->mBounds[1];
|
||||
LLVector4a offset;
|
||||
LLVector4a size = root->mBounds[1];
|
||||
|
||||
LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix();
|
||||
LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix());
|
||||
|
||||
offset *= rotation;
|
||||
center += offset;
|
||||
|
||||
LLVector3 v[4];
|
||||
//get 4 corners of bounding box
|
||||
v[0] = (size * rotation);
|
||||
v[1] = (LLVector3(-size.mV[0], -size.mV[1], size.mV[2]) * rotation);
|
||||
v[2] = (LLVector3(size.mV[0], -size.mV[1], -size.mV[2]) * rotation);
|
||||
v[3] = (LLVector3(-size.mV[0], size.mV[1], -size.mV[2]) * rotation);
|
||||
//VECTORIZE THIS
|
||||
LLMatrix4a mat;
|
||||
mat.loadu(mDrawable->getXform()->getWorldMatrix());
|
||||
|
||||
LLVector3& newMin = mExtents[0];
|
||||
LLVector3& newMax = mExtents[1];
|
||||
LLVector4a t;
|
||||
t.splat(0.f);
|
||||
|
||||
LLVector4a center;
|
||||
mat.affineTransform(t, center);
|
||||
|
||||
mat.rotate(root->mBounds[0], offset);
|
||||
center.add(offset);
|
||||
|
||||
LLVector4a v[4];
|
||||
|
||||
//get 4 corners of bounding box
|
||||
mat.rotate(size,v[0]);
|
||||
|
||||
LLVector4a scale;
|
||||
|
||||
scale.set(-1.f, -1.f, 1.f);
|
||||
scale.mul(size);
|
||||
mat.rotate(scale, v[1]);
|
||||
|
||||
scale.set(1.f, -1.f, -1.f);
|
||||
scale.mul(size);
|
||||
mat.rotate(scale, v[2]);
|
||||
|
||||
scale.set(-1.f, 1.f, -1.f);
|
||||
scale.mul(size);
|
||||
mat.rotate(scale, v[3]);
|
||||
|
||||
|
||||
LLVector4a& newMin = mExtents[0];
|
||||
LLVector4a& newMax = mExtents[1];
|
||||
|
||||
newMin = newMax = center;
|
||||
|
||||
for (U32 i = 0; i < 4; i++)
|
||||
{
|
||||
for (U32 j = 0; j < 3; j++)
|
||||
{
|
||||
F32 delta = fabsf(v[i].mV[j]);
|
||||
F32 min = center.mV[j] - delta;
|
||||
F32 max = center.mV[j] + delta;
|
||||
|
||||
if (min < newMin.mV[j])
|
||||
{
|
||||
newMin.mV[j] = min;
|
||||
}
|
||||
|
||||
if (max > newMax.mV[j])
|
||||
{
|
||||
newMax.mV[j] = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
LLVector4a delta;
|
||||
delta.setAbs(v[i]);
|
||||
LLVector4a min;
|
||||
min.setSub(center, delta);
|
||||
LLVector4a max;
|
||||
max.setAdd(center, delta);
|
||||
|
||||
LLVector3 diagonal = newMax - newMin;
|
||||
mRadius = diagonal.magVec() * 0.5f;
|
||||
newMin.setMin(newMin, min);
|
||||
newMax.setMax(newMax, max);
|
||||
}
|
||||
|
||||
mPositionGroup.setVec((newMin + newMax) * 0.5f);
|
||||
LLVector4a diagonal;
|
||||
diagonal.setSub(newMax, newMin);
|
||||
mRadius = diagonal.getLength3().getF32() * 0.5f;
|
||||
|
||||
mPositionGroup.setAdd(newMin,newMax);
|
||||
mPositionGroup.mul(0.5f);
|
||||
updateBinRadius();
|
||||
}
|
||||
|
||||
void LLSpatialBridge::updateBinRadius()
|
||||
{
|
||||
mBinRadius = llmin((F32) mOctree->getSize().mdV[0]*0.5f, 256.f);
|
||||
mBinRadius = llmin( mOctree->getSize()[0]*0.5f, 256.f);
|
||||
}
|
||||
|
||||
LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)
|
||||
@@ -1292,8 +1313,12 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
|
||||
LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
|
||||
group->rebound();
|
||||
|
||||
LLVector3 center = (mExtents[0] + mExtents[1]) * 0.5f;
|
||||
LLVector3 size = (mExtents[1]-mExtents[0]) * 0.5f;
|
||||
LLVector4a center;
|
||||
center.setAdd(mExtents[0], mExtents[1]);
|
||||
center.mul(0.5f);
|
||||
LLVector4a size;
|
||||
size.setSub(mExtents[1], mExtents[0]);
|
||||
size.mul(0.5f);
|
||||
|
||||
if ((LLPipeline::sShadowRender && camera_in.AABBInFrustum(center, size)) ||
|
||||
LLPipeline::sImpostorRender ||
|
||||
@@ -1397,6 +1422,7 @@ BOOL LLSpatialBridge::updateMove()
|
||||
llassert_always(mDrawable->getRegion());
|
||||
LLSpatialPartition* part = mDrawable->getRegion()->getSpatialPartition(mPartitionType);
|
||||
llassert_always(part);
|
||||
|
||||
mOctree->balance();
|
||||
if (part)
|
||||
{
|
||||
@@ -1405,11 +1431,11 @@ BOOL LLSpatialBridge::updateMove()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void LLSpatialBridge::shiftPos(const LLVector3& vec)
|
||||
void LLSpatialBridge::shiftPos(const LLVector4a& vec)
|
||||
{
|
||||
mExtents[0] += vec;
|
||||
mExtents[1] += vec;
|
||||
mPositionGroup += LLVector3d(vec);
|
||||
mExtents[0].add(vec);
|
||||
mExtents[1].add(vec);
|
||||
mPositionGroup.add(vec);
|
||||
}
|
||||
|
||||
void LLSpatialBridge::cleanupReferences()
|
||||
@@ -1527,7 +1553,7 @@ F32 LLHUDBridge::calcPixelArea(LLSpatialGroup* group, LLCamera& camera)
|
||||
}
|
||||
|
||||
|
||||
void LLHUDBridge::shiftPos(const LLVector3& vec)
|
||||
void LLHUDBridge::shiftPos(const LLVector4a& vec)
|
||||
{
|
||||
//don't shift hud bridges on region crossing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user