/// <summary>
        /// Sets the bones pose to ragdoll pose
        /// </summary>
        private void SimulateRagdoll()
        {
            //if (MyFakes.ENABLE_RAGDOLL_DEBUG) Debug.WriteLine("RagdollComponent.SimulateRagdoll");
            if (!MyPerGameSettings.EnableRagdollModels)
            {
                return;
            }
            if (Character.Physics == null || RagdollMapper == null)
            {
                return;
            }

            if (Character.Physics.Ragdoll == null || !Character.Physics.Ragdoll.InWorld || !RagdollMapper.IsActive)
            {
                return;
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Update Bones To Ragdoll");

            try
            {
                RagdollMapper.UpdateRagdollAfterSimulation();

                if (!Character.IsCameraNear && !MyFakes.ENABLE_PERMANENT_SIMULATIONS_COMPUTATION)
                {
                    return;
                }

                RagdollMapper.UpdateCharacterPose(Character.IsDead ? 1.0f : 0.1f, Character.IsDead ? 1.0f : 0.0f);

                RagdollMapper.DebugDraw(Character.WorldMatrix);
            }
            finally
            {
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
            }

            // save bone changes
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Save bones and pos update");

            var characterBones = Character.AnimationController.CharacterBones;

            for (int i = 0; i < characterBones.Length; i++)
            {
                MyCharacterBone bone = characterBones[i];
                Character.BoneRelativeTransforms[i] = bone.ComputeBoneTransform();
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
예제 #2
0
        /// <summary>
        /// Sets the bones pose to ragdoll pose
        /// </summary>
        private void SimulateRagdoll()
        {
            if (!MyPerGameSettings.EnableRagdollModels)
            {
                return;
            }
            if (Character.Physics == null || RagdollMapper == null)
            {
                return;
            }

            if (Character.Physics.Ragdoll == null || !Character.Physics.Ragdoll.IsAddedToWorld || !RagdollMapper.IsActive)
            {
                return;
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Update Bones To Ragdoll");

            RagdollMapper.UpdateRagdollAfterSimulation();

            if (!Character.IsCameraNear && !MyFakes.ENABLE_PERMANENT_SIMULATIONS_COMPUTATION)
            {
                return;
            }

            RagdollMapper.UpdateCharacterPose(Character.IsDead ? 1.0f : 0.1f, Character.IsDead ? 1.0f : 0.0f);

            RagdollMapper.DebugDraw(Character.WorldMatrix);

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            // save bone changes
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Save bones and pos update");

            for (int i = 0; i < Character.Bones.Count; i++)
            {
                MyCharacterBone bone = Character.Bones[i];
                Character.BoneRelativeTransforms[i] = bone.ComputeBoneTransform();
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
        private void UpdateCharacterBones()
        {
            // save bone changes
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Save bones and pos update");

            if (RagdollMapper != null && RagdollMapper.Ragdoll != null && RagdollMapper.Ragdoll.InWorld)
            {
                RagdollMapper.UpdateCharacterPose(Character.IsDead ? 1.0f : 0.1f, Character.IsDead ? 1.0f : 0.0f);
                RagdollMapper.DebugDraw(Character.WorldMatrix);

                var characterBones = Character.AnimationController.CharacterBones;
                for (int i = 0; i < characterBones.Length; i++)
                {
                    MyCharacterBone bone = characterBones[i];
                    bone.ComputeBoneTransform();
                    Character.BoneRelativeTransforms[i] = bone.RelativeTransform;
                }
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }