22 APR 2026

rahulmnavneeth

mesh edit

homedocs

Location

include/mop/interact/mesh_edit.h   — Public topology ops
src/interact/mesh_edit.c           — Half-edge structure + ops

Overview

Mesh editing operates on raw index-buffer topology. An auxiliary half-edge structure is built on demand from the index buffer; O(n²) twin-finding is acceptable for interactive edit operations. Every op finishes by recomputing normals and calling mop_mesh_update_geometry internally, so CPU and GPU buffers stay in sync and the next mop_viewport_render sees the new mesh.

These functions do not push undo themselves — wrap them in mop_viewport_push_undo on the calling side if you want undo.

Functions

Vertex ops

void mop_mesh_move_vertices  (MopMesh *m, MopViewport *vp,
                              const uint32_t *indices, uint32_t count,
                              MopVec3 delta);
void mop_mesh_delete_vertices(MopMesh *m, MopViewport *vp,
                              const uint32_t *indices, uint32_t count);
void mop_mesh_merge_vertices (MopMesh *m, MopViewport *vp,
                              uint32_t v0, uint32_t v1);

Edge ops

void mop_mesh_split_edge   (MopMesh *m, MopViewport *vp,
                            uint32_t edge_v0, uint32_t edge_v1);
void mop_mesh_dissolve_edge(MopMesh *m, MopViewport *vp,
                            uint32_t edge_v0, uint32_t edge_v1);

Face ops

void mop_mesh_extrude_faces(MopMesh *m, MopViewport *vp,
                            const uint32_t *face_indices, uint32_t count,
                            float distance);
void mop_mesh_inset_faces  (MopMesh *m, MopViewport *vp,
                            const uint32_t *face_indices, uint32_t count,
                            float inset);
void mop_mesh_delete_faces (MopMesh *m, MopViewport *vp,
                            const uint32_t *face_indices, uint32_t count);
void mop_mesh_flip_normals (MopMesh *m, MopViewport *vp,
                            const uint32_t *face_indices, uint32_t count);

Notes

Usage

Extrude the currently selected faces by 0.5 units along their normals:

const MopSelection *sel = mop_viewport_get_selection(vp);
if (sel->mode == MOP_EDIT_FACE && sel->element_count > 0) {
    mop_viewport_push_undo(vp, selected_mesh);
    mop_mesh_extrude_faces(selected_mesh, vp,
                           sel->elements, sel->element_count, 0.5f);
}

See Also