Beispiel #1
0
        protected unsafe void SetProxyConstants(ref MyRenderableProxy_2 proxy, MyMergeInstancingConstants?arg = null)
        {
            MyMergeInstancingConstants constants = arg ?? MyMergeInstancingConstants.Default;

            int version = constants.GetHashCode();

            if (constants.GetHashCode() != proxy.ObjectConstants.Version)
            {
                int size   = sizeof(MyMergeInstancingConstants);
                var buffer = new byte[sizeof(MyMergeInstancingConstants)];

                proxy.ObjectConstants = new MyConstantsPack()
                {
                    BindFlag = MyBindFlag.BIND_VS,
                    CB       = MyCommon.GetObjectCB(size),
                    Version  = version,
                    Data     = buffer
                };


                fixed(byte *dstPtr = buffer)
                {
#if XB1
                    SharpDX.Utilities.CopyMemory(new IntPtr(dstPtr), new IntPtr(&constants), size);
#else // !XB1
                    MyMemory.CopyMemory(new IntPtr(dstPtr), new IntPtr(&constants), (uint)size);
#endif // !XB1
                }
            }

            MyRenderUtils.MoveConstants(RC, ref proxy.ObjectConstants);
            MyRenderUtils.SetConstants(RC, ref proxy.ObjectConstants, MyCommon.OBJECT_SLOT);

            ++Stats.ObjectConstantsChanges;
        }