// Textures
objectupdate.Textures = new TextureEntry(block.TextureEntry, 0,
block.TextureEntry.length);
onObjectDataBlockUpdate.raiseEvent(new ObjectDataBlockUpdateEventArgs(simulator, prim, data, block, objectupdate, nameValues));
//region Update Prim Info with decoded data
prim.Flags = block.UpdateFlags;
//JLogger.debug("Block UpdateFlags: " + block.UpdateFlags + Utils.bytesToHexDebugString(Utils.int64ToBytes(block.UpdateFlags), ""));
if ((prim.Flags & PrimFlags.ZlibCompressed.getIndex()) != 0)
{
JLogger.warn("Got a ZlibCompressed ObjectUpdate, implement me!");
continue;
}
// Automatically request ObjectProperties for prim if it was rezzed selected.
if (( prim.Flags & PrimFlags.CreateSelected.getIndex()) != 0)
{
SelectObject(simulator, prim.LocalID);
}
prim.NameValues = nameValues;
prim.LocalID = block.ID;
prim.ID = block.FullID;
prim.ParentID = block.ParentID;
prim.RegionHandle = update.RegionData.RegionHandle;
prim.Scale = block.Scale;
prim.ClickAction = ClickAction.get(block.ClickAction);
prim.OwnerID = block.OwnerID;
prim.MediaURL = Utils.bytesWithTrailingNullByteToString(block.MediaURL);
prim.Text = Utils.bytesWithTrailingNullByteToString(block.Text);
prim.TextColor = new Color4(block.TextColor, 0, false, true);
prim.IsAttachment = attachment;
// Sound information
prim.Sound = block.Sound;
prim.SoundFlags = block.Flags;
prim.SoundGain = block.Gain;
prim.SoundRadius = block.Radius;
// Joint information
prim.Joint = JointType.get(block.JointType);
prim.JointPivot = block.JointPivot;
prim.JointAxisOrAnchor = block.JointAxisOrAnchor;
// Object parameters
prim.PrimData = data;
// Textures, texture animations, particle system, and extra params
prim.Textures = objectupdate.Textures;
prim.TextureAnim = new TextureAnimation(block.TextureAnim, 0);
//FIXME need to fix the following exception
try{
prim.ParticleSys = new ParticleSystem(block.PSBlock, 0);
}
catch(Exception ex)
{
JLogger.warn("Error while decoding ParticleSystem from packet: "
+ Utils.getExceptionStackTraceAsString(ex));
}
prim.SetExtraParamsFromBytes(block.ExtraParams, 0);
// PCode-specific data
switch (pcode)
{
case Grass:
case Tree:
case NewTree:
if (block.Data.length == 1)
prim.TreeSpecies = Tree.get(block.Data[0]);
else
JLogger.warn("Got a foliage update with an invalid TreeSpecies field");
// prim.ScratchPad = Utils.EmptyBytes;
// break;
//default:
// prim.ScratchPad = new byte[block.Data.Length];
// if (block.Data.Length > 0)
// Buffer.BlockCopy(block.Data, 0, prim.ScratchPad, 0, prim.ScratchPad.Length);
break;
}
prim.ScratchPad = Utils.EmptyBytes;
// Packed parameters
prim.CollisionPlane = objectupdate.CollisionPlane;
prim.Position = objectupdate.Position;
prim.Velocity = objectupdate.Velocity;
prim.Acceleration = objectupdate.Acceleration;
prim.Rotation = objectupdate.Rotation;
prim.AngularVelocity = objectupdate.AngularVelocity;
JLogger.debug("Primitive " + prim.LocalID + " Position " + prim.Position.toString());
//endregion
final boolean isNewObject2 = isNewObject;
// EventHandler<PrimEventArgs> handler = m_ObjectUpdate;
if (onObjectUpdate != null)
{
final boolean attachment2 = attachment;
threadPool.execute(new Runnable(){
public void run()
{
onObjectUpdate.raiseEvent(new PrimEventArgs(simulator, prim, update.RegionData.TimeDilation, isNewObject2, attachment2));
}
});
// ThreadPool.QueueUserWorkItem(delegate(object o)
// { handler(this, new PrimEventArgs(simulator, prim, update.RegionData.TimeDilation, isNewObject, attachment)); });
}
break;
//endregion Prim and Foliage
//region Avatar
case Avatar:
boolean isNewAvatar;
// lock (simulator.ObjectsAvatars.Dictionary)
isNewAvatar = !simulator.ObjectsAvatars.containsKey(block.ID);
if(block.FullID.equals(UUID.Zero))
JLogger.warn(String.format("Received Avatar with Zero ID PCcode %d LocalID %d", block.PCode, block.ID));
// Update some internals if this is our avatar
if (block.FullID.equals(Client.self.getAgentID()) && simulator.equals(Client.network.getCurrentSim()))
{
//region Update Client.Self
// We need the local ID to recognize terse updates for our agent
Client.self.setLocalID(block.ID);
// Packed parameters
Client.self.setCollisionPlane(objectupdate.CollisionPlane);
Client.self.setRelativePosition(objectupdate.Position);
Client.self.setVelocity(objectupdate.Velocity);
Client.self.setAcceleration(objectupdate.Acceleration);
Client.self.setRelativeRotation(objectupdate.Rotation);
Client.self.setAngularVelocity(objectupdate.AngularVelocity);
//endregion
}
//region Create an Avatar from the decoded data
Avatar avatar = GetAvatar(simulator, block.ID, block.FullID);
objectupdate.Avatar = true;
// Textures
objectupdate.Textures = new TextureEntry(block.TextureEntry, 0,
block.TextureEntry.length);
onObjectDataBlockUpdate.raiseEvent(new ObjectDataBlockUpdateEventArgs(simulator, avatar, data, block, objectupdate, nameValues));
long oldSeatID = avatar.ParentID;
avatar.ID = block.FullID;
avatar.LocalID = block.ID;