refactoring of PrimitiveBaseShape to properties

0.6.0-stable
Sean Dague 2008-07-16 14:41:57 +00:00
parent e2d02cbf65
commit 1e447478b8
2 changed files with 144 additions and 540 deletions

View File

@ -74,10 +74,11 @@
<column name="SitTargetOrientZ" />
<column name="SitTargetOrientW" />
</property>
<class name="PrimShape" type="OpenSim.Framework.PrimitiveBaseShape, OpenSim.Framework">
<property name="
</class>
</class>
<class name="OpenSim.Framework.PrimitiveBaseShape, OpenSim.Framework" table="PrimShapes" lazy="false">
<id name="UUID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
<generator class="assigned" />
</id>
</class>
</hibernate-mapping>

View File

@ -78,57 +78,23 @@ namespace OpenSim.Framework
private byte[] m_textureEntry;
public ushort _pathBegin;
public byte _pathCurve;
public ushort _pathEnd;
public sbyte _pathRadiusOffset;
public byte _pathRevolutions;
public byte _pathScaleX;
public byte _pathScaleY;
public byte _pathShearX;
public byte _pathShearY;
public sbyte _pathSkew;
public sbyte _pathTaperX;
public sbyte _pathTaperY;
public sbyte _pathTwist;
public sbyte _pathTwistBegin;
public byte _pCode;
public ushort _profileBegin;
public ushort _profileEnd;
public ushort _profileHollow;
public LLVector3 _scale;
public byte _state;
public ProfileShape _profileShape;
public HollowShape _hollowShape;
public ushort PathBegin;
public byte PathCurve;
public ushort PathEnd;
public sbyte PathRadiusOffset;
public byte PathRevolutions;
public byte PathScaleX;
public byte PathScaleY;
public byte PathShearX;
public byte PathShearY;
public sbyte PathSkew;
public sbyte PathTaperX;
public sbyte PathTaperY;
public sbyte PathTwist;
public sbyte PathTwistBegin;
public byte PCode;
public ushort ProfileBegin;
// Sculpted
[XmlIgnore] public LLUUID _sculptTexture = LLUUID.Zero;
[XmlIgnore] public byte _sculptType = (byte)0;
[XmlIgnore] public byte[] _sculptData = new byte[0];
// Flexi
[XmlIgnore] public int _flexiSoftness = 0;
[XmlIgnore] public float _flexiTension = 0f;
[XmlIgnore] public float _flexiDrag = 0f;
[XmlIgnore] public float _flexiGravity = 0f;
[XmlIgnore] public float _flexiWind = 0f;
[XmlIgnore] public float _flexiForceX = 0f;
[XmlIgnore] public float _flexiForceY = 0f;
[XmlIgnore] public float _flexiForceZ = 0f;
//Bright n sparkly
[XmlIgnore] public float _lightColorR = 0f;
[XmlIgnore] public float _lightColorG = 0f;
[XmlIgnore] public float _lightColorB = 0f;
[XmlIgnore] public float _lightColorA = 1f;
[XmlIgnore] public float _lightRadius = 0f;
[XmlIgnore] public float _lightCutoff = 0f;
[XmlIgnore] public float _lightFalloff = 0f;
[XmlIgnore] public float _lightIntensity = 1f;
[XmlIgnore] public bool _flexiEntry = false;
[XmlIgnore] public bool _lightEntry = false;
[XmlIgnore] public bool _sculptEntry = false;
public byte ProfileCurve
{
get { return (byte)((byte)HollowShape | (byte)ProfileShape); }
@ -144,11 +110,11 @@ namespace OpenSim.Framework
"[SHAPE]: Attempt to set a ProfileCurve with a hollow shape value of {0}, which isn't a valid enum. Replacing with default shape.",
hollowShapeByte);
this._hollowShape = HollowShape.Same;
this.HollowShape = HollowShape.Same;
}
else
{
this._hollowShape = (HollowShape)hollowShapeByte;
this.HollowShape = (HollowShape)hollowShapeByte;
}
// Handle profile shape component
@ -160,16 +126,47 @@ namespace OpenSim.Framework
"[SHAPE]: Attempt to set a ProfileCurve with a profile shape value of {0}, which isn't a valid enum. Replacing with square.",
profileShapeByte);
this._profileShape = ProfileShape.Square;
this.ProfileShape = ProfileShape.Square;
}
else
{
this._profileShape = (ProfileShape)profileShapeByte;
this.ProfileShape = (ProfileShape)profileShapeByte;
}
}
}
public ushort ProfileEnd;
public ushort ProfileHollow;
public LLVector3 Scale;
public byte State;
// Sculpted
[XmlIgnore] public LLUUID SculptTexture = LLUUID.Zero;
[XmlIgnore] public byte SculptType = (byte)0;
[XmlIgnore] public byte[] SculptData = new byte[0];
// Flexi
[XmlIgnore] public int FlexiSoftness = 0;
[XmlIgnore] public float FlexiTension = 0f;
[XmlIgnore] public float FlexiDrag = 0f;
[XmlIgnore] public float FlexiGravity = 0f;
[XmlIgnore] public float FlexiWind = 0f;
[XmlIgnore] public float FlexiForceX = 0f;
[XmlIgnore] public float FlexiForceY = 0f;
[XmlIgnore] public float FlexiForceZ = 0f;
//Bright n sparkly
[XmlIgnore] public float LightColorR = 0f;
[XmlIgnore] public float LightColorG = 0f;
[XmlIgnore] public float LightColorB = 0f;
[XmlIgnore] public float LightColorA = 1f;
[XmlIgnore] public float LightRadius = 0f;
[XmlIgnore] public float LightCutoff = 0f;
[XmlIgnore] public float LightFalloff = 0f;
[XmlIgnore] public float LightIntensity = 1f;
[XmlIgnore] public bool FlexiEntry = false;
[XmlIgnore] public bool LightEntry = false;
[XmlIgnore] public bool SculptEntry = false;
static PrimitiveBaseShape()
@ -200,7 +197,9 @@ namespace OpenSim.Framework
set { m_textureEntry = value; }
}
public ProfileShape ProfileShape;
public HollowShape HollowShape;
public static PrimitiveBaseShape Default
{
@ -224,10 +223,10 @@ namespace OpenSim.Framework
{
PrimitiveBaseShape shape = Create();
shape._pathCurve = (byte) Extrusion.Straight;
shape._profileShape = ProfileShape.Square;
shape._pathScaleX = 100;
shape._pathScaleY = 100;
shape.PathCurve = (byte) Extrusion.Straight;
shape.ProfileShape = ProfileShape.Square;
shape.PathScaleX = 100;
shape.PathScaleY = 100;
return shape;
}
@ -236,28 +235,28 @@ namespace OpenSim.Framework
{
PrimitiveBaseShape shape = Create();
shape._pathCurve = (byte) Extrusion.Curve1;
shape._profileShape = ProfileShape.Square;
shape.PathCurve = (byte) Extrusion.Curve1;
shape.ProfileShape = ProfileShape.Square;
shape._pathScaleX = 100;
shape._pathScaleY = 100;
shape.PathScaleX = 100;
shape.PathScaleY = 100;
return shape;
}
public void SetScale(float side)
{
_scale = new LLVector3(side, side, side);
Scale = new LLVector3(side, side, side);
}
public void SetHeigth(float heigth)
{
_scale.Z = heigth;
Scale.Z = heigth;
}
public void SetRadius(float radius)
{
_scale.X = _scale.Y = radius * 2f;
Scale.X = Scale.Y = radius * 2f;
}
// TODO: void returns need to change of course
@ -282,20 +281,20 @@ namespace OpenSim.Framework
public void SetPathRange(LLVector3 pathRange)
{
_pathBegin = LLObject.PackBeginCut(pathRange.X);
_pathEnd = LLObject.PackEndCut(pathRange.Y);
PathBegin = LLObject.PackBeginCut(pathRange.X);
PathEnd = LLObject.PackEndCut(pathRange.Y);
}
public void SetSculptData(byte sculptType, LLUUID SculptTextureUUID)
{
_sculptType = sculptType;
_sculptTexture = SculptTextureUUID;
SculptType = sculptType;
SculptTexture = SculptTextureUUID;
}
public void SetProfileRange(LLVector3 profileRange)
{
_profileBegin = LLObject.PackBeginCut(profileRange.X);
_profileEnd = LLObject.PackEndCut(profileRange.Y);
ProfileBegin = LLObject.PackBeginCut(profileRange.X);
ProfileEnd = LLObject.PackEndCut(profileRange.Y);
}
public byte[] ExtraParams
@ -310,402 +309,6 @@ namespace OpenSim.Framework
}
}
public ushort PathBegin {
get {
return _pathBegin;
}
set {
_pathBegin = value;
}
}
public byte PathCurve {
get {
return _pathCurve;
}
set {
_pathCurve = value;
}
}
public ushort PathEnd {
get {
return _pathEnd;
}
set {
_pathEnd = value;
}
}
public sbyte PathRadiusOffset {
get {
return _pathRadiusOffset;
}
set {
_pathRadiusOffset = value;
}
}
public byte PathRevolutions {
get {
return _pathRevolutions;
}
set {
_pathRevolutions = value;
}
}
public byte PathScaleX {
get {
return _pathScaleX;
}
set {
_pathScaleX = value;
}
}
public byte PathScaleY {
get {
return _pathScaleY;
}
set {
_pathScaleY = value;
}
}
public byte PathShearX {
get {
return _pathShearX;
}
set {
_pathShearX = value;
}
}
public byte PathShearY {
get {
return _pathShearY;
}
set {
_pathShearY = value;
}
}
public sbyte PathSkew {
get {
return _pathSkew;
}
set {
_pathSkew = value;
}
}
public sbyte PathTaperX {
get {
return _pathTaperX;
}
set {
_pathTaperX = value;
}
}
public sbyte PathTaperY {
get {
return _pathTaperY;
}
set {
_pathTaperY = value;
}
}
public sbyte PathTwist {
get {
return _pathTwist;
}
set {
_pathTwist = value;
}
}
public sbyte PathTwistBegin {
get {
return _pathTwistBegin;
}
set {
_pathTwistBegin = value;
}
}
public byte PCode {
get {
return _pCode;
}
set {
_pCode = value;
}
}
public ushort ProfileBegin {
get {
return _profileBegin;
}
set {
_profileBegin = value;
}
}
public ushort ProfileEnd {
get {
return _profileEnd;
}
set {
_profileEnd = value;
}
}
public ushort ProfileHollow {
get {
return _profileHollow;
}
set {
_profileHollow = value;
}
}
public LLVector3 Scale {
get {
return _scale;
}
set {
_scale = value;
}
}
public byte State {
get {
return _state;
}
set {
_state = value;
}
}
public ProfileShape ProfileShape {
get {
return _profileShape;
}
set {
_profileShape = value;
}
}
public HollowShape HollowShape {
get {
return _hollowShape;
}
set {
_hollowShape = value;
}
}
public LLUUID SculptTexture {
get {
return _sculptTexture;
}
set {
_sculptTexture = value;
}
}
public byte SculptType {
get {
return _sculptType;
}
set {
_sculptType = value;
}
}
public byte[] SculptData {
get {
return _sculptData;
}
set {
_sculptData = value;
}
}
public int FlexiSoftness {
get {
return _flexiSoftness;
}
set {
_flexiSoftness = value;
}
}
public float FlexiTension {
get {
return _flexiTension;
}
set {
_flexiTension = value;
}
}
public float FlexiDrag {
get {
return _flexiDrag;
}
set {
_flexiDrag = value;
}
}
public float FlexiGravity {
get {
return _flexiGravity;
}
set {
_flexiGravity = value;
}
}
public float FlexiWind {
get {
return _flexiWind;
}
set {
_flexiWind = value;
}
}
public float FlexiForceX {
get {
return _flexiForceX;
}
set {
_flexiForceX = value;
}
}
public float FlexiForceY {
get {
return _flexiForceY;
}
set {
_flexiForceY = value;
}
}
public float FlexiForceZ {
get {
return _flexiForceZ;
}
set {
_flexiForceZ = value;
}
}
public float LightColorR {
get {
return _lightColorR;
}
set {
_lightColorR = value;
}
}
public float LightColorG {
get {
return _lightColorG;
}
set {
_lightColorG = value;
}
}
public float LightColorB {
get {
return _lightColorB;
}
set {
_lightColorB = value;
}
}
public float LightColorA {
get {
return _lightColorA;
}
set {
_lightColorA = value;
}
}
public float LightRadius {
get {
return _lightRadius;
}
set {
_lightRadius = value;
}
}
public float LightCutoff {
get {
return _lightCutoff;
}
set {
_lightCutoff = value;
}
}
public float LightFalloff {
get {
return _lightFalloff;
}
set {
_lightFalloff = value;
}
}
public float LightIntensity {
get {
return _lightIntensity;
}
set {
_lightIntensity = value;
}
}
public bool FlexiEntry {
get {
return _flexiEntry;
}
set {
_flexiEntry = value;
}
}
public bool LightEntry {
get {
return _lightEntry;
}
set {
_lightEntry = value;
}
}
public bool SculptEntry {
get {
return _sculptEntry;
}
set {
_sculptEntry = value;
}
}
public byte[] ExtraParamsToBytes()
{
ushort FlexiEP = 0x10;
@ -716,19 +319,19 @@ namespace OpenSim.Framework
uint TotalBytesLength = 1; // ExtraParamsNum
uint ExtraParamsNum = 0;
if (_flexiEntry)
if (FlexiEntry)
{
ExtraParamsNum++;
TotalBytesLength += 16;// data
TotalBytesLength += 2 + 4; // type
}
if (_lightEntry)
if (LightEntry)
{
ExtraParamsNum++;
TotalBytesLength += 16;// data
TotalBytesLength += 2 + 4; // type
}
if (_sculptEntry)
if (SculptEntry)
{
ExtraParamsNum++;
TotalBytesLength += 17;// data
@ -743,7 +346,7 @@ namespace OpenSim.Framework
// Stick in the number of parameters
returnbytes[i++] = (byte)ExtraParamsNum;
if (_flexiEntry)
if (FlexiEntry)
{
byte[] FlexiData = GetFlexiBytes();
@ -757,7 +360,7 @@ namespace OpenSim.Framework
Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length);
i += FlexiData.Length;
}
if (_lightEntry)
if (LightEntry)
{
byte[] LightData = GetLightBytes();
@ -771,7 +374,7 @@ namespace OpenSim.Framework
Array.Copy(LightData, 0, returnbytes, i, LightData.Length);
i += LightData.Length;
}
if (_sculptEntry)
if (SculptEntry)
{
byte[] SculptData = GetSculptBytes();
@ -786,7 +389,7 @@ namespace OpenSim.Framework
i += SculptData.Length;
}
if (!_flexiEntry && !_lightEntry && !_sculptEntry)
if (!FlexiEntry && !LightEntry && !SculptEntry)
{
byte[] returnbyte = new byte[1];
returnbyte[0] = 0;
@ -810,7 +413,7 @@ namespace OpenSim.Framework
case FlexiEP:
if (!inUse)
{
_flexiEntry = false;
FlexiEntry = false;
return;
}
ReadFlexiData(data, 0);
@ -819,7 +422,7 @@ namespace OpenSim.Framework
case LightEP:
if (!inUse)
{
_lightEntry = false;
LightEntry = false;
return;
}
ReadLightData(data, 0);
@ -828,7 +431,7 @@ namespace OpenSim.Framework
case SculptEP:
if (!inUse)
{
_sculptEntry = false;
SculptEntry = false;
return;
}
ReadSculptData(data, 0);
@ -885,11 +488,11 @@ namespace OpenSim.Framework
}
if (!lGotFlexi)
_flexiEntry = false;
FlexiEntry = false;
if (!lGotLight)
_lightEntry = false;
LightEntry = false;
if (!lGotSculpt)
_sculptEntry = false;
SculptEntry = false;
}
@ -901,7 +504,7 @@ namespace OpenSim.Framework
if (data.Length+pos >= 17)
{
_sculptEntry = true;
SculptEntry = true;
SculptTextureUUID = new byte[16];
SculptTypel = data[16 + pos];
Array.Copy(data, pos, SculptTextureUUID,0, 16);
@ -909,18 +512,18 @@ namespace OpenSim.Framework
}
else
{
_sculptEntry = false;
SculptEntry = false;
SculptUUID = LLUUID.Zero;
SculptTypel = 0x00;
}
if (_sculptEntry)
if (SculptEntry)
{
if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4)
_sculptType = 4;
if (SculptType != (byte)1 && SculptType != (byte)2 && SculptType != (byte)3 && SculptType != (byte)4)
SculptType = 4;
}
_sculptTexture = SculptUUID;
_sculptType = SculptTypel;
SculptTexture = SculptUUID;
SculptType = SculptTypel;
//m_log.Info("[SCULPT]:" + SculptUUID.ToString());
}
@ -928,8 +531,8 @@ namespace OpenSim.Framework
{
byte[] data = new byte[17];
_sculptTexture.GetBytes().CopyTo(data, 0);
data[16] = (byte)_sculptType;
SculptTexture.GetBytes().CopyTo(data, 0);
data[16] = (byte)SculptType;
return data;
}
@ -938,30 +541,30 @@ namespace OpenSim.Framework
{
if (data.Length-pos >= 16)
{
_flexiEntry = true;
_flexiSoftness = ((data[pos] & 0x80) >> 6) | ((data[pos + 1] & 0x80) >> 7);
FlexiEntry = true;
FlexiSoftness = ((data[pos] & 0x80) >> 6) | ((data[pos + 1] & 0x80) >> 7);
_flexiTension = (float)(data[pos++] & 0x7F) / 10.0f;
_flexiDrag = (float)(data[pos++] & 0x7F) / 10.0f;
_flexiGravity = (float)(data[pos++] / 10.0f) - 10.0f;
_flexiWind = (float)data[pos++] / 10.0f;
FlexiTension = (float)(data[pos++] & 0x7F) / 10.0f;
FlexiDrag = (float)(data[pos++] & 0x7F) / 10.0f;
FlexiGravity = (float)(data[pos++] / 10.0f) - 10.0f;
FlexiWind = (float)data[pos++] / 10.0f;
LLVector3 lForce = new LLVector3(data, pos);
_flexiForceX = lForce.X;
_flexiForceY = lForce.Y;
_flexiForceZ = lForce.Z;
FlexiForceX = lForce.X;
FlexiForceY = lForce.Y;
FlexiForceZ = lForce.Z;
}
else
{
_flexiEntry = false;
_flexiSoftness = 0;
FlexiEntry = false;
FlexiSoftness = 0;
_flexiTension = 0.0f;
_flexiDrag = 0.0f;
_flexiGravity = 0.0f;
_flexiWind = 0.0f;
_flexiForceX = 0f;
_flexiForceY = 0f;
_flexiForceZ = 0f;
FlexiTension = 0.0f;
FlexiDrag = 0.0f;
FlexiGravity = 0.0f;
FlexiWind = 0.0f;
FlexiForceX = 0f;
FlexiForceY = 0f;
FlexiForceZ = 0f;
}
}
@ -971,14 +574,14 @@ namespace OpenSim.Framework
int i = 0;
// Softness is packed in the upper bits of tension and drag
data[i] = (byte)((_flexiSoftness & 2) << 6);
data[i + 1] = (byte)((_flexiSoftness & 1) << 7);
data[i] = (byte)((FlexiSoftness & 2) << 6);
data[i + 1] = (byte)((FlexiSoftness & 1) << 7);
data[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F);
data[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F);
data[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f);
data[i++] = (byte)(_flexiWind * 10.01f);
LLVector3 lForce = new LLVector3(_flexiForceX, _flexiForceY, _flexiForceZ);
data[i++] |= (byte)((byte)(FlexiTension * 10.01f) & 0x7F);
data[i++] |= (byte)((byte)(FlexiDrag * 10.01f) & 0x7F);
data[i++] = (byte)((FlexiGravity + 10.0f) * 10.01f);
data[i++] = (byte)(FlexiWind * 10.01f);
LLVector3 lForce = new LLVector3(FlexiForceX, FlexiForceY, FlexiForceZ);
lForce.GetBytes().CopyTo(data, i);
return data;
@ -988,29 +591,29 @@ namespace OpenSim.Framework
{
if (data.Length - pos >= 16)
{
_lightEntry = true;
LightEntry = true;
LLColor lColor = new LLColor(data, pos, false);
_lightIntensity = lColor.A;
_lightColorA = 1f;
_lightColorR = lColor.R;
_lightColorG = lColor.G;
_lightColorB = lColor.B;
LightIntensity = lColor.A;
LightColorA = 1f;
LightColorR = lColor.R;
LightColorG = lColor.G;
LightColorB = lColor.B;
_lightRadius = Helpers.BytesToFloat(data, pos + 4);
_lightCutoff = Helpers.BytesToFloat(data, pos + 8);
_lightFalloff = Helpers.BytesToFloat(data, pos + 12);
LightRadius = Helpers.BytesToFloat(data, pos + 4);
LightCutoff = Helpers.BytesToFloat(data, pos + 8);
LightFalloff = Helpers.BytesToFloat(data, pos + 12);
}
else
{
_lightEntry = false;
_lightColorA = 1f;
_lightColorR = 0f;
_lightColorG = 0f;
_lightColorB = 0f;
_lightRadius = 0f;
_lightCutoff = 0f;
_lightFalloff = 0f;
_lightIntensity = 0f;
LightEntry = false;
LightColorA = 1f;
LightColorR = 0f;
LightColorG = 0f;
LightColorB = 0f;
LightRadius = 0f;
LightCutoff = 0f;
LightFalloff = 0f;
LightIntensity = 0f;
}
}
@ -1019,12 +622,12 @@ namespace OpenSim.Framework
byte[] data = new byte[16];
// Alpha channel in color is intensity
LLColor tmpColor = new LLColor(_lightColorR,_lightColorG,_lightColorB,_lightIntensity);
LLColor tmpColor = new LLColor(LightColorR,LightColorG,LightColorB,LightIntensity);
tmpColor.GetBytes().CopyTo(data, 0);
Helpers.FloatToBytes(_lightRadius).CopyTo(data, 4);
Helpers.FloatToBytes(_lightCutoff).CopyTo(data, 8);
Helpers.FloatToBytes(_lightFalloff).CopyTo(data, 12);
Helpers.FloatToBytes(LightRadius).CopyTo(data, 4);
Helpers.FloatToBytes(LightCutoff).CopyTo(data, 8);
Helpers.FloatToBytes(LightFalloff).CopyTo(data, 12);
return data;
}