summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2007-12-05 23:43:56 +0000
committerDon Kjer <don@lindenlab.com>2007-12-05 23:43:56 +0000
commitfacf67ae3226105910c983a8fa8760414bf703e9 (patch)
treeb5f7cd6b79a79f769080a65b6fe2cb6b97c8b6fb /indra/llprimitive
parent45057e8881c3166c7c0ef545c02bc177922af6fb (diff)
EFFECTIVE MERGE: svn merge -r 71520:73420 svn+ssh://svn/svn/linden/branches/maintenance-3 into release
ACTUAL MERGE: svn merge -r 75074:75114 svn+ssh://svn/svn/linden/qa/maintenance-3-merge-75067 into release
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/llprimitive.cpp126
-rw-r--r--indra/llprimitive/llprimitive.h12
2 files changed, 138 insertions, 0 deletions
diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp
index b41879380f..77bca8f803 100644
--- a/indra/llprimitive/llprimitive.cpp
+++ b/indra/llprimitive/llprimitive.cpp
@@ -41,6 +41,7 @@
#include "llvolumemgr.h"
#include "llstring.h"
#include "lldatapacker.h"
+#include "llsdutil.h"
/**
* exported constants
@@ -1795,6 +1796,47 @@ void LLLightParams::copy(const LLNetworkData& data)
mFalloff = param->mFalloff;
}
+LLSD LLLightParams::asLLSD() const
+{
+ LLSD sd;
+
+ sd["color"] = ll_sd_from_color4(getColor());
+ sd["radius"] = getRadius();
+ sd["falloff"] = getFalloff();
+ sd["cutoff"] = getCutoff();
+
+ return sd;
+}
+
+bool LLLightParams::fromLLSD(LLSD& sd)
+{
+ const char *w;
+ w = "color";
+ if (sd.has(w))
+ {
+ setColor( ll_color4_from_sd(sd["color"]) );
+ } else goto fail;
+ w = "radius";
+ if (sd.has(w))
+ {
+ setRadius( (F32)sd[w].asReal() );
+ } else goto fail;
+ w = "falloff";
+ if (sd.has(w))
+ {
+ setFalloff( (F32)sd[w].asReal() );
+ } else goto fail;
+ w = "cutoff";
+ if (sd.has(w))
+ {
+ setCutoff( (F32)sd[w].asReal() );
+ } else goto fail;
+
+ return true;
+ fail:
+ return false;
+}
+
//============================================================================
LLFlexibleObjectData::LLFlexibleObjectData()
@@ -1876,6 +1918,59 @@ void LLFlexibleObjectData::copy(const LLNetworkData& data)
//mRenderingCollisionSphere = flex_data->mRenderingCollisionSphere;
}
+LLSD LLFlexibleObjectData::asLLSD() const
+{
+ LLSD sd;
+
+ sd["air_friction"] = getAirFriction();
+ sd["gravity"] = getGravity();
+ sd["simulate_lod"] = getSimulateLOD();
+ sd["tension"] = getTension();
+ sd["user_force"] = getUserForce().getValue();
+ sd["wind_sensitivity"] = getWindSensitivity();
+
+ return sd;
+}
+
+bool LLFlexibleObjectData::fromLLSD(LLSD& sd)
+{
+ const char *w;
+ w = "air_friction";
+ if (sd.has(w))
+ {
+ setAirFriction( (F32)sd[w].asReal() );
+ } else goto fail;
+ w = "gravity";
+ if (sd.has(w))
+ {
+ setGravity( (F32)sd[w].asReal() );
+ } else goto fail;
+ w = "simulate_lod";
+ if (sd.has(w))
+ {
+ setSimulateLOD( sd[w].asInteger() );
+ } else goto fail;
+ w = "tension";
+ if (sd.has(w))
+ {
+ setTension( (F32)sd[w].asReal() );
+ } else goto fail;
+ w = "user_force";
+ if (sd.has(w))
+ {
+ LLVector3 user_force = ll_vector3_from_sd(sd[w], 0);
+ setUserForce( user_force );
+ } else goto fail;
+ w = "wind_sensitivity";
+ if (sd.has(w))
+ {
+ setWindSensitivity( (F32)sd[w].asReal() );
+ } else goto fail;
+
+ return true;
+ fail:
+ return false;
+}
//============================================================================
@@ -1927,3 +2022,34 @@ void LLSculptParams::copy(const LLNetworkData& data)
mSculptType = param->mSculptType;
}
+
+
+LLSD LLSculptParams::asLLSD() const
+{
+ LLSD sd;
+
+ sd["texture"] = mSculptTexture;
+ sd["type"] = mSculptType;
+
+ return sd;
+}
+
+bool LLSculptParams::fromLLSD(LLSD& sd)
+{
+ const char *w;
+ w = "texture";
+ if (sd.has(w))
+ {
+ setSculptTexture( sd[w] );
+ } else goto fail;
+ w = "type";
+ if (sd.has(w))
+ {
+ setSculptType( (U8)sd[w].asInteger() );
+ } else goto fail;
+
+ return true;
+ fail:
+ return false;
+}
+
diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h
index 53b17bc2ef..eef58341e7 100644
--- a/indra/llprimitive/llprimitive.h
+++ b/indra/llprimitive/llprimitive.h
@@ -141,7 +141,13 @@ public:
/*virtual*/ BOOL unpack(LLDataPacker &dp);
/*virtual*/ bool operator==(const LLNetworkData& data) const;
/*virtual*/ void copy(const LLNetworkData& data);
+ // LLSD implementations here are provided by Eddy Stryker.
+ // NOTE: there are currently unused in protocols
+ LLSD asLLSD() const;
+ operator LLSD() const { return asLLSD(); }
+ bool fromLLSD(LLSD& sd);
+
void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); }
void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); }
void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); }
@@ -229,6 +235,9 @@ public:
BOOL unpack(LLDataPacker &dp);
bool operator==(const LLNetworkData& data) const;
void copy(const LLNetworkData& data);
+ LLSD asLLSD() const;
+ operator LLSD() const { return asLLSD(); }
+ bool fromLLSD(LLSD& sd);
};// end of attributes structure
@@ -245,6 +254,9 @@ public:
/*virtual*/ BOOL unpack(LLDataPacker &dp);
/*virtual*/ bool operator==(const LLNetworkData& data) const;
/*virtual*/ void copy(const LLNetworkData& data);
+ LLSD asLLSD() const;
+ operator LLSD() const { return asLLSD(); }
+ bool fromLLSD(LLSD& sd);
void setSculptTexture(const LLUUID& id) { mSculptTexture = id; }
LLUUID getSculptTexture() { return mSculptTexture; }