@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
278 lines • 9.28 kB
TypeScript
/**
* Size in bytes of a single tetrahedron record
* @readonly
* @type {number}
*/
export const LAYOUT_TETRA_BYTE_SIZE: number;
/**
* @readonly
* @type {number}
*/
export const INVALID_NEIGHBOUR: number;
/**
* @readonly
* @type {number}
*/
export const MAX_TET_INDEX: number;
/**
* Only keeps track of tetrahedra, actual point coordinates are stored outside.
* For most useful operations point coordinates are passed in as an extra argument.
*
* Binary Layout:
* vertex_id_a :: uint32
* vertex_id_b :: uint32
* vertex_id_c :: uint32
* vertex_id_d :: uint32
* neighbour_a :: uint32 - neighbour tetrahedron, opposite to vertex A
* neighbour_b :: uint32 - neighbour tetrahedron, opposite to vertex B
* neighbour_c :: uint32 - neighbour tetrahedron, opposite to vertex C
* neighbour_d :: uint32 - neighbour tetrahedron, opposite to vertex D
* Layout is similar to [1], but is interleaved for better cache locality.
* Also note that sub-determinants are not included, these are only needed for building the mesh, we excluded them to keep structure clean and more compact.
*
* Neighbours are encoded in the following manner:
* MSB -> [tet_id:30bit][opposite_corner_index:2bit] <- LSB
* Code to get tet index: encoded >> 2
* Code to get corner index: encoded & 3
*
* @see [1] 2018 "One machine, one minute, three billion tetrahedra" by Célestin Marot, Jeanne Pellerin and Jean-François Remacle
* @see https://git.immc.ucl.ac.be/hextreme/hxt_seqdel (C source code for [1])
*/
export class TetrahedralMesh {
/**
*
* @param {number} [initial_size]
*/
constructor(initial_size?: number);
/**
*
* @type {ArrayBuffer}
* @private
*/
private __buffer;
/**
*
* @type {Uint32Array}
* @private
*/
private __data_uint32;
/**
*
* @type {DataView}
* @private
*/
private __view;
/**
*
* @type {number}
* @private
*/
private __capacity;
/**
*
* @type {number}
* @private
*/
private __used_end;
/**
* Unused slots
* @type {number[]}
* @private
*/
private __free;
/**
*
* @type {number}
* @private
*/
private __free_pointer;
/**
* Access raw data
* Useful for serialization
* If you intend to modify the data directly - make sure you fully understand the implications of doing so
* @returns {ArrayBuffer}
*/
get data_buffer(): ArrayBuffer;
/**
* Exposes internal state, when this is false there are hole in the allocated memory
* Useful mainly for serialization and debugging.
* When serializing, you would want to get rid of any holes first by calling {@link compact}
* @return {boolean}
*/
get isCompacted(): boolean;
/**
* Traverse live tetrahedrons
* @param { function( tet_id:number, mesh:TetrahedralMesh ):* } visitor
* @param {*} [thisArg]
*/
forEach(visitor: any, thisArg?: any): void;
/**
* Produces a list of live tetrahedrons
* Allocates.
* @return {number[]}
*/
getLive(): number[];
/**
* Clears all data from the mesh, making it contain 0 tetrahedrons
* Ensures that consequent allocation requests will be sequential
*/
clear(): void;
/**
*
* @param {number} capacity
*/
setCapacity(capacity: number): void;
/**
*
* @return {number}
*/
getCapacity(): number;
/**
* How many tetrahedrons are contained in the mesh, includes any unallocated tetrahedrons
* @deprecated use {@link count} instead
* @return {number}
*/
size(): number;
/**
* Number of currently live tetrahedrons.
* Excludes unallocated tetrahedrons.
* @return {number}
*/
get count(): number;
/**
* Grow capacity to at least the specified size
* @private
* @param {number} capacity minimum
*/
private growCapacity;
/**
* Make sure that capacity is large enough to contain a certain total number of tetrahedrons
* @param {number} capacity
*/
ensureCapacity(capacity: number): void;
/**
* NOTE: this method can be quite slow in cases of sparse allocation, please prefer not to use it
* @param {number} tet
* @return {boolean}
*/
exists(tet: number): boolean;
/**
* NOTE: the neighbour value must be encoded, see format specification for details
* @param {number} tetra_index
* @param {number} neighbour_index
* @returns {number} index of the neighbour encoded with the opposite corner
*/
getNeighbour(tetra_index: number, neighbour_index: number): number;
/**
* NOTE: the neighbour value must be encoded, see format specification for details
* @param {number} tetra_index
* @param {number} neighbour_index which neighbour to set (00..11)
* @param {number} neighbour index of the neighbour encoded with the opposite corner
*/
setNeighbour(tetra_index: number, neighbour_index: number, neighbour: number): void;
/**
*
* @param {number} tet_index
* @param {number} point_index should be an integer between 0 and 3
* @returns {number}
*/
getVertexIndex(tet_index: number, point_index: number): number;
/**
*
* @param {number} tet_index
* @param {number} point_index
* @param {number} vertex
*/
setVertexIndex(tet_index: number, point_index: number, vertex: number): void;
/**
* Whether a given tetrahedron contains vertex with a given index
* @param {number} tet
* @param {number} vertex
* @return {boolean}
*/
tetContainsVertex(tet: number, vertex: number): boolean;
/**
* Allocate empty tet
* NOTE: the tet memory might be dirty, please make sure you set/clear it as necessary
* @return {number} index of allocated tetrahedron
*/
allocate(): number;
/**
*
* @param {number} a
* @param {number} b
* @param {number} c
* @param {number} d
* @returns {number} index of the new tetrahedron
*/
append(a: number, b: number, c: number, d: number): number;
/**
* Sets back-links on neighbours to this tet to INVALID_NEIGHBOUR basically making them into mesh surface
* This is a useful method for when you want to completely remove a given tet from the mesh to make sure that no dangling references will remain
* @param {number} tetra_index
*/
disconnect(tetra_index: number): void;
/**
* Remove tetrahedron, de-allocating memory
* Please note that if there are any dangling references in the mesh neighbourhood - you will need to take care of that separately
* @param {number} tetra_index
*/
delete(tetra_index: number): void;
/**
* Used mainly to remove tetrahedrons whos points touch the "super-tetrahedron's" points that was inserted originally
* These points are identified by an offset + count parameters
* @param {number} range_start
* @param {number} range_end
*/
removeTetrasConnectedToPoints(range_start: number, range_end: number): void;
/**
* Note that this method does not guarantee to find the containing tet in case of concave mesh, that is - if there is a gap between the starting tet and the countaining tet
* @param {number} x
* @param {number} y
* @param {number} z
* @param {number[]} points Positions of vertices of tetrahedrons
* @param {number} [start_tetrahedron]
* @returns {number} index of tetra or -1 if no containing tetra found
*/
walkToTetraContainingPoint(x: number, y: number, z: number, points: number[], start_tetrahedron?: number): number;
/**
* Relocate tetrahedron in memory, patches neighbourhood links as well
* NOTE: The destination slot will be overwritten. This is a dangerous method that can break the topology, make sure you fully understand what you are doing when using it
* @param {number} source_index index of source tetrahedron
* @param {number} destination_index new index, where the source tetrahedron is to be moved
*/
relocate(source_index: number, destination_index: number): void;
/**
* Perform compaction, removing unused memory slots
* NOTE: existing tetrahedron indices can become invalidated as tets are moved into free slots
* @returns {number} number of relocated elements
*/
compact(): number;
/**
*
* @param {BinaryBuffer} buffer
*/
serialize(buffer: BinaryBuffer): void;
/**
*
* @param {BinaryBuffer} buffer
*/
deserialize(buffer: BinaryBuffer): void;
/**
* Turns data into a base64 encoded string
* @return {string}
*/
serialize_base64(): string;
/**
* Dual of serialization method, decodes a base64 representation
* @param {string} str
*/
deserialize_base64(str: string): void;
/**
* @readonly
* @type {boolean}
*/
readonly isTetrahedralMesh: boolean;
}
import { BinaryBuffer } from "../../../binary/BinaryBuffer.js";
//# sourceMappingURL=TetrahedralMesh.d.ts.map