summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r--indra/newview/llvoavatar.cpp173
1 files changed, 76 insertions, 97 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 5329b354d3..8e8cf7424f 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -616,7 +616,6 @@ bool LLVOAvatar::sVisibleInFirstPerson = false;
F32 LLVOAvatar::sLODFactor = 1.f;
F32 LLVOAvatar::sPhysicsLODFactor = 1.f;
bool LLVOAvatar::sJointDebug = false;
-bool LLVOAvatar::sLipSyncEnabled = false;
F32 LLVOAvatar::sUnbakedTime = 0.f;
F32 LLVOAvatar::sUnbakedUpdateTime = 0.f;
F32 LLVOAvatar::sGreyTime = 0.f;
@@ -1177,7 +1176,6 @@ void LLVOAvatar::initClass()
LLControlAvatar::sRegionChangedSlot = gAgent.addRegionChangedCallback(&LLControlAvatar::onRegionChanged);
sCloudTexture = LLViewerTextureManager::getFetchedTextureFromFile("cloud-particle.j2c");
- gSavedSettings.getControl("LipSyncEnabled")->getSignal()->connect(boost::bind(&LLVOAvatar::handleVOAvatarPrefsChanged, _2));
}
@@ -1185,12 +1183,6 @@ void LLVOAvatar::cleanupClass()
{
}
-bool LLVOAvatar::handleVOAvatarPrefsChanged(const LLSD &newvalue)
-{
- sLipSyncEnabled = gSavedSettings.getBOOL("LipSyncEnabled");
- return true;
-}
-
// virtual
void LLVOAvatar::initInstance()
{
@@ -1847,36 +1839,36 @@ bool LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
{
mCollisionVolumes[i].updateWorldMatrix();
- glh::matrix4f mat((F32*) mCollisionVolumes[i].getXform()->getWorldMatrix().mMatrix);
- glh::matrix4f inverse = mat.inverse();
- glh::matrix4f norm_mat = inverse.transpose();
+ glm::mat4 mat(glm::make_mat4((F32*) mCollisionVolumes[i].getXform()->getWorldMatrix().mMatrix));
+ glm::mat4 inverse = glm::inverse(mat);
+ glm::mat4 norm_mat = glm::transpose(inverse);
- glh::vec3f p1(start.getF32ptr());
- glh::vec3f p2(end.getF32ptr());
+ glm::vec3 p1(glm::make_vec3(start.getF32ptr()));
+ glm::vec3 p2(glm::make_vec3(end.getF32ptr()));
- inverse.mult_matrix_vec(p1);
- inverse.mult_matrix_vec(p2);
+ p1 = mul_mat4_vec3(inverse, p1);
+ p2 = mul_mat4_vec3(inverse, p2);
LLVector3 position;
LLVector3 norm;
- if (linesegment_sphere(LLVector3(p1.v), LLVector3(p2.v), LLVector3(0,0,0), 1.f, position, norm))
+ if (linesegment_sphere(LLVector3(glm::value_ptr(p1)), LLVector3(glm::value_ptr(p2)), LLVector3(0,0,0), 1.f, position, norm))
{
- glh::vec3f res_pos(position.mV);
- mat.mult_matrix_vec(res_pos);
+ glm::vec3 res_pos(glm::make_vec3(position.mV));
+ res_pos = mul_mat4_vec3(mat, res_pos);
- norm.normalize();
- glh::vec3f res_norm(norm.mV);
- norm_mat.mult_matrix_dir(res_norm);
+ glm::vec3 res_norm(glm::make_vec3(norm.mV));
+ res_norm = glm::normalize(res_norm);
+ res_norm = glm::mat3(norm_mat) * res_norm;
if (intersection)
{
- intersection->load3(res_pos.v);
+ intersection->load3(glm::value_ptr(res_pos));
}
if (normal)
{
- normal->load3(res_norm.v);
+ normal->load3(glm::value_ptr(res_norm));
}
return true;
@@ -2881,7 +2873,7 @@ static void override_bbox(LLDrawable* drawable, LLVector4a* extents)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL;
drawable->setSpatialExtents(extents[0], extents[1]);
- drawable->setPositionGroup(LLVector4a(0, 0, 0));
+ drawable->setPositionGroup(LLVector4a(0.f, 0.f, 0.f));
drawable->movePartition();
}
@@ -2902,19 +2894,12 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
if (detailed_update)
{
U32 draw_order = 0;
- S32 attachment_selected = LLSelectMgr::getInstance()->getSelection()->getObjectCount() && LLSelectMgr::getInstance()->getSelection()->isAttachment();
- for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end();
- ++iter)
+ bool attachment_selected = LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 0 && LLSelectMgr::getInstance()->getSelection()->isAttachment();
+ for (const auto& [attachment_point_id, attachment] : mAttachmentPoints)
{
- LLViewerJointAttachment* attachment = iter->second;
-
- for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
- attachment_iter != attachment->mAttachedObjects.end();
- ++attachment_iter)
+ for (auto& attached_object : attachment->mAttachedObjects)
{
- LLViewerObject* attached_object = attachment_iter->get();
- if (!attached_object
+ if (attached_object.isNull()
|| attached_object->isDead()
|| !attachment->getValid()
|| attached_object->mDrawable.isNull())
@@ -3119,7 +3104,7 @@ void LLVOAvatar::idleUpdateLipSync(bool voice_enabled)
// Use the Lipsync_Ooh and Lipsync_Aah morphs for lip sync
if ( voice_enabled
&& mLastRezzedStatus > 0 // no point updating lip-sync for clouds
- && sLipSyncEnabled
+ && LLVoiceVisualizer::getLipSyncEnabled()
&& LLVoiceClient::getInstance()->getIsSpeaking( mID ) )
{
F32 ooh_morph_amount = 0.0f;
@@ -3696,21 +3681,22 @@ LLVector3 LLVOAvatar::idleCalcNameTagPosition(const LLVector3 &root_pos_last)
name_position += (local_camera_up * root_rot) - (projected_vec(local_camera_at * root_rot, camera_to_av));
name_position += pixel_up_vec * NAMETAG_VERTICAL_SCREEN_OFFSET;
- const F32 water_height = getRegion()->getWaterHeight();
- static const F32 WATER_HEIGHT_DELTA = 0.25f;
- if (name_position[VZ] < water_height + WATER_HEIGHT_DELTA)
+ // Avoid of crossing the name tag by the water surface
+ if (mNameText)
{
- if (LLViewerCamera::getInstance()->getOrigin()[VZ] >= water_height)
+ F32 water_height = getRegion()->getWaterHeight();
+ static const F32 WATER_HEIGHT_ABOVE_DELTA = 0.25;
+ if (name_position[VZ] < water_height + WATER_HEIGHT_ABOVE_DELTA)
{
- name_position[VZ] = water_height;
- }
- else if (mNameText) // both camera and HUD are below watermark
- {
- F32 name_world_height = mNameText->getWorldHeight();
- F32 max_z_position = water_height - name_world_height;
- if (name_position[VZ] > max_z_position)
+ F32 camera_height = LLViewerCamera::getInstance()->getOrigin()[VZ];
+ if (camera_height >= water_height)
{
- name_position[VZ] = max_z_position;
+ F32 name_world_height = mNameText->getWorldHeight();
+ static const F32 WATER_HEIGHT_BELOW_DELTA = 0.5;
+ if (name_position[VZ] + name_world_height > water_height - WATER_HEIGHT_BELOW_DELTA)
+ {
+ name_position[VZ] = water_height + WATER_HEIGHT_ABOVE_DELTA;
+ }
}
}
}
@@ -8615,60 +8601,53 @@ void LLVOAvatar::updateMeshVisibility()
if (getOverallAppearance() == AOA_NORMAL)
{
- for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
- iter != mAttachmentPoints.end();
- ++iter)
+ for (const auto& [attachment_point_id, attachment] : mAttachmentPoints)
{
- LLViewerJointAttachment* attachment = iter->second;
- if (attachment)
+ if (!attachment)
+ continue;
+
+ for (const auto& objectp : attachment->mAttachedObjects)
{
- for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
- attachment_iter != attachment->mAttachedObjects.end();
- ++attachment_iter)
+ if (objectp.isNull())
+ continue;
+
+ for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++)
{
- LLViewerObject *objectp = attachment_iter->get();
- if (objectp)
- {
- for (int face_index = 0; face_index < objectp->getNumTEs(); face_index++)
- {
- LLTextureEntry* tex_entry = objectp->getTE(face_index);
- bake_flag[BAKED_HEAD] |= (tex_entry->getID() == IMG_USE_BAKED_HEAD);
- bake_flag[BAKED_EYES] |= (tex_entry->getID() == IMG_USE_BAKED_EYES);
- bake_flag[BAKED_HAIR] |= (tex_entry->getID() == IMG_USE_BAKED_HAIR);
- bake_flag[BAKED_LOWER] |= (tex_entry->getID() == IMG_USE_BAKED_LOWER);
- bake_flag[BAKED_UPPER] |= (tex_entry->getID() == IMG_USE_BAKED_UPPER);
- bake_flag[BAKED_SKIRT] |= (tex_entry->getID() == IMG_USE_BAKED_SKIRT);
- bake_flag[BAKED_LEFT_ARM] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTARM);
- bake_flag[BAKED_LEFT_LEG] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTLEG);
- bake_flag[BAKED_AUX1] |= (tex_entry->getID() == IMG_USE_BAKED_AUX1);
- bake_flag[BAKED_AUX2] |= (tex_entry->getID() == IMG_USE_BAKED_AUX2);
- bake_flag[BAKED_AUX3] |= (tex_entry->getID() == IMG_USE_BAKED_AUX3);
- }
- }
+ LLTextureEntry* tex_entry = objectp->getTE(face_index);
+ const auto& tex_id = tex_entry->getID();
+ bake_flag[BAKED_HEAD] |= (tex_id == IMG_USE_BAKED_HEAD);
+ bake_flag[BAKED_EYES] |= (tex_id == IMG_USE_BAKED_EYES);
+ bake_flag[BAKED_HAIR] |= (tex_id == IMG_USE_BAKED_HAIR);
+ bake_flag[BAKED_LOWER] |= (tex_id == IMG_USE_BAKED_LOWER);
+ bake_flag[BAKED_UPPER] |= (tex_id == IMG_USE_BAKED_UPPER);
+ bake_flag[BAKED_SKIRT] |= (tex_id == IMG_USE_BAKED_SKIRT);
+ bake_flag[BAKED_LEFT_ARM] |= (tex_id == IMG_USE_BAKED_LEFTARM);
+ bake_flag[BAKED_LEFT_LEG] |= (tex_id == IMG_USE_BAKED_LEFTLEG);
+ bake_flag[BAKED_AUX1] |= (tex_id == IMG_USE_BAKED_AUX1);
+ bake_flag[BAKED_AUX2] |= (tex_id == IMG_USE_BAKED_AUX2);
+ bake_flag[BAKED_AUX3] |= (tex_id == IMG_USE_BAKED_AUX3);
+ }
- LLViewerObject::const_child_list_t& child_list = objectp->getChildren();
- for (LLViewerObject::child_list_t::const_iterator iter1 = child_list.begin();
- iter1 != child_list.end(); ++iter1)
+ for (const auto& objectchild : objectp->getChildren())
+ {
+ if (objectchild.isNull())
+ continue;
+
+ for (int face_index = 0; face_index < objectchild->getNumTEs(); face_index++)
{
- LLViewerObject* objectchild = *iter1;
- if (objectchild)
- {
- for (int face_index = 0; face_index < objectchild->getNumTEs(); face_index++)
- {
- LLTextureEntry* tex_entry = objectchild->getTE(face_index);
- bake_flag[BAKED_HEAD] |= (tex_entry->getID() == IMG_USE_BAKED_HEAD);
- bake_flag[BAKED_EYES] |= (tex_entry->getID() == IMG_USE_BAKED_EYES);
- bake_flag[BAKED_HAIR] |= (tex_entry->getID() == IMG_USE_BAKED_HAIR);
- bake_flag[BAKED_LOWER] |= (tex_entry->getID() == IMG_USE_BAKED_LOWER);
- bake_flag[BAKED_UPPER] |= (tex_entry->getID() == IMG_USE_BAKED_UPPER);
- bake_flag[BAKED_SKIRT] |= (tex_entry->getID() == IMG_USE_BAKED_SKIRT);
- bake_flag[BAKED_LEFT_ARM] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTARM);
- bake_flag[BAKED_LEFT_LEG] |= (tex_entry->getID() == IMG_USE_BAKED_LEFTLEG);
- bake_flag[BAKED_AUX1] |= (tex_entry->getID() == IMG_USE_BAKED_AUX1);
- bake_flag[BAKED_AUX2] |= (tex_entry->getID() == IMG_USE_BAKED_AUX2);
- bake_flag[BAKED_AUX3] |= (tex_entry->getID() == IMG_USE_BAKED_AUX3);
- }
- }
+ LLTextureEntry* tex_entry = objectchild->getTE(face_index);
+ const auto& tex_id = tex_entry->getID();
+ bake_flag[BAKED_HEAD] |= (tex_id == IMG_USE_BAKED_HEAD);
+ bake_flag[BAKED_EYES] |= (tex_id == IMG_USE_BAKED_EYES);
+ bake_flag[BAKED_HAIR] |= (tex_id == IMG_USE_BAKED_HAIR);
+ bake_flag[BAKED_LOWER] |= (tex_id == IMG_USE_BAKED_LOWER);
+ bake_flag[BAKED_UPPER] |= (tex_id == IMG_USE_BAKED_UPPER);
+ bake_flag[BAKED_SKIRT] |= (tex_id == IMG_USE_BAKED_SKIRT);
+ bake_flag[BAKED_LEFT_ARM] |= (tex_id == IMG_USE_BAKED_LEFTARM);
+ bake_flag[BAKED_LEFT_LEG] |= (tex_id == IMG_USE_BAKED_LEFTLEG);
+ bake_flag[BAKED_AUX1] |= (tex_id == IMG_USE_BAKED_AUX1);
+ bake_flag[BAKED_AUX2] |= (tex_id == IMG_USE_BAKED_AUX2);
+ bake_flag[BAKED_AUX3] |= (tex_id == IMG_USE_BAKED_AUX3);
}
}
}