From 67bbed820290b0307f09f29343e5fc96bdfc669a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 28 Dec 2007 05:25:21 +0000 Subject: * 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. --- OpenSim/Region/Environment/Scenes/Scene.cs | 120 ++++++++++++++------- .../Region/Environment/Scenes/SceneObjectPart.cs | 7 +- 2 files changed, 88 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') 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 return myID; } - public virtual void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape) + public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection) { - // What we're *supposed* to do is raytrace from the camera position given by the client to the nearest collision - // in the direction the client supplies (the ground level that we clicked) - // This function is pretty crappy right now.. so we're not affecting where the newly rezzed objects go - // Test it if you like. The console will write where it guesses a collision took place. if it thinks one did. - // It's wrong many times though. - - if (PermissionsMngr.CanRezObject(ownerID, pos)) + LLVector3 pos = LLVector3.Zero; + if (RayEndIsIntersection == (byte)1) { - EntityIntersection rayTracing = null; - ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID)); - if (presence != null) + pos = RayEnd; + return pos; + } + if (RayTargetID != LLUUID.Zero) + { + SceneObjectPart target = GetSceneObjectPart(RayTargetID); + if (target != null) { - Vector3 CameraPosition = presence.CameraPosition; - Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z); + pos = target.AbsolutePosition; - float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); + //MainLog.Instance.Verbose("RAYTRACE", pos.ToString()); + //EntityIntersection rayTracing = null; + //ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); + //if (presence != null) + //{ + //Vector3 CameraPosition = presence.CameraPosition; + //Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z); - Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance); + //float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd); + //LLVector3 rayDirectionLL = Util.GetNormal(pos); - Ray rezRay = new Ray(CameraPosition, rayDirection); + //Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z); - Vector3 RezDirectionFromCamera = rezRay.Direction; + //Ray rezRay = new Ray(CameraPosition, rayDirection); - rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); - } + //Vector3 RezDirectionFromCamera = rezRay.Direction; - if ((rayTracing != null) && (rayTracing.HitTF)) - { - // We raytraced and found a prim in the way of the ground.. so - // We will rez the object somewhere close to the prim. Better math needed. This is a Stub - //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); - Vector3 Newpos = rayTracing.ipoint; - Vector3 NewScale = - new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); + //rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); + //} + + //if ((rayTracing != null) && (rayTracing.HitTF)) + //{ + // We raytraced and found a prim in the way of the ground.. so + // We will rez the object somewhere close to the prim. Better math needed. This is a Stub + //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); + //Vector3 Newpos = rayTracing.ipoint; + //Vector3 NewScale = + //new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); + + //Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; + //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); + + //LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; + //Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); - Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; - //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); + //Quaternion NewRot = LocalRot * ParentRot; - LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; - Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); + //Vector3 RezPoint = Newpos; - Quaternion NewRot = LocalRot*ParentRot; + //MainLog.Instance.Verbose("REZINFO", "Possible Rez Point:" + RezPoint.ToString()); + //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z); + //} - Vector3 RezPoint = Newpos; - MainLog.Instance.Verbose("REZINFO", "Possible Rez Point:" + RezPoint.ToString()); - //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z); + + + + return pos; } else { + // fall back to our stupid functionality + pos = RayEnd; + return pos; + } + } + else + { + // fall back to our stupid functionality + pos = RayEnd; + return pos; + } + + } + + public virtual void AddNewPrim(LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot, PrimitiveBaseShape shape, + byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, + byte RayEndIsIntersection) + { + // What we're *supposed* to do is raytrace from the camera position given by the client to the nearest collision + // in the direction the client supplies (the ground level that we clicked) + // This function is pretty crappy right now.. so we're not affecting where the newly rezzed objects go + // Test it if you like. The console will write where it guesses a collision took place. if it thinks one did. + // It's wrong many times though. + + LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection); + + + + + if (PermissionsMngr.CanRezObject(ownerID, pos)) + { + // rez ON the ground, not IN the ground pos.Z += 0.25F; - } + SceneObjectGroup sceneOb = new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); @@ -1018,7 +1064,7 @@ namespace OpenSim.Region.Environment.Scenes treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; treeShape.Scale = scale; treeShape.State = (byte) treeType; - AddNewPrim(LLUUID.Random(), position, rotation, treeShape); + AddNewPrim(LLUUID.Random(), position, rotation, treeShape,(byte)1,LLVector3.Zero,LLUUID.Zero,(byte)1); } 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 EntityIntersection returnresult = new EntityIntersection(); Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z); Quaternion qRotation = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - Quaternion worldRotation = (qRotation*parentrot); - Matrix3 worldRotM = worldRotation.ToRotationMatrix(); + //Quaternion worldRotation = (qRotation*parentrot); + //Matrix3 worldRotM = worldRotation.ToRotationMatrix(); Vector3 rOrigin = iray.Origin; Vector3 rDirection = iray.Direction; + + //rDirection = rDirection.Normalize(); // Buidling the first part of the Quadratic equation Vector3 r2ndDirection = rDirection*rDirection; float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; -- cgit v1.1