boolean isNew;
// lock (simulator.ObjectsPrimitives.Dictionary)
isNew = simulator.ObjectsPrimitives.containsKey(LocalID);
Primitive prim = GetPrimitive(simulator, LocalID, FullID);
prim.LocalID = LocalID;
prim.ID = FullID;
prim.Flags = block.UpdateFlags;
prim.PrimData.PCode = pcode;
//region Decode block and update Prim
// State
prim.PrimData.State = block.Data[i++];
// CRC
i += 4;
// Material
prim.PrimData.Material = Material.get(block.Data[i++]);
// Click action
prim.ClickAction = ClickAction.get(block.Data[i++]);
// Scale
prim.Scale = new Vector3(block.Data, i);
i += 12;
// Position
prim.Position = new Vector3(block.Data, i);
i += 12;
// Rotation
prim.Rotation = new Quaternion(block.Data, i, true);
i += 12;
// Compressed flags
//EnumSet<CompressedFlags>
long flags = Utils.bytesToUIntLit(block.Data, i);
i += 4;
prim.OwnerID = new UUID(block.Data, i);
i += 16;
// Angular velocity
if ((flags & CompressedFlags.HasAngularVelocity.getIndex()) != 0)
{
prim.AngularVelocity = new Vector3(block.Data, i);
i += 12;
}
// Parent ID
if ((flags & CompressedFlags.HasParent.getIndex()) != 0)
{
// prim.ParentID = (uint)(block.Data[i++] + (block.Data[i++] << 8) +
// (block.Data[i++] << 16) + (block.Data[i++] << 24));
prim.ParentID = Utils.bytesToUIntLit(block.Data, i); i += 4;
}
else
{
prim.ParentID = 0;
}
// Tree data
if ((flags & CompressedFlags.Tree.getIndex()) != 0)
{
prim.TreeSpecies = Tree.get(block.Data[i++]);
//prim.ScratchPad = Utils.EmptyBytes;
}
// Scratch pad
else if ((flags & CompressedFlags.ScratchPad.getIndex()) != 0)
{
prim.TreeSpecies = Tree.get((byte)0);
int size = block.Data[i++];
//prim.ScratchPad = new byte[size];
//Buffer.BlockCopy(block.Data, i, prim.ScratchPad, 0, size);
i += size;
}
prim.ScratchPad = Utils.EmptyBytes;
// Floating text
if ((flags & CompressedFlags.HasText.getIndex()) != 0)
{
String text = "";
while (block.Data[i] != 0)
{
text += (char)block.Data[i];
i++;
}
i++;
// Floating text
prim.Text = text;
// Text color
prim.TextColor = new Color4(block.Data, i, false);
i += 4;
}
else
{
prim.Text = "";
}
// Media URL
if ((flags & CompressedFlags.MediaURL.getIndex()) != 0)
{
String text = "";
while (block.Data[i] != 0)
{
text += (char)block.Data[i];
i++;
}
i++;
prim.MediaURL = text;
}
// Particle system
if ((flags & CompressedFlags.HasParticles.getIndex()) != 0)
{
prim.ParticleSys = new ParticleSystem(block.Data, i);
i += 86;
}
// Extra parameters
i += prim.SetExtraParamsFromBytes(block.Data, i);
//Sound data
if ((flags & CompressedFlags.HasSound.getIndex()) != 0)
{
prim.Sound = new UUID(block.Data, i);