Пример #1
0
 internal void Render(ref FPGrass.RenderArguments renderArgs)
 {
     FPGrass.RenderArguments arguments = renderArgs;
     arguments.center = this.lastPosition;
     foreach (FPGrassPatch patch in this.children)
     {
         if (patch.enabled)
         {
             patch.Render(ref arguments);
         }
     }
 }
Пример #2
0
 internal void Render(ref FPGrass.RenderArguments renderArgs)
 {
     FPGrass.RenderArguments renderArgument = renderArgs;
     renderArgument.center = this.lastPosition;
     foreach (FPGrassPatch child in this.children)
     {
         if (!child.enabled)
         {
             continue;
         }
         child.Render(ref renderArgument);
     }
 }
Пример #3
0
    internal static void DrawAllGrass(ref FPGrass.RenderArguments renderArgs)
    {
        List <FPGrass> allEnabledFPGrass = FPGrass.AllEnabledFPGrass;

        FPGrass.AllEnabledFPGrassInstancesSwap.AddRange(allEnabledFPGrass);
        FPGrass.AllEnabledFPGrass = FPGrass.AllEnabledFPGrassInstancesSwap;
        FPGrass.AllEnabledFPGrassInstancesSwap = allEnabledFPGrass;
        try
        {
            foreach (FPGrass allEnabledFPGrassInstancesSwap in FPGrass.AllEnabledFPGrassInstancesSwap)
            {
                allEnabledFPGrassInstancesSwap.Render(ref renderArgs);
            }
        }
        finally
        {
            FPGrass.AllEnabledFPGrassInstancesSwap.Clear();
        }
    }
Пример #4
0
 private void Render(ref FPGrass.RenderArguments renderArgs)
 {
     if (base.enabled)
     {
         foreach (FPGrassLevel child in this.children)
         {
             if (!child.enabled)
             {
                 continue;
             }
             if (!renderArgs.immediate)
             {
                 child.UpdateLevel(renderArgs.center, renderArgs.terrain);
             }
             if (!child.enabled)
             {
                 continue;
             }
             child.Render(ref renderArgs);
         }
     }
 }
Пример #5
0
 internal void Draw(FPGrassPatch patch, Mesh mesh, ref Vector3 renderPosition, ref FPGrass.RenderArguments renderArgs)
 {
     if (this.probabilityUpdateQueued || grass.forceredraw)
     {
         this.UpdateMapsNow(this.lastPosition);
         this.probabilityUpdateQueued = false;
     }
     if (grass.displacement)
     {
         Graphics.Blit(FPGrassDisplacementCamera.GetRT(), this.probabilityGenerator.probabilityTexture, FPGrassDisplacementCamera.GetBlitMat());
     }
     if (renderArgs.immediate)
     {
         GL.PushMatrix();
         this.levelMaterial.SetPass(0);
         Graphics.DrawMeshNow(mesh, renderPosition, Constant.rotation, 0);
         GL.PopMatrix();
     }
     else
     {
         Graphics.DrawMesh(mesh, renderPosition, Constant.rotation, this.levelMaterial, base.gameObject.layer, base.camera, 0, null, FPGrass.castShadows, FPGrass.receiveShadows);
     }
 }
Пример #6
0
 private void OnPreCull()
 {
     FPGrass.RenderArguments renderArgument = new FPGrass.RenderArguments();
     if (!Terrain.activeTerrain || !Terrain.activeTerrain.terrainData)
     {
         return;
     }
     if (this._enabled && grass.on && FPGrass.anyEnabled)
     {
         Terrain terrain = Terrain.activeTerrain;
         this.UpdateDisplacement(grass.displacement);
         if (terrain)
         {
             Camera camera = base.camera;
             this._frustum            = GeometryUtility.CalculateFrustumPlanes(camera);
             renderArgument.frustum   = this._frustum;
             renderArgument.camera    = camera;
             renderArgument.immediate = false;
             renderArgument.terrain   = terrain;
             renderArgument.center    = camera.transform.position;
             FPGrass.DrawAllGrass(ref renderArgument);
         }
     }
 }
Пример #7
0
 private void OnPreCull()
 {
     FPGrass.RenderArguments renderArgument = new FPGrass.RenderArguments();
     if (!Terrain.activeTerrain || !Terrain.activeTerrain.terrainData)
     {
         return;
     }
     if (this._enabled && grass.on && FPGrass.anyEnabled)
     {
         Terrain terrain = Terrain.activeTerrain;
         this.UpdateDisplacement(grass.displacement);
         if (terrain)
         {
             Camera camera = base.camera;
             this._frustum = GeometryUtility.CalculateFrustumPlanes(camera);
             renderArgument.frustum = this._frustum;
             renderArgument.camera = camera;
             renderArgument.immediate = false;
             renderArgument.terrain = terrain;
             renderArgument.center = camera.transform.position;
             FPGrass.DrawAllGrass(ref renderArgument);
         }
     }
 }
