public MappedBuffer(Scene scene, Int32 geometryID, BufferType bufferType) : base(RTC.MapBuffer(scene.NativePtr, geometryID, bufferType)) { this.scene = scene; this.geometryID = geometryID; this.bufferType = bufferType; }
public void Update(uint geomID, IntPtr scenePtr) { if (indices.Count / 3 == triangleCount) { var indexBuffer = RTC.MapBuffer(scenePtr, geomID, RTC.BufferType.IndexBuffer); RTC.CheckLastError(); Marshal.Copy(indices.ToArray(), 0, indexBuffer, indices.Count); RTC.UnmapBuffer(scenePtr, geomID, RTC.BufferType.IndexBuffer); } else { throw new InvalidOperationException("Index buffer length was changed."); } if (vertices.Count == vertexCount) { var vertexBuffer = RTC.MapBuffer(scenePtr, geomID, RTC.BufferType.VertexBuffer); RTC.CheckLastError(); unsafe { float *ptr = (float *)vertexBuffer; foreach (var vertex in vertices) { *(ptr++) = vertex.X; *(ptr++) = vertex.Y; *(ptr++) = vertex.Z; *(ptr++) = 1.0f; } } RTC.UnmapBuffer(scenePtr, geomID, RTC.BufferType.VertexBuffer); } else { throw new InvalidOperationException("Vertex buffer length was changed."); } }