aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-28 05:25:21 +0000
committerTeravus Ovares2007-12-28 05:25:21 +0000
commit67bbed820290b0307f09f29343e5fc96bdfc669a (patch)
tree154efd468369742724b06589e167b66a6de937ba /OpenSim/Region/Environment
parentAdd missing "System." to System.NullReferenceException (diff)
downloadopensim-SC-67bbed820290b0307f09f29343e5fc96bdfc669a.zip
opensim-SC-67bbed820290b0307f09f29343e5fc96bdfc669a.tar.gz
opensim-SC-67bbed820290b0307f09f29343e5fc96bdfc669a.tar.bz2
opensim-SC-67bbed820290b0307f09f29343e5fc96bdfc669a.tar.xz
* Added ability to create new prim on existing prim (rezzing prim from inventory on other prim coming soon). No more new prim buried in the ground by accident.
* The prim are at the absolute position of the prim you rezzed it on top of + (0,0,0.5) for now.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs120
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs7
2 files changed, 88 insertions, 39 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index afceaab..077157f 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -925,61 +925,107 @@ namespace OpenSim.Region.Environment.Scenes
925 return myID; 925 return myID;
926 } 926 }
927 927
928 public virtual void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape) 928 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection)
929 { 929 {
930 // What we're *supposed* to do is raytrace from the camera position given by the client to the nearest collision 930 LLVector3 pos = LLVector3.Zero;
931 // in the direction the client supplies (the ground level that we clicked) 931 if (RayEndIsIntersection == (byte)1)
932 // This function is pretty crappy right now.. so we're not affecting where the newly rezzed objects go
933 // Test it if you like. The console will write where it guesses a collision took place. if it thinks one did.
934 // It's wrong many times though.
935
936 if (PermissionsMngr.CanRezObject(ownerID, pos))
937 { 932 {
938 EntityIntersection rayTracing = null; 933 pos = RayEnd;
939 ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID)); 934 return pos;
940 if (presence != null) 935 }
936 if (RayTargetID != LLUUID.Zero)
937 {
938 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
939 if (target != null)
941 { 940 {
942 Vector3 CameraPosition = presence.CameraPosition; 941 pos = target.AbsolutePosition;
943 Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z);
944 942
945 float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); 943 //MainLog.Instance.Verbose("RAYTRACE", pos.ToString());
944 //EntityIntersection rayTracing = null;
945 //ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID));
946 //if (presence != null)
947 //{
948 //Vector3 CameraPosition = presence.CameraPosition;
949 //Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z);
946 950
947 Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance); 951 //float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
952 //LLVector3 rayDirectionLL = Util.GetNormal(pos);
948 953
949 Ray rezRay = new Ray(CameraPosition, rayDirection); 954 //Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z);
950 955
951 Vector3 RezDirectionFromCamera = rezRay.Direction; 956 //Ray rezRay = new Ray(CameraPosition, rayDirection);
952 957
953 rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); 958 //Vector3 RezDirectionFromCamera = rezRay.Direction;
954 }
955 959
956 if ((rayTracing != null) && (rayTracing.HitTF)) 960 //rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
957 { 961 //}
958 // We raytraced and found a prim in the way of the ground.. so 962
959 // We will rez the object somewhere close to the prim. Better math needed. This is a Stub 963 //if ((rayTracing != null) && (rayTracing.HitTF))
960 //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); 964 //{
961 Vector3 Newpos = rayTracing.ipoint; 965 // We raytraced and found a prim in the way of the ground.. so
962 Vector3 NewScale = 966 // We will rez the object somewhere close to the prim. Better math needed. This is a Stub
963 new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); 967 //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
968 //Vector3 Newpos = rayTracing.ipoint;
969 //Vector3 NewScale =
970 //new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
971
972 //Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
973 //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
974
975 //LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
976 //Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
964 977
965 Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; 978 //Quaternion NewRot = LocalRot * ParentRot;
966 //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
967 979
968 LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; 980 //Vector3 RezPoint = Newpos;
969 Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
970 981
971 Quaternion NewRot = LocalRot*ParentRot; 982 //MainLog.Instance.Verbose("REZINFO", "Possible Rez Point:" + RezPoint.ToString());
983 //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z);
984 //}
972 985
973 Vector3 RezPoint = Newpos;
974 986
975 MainLog.Instance.Verbose("REZINFO", "Possible Rez Point:" + RezPoint.ToString()); 987
976 //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z); 988
989
990 return pos;
977 } 991 }
978 else 992 else
979 { 993 {
994 // fall back to our stupid functionality
995 pos = RayEnd;
996 return pos;
997 }
998 }
999 else
1000 {
1001 // fall back to our stupid functionality
1002 pos = RayEnd;
1003 return pos;
1004 }
1005
1006 }
1007
1008 public virtual void AddNewPrim(LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot, PrimitiveBaseShape shape,
1009 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
1010 byte RayEndIsIntersection)
1011 {
1012 // What we're *supposed* to do is raytrace from the camera position given by the client to the nearest collision
1013 // in the direction the client supplies (the ground level that we clicked)
1014 // This function is pretty crappy right now.. so we're not affecting where the newly rezzed objects go
1015 // Test it if you like. The console will write where it guesses a collision took place. if it thinks one did.
1016 // It's wrong many times though.
1017
1018 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection);
1019
1020
1021
1022
1023 if (PermissionsMngr.CanRezObject(ownerID, pos))
1024 {
1025
980 // rez ON the ground, not IN the ground 1026 // rez ON the ground, not IN the ground
981 pos.Z += 0.25F; 1027 pos.Z += 0.25F;
982 } 1028
983 1029
984 SceneObjectGroup sceneOb = 1030 SceneObjectGroup sceneOb =
985 new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); 1031 new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
@@ -1018,7 +1064,7 @@ namespace OpenSim.Region.Environment.Scenes
1018 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; 1064 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree;
1019 treeShape.Scale = scale; 1065 treeShape.Scale = scale;
1020 treeShape.State = (byte) treeType; 1066 treeShape.State = (byte) treeType;
1021 AddNewPrim(LLUUID.Random(), position, rotation, treeShape); 1067 AddNewPrim(LLUUID.Random(), position, rotation, treeShape,(byte)1,LLVector3.Zero,LLUUID.Zero,(byte)1);
1022 } 1068 }
1023 1069
1024 public void RemovePrim(uint localID, LLUUID avatar_deleter) 1070 public void RemovePrim(uint localID, LLUUID avatar_deleter)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 90a975c..dad8812 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -694,19 +694,22 @@ namespace OpenSim.Region.Environment.Scenes
694 694
695 EntityIntersection returnresult = new EntityIntersection(); 695 EntityIntersection returnresult = new EntityIntersection();
696 Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); 696 Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
697
697 Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z); 698 Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z);
698 Quaternion qRotation = 699 Quaternion qRotation =
699 new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); 700 new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
700 701
701 702
702 Quaternion worldRotation = (qRotation*parentrot); 703 //Quaternion worldRotation = (qRotation*parentrot);
703 Matrix3 worldRotM = worldRotation.ToRotationMatrix(); 704 //Matrix3 worldRotM = worldRotation.ToRotationMatrix();
704 705
705 706
706 Vector3 rOrigin = iray.Origin; 707 Vector3 rOrigin = iray.Origin;
707 Vector3 rDirection = iray.Direction; 708 Vector3 rDirection = iray.Direction;
708 709
710
709 711
712 //rDirection = rDirection.Normalize();
710 // Buidling the first part of the Quadratic equation 713 // Buidling the first part of the Quadratic equation
711 Vector3 r2ndDirection = rDirection*rDirection; 714 Vector3 r2ndDirection = rDirection*rDirection;
712 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; 715 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z;