From: Latif Khalifa Date: Sun, 10 Jul 2011 19:53:05 +0000 (+0000) Subject: Added RenderPrimite to replace faceted mesh. X-Git-Tag: 2.8~404 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=cabed154be2833d56755746b53eedb978d1cb52d;p=radegast%2Fradegast.git Added RenderPrimite to replace faceted mesh. git-svn-id: https://radegast.googlecode.com/svn/trunk@967 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- diff --git a/Radegast/GUI/Rendering/Rendering.cs b/Radegast/GUI/Rendering/Rendering.cs index 4083714..8337bba 100644 --- a/Radegast/GUI/Rendering/Rendering.cs +++ b/Radegast/GUI/Rendering/Rendering.cs @@ -81,8 +81,8 @@ namespace Radegast.Rendering /// /// List of prims in the scene /// - Dictionary Prims = new Dictionary(); - + Dictionary Prims = new Dictionary(); + List SortedPrims; Dictionary Avatars = new Dictionary(); #endregion Public fields @@ -109,7 +109,6 @@ namespace Radegast.Rendering double lastFrameTime = 0d; double advTimerTick = 0d; float minLODFactor = 0.005f; - float timeToFocus = 0.3f; float[] lightPos = new float[] { 128f, 128f, 5000f, 0f }; float ambient = 0.26f; @@ -899,7 +898,7 @@ namespace Radegast.Rendering } else { - FacetedMesh parent; + RenderPrimitive parent; RenderAvatar parentav; if (Prims.TryGetValue(prim.ParentID, out parent)) { @@ -1012,7 +1011,7 @@ namespace Radegast.Rendering lock (Prims) { int primNr = 0; - foreach (FacetedMesh mesh in Prims.Values) + foreach (RenderPrimitive mesh in Prims.Values) { primNr++; Primitive prim = mesh.Prim; @@ -1556,11 +1555,11 @@ namespace Radegast.Rendering GL.EnableClientState(ArrayCap.NormalArray); int primNr = 0; - foreach (FacetedMesh mesh in Prims.Values) + foreach (RenderPrimitive mesh in Prims.Values) { primNr++; Primitive prim = mesh.Prim; - FacetedMesh parent = null; + RenderPrimitive parent = null; RenderAvatar parentav = null; if (prim.ParentID != 0 && !Prims.TryGetValue(prim.ParentID, out parent) && !Avatars.TryGetValue(prim.ParentID, out parentav)) continue; @@ -2036,9 +2035,9 @@ namespace Radegast.Rendering } } - private void MeshPrim(Primitive prim, FacetedMesh mesh) + private void MeshPrim(Primitive prim, RenderPrimitive mesh) { - FacetedMesh existingMesh = null; + RenderPrimitive existingMesh = null; lock (Prims) { @@ -2127,7 +2126,7 @@ namespace Radegast.Rendering ) { FaceData existingData = (FaceData)existingMesh.Faces[j].UserData; - data.TextureInfo.TexturePointer = existingData.TextureInfo.TexturePointer; + data.TextureInfo = existingData.TextureInfo; } else { @@ -2165,7 +2164,11 @@ namespace Radegast.Rendering // Regular prim if (prim.Sculpt == null || prim.Sculpt.SculptTexture == UUID.Zero) { - MeshPrim(prim, renderer.GenerateFacetedMesh(prim, DetailLevel.High)); + FacetedMesh mesh = renderer.GenerateFacetedMesh(prim, DetailLevel.High); + RenderPrimitive rPrim = new RenderPrimitive(); + rPrim.Faces = mesh.Faces; + rPrim.Prim = prim; + MeshPrim(prim, rPrim); } else { @@ -2223,7 +2226,10 @@ namespace Radegast.Rendering if (mesh != null) { - MeshPrim(prim, mesh); + RenderPrimitive rPrim = new RenderPrimitive(); + rPrim.Faces = mesh.Faces; + rPrim.Prim = prim; + MeshPrim(prim, rPrim); } } catch diff --git a/Radegast/GUI/Rendering/RenderingHelpers.cs b/Radegast/GUI/Rendering/RenderingHelpers.cs index 3142a26..c2f352a 100644 --- a/Radegast/GUI/Rendering/RenderingHelpers.cs +++ b/Radegast/GUI/Rendering/RenderingHelpers.cs @@ -26,6 +26,8 @@ namespace Radegast.Rendering public BoundingSphere BoundingSphere = new BoundingSphere(); public static int VertexSize = 32; // sizeof (vertex), 2 x vector3 + 1 x vector2 = 8 floats x 4 bytes = 32 bytes public TextureAnimationInfo AnimInfo; + public bool Occluded = false; + public int QueryID = 0; public void CheckVBO(Face face) { @@ -279,6 +281,29 @@ namespace Radegast.Rendering Alpha } + public class RenderPrimitive : IComparable, IDisposable + { + public Primitive Prim; + public List Faces; + public float DistanceSquared; + public BoundingSphere Bounding; + + public virtual void Dispose() + { + } + + public virtual int CompareTo(object other) + { + RenderPrimitive o = (RenderPrimitive)other; + if (this.DistanceSquared < o.DistanceSquared) + return -1; + else if (this.DistanceSquared > o.DistanceSquared) + return 1; + else + return 0; + } + } + public static class Render { public static IRendering Plugin;