summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloaterpathfindinglinksets.cpp204
-rw-r--r--indra/newview/llfloaterpathfindinglinksets.h12
2 files changed, 167 insertions, 49 deletions
diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp
index 9d8f99902b..e8f1401095 100644
--- a/indra/newview/llfloaterpathfindinglinksets.cpp
+++ b/indra/newview/llfloaterpathfindinglinksets.cpp
@@ -94,6 +94,9 @@ private:
// PathfindingLinkset
//---------------------------------------------------------------------------
+const S32 PathfindingLinkset::MIN_WALKABILITY_VALUE(0);
+const S32 PathfindingLinkset::MAX_WALKABILITY_VALUE(100);
+
PathfindingLinkset::PathfindingLinkset(const std::string &pUUID, const LLSD& pNavMeshItem)
: mUUID(pUUID),
mName(),
@@ -102,10 +105,13 @@ PathfindingLinkset::PathfindingLinkset(const std::string &pUUID, const LLSD& pNa
mLocation(),
mPathState(kIgnored),
mIsPhantom(false),
- mA(0),
- mB(0),
- mC(0),
- mD(0)
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32(false),
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mA(MIN_WALKABILITY_VALUE),
+ mB(MIN_WALKABILITY_VALUE),
+ mC(MIN_WALKABILITY_VALUE),
+ mD(MIN_WALKABILITY_VALUE)
{
llassert(pNavMeshItem.has("name"));
llassert(pNavMeshItem.get("name").isString());
@@ -135,20 +141,75 @@ PathfindingLinkset::PathfindingLinkset(const std::string &pUUID, const LLSD& pNa
mIsPhantom = pNavMeshItem.get("phantom").asBoolean();
llassert(pNavMeshItem.has("A"));
- llassert(pNavMeshItem.get("A").isReal());
- mA = llround(pNavMeshItem.get("A").asReal() * 100.0f);
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32 = pNavMeshItem.get("A").isReal();
+ if (mIsWalkabilityCoefficientsF32)
+ {
+ // Old server-side storage was real
+ mA = llround(pNavMeshItem.get("A").asReal() * 100.0f);
+
+ llassert(pNavMeshItem.has("B"));
+ llassert(pNavMeshItem.get("B").isReal());
+ mB = llround(pNavMeshItem.get("B").asReal() * 100.0f);
+
+ llassert(pNavMeshItem.has("C"));
+ llassert(pNavMeshItem.get("C").isReal());
+ mC = llround(pNavMeshItem.get("C").asReal() * 100.0f);
+
+ llassert(pNavMeshItem.has("D"));
+ llassert(pNavMeshItem.get("D").isReal());
+ mD = llround(pNavMeshItem.get("D").asReal() * 100.0f);
+ }
+ else
+ {
+ // New server-side storage will be integer
+ llassert(pNavMeshItem.get("A").isInteger());
+ mA = pNavMeshItem.get("A").asInteger();
+ llassert(mA >= MIN_WALKABILITY_VALUE);
+ llassert(mA <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("B"));
+ llassert(pNavMeshItem.get("B").isInteger());
+ mB = pNavMeshItem.get("B").asInteger();
+ llassert(mB >= MIN_WALKABILITY_VALUE);
+ llassert(mB <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("C"));
+ llassert(pNavMeshItem.get("C").isInteger());
+ mC = pNavMeshItem.get("C").asInteger();
+ llassert(mC >= MIN_WALKABILITY_VALUE);
+ llassert(mC <= MAX_WALKABILITY_VALUE);
+
+ llassert(pNavMeshItem.has("D"));
+ llassert(pNavMeshItem.get("D").isInteger());
+ mD = pNavMeshItem.get("D").asInteger();
+ llassert(mD >= MIN_WALKABILITY_VALUE);
+ llassert(mD <= MAX_WALKABILITY_VALUE);
+ }
+#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ llassert(pNavMeshItem.get("A").isInteger());
+ mA = pNavMeshItem.get("A").asInteger();
+ llassert(mA >= MIN_WALKABILITY_VALUE);
+ llassert(mA <= MAX_WALKABILITY_VALUE);
llassert(pNavMeshItem.has("B"));
- llassert(pNavMeshItem.get("B").isReal());
- mB = llround(pNavMeshItem.get("B").asReal() * 100.0f);
+ llassert(pNavMeshItem.get("B").isInteger());
+ mB = pNavMeshItem.get("B").asInteger();
+ llassert(mB >= MIN_WALKABILITY_VALUE);
+ llassert(mB <= MAX_WALKABILITY_VALUE);
llassert(pNavMeshItem.has("C"));
- llassert(pNavMeshItem.get("C").isReal());
- mC = llround(pNavMeshItem.get("C").asReal() * 100.0f);
+ llassert(pNavMeshItem.get("C").isInteger());
+ mC = pNavMeshItem.get("C").asInteger();
+ llassert(mC >= MIN_WALKABILITY_VALUE);
+ llassert(mC <= MAX_WALKABILITY_VALUE);
llassert(pNavMeshItem.has("D"));
- llassert(pNavMeshItem.get("D").isReal());
- mD = llround(pNavMeshItem.get("D").asReal() * 100.0f);
+ llassert(pNavMeshItem.get("D").isInteger());
+ mD = pNavMeshItem.get("D").asInteger();
+ llassert(mD >= MIN_WALKABILITY_VALUE);
+ llassert(mD <= MAX_WALKABILITY_VALUE);
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
llassert(pNavMeshItem.has("position"));
llassert(pNavMeshItem.get("position").isArray());
@@ -163,6 +224,9 @@ PathfindingLinkset::PathfindingLinkset(const PathfindingLinkset& pOther)
mLocation(pOther.mLocation),
mPathState(pOther.mPathState),
mIsPhantom(pOther.mIsPhantom),
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32(pOther.mIsWalkabilityCoefficientsF32),
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
mA(pOther.mA),
mB(pOther.mB),
mC(pOther.mC),
@@ -183,6 +247,9 @@ PathfindingLinkset& PathfindingLinkset::operator =(const PathfindingLinkset& pOt
mLocation = pOther.mLocation;
mPathState = pOther.mPathState;
mIsPhantom = pOther.mIsPhantom;
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ mIsWalkabilityCoefficientsF32 = pOther.mIsWalkabilityCoefficientsF32;
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
mA = pOther.mA;
mB = pOther.mB;
mC = pOther.mC;
@@ -325,6 +392,80 @@ void PathfindingLinkset::setD(S32 pD)
mD = pD;
}
+LLSD PathfindingLinkset::getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const
+{
+ LLSD itemData;
+
+ if (mPathState != pPathState)
+ {
+ itemData["permanent"] = static_cast<bool>(PathfindingLinkset::isPermanent(pPathState));
+ itemData["walkable"] = static_cast<bool>(PathfindingLinkset::isWalkable(pPathState));
+ }
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ if (mIsWalkabilityCoefficientsF32)
+ {
+ if (mA != pA)
+ {
+ itemData["A"] = llclamp(static_cast<F32>(pA) / 100.0f, 0.0f, 1.0f);
+ }
+ if (mB != pB)
+ {
+ itemData["B"] = llclamp(static_cast<F32>(pB) / 100.0f, 0.0f, 1.0f);
+ }
+ if (mC != pC)
+ {
+ itemData["C"] = llclamp(static_cast<F32>(pC) / 100.0f, 0.0f, 1.0f);
+ }
+ if (mD != pD)
+ {
+ itemData["D"] = llclamp(static_cast<F32>(pD) / 100.0f, 0.0f, 1.0f);
+ }
+ }
+ else
+ {
+ if (mA != pA)
+ {
+ itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mB != pB)
+ {
+ itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mC != pC)
+ {
+ itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mD != pD)
+ {
+ itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ }
+#else // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ if (mA != pA)
+ {
+ itemData["A"] = llclamp(pA, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mB != pB)
+ {
+ itemData["B"] = llclamp(pB, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mC != pC)
+ {
+ itemData["C"] = llclamp(pC, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+ if (mD != pD)
+ {
+ itemData["D"] = llclamp(pD, MIN_WALKABILITY_VALUE, MAX_WALKABILITY_VALUE);
+ }
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ if (mIsPhantom != pIsPhantom)
+ {
+ itemData["phantom"] = static_cast<bool>(pIsPhantom);
+ }
+
+ return itemData;
+}
+
//---------------------------------------------------------------------------
// FilterString
//---------------------------------------------------------------------------
@@ -1160,8 +1301,6 @@ void LLFloaterPathfindingLinksets::applyEditFields()
if (!selectedItems.empty())
{
PathfindingLinkset::EPathState pathState = getPathState();
- BOOL isPermanentBool = PathfindingLinkset::isPermanent(pathState);
- BOOL isWalkableBool = PathfindingLinkset::isWalkable(pathState);
const std::string &aString = mEditA->getText();
const std::string &bString = mEditB->getText();
const std::string &cString = mEditC->getText();
@@ -1170,15 +1309,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
S32 bValue = static_cast<S32>(atoi(bString.c_str()));
S32 cValue = static_cast<S32>(atoi(cString.c_str()));
S32 dValue = static_cast<S32>(atoi(dString.c_str()));
- BOOL isPhantomBool = mEditPhantom->getValue();
-
- LLSD isPermanent = (bool)isPermanentBool;
- LLSD isWalkable = (bool)isWalkableBool;
- LLSD a = static_cast<F32>(aValue) / 100.0f;
- LLSD b = static_cast<F32>(bValue) / 100.0f;
- LLSD c = static_cast<F32>(cValue) / 100.0f;
- LLSD d = static_cast<F32>(dValue) / 100.0f;
- LLSD isPhantom = (bool)isPhantomBool;
+ BOOL isPhantom = mEditPhantom->getValue();
const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
@@ -1192,32 +1323,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
const PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
const PathfindingLinkset &linkset = linksetIter->second;
- LLSD itemData;
- if (linkset.getPathState() != pathState)
- {
- itemData["permanent"] = isPermanent;
- itemData["walkable"] = isWalkable;
- }
- if (linkset.getA() != aValue)
- {
- itemData["A"] = a;
- }
- if (linkset.getB() != bValue)
- {
- itemData["B"] = b;
- }
- if (linkset.getC() != cValue)
- {
- itemData["C"] = c;
- }
- if (linkset.getD() != dValue)
- {
- itemData["D"] = d;
- }
- if (linkset.isPhantom() != isPhantomBool)
- {
- itemData["phantom"] = isPhantom;
- }
+ LLSD itemData = linkset.getAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom);
if (!itemData.isUndefined())
{
diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h
index 11750a2ca0..976eaa355f 100644
--- a/indra/newview/llfloaterpathfindinglinksets.h
+++ b/indra/newview/llfloaterpathfindinglinksets.h
@@ -33,6 +33,10 @@
#include "llfloater.h"
#include "lluuid.h"
+// This is a reminder to remove the code regarding the changing of the data type for the
+// walkability coefficients from F32 to S32 representing the percentage from 0-100.
+#define XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+
class LLTextBase;
class LLScrollListCtrl;
class LLLineEditor;
@@ -83,9 +87,14 @@ public:
S32 getD() const;
void setD(S32 pD);
+ LLSD getAlteredFields(EPathState pPathState, S32 pA, S32 pB, S32 pC, S32 pD, BOOL pIsPhantom) const;
+
protected:
private:
+ static const S32 MIN_WALKABILITY_VALUE;
+ static const S32 MAX_WALKABILITY_VALUE;
+
LLUUID mUUID;
std::string mName;
std::string mDescription;
@@ -93,6 +102,9 @@ private:
LLVector3 mLocation;
EPathState mPathState;
BOOL mIsPhantom;
+#ifdef XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
+ BOOL mIsWalkabilityCoefficientsF32;
+#endif // XXX_STINSON_WALKABILITY_COEFFICIENTS_TYPE_CHANGE
S32 mA;
S32 mB;
S32 mC;