private void RecreateRenderData() { if (Mesh?.GetAsset() != null) { CRenderScene scene = CRenderer.Instance.ActiveScene; if (m_renderNode != null) { scene.UnregisterRenderNode(m_renderNode); } if (m_overrideMaterial != null) { m_renderNode = new CMeshRenderNode(this, Mesh, null, m_transform); m_renderNode.SetMaterialOverride(m_overrideMaterial); } else { m_renderNode = new CMeshRenderNode(this, Mesh, MaterialAsset, m_transform); } scene.RegisterRenderNode(m_renderNode); } else { if (m_renderNode != null) { CRenderer.Instance.ActiveScene.UnregisterRenderNode(m_renderNode); } } }
private void RecreateRenderData(float deltaTime) { if (Model == null) { CRenderScene scene = CRenderer.Instance.ActiveScene; for (int i = 0; i < m_renderNodes.Length; i++) { scene.UnregisterRenderNode(m_renderNodes[i]); } return; } CModelAsset modelAsset = Model.GetAsset(); if (modelAsset != null && modelAsset.IsLoaded) { CRenderScene scene = CRenderer.Instance.ActiveScene; for (int i = 0; i < m_renderNodes.Length; i++) { scene.UnregisterRenderNode(m_renderNodes[i]); } int meshCount = modelAsset.MeshChildren.Count; m_renderNodes = new CMeshRenderNode[meshCount]; m_overrideMaterials.SetMinSize(meshCount); m_materialAssets.SetMinSize(meshCount); for (int i = 0; i < meshCount; i++) { Transform childTransform = new Transform(); childTransform.SetFromMatrix(modelAsset.MeshChildren[i].relativeTransform); childTransform.Parent = m_transform; CMeshRenderNode newRenderNode; if (m_overrideMaterials[i] != null) { newRenderNode = new CMeshRenderNode(this, modelAsset.MeshChildren[i].meshAsset, null, childTransform); newRenderNode.SetMaterialOverride(m_overrideMaterials[i]); } else { newRenderNode = new CMeshRenderNode(this, modelAsset.MeshChildren[i].meshAsset, m_materialAssets[i], childTransform); } m_renderNodes[i] = newRenderNode; scene.RegisterRenderNode(newRenderNode); } m_updateRenderDataScope?.Disconnect(); m_updateRenderDataScope = null; } }
public override void Shutdown() { base.Shutdown(); if (m_renderNodes != null) { CRenderScene scene = CRenderer.Instance.ActiveScene; foreach (CMeshRenderNode renderNode in m_renderNodes) { scene.UnregisterRenderNode(renderNode); } m_renderNodes = null; } if (m_updateRenderDataScope != null && m_updateRenderDataScope.IsConnected()) { m_updateRenderDataScope.Disconnect(); m_updateRenderDataScope = null; } }