Initial commit
This commit is contained in:
59
modules/world/world_terrain_lod.h
Normal file
59
modules/world/world_terrain_lod.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef WORLD_TERRAIN_LOD_H
|
||||
#define WORLD_TERRAIN_LOD_H
|
||||
#include <core/hash_map.h>
|
||||
#include <core/reference.h>
|
||||
#include <scene/resources/mesh.h>
|
||||
#include <scene/resources/world.h>
|
||||
#include <scene/resources/packed_scene.h>
|
||||
#include <modules/voxel/util/math/vector3i.h>
|
||||
#include "world_chunk.h"
|
||||
#include "terrain_object.h"
|
||||
#include "new_point.h"
|
||||
#include "direct_lod_multimesh.h"
|
||||
class LodMultiMesh3D;
|
||||
class WorldChunk;
|
||||
class WorldTerrainLod {
|
||||
public:
|
||||
List<LodMultiMesh3D *> meshes;
|
||||
private:
|
||||
HashMap<Vector3i, LodMultiMesh3D *, Vector3iHasher> mesh_h;
|
||||
int min_dist, max_dist;
|
||||
Ref<World> gworld;
|
||||
float density_range = 3.0f;
|
||||
public:
|
||||
void set_world(Ref<World> world);
|
||||
void init_lod(int mind, int maxd,
|
||||
float density_range);
|
||||
void create_chunk(const WorldChunk *chunk, const List<TerrainObject> &obj_list);
|
||||
void update();
|
||||
inline bool has(const Vector3i *loc) const
|
||||
{
|
||||
return mesh_h.has(*loc);
|
||||
}
|
||||
void cleanup(const Transform &vxform);
|
||||
bool valid_org(const Transform &vxform, const Vector3 &org, float margin) const;
|
||||
void update_visibility(const Transform &vxform);
|
||||
inline float get_density_range() const
|
||||
{
|
||||
return density_range;
|
||||
}
|
||||
inline bool in_range(float d) const
|
||||
{
|
||||
if (d >= (float)min_dist && d < (float)max_dist)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
inline void erase(const Vector3i &key)
|
||||
{
|
||||
if (mesh_h.has(key)) {
|
||||
LodMultiMesh3D *v = mesh_h[key];
|
||||
v->hide();
|
||||
v->set_world(NULL);
|
||||
memfree(v);
|
||||
meshes.erase(v);
|
||||
mesh_h.erase(key);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user