Пример #8
0
 internal void Render(ref FPGrass.RenderArguments renderArgs)
 {
     if (renderArgs.terrain != null)
     {
         Bounds  lastBounds;
         bool    flag;
         Vector3 renderPosition = renderArgs.center + this.transform.position;
         if (((renderPosition.x == this.lastRenderPosition.x) && (renderPosition.y == this.lastRenderPosition.y)) && (renderPosition.z == this.lastRenderPosition.z))
         {
             lastBounds = this.lastBounds;
             flag       = false;
         }
         else
         {
             float   num2;
             float   num3;
             float   num4;
             float   num5;
             float   num6;
             float   num7;
             Vector3 worldPosition = renderPosition;
             Vector3 vector3       = worldPosition;
             Vector3 vector4       = worldPosition;
             Vector3 vector5       = worldPosition;
             float   num           = this.patchSize * 0.5f;
             worldPosition.x -= num;
             worldPosition.z += num;
             vector3.x       -= num;
             vector3.z       -= num;
             vector4.x       += num;
             vector4.z       += num;
             vector5.x       += num;
             vector5.z       -= num;
             float num8  = renderArgs.terrain.SampleHeight(worldPosition);
             float num9  = renderArgs.terrain.SampleHeight(vector3);
             float num10 = renderArgs.terrain.SampleHeight(vector4);
             float num11 = renderArgs.terrain.SampleHeight(vector5);
             if (num8 < num9)
             {
                 num4 = num8;
                 num6 = num9;
             }
             else
             {
                 num4 = num9;
                 num6 = num8;
             }
             if (num10 < num11)
             {
                 num5 = num10;
                 num7 = num11;
             }
             else
             {
                 num5 = num11;
                 num7 = num10;
             }
             if (num4 < num5)
             {
                 num2 = num4;
             }
             else
             {
                 num2 = num5;
             }
             if (num6 > num7)
             {
                 num3 = num6;
             }
             else
             {
                 num3 = num7;
             }
             vector3.y  = num2 - 5f;
             vector4.y  = num3 + 5f;
             lastBounds = new Bounds();
             lastBounds.SetMinMax(vector3, vector4);
             flag = lastBounds != this.lastBounds;
         }
         if (this.runtimeMesh == null)
         {
             this.runtimeMesh = this.mesh;
         }
         if (flag)
         {
             this.runtimeMesh.bounds = new Bounds(lastBounds.center - renderPosition, lastBounds.size);
             this.lastBounds         = lastBounds;
         }
         if (GeometryUtility.TestPlanesAABB(renderArgs.frustum, lastBounds))
         {
             this.level.Draw(this, this.runtimeMesh, ref renderPosition, ref renderArgs);
         }
     }
 }
Пример #9
0
    internal void Render(ref FPGrass.RenderArguments renderArgs)
    {
        Bounds bound;
        bool   flag;
        float  single;
        float  single1;
        float  single2;
        float  single3;
        float  single4;
        float  single5;

        if (renderArgs.terrain == null)
        {
            return;
        }
        Vector3 vector3 = renderArgs.center + this.transform.position;

        if (vector3.x != this.lastRenderPosition.x || vector3.y != this.lastRenderPosition.y || vector3.z != this.lastRenderPosition.z)
        {
            Vector3 vector31 = vector3;
            Vector3 vector32 = vector31;
            Vector3 vector33 = vector31;
            Vector3 vector34 = vector31;
            float   single6  = this.patchSize * 0.5f;
            vector31.x = vector31.x - single6;
            vector31.z = vector31.z + single6;
            vector32.x = vector32.x - single6;
            vector32.z = vector32.z - single6;
            vector33.x = vector33.x + single6;
            vector33.z = vector33.z + single6;
            vector34.x = vector34.x + single6;
            vector34.z = vector34.z - single6;
            float single7  = renderArgs.terrain.SampleHeight(vector31);
            float single8  = renderArgs.terrain.SampleHeight(vector32);
            float single9  = renderArgs.terrain.SampleHeight(vector33);
            float single10 = renderArgs.terrain.SampleHeight(vector34);
            if (single7 >= single8)
            {
                single2 = single8;
                single4 = single7;
            }
            else
            {
                single2 = single7;
                single4 = single8;
            }
            if (single9 >= single10)
            {
                single3 = single10;
                single5 = single9;
            }
            else
            {
                single3 = single9;
                single5 = single10;
            }
            single     = (single2 >= single3 ? single3 : single2);
            single1    = (single4 <= single5 ? single5 : single4);
            vector32.y = single - 5f;
            vector33.y = single1 + 5f;
            bound      = new Bounds();
            bound.SetMinMax(vector32, vector33);
            flag = bound != this.lastBounds;
        }
        else
        {
            bound = this.lastBounds;
            flag  = false;
        }
        if (!this.runtimeMesh)
        {
            this.runtimeMesh = this.mesh;
        }
        if (flag)
        {
            this.runtimeMesh.bounds = new Bounds(bound.center - vector3, bound.size);
            this.lastBounds         = bound;
        }
        if (GeometryUtility.TestPlanesAABB(renderArgs.frustum, bound))
        {
            this.level.Draw(this, this.runtimeMesh, ref vector3, ref renderArgs);
        }
    }