Skip to content
Snippets Groups Projects
Commit 8997eb45 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Small opt to tree code to reduce many map finds

parent c8d4472e
No related branches found
No related tags found
No related merge requests found
...@@ -304,35 +304,34 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys, ...@@ -304,35 +304,34 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys,
mSpecies = ((U8 *)mData)[0]; mSpecies = ((U8 *)mData)[0];
} }
if (!sSpeciesTable.count(mSpecies)) if (!sSpeciesTable.empty() && !sSpeciesTable.count(mSpecies))
{ {
if (sSpeciesTable.size()) SpeciesMap::const_iterator it = sSpeciesTable.begin();
{ mSpecies = (*it).first;
SpeciesMap::const_iterator it = sSpeciesTable.begin();
mSpecies = (*it).first;
}
} }
// //
// Load Species-Specific data // Load Species-Specific data
// //
auto species_data = sSpeciesTable[mSpecies];
static const S32 MAX_TREE_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL = 32 ; //frames. static const S32 MAX_TREE_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL = 32 ; //frames.
mTreeImagep = LLViewerTextureManager::getFetchedTexture(sSpeciesTable[mSpecies]->mTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); mTreeImagep = LLViewerTextureManager::getFetchedTexture(species_data->mTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
mTreeImagep->setMaxVirtualSizeResetInterval(MAX_TREE_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL); //allow to wait for at most 16 frames to reset virtual size. mTreeImagep->setMaxVirtualSizeResetInterval(MAX_TREE_TEXTURE_VIRTURE_SIZE_RESET_INTERVAL); //allow to wait for at most 16 frames to reset virtual size.
mBranchLength = sSpeciesTable[mSpecies]->mBranchLength; mBranchLength = species_data->mBranchLength;
mTrunkLength = sSpeciesTable[mSpecies]->mTrunkLength; mTrunkLength = species_data->mTrunkLength;
mLeafScale = sSpeciesTable[mSpecies]->mLeafScale; mLeafScale = species_data->mLeafScale;
mDroop = sSpeciesTable[mSpecies]->mDroop; mDroop = species_data->mDroop;
mTwist = sSpeciesTable[mSpecies]->mTwist; mTwist = species_data->mTwist;
mBranches = sSpeciesTable[mSpecies]->mBranches; mBranches = species_data->mBranches;
mDepth = sSpeciesTable[mSpecies]->mDepth; mDepth = species_data->mDepth;
mScaleStep = sSpeciesTable[mSpecies]->mScaleStep; mScaleStep = species_data->mScaleStep;
mTrunkDepth = sSpeciesTable[mSpecies]->mTrunkDepth; mTrunkDepth = species_data->mTrunkDepth;
mBillboardScale = sSpeciesTable[mSpecies]->mBillboardScale; mBillboardScale = species_data->mBillboardScale;
mBillboardRatio = sSpeciesTable[mSpecies]->mBillboardRatio; mBillboardRatio = species_data->mBillboardRatio;
mTrunkAspect = sSpeciesTable[mSpecies]->mTrunkAspect; mTrunkAspect = species_data->mTrunkAspect;
mBranchAspect = sSpeciesTable[mSpecies]->mBranchAspect; mBranchAspect = species_data->mBranchAspect;
// position change not caused by us, etc. make sure to rebuild. // position change not caused by us, etc. make sure to rebuild.
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL); gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL);
...@@ -716,12 +715,14 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable) ...@@ -716,12 +715,14 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
// Generate the vertices // Generate the vertices
// Generate the indices // Generate the indices
auto species_data = sSpeciesTable[mSpecies];
for (lod = 0; lod < sMAX_NUM_TREE_LOD_LEVELS; lod++) for (lod = 0; lod < sMAX_NUM_TREE_LOD_LEVELS; lod++)
{ {
slices = sLODSlices[lod]; slices = sLODSlices[lod];
F32 base_radius = 0.65f; F32 base_radius = 0.65f;
F32 top_radius = base_radius * sSpeciesTable[mSpecies]->mTaper; F32 top_radius = base_radius * species_data->mTaper;
//LL_INFOS() << "Species " << ((U32) mSpecies) << ", taper = " << sSpeciesTable[mSpecies].mTaper << LL_ENDL; //LL_INFOS() << "Species " << ((U32) mSpecies) << ", taper = " << species_data.mTaper << LL_ENDL;
//LL_INFOS() << "Droop " << mDroop << ", branchlength: " << mBranchLength << LL_ENDL; //LL_INFOS() << "Droop " << mDroop << ", branchlength: " << mBranchLength << LL_ENDL;
F32 angle = 0; F32 angle = 0;
F32 angle_inc = 360.f/(slices-1); F32 angle_inc = 360.f/(slices-1);
...@@ -734,16 +735,16 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable) ...@@ -734,16 +735,16 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
F32 radius = base_radius; F32 radius = base_radius;
F32 x1,y1; F32 x1,y1;
F32 noise_scale = sSpeciesTable[mSpecies]->mNoiseMag; F32 noise_scale = species_data->mNoiseMag;
LLVector3 nvec; LLVector3 nvec;
const F32 cap_nudge = 0.1f; // Height to 'peak' the caps on top/bottom of branch const F32 cap_nudge = 0.1f; // Height to 'peak' the caps on top/bottom of branch
const S32 fractal_depth = 5; const S32 fractal_depth = 5;
F32 nvec_scale = 1.f * sSpeciesTable[mSpecies]->mNoiseScale; F32 nvec_scale = 1.f * species_data->mNoiseScale;
F32 nvec_scalez = 4.f * sSpeciesTable[mSpecies]->mNoiseScale; F32 nvec_scalez = 4.f * species_data->mNoiseScale;
F32 tex_z_repeat = sSpeciesTable[mSpecies]->mRepeatTrunkZ; F32 tex_z_repeat = species_data->mRepeatTrunkZ;
F32 start_radius; F32 start_radius;
F32 nangle = 0; F32 nangle = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment