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

◆ SetValue() [3/18]

unsafe void Microsoft.Xna.Framework.Graphics.EffectParameter.SetValue ( float value)
inline

Definition at line 701 of file EffectParameter.cs.

702 {
703 if (pElementCollection.Count != 0)
704 {
705 throw new InvalidCastException();
706 }
707 EffectParameterClass paramClass = _paramClass;
708 if (paramClass == EffectParameterClass.Vector && _rows == 1)
709 {
710 switch (_columns)
711 {
712 default:
713 throw new InvalidCastException();
714 case 4:
715 {
716 System.Runtime.CompilerServices.Unsafe.SkipInit(out D3DXVECTOR4 d3DXVECTOR2);
717 System.Runtime.CompilerServices.Unsafe.As<D3DXVECTOR4, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXVECTOR2, 12)) = value;
718 System.Runtime.CompilerServices.Unsafe.As<D3DXVECTOR4, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXVECTOR2, 8)) = value;
719 System.Runtime.CompilerServices.Unsafe.As<D3DXVECTOR4, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXVECTOR2, 4)) = value;
720 *(float*)(&d3DXVECTOR2) = value;
721 ID3DXBaseEffect* ptr = pEffect;
722 int num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, D3DXVECTOR4*, int>)(int)(*(uint*)(*(int*)ptr + 136)))((nint)ptr, _handle, &d3DXVECTOR2);
723 if (num2 < 0)
724 {
725 throw GraphicsHelpers.GetExceptionFromResult((uint)num2);
726 }
727 break;
728 }
729 case 3:
730 {
731 System.Runtime.CompilerServices.Unsafe.SkipInit(out D3DXVECTOR3 d3DXVECTOR3);
732 System.Runtime.CompilerServices.Unsafe.As<D3DXVECTOR3, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXVECTOR3, 8)) = value;
733 System.Runtime.CompilerServices.Unsafe.As<D3DXVECTOR3, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXVECTOR3, 4)) = value;
734 *(float*)(&d3DXVECTOR3) = value;
735 ID3DXBaseEffect* ptr = pEffect;
736 int num3 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, float*, uint, int>)(int)(*(uint*)(*(int*)ptr + 128)))((nint)ptr, _handle, (float*)(&d3DXVECTOR3), 3u);
737 if (num3 < 0)
738 {
739 throw GraphicsHelpers.GetExceptionFromResult((uint)num3);
740 }
741 break;
742 }
743 case 2:
744 {
745 System.Runtime.CompilerServices.Unsafe.SkipInit(out D3DXVECTOR2 d3DXVECTOR);
746 System.Runtime.CompilerServices.Unsafe.As<D3DXVECTOR2, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXVECTOR, 4)) = value;
747 *(float*)(&d3DXVECTOR) = value;
748 ID3DXBaseEffect* ptr = pEffect;
749 int num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, float*, uint, int>)(int)(*(uint*)(*(int*)ptr + 128)))((nint)ptr, _handle, (float*)(&d3DXVECTOR), 2u);
750 if (num < 0)
751 {
752 throw GraphicsHelpers.GetExceptionFromResult((uint)num);
753 }
754 break;
755 }
756 }
757 }
758 else if (paramClass == EffectParameterClass.Matrix)
759 {
760 System.Runtime.CompilerServices.Unsafe.SkipInit(out D3DXMATRIX d3DXMATRIX);
761 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 12)) = value;
762 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 8)) = value;
763 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 4)) = value;
764 *(float*)(&d3DXMATRIX) = value;
765 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 28)) = value;
766 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 24)) = value;
767 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 20)) = value;
768 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 16)) = value;
769 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 44)) = value;
770 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 40)) = value;
771 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 36)) = value;
772 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 32)) = value;
773 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 60)) = value;
774 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 56)) = value;
775 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 52)) = value;
776 System.Runtime.CompilerServices.Unsafe.As<D3DXMATRIX, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXMATRIX, 48)) = value;
777 ID3DXBaseEffect* ptr = pEffect;
778 int num4 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, D3DXMATRIX*, int>)(int)(*(uint*)(*(int*)ptr + 152)))((nint)ptr, _handle, &d3DXMATRIX);
779 if (num4 < 0)
780 {
781 throw GraphicsHelpers.GetExceptionFromResult((uint)num4);
782 }
783 }
784 else
785 {
786 if (paramClass != 0)
787 {
788 throw new InvalidCastException();
789 }
790 ID3DXBaseEffect* ptr = pEffect;
791 int num5 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, float, int>)(int)(*(uint*)(*(int*)ptr + 120)))((nint)ptr, _handle, value);
792 if (num5 < 0)
793 {
794 throw GraphicsHelpers.GetExceptionFromResult((uint)num5);
795 }
796 }
797 }

References Microsoft.Xna.Framework.Graphics.EffectParameter._columns, Microsoft.Xna.Framework.Graphics.EffectParameter._handle, Microsoft.Xna.Framework.Graphics.EffectParameter._paramClass, Microsoft.Xna.Framework.Graphics.EffectParameter._rows, Microsoft.Xna.Framework.Graphics.EffectParameterCollection.Count, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.EffectParameter.pEffect, Microsoft.Xna.Framework.Graphics.EffectParameter.pElementCollection, and System.value.