コード例 #1
0
 /// <summary>
 /// Change mesh under lock. This safely allows mesh edits to happen in concert
 /// with background threads reading from the mesh.
 ///
 /// Currently it is only safe to call this from the main thread!
 /// </summary>
 public void EditAndUpdateMesh(Action <DMesh3> EditF, GeometryEditTypes editType)
 {
     lock (mesh_write_lock) {
         EditF(mesh);
     }
     notify_mesh_edited(editType);
 }
コード例 #2
0
        //
        // internals
        //

        public void notify_mesh_edited(GeometryEditTypes editType)
        {
            if (editType == GeometryEditTypes.VertexDeformation)
            {
                fast_mesh_update(true, true);
            }
            else
            {
                on_mesh_changed();
                viewMeshes.ValidateViewMeshes();
            }
            post_mesh_modified();
        }
コード例 #3
0
 /// <summary>
 /// This function returns an object that holds a lock on the .Mesh for writing.
 /// You should only call like this:
 ///
 /// using (var danger = meshSO.AcquireDangerousMeshLockForEditing(editType)) {
 ///      ...do your thing to meshSO.Mesh
 /// }
 ///
 /// This will safely lock the mesh so that background mesh-read threads are blocked.
 /// ***DO NOT*** hold onto this lock, or you will never be able to update the mesh again!
 /// </summary>
 DangerousExternalLock AcquireDangerousMeshLockForEditing(GeometryEditTypes editType)
 {
     return(DangerousExternalLock.Lock(mesh_write_lock,
                                       () => { notify_mesh_edited(editType); }));
 }