public bool AddEdgeInfo(long hash, MyEdgeInfo info, MySlimBlock owner) { MyFourEdgeInfo orAdd; bool flag; if (!this.m_edgeInfosNew.TryGetValue(hash, out orAdd)) { orAdd = new MyFourEdgeInfo(info.LocalOrthoMatrix, info.EdgeType); orAdd = this.m_edgeInfosNew.GetOrAdd(hash, orAdd); } MyFourEdgeInfo info3 = orAdd; lock (info3) { flag = orAdd.AddInstance((Vector3)(owner.Position * owner.CubeGrid.GridSize), info.Color, owner.SkinSubtypeId, info.EdgeModel, info.PackedNormal0, info.PackedNormal1); } if (flag) { if (!orAdd.Full) { this.m_dirtyEdges[hash] = orAdd; } else { this.m_dirtyEdges.Remove <long, MyFourEdgeInfo>(hash); this.m_edgesToRender.Remove <long, MyEdgeRenderData>(hash); } } return(flag); }
public bool AddEdgeInfo(long hash, MyEdgeInfo info, MySlimBlock owner) { MyFourEdgeInfo fourInfo; if (!m_edgeInfosNew.TryGetValue(hash, out fourInfo)) { fourInfo = new MyFourEdgeInfo(info.LocalOrthoMatrix, info.EdgeType); m_edgeInfosNew.Add(hash, fourInfo); } return(fourInfo.AddInstance(owner.Position * owner.CubeGrid.GridSize, info.Color, info.EdgeModel, info.PackedNormal0, info.PackedNormal1)); }
private void AddEdgeParts(Dictionary <MyInstanceBucket, Tuple <List <MyCubeInstanceMergedData>, Sandbox.Game.Entities.Cube.MyInstanceInfo> > instanceParts) { MyCubeInstanceData instance = new MyCubeInstanceData(); instance.ResetBones(); instance.SetTextureOffset(new Vector4UByte(0, 0, 1, 1)); foreach (KeyValuePair <long, MyEdgeRenderData> pair in this.m_edgesToRender) { int modelId = pair.Value.ModelId; MyFourEdgeInfo edgeInfo = pair.Value.EdgeInfo; instance.PackedOrthoMatrix = edgeInfo.LocalOrthoMatrix; this.AddInstancePart(instanceParts, modelId, MyStringHash.NullOrEmpty, ref instance, null, 0, this.EdgeViewDistance); } }
public MyEdgeRenderData(int modelId, MyFourEdgeInfo edgeInfo) { this.ModelId = modelId; this.EdgeInfo = edgeInfo; }
private bool IsEdgeVisible(MyFourEdgeInfo edgeInfo, out int modelId) { int[] numArray; modelId = 0; m_edgesToCompare.Clear(); if (edgeInfo.Full) { return(false); } for (int i = 0; i < 4; i++) { Color color; MyStringHash hash2; MyStringHash hash3; Base27Directions.Direction direction; Base27Directions.Direction direction2; if (edgeInfo.GetNormalInfo(i, out color, out hash3, out hash2, out direction, out direction2)) { EdgeInfoNormal item = new EdgeInfoNormal { Normal = Base27Directions.GetVector(direction), Color = color, SkinSubtypeId = hash3, EdgeModel = hash2 }; m_edgesToCompare.Add(item); item = new EdgeInfoNormal { Normal = Base27Directions.GetVector(direction2), Color = color, SkinSubtypeId = hash3, EdgeModel = hash2 }; m_edgesToCompare.Add(item); } } if (m_edgesToCompare.Count == 0) { return(false); } bool flag = m_edgesToCompare.Count == 4; MyStringHash edgeModel = m_edgesToCompare[0].EdgeModel; int index = 0; while (index < m_edgesToCompare.Count) { int num6 = index + 1; while (true) { if (num6 < m_edgesToCompare.Count) { if (!MyUtils.IsZero(m_edgesToCompare[index].Normal + m_edgesToCompare[num6].Normal, 0.1f)) { num6++; continue; } m_edgesToCompare.RemoveAt(num6); m_edgesToCompare.RemoveAt(index); index--; } index++; break; } } if (m_edgesToCompare.Count == 1) { return(false); } bool flag2 = false; bool flag3 = false; bool flag4 = false; if (m_edgesToCompare.Count > 0) { Color color = m_edgesToCompare[0].Color; MyStringHash skinSubtypeId = m_edgesToCompare[0].SkinSubtypeId; edgeModel = m_edgesToCompare[0].EdgeModel; for (int j = 1; j < m_edgesToCompare.Count; j++) { EdgeInfoNormal normal2 = m_edgesToCompare[j]; flag2 |= normal2.Color != color; flag4 |= normal2.SkinSubtypeId != skinSubtypeId; flag3 |= edgeModel != normal2.EdgeModel; if ((flag2 | flag3) | flag4) { break; } } } if (!((m_edgesToCompare.Count != 1) ? (!((flag2 | flag3) | flag4) ? ((m_edgesToCompare.Count <= 2) ? ((m_edgesToCompare.Count != 0) ? (Math.Abs(Vector3.Dot(m_edgesToCompare[0].Normal, m_edgesToCompare[1].Normal)) <= 0.85f) : flag) : true) : true) : false)) { return(false); } int edgeTypeCount = m_edgeTypeCount; if (!m_edgeModelIdCache.TryGetValue(edgeModel, out numArray)) { MyDefinitionId id = new MyDefinitionId(m_edgeDefinitionType, edgeModel); MyEdgesDefinition edgesDefinition = MyDefinitionManager.Static.GetEdgesDefinition(id); MyEdgesModelSet small = edgesDefinition.Small; MyEdgesModelSet large = edgesDefinition.Large; numArray = new int[m_edgeTypeCount * 2]; MyCubeEdgeType[] values = MyEnum <MyCubeEdgeType> .Values; int num8 = 0; while (true) { int num9; int num10; if (num8 >= values.Length) { m_edgeModelIdCache.Add(edgeModel, numArray); break; } MyCubeEdgeType type = values[num8]; switch (type) { case MyCubeEdgeType.Vertical: num9 = MyModel.GetId(small.Vertical); num10 = MyModel.GetId(large.Vertical); break; case MyCubeEdgeType.Vertical_Diagonal: num9 = MyModel.GetId(small.VerticalDiagonal); num10 = MyModel.GetId(large.VerticalDiagonal); break; case MyCubeEdgeType.Horizontal: num9 = MyModel.GetId(small.Horisontal); num10 = MyModel.GetId(large.Horisontal); break; case MyCubeEdgeType.Horizontal_Diagonal: num9 = MyModel.GetId(small.HorisontalDiagonal); num10 = MyModel.GetId(large.HorisontalDiagonal); break; case MyCubeEdgeType.Hidden: num9 = 0; num10 = 0; break; default: throw new Exception("Unhandled edge type"); } int num11 = (int)type; numArray[num11] = num9; numArray[num11 + edgeTypeCount] = num10; num8++; } } int edgeType = (int)edgeInfo.EdgeType; modelId = numArray[((this.m_gridRenderComponent.GridSizeEnum == MyCubeSize.Large) ? edgeTypeCount : 0) + edgeType]; return(true); }
public bool AddEdgeInfo(long hash, MyEdgeInfo info, MySlimBlock owner) { MyFourEdgeInfo fourInfo; if (!m_edgeInfosNew.TryGetValue(hash, out fourInfo)) { fourInfo = new MyFourEdgeInfo(info.LocalOrthoMatrix, info.EdgeType); m_edgeInfosNew.Add(hash, fourInfo); } return fourInfo.AddInstance(owner.Position * owner.CubeGrid.GridSize, info.Color, info.EdgeModel, info.PackedNormal0, info.PackedNormal1); }