protected override void OnUpdate(RenderContext context, DeviceContextProxy deviceContext)
            {
                //Skip if not ready
                if (preComputeBoneSkinPass.IsNULL || preComputeBoneBuffer == null || !preComputeBoneBuffer.CanPreCompute)
                {
                    return;
                }

                //Skip if not necessary
                if (!matricsChanged && !mtChanged)
                {
                    return;
                }

                var boneBuffer = sharedBoneBuffer ?? internalBoneBuffer;

                if (boneBuffer.BoneMatrices.Length == 0 && !mtChanged)
                {
                    preComputeBoneBuffer.ResetSkinnedVertexBuffer(deviceContext);
                }
                else
                {
                    GeometryBuffer.UpdateBuffers(deviceContext, EffectTechnique.EffectsManager);
                    preComputeBoneBuffer.BindSkinnedVertexBufferToOutput(deviceContext);
                    boneBuffer.Update(context, deviceContext);
                    internalMTBuffer.Update(context, deviceContext);
                    preComputeBoneSkinPass.BindShader(deviceContext);
                    boneBuffer.BindBuffer(deviceContext, boneSkinSBSlot);
                    internalMTBuffer.BindBuffers(deviceContext, mtWeightsBSlot, mtDeltasBSlot, mtOffsetsBSlot);
                    deviceContext.Draw(GeometryBuffer.VertexBuffer[0].ElementCount, 0);
                    preComputeBoneBuffer.UnBindSkinnedVertexBufferToOutput(deviceContext);
                }
                matricsChanged = false;
            }
Esempio n. 2
0
        protected override void OnUpdate(RenderContext context, DeviceContextProxy deviceContext)
        {
            if (preComputeBoneSkinPass.IsNULL || preComputeBoneBuffer == null || !preComputeBoneBuffer.CanPreCompute || !matricsChanged)
            {
                return;
            }
            var buffer = sharedBoneBuffer ?? internalBoneBuffer;

            if (buffer.BoneMatrices.Length == 0)
            {
                preComputeBoneBuffer.ResetSkinnedVertexBuffer(deviceContext);
            }
            else
            {
                GeometryBuffer.UpdateBuffers(deviceContext, EffectTechnique.EffectsManager);
                preComputeBoneBuffer.BindSkinnedVertexBufferToOutput(deviceContext);
                buffer.Update(context, deviceContext);
                preComputeBoneSkinPass.BindShader(deviceContext);
                buffer.BindBuffer(deviceContext, boneSkinSBSlot);
                deviceContext.Draw(GeometryBuffer.VertexBuffer[0].ElementCount, 0);
                preComputeBoneBuffer.UnBindSkinnedVertexBufferToOutput(deviceContext);
            }
            matricsChanged = false;
        }