SL-10566 Use vector for some high-traffic, low-item count containers instead of list.

Provide method of storing joint indices sep from weight data for faster runtime processing.
master
Graham Linden 2019-08-05 12:04:29 -07:00
parent 9bb6da1e76
commit 76128c4357
20 changed files with 228 additions and 152 deletions

View File

@ -81,8 +81,8 @@ public:
LLAvatarBoneInfo() : mIsJoint(FALSE) {}
~LLAvatarBoneInfo()
{
std::for_each(mChildList.begin(), mChildList.end(), DeletePointer());
mChildList.clear();
std::for_each(mChildren.begin(), mChildren.end(), DeletePointer());
mChildren.clear();
}
BOOL parseXml(LLXmlTreeNode* node);
@ -96,8 +96,8 @@ private:
LLVector3 mRot;
LLVector3 mScale;
LLVector3 mPivot;
typedef std::vector<LLAvatarBoneInfo*> child_list_t;
child_list_t mChildList;
typedef std::vector<LLAvatarBoneInfo*> bones_t;
bones_t mChildren;
};
//------------------------------------------------------------------------
@ -679,8 +679,8 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
// setup children
LLAvatarBoneInfo::child_list_t::const_iterator iter;
for (iter = info->mChildList.begin(); iter != info->mChildList.end(); ++iter)
LLAvatarBoneInfo::bones_t::const_iterator iter;
for (iter = info->mChildren.begin(); iter != info->mChildren.end(); ++iter)
{
LLAvatarBoneInfo *child_info = *iter;
if (!setupBone(child_info, joint, volume_num, joint_num))
@ -1669,7 +1669,7 @@ BOOL LLAvatarBoneInfo::parseXml(LLXmlTreeNode* node)
delete child_info;
return FALSE;
}
mChildList.push_back(child_info);
mChildren.push_back(child_info);
}
return TRUE;
}
@ -1728,8 +1728,8 @@ void LLAvatarAppearance::makeJointAliases(LLAvatarBoneInfo *bone_info)
mJointAliasMap[*i] = bone_name;
}
LLAvatarBoneInfo::child_list_t::const_iterator iter;
for (iter = bone_info->mChildList.begin(); iter != bone_info->mChildList.end(); ++iter)
LLAvatarBoneInfo::bones_t::const_iterator iter;
for (iter = bone_info->mChildren.begin(); iter != bone_info->mChildren.end(); ++iter)
{
makeJointAliases( *iter );
}

View File

@ -100,7 +100,7 @@ void LLAvatarJoint::setValid( BOOL valid, BOOL recursive )
//----------------------------------------------------------------
if (recursive)
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = (LLAvatarJoint*)(*iter);
@ -118,10 +118,10 @@ void LLAvatarJoint::setSkeletonComponents( U32 comp, BOOL recursive )
mComponents = comp;
if (recursive)
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter);
joint->setSkeletonComponents(comp, recursive);
}
}
@ -133,7 +133,7 @@ void LLAvatarJoint::setVisible(BOOL visible, BOOL recursive)
if (recursive)
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = (LLAvatarJoint*)(*iter);
@ -144,27 +144,27 @@ void LLAvatarJoint::setVisible(BOOL visible, BOOL recursive)
void LLAvatarJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area)
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter);
joint->updateFaceSizes(num_vertices, num_indices, pixel_area);
}
}
void LLAvatarJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter);
joint->updateFaceData(face, pixel_area, damp_wind, terse_update);
}
}
void LLAvatarJoint::updateJointGeometry()
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
@ -178,10 +178,10 @@ BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate)
BOOL lod_changed = FALSE;
BOOL found_lod = FALSE;
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter);
F32 jointLOD = joint->getLOD();
if (found_lod || jointLOD == DEFAULT_AVATAR_JOINT_LOD)
@ -207,10 +207,10 @@ BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate)
void LLAvatarJoint::dump()
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
LLAvatarJoint* joint = static_cast<LLAvatarJoint*>(*iter);
joint->dump();
}
}

