Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ PlatformRenderBatch()

unsafe void Microsoft.Xna.Framework.Graphics.SpriteBatch.PlatformRenderBatch ( Texture2D texture,
SpriteInfo[] sprites,
int offset,
int count )
inlineprivate

Definition at line 208 of file SpriteBatch.cs.

209 {
210 float num = 1f / (float)texture.Width;
211 float num2 = 1f / (float)texture.Height;
212 while (count > 0)
213 {
215 int num3 = count;
216 if (num3 > 2048 - vertexBufferPosition)
217 {
218 num3 = 2048 - vertexBufferPosition;
219 if (num3 < 256)
220 {
222 options = SetDataOptions.Discard;
223 num3 = count;
224 if (num3 > 2048)
225 {
226 num3 = 2048;
227 }
228 }
229 }
230 fixed (SpriteInfo* ptr = &sprites[offset])
231 {
232 fixed (VertexPositionColorTexture* ptr3 = &outputVertices[0])
233 {
234 SpriteInfo* ptr2 = ptr;
235 VertexPositionColorTexture* ptr4 = ptr3;
236 for (int i = 0; i < num3; i++)
237 {
238 float num4;
239 float num5;
240 if (ptr2->Rotation != 0f)
241 {
242 num4 = (float)Math.Cos(ptr2->Rotation);
243 num5 = (float)Math.Sin(ptr2->Rotation);
244 }
245 else
246 {
247 num4 = 1f;
248 num5 = 0f;
249 }
250 float num6 = ((ptr2->Source.Z != 0f) ? (ptr2->Origin.X / ptr2->Source.Z) : (ptr2->Origin.X * 2E+32f));
251 float num7 = ((ptr2->Source.W != 0f) ? (ptr2->Origin.Y / ptr2->Source.W) : (ptr2->Origin.Y * 2E+32f));
252 for (int j = 0; j < 4; j++)
253 {
254 float num8 = xCornerOffsets[j];
255 float num9 = yCornerOffsets[j];
256 float num10 = (num8 - num6) * ptr2->Destination.Z;
257 float num11 = (num9 - num7) * ptr2->Destination.W;
258 float x = ptr2->Destination.X + num10 * num4 - num11 * num5;
259 float y = ptr2->Destination.Y + num10 * num5 + num11 * num4;
260 if ((ptr2->Effects & SpriteEffects.FlipHorizontally) != 0)
261 {
262 num8 = 1f - num8;
263 }
264 if ((ptr2->Effects & SpriteEffects.FlipVertically) != 0)
265 {
266 num9 = 1f - num9;
267 }
268 ptr4->Position.X = x;
269 ptr4->Position.Y = y;
270 ptr4->Position.Z = ptr2->Depth;
271 ptr4->Color = ptr2->Color;
272 ptr4->TextureCoordinate.X = (ptr2->Source.X + num8 * ptr2->Source.Z) * num;
273 ptr4->TextureCoordinate.Y = (ptr2->Source.Y + num9 * ptr2->Source.W) * num2;
274 ptr4++;
275 }
276 ptr2++;
277 }
278 }
279 }
280 int num12 = sizeof(VertexPositionColorTexture);
284 int numVertices = num3 * 4;
286 int primitiveCount = num3 * 2;
287 _parent.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, minVertexIndex, numVertices, startIndex, primitiveCount);
289 offset += num3;
290 count -= num3;
291 }
292 }
unsafe void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
VertexPositionColorTexture[] outputVertices
static double Cos(double d)
static double Sin(double a)

References Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, System.Math.Cos(), System.count, Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawIndexedPrimitives(), System.E, Microsoft.Xna.Framework.Graphics.Texture2D.Height, System.offset, System.options, Microsoft.Xna.Framework.Graphics.SpriteBatch.outputVertices, System.Math.Sin(), System.startIndex, Microsoft.Xna.Framework.Graphics.SpriteBatch.vertexBuffer, Microsoft.Xna.Framework.Graphics.SpriteBatch.vertexBufferPosition, Microsoft.Xna.Framework.Graphics.Texture2D.Width, Microsoft.Xna.Framework.Graphics.SpriteBatch.xCornerOffsets, and Microsoft.Xna.Framework.Graphics.SpriteBatch.yCornerOffsets.

Referenced by Microsoft.Xna.Framework.Graphics.SpriteBatch.RenderBatch().