From 8cd72beb86d2a563bdaf88b20aa76d9bafa6b971 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 28 Dec 2007 08:34:38 +0000 Subject: * Moved PrimitiveBaseShape subclasses into factory methods - the subclassing scheme won't hold for serialization * Extracted out the 'old' AddNewPrimitive that places an object at an exact pos, without the raytracing --- OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 4 +- OpenSim/Framework/PrimitiveBaseShape.cs | 106 +++++++++++-------------- 2 files changed, 50 insertions(+), 60 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index fcf8c6f..3c25533 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs @@ -203,7 +203,7 @@ namespace OpenSim.Framework.Data.MySQL { MainLog.Instance.Notice( "No shape found for prim in storage, so setting default box shape"); - prim.Shape = BoxShape.Default; + prim.Shape = PrimitiveBaseShape.Default; } group.AddPart(prim); group.RootPart = prim; @@ -223,7 +223,7 @@ namespace OpenSim.Framework.Data.MySQL { MainLog.Instance.Notice( "No shape found for prim in storage, so setting default box shape"); - prim.Shape = BoxShape.Default; + prim.Shape = PrimitiveBaseShape.Default; } createdObjects[new LLUUID(objID)].AddPart(prim); } diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 66511e6..1424395 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -112,22 +112,22 @@ namespace OpenSim.Framework public ProfileShape ProfileShape { - get { return (ProfileShape) (ProfileCurve & 0xf); } + get { return (ProfileShape)(ProfileCurve & 0xf); } set { - byte oldValueMasked = (byte) (ProfileCurve & 0xf0); - ProfileCurve = (byte) (oldValueMasked | (byte) value); + byte oldValueMasked = (byte)(ProfileCurve & 0xf0); + ProfileCurve = (byte)(oldValueMasked | (byte)value); } } [XmlIgnore] public HollowShape HollowShape { - get { return (HollowShape) (ProfileCurve & 0xf0); } + get { return (HollowShape)(ProfileCurve & 0xf0); } set { - byte oldValueMasked = (byte) (ProfileCurve & 0x0f); - ProfileCurve = (byte) (oldValueMasked | (byte) value); + byte oldValueMasked = (byte)(ProfileCurve & 0x0f); + ProfileCurve = (byte)(oldValueMasked | (byte)value); } } @@ -145,7 +145,7 @@ namespace OpenSim.Framework public PrimitiveBaseShape() { - PCode = (byte) PCodeEnum.Primitive; + PCode = (byte)PCodeEnum.Primitive; ExtraParams = new byte[1]; Textures = m_defaultTexture; } @@ -156,86 +156,76 @@ namespace OpenSim.Framework return shape; } - //void returns need to change of course - public virtual void GetMesh() + public static PrimitiveBaseShape CreateBox() { - } + PrimitiveBaseShape shape = Create(); - public PrimitiveBaseShape Copy() - { - return (PrimitiveBaseShape) MemberwiseClone(); - } - } + shape.PathCurve = (byte)Extrusion.Straight; + shape.ProfileShape = ProfileShape.Square; + shape.PathScaleX = 100; + shape.PathScaleY = 100; - public class GenericShape : PrimitiveBaseShape - { - public GenericShape() - : base() - { + return shape; } - } - public class BoxShape : PrimitiveBaseShape - { - public BoxShape() - : base() + public static PrimitiveBaseShape CreateCylinder() { - PathCurve = (byte) Extrusion.Straight; - ProfileShape = ProfileShape.Square; - PathScaleX = 100; - PathScaleY = 100; - } + PrimitiveBaseShape shape = Create(); - public BoxShape(float side) - : this() - { - SetSide(side); - } + shape.PathCurve = (byte)Extrusion.Curve1; + shape.ProfileShape = ProfileShape.Square; - public void SetSide(float side) - { - Scale = new LLVector3(side, side, side); + shape.PathScaleX = 100; + shape.PathScaleY = 100; + + return shape; } - public static BoxShape Default + public static PrimitiveBaseShape Default { get { - BoxShape boxShape = new BoxShape(); + PrimitiveBaseShape boxShape = CreateBox(); - boxShape.SetSide(0.5f); + boxShape.SetScale(0.5f); return boxShape; } } - } - public class CylinderShape : PrimitiveBaseShape - { - public CylinderShape() - : base() + public void SetScale(float side) { - PathCurve = (byte) Extrusion.Straight; - ProfileShape = ProfileShape.Circle; - PathScaleX = 100; - PathScaleY = 100; + Scale = new LLVector3(side, side, side); } - public CylinderShape(float radius, float heigth) - : this() + public void SetHeigth(float heigth) { - SetRadius(radius); - SetHeigth(heigth); + Scale.Z = heigth; } - private void SetHeigth(float heigth) + public void SetRadius(float radius) + { + Scale.X = Scale.Y = radius * 2f; + } + + //void returns need to change of course + public virtual void GetMesh() { - Scale.Z = heigth; } - private void SetRadius(float radius) + public PrimitiveBaseShape Copy() { - Scale.X = Scale.Y = radius*2f; + return (PrimitiveBaseShape)MemberwiseClone(); + } + + public static PrimitiveBaseShape CreateCylinder(float radius, float heigth) + { + PrimitiveBaseShape shape = CreateCylinder( ); + + shape.SetHeigth( heigth ); + shape.SetRadius( radius ); + + return shape; } } } -- cgit v1.1