* By the time we hit set in BasePrim value and BasePrim are the same object
(libomv doesn't create a new object on update if it already knows about it)
* Back to keep track of hash codes, this time only on object update so
the impact is negligible
git-svn-id: https://radegast.googlecode.com/svn/trunk@1046
f7a694da-4d33-11de-9ad6-
1127a62b9fcd
#region Mouse handling\r
bool dragging = false;\r
int dragX, dragY, downX, downY;\r
#region Mouse handling\r
bool dragging = false;\r
int dragX, dragY, downX, downY;\r
- /// <summary>\r
- /// The camera doesn't move when ctrl-alt has been used, so don't move it if the user moves around\r
- /// </summary>\r
- private Vector3 lastCachedClientCameraPos = Vector3.Zero;\r
\r
private void glControl_MouseWheel(object sender, MouseEventArgs e)\r
{\r
\r
private void glControl_MouseWheel(object sender, MouseEventArgs e)\r
{\r
meshingsRequestedThisFrame++;\r
MeshPrim(obj);\r
}\r
meshingsRequestedThisFrame++;\r
MeshPrim(obj);\r
}\r
+ if (obj.Faces == null) continue;\r
+\r
obj.Step(lastFrameTime);\r
\r
if (!obj.PositionCalculated)\r
obj.Step(lastFrameTime);\r
\r
if (!obj.PositionCalculated)\r
foreach (RenderAvatar obj in Avatars.Values)\r
{\r
if (!obj.Initialized) obj.Initialize();\r
foreach (RenderAvatar obj in Avatars.Values)\r
{\r
if (!obj.Initialized) obj.Initialize();\r
- obj.Step(lastFrameTime);\r
+ if (AvatarRenderingEnabled) obj.Step(lastFrameTime);\r
PrimPosAndRot(obj, out obj.RenderPosition, out obj.RenderRotation);\r
obj.DistanceSquared = Vector3.DistanceSquared(Camera.RenderPosition, obj.RenderPosition);\r
obj.PositionCalculated = true;\r
PrimPosAndRot(obj, out obj.RenderPosition, out obj.RenderRotation);\r
obj.DistanceSquared = Vector3.DistanceSquared(Camera.RenderPosition, obj.RenderPosition);\r
obj.PositionCalculated = true;\r
meshingsRequestedThisFrame++;\r
MeshPrim(obj);\r
}\r
meshingsRequestedThisFrame++;\r
MeshPrim(obj);\r
}\r
+ if (obj.Faces == null) continue;\r
+\r
obj.Step(lastFrameTime);\r
\r
if (!obj.PositionCalculated)\r
obj.Step(lastFrameTime);\r
\r
if (!obj.PositionCalculated)\r
\r
public class RenderPrimitive : SceneObject\r
{\r
\r
public class RenderPrimitive : SceneObject\r
{\r
+ #region Public fields\r
public Primitive Prim;\r
public List<Face> Faces;\r
/// <summary>Is this object attached to an avatar</summary>\r
public Primitive Prim;\r
public List<Face> Faces;\r
/// <summary>Is this object attached to an avatar</summary>\r
public bool Meshed;\r
/// <summary>Process of creating a mesh is underway</summary>\r
public bool Meshing;\r
public bool Meshed;\r
/// <summary>Process of creating a mesh is underway</summary>\r
public bool Meshing;\r
+ #endregion Public fields\r
+\r
+ #region Private fields\r
+ int prevTEHash;\r
+ int prevSculptHash;\r
+ int prevShapeHash;\r
+ #endregion Private fields\r
\r
public RenderPrimitive()\r
{\r
\r
public RenderPrimitive()\r
{\r
public override Primitive BasePrim\r
{\r
get { return Prim; }\r
public override Primitive BasePrim\r
{\r
get { return Prim; }\r
+ Prim = value;\r
+\r
+ int TEHash = Prim.Textures == null ? 0 : Prim.Textures.GetHashCode();\r
+ int sculptHash, shapeHash;\r
+\r
+ if (Meshed)\r
- if(Prim.Type == PrimType.Sculpt || Prim.Type == PrimType.Mesh)\r
+ if (Prim.Type == PrimType.Sculpt || Prim.Type == PrimType.Mesh)\r
- if(!Prim.Sculpt.Equals(value.Sculpt) || !Prim.Textures.Equals(value.Textures))\r
+ sculptHash = Prim.Sculpt.GetHashCode();\r
+ if (Prim.Sculpt.GetHashCode() != prevSculptHash || TEHash != prevTEHash)\r
+ prevSculptHash = sculptHash;\r
- if(!Prim.PrimData.Equals(value.PrimData))\r
+ shapeHash = Prim.PrimData.GetHashCode();\r
+ if (shapeHash != prevShapeHash)\r
- else if(!Prim.Textures.Equals(value.Textures))\r
+ else if (TEHash != prevTEHash)\r
+ prevShapeHash = shapeHash;\r
- public static class Render\r
- {\r
- public static IRendering Plugin;\r
- }\r
-\r
public static class RHelp\r
{\r
public static readonly Vector3 InvalidPosition = new Vector3(99999f, 99999f, 99999f);\r
public static class RHelp\r
{\r
public static readonly Vector3 InvalidPosition = new Vector3(99999f, 99999f, 99999f);\r
public skeleton()\r
{\r
\r
public skeleton()\r
{\r
\r
\r
mBones = new Dictionary<string, Bone>();\r
\r
\r
mBones = new Dictionary<string, Bone>();\r
\r
\r
// Add animations to the global decoded list\r
// TODO garbage collect unused animations somehow\r
\r
// Add animations to the global decoded list\r
// TODO garbage collect unused animations somehow\r
- public static void addanimation(OpenMetaverse.Assets.Asset asset,UUID tid, BinBVHAnimationReader b)\r
+ public static void addanimation(OpenMetaverse.Assets.Asset asset, UUID tid, BinBVHAnimationReader b)\r
{\r
RenderAvatar av;\r
mAnimationTransactions.TryGetValue(tid, out av);\r
{\r
RenderAvatar av;\r
mAnimationTransactions.TryGetValue(tid, out av);\r
mAnimationCache[asset.AssetID] = b;\r
Logger.Log("Adding new decoded animaton known animations " + asset.AssetID.ToString(), Helpers.LogLevel.Info);\r
}\r
mAnimationCache[asset.AssetID] = b;\r
Logger.Log("Adding new decoded animaton known animations " + asset.AssetID.ToString(), Helpers.LogLevel.Info);\r
}\r
foreach (binBVHJoint joint in b.joints)\r
{\r
binBVHJointState state;\r
foreach (binBVHJoint joint in b.joints)\r
{\r
binBVHJointState state;\r
\r
if (b.Loop == true)\r
{\r
\r
if (b.Loop == true)\r
{\r
- int frame=0;\r
- foreach( binBVHJointKey key in joint.rotationkeys)\r
+ int frame = 0;\r
+ foreach (binBVHJointKey key in joint.rotationkeys)\r
{\r
if (key.time == b.InPoint)\r
{\r
{\r
if (key.time == b.InPoint)\r
{\r
{\r
mPriority.Clear();\r
\r
{\r
mPriority.Clear();\r
\r
- lock(mAnimations)\r
- foreach (BinBVHAnimationReader b in mAnimations) \r
+ lock (mAnimations)\r
+ foreach (BinBVHAnimationReader b in mAnimations)\r
{\r
if (b == null)\r
continue;\r
\r
{\r
if (b == null)\r
continue;\r
\r
- int jpos = 0;\r
- foreach (binBVHJoint joint in b.joints)\r
+ int jpos = 0;\r
+ foreach (binBVHJoint joint in b.joints)\r
+ {\r
+ int prio = 0;\r
+\r
+ //Quick hack to stack animations in the correct order\r
+ //TODO we need to do this per joint as they all have their own priorities as well ;-(\r
+ if (mPriority.TryGetValue(joint.Name, out prio))\r
- int prio=0;\r
- \r
- //Quick hack to stack animations in the correct order\r
- //TODO we need to do this per joint as they all have their own priorities as well ;-(\r
- if (mPriority.TryGetValue(joint.Name, out prio))\r
- {\r
- if (prio > b.Priority)\r
- continue;\r
- }\r
+ if (prio > b.Priority)\r
+ continue;\r
+ }\r
- mPriority[joint.Name] = b.Priority;\r
- \r
- binBVHJointState state = (binBVHJointState) b.joints[jpos].Tag;\r
+ mPriority[joint.Name] = b.Priority;\r
- state.currenttime_rot += lastframetime;\r
- state.currenttime_pos += lastframetime;\r
+ binBVHJointState state = (binBVHJointState)b.joints[jpos].Tag;\r
- //fudge\r
- if (b.joints[jpos].rotationkeys.Length == 1)\r
- {\r
- state.nextkeyframe_rot = 0;\r
- }\r
+ state.currenttime_rot += lastframetime;\r
+ state.currenttime_pos += lastframetime;\r
- Vector3 poslerp = Vector3.Zero;\r
+ //fudge\r
+ if (b.joints[jpos].rotationkeys.Length == 1)\r
+ {\r
+ state.nextkeyframe_rot = 0;\r
+ }\r
- if (b.joints[jpos].positionkeys.Length > 2)\r
- {\r
- binBVHJointKey pos2 = b.joints[jpos].positionkeys[state.nextkeyframe_pos];\r
+ Vector3 poslerp = Vector3.Zero;\r
+ if (b.joints[jpos].positionkeys.Length > 2)\r
+ {\r
+ binBVHJointKey pos2 = b.joints[jpos].positionkeys[state.nextkeyframe_pos];\r
- if (state.currenttime_pos > pos2.time)\r
- {\r
- state.lastkeyframe_pos++;\r
- state.nextkeyframe_pos++;\r
- if (state.nextkeyframe_pos >= b.joints[jpos].positionkeys.Length || (state.nextkeyframe_pos >=state.loopoutframe && b.Loop==true))\r
+ if (state.currenttime_pos > pos2.time)\r
+ {\r
+ state.lastkeyframe_pos++;\r
+ state.nextkeyframe_pos++;\r
+\r
+ if (state.nextkeyframe_pos >= b.joints[jpos].positionkeys.Length || (state.nextkeyframe_pos >= state.loopoutframe && b.Loop == true))\r
+ {\r
+ if (b.Loop == true)\r
- if (b.Loop == true)\r
- {\r
- state.nextkeyframe_pos = state.loopinframe;\r
- state.currenttime_pos = b.InPoint;\r
+ state.nextkeyframe_pos = state.loopinframe;\r
+ state.currenttime_pos = b.InPoint;\r
- if (state.lastkeyframe_pos >= b.joints[jpos].positionkeys.Length)\r
- {\r
- state.lastkeyframe_pos = state.loopinframe;\r
- }\r
- }\r
- else\r
+ if (state.lastkeyframe_pos >= b.joints[jpos].positionkeys.Length)\r
- state.nextkeyframe_pos = joint.positionkeys.Length - 1;\r
+ state.lastkeyframe_pos = state.loopinframe;\r
+ else\r
+ {\r
+ state.nextkeyframe_pos = joint.positionkeys.Length - 1;\r
+ }\r
+ }\r
- if (state.lastkeyframe_pos >= b.joints[jpos].positionkeys.Length)\r
+\r
+ if (state.lastkeyframe_pos >= b.joints[jpos].positionkeys.Length)\r
+ {\r
+ if (b.Loop == true)\r
- if (b.Loop == true)\r
- {\r
- state.lastkeyframe_pos = 0;\r
- state.currenttime_pos = 0;\r
+ state.lastkeyframe_pos = 0;\r
+ state.currenttime_pos = 0;\r
- }\r
- else\r
- {\r
- state.lastkeyframe_pos = joint.positionkeys.Length - 1;\r
- if (state.lastkeyframe_pos < 0)//eeww\r
- state.lastkeyframe_pos = 0; \r
- }\r
+ }\r
+ else\r
+ {\r
+ state.lastkeyframe_pos = joint.positionkeys.Length - 1;\r
+ if (state.lastkeyframe_pos < 0)//eeww\r
+ state.lastkeyframe_pos = 0;\r
- binBVHJointKey pos = b.joints[jpos].positionkeys[state.lastkeyframe_pos];\r
+ binBVHJointKey pos = b.joints[jpos].positionkeys[state.lastkeyframe_pos];\r
- float delta = (pos2.time - pos.time) / ((state.currenttime_pos) - (pos.time - b.joints[jpos].positionkeys[0].time));\r
+ float delta = (pos2.time - pos.time) / ((state.currenttime_pos) - (pos.time - b.joints[jpos].positionkeys[0].time));\r
- if (delta < 0)\r
- delta = 0;\r
+ if (delta < 0)\r
+ delta = 0;\r
- if (delta > 1)\r
- delta = 1;\r
+ if (delta > 1)\r
+ delta = 1;\r
- poslerp = Vector3.Lerp(pos.key_element, pos2.key_element, delta) *-1;\r
+ poslerp = Vector3.Lerp(pos.key_element, pos2.key_element, delta) * -1;\r
- Vector3 rotlerp = Vector3.Zero;\r
- if (b.joints[jpos].rotationkeys.Length > 0)\r
+ Vector3 rotlerp = Vector3.Zero;\r
+ if (b.joints[jpos].rotationkeys.Length > 0)\r
+ {\r
+ binBVHJointKey rot2 = b.joints[jpos].rotationkeys[state.nextkeyframe_rot];\r
+\r
+ if (state.currenttime_rot > rot2.time)\r
- binBVHJointKey rot2 = b.joints[jpos].rotationkeys[state.nextkeyframe_rot];\r
+ state.lastkeyframe_rot++;\r
+ state.nextkeyframe_rot++;\r
- if (state.currenttime_rot > rot2.time)\r
+ if (state.nextkeyframe_rot >= b.joints[jpos].rotationkeys.Length || (state.nextkeyframe_rot >= state.loopoutframe && b.Loop == true))\r
- state.lastkeyframe_rot++;\r
- state.nextkeyframe_rot++;\r
-\r
- if (state.nextkeyframe_rot >= b.joints[jpos].rotationkeys.Length || (state.nextkeyframe_rot >= state.loopoutframe && b.Loop == true))\r
+ state.nextkeyframe_rot = state.loopinframe;\r
+ state.currenttime_rot = b.InPoint;\r
+\r
+ if (state.lastkeyframe_rot >= b.joints[jpos].rotationkeys.Length)\r
- state.nextkeyframe_rot = state.loopinframe;\r
- state.currenttime_rot = b.InPoint;\r
+ state.lastkeyframe_rot = state.loopinframe;\r
- if (state.lastkeyframe_rot >= b.joints[jpos].rotationkeys.Length)\r
- {\r
- state.lastkeyframe_rot = state.loopinframe;\r
- \r
- \r
- }\r
- else\r
- {\r
- state.nextkeyframe_rot = joint.rotationkeys.Length - 1;\r
- }\r
+\r
+ }\r
+ else\r
+ {\r
+ state.nextkeyframe_rot = joint.rotationkeys.Length - 1;\r
- if (state.lastkeyframe_rot >= b.joints[jpos].rotationkeys.Length)\r
+ if (state.lastkeyframe_rot >= b.joints[jpos].rotationkeys.Length)\r
+ {\r
+ if (b.Loop == true)\r
- if (b.Loop == true)\r
- {\r
- state.lastkeyframe_rot = 0;\r
- state.currenttime_rot = 0;\r
+ state.lastkeyframe_rot = 0;\r
+ state.currenttime_rot = 0;\r
- }\r
- else\r
- {\r
- state.lastkeyframe_rot = joint.rotationkeys.Length - 1;\r
- }\r
+ }\r
+ else\r
+ {\r
+ state.lastkeyframe_rot = joint.rotationkeys.Length - 1;\r
- \r
- binBVHJointKey rot = b.joints[jpos].rotationkeys[state.lastkeyframe_rot];\r
- rot2 = b.joints[jpos].rotationkeys[state.nextkeyframe_rot];\r
- float deltarot = (rot2.time - rot.time) / ((state.currenttime_rot) - (rot.time - b.joints[jpos].rotationkeys[0].time));\r
+ binBVHJointKey rot = b.joints[jpos].rotationkeys[state.lastkeyframe_rot];\r
+ rot2 = b.joints[jpos].rotationkeys[state.nextkeyframe_rot];\r
- \r
- if (deltarot < 0)\r
- deltarot = 0;\r
+ float deltarot = (rot2.time - rot.time) / ((state.currenttime_rot) - (rot.time - b.joints[jpos].rotationkeys[0].time));\r
- if (deltarot > 1)\r
- deltarot = 1;\r
- rotlerp = Vector3.Lerp(rot.key_element, rot2.key_element, deltarot);\r
+ if (deltarot < 0)\r
+ deltarot = 0;\r
+ if (deltarot > 1)\r
+ deltarot = 1;\r
- b.joints[jpos].Tag = (object)state;\r
- \r
- deformbone(joint.Name, poslerp, new Vector3(0, 0, 0), new Quaternion(rotlerp.X, rotlerp.Y, rotlerp.Z));\r
+ rotlerp = Vector3.Lerp(rot.key_element, rot2.key_element, deltarot);\r
- mNeedsMeshRebuild = true;\r
+ b.joints[jpos].Tag = (object)state;\r
+\r
+ deformbone(joint.Name, poslerp, new Vector3(0, 0, 0), new Quaternion(rotlerp.X, rotlerp.Y, rotlerp.Z));\r
+\r
+ jpos++;\r
+ mNeedsMeshRebuild = true;\r
+ }\r
+\r
mNeedsUpdate = false;\r
}\r
}\r
mNeedsUpdate = false;\r
}\r
}\r
Vector3 mepre = pos * scale;\r
mepre = mepre * totalrot;\r
mTotalPos = parento + mepre;\r
Vector3 mepre = pos * scale;\r
mepre = mepre * totalrot;\r
mTotalPos = parento + mepre;\r
Vector3 orig = getOrigOffset();\r
mDeltaPos = mTotalPos - orig;\r
\r
Vector3 orig = getOrigOffset();\r
mDeltaPos = mTotalPos - orig;\r
\r
mDeltaPos = mTotalPos - orig;\r
posdirty = false;\r
return mTotalPos;\r
mDeltaPos = mTotalPos - orig;\r
posdirty = false;\r
return mTotalPos;\r
\r
public int readblock(byte[] blockdata, int offset)\r
{\r
\r
public int readblock(byte[] blockdata, int offset)\r
{\r
- \r
- BitPack input = new BitPack(blockdata, offset);\r
- mLocation = input.UnpackInt();\r
- mLength = input.UnpackInt();\r
- mAccessTime = input.UnpackInt();\r
- mFileID = input.UnpackUUID();\r
- int filetype = input.UnpackShort();\r
- mAssetType = (AssetType)filetype;\r
- mSize = input.UnpackInt();\r
- offset += 34;\r
- Logger.Log(String.Format("Found header for {0} type {1} length {2} at {3}", mFileID, mAssetType, mSize, mLocation),Helpers.LogLevel.Info);\r
- \r
- return offset;\r
+ BitPack input = new BitPack(blockdata, offset);\r
+ mLocation = input.UnpackInt();\r
+ mLength = input.UnpackInt();\r
+ mAccessTime = input.UnpackInt();\r
+ mFileID = input.UnpackUUID();\r
+ int filetype = input.UnpackShort();\r
+ mAssetType = (AssetType)filetype;\r
+ mSize = input.UnpackInt();\r
+ offset += 34;\r
+\r
+ Logger.Log(String.Format("Found header for {0} type {1} length {2} at {3}", mFileID, mAssetType, mSize, mLocation), Helpers.LogLevel.Info);\r
+\r
+ return offset;\r
datastream = File.Open(datafile, FileMode.Open);\r
indexstream = File.Open(indexfile, FileMode.Open);\r
\r
datastream = File.Open(datafile, FileMode.Open);\r
indexstream = File.Open(indexfile, FileMode.Open);\r
\r
\r
byte[] blockdata = new byte[indexstream.Length];\r
indexstream.Read(blockdata, 0, (int)indexstream.Length);\r
\r
byte[] blockdata = new byte[indexstream.Length];\r
indexstream.Read(blockdata, 0, (int)indexstream.Length);\r
VFSblock block = new VFSblock();\r
offset = block.readblock(blockdata, offset);\r
\r
VFSblock block = new VFSblock();\r
offset = block.readblock(blockdata, offset);\r
\r
- FileStream writer = File.Open(OpenMetaverse.Settings.RESOURCE_DIR+System.IO.Path.DirectorySeparatorChar+block.mFileID.ToString(),FileMode.Create);\r
+ FileStream writer = File.Open(OpenMetaverse.Settings.RESOURCE_DIR + System.IO.Path.DirectorySeparatorChar + block.mFileID.ToString(), FileMode.Create);\r
byte[] data = new byte[block.mSize];\r
datastream.Seek(block.mLocation, SeekOrigin.Begin);\r
datastream.Read(data, 0, block.mSize);\r
writer.Write(data, 0, block.mSize);\r
writer.Close();\r
}\r
byte[] data = new byte[block.mSize];\r
datastream.Seek(block.mLocation, SeekOrigin.Begin);\r
datastream.Read(data, 0, block.mSize);\r
writer.Write(data, 0, block.mSize);\r
writer.Close();\r
}\r
}\r
}\r
}
\ No newline at end of file
}\r
}\r
}
\ No newline at end of file