public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) { if (this._physActor != null) { if (this._physActor.Kinematic == pack.AgentData.UsePhysics) { this._physActor.Kinematic = !pack.AgentData.UsePhysics; //if Usephysics = true, then Kinematic should = false } this.physicsEnabled = pack.AgentData.UsePhysics; if (this._physActor.Kinematic == false) { LLVector3 pos = this.Pos; this.UpdatePosition(pos); pos.Z += 0.000001f; this.UpdatePosition(pos); this.physicstest = true; } else { PhysicsVector vec = this._physActor.Position; LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z); this.Pos = pos; this.updateFlag = true; } } }
void ObjectFlagUpdateHandler(Packet packet, Agent agent) { ObjectFlagUpdatePacket update = (ObjectFlagUpdatePacket)packet; SimulationObject obj; if (server.Scene.TryGetObject(update.AgentData.ObjectLocalID, out obj)) { PrimFlags flags = obj.Prim.Flags; if (update.AgentData.CastsShadows) { flags |= PrimFlags.CastShadows; } else { flags &= ~PrimFlags.CastShadows; } if (update.AgentData.IsPhantom) { flags |= PrimFlags.Phantom; } else { flags &= ~PrimFlags.Phantom; } if (update.AgentData.IsTemporary) { flags |= PrimFlags.Temporary; } else { flags &= ~PrimFlags.Temporary; } if (update.AgentData.UsePhysics) { flags |= PrimFlags.Physics; } else { flags &= ~PrimFlags.Physics; } server.Scene.ObjectFlags(this, obj, flags); } else { Logger.Log("Got an ObjectFlagUpdate packet for unknown object " + update.AgentData.ObjectLocalID, Helpers.LogLevel.Warning); } }
/// <summary> /// Update the properties of an object /// </summary> /// <param name="simulator">The <see cref="Simulator"/> the object is located</param> /// <param name="localID">The Local ID of the object</param> /// <param name="physical">true to turn the objects physical property on</param> /// <param name="temporary">true to turn the objects temporary property on</param> /// <param name="phantom">true to turn the objects phantom property on</param> /// <param name="castsShadow">true to turn the objects cast shadows property on</param> public void SetFlags(Simulator simulator, uint localID, bool physical, bool temporary, bool phantom, bool castsShadow) { ObjectFlagUpdatePacket flags = new ObjectFlagUpdatePacket(); flags.AgentData.AgentID = Client.Self.AgentID; flags.AgentData.SessionID = Client.Self.SessionID; flags.AgentData.ObjectLocalID = localID; flags.AgentData.UsePhysics = physical; flags.AgentData.IsTemporary = temporary; flags.AgentData.IsPhantom = phantom; flags.AgentData.CastsShadows = castsShadow; Client.Network.SendPacket(flags, simulator); }
/// <summary> /// A user has changed an object setting /// </summary> /// <param name="LocalID"></param> /// <param name="blocks"></param> /// <param name="remoteClient"></param> /// <param name="UsePhysics"></param> /// <param name="IsTemporary"></param> /// <param name="IsPhantom"></param> protected internal void UpdatePrimFlags(uint LocalID, bool UsePhysics, bool IsTemporary, bool IsPhantom, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks, IClientAPI remoteClient) { IEntity entity; if (TryGetEntity(LocalID, out entity)) { if (m_parentScene.Permissions.CanEditObject(entity.UUID, remoteClient.AgentId)) { ((SceneObjectGroup) entity).UpdatePrimFlags(LocalID, UsePhysics, IsTemporary, IsPhantom, false, blocks); // VolumeDetect can't be set via UI and will always be off when a change is made there } } }
/// <summary> /// Update prim flags for this group. /// </summary> /// <param name = "localID"></param> /// <param name="UsePhysics"></param> /// <param name="IsTemporary"></param> /// <param name="IsPhantom"></param> /// <param name="IsVolumeDetect"></param> /// <param name="blocks"></param> public void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVolumeDetect, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks) { ISceneChildEntity selectionPart = GetChildPart(localID); if (IsTemporary) { // Remove from database and parcel prim count // Temporary objects arn't saved to the database ever, so we don't need to do anything } if (selectionPart != null) { foreach (SceneObjectPart part in m_partsList) { IOpenRegionSettingsModule WSModule = Scene.RequestModuleInterface<IOpenRegionSettingsModule>(); if (WSModule != null) { if (WSModule.MaximumPhysPrimScale == -1) break; if (part.Scale.X > WSModule.MaximumPhysPrimScale || part.Scale.Y > WSModule.MaximumPhysPrimScale || part.Scale.Z > WSModule.MaximumPhysPrimScale) { UsePhysics = false; // Reset physics break; } } } bool needsPhysicalRebuild = ((SceneObjectPart) selectionPart).UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, blocks); #if (!ISWIN) foreach (SceneObjectPart part in m_partsList) { if (selectionPart != part) { if (needsPhysicalRebuild) part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, null); else needsPhysicalRebuild = part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, null); } } #else foreach (SceneObjectPart part in m_partsList.Where(part => selectionPart != part)) { if (needsPhysicalRebuild) part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, null); else needsPhysicalRebuild = part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, null); } #endif if (needsPhysicalRebuild) RebuildPhysicalRepresentation(true); } }
public void UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVD, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks) { if (blocks != null && blocks.Length != 0) { ObjectFlagUpdatePacket.ExtraPhysicsBlock block = blocks[0]; Shape.PreferredPhysicsShape = (PhysicsShapeType)block.PhysicsShapeType; PhysicsShapeChanged(); if (PhysActor != null) { PhysActor.SetMaterial( new MaterialDesc { Restitution = block.Restitution, StaticFriction = block.Friction, DynamicFriction = block.Friction / 1.75f, Density = block.Density, GravityMultiplier = block.GravityMultiplier, MaterialPreset = MaterialDesc.NO_PRESET }, true, MaterialChanges.Restitution ); } } if (!IsRootPart()) return; SceneObjectPartPhysicsSummary targetSummary = SceneObjectPartPhysicsSummary.SummaryFromParams(Shape.FlexiEntry, IsAttachment, IsVD, UsePhysics, IsPhantom); SceneObjectPartPhysicsSummary.ChangeFlags changed = SceneObjectPartPhysicsSummary.Compare(this.PhysicsSummary, targetSummary); //has to be done before the ChangeFlags are tested because they do not cover the //temporary status if (IsTemporary) { m_parentGroup.AddGroupFlagValue(PrimFlags.TemporaryOnRez); } else { m_parentGroup.RemGroupFlagValue(PrimFlags.TemporaryOnRez); } if (changed == SceneObjectPartPhysicsSummary.ChangeFlags.NoChange) { return; } if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.IsPhantomChanged) != 0) { if (targetSummary.IsPhantom) { m_parentGroup.AddGroupFlagValue(PrimFlags.Phantom); } else { m_parentGroup.RemGroupFlagValue(PrimFlags.Phantom); } } if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.IsVolumeDetectChanged) != 0) { if (targetSummary.IsVolumeDetect) { VolumeDetectActive = true; } else { VolumeDetectActive = false; } } if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.NeedsDynamicActorChanged) != 0) { if (targetSummary.NeedsDynamicActor) { m_parentGroup.Scene.AddPhysicalObject(); m_parentGroup.AddGroupFlagValue(PrimFlags.Physics); } else { m_parentGroup.Scene.RemovePhysicalObject(); m_parentGroup.RemGroupFlagValue(PrimFlags.Physics); } } //apply the actual physics changes if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.NeedsPhysicsShapeChanged) != 0) { if (targetSummary.NeedsPhysicsShape) { //reapplies physics to the entire group m_parentGroup.ApplyPhysics(true, false); } else { PhysicsActor physActor = PhysActor; if (physActor != null) { Vector3 velIgnore; Vector3 accelIgnore; Vector3 angularVelIgnore; physActor.GatherTerseUpdate(out m_groupPosition, out m_rotationOffset, out velIgnore, out accelIgnore, out angularVelIgnore); SetOffsetPositionDirect(Vector3.Zero); RemoveFromPhysicalScene(physActor); } } } if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.IsVolumeDetectChanged) != 0) { PhysicsActor physActor = PhysActor; if (physActor != null) { physActor.SetVolumeDetect(targetSummary.IsVolumeDetect); } } else { if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.NeedsDynamicActorChanged) != 0 && (changed & SceneObjectPartPhysicsSummary.ChangeFlags.NeedsPhysicsShapeChanged) == 0) { //needs an actor change, but didnt also need a physics shape change which would've //already created the appropriate actor AdjustPhysactorDynamics(targetSummary.NeedsDynamicActor, false); } if ((changed & SceneObjectPartPhysicsSummary.ChangeFlags.IsPhantomChanged) != 0) { PhysicsActor physActor = PhysActor; if (physActor != null) { //we're still using physics and are now phantom, so we need to update //the prim physActor.SetPhantom(targetSummary.IsPhantom); } } } //m_log.Debug(targetSummary); ParentGroup.HasGroupChanged = true; ScheduleFullUpdate(PrimUpdateFlags.PrimFlags); }
public bool UpdatePrimFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVD, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks) { bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); bool wasVD = VolumeDetectActive; bool needsPhysicalRebuild = false; if (blocks != null && blocks.Length != 0) { ObjectFlagUpdatePacket.ExtraPhysicsBlock block = blocks[0]; //These 2 are static properties, and do require rebuilding the entire physical representation if (PhysicsType != block.PhysicsShapeType) { PhysicsType = block.PhysicsShapeType; needsPhysicalRebuild = true; //Gotta rebuild now } if (Density != block.Density) { Density = block.Density; needsPhysicalRebuild = true; //Gotta rebuild now } //These 3 are dynamic properties, and don't require rebuilding the physics representation if (Friction != block.Friction) Friction = block.Friction; if (Restitution != block.Restitution) Restitution = block.Restitution; if (GravityMultiplier != block.GravityMultiplier) GravityMultiplier = block.GravityMultiplier; } if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD == wasVD)) return needsPhysicalRebuild; // Special cases for VD. VD can only be called from a script // and can't be combined with changes to other states. So we can rely // that... // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. if (IsVD) // VD is active, special logic applies { // State machine logic for VolumeDetect // More logic below bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom; if (phanReset) // Phantom changes from on to off switch VD off too { IsVD = false; // Switch it of for the course of this routine VolumeDetectActive = false; // and also permanently if (PhysActor != null) PhysActor.VolumeDetect = false; // Let physics know about it too } else { IsPhantom = false; // If volumedetect is active we don't want phantom to be applied. // If this is a new call to VD out of the state "phantom" // this will also cause the prim to be visible to physics } } if (UsePhysics) AddFlag(PrimFlags.Physics); else RemFlag(PrimFlags.Physics); if (PhysActor != null) { PhysActor.IsPhysical = UsePhysics; if (!UsePhysics) { //Clear out old data Velocity = Vector3.Zero; Acceleration = Vector3.Zero; AngularVelocity = Vector3.Zero; PhysActor.RotationalVelocity = Vector3.Zero; GenerateRotationalVelocityFromOmega(); if (wasUsingPhysics) ScheduleTerseUpdate(); //Force it out of the client too } } if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte) Extrusion.Flexible)) // note: this may have been changed above in the case of joints { AddFlag(PrimFlags.Phantom); needsPhysicalRebuild = true; //Gotta rebuild now } else // Not phantom { if (wasPhantom) { RemFlag(PrimFlags.Phantom); needsPhysicalRebuild = true; //Gotta rebuild now } } if (IsVD && IsVD != VolumeDetectActive) { // If the above logic worked (this is urgent candidate to unit tests!) // we now have a physicsactor. // Defensive programming calls for a check here. // Better would be throwing an exception that could be catched by a unit test as the internal // logic should make sure, this Physactor is always here. //FALSE, you can go from a phantom prim > VD -7/26 if (PhysActor != null) PhysActor.VolumeDetect = true; AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active VolumeDetectActive = true; } else { if (!IsVD) { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) PhysicsObject pa = this.PhysActor; if (pa != null) PhysActor.VolumeDetect = false; VolumeDetectActive = false; } } if (IsTemporary) AddFlag(PrimFlags.TemporaryOnRez); else RemFlag(PrimFlags.TemporaryOnRez); if (UsePhysics != wasUsingPhysics) //Fire the event ParentGroup.Scene.AuroraEventManager.FireGenericEventHandler("ObjectChangedPhysicalStatus", ParentGroup); ParentGroup.HasGroupChanged = true; ScheduleUpdate(PrimUpdateFlags.PrimFlags); return needsPhysicalRebuild; }
/// <summary> /// Update the properties of an object /// </summary> /// <param name="simulator">The <see cref="Simulator"/> the object is located</param> /// <param name="localID">The Local ID of the object</param> /// <param name="physical">true to turn the objects physical property on</param> /// <param name="temporary">true to turn the objects temporary property on</param> /// <param name="phantom">true to turn the objects phantom property on</param> /// <param name="castsShadow">true to turn the objects cast shadows property on</param> /// <param name="physicsType">Type of the represetnation prim will have in the physics engine</param> /// <param name="density">Density - normal value 1000</param> /// <param name="friction">Friction - normal value 0.6</param> /// <param name="restitution">Restitution - standard value 0.5</param> /// <param name="gravityMultiplier">Gravity multiplier - standar value 1.0</param> public void SetFlags(Simulator simulator, uint localID, bool physical, bool temporary, bool phantom, bool castsShadow, PhysicsShapeType physicsType, float density, float friction, float restitution, float gravityMultiplier) { ObjectFlagUpdatePacket flags = new ObjectFlagUpdatePacket(); flags.AgentData.AgentID = Client.Self.AgentID; flags.AgentData.SessionID = Client.Self.SessionID; flags.AgentData.ObjectLocalID = localID; flags.AgentData.UsePhysics = physical; flags.AgentData.IsTemporary = temporary; flags.AgentData.IsPhantom = phantom; flags.AgentData.CastsShadows = castsShadow; flags.ExtraPhysics = new ObjectFlagUpdatePacket.ExtraPhysicsBlock[1]; flags.ExtraPhysics[0] = new ObjectFlagUpdatePacket.ExtraPhysicsBlock(); flags.ExtraPhysics[0].PhysicsShapeType = (byte)physicsType; flags.ExtraPhysics[0].Density = density; flags.ExtraPhysics[0].Friction = friction; flags.ExtraPhysics[0].Restitution = restitution; flags.ExtraPhysics[0].GravityMultiplier = gravityMultiplier; Client.Network.SendPacket(flags, simulator); }
/// <summary> /// Update prim flags for this group. /// </summary> /// <param name="localID"></param> /// <param name="type"></param> /// <param name="inUse"></param> /// <param name="data"></param> public void UpdateFlags(bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVolumeDetect, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks) { SceneObjectPart rootPart = RootPart; if (IsTemporary) { //only do this if it is actually changing since it is a heavy op //and can be blocked by object persistence if ((RootPart.Flags & PrimFlags.TemporaryOnRez) == 0) { DetachFromBackup(); Scene.RemoveFromPotentialReturns(this); // Remove from database and parcel prim count // if (IsPersisted) m_scene.DeleteFromStorage(UUID); } } else { // Ensure that changes made to this object are persisted. AttachToBackup(); Scene.InspectForAutoReturn(this); } // I don't think the prim counts look at temp objects, but this was here in the normal->Temp case. // If it needs to remain at all, it also needs to be in the else clause, the Temp->normal case. // (We need to include both temp and normal prims in counts or it could be a griefer performance exploit.) m_scene.EventManager.TriggerParcelPrimCountTainted(); //changing any of these flags puts the root part in charge of setting flags //on the children rootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect, blocks); }
public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) { }
protected virtual void ProcessInPacket(Packet Pack) { ack_pack(Pack); if (debug) { if (Pack.Type != PacketType.AgentUpdate) { Console.WriteLine(Pack.Type.ToString()); } } if (this.ProcessPacketMethod(Pack)) { //there is a handler registered that handled this packet type return; } else { System.Text.Encoding _enc = System.Text.Encoding.ASCII; switch (Pack.Type) { case PacketType.CompleteAgentMovement: if (this.m_child) { this.UpgradeClient(); } ClientAvatar.CompleteMovement(m_world); ClientAvatar.SendInitialPosition(); break; case PacketType.RegionHandshakeReply: m_world.SendLayerData(this); break; case PacketType.AgentWearablesRequest: ClientAvatar.SendInitialAppearance(); foreach (SimClient client in m_clientThreads.Values) { if (client.AgentID != this.AgentID) { ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); this.OutPacket(objupdate); client.ClientAvatar.SendAppearanceToOtherAgent(this); } } m_world.GetInitialPrims(this); break; case PacketType.AgentIsNowWearing: AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; //Console.WriteLine(Pack.ToString()); break; case PacketType.AgentSetAppearance: AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; // Console.WriteLine(appear.ToString()); this.ClientAvatar.SetAppearance(appear); break; case PacketType.ObjectAdd: m_world.AddNewPrim((ObjectAddPacket)Pack, this); break; case PacketType.ObjectLink: OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); ObjectLinkPacket link = (ObjectLinkPacket)Pack; uint parentprimid = 0; OpenSim.world.Primitive parentprim = null; if (link.ObjectData.Length > 1) { parentprimid = link.ObjectData[0].ObjectLocalID; foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == parentprimid) { parentprim = (OpenSim.world.Primitive)ent; } } for (int i = 1; i < link.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == link.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).MakeParent(parentprim); } } } } break; case PacketType.ObjectScale: OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); break; case PacketType.ObjectShape: ObjectShapePacket shape = (ObjectShapePacket)Pack; for (int i = 0; i < shape.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == shape.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); } } } break; case PacketType.RequestImage: RequestImagePacket imageRequest = (RequestImagePacket)Pack; for (int i = 0; i < imageRequest.RequestImage.Length; i++) { m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); } break; case PacketType.TransferRequest: //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); TransferRequestPacket transfer = (TransferRequestPacket)Pack; m_assetCache.AddAssetRequest(this, transfer); break; case PacketType.AgentUpdate: ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); break; case PacketType.ObjectImage: ObjectImagePacket imagePack = (ObjectImagePacket)Pack; for (int i = 0; i < imagePack.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); } } } break; case PacketType.ObjectFlagUpdate: ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == flags.AgentData.ObjectLocalID) { ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); } } break; case PacketType.AssetUploadRequest: AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); break; case PacketType.RequestXfer: //Console.WriteLine(Pack.ToString()); break; case PacketType.SendXferPacket: this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); break; case PacketType.CreateInventoryFolder: CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); //Console.WriteLine(Pack.ToString()); break; case PacketType.CreateInventoryItem: //Console.WriteLine(Pack.ToString()); CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) { this.UploadAssets.CreateInventoryItem(createItem); } else { // Console.Write(Pack.ToString()); this.CreateInventoryItem(createItem); } break; case PacketType.FetchInventory: //Console.WriteLine("fetch item packet"); FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; m_inventoryCache.FetchInventory(this, FetchInventory); break; case PacketType.FetchInventoryDescendents: FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; m_inventoryCache.FetchInventoryDescendents(this, Fetch); break; case PacketType.UpdateInventoryItem: UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; //Console.WriteLine(Pack.ToString()); for (int i = 0; i < update.InventoryData.Length; i++) { if (update.InventoryData[i].TransactionID != LLUUID.Zero) { AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); if (asset != null) { // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); } else { asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); if (asset != null) { //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); } else { //Console.WriteLine("trying to update inventory item, but asset is null"); } } } else { m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]);; } } break; case PacketType.ViewerEffect: ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; foreach (SimClient client in m_clientThreads.Values) { if (client.AgentID != this.AgentID) { viewer.AgentData.AgentID = client.AgentID; viewer.AgentData.SessionID = client.SessionID; client.OutPacket(viewer); } } break; case PacketType.RequestTaskInventory: // Console.WriteLine(Pack.ToString()); RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); bool foundent = false; foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == requesttask.InventoryData.LocalID) { replytask.InventoryData.TaskID = ent.uuid; replytask.InventoryData.Serial = 0; replytask.InventoryData.Filename = new byte[0]; foundent = true; } } if (foundent) { this.OutPacket(replytask); } break; case PacketType.UpdateTaskInventory: // Console.WriteLine(Pack.ToString()); UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); if (myinventory != null) { if (updatetask.UpdateData.Key == 0) { if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) { if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) { LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; AssetBase assBase = this.m_assetCache.GetAsset(noteaid); if (assBase != null) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == updatetask.UpdateData.LocalID) { if (ent is OpenSim.world.Primitive) { this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); } } } } } } } } break; case PacketType.AgentAnimation: if (!m_child) { AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; for (int i = 0; i < AgentAni.AnimationList.Length; i++) { if (AgentAni.AnimationList[i].StartAnim) { ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; ClientAvatar.anim_seq = 1; ClientAvatar.SendAnimPack(); } } } break; case PacketType.ObjectSelect: ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; for (int i = 0; i < incomingselect.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).GetProperites(this); break; } } } break; } } }
/// <summary> /// /// </summary> /// <param name="localID"></param> /// <param name="packet"></param> /// <param name="remoteClient"></param> /// This routine seems to get called when a user changes object settings in the viewer. /// If some one can confirm that, please change the comment according. protected internal void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, IClientAPI remoteClient, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks) { SceneObjectPart part = GetPrimByLocalId(localID); if (part != null) { if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) { bool VolDetect = false; // VolumeDetect can't be set via UI and will always be off when a change is made there if (part.IsRootPart()) part.ParentGroup.UpdateFlags(UsePhysics, IsTemporary, IsPhantom, VolDetect, blocks); else part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, VolDetect, blocks); } } }
public void UpdatePrimFlags (bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVD, ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks) { bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); bool wasVD = VolumeDetectActive; if (blocks != null && blocks.Length != 0) { ObjectFlagUpdatePacket.ExtraPhysicsBlock block = blocks[0]; if (PhysicsType != block.PhysicsShapeType) { PhysicsType = block.PhysicsShapeType; ParentGroup.RebuildPhysicalRepresentation (); } if (this.PhysActor != null) GravityMultiplier = block.GravityMultiplier; if (Density != block.Density) { Density = block.Density; ParentGroup.RebuildPhysicalRepresentation (); } } if ((UsePhysics == wasUsingPhysics) && (wasTemporary == IsTemporary) && (wasPhantom == IsPhantom) && (IsVD==wasVD)) return; // Special cases for VD. VD can only be called from a script // and can't be combined with changes to other states. So we can rely // that... // ... if VD is changed, all others are not. // ... if one of the others is changed, VD is not. if (IsVD) // VD is active, special logic applies { // State machine logic for VolumeDetect // More logic below bool phanReset = (IsPhantom != wasPhantom) && !IsPhantom; if (phanReset) // Phantom changes from on to off switch VD off too { IsVD = false; // Switch it of for the course of this routine VolumeDetectActive = false; // and also permanently if (PhysActor != null) PhysActor.VolumeDetect = false; // Let physics know about it too } else { IsPhantom = false; // If volumedetect is active we don't want phantom to be applied. // If this is a new call to VD out of the state "phantom" // this will also cause the prim to be visible to physics } } if (UsePhysics) { AddFlag(PrimFlags.Physics); if (!wasUsingPhysics) { DoPhysicsPropertyUpdate(UsePhysics, false); if (m_parentGroup != null) if (!m_parentGroup.IsDeleted) if (LocalId == m_parentGroup.RootPart.LocalId) m_parentGroup.CheckSculptAndLoad(); } if (PhysActor != null) { PhysActor.OnCollisionUpdate += PhysicsCollision; PhysActor.SubscribeEvents(1000); } } else { RemFlag(PrimFlags.Physics); if (wasUsingPhysics) DoPhysicsPropertyUpdate(UsePhysics, false); if (PhysActor != null) { PhysActor.UnSubscribeEvents(); PhysActor.OnCollisionUpdate -= PhysicsCollision; } } if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints { AddFlag(PrimFlags.Phantom); if (PhysActor != null) { m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); /// that's not wholesome. Had to make Scene public PhysActor = null; } } else // Not phantom { RemFlag(PrimFlags.Phantom); PhysicsObject pa = PhysActor; if (pa == null) { // It's not phantom anymore. So make sure the physics engine get's knowledge of it Vector3 tmp = GetWorldPosition(); Quaternion qtmp = GetWorldRotation(); PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( string.Format("{0}/{1}", Name, UUID), Shape, tmp, Scale, qtmp, UsePhysics, Density); pa = PhysActor; if (pa != null) { pa.LocalID = LocalId; pa.UUID = UUID; DoPhysicsPropertyUpdate(UsePhysics, true); if (m_parentGroup != null) { if (!m_parentGroup.IsDeleted) { if (LocalId == m_parentGroup.RootPart.LocalId) { m_parentGroup.CheckSculptAndLoad(); } } } PhysActor.OnCollisionUpdate += PhysicsCollision; PhysActor.SubscribeEvents(1000); } } else // it already has a physical representation { pa.IsPhysical = UsePhysics; DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim if (m_parentGroup != null) { if (!m_parentGroup.IsDeleted) { if (LocalId == m_parentGroup.RootPart.LocalId) { m_parentGroup.CheckSculptAndLoad(); } } } } } if (IsVD && IsVD != this.VolumeDetectActive) { // If the above logic worked (this is urgent candidate to unit tests!) // we now have a physicsactor. // Defensive programming calls for a check here. // Better would be throwing an exception that could be catched by a unit test as the internal // logic should make sure, this Physactor is always here. if (this.PhysActor != null) { PhysActor.VolumeDetect = true; AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active this.VolumeDetectActive = true; if(!PhysActor.SubscribedEvents()) { PhysActor.OnCollisionUpdate += PhysicsCollision; PhysActor.SubscribeEvents (1000); } } } else { if (IsVD != this.VolumeDetectActive) { // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like // (mumbles, well, at least if you have infinte CPU powers :-)) PhysicsObject pa = this.PhysActor; if (pa != null) { PhysActor.VolumeDetect = false; } this.VolumeDetectActive = false; } } if (IsTemporary) { AddFlag(PrimFlags.TemporaryOnRez); } else { RemFlag(PrimFlags.TemporaryOnRez); } // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); ParentGroup.HasGroupChanged = true; ScheduleUpdate(PrimUpdateFlags.PrimFlags); }