|
Untitled
|
Mesh functions that modify and initialize Mesh data. More...
#include <math.h>#include <assert.h>#include <stdio.h>#include <string.h>#include "utilities/types.h"#include "utilities/utilities.h"#include "utilities/mathf.h"#include "core/mesh.h"#include "uthash/uthash.h"Go to the source code of this file.
Data Structures | |
| struct | WeldedVertexKey |
| struct | WeldedEntry |
| struct | EdgePairKey |
| struct | EdgePairEntry |
Functions | |
| WeldedVertexKey | get_welded_key (vec3 pos, float epsilon) |
| Quantizes a position to its voxel boundary to be used as a WeldedVertexKey. | |
| void | clean_up_hull (Vector *in_vertices, Vector *in_faces) |
| Removes extraneous points from a ConvexHull that aren't referenced by its HullFaces after running incremental_hull(). | |
| void | check_face_visibility (vec3 p, Vector vertices, Vector hull_faces, Vector hull_indices, Vector *visible_faces_indices) |
| Checks what faces are visible (facing) the given point. | |
| void | check_horizon_edges (MeshFace *face, Vector vertices, Vector *edges, Vector *counts) |
| void | add_horizon_face_to_hull_faces (size_t p_idx, HorizonEdge e, Vector vertices, vec3 center, Vector *hull_faces, Vector *hull_indices, bool epa) |
| int | pick_lowest_point (ConvexHull *hull) |
| bool | setup_initial_hull_points (ConvexHull *hull) |
| void | build_adjacency_map (Mesh *mesh) |
| Builds a map of TriangleAdjacency over adjacent MeshFaces on the Mesh. | |
| int | find_mn_by_name (char name[256]) |
| Finds a Mesh inside of Globals.meshes via string. | |
| void | deduplicate (Vector *in_verts, Vector *faces) |
| Deduplicates vertices. | |
| void | expand_hull (vec3 p, int index, Vector *vertices, Vector *hull_faces, Vector *hull_indices, Vector *horizon_edges, Vector *horizon_counts, Vector *visible_faces_indices, vec3 centroid) |
| void | incremental_hull (ConvexHull *hull) |
| Deduplicates vertices. | |
| void | compute_mesh_hulls (ConvexHull *hull) |
| Combines contiguous triangles with same normals into one face. | |
Variables | |
| EdgePairEntry * | edge_pair_table = NULL |
| WeldedEntry * | welded_table = NULL |
| struct WeldedVertexKey |
| struct WeldedEntry |
| Data Fields | ||
|---|---|---|
| WeldedVertexKey | key | |
| size_t | index | |
| UT_hash_handle | hh | |
| struct EdgePairEntry |
| Data Fields | ||
|---|---|---|
| EdgePairKey | key | |
| Vector | tris | |
| UT_hash_handle | hh | |
| WeldedVertexKey get_welded_key | ( | vec3 | pos, |
| float | epsilon ) |
Quantizes a position to its voxel boundary to be used as a WeldedVertexKey.
| pos | The position. |
| epsilon | The epsilon that controls how quantized the positions become. |
Definition at line 82 of file mesh.c.
References get_welded_key(), vec3::x, WeldedVertexKey::x, vec3::y, WeldedVertexKey::y, vec3::z, and WeldedVertexKey::z.
Referenced by build_adjacency_map(), and get_welded_key().
Removes extraneous points from a ConvexHull that aren't referenced by its HullFaces after running incremental_hull().
| in_vertices | The vertices to test. |
| in_faces | The faces to test against. |
Definition at line 297 of file mesh.c.
References Vector::buffer, CAST_VEC, clean_up_hull(), Vector::count, deduplicate(), MeshFace::indices, init_vector(), vec3_equal(), and vector_expand().
Referenced by clean_up_hull(), and incremental_hull().
| void check_face_visibility | ( | vec3 | p, |
| Vector | vertices, | ||
| Vector | hull_faces, | ||
| Vector | hull_indices, | ||
| Vector * | visible_faces_indices ) |
Checks what faces are visible (facing) the given point.
| p | The new point to check against. |
| vertices | The current vec3 vertices on the ConvexHull. |
| hull_faces | The current MeshFaces on the ConvexHull. |
| hull_indices | The indices that are indirections into hull_faces that provide all valid faces. |
| visible_faces_indices | The expanding list of visible faces. |
\(\text{ADD TO LIST, if } ((p - f_A) \cdot \vec{f_N}) \gt 0\)
Definition at line 349 of file mesh.c.
References CAST_VEC, check_face_visibility(), Vector::count, MeshFace::indices, MeshFace::normal, vec3_dot(), vec3_sub(), and vector_expand().
Referenced by check_face_visibility(), and expand_hull().
Definition at line 370 of file mesh.c.
References HorizonEdge::ab, CAST_VEC, check_horizon_edges(), Vector::count, MeshFace::indices, vec3_equal(), and vector_expand().
Referenced by check_horizon_edges(), expand_hull(), and incremental_hull().
| void add_horizon_face_to_hull_faces | ( | size_t | p_idx, |
| HorizonEdge | e, | ||
| Vector | vertices, | ||
| vec3 | center, | ||
| Vector * | hull_faces, | ||
| Vector * | hull_indices, | ||
| bool | epa ) |
Definition at line 415 of file mesh.c.
References A, HorizonEdge::ab, add_horizon_face_to_hull_faces(), B, C, CAST_VEC, compute_tri_normal(), Vector::count, epa(), MeshFace::indices, MeshFace::normal, vec3_dot(), vec3_sub(), and vector_expand().
Referenced by add_horizon_face_to_hull_faces(), expand_hull(), and incremental_hull().
| int pick_lowest_point | ( | ConvexHull * | hull | ) |
Definition at line 552 of file mesh.c.
References ConvexHull::aabb, CAST_VEC, Vector::count, AABB::extents, pick_lowest_point(), ConvexHull::vertices, X, vec3::x, Y, vec3::y, Z, and vec3::z.
Referenced by pick_lowest_point(), and setup_initial_hull_points().
| bool setup_initial_hull_points | ( | ConvexHull * | hull | ) |
Definition at line 601 of file mesh.c.
References A, B, C, CAST_VEC, ConvexHull::centroid, compute_tri_normal(), Vector::count, D, ConvexHull::faces, MeshFace::indices, init_vector(), MeshFace::normal, pick_lowest_point(), setup_initial_hull_points(), vec3_add(), vec3_cross(), vec3_dist(), vec3_dot(), vec3_length(), vec3_normalize(), vec3_scale(), vec3_sub(), vector_expand(), ConvexHull::vertices, vec3::x, vec3::y, and vec3::z.
Referenced by incremental_hull(), and setup_initial_hull_points().
| void build_adjacency_map | ( | Mesh * | mesh | ) |
Builds a map of TriangleAdjacency over adjacent MeshFaces on the Mesh.
| mesh | The Mesh to build over. |
Definition at line 96 of file mesh.c.
References TriangleAdjacency::adjacent_indices, Vector::buffer, build_adjacency_map(), CAST_VEC, Vector::count, edge_pair_table, get_welded_key(), WeldedEntry::index, MeshFace::indices, init_vector(), EdgePairEntry::key, WeldedEntry::key, Mesh::tri_adjacency, EdgePairEntry::tris, Mesh::tris, vector_expand(), Mesh::vertices, and welded_table.
Referenced by build_adjacency_map(), and init_mesh().
| int find_mn_by_name | ( | char | name[256] | ) |
Finds a Mesh inside of Globals.meshes via string.
| name | The name to compare. |
Definition at line 229 of file mesh.c.
References CAST_VEC, Vector::count, find_mn_by_name(), MeshNode::free, GLOBALS, Globals::mesh_nodes, and MeshNode::name.
Referenced by find_mn_by_name(), and load_lightmap_from_binary().
Deduplicates vertices.
| in_verts | The vec3s of the ConvexHull. |
| faces | The MeshFaces of the ConvexHull. |
Definition at line 248 of file mesh.c.
References Vector::buffer, CAST_VEC, Vector::count, deduplicate(), MeshFace::indices, init_vector(), vec3_equal(), and vector_expand().
Referenced by clean_up_hull(), and deduplicate().
| void expand_hull | ( | vec3 | p, |
| int | index, | ||
| Vector * | vertices, | ||
| Vector * | hull_faces, | ||
| Vector * | hull_indices, | ||
| Vector * | horizon_edges, | ||
| Vector * | horizon_counts, | ||
| Vector * | visible_faces_indices, | ||
| vec3 | centroid ) |
Definition at line 443 of file mesh.c.
References add_horizon_face_to_hull_faces(), CAST_VEC, check_face_visibility(), check_horizon_edges(), Vector::count, expand_hull(), and REMOVE_FROM_VEC.
Referenced by expand_hull().
| void incremental_hull | ( | ConvexHull * | hull | ) |
Deduplicates vertices.
| in_verts | The vec3s of the ConvexHull. |
| faces | The MeshFaces of the ConvexHull. |
Definition at line 782 of file mesh.c.
References ConvexHull::aabb, add_horizon_face_to_hull_faces(), Vector::buffer, Vector::capacity, CAST_VEC, ConvexHull::centroid, check_horizon_edges(), clean_up_hull(), compute_aabb_from_points(), Vector::count, ConvexHull::faces, incremental_hull(), MeshFace::indices, init_vector(), MeshFace::normal, REMOVE_FROM_VEC, setup_initial_hull_points(), uv, vec3_dot(), vec3_equal(), vec3_sub(), vector_expand(), and ConvexHull::vertices.
Referenced by incremental_hull(), init_mesh(), and init_player().
| void compute_mesh_hulls | ( | ConvexHull * | hull | ) |
Combines contiguous triangles with same normals into one face.
Important for more efficient physics / manifold clipping.
| in_verts | The vec3s of the ConvexHull. |
| faces | The MeshFaces of the ConvexHull. |
Definition at line 962 of file mesh.c.
References A, B, Vector::buffer, C, CAST_VEC, compute_hull_faces(), compute_mesh_hulls(), HullFace::count, Vector::count, ConvexHull::faces, ConvexHull::hull_faces, HullFace::indices, MeshFace::indices, TriangleGroup::indices, init_vector(), is_similar_plane(), mesh_faces_are_contiguous(), HullFace::normal, MeshFace::normal, TriangleGroup::normal, TriangleGroup::ref_point, triangle_area(), vec3_equal(), vector_expand(), ConvexHull::vertices, and vec3::z.
Referenced by compute_mesh_hulls(), init_mesh(), and init_player().
| EdgePairEntry* edge_pair_table = NULL |
Definition at line 92 of file mesh.c.
Referenced by build_adjacency_map().
| WeldedEntry* welded_table = NULL |
Definition at line 93 of file mesh.c.
Referenced by build_adjacency_map().