source: Revenant/geoworld/include/gwmorphs/winderode.h@ 7ef8ec4

port/mars-tycoon
Last change on this file since 7ef8ec4 was 80a6a52, checked in by Jonathan Neufeld <support@…>, 3 years ago

Get to a compile state for terrain procedural generation

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#pragma once
2
3#include "geomorph.h"
4#include "gwutil.h"
5#include "gmregistry.h"
6#include "gwtypes.h"
7
8namespace geoworld
9{
10 class WindErosionGM : public HeightMapGeoMorph
11 {
12 private:
13 typedef float RationalType;
14
15 unsigned int _iterations;
16 RationalType _frDecayLevel;
17 bool _bSmoothPost;
18
19 const IGeoWorldAccessor * _pAccessor;
20 const GMScalarField * _psfDensity;
21
22 RationalType _fgaussblur[5][5];
23
24 using NoiseGen = NoiseGenerator< RationalType >;
25 NoiseGen _ngen;
26
27 template< typename T >
28 inline void grad5( const mars::ScalarField< T > & hmf, const signed int x, const signed int y, VectorTag< RationalType >:: V2 & v ) const
29 {
30 v.x = (hmf(x + 2, y) - hmf(x - 2, y)) / static_cast< T > (4);
31 v.y = (hmf(x, y + 2) - hmf(x, y - 2)) / static_cast< T > (4);
32 }
33
34 inline RationalType & gaussblur (const signed int x, const signed int y)
35 {
36 assert(x >= -2 && y >= -2 && x <= +2 && y <= +2);
37 return _fgaussblur[x + 2][y + 2];
38 }
39 inline RationalType gaussblur (const signed int x, const signed int y) const
40 {
41 assert(x >= -2 && y >= -2 && x <= +2 && y <= +2);
42 return _fgaussblur[x + 2][y + 2];
43 }
44
45 public:
46 WindErosionGM (
47 const unsigned int nIterations = 8,
48 const float frDecayLevel = 0.1f,
49 const bool bSmoothPost = true
50 );
51 ~WindErosionGM();
52
53 void init (SynthesisSession & manager, const IGeoWorldAccessor & accessor, const unsigned short nMaxWidth, const unsigned short nMaxHeight);
54 void doMorph (LockedGWSection & section) const;
55 };
56
57 class WindErosionGTFactory : public GeoTemplateFactory, public IOpenGeoMorphFactory
58 {
59 private:
60 mars::RangeX< unsigned int > _mmnIterations;
61 float _frDecayLevel;
62 bool _bSmoothPost;
63
64 public:
65 virtual GeoMorph * createRandomInstance() const;
66 virtual void configure( IConfigGTFactory * pFactoryConfig, const IConfigGTFactory::Settings & settings );
67 };
68}
Note: See TracBrowser for help on using the repository browser.