Index: llprimitive.cpp =================================================================== --- llprimitive.cpp (revision 106) +++ llprimitive.cpp (working copy) @@ -38,6 +38,7 @@ #include "llvolumemgr.h" #include "llstring.h" #include "lldatapacker.h" +#include "llsdutil.h" /** * exported constants @@ -1745,6 +1746,47 @@ 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() @@ -1826,7 +1868,59 @@ //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)) + { + setUserForce( ll_vector3_from_sd(sd[w], 0) ); + } else goto fail; + w = "wind_sensitivity"; + if (sd.has(w)) + { + setWindSensitivity( (F32)sd[w].asReal() ); + } else goto fail; + + return true; +fail: + return false; +} + //============================================================================ LLSculptParams::LLSculptParams() @@ -1877,3 +1971,31 @@ 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; +} Index: llprimitive.h =================================================================== --- llprimitive.h (revision 106) +++ llprimitive.h (working copy) @@ -139,6 +139,10 @@ /*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 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); } @@ -226,6 +230,10 @@ 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 @@ -243,6 +251,10 @@ /*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; } void setSculptType(U8 type) { mSculptType = type; }