View File

@ -379,7 +379,7 @@ void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint)
}
// depth-first traversal
for (LLJoint::child_list_t::iterator iter = current_joint->mChildren.begin();
for (LLJoint::joints_t::iterator iter = current_joint->mChildren.begin();
iter != current_joint->mChildren.end(); ++iter)
{
LLAvatarJoint* child_joint = (LLAvatarJoint*)(*iter);

View File

@ -614,7 +614,7 @@ void LLDriverParam::setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight)
mAvatarAppearance->isValid() &&
driven->mParam->getCrossWearable())
{
LLWearable* wearable = dynamic_cast<LLWearable*> (mWearablep);
LLWearable* wearable = mWearablep;
if (mAvatarAppearance->getWearableData()->isOnTop(wearable))
{
use_self = true;

View File

@ -160,7 +160,7 @@ BOOL LLPolySkeletalDistortion::setInfo(LLPolySkeletalDistortionInfo *info)
mJointScales[joint] = bone_info->mScaleDeformation;
// apply to children that need to inherit it
for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
for (LLJoint::joints_t::iterator iter = joint->mChildren.begin();
iter != joint->mChildren.end(); ++iter)
{
LLAvatarJoint* child_joint = (LLAvatarJoint*)(*iter);

View File

@ -252,7 +252,7 @@ void LLCharacter::dumpCharacter( LLJoint* joint )
LL_INFOS() << "DEBUG: " << joint->getName() << " (" << (joint->getParent()?joint->getParent()->getName():std::string("ROOT")) << ")" << LL_ENDL;
// recurse
for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
for (LLJoint::joints_t::iterator iter = joint->mChildren.begin();
iter != joint->mChildren.end(); ++iter)
{
LLJoint* child_joint = *iter;

View File

@ -209,7 +209,7 @@ void LLJoint::touch(U32 flags)
child_flags |= POSITION_DIRTY;
}
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLJoint* joint = *iter;
@ -251,7 +251,7 @@ LLJoint *LLJoint::findJoint( const std::string &name )
if (name == getName())
return this;
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLJoint* joint = *iter;
@ -286,7 +286,7 @@ void LLJoint::addChild(LLJoint* joint)
//--------------------------------------------------------------------
void LLJoint::removeChild(LLJoint* joint)
{
child_list_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint);
joints_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint);
if (iter != mChildren.end())
{
mChildren.erase(iter);
@ -303,10 +303,10 @@ void LLJoint::removeChild(LLJoint* joint)
//--------------------------------------------------------------------
void LLJoint::removeAllChildren()
{
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end();)
{
child_list_t::iterator curiter = iter++;
joints_t::iterator curiter = iter++;
LLJoint* joint = *curiter;
mChildren.erase(curiter);
joint->mXform.setParent(NULL);
@ -985,7 +985,7 @@ void LLJoint::updateWorldMatrixChildren()
{
updateWorldMatrix();
}
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLJoint* joint = *iter;
@ -1031,7 +1031,7 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot)
{
LLVector3 main_axis(1.f, 0.f, 0.f);
for (child_list_t::iterator iter = mChildren.begin();
for (joints_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
{
LLJoint* joint = *iter;

View File

@ -139,8 +139,8 @@ public:
S32 mJointNum;
// child joints
typedef std::list<LLJoint*> child_list_t;
child_list_t mChildren;
typedef std::vector<LLJoint*> joints_t;
joints_t mChildren;
// debug statics
static S32 sNumTouches;

View File

@ -2321,7 +2321,7 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs,
LLCharacter* character = *char_iter;
// look for an existing instance of this motion
LLKeyframeMotion* motionp = dynamic_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid));
LLKeyframeMotion* motionp = static_cast<LLKeyframeMotion*> (character->findMotion(asset_uuid));
if (motionp)
{
if (0 == status)

View File

@ -2526,6 +2526,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
if (mdl[i].has("Weights"))
{
face.allocateWeights(num_verts);
face.allocateJointIndices(num_verts);
LLSD::Binary weights = mdl[i]["Weights"];
@ -2566,6 +2567,13 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
{
wght = LLVector4(0.999f,0.f,0.f,0.f);
}
if (face.mJointIndices)
{
for (U32 k=0; k<4; k++)
{
face.mJointIndices[cur_vertex * 4 + k] = llclamp((U8)joints[k], (U8)0, (U8)110);
}
}
for (U32 k=0; k<4; k++)
{
F32 f_combined = (F32) joints[k] + wght[k];
@ -4656,6 +4664,7 @@ LLVolumeFace::LLVolumeFace() :
mTexCoords(NULL),
mIndices(NULL),
mWeights(NULL),
mJointIndices(NULL),
mWeightsScrubbed(FALSE),
mOctree(NULL),
mOptimized(FALSE)
@ -4682,6 +4691,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src)
mTexCoords(NULL),
mIndices(NULL),
mWeights(NULL),
mJointIndices(NULL),
mWeightsScrubbed(FALSE),
mOctree(NULL)
{
@ -4746,15 +4756,29 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
if (src.mWeights)
{
llassert(!mWeights); // don't orphan an old alloc here accidentally
allocateWeights(src.mNumVertices);
LLVector4a::memcpyNonAliased16((F32*) mWeights, (F32*) src.mWeights, vert_size);
LLVector4a::memcpyNonAliased16((F32*) mWeights, (F32*) src.mWeights, vert_size);
mWeightsScrubbed = src.mWeightsScrubbed;
}
else
{
ll_aligned_free_16(mWeights);
mWeights = NULL;
}
mWeightsScrubbed = src.mWeightsScrubbed;
ll_aligned_free_16(mWeights);
mWeights = NULL;
mWeightsScrubbed = FALSE;
}
if (src.mJointIndices)
{
llassert(!mJointIndices); // don't orphan an old alloc here accidentally
allocateJointIndices(src.mNumVertices);
LLVector4a::memcpyNonAliased16((F32*) mJointIndices, (F32*) src.mJointIndices, src.mNumVertices * sizeof(U8) * 4);
}
else
{
ll_aligned_free_16(mJointIndices);
mJointIndices = NULL;
}
}
if (mNumIndices)
@ -4763,7 +4787,12 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src)
LLVector4a::memcpyNonAliased16((F32*) mIndices, (F32*) src.mIndices, idx_size);
}
else
{
ll_aligned_free_16(mIndices);
mIndices = NULL;
}
mOptimized = src.mOptimized;
//delete
@ -4794,6 +4823,8 @@ void LLVolumeFace::freeData()
mTangents = NULL;
ll_aligned_free_16(mWeights);
mWeights = NULL;
ll_aligned_free_16(mJointIndices);
mJointIndices = NULL;
delete mOctree;
mOctree = NULL;
@ -5448,11 +5479,13 @@ bool LLVolumeFace::cacheOptimize()
// DO NOT free mNormals and mTexCoords as they are part of mPositions buffer
ll_aligned_free_16(mWeights);
ll_aligned_free_16(mTangents);
ll_aligned_free_16(mJointIndices);
mPositions = pos;
mNormals = norm;
mTexCoords = tc;
mWeights = wght;
mJointIndices = NULL; // filled in later as necessary by skinning code for acceleration
mTangents = binorm;
//std::string result = llformat("ACMR pre/post: %.3f/%.3f -- %d triangles %d breaks", pre_acmr, post_acmr, mNumIndices/3, breaks);
@ -6362,7 +6395,14 @@ void LLVolumeFace::allocateTangents(S32 num_verts)
void LLVolumeFace::allocateWeights(S32 num_verts)
{
ll_aligned_free_16(mWeights);
mWeights = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
mWeights = (LLVector4a*)ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
}
void LLVolumeFace::allocateJointIndices(S32 num_verts)
{
ll_aligned_free_16(mJointIndices);
mJointIndices = (U8*)ll_aligned_malloc_16(sizeof(U8) * 4 * num_verts);
}
void LLVolumeFace::resizeIndices(S32 num_indices)

View File

@ -875,6 +875,7 @@ public:
void resizeVertices(S32 num_verts);
void allocateTangents(S32 num_verts);
void allocateWeights(S32 num_verts);
void allocateJointIndices(S32 num_verts);
void resizeIndices(S32 num_indices);
void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx);
@ -955,6 +956,7 @@ public:
// format is mWeights[vertex_index].mV[influence] = <joint_index>.<weight>
// mWeights.size() should be empty or match mVertices.size()
LLVector4a* mWeights;
U8* mJointIndices;
mutable BOOL mWeightsScrubbed;

View File

@ -1784,7 +1784,7 @@ void LLDAELoader::extractTranslationViaElement( daeElement* pTranslateElement, L
{
if ( pTranslateElement )
{
domTranslate* pTranslateChild = dynamic_cast<domTranslate*>( pTranslateElement );
domTranslate* pTranslateChild = static_cast<domTranslate*>( pTranslateElement );
domFloat3 translateChild = pTranslateChild->getValue();
LLVector3 singleJointTranslation( translateChild[0], translateChild[1], translateChild[2] );
transform.setTranslation( singleJointTranslation );

View File

@ -80,6 +80,7 @@ set(llrender_HEADER_FILES
llshadermgr.h
lltexture.h
lluiimage.h
lluiimage.inl
llvertexbuffer.h
llglcommonfunc.h
)

View File

@ -31,7 +31,6 @@
// Project includes
#include "lluiimage.h"
#include "llrender2dutils.h"
LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
: mName(name),
@ -39,67 +38,29 @@ LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
mScaleRegion(0.f, 1.f, 1.f, 0.f),
mClipRegion(0.f, 1.f, 1.f, 0.f),
mImageLoaded(NULL),
mScaleStyle(SCALE_INNER)
{}
mScaleStyle(SCALE_INNER),
mCachedW(-1),
mCachedH(-1)
{
getTextureWidth();
getTextureHeight();
}
LLUIImage::~LLUIImage()
{
delete mImageLoaded;
}
void LLUIImage::setClipRegion(const LLRectf& region)
S32 LLUIImage::getWidth() const
{
mClipRegion = region;
// return clipped dimensions of actual image area
return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth());
}
void LLUIImage::setScaleRegion(const LLRectf& region)
S32 LLUIImage::getHeight() const
{
mScaleRegion = region;
}
void LLUIImage::setScaleStyle(LLUIImage::EScaleStyle style)
{
mScaleStyle = style;
}
//TODO: move drawing implementation inside class
void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const
{
draw(x, y, getWidth(), getHeight(), color);
}
void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
{
gl_draw_scaled_image_with_border(
x, y,
width, height,
mImage,
color,
FALSE,
mClipRegion,
mScaleRegion,
mScaleStyle == SCALE_INNER);
}
void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
{
gl_draw_scaled_image_with_border(
x, y,
width, height,
mImage,
color,
TRUE,
mClipRegion,
mScaleRegion,
mScaleStyle == SCALE_INNER);
}
void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
{
LLRect border_rect;
border_rect.setOriginAndSize(x, y, width, height);
border_rect.stretch(border_width, border_width);
drawSolid(border_rect, color);
// return clipped dimensions of actual image area
return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight());
}
void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, const LLVector3& y_axis,
@ -145,28 +106,7 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c
} LLRender2D::popMatrix();
}
S32 LLUIImage::getWidth() const
{
// return clipped dimensions of actual image area
return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth());
}
S32 LLUIImage::getHeight() const
{
// return clipped dimensions of actual image area
return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight());
}
S32 LLUIImage::getTextureWidth() const
{
return mImage->getWidth(0);
}
S32 LLUIImage::getTextureHeight() const
{
return mImage->getHeight(0);
}
//#include "lluiimage.inl"
boost::signals2::connection LLUIImage::addLoadedCallback( const image_loaded_signal_t::slot_type& cb )
{
@ -186,7 +126,6 @@ void LLUIImage::onImageLoaded()
}
}
namespace LLInitParam
{
void ParamValue<LLUIImage*>::updateValueFromBlock()

View File

@ -36,6 +36,7 @@
#include <boost/signals2.hpp>
#include "llinitparam.h"
#include "lltexture.h"
#include "llrender2dutils.h"
extern const LLColor4 UI_VERTEX_COLOR;
@ -53,35 +54,46 @@ public:
LLUIImage(const std::string& name, LLPointer<LLTexture> image);
virtual ~LLUIImage();
void setClipRegion(const LLRectf& region);
void setScaleRegion(const LLRectf& region);
void setScaleStyle(EScaleStyle style);
LL_FORCE_INLINE void setClipRegion(const LLRectf& region)
{
mClipRegion = region;
}
LLPointer<LLTexture> getImage() { return mImage; }
const LLPointer<LLTexture>& getImage() const { return mImage; }
LL_FORCE_INLINE void setScaleRegion(const LLRectf& region)
{
mScaleRegion = region;
}
void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
LL_FORCE_INLINE void setScaleStyle(EScaleStyle style)
{
mScaleStyle = style;
}
LL_FORCE_INLINE LLPointer<LLTexture> getImage() { return mImage; }
LL_FORCE_INLINE const LLPointer<LLTexture>& getImage() const { return mImage; }
LL_FORCE_INLINE void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
LL_FORCE_INLINE void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
LL_FORCE_INLINE void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); }
LL_FORCE_INLINE void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
LL_FORCE_INLINE void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
LL_FORCE_INLINE void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); }
void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); }
LL_FORCE_INLINE void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
LL_FORCE_INLINE void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
LL_FORCE_INLINE void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); }
void draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, const LLVector3& y_axis, const LLRect& rect, const LLColor4& color);
const std::string& getName() const { return mName; }
LL_FORCE_INLINE const std::string& getName() const { return mName; }
virtual S32 getWidth() const;
virtual S32 getHeight() const;
// returns dimensions of underlying textures, which might not be equal to ui image portion
S32 getTextureWidth() const;
S32 getTextureHeight() const;
LL_FORCE_INLINE S32 getTextureWidth() const;
LL_FORCE_INLINE S32 getTextureHeight() const;
boost::signals2::connection addLoadedCallback( const image_loaded_signal_t::slot_type& cb );
@ -95,8 +107,12 @@ protected:
LLRectf mClipRegion;
LLPointer<LLTexture> mImage;
EScaleStyle mScaleStyle;
mutable S32 mCachedW;
mutable S32 mCachedH;
};
#include "lluiimage.inl"
namespace LLInitParam
{
template<>

View File

@ -0,0 +1,77 @@
/**
* @file lluiimage.inl
* @brief UI inline func implementation
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const
{
draw(x, y, getWidth(), getHeight(), color);
}
void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
{
gl_draw_scaled_image_with_border(
x, y,
width, height,
mImage,
color,
FALSE,
mClipRegion,
mScaleRegion,
mScaleStyle == SCALE_INNER);
}
void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
{
gl_draw_scaled_image_with_border(
x, y,
width, height,
mImage,
color,
TRUE,
mClipRegion,
mScaleRegion,
mScaleStyle == SCALE_INNER);
}
void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
{
LLRect border_rect;
border_rect.setOriginAndSize(x, y, width, height);
border_rect.stretch(border_width, border_width);
drawSolid(border_rect, color);
}
// returns dimensions of underlying textures, which might not be equal to ui image portion
S32 LLUIImage::getTextureWidth() const
{
mCachedW = (mCachedW == -1) ? getWidth() : mCachedW;
return mCachedW;
}
S32 LLUIImage::getTextureHeight() const
{
mCachedH = (mCachedH == -1) ? getHeight() : mCachedH;
return mCachedH;
}

View File

@ -111,9 +111,11 @@ LLXmlTreeNode::~LLXmlTreeNode()
attribute_map_t::iterator iter;
for (iter=mAttributes.begin(); iter != mAttributes.end(); iter++)
delete iter->second;
child_list_t::iterator child_iter;
for (child_iter=mChildList.begin(); child_iter != mChildList.end(); child_iter++)
delete *child_iter;
for(LLXmlTreeNode* node : mChildren)
{
delete node;
}
mChildren.clear();
}
void LLXmlTreeNode::dump( const std::string& prefix )
@ -149,15 +151,15 @@ void LLXmlTreeNode::addAttribute(const std::string& name, const std::string& val
LLXmlTreeNode* LLXmlTreeNode::getFirstChild()
{
mChildListIter = mChildList.begin();
mChildrenIter = mChildren.begin();
return getNextChild();
}
LLXmlTreeNode* LLXmlTreeNode::getNextChild()
{
if (mChildListIter == mChildList.end())
if (mChildrenIter == mChildren.end())
return 0;
else
return *mChildListIter++;
return *mChildrenIter++;
}
LLXmlTreeNode* LLXmlTreeNode::getChildByName(const std::string& name)
@ -184,7 +186,7 @@ void LLXmlTreeNode::appendContents(const std::string& str)
void LLXmlTreeNode::addChild(LLXmlTreeNode* child)
{
llassert( child );
mChildList.push_back( child );
mChildren.push_back( child );
// Add a name mapping to this node
LLStdStringHandle tableptr = mTree->mNodeNames.insert(child->mName);

View File

@ -151,7 +151,7 @@ public:
LLXmlTreeNode* getParent() { return mParent; }
LLXmlTreeNode* getFirstChild();
LLXmlTreeNode* getNextChild();
S32 getChildCount() { return (S32)mChildList.size(); }
S32 getChildCount() { return (S32)mChildren.size(); }
LLXmlTreeNode* getChildByName( const std::string& name ); // returns first child with name, NULL if none
LLXmlTreeNode* getNextNamedChild(); // returns next child with name, NULL if none
@ -177,9 +177,9 @@ private:
std::string mName;
std::string mContents;
typedef std::list<class LLXmlTreeNode *> child_list_t;
child_list_t mChildList;
child_list_t::iterator mChildListIter;
typedef std::vector<class LLXmlTreeNode *> children_t;
children_t mChildren;
children_t::iterator mChildrenIter;
typedef std::multimap<LLStdStringHandle, LLXmlTreeNode *> child_map_t;
child_map_t mChildMap; // for fast name lookups

View File

@ -255,7 +255,7 @@ void LLControlAvatar::recursiveScaleJoint(LLJoint* joint, F32 factor)
{
joint->setScale(factor * joint->getScale());
for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
for (LLJoint::joints_t::iterator iter = joint->mChildren.begin();
iter != joint->mChildren.end(); ++iter)
{
LLJoint* child = *iter;

View File

@ -141,11 +141,10 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy )
//----------------------------------------------------------------
// render children
//----------------------------------------------------------------
for (child_list_t::iterator iter = mChildren.begin();
iter != mChildren.end(); ++iter)
for (LLJoint* j : mChildren)
{
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(*iter);
F32 jointLOD = joint->getLOD();
LLAvatarJoint* joint = dynamic_cast<LLAvatarJoint*>(j);
F32 jointLOD = joint ? joint->getLOD() : 0;
if (pixelArea >= jointLOD || sDisableLOD)
{
triangle_count += joint->render( pixelArea, TRUE, is_dummy );