public virtual void AddShape(IShape shape) { shape.CreateMeshData(_tempPoints, _tempIndexes); if (_tempPoints.Count == 0 || _tempIndexes.Count == 0) { return; } bool doesNeedToFinalize = false; //If the new vertices will bring us over the vertex count if (_meshPoints.Count + _tempPoints.Count >= _maxVertices) { doesNeedToFinalize = true; } //If the current mesh already has data, but either // the current mesh has normals and the new shape does not // or // the current mesh does not have normals but the new shape does if (_meshPoints.Count != 0 && (_meshPoints.HasNormalsDefined != _tempPoints.HasNormalsDefined)) { doesNeedToFinalize = true; } //If the current mesh already has data, but has a different topology if (_meshPoints.Count != 0 && _currTopology != shape.Topology) { doesNeedToFinalize = true; } else { _currTopology = shape.Topology; } if (doesNeedToFinalize) { FinalizeCurrentMesh(); } int offset = _meshPoints.Count; _tempPoints.CopyTo(_meshPoints); for (int i = 0; i < _tempIndexes.Count; i++) { _meshIndexes.Add(_tempIndexes[i] + offset); } _tempPoints.Clear(); _tempIndexes.Clear(); }
public void CreateMeshData(MeshPoints points, List <int> connections) { if (_points.Count <= 1) { return; } _points.CopyTo(points); for (int i = 0; i < _points.Count - 1; i++) { connections.Add(i); connections.Add(i + 1); } }