static public GLMeshTrianglePlugin Get(Mesh meshToGetDisplayListFor)
        {
            GLMeshTrianglePlugin plugin;

            meshesWithCacheData.TryGetValue(meshToGetDisplayListFor, out plugin);

            if (plugin != null && meshToGetDisplayListFor.ChangedCount != plugin.meshUpdateCount)
            {
                plugin.meshUpdateCount = meshToGetDisplayListFor.ChangedCount;
                plugin.AddRemoveData();
                plugin.CreateRenderData(meshToGetDisplayListFor);
                plugin.meshUpdateCount = meshToGetDisplayListFor.ChangedCount;
            }

            if (plugin == null)
            {
                GLMeshTrianglePlugin newPlugin = new GLMeshTrianglePlugin();
                meshesWithCacheData.Add(meshToGetDisplayListFor, newPlugin);
                newPlugin.CreateRenderData(meshToGetDisplayListFor);
                newPlugin.meshUpdateCount = meshToGetDisplayListFor.ChangedCount;

                return(newPlugin);
            }

            return(plugin);
        }
        static public GLMeshTrianglePlugin Get(Mesh mesh, Func <Vector3Float, Color> getColorFunc = null)
        {
            object meshData;

            mesh.PropertyBag.TryGetValue(GLMeshTrianglePluginName, out meshData);
            if (meshData is GLMeshTrianglePlugin plugin)
            {
                if (mesh.ChangedCount == plugin.meshUpdateCount)
                {
                    return(plugin);
                }

                // else we need to rebuild the data
                plugin.meshUpdateCount = mesh.ChangedCount;
                mesh.PropertyBag.Remove(GLMeshTrianglePluginName);
            }

            GLMeshTrianglePlugin newPlugin = new GLMeshTrianglePlugin();

            newPlugin.CreateRenderData(mesh, getColorFunc);
            newPlugin.meshUpdateCount = mesh.ChangedCount;
            mesh.PropertyBag.Add(GLMeshTrianglePluginName, newPlugin);

            return(newPlugin);
        }
Example #3
0
        static public GLMeshTrianglePlugin Get(Mesh meshToGetDisplayListFor)
        {
            GLMeshTrianglePlugin plugin;
            meshesWithCacheData.TryGetValue(meshToGetDisplayListFor, out plugin);

                if (plugin != null && meshToGetDisplayListFor.ChangedCount != plugin.meshUpdateCount)
                {
                    plugin.meshUpdateCount = meshToGetDisplayListFor.ChangedCount;
                    plugin.AddRemoveData();
                    plugin.CreateRenderData(meshToGetDisplayListFor);
                    plugin.meshUpdateCount = meshToGetDisplayListFor.ChangedCount;
                }

            DeleteUnusedGLResources();

            if (plugin == null)
            {
                GLMeshTrianglePlugin newPlugin = new GLMeshTrianglePlugin();
                meshesWithCacheData.Add(meshToGetDisplayListFor, newPlugin);
                newPlugin.CreateRenderData(meshToGetDisplayListFor);
                newPlugin.meshUpdateCount = meshToGetDisplayListFor.ChangedCount;

                return newPlugin;
            }

            return plugin;
        }