public uint RezObject(ObjectGroup group, RezObjectParams rezparams)
 {
     group.GlobalPosition = CalculateRezLocation(
         rezparams,
         group.Size);
     if (rezparams.SourceItem != null)
     {
         HandleRezOverwritePerms(group, rezparams.SourceItem);
     }
     return(RezObject(group, rezparams.RezzingAgent));
 }
        public List <uint> RezObjects(List <ObjectGroup> groups, RezObjectParams rezparams)
        {
            var result = new List <uint>();

            if (groups.Count == 0)
            {
                return(result);
            }
            Vector3 aabbMin = groups[0].CoalescedRestoreOffset;
            Vector3 aabbMax = aabbMin;

            foreach (ObjectGroup grp in groups)
            {
                aabbMin = aabbMin.ComponentMin(grp.CoalescedRestoreOffset - grp.Size / 2);
                aabbMax = aabbMax.ComponentMax(grp.CoalescedRestoreOffset + grp.Size / 2);
            }
            Vector3 coalescedOffset = (aabbMax - aabbMin) / 2;

#if DEBUG
            m_Log.DebugFormat("RezObject at coalescedbaseoffset={0} aabbmin={1} aabbmax={2}", coalescedOffset, aabbMin, aabbMax);
#endif
            Vector3 basePosition = CalculateRezLocation(rezparams, aabbMax - aabbMin) - coalescedOffset;
            foreach (ObjectGroup grp in groups)
            {
#if DEBUG
                m_Log.DebugFormat("RezObject \"{0}\" at coalescedrestoreoffset={1} size={2}", grp.Name, grp.CoalescedRestoreOffset, grp.Size);
#endif
                try
                {
                    grp.GlobalPosition = basePosition + grp.CoalescedRestoreOffset;
                    result.Add(RezObject(grp, rezparams));
                }
                catch (Exception e)
                {
                    m_Log.DebugFormat("Exception at {0}: {1}\n{2}", e.GetType().FullName, e.Message, e.StackTrace);
                    break;
                }
            }
            return(result);
        }
예제 #3
0
        public UInt32 ObjectAdd(ObjectAdd p)
        {
            var rezparams = new RezObjectParams();
            var group     = new Object.ObjectGroup();
            var part      = new ObjectPart();

            group.Add(1, part.ID, part);
            group.Name = "Primitive";
            IAgent agent      = Agents[p.AgentID];
            UGUI   agentOwner = agent.Owner;

            group.LastOwner        = agentOwner;
            part.Creator           = agentOwner;
            rezparams.RezzingAgent = agentOwner;
            ObjectPart.PrimitiveShape pshape = part.Shape;
            pshape.PCode            = p.PCode;
            part.Material           = p.Material;
            pshape.PathCurve        = p.PathCurve;
            pshape.ProfileCurve     = p.ProfileCurve;
            pshape.PathBegin        = p.PathBegin;
            pshape.PathEnd          = p.PathEnd;
            pshape.PathScaleX       = p.PathScaleX;
            pshape.PathScaleY       = p.PathScaleY;
            pshape.PathShearX       = p.PathShearX;
            pshape.PathShearY       = p.PathShearY;
            pshape.PathTwist        = p.PathTwist;
            pshape.PathTwistBegin   = p.PathTwistBegin;
            pshape.PathRadiusOffset = p.PathRadiusOffset;
            pshape.PathTaperX       = p.PathTaperX;
            pshape.PathTaperY       = p.PathTaperY;
            pshape.PathRevolutions  = p.PathRevolutions;
            pshape.PathSkew         = p.PathSkew;
            pshape.ProfileBegin     = p.ProfileBegin;
            pshape.ProfileEnd       = p.ProfileEnd;
            pshape.ProfileHollow    = p.ProfileHollow;

            rezparams.RayStart             = p.RayStart;
            rezparams.RayEnd               = p.RayEnd;
            rezparams.RayTargetID          = p.RayTargetID;
            rezparams.RayEndIsIntersection = p.RayEndIsIntersection;
            rezparams.Scale    = p.Scale;
            rezparams.Rotation = p.Rotation;
            pshape.State       = p.State;
            group.AttachPoint  = p.LastAttachPoint;

            part.Size          = Vector3.One / 2.0;
            part.BaseMask      = p.BasePermissions;
            part.EveryoneMask  = p.EveryOnePermissions;
            part.OwnerMask     = p.CurrentPermissions;
            part.NextOwnerMask = p.NextOwnerPermissions;
            part.GroupMask     = p.GroupPermissions;
            part.Shape         = pshape;
            group.Group.ID     = p.GroupID;
            part.ObjectGroup   = group;
            part.Size          = Vector3.One / 2f;

            /* initial setup of object */
            part.UpdateData(ObjectPartLocalizedInfo.UpdateDataFlags.All);

            var selectedList = agent.SelectedObjects(ID);

            foreach (UUID old in selectedList.GetAndClear())
            {
                ObjectPart oldSelectedPart;
                if (Primitives.TryGetValue(old, out oldSelectedPart))
                {
                    agent.ScheduleUpdate(oldSelectedPart.UpdateInfo, ID);
                }
            }
            selectedList.Add(part.ID);

            return(RezObject(group, rezparams));
        }
        public Vector3 CalculateRezLocation(
            RezObjectParams rezparams,
            Vector3 scale)
        {
            Vector3 pos = rezparams.RayEnd + new Vector3(0, 0, scale.Z / 2f);

            if (rezparams.RayEndIsIntersection)
            {
                return(rezparams.RayEnd);
            }

            Vector3 projectedWaterLocation = Vector3.Zero;
            double  waterHeight            = RegionSettings.WaterHeight;

            if (rezparams.RayStart.Z > waterHeight && rezparams.RayEnd.Z < waterHeight)
            {
                Vector3 dir   = rezparams.RayEnd - rezparams.RayStart;
                double  ratio = (waterHeight - rezparams.RayStart.Z) / dir.Z;

                projectedWaterLocation    = rezparams.RayStart;
                projectedWaterLocation.X += ratio * dir.X;
                projectedWaterLocation.Y += ratio * dir.Y;
                projectedWaterLocation.Z  = waterHeight;
            }
            else
            {
                projectedWaterLocation.Z = waterHeight;
            }

            ObjectPart target;

            if (Primitives.TryGetValue(rezparams.RayTargetID, out target))
            {
                pos = target.GlobalPosition;
            }
            RayResult[] results = PhysicsScene.RayTest(rezparams.RayStart, pos);

            if (rezparams.RayTargetID != UUID.Zero)
            {
                foreach (RayResult ray in results)
                {
                    if (ray.PartId == rezparams.RayTargetID)
                    {
                        return(CalculateTargetedRezLocation(ray, scale, projectedWaterLocation));
                    }
                }
            }
            else
            {
                foreach (RayResult ray in results)
                {
                    if (ray.IsTerrain)
                    {
                        return(CalculateTargetedRezLocation(ray, scale, projectedWaterLocation));
                    }
                }
            }

            if (results.Length > 0)
            {
                return(CalculateTargetedRezLocation(results[0], scale, projectedWaterLocation));
            }
            else
            {
                pos = rezparams.RayEnd;
                LocationInfo info = GetLocationInfoProvider().At(pos);
                pos.Z = info.GroundHeight;
                if (pos.Z < info.WaterHeight && rezparams.RayStart.Z >= info.WaterHeight)
                {
                    pos.Z = info.WaterHeight;
                }
                pos.Z += scale.Z * 0.5;
            }
            return(pos);
        }