private bool EvenlyDistributeChildPrims(SceneObjectGroup group, Vector3 size, Vector3 point, Quaternion rot, Vector3 distribution, Vector3 margin)
        {

            int width = (int)distribution.X;
            int depth = (int)distribution.Y;
            int height = (int)distribution.Z;
            int volume = width * height * depth;

            bool distributionIsZeroVector = (Vector3)distribution == Vector3.Zero;

            if (!distributionIsZeroVector && (width < 1 || depth < 1 || height < 1))
            {
                ScriptError(group.RootPart, "Cannot evenly distribute prims across a distribution volume with axis less than 1");
                return false;
            }

            PhysicsActor pa = group.RootPart.PhysActor;
            if (pa != null && pa.IsPhysical)
            {
                size.X = Math.Max(group.Scene.m_minPhys, Math.Min(group.Scene.m_maxPhys, size.X));
                size.Y = Math.Max(group.Scene.m_minPhys, Math.Min(group.Scene.m_maxPhys, size.Y));
                size.Z = Math.Max(group.Scene.m_minPhys, Math.Min(group.Scene.m_maxPhys, size.Z));
            }
            else
            {
                // If not physical, then we clamp the scale to the non-physical min/max
                size.X = Math.Max(group.Scene.m_minNonphys, Math.Min(group.Scene.m_maxNonphys, size.X));
                size.Y = Math.Max(group.Scene.m_minNonphys, Math.Min(group.Scene.m_maxNonphys, size.Y));
                size.Z = Math.Max(group.Scene.m_minNonphys, Math.Min(group.Scene.m_maxNonphys, size.Z));
            }

            List<SceneObjectPart> parts = LSL_Api.GetLinkParts(group.RootPart, ScriptBaseClass.LINK_ALL_CHILDREN);
            if (volume == 0 && distributionIsZeroVector)
            {
                foreach (SceneObjectPart part in parts)
                {
                    part.OffsetPosition = point;
                    part.RotationOffset = rot;
                    part.Scale = size;
                }
                group.SendGroupFullUpdate();
                return true;
            }
            else if (volume < 2)
            {
                ScriptError(group.RootPart, "Cannot evenly distribute prims across a distribution volume less than 2");
                return false;
            }

            if (parts.Count > volume)
            {
                ScriptError(group.RootPart, "Cannot evenly distribute prims, distribution volume higher than specified number of prims to distribute");
                return false;
            }

            Vector3 start = new Vector3();
            start.X = ((size.X + margin.X) * (width - 1)) / -2.0f;
            start.Y = ((size.Y + margin.Y) * (depth - 1)) / -2.0f;
            start.Z = ((size.Z + margin.Z) * (height - 1)) / -2.0f;

            uint w = 0;
            uint d = 0;
            uint h = 0;

            foreach (SceneObjectPart part in parts)
            {
                float x = (w * (size.X + margin.X));
                float y = (d * (size.Y + margin.Y));
                float z = (h * (size.Z + margin.Z));
                part.OffsetPosition = (start + new Vector3(x, y, z)) * rot;
                part.OffsetPosition += point;
                part.RotationOffset = rot;
                part.Scale = size;

                if (++w >= width)
                {
                    w = 0;
                    ++d;
                }
                if (d >= depth)
                {
                    d = 0;
                    ++h;
                }
                if (h >= height)
                {
                    break;
                }
            }

            group.SendGroupFullUpdate();

            return true;
        }
Esempio n. 2
0
        public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client)
        {
            if (IsChildAgent || IsInTransit)
            {
                m_log.Info("[SCENE PRESENCE]: DoAutoPilot: Request from child agent ignored - " + this.UUID.ToString());
                return;
            }

            //m_log.Debug("[SCENE PRESENCE]: DoAutoPilot: Auto-move " + this.UUID.ToString() + " to " + Pos.ToString());
            m_autopilotMoving = true;
            m_autoPilotTarget = Pos;
            m_sitAtAutoTarget = false;
            PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
            //proxy.PCode = (byte)PCode.ParticleSystem;

            proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy, false);
            proxyObjectGroup.AttachToScene(m_scene, false);
            
            // Commented out this code since it could never have executed, but might still be informative.
//            if (proxyObjectGroup != null)
//            {
                proxyObjectGroup.SendGroupFullUpdate(PrimUpdateFlags.ForcedFullUpdate);
                remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false);
                m_scene.DeleteSceneObject(proxyObjectGroup, false);
//            }
//            else
//            {
//                m_autopilotMoving = false;
//                m_autoPilotTarget = Vector3.Zero;
//                ControllingClient.SendAlertMessage("Autopilot cancelled");
//            }
        }
        public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client)
        {
            m_autopilotMoving = true;
            m_autoPilotTarget = Pos;
            m_sitAtAutoTarget = false;
            PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
            //proxy.PCode = (byte)PCode.ParticleSystem;

            proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy);
            proxyObjectGroup.AttachToScene(m_scene);
            
            // Commented out this code since it could never have executed, but might still be informative.
//            if (proxyObjectGroup != null)
//            {
                proxyObjectGroup.SendGroupFullUpdate();
                remote_client.SendSitResponse(proxyObjectGroup.UUID, Vector3.Zero, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false);
                m_scene.DeleteSceneObject(proxyObjectGroup, false);
//            }
//            else
//            {
//                m_autopilotMoving = false;
//                m_autoPilotTarget = Vector3.Zero;
//                ControllingClient.SendAlertMessage("Autopilot cancelled");
//            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a Scene Object group to the Scene.
        /// Verifies that the creator of the object is not banned from the simulator.
        /// Checks if the item is an Attachment
        /// </summary>
        /// <param name="sceneObject"></param>
        /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
        public bool AddSceneObject(SceneObjectGroup sceneObject)
        {
            // If the user is banned, we won't let any of their objects
            // enter. Period.
            //
            if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
            {
                m_log.Info("[INTERREGION]: Denied prim crossing for " +
                        "banned avatar");

                return false;
            }

            if (sceneObject.IsAttachmentCheckFull()) // Attachment
            {
                sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
                sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
                AddPrimToScene(sceneObject);

                // Fix up attachment Parent Local ID
                ScenePresence sp = GetScenePresence(sceneObject.OwnerID);

                if (sp != null)
                {
                    m_log.DebugFormat(
                        "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", sceneObject.GetFromItemID(), sceneObject.UUID);
                    m_log.DebugFormat(
                        "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, sceneObject.AbsolutePosition);

                    if (AttachmentsModule != null)
                        AttachmentsModule.AttachObject(sp.ControllingClient, sceneObject.LocalId, 0, false);

                    sceneObject.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
                }
                else
                {
                    sceneObject.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
                    sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
                }
            }
            else
            {
                if (!Permissions.CanObjectEntry(sceneObject.UUID,
                        true, sceneObject.AbsolutePosition))
                {
                    // Deny non attachments based on parcel settings
                    //
                    m_log.Info("[INTERREGION]: Denied prim crossing " +
                            "because of parcel settings");

                    DeleteSceneObject(sceneObject, false, true);

                    return false;
                }
                AddPrimToScene(sceneObject);
            }
            sceneObject.SendGroupFullUpdate(PrimUpdateFlags.FullUpdate);

            return true;
        }