Skip to content
Snippets Groups Projects
Commit 31543e63 authored by prep's avatar prep
Browse files

Fixed default character width bug. Updated rendertri api for new path rendering bookends.

parent 1dadfbb8
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ void LLRenderNavPrim::renderTri( const LLVector3& a, const LLVector3& b, const L ...@@ -62,7 +62,7 @@ void LLRenderNavPrim::renderTri( const LLVector3& a, const LLVector3& b, const L
gGL.end(); gGL.end();
} }
//============================================================================= //=============================================================================
void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const void LLRenderNavPrim::renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color ) const
{ {
LLColor4 cV(color); LLColor4 cV(color);
gGL.color4fv( cV.mV ); gGL.color4fv( cV.mV );
......
...@@ -43,8 +43,8 @@ class LLRenderNavPrim ...@@ -43,8 +43,8 @@ class LLRenderNavPrim
void renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const; void renderLLSegment( const LLVector3& start, const LLVector3& end, const LLColor4U& color ) const;
//Draw simple tri //Draw simple tri
void renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const; void renderTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, int color ) const;
//Draw simple tri //Draw simple tri
void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color, const LLVector3& n ) const; void renderLLTri( const LLVector3& a, const LLVector3& b, const LLVector3& c, const LLColor4U& color ) const;
//Draw the contents of vertex buffer //Draw the contents of vertex buffer
void renderNavMeshVB( U32 mode, LLVertexBuffer* pVBO, int vertCnt ); void renderNavMeshVB( U32 mode, LLVertexBuffer* pVBO, int vertCnt );
//Draw a star //Draw a star
......
/** /**
* @file llpathfindingpathtool.cpp * @file llpathfindingpathtool.cpp
* @author William Todd Stinson * @author William Todd Stinson
* @brief XXX * @brief XXX
* *
* $LicenseInfo:firstyear=2002&license=viewerlgpl$ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code * Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc. * Copyright (C) 2010, Linden Research, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; * License as published by the Free Software Foundation;
* version 2.1 of the License only. * version 2.1 of the License only.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "llpathfindingpathtool.h" #include "llpathfindingpathtool.h"
#include "llsingleton.h" #include "llsingleton.h"
#include "lltool.h" #include "lltool.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
#include "llviewercamera.h" #include "llviewercamera.h"
#include "llpathfindingmanager.h" #include "llpathfindingmanager.h"
#include "llpathinglib.h" #include "llpathinglib.h"
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
#define PATH_TOOL_NAME "PathfindingPathTool" #define PATH_TOOL_NAME "PathfindingPathTool"
LLPathfindingPathTool::LLPathfindingPathTool() LLPathfindingPathTool::LLPathfindingPathTool()
: LLTool(PATH_TOOL_NAME), : LLTool(PATH_TOOL_NAME),
LLSingleton<LLPathfindingPathTool>(), LLSingleton<LLPathfindingPathTool>(),
mPathData(), mPathData(),
mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED), mPathResult(LLPathingLib::LLPL_PATH_NOT_GENERATED),
mHasStartPoint(false), mHasStartPoint(false),
mHasEndPoint(false), mHasEndPoint(false),
mCharacterWidth(1.0f), mCharacterWidth(1.0f),
mCharacterType(kCharacterTypeNone), mCharacterType(kCharacterTypeNone),
mPathEventSignal() mPathEventSignal()
{ {
if (!LLPathingLib::getInstance()) if (!LLPathingLib::getInstance())
{ {
LLPathingLib::initSystem(); LLPathingLib::initSystem();
} }
}
mPathData.mCharacterWidth = mCharacterWidth;
LLPathfindingPathTool::~LLPathfindingPathTool() }
{
} LLPathfindingPathTool::~LLPathfindingPathTool()
{
BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask) }
{
if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask)
{ {
LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY); if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0)
LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin(); {
LLVector3 rayStart = mousePos; LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY);
LLVector3 rayEnd = mousePos + dv * 150; LLVector3 mousePos = LLViewerCamera::getInstance()->getOrigin();
LLVector3 rayStart = mousePos;
if (pMask & MASK_CONTROL) LLVector3 rayEnd = mousePos + dv * 150;
{
mPathData.mStartPointA = rayStart; if (pMask & MASK_CONTROL)
mPathData.mEndPointA = rayEnd; {
mHasStartPoint = true; mPathData.mStartPointA = rayStart;
} mPathData.mEndPointA = rayEnd;
else if (pMask & MASK_SHIFT) mHasStartPoint = true;
{ }
mPathData.mStartPointB = rayStart; else if (pMask & MASK_SHIFT)
mPathData.mEndPointB = rayEnd; {
mHasEndPoint = true; mPathData.mStartPointB = rayStart;
} mPathData.mEndPointB = rayEnd;
computePath(); mHasEndPoint = true;
} }
computePath();
return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); }
}
return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0);
BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask) }
{
if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0) BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask)
{ {
gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING); if ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0)
} {
gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING);
return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0); }
}
return ((pMask & (MASK_CONTROL|MASK_SHIFT)) != 0);
LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const }
{
EPathStatus status = kPathStatusUnknown; LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const
{
if (LLPathingLib::getInstance() == NULL) EPathStatus status = kPathStatusUnknown;
{
status = kPathStatusNotImplemented; if (LLPathingLib::getInstance() == NULL)
} {
else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion()) status = kPathStatusNotImplemented;
{ }
status = kPathStatusNotEnabled; else if (!LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion())
} {
else if (!mHasStartPoint && !mHasEndPoint) status = kPathStatusNotEnabled;
{ }
status = kPathStatusChooseStartAndEndPoints; else if (!mHasStartPoint && !mHasEndPoint)
} {
else if (!mHasStartPoint) status = kPathStatusChooseStartAndEndPoints;
{ }
status = kPathStatusChooseStartPoint; else if (!mHasStartPoint)
} {
else if (!mHasEndPoint) status = kPathStatusChooseStartPoint;
{ }
status = kPathStatusChooseEndPoint; else if (!mHasEndPoint)
} {
else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK) status = kPathStatusChooseEndPoint;
{ }
status = kPathStatusHasValidPath; else if (mPathResult == LLPathingLib::LLPL_PATH_GENERATED_OK)
} {
else if (mPathResult == LLPathingLib::LLPL_NO_PATH) status = kPathStatusHasValidPath;
{ }
status = kPathStatusHasInvalidPath; else if (mPathResult == LLPathingLib::LLPL_NO_PATH)
} {
else status = kPathStatusHasInvalidPath;
{ }
status = kPathStatusError; else
} {
status = kPathStatusError;
return status; }
}
return status;
F32 LLPathfindingPathTool::getCharacterWidth() const }
{
return mCharacterWidth; F32 LLPathfindingPathTool::getCharacterWidth() const
} {
return mCharacterWidth;
void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth) }
{
mCharacterWidth = pCharacterWidth; void LLPathfindingPathTool::setCharacterWidth(F32 pCharacterWidth)
mPathData.mCharacterWidth = pCharacterWidth; {
computePath(); mCharacterWidth = pCharacterWidth;
} mPathData.mCharacterWidth = pCharacterWidth;
computePath();
LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const }
{
return mCharacterType; LLPathfindingPathTool::ECharacterType LLPathfindingPathTool::getCharacterType() const
} {
return mCharacterType;
void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType) }
{
mCharacterType = pCharacterType; void LLPathfindingPathTool::setCharacterType(ECharacterType pCharacterType)
switch (pCharacterType) {
{ mCharacterType = pCharacterType;
case kCharacterTypeNone : switch (pCharacterType)
mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; {
break; case kCharacterTypeNone :
case kCharacterTypeA : mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE;
mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_A; break;
break; case kCharacterTypeA :
case kCharacterTypeB : mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_A;
mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_B; break;
break; case kCharacterTypeB :
case kCharacterTypeC : mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_B;
mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_C; break;
break; case kCharacterTypeC :
case kCharacterTypeD : mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_C;
mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_D; break;
break; case kCharacterTypeD :
default : mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_D;
mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE; break;
llassert(0); default :
break; mPathData.mCharacterType = LLPathingLib::LLPL_CHARACTER_TYPE_NONE;
} llassert(0);
computePath(); break;
} }
computePath();
bool LLPathfindingPathTool::isRenderPath() const }
{
return (mHasStartPoint && mHasEndPoint); bool LLPathfindingPathTool::isRenderPath() const
} {
return (mHasStartPoint && mHasEndPoint);
void LLPathfindingPathTool::clearPath() }
{
mHasStartPoint = false; void LLPathfindingPathTool::clearPath()
mHasEndPoint = false; {
computePath(); mHasStartPoint = false;
} mHasEndPoint = false;
computePath();
LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback) }
{
return mPathEventSignal.connect(pPathEventCallback); LLPathfindingPathTool::path_event_slot_t LLPathfindingPathTool::registerPathEventListener(path_event_callback_t pPathEventCallback)
} {
return mPathEventSignal.connect(pPathEventCallback);
void LLPathfindingPathTool::computePath() }
{
mPathResult = LLPathingLib::getInstance()->generatePath(mPathData); void LLPathfindingPathTool::computePath()
mPathEventSignal(); {
} mPathResult = LLPathingLib::getInstance()->generatePath(mPathData);
mPathEventSignal();
}
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