Fix measurement tool

This commit is contained in:
Siana Gearz
2012-07-23 14:18:45 +02:00
parent 1ad4597d7a
commit 89be317a00
3 changed files with 27 additions and 40 deletions

View File

@@ -2683,44 +2683,37 @@ class LLObjectMeasure : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
if(object)
static LLVector3 startMeasurePoint = LLVector3::zero;
static bool startpoint_set = false;
LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
if(!object)
return false;
LLVector3 position = object->getPositionEdit();
LLChat chat;
chat.mSourceType = CHAT_SOURCE_SYSTEM;
if (!startpoint_set)
{
LLChat chat;
chat.mSourceType = CHAT_SOURCE_SYSTEM;
if (LLAgent::exlStartMeasurePoint.isExactlyZero())
{
LLAgent::exlStartMeasurePoint = object->getPosition();
startMeasurePoint = position;
startpoint_set = true;
chat.mText = llformat("Start point set");
LLFloaterChat::addChat(chat);
}
else if (LLAgent::exlEndMeasurePoint.isExactlyZero())
{
LLAgent::exlEndMeasurePoint = object->getPosition();
chat.mText = llformat("End point set");
LLFloaterChat::addChat(chat);
}
else
{
LLAgent::exlStartMeasurePoint = LLVector3::zero;
LLAgent::exlEndMeasurePoint = LLVector3::zero;
return false;
}
if (!LLAgent::exlStartMeasurePoint.isExactlyZero() && !LLAgent::exlEndMeasurePoint.isExactlyZero())
{
F32 fdist = dist_vec(LLAgent::exlStartMeasurePoint, LLAgent::exlEndMeasurePoint);
LLAgent::exlStartMeasurePoint = LLVector3::zero;
LLAgent::exlEndMeasurePoint = LLVector3::zero;
chat.mText = llformat("Distance: %fm", fdist);
LLFloaterChat::addChat(chat);
}
chat.mText = llformat("Start point set");
LLFloaterChat::addChat(chat);
}
else
{
chat.mText = llformat("End point set");
LLFloaterChat::addChat(chat);
F32 fdist = dist_vec(startMeasurePoint, position);
chat.mText = llformat("Distance: %fm", fdist);
LLFloaterChat::addChat(chat);
startpoint_set = false;
}
return true;
}
};