16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 10:29:19 +02:00

Snap to ground || New terrain system || Terrain sculping || Mesh simplification

This commit is contained in:
2026-06-17 08:56:42 +02:00
parent 5a39ed5193
commit 449609d817
7 changed files with 958 additions and 14 deletions

View File

@@ -423,6 +423,32 @@ shape_node::convert( TSubModel const *Submodel ) {
return *this;
}
// builds an opaque, always-visible shape from a world-space GL_TRIANGLES vertex list
shape_node &
shape_node::make_terrain( material_handle const Material, std::vector<world_vertex> Vertices, glm::dvec3 const Origin ) {
m_data.material = Material;
m_data.translucent = false;
m_data.visible = true;
m_data.rangesquared_min = 0.0;
m_data.rangesquared_max = std::numeric_limits<double>::max();
m_data.origin = Origin;
m_data.vertices = std::move( Vertices );
// bounding area from the supplied geometry
m_data.area.center = glm::dvec3( 0.0 );
if( false == m_data.vertices.empty() ) {
for( auto const &vertex : m_data.vertices ) {
m_data.area.center += vertex.position;
}
m_data.area.center /= static_cast<double>( m_data.vertices.size() );
}
invalidate_radius();
radius(); // force recompute now, while vertices are still present
return *this;
}
// adds content of provided node to already enclosed geometry. returns: true if merge could be performed
bool
shape_node::merge( shape_node &Shape ) {

View File

@@ -120,6 +120,10 @@ public:
// imports data from provided submodel
shape_node &
convert( TSubModel const *Submodel );
// builds an opaque, always-visible shape from a world-space GL_TRIANGLES vertex list, stored
// relative to Origin. used by the editor's terrain to own editable geometry it can re-upload.
shape_node &
make_terrain( material_handle const Material, std::vector<world_vertex> Vertices, glm::dvec3 const Origin );
// adds content of provided node to already enclosed geometry. returns: true if merge could be performed
bool
merge( shape_node &Shape );
@@ -138,6 +142,9 @@ public:
// set origin point
void
origin( glm::dvec3 Origin );
// replaces the renderable geometry handle (used by the editor when it re-uploads terrain geometry)
void
geometry( gfx::geometry_handle const &Handle );
// data access
shapenode_data const &
data() const;
@@ -163,6 +170,12 @@ void
shape_node::origin( glm::dvec3 Origin ) {
m_data.origin = Origin;
}
// replaces the renderable geometry handle
inline
void
shape_node::geometry( gfx::geometry_handle const &Handle ) {
m_data.geometry = Handle;
}
// data access
inline
shape_node::shapenode_data const &