Speed up object param lookups.
This commit is contained in:
@@ -1377,11 +1377,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
|
||||
unpackParticleSource(block_num, owner_id);
|
||||
|
||||
// Mark all extra parameters not used
|
||||
std::vector<std::unique_ptr<ExtraParameter> >::iterator iter;
|
||||
for (iter = mExtraParameterList.begin(); iter != mExtraParameterList.end(); ++iter)
|
||||
for (auto& entry : mExtraParameterList)
|
||||
{
|
||||
if(*iter)
|
||||
(*iter)->in_use = FALSE;
|
||||
if (entry.in_use) *entry.in_use = false;
|
||||
}
|
||||
|
||||
// Unpack extra parameters
|
||||
@@ -1410,10 +1408,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
|
||||
|
||||
for (size_t i = 0; i < mExtraParameterList.size(); ++i)
|
||||
{
|
||||
if (mExtraParameterList[i] && !mExtraParameterList[i]->in_use)
|
||||
auto& entry = mExtraParameterList[i];
|
||||
if (entry.in_use && !*entry.in_use)
|
||||
{
|
||||
// Send an update message in case it was formerly in use
|
||||
parameterChanged((i + 1) << 4, mExtraParameterList[i]->data.get(), FALSE, false);
|
||||
parameterChanged((i + 1) << 4, entry.data, FALSE, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1633,11 +1632,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
|
||||
}
|
||||
|
||||
// Mark all extra parameters not used
|
||||
std::vector<std::unique_ptr<ExtraParameter> >::iterator iter;
|
||||
for (iter = mExtraParameterList.begin(); iter != mExtraParameterList.end(); ++iter)
|
||||
for (auto& entry : mExtraParameterList)
|
||||
{
|
||||
if(*iter)
|
||||
(*iter)->in_use = FALSE;
|
||||
if (entry.in_use) *entry.in_use = false;
|
||||
}
|
||||
|
||||
// Unpack extra params
|
||||
@@ -1657,10 +1654,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
|
||||
|
||||
for (size_t i = 0; i < mExtraParameterList.size(); ++i)
|
||||
{
|
||||
if (mExtraParameterList[i] && !mExtraParameterList[i]->in_use)
|
||||
auto& entry = mExtraParameterList[i];
|
||||
if (entry.in_use && !*entry.in_use)
|
||||
{
|
||||
// Send an update message in case it was formerly in use
|
||||
parameterChanged((i + 1) << 4, mExtraParameterList[i]->data.get(), FALSE, false);
|
||||
parameterChanged((i + 1) << 4, entry.data, FALSE, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3990,7 +3988,7 @@ void LLViewerObject::boostTexturePriority(BOOL boost_children /* = TRUE */)
|
||||
|
||||
if (isSculpted() && !isMesh())
|
||||
{
|
||||
LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT);
|
||||
const LLSculptParams *sculpt_params = getSculptParams();
|
||||
LLUUID sculpt_id = sculpt_params->getSculptTexture();
|
||||
LLViewerTextureManager::getFetchedTexture(sculpt_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE)->setBoostLevel(LLGLTexture::BOOST_SELECTED);
|
||||
}
|
||||
@@ -5814,8 +5812,8 @@ bool LLViewerObject::unpackParameterEntry(U16 param_type, LLDataPacker *dp)
|
||||
if (param)
|
||||
{
|
||||
param->data->unpack(*dp);
|
||||
param->in_use = TRUE;
|
||||
parameterChanged(param_type, param->data.get(), TRUE, false);
|
||||
*param->in_use = TRUE;
|
||||
parameterChanged(param_type, param->data, TRUE, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -5827,31 +5825,37 @@ bool LLViewerObject::unpackParameterEntry(U16 param_type, LLDataPacker *dp)
|
||||
LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 param_type)
|
||||
{
|
||||
LLNetworkData* new_block = NULL;
|
||||
bool* in_use = NULL;
|
||||
switch (param_type)
|
||||
{
|
||||
case LLNetworkData::PARAMS_FLEXIBLE:
|
||||
{
|
||||
new_block = new LLFlexibleObjectData();
|
||||
new_block = &mFlexibleObjectData;
|
||||
in_use = &mFlexibleObjectDataInUse;
|
||||
break;
|
||||
}
|
||||
case LLNetworkData::PARAMS_LIGHT:
|
||||
{
|
||||
new_block = new LLLightParams();
|
||||
new_block = &mLightParams;
|
||||
in_use = &mLightParamsInUse;
|
||||
break;
|
||||
}
|
||||
case LLNetworkData::PARAMS_SCULPT:
|
||||
{
|
||||
new_block = new LLSculptParams();
|
||||
new_block = &mSculptParams;
|
||||
in_use = &mSculptParamsInUse;
|
||||
break;
|
||||
}
|
||||
case LLNetworkData::PARAMS_LIGHT_IMAGE:
|
||||
{
|
||||
new_block = new LLLightImageParams();
|
||||
new_block = &mLightImageParams;
|
||||
in_use = &mLightImageParamsInUse;
|
||||
break;
|
||||
}
|
||||
case LLNetworkData::PARAMS_EXTENDED_MESH:
|
||||
{
|
||||
new_block = new LLExtendedMeshParams();
|
||||
new_block = &mExtendedMeshParams;
|
||||
in_use = &mExtendedMeshParamsInUse;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -5861,70 +5865,33 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para
|
||||
}
|
||||
};
|
||||
|
||||
ExtraParameter& entry = mExtraParameterList[U32(param_type >> 4) - 1];
|
||||
if (new_block)
|
||||
{
|
||||
ExtraParameter* new_entry = new ExtraParameter;
|
||||
new_entry->data = decltype(new_entry->data)(new_block);
|
||||
new_entry->in_use = false; // not in use yet
|
||||
mExtraParameterList[(param_type >> 4) - 1].reset(new_entry);
|
||||
return new_entry;
|
||||
entry.in_use = in_use;
|
||||
*entry.in_use = false; // not in use yet
|
||||
entry.data = new_block;
|
||||
return &entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.is_invalid = true;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LLViewerObject::ExtraParameter* LLViewerObject::getExtraParameterEntry(U16 param_type) const
|
||||
{
|
||||
return param_type <= LLNetworkData::PARAMS_MAX ? mExtraParameterList[(param_type >> 4) - 1].get() : nullptr;
|
||||
}
|
||||
|
||||
LLViewerObject::ExtraParameter* LLViewerObject::getExtraParameterEntryCreate(U16 param_type)
|
||||
{
|
||||
ExtraParameter* param = getExtraParameterEntry(param_type);
|
||||
if (!param)
|
||||
{
|
||||
param = createNewParameterEntry(param_type);
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
LLNetworkData* LLViewerObject::getParameterEntry(U16 param_type) const
|
||||
{
|
||||
ExtraParameter* param = getExtraParameterEntry(param_type);
|
||||
if (param)
|
||||
{
|
||||
return param->data.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLViewerObject::getParameterEntryInUse(U16 param_type) const
|
||||
{
|
||||
ExtraParameter* param = getExtraParameterEntry(param_type);
|
||||
if (param)
|
||||
{
|
||||
return param->in_use;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool LLViewerObject::setParameterEntry(U16 param_type, const LLNetworkData& new_value, bool local_origin)
|
||||
{
|
||||
ExtraParameter* param = getExtraParameterEntryCreate(param_type);
|
||||
if (param)
|
||||
{
|
||||
if (param->in_use && new_value == *(param->data))
|
||||
if (*(param->in_use) && new_value == *(param->data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
param->in_use = true;
|
||||
*param->in_use = true;
|
||||
param->data->copy(new_value);
|
||||
parameterChanged(param_type, param->data.get(), TRUE, local_origin);
|
||||
parameterChanged(param_type, param->data, TRUE, local_origin);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -5938,22 +5905,28 @@ bool LLViewerObject::setParameterEntry(U16 param_type, const LLNetworkData& new_
|
||||
// Should always return true.
|
||||
bool LLViewerObject::setParameterEntryInUse(U16 param_type, BOOL in_use, bool local_origin)
|
||||
{
|
||||
ExtraParameter* param = getExtraParameterEntryCreate(param_type);
|
||||
if (param && param->in_use != in_use)
|
||||
if (param_type <= LLNetworkData::PARAMS_MAX)
|
||||
{
|
||||
param->in_use = in_use;
|
||||
parameterChanged(param_type, param->data.get(), in_use, local_origin);
|
||||
return true;
|
||||
ExtraParameter* param = (in_use ? getExtraParameterEntryCreate(param_type) : &getExtraParameterEntry(param_type));
|
||||
if (param && param->data && *param->in_use != (bool)in_use)
|
||||
{
|
||||
*param->in_use = in_use;
|
||||
parameterChanged(param_type, param->data, in_use, local_origin);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LLViewerObject::parameterChanged(U16 param_type, bool local_origin)
|
||||
{
|
||||
ExtraParameter* param = getExtraParameterEntry(param_type);
|
||||
if (param)
|
||||
if (param_type <= LLNetworkData::PARAMS_MAX)
|
||||
{
|
||||
parameterChanged(param_type, param->data.get(), param->in_use, local_origin);
|
||||
const ExtraParameter& param = getExtraParameterEntry(param_type);
|
||||
if (param.data)
|
||||
{
|
||||
parameterChanged(param_type, param.data, *param.in_use, local_origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user