Example #1
0
 public virtual void UpdateMap(VectorDisplacement update)
 {
     lock (set_displacement) {
         set_displacement.Set(update);
         have_set_displacement = true;
     }
     base.invalidate();
 }
Example #2
0
        /// <summary>
        /// Returns copy of current displacement map. thread-safe.
        /// </summary>
        public virtual VectorDisplacement GetMapCopy()
        {
            VectorDisplacement map = new VectorDisplacement();

            lock (Displacement) {
                map.Set(Displacement);
            }
            return(map);
        }
Example #3
0
        public virtual void Update()
        {
            base.begin_update();

            if (MeshSource == null)
            {
                throw new Exception("VectorDisplacementMapOp: must set valid MeshSource to compute!");
            }

            IMesh imesh = MeshSource.GetIMesh();

            if (imesh.HasVertexNormals == false)
            {
                throw new Exception("VectorDisplacementMapOp: input mesh does not have surface normals...");
            }
            if (imesh is DMesh3 == false)
            {
                throw new Exception("VectorDisplacementMapOp: in current implementation, input mesh must be a DMesh3. Ugh.");
            }
            DMesh3 mesh = imesh as DMesh3;

            lock (Displacement) {
                if (have_set_displacement)
                {
                    lock (set_displacement) {
                        if (set_displacement.Count == mesh.MaxVertexID)
                        {
                            Displacement.Set(set_displacement);
                        }
                        have_set_displacement = false;
                    }
                }
                else if (Displacement.Count != mesh.MaxVertexID)
                {
                    Displacement.Clear();
                    Displacement.Resize(mesh.MaxVertexID);
                }
            }

            base.complete_update();
        }