From a8322b7d4507328544f2f5abccfaf9f6f00cfba2 Mon Sep 17 00:00:00 2001 From: codeimp Date: Mon, 16 Aug 2010 17:53:28 +0000 Subject: [PATCH] @ Fixed a bug in the new way the Things are rendered Removed code that crashed the script editor and I had no better solution (it was unused code anyway) --- Source/Core/Controls/ScintillaControl.cs | 24 ++++++++++++---- Source/Core/Rendering/Renderer2D.cs | 36 +++++++++--------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Source/Core/Controls/ScintillaControl.cs b/Source/Core/Controls/ScintillaControl.cs index 599adc95..85863d19 100644 --- a/Source/Core/Controls/ScintillaControl.cs +++ b/Source/Core/Controls/ScintillaControl.cs @@ -2450,13 +2450,13 @@ namespace CodeImp.DoomBuilder.Controls break; case (uint)ScintillaEvents.UserlistSelection: - if(UserListSelection != null) - UserListSelection(this, scn.listType, System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text)); + //if(UserListSelection != null) + // UserListSelection(this, scn.listType, System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text)); break; case (uint)ScintillaEvents.UriDropped: - if(URIDropped != null) - URIDropped(this, System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text)); + //if(URIDropped != null) + // URIDropped(this, System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text)); break; case (uint)ScintillaEvents.DwellStart: @@ -2525,8 +2525,20 @@ namespace CodeImp.DoomBuilder.Controls if(BeforeDelete != null) BeforeDelete(this, scn.position, scn.length); - if(Modified != null) - Modified(this, scn.position, scn.modificationType, System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text), scn.length, scn.linesAdded, scn.line, scn.foldLevelNow, scn.foldLevelPrev); + if(Modified != null) + { + string textstr = null; + try + { + textstr = System.Runtime.InteropServices.Marshal.PtrToStringAuto(scn.text); + } + catch(IndexOutOfRangeException e) + { + // I don't know why this is happening, but I don't need the text here anyways + } + + Modified(this, scn.position, scn.modificationType, textstr, scn.length, scn.linesAdded, scn.line, scn.foldLevelNow, scn.foldLevelPrev); + } break; } diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index d82d7810..13c7b1a1 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -1000,6 +1000,7 @@ namespace CodeImp.DoomBuilder.Rendering { int thingtextureindex = 0; PixelColor tc; + DataStream stream; // Anything to render? if(things.Count > 0) @@ -1029,10 +1030,9 @@ namespace CodeImp.DoomBuilder.Rendering // Begin drawing graphics.Shaders.Things2D.Begin(); graphics.Shaders.Things2D.BeginPass(0); - - // Lock buffer + + // Determine next lock size int locksize = (things.Count > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : things.Count; - DataStream stream = thingsvertices.Lock(0, locksize * 12 * FlatVertex.Stride, LockFlags.Discard); FlatVertex[] verts = new FlatVertex[THING_BUFFER_SIZE * 12]; // Go for all things @@ -1050,38 +1050,30 @@ namespace CodeImp.DoomBuilder.Rendering // Buffer filled? if(buffercount == locksize) { - // Unlock buffer - stream.WriteRange(verts, 0, buffercount * 12); + // Write to buffer + stream = thingsvertices.Lock(0, locksize * 12 * FlatVertex.Stride, LockFlags.Discard); + stream.WriteRange(verts, 0, buffercount * 12); thingsvertices.Unlock(); stream.Dispose(); - stream = null; // Draw! graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 4); buffercount = 0; - // Do we need to continue drawing? - if(totalcount < things.Count) - { - // Lock buffer - locksize = ((things.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (things.Count - totalcount); - stream = thingsvertices.Lock(0, locksize * 12 * FlatVertex.Stride, LockFlags.Discard); - } + // Determine next lock size + locksize = ((things.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (things.Count - totalcount); } } + + // Write to buffer + stream = thingsvertices.Lock(0, locksize * 12 * FlatVertex.Stride, LockFlags.Discard); + if(buffercount > 0) stream.WriteRange(verts, 0, buffercount * 12); + thingsvertices.Unlock(); + stream.Dispose(); // Draw what's still remaining if(buffercount > 0) - { - // Unlock buffer - stream.WriteRange(verts, 0, buffercount * 12); - thingsvertices.Unlock(); - stream.Dispose(); - stream = null; - - // Draw! graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 4); - } // Done graphics.Shaders.Things2D.EndPass();