internal bool IsMergable(MeshId model) { var mesh = MyMeshes.GetLodMesh(model, 0); MeshPartId part1; bool multipleParts = MyMeshes.TryGetMeshPart(model, 0, 1, out part1); return(!multipleParts && mesh.Info.Data.VertexLayout == OneAndOnlySupportedVertexLayout && mesh.Info.IndicesNum > 0 && model.Info.RuntimeGenerated == false && model.Info.Dynamic == false); }
internal void Add(MyActor child) { child.AddComponent <MyGroupLeafComponent>(MyComponentFactory <MyGroupLeafComponent> .Create()); child.GetGroupLeaf().Parent = Owner; m_children.Add(child); if (child.m_relativeTransform == null) { child.m_relativeTransform = (Matrix)(child.WorldMatrix * MatrixD.Invert(Owner.WorldMatrix)); } if (!Owner.m_localAabb.HasValue) { Owner.m_localAabb = child.m_localAabb; } else { var localAabb = child.m_localAabb.Value; Owner.m_localAabb = Owner.m_localAabb.Value.Include(ref localAabb); } PropagateMatrixChange(child); if (child.GetRenderable() == null) { return; } //var mesh = child.GetRenderable().GetMesh(); var model = child.GetRenderable().GetModel(); var material = MyMeshes.GetMeshPart(model, 0, 0).Info.Material; MeshPartId part1; bool AreMultipleParts = MyMeshes.TryGetMeshPart(model, 0, 1, out part1); bool fracture = model.Info.RuntimeGenerated || model.Info.Dynamic; if (MyMeshMaterials1.IsMergable(material) && MyBigMeshTable.Table.IsMergable(model) && !fracture && !AreMultipleParts) { child.GetGroupLeaf().Mergeable = true; MyBigMeshTable.Table.AddMesh(model); m_mergablesCounter++; if (!m_isMerged && m_mergablesCounter >= MERGE_THRESHOLD) { TurnIntoMergeInstancing(); } else if (m_isMerged) { Merge(child); } //var materialRk = MyMeshMaterials1.Table[material.Index].RepresentationKey; //var mergeGroupForMaterial = m_materialGroups.Get(materialRk); //if (mergeGroupForMaterial == null) //{ // var proxyIndex = m_materialGroups.Count; // mergeGroupForMaterial = new MyMaterialMergeGroup(MyBigMeshTable.Table, material, proxyIndex); // m_materialGroups[MyMeshMaterials1.Table[material.Index].RepresentationKey] = mergeGroupForMaterial; // m_dirtyProxy = true; //} //child.GetRenderable().SetStandaloneRendering(false); //child.GetGroupLeaf().m_mergeGroup = mergeGroupForMaterial; //mergeGroupForMaterial.AddEntity(child, model); //mergeGroupForMaterial.UpdateEntity(child); } else { //Debug.WriteLine(String.Format("Mesh {0}, material {1} is not mergable", mesh.Name, material)); } m_dirtyTree = true; }