summaryrefslogtreecommitdiff
path: root/indra/newview/llselectmgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r--indra/newview/llselectmgr.cpp516
1 files changed, 457 insertions, 59 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index f05892d9b0..9b264b81c7 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -64,6 +64,7 @@
#include "llhudmanager.h"
#include "llinventorymodel.h"
#include "llmenugl.h"
+#include "llmeshrepository.h"
#include "llmutelist.h"
#include "llnotificationsutil.h"
#include "llsidepaneltaskinfo.h"
@@ -176,7 +177,6 @@ LLObjectSelection *get_null_object_selection()
// Build time optimization, generate this function once here
template class LLSelectMgr* LLSingleton<class LLSelectMgr>::getInstance();
-
//-----------------------------------------------------------------------------
// LLSelectMgr()
//-----------------------------------------------------------------------------
@@ -1191,8 +1191,8 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
mGridRotation = first_grid_object->getRenderRotation();
LLVector3 first_grid_obj_pos = first_grid_object->getRenderPosition();
- LLVector3 min_extents(F32_MAX, F32_MAX, F32_MAX);
- LLVector3 max_extents(-F32_MAX, -F32_MAX, -F32_MAX);
+ LLVector4a min_extents(F32_MAX);
+ LLVector4a max_extents(-F32_MAX);
BOOL grid_changed = FALSE;
for (LLObjectSelection::iterator iter = mGridObjects.begin();
iter != mGridObjects.end(); ++iter)
@@ -1201,7 +1201,7 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
LLDrawable* drawable = object->mDrawable;
if (drawable)
{
- const LLVector3* ext = drawable->getSpatialExtents();
+ const LLVector4a* ext = drawable->getSpatialExtents();
update_min_max(min_extents, max_extents, ext[0]);
update_min_max(min_extents, max_extents, ext[1]);
grid_changed = TRUE;
@@ -1209,13 +1209,19 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
}
if (grid_changed)
{
- mGridOrigin = lerp(min_extents, max_extents, 0.5f);
+ LLVector4a center, size;
+ center.setAdd(min_extents, max_extents);
+ center.mul(0.5f);
+ size.setSub(max_extents, min_extents);
+ size.mul(0.5f);
+
+ mGridOrigin.set(center.getF32ptr());
LLDrawable* drawable = first_grid_object->mDrawable;
if (drawable && drawable->isActive())
{
mGridOrigin = mGridOrigin * first_grid_object->getRenderMatrix();
}
- mGridScale = (max_extents - min_extents) * 0.5f;
+ mGridScale.set(size.getF32ptr());
}
}
else // GRID_MODE_WORLD or just plain default
@@ -1979,6 +1985,103 @@ BOOL LLSelectMgr::selectionGetGlow(F32 *glow)
return identical;
}
+
+void LLSelectMgr::selectionSetPhysicsType(U8 type)
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ U8 mType;
+ f(const U8& t) : mType(t) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsShapeType(mType);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(type);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetFriction(F32 friction)
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mFriction;
+ f(const F32& friction) : mFriction(friction) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsFriction(mFriction);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(friction);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetGravity(F32 gravity )
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mGravity;
+ f(const F32& gravity) : mGravity(gravity) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsGravity(mGravity);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(gravity);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetDensity(F32 density )
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mDensity;
+ f(const F32& density ) : mDensity(density) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsDensity(mDensity);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(density);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+void LLSelectMgr::selectionSetRestitution(F32 restitution)
+{
+ struct f : public LLSelectedObjectFunctor
+ {
+ F32 mRestitution;
+ f(const F32& restitution ) : mRestitution(restitution) {}
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ object->setPhysicsRestitution(mRestitution);
+ object->updateFlags();
+ }
+ return true;
+ }
+ } sendfunc(restitution);
+ getSelection()->applyToObjects(&sendfunc);
+}
+
+
//-----------------------------------------------------------------------------
// selectionSetMaterial()
//-----------------------------------------------------------------------------
@@ -3628,7 +3731,7 @@ void LLSelectMgr::deselectAllIfTooFar()
{
if (mDebugSelectMgr)
{
- llinfos << "Selection manager: auto-deselecting, select_dist = " << fsqrtf(select_dist_sq) << llendl;
+ llinfos << "Selection manager: auto-deselecting, select_dist = " << (F32) sqrt(select_dist_sq) << llendl;
llinfos << "agent pos global = " << gAgent.getPositionGlobal() << llendl;
llinfos << "selection pos global = " << selectionCenter << llendl;
}
@@ -3797,6 +3900,26 @@ void LLSelectMgr::sendDelink()
return;
}
+ struct f : public LLSelectedObjectFunctor
+ { //on delink, any modifyable object should
+ f() {}
+
+ virtual bool apply(LLViewerObject* object)
+ {
+ if (object->permModify())
+ {
+ if (object->getPhysicsShapeType() == LLViewerObject::PHYSICS_SHAPE_NONE)
+ {
+ object->setPhysicsShapeType(LLViewerObject::PHYSICS_SHAPE_CONVEX_HULL);
+ object->updateFlags();
+ }
+ }
+ return true;
+ }
+ } sendfunc;
+ getSelection()->applyToObjects(&sendfunc);
+
+
// Delink needs to send individuals so you can unlink a single object from
// a linked set.
sendListToRegions(
@@ -4026,7 +4149,6 @@ void LLSelectMgr::selectionUpdateCastShadows(BOOL cast_shadows)
getSelection()->applyToObjects(&func);
}
-
//----------------------------------------------------------------------
// Helpful packing functions for sendObjectMessage()
//----------------------------------------------------------------------
@@ -4715,7 +4837,6 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**)
LLSelectMgr::getInstance()->highlightObjectAndFamily(objects);
}
-
extern LLGLdouble gGLModelView[16];
void LLSelectMgr::updateSilhouettes()
@@ -5199,7 +5320,6 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep)
mSilhouetteVertices = nodep.mSilhouetteVertices;
mSilhouetteNormals = nodep.mSilhouetteNormals;
- mSilhouetteSegments = nodep.mSilhouetteSegments;
mSilhouetteExists = nodep.mSilhouetteExists;
mObject = nodep.mObject;
@@ -5433,6 +5553,111 @@ BOOL LLSelectNode::allowOperationOnNode(PermissionBit op, U64 group_proxy_power)
return (mPermissions->allowOperationBy(op, proxy_agent_id, group_id));
}
+
+//helper function for pushing relevant vertices from drawable to GL
+void pushWireframe(LLDrawable* drawable)
+{
+ if (drawable->isState(LLDrawable::RIGGED))
+ { //render straight from rigged volume if this is a rigged attachment
+ LLVOVolume* vobj = drawable->getVOVolume();
+ if (vobj)
+ {
+ vobj->updateRiggedVolume();
+ LLRiggedVolume* rigged_volume = vobj->getRiggedVolume();
+ if (rigged_volume)
+ {
+ LLVertexBuffer::unbind();
+ gGL.pushMatrix();
+ glMultMatrixf((F32*) vobj->getRelativeXform().mMatrix);
+ for (S32 i = 0; i < rigged_volume->getNumVolumeFaces(); ++i)
+ {
+ const LLVolumeFace& face = rigged_volume->getVolumeFace(i);
+ glVertexPointer(3, GL_FLOAT, 16, face.mPositions);
+ glDrawElements(GL_TRIANGLES, face.mNumIndices, GL_UNSIGNED_SHORT, face.mIndices);
+ }
+ gGL.popMatrix();
+ }
+ }
+ }
+ else
+ {
+ for (S32 i = 0; i < drawable->getNumFaces(); ++i)
+ {
+ LLFace* face = drawable->getFace(i);
+ if (face->verify())
+ {
+ pushVerts(face, LLVertexBuffer::MAP_VERTEX);
+ }
+ }
+ }
+}
+
+void LLSelectNode::renderOneWireframe(const LLColor4& color)
+{
+ LLViewerObject* objectp = getObject();
+ if (!objectp)
+ {
+ return;
+ }
+
+ LLDrawable* drawable = objectp->mDrawable;
+ if(!drawable)
+ {
+ return;
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+ gGL.pushMatrix();
+
+ BOOL is_hud_object = objectp->isHUDAttachment();
+
+ if (drawable->isActive())
+ {
+ glLoadMatrixd(gGLModelView);
+ glMultMatrixf((F32*) objectp->getRenderMatrix().mMatrix);
+ }
+ else if (!is_hud_object)
+ {
+ glLoadIdentity();
+ glMultMatrixd(gGLModelView);
+ LLVector3 trans = objectp->getRegion()->getOriginAgent();
+ glTranslatef(trans.mV[0], trans.mV[1], trans.mV[2]);
+ }
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ if (LLSelectMgr::sRenderHiddenSelections) // && gFloaterTools && gFloaterTools->getVisible())
+ {
+ gGL.blendFunc(LLRender::BF_SOURCE_COLOR, LLRender::BF_ONE);
+ LLGLEnable fog(GL_FOG);
+ glFogi(GL_FOG_MODE, GL_LINEAR);
+ float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec();
+ LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgentCamera.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0);
+ glFogf(GL_FOG_START, d);
+ glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV())));
+ glFogfv(GL_FOG_COLOR, fogCol.mV);
+
+ LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL);
+ gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+ {
+ glColor4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f);
+ pushWireframe(drawable);
+ }
+ }
+
+ gGL.flush();
+ gGL.setSceneBlendType(LLRender::BT_ALPHA);
+
+ glColor4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2);
+ LLGLEnable offset(GL_POLYGON_OFFSET_LINE);
+ glPolygonOffset(3.f, 3.f);
+ glLineWidth(3.f);
+ pushWireframe(drawable);
+ glLineWidth(1.f);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ gGL.popMatrix();
+}
+
//-----------------------------------------------------------------------------
// renderOneSilhouette()
//-----------------------------------------------------------------------------
@@ -5450,6 +5675,13 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
return;
}
+ LLVOVolume* vobj = drawable->getVOVolume();
+ if (vobj && vobj->isMesh())
+ {
+ renderOneWireframe(color);
+ return;
+ }
+
if (!mSilhouetteExists)
{
return;
@@ -5514,17 +5746,15 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
gGL.begin(LLRender::LINES);
{
- S32 i = 0;
- for (S32 seg_num = 0; seg_num < (S32)mSilhouetteSegments.size(); seg_num++)
+ for(S32 i = 0; i < mSilhouetteVertices.size(); i += 2)
{
- for(; i < mSilhouetteSegments[seg_num]; i++)
- {
- u_coord += u_divisor * LLSelectMgr::sHighlightUScale;
-
- gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f);
- gGL.texCoord2f( u_coord, v_coord );
- gGL.vertex3fv( mSilhouetteVertices[i].mV );
- }
+ u_coord += u_divisor * LLSelectMgr::sHighlightUScale;
+ gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.4f);
+ gGL.texCoord2f( u_coord, v_coord );
+ gGL.vertex3fv( mSilhouetteVertices[i].mV);
+ u_coord += u_divisor * LLSelectMgr::sHighlightUScale;
+ gGL.texCoord2f( u_coord, v_coord );
+ gGL.vertex3fv(mSilhouetteVertices[i+1].mV);
}
}
gGL.end();
@@ -5535,51 +5765,50 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color)
gGL.setSceneBlendType(LLRender::BT_ALPHA);
gGL.begin(LLRender::TRIANGLES);
{
- S32 i = 0;
- for (S32 seg_num = 0; seg_num < (S32)mSilhouetteSegments.size(); seg_num++)
+ for(S32 i = 0; i < mSilhouetteVertices.size(); i+=2)
{
- S32 first_i = i;
- LLVector3 v;
- LLVector2 t;
+ if (!mSilhouetteNormals[i].isFinite() ||
+ !mSilhouetteNormals[i+1].isFinite())
+ { //skip skewed segments
+ continue;
+ }
- for(; i < mSilhouetteSegments[seg_num]; i++)
- {
+ LLVector3 v[4];
+ LLVector2 tc[4];
+ v[0] = mSilhouetteVertices[i] + (mSilhouetteNormals[i] * silhouette_thickness);
+ tc[0].set(u_coord, v_coord + LLSelectMgr::sHighlightVScale);
- if (i == first_i) {
- LLVector3 vert = (mSilhouetteNormals[i]) * silhouette_thickness;
- vert += mSilhouetteVertices[i];
+ v[1] = mSilhouetteVertices[i];
+ tc[1].set(u_coord, v_coord);
- gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.0f); //LLSelectMgr::sHighlightAlpha);
- gGL.texCoord2f( u_coord, v_coord + LLSelectMgr::sHighlightVScale );
- gGL.vertex3fv( vert.mV );
-
- u_coord += u_divisor * LLSelectMgr::sHighlightUScale;
+ u_coord += u_divisor * LLSelectMgr::sHighlightUScale;
- gGL.color4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2);
- gGL.texCoord2f( u_coord, v_coord );
- gGL.vertex3fv( mSilhouetteVertices[i].mV );
+ v[2] = mSilhouetteVertices[i+1] + (mSilhouetteNormals[i+1] * silhouette_thickness);
+ tc[2].set(u_coord, v_coord + LLSelectMgr::sHighlightVScale);
+
+ v[3] = mSilhouetteVertices[i+1];
+ tc[3].set(u_coord,v_coord);
- v = mSilhouetteVertices[i];
- t = LLVector2(u_coord, v_coord);
- }
- else {
- LLVector3 vert = (mSilhouetteNormals[i]) * silhouette_thickness;
- vert += mSilhouetteVertices[i];
-
- gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.0f); //LLSelectMgr::sHighlightAlpha);
- gGL.texCoord2f( u_coord, v_coord + LLSelectMgr::sHighlightVScale );
- gGL.vertex3fv( vert.mV );
- gGL.vertex3fv( vert.mV );
-
- gGL.texCoord2fv(t.mV);
- u_coord += u_divisor * LLSelectMgr::sHighlightUScale;
- gGL.color4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2);
- gGL.vertex3fv(v.mV);
- gGL.texCoord2f( u_coord, v_coord );
- gGL.vertex3fv( mSilhouetteVertices[i].mV );
+ gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.0f); //LLSelectMgr::sHighlightAlpha);
+ gGL.texCoord2fv(tc[0].mV);
+ gGL.vertex3fv( v[0].mV );
+
+ gGL.color4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2);
+ gGL.texCoord2fv( tc[1].mV );
+ gGL.vertex3fv( v[1].mV );
- }
- }
+ gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], 0.0f); //LLSelectMgr::sHighlightAlpha);
+ gGL.texCoord2fv( tc[2].mV );
+ gGL.vertex3fv( v[2].mV );
+
+ gGL.vertex3fv( v[2].mV );
+
+ gGL.color4f(color.mV[VRED]*2, color.mV[VGREEN]*2, color.mV[VBLUE]*2, LLSelectMgr::sHighlightAlpha*2);
+ gGL.texCoord2fv( tc[1].mV );
+ gGL.vertex3fv( v[1].mV );
+
+ gGL.texCoord2fv( tc[3].mV );
+ gGL.vertex3fv( v[3].mV );
}
}
gGL.end();
@@ -6147,9 +6376,178 @@ S32 LLObjectSelection::getObjectCount()
{
cleanupNodes();
S32 count = mList.size();
+
+ return count;
+}
+
+F32 LLObjectSelection::getSelectedObjectCost()
+{
+ cleanupNodes();
+ F32 cost = 0.f;
+
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLViewerObject* object = node->getObject();
+
+ if (object)
+ {
+ cost += object->getObjectCost();
+ }
+ }
+
+ return cost;
+}
+
+F32 LLObjectSelection::getSelectedLinksetCost()
+{
+ cleanupNodes();
+ F32 cost = 0.f;
+
+ std::set<LLViewerObject*> me_roots;
+
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLViewerObject* object = node->getObject();
+
+ if (object)
+ {
+ LLViewerObject* root = static_cast<LLViewerObject*>(object->getRoot());
+ if (root)
+ {
+ if (me_roots.find(root) == me_roots.end())
+ {
+ me_roots.insert(root);
+ cost += root->getLinksetCost();
+ }
+ }
+ }
+ }
+
+ return cost;
+}
+
+F32 LLObjectSelection::getSelectedPhysicsCost()
+{
+ cleanupNodes();
+ F32 cost = 0.f;
+
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLViewerObject* object = node->getObject();
+
+ if (object)
+ {
+ cost += object->getPhysicsCost();
+ }
+ }
+
+ return cost;
+}
+
+F32 LLObjectSelection::getSelectedLinksetPhysicsCost()
+{
+ cleanupNodes();
+ F32 cost = 0.f;
+
+ std::set<LLViewerObject*> me_roots;
+
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLViewerObject* object = node->getObject();
+
+ if (object)
+ {
+ LLViewerObject* root = static_cast<LLViewerObject*>(object->getRoot());
+ if (root)
+ {
+ if (me_roots.find(root) == me_roots.end())
+ {
+ me_roots.insert(root);
+ cost += root->getLinksetPhysicsCost();
+ }
+ }
+ }
+ }
+
+ return cost;
+}
+
+F32 LLObjectSelection::getSelectedObjectStreamingCost(S32* total_bytes, S32* visible_bytes)
+{
+ F32 cost = 0.f;
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLViewerObject* object = node->getObject();
+
+ if (object)
+ {
+ S32 bytes = 0;
+ S32 visible = 0;
+ cost += object->getStreamingCost(&bytes, &visible);
+
+ if (total_bytes)
+ {
+ *total_bytes += bytes;
+ }
+
+ if (visible_bytes)
+ {
+ *visible_bytes += visible;
+ }
+ }
+ }
+
+ return cost;
+}
+
+U32 LLObjectSelection::getSelectedObjectTriangleCount()
+{
+ U32 count = 0;
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLViewerObject* object = node->getObject();
+
+ if (object)
+ {
+ count += object->getTriangleCount();
+ }
+ }
+
return count;
}
+/*S32 LLObjectSelection::getSelectedObjectRenderCost()
+{
+ S32 cost = 0;
+ LLVOVolume::texture_cost_t textures;
+ for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
+ {
+ LLSelectNode* node = *iter;
+ LLVOVolume* object = (LLVOVolume*)node->getObject();
+
+ if (object)
+ {
+ cost += object->getRenderCost(textures);
+ }
+
+ for (LLVOVolume::texture_cost_t::iterator iter = textures.begin(); iter != textures.end(); ++iter)
+ {
+ // add the cost of each individual texture in the linkset
+ cost += iter->second;
+ }
+ textures.clear();
+ }
+
+
+ return cost;
+}*/
+
//-----------------------------------------------------------------------------
// getTECount()
@@ -6585,7 +6983,7 @@ bool LLSelectMgr::selectionMove(const LLVector3& displ,
// factor the distance into the displacement vector. This will get us
// equally visible movements for both close and far away selections.
- F32 min_dist = sqrt(fsqrtf(min_dist_squared)) / 2;
+ F32 min_dist = sqrt((F32) sqrtf(min_dist_squared)) / 2;
displ_global.setVec(displ.mV[0] * min_dist,
displ.mV[1] * min_dist,
displ.mV[2] * min_dist);