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

◆ CopyOrRestoreData()

unsafe int Microsoft.Xna.Framework.Graphics.Texture3D.CopyOrRestoreData ( [MarshalAs(UnmanagedType.U1)] bool isStoring)
inlinepackage

Definition at line 480 of file Texture3D.cs.

481 {
482 IDirect3DVolumeTexture9* ptr = pComPtr;
483 if (ptr == null)
484 {
485 return 0;
486 }
487 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DVOLUME_DESC d3DVOLUME_DESC);
488 int num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DVOLUME_DESC*, int>)(int)(*(uint*)(*(int*)ptr + 68)))((nint)ptr, 0u, &d3DVOLUME_DESC);
489 if (num >= 0)
490 {
491 if (isStoring)
492 {
494 }
495 uint num2 = System.Runtime.CompilerServices.Unsafe.As<_D3DVOLUME_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVOLUME_DESC, 16));
496 uint num3 = System.Runtime.CompilerServices.Unsafe.As<_D3DVOLUME_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVOLUME_DESC, 20));
497 uint num4 = System.Runtime.CompilerServices.Unsafe.As<_D3DVOLUME_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVOLUME_DESC, 24));
498 byte expectedByteSizeFromFormat = Texture.GetExpectedByteSizeFromFormat(*(_D3DFORMAT*)(&d3DVOLUME_DESC));
499 int num5 = 0;
500 int num6 = 0;
501 if (0 < _levelCount)
502 {
503 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DLOCKED_BOX d3DLOCKED_BOX);
504 do
505 {
506 byte* ptr2 = null;
507 int num7;
508 if (!isStoring)
509 {
510 ref IntPtr reference = ref pFaceData[num5];
511 num5++;
512 ptr2 = (byte*)reference.ToPointer();
513 num7 = 0;
514 }
515 else
516 {
517 num7 = 16;
518 }
519 ptr = pComPtr;
520 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DLOCKED_BOX*, _D3DBOX*, uint, int>)(int)(*(uint*)(*(int*)ptr + 76)))((nint)ptr, (uint)num6, &d3DLOCKED_BOX, null, (uint)num7);
521 if (num < 0)
522 {
523 break;
524 }
525 uint num8 = expectedByteSizeFromFormat * num2;
526 if (isStoring)
527 {
528 ptr2 = (byte*)_003CModule_003E.new_005B_005D(num8 * num4 * num3);
529 }
530 byte* ptr3 = ptr2;
531 byte* ptr4 = (byte*)(int)System.Runtime.CompilerServices.Unsafe.As<_D3DLOCKED_BOX, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DLOCKED_BOX, 8));
532 if (0 < num4)
533 {
534 uint num9 = num4;
535 do
536 {
537 byte* ptr5 = ptr4;
538 if (0 < num3)
539 {
540 uint num10 = num3;
541 do
542 {
543 if (isStoring)
544 {
545 _003CModule_003E.memcpy_s(ptr3, num8 * num3, ptr5, num8);
546 }
547 else
548 {
549 _003CModule_003E.memcpy_s(ptr5, *(uint*)(&d3DLOCKED_BOX), ptr3, num8);
550 }
551 ptr5 = *(int*)(&d3DLOCKED_BOX) + ptr5;
552 ptr3 = (int)num8 + ptr3;
553 num10--;
554 }
555 while (num10 != 0);
556 }
557 ptr4 = System.Runtime.CompilerServices.Unsafe.As<_D3DLOCKED_BOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DLOCKED_BOX, 4)) + ptr4;
558 num9--;
559 }
560 while (num9 != 0);
561 }
562 ptr = pComPtr;
563 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, int>)(int)(*(uint*)(*(int*)ptr + 80)))((nint)ptr, (uint)num6);
564 if (num < 0)
565 {
566 break;
567 }
568 if (isStoring)
569 {
570 IntPtr intPtr = (IntPtr)ptr2;
571 ref IntPtr reference2 = ref pFaceData[num5];
572 num5++;
573 reference2 = intPtr;
574 }
575 num2 = ((num2 <= 1) ? 1u : (num2 >> 1));
576 num3 = ((num3 <= 1) ? 1u : (num3 >> 1));
577 num4 = ((num4 <= 1) ? 1u : (num4 >> 1));
578 num6++;
579 }
580 while (num6 < _levelCount);
581 }
582 }
583 return num;
584 }
unsafe IDirect3DVolumeTexture9 * pComPtr
Definition Texture3D.cs:18

References Microsoft.Xna.Framework.Graphics.Texture._levelCount, Microsoft.Xna.Framework.Graphics.Texture.GetExpectedByteSizeFromFormat(), Microsoft.Xna.Framework.Graphics.Texture3D.pComPtr, and Microsoft.Xna.Framework.Graphics.Texture3D.pFaceData.

Referenced by Microsoft.Xna.Framework.Graphics.Texture3D.RecreateAndPopulateObject(), and Microsoft.Xna.Framework.Graphics.Texture3D.SaveDataForRecreation().