private void UpdatePreview() { if (ac_ == null) { ClosePreviewMode(); return; } if (!EditorApplication.isPlayingOrWillChangePlaymode) { if (ac_.PreviewInEditor && ac_.IsPreviewing && ac_.isActiveAndEnabled) { double currentTime = EditorApplication.timeSinceStartup; float deltaTime = (float)(currentTime - lastPreviewTime_); lastPreviewTime_ = currentTime; ac_.Update(deltaTime); Repaint(); } else if (!ac_.PreviewInEditor) { ClosePreviewMode(); } } else { ClosePreviewMode(); } }
public void UpdateSimulating(CarAnimationData animData, UnityEngine.Mesh animBakingMesh, float eventTime, float deltaTime) { if (crAnimation_ == null) { return; } crAnimation_.Update(deltaTime); float targetTime = eventTime + deltaTime; for (int i = 0; i < arrSkinnedMeshRenderer_.Length; ++i) { uint idBody = arrIdBodySkinnedGameObjects_[i]; SkinnedMeshRenderer smRenderer = arrSkinnedMeshRenderer_[i]; GameObject gameObject = smRenderer.gameObject; smRenderer.BakeMesh(animBakingMesh); if (idBody != uint.MaxValue) { Matrix4x4 m_MODEL_TO_WORLD = gameObject.transform.localToWorldMatrix; RigidbodyManager.Rg_addEventTargetArrPos_WORLD((double)eventTime, (double)targetTime, idBody, ref m_MODEL_TO_WORLD, animBakingMesh.vertices); } } for (int i = 0; i < arrNormalMeshRenderer_.Length; ++i) { uint idBody = arrIdBodyNormalGameObjects_[i]; MeshRenderer renderer = arrNormalMeshRenderer_[i]; GameObject gameObject = renderer.gameObject; if (idBody != uint.MaxValue) { Matrix4x4 m_MODEL_TO_WORLD = gameObject.transform.localToWorldMatrix; if (crAnimation_.IsVertexAnimated(gameObject)) { MeshFilter mf = gameObject.GetComponent <MeshFilter>(); Mesh mesh = mf.sharedMesh; RigidbodyManager.Rg_addEventTargetArrPos_WORLD((double)eventTime, (double)targetTime, idBody, ref m_MODEL_TO_WORLD, mesh.vertices); } else { RigidbodyManager.Rg_addEventTargetPos_WORLD((double)eventTime, (double)targetTime, idBody, ref m_MODEL_TO_WORLD, 0.01); } } } animData.timeAnimated_ += deltaTime; }