internal unsafe void UpdateCube(List <MyCubeInstanceData> instanceData, int capacity) { Debug.Assert(m_type == MyRenderInstanceBufferType.Cube); m_capacity = Math.Max(instanceData.Count, capacity); var rawBuffer = new MyVertexFormatCubeInstance[m_capacity]; for (int instanceIndex = 0; instanceIndex < m_capacity; instanceIndex++) { fixed(byte *pSource = instanceData[instanceIndex].RawBones(), pTarget = rawBuffer[instanceIndex].bones) { for (int boneIndex = 0; boneIndex < MyRender11Constants.CUBE_INSTANCE_BONES_NUM * 4; ++boneIndex) { pTarget[boneIndex] = pSource[boneIndex]; } } rawBuffer[instanceIndex].translationRotation = instanceData[instanceIndex].m_translationAndRot; rawBuffer[instanceIndex].colorMaskHSV = instanceData[instanceIndex].ColorMaskHSV; } fixed(MyVertexFormatCubeInstance *dataPtr = rawBuffer) { MyHwBuffers.ResizeAndUpdateStaticVertexBuffer(ref VB, m_capacity, sizeof(MyVertexFormatCubeInstance), new IntPtr(dataPtr), m_debugName + " instances buffer"); } BumpRenderable(); }
internal unsafe void UpdateGeneric(List <MyInstanceData> instanceData, int capacity) { Debug.Assert(m_type == MyRenderInstanceBufferType.Generic); fixed(MyInstanceData *dataPtr = instanceData.GetInternalArray()) { m_capacity = Math.Max(instanceData.Count, capacity); MyHwBuffers.ResizeAndUpdateStaticVertexBuffer(ref VB, m_capacity, sizeof(MyVertexFormatGenericInstance), new IntPtr(dataPtr), m_debugName + " instances buffer"); } BumpRenderable(); }
internal unsafe void UpdateGeneric(List <MyInstanceData> instanceData, int capacity) { var instancesNum = instanceData.Count; if (m_capacity < instancesNum) { m_capacity = Math.Max(instancesNum, capacity); fixed(MyInstanceData *dataPtr = instanceData.ToArray()) { MyHwBuffers.ResizeAndUpdateStaticVertexBuffer(ref VertexBuffer, m_capacity, sizeof(MyVertexFormatGenericInstance), new IntPtr(dataPtr), m_debugName + " instances buffer"); } }
internal static unsafe void UpdateVertexBuffer(InstancingId id) { var info = id.Info; if (info.VisibleCapacity == 0) return; fixed(byte *ptr = info.Data) { MyHwBuffers.ResizeAndUpdateStaticVertexBuffer(ref Data[id.Index].VB, info.VisibleCapacity, info.Stride, new IntPtr(ptr), info.DebugName); } }