MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/Terrain/TerrainPatch.cpp:64–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void TerrainPatch::Init(Terrain* terrain, int16 x, int16 z)
65{
66 PROFILE_MEM(LevelTerrain);
67 ScopeLock lock(_collisionLocker);
68
69 _terrain = terrain;
70 _physicsShape = nullptr;
71 _physicsActor = nullptr;
72 _physicsHeightField = nullptr;
73 _x = x;
74 _z = z;
75 const float size = _terrain->_chunkSize * TERRAIN_UNITS_PER_VERTEX * Terrain::ChunksCountEdge;
76 _offset = Float3(_x * size, 0.0f, _z * size);
77 _yOffset = 0.0f;
78 _yHeight = 1.0f;
79 for (int32 i = 0; i < Terrain::ChunksCount; i++)
80 {
81 Chunks[i].Init(this, i % Terrain::ChunksCountEdge, i / Terrain::ChunksCountEdge);
82 }
83 Heightmap = nullptr;
84 for (int32 i = 0; i < TERRAIN_MAX_SPLATMAPS_COUNT; i++)
85 {
86 Splatmap[i] = nullptr;
87 }
88 _heightfield = nullptr;
89#if TERRAIN_EDITING
90 _cachedHeightMap.Resize(0);
91 _cachedHolesMask.Resize(0);
92 _wasHeightModified = false;
93 for (int32 i = 0; i < TERRAIN_MAX_SPLATMAPS_COUNT; i++)
94 {
95 _cachedSplatMap[i].Resize(0);
96 _wasSplatmapModified[i] = false;
97 }
98#endif
99#if TERRAIN_USE_PHYSICS_DEBUG
100 SAFE_DELETE_GPU_RESOURCE(_debugLines);
101 _debugLinesDirty = true;
102#endif
103#if USE_EDITOR
104 _collisionTriangles.Resize(0);
105 SAFE_DELETE_GPU_RESOURCE(_collisionTrianglesBuffer);
106 _collisionTrianglesBufferDirty = true;
107#endif
108 _collisionVertices.Resize(0);
109}
110
111TerrainPatch::~TerrainPatch()
112{

Callers 9

TestPrefabs.cppFile · 0.45
AddPatchesMethod · 0.45
AddPatchMethod · 0.45
DeserializeMethod · 0.45
SetupHeightMapMethod · 0.45
SetupSplatMapMethod · 0.45
ModifySplatMapMethod · 0.45
CacheDebugLinesMethod · 0.45
DrawPhysicsDebugMethod · 0.45

Calls 2

Float3Class · 0.85
ResizeMethod · 0.45

Tested by

no test coverage detected