A grid ray intersection method accelerated by multi-dimensional hashing

The grid ray intersection method accelerated by multi-dimensional hashing solves the problems of memory waste and redundant calculation in ray intersection algorithms in dynamic scenes, and achieves efficient ray intersection and real-time response in dynamic scenes.

CN121053306BActive Publication Date: 2026-03-13ZHEJIANG HUADONG ENG DIGITAL TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing ray intersection algorithms are computationally inefficient and wasteful of memory in dynamic scenes. They also fail to effectively utilize ray direction features, leading to redundant calculations and repeated testing, making it difficult to meet the real-time editing and topology update requirements of highly complex CAD models.

Method used

A multi-dimensional hash-accelerated grid ray intersection method is adopted. Through adaptive spatial grid partitioning and ray direction hashing, combined with multi-level cache query, direction pruning and spatial hash traversal, a hybrid intersection calculation is achieved, which supports real-time updates in dynamic scenarios.

Benefits of technology

Significantly reduces memory usage, minimizes invalid tests and redundant calculations, improves ray intersection efficiency, supports efficient reconstruction of dynamic scenes, and enhances the real-time response capability of dynamic scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121053306B_ABST
    Figure CN121053306B_ABST
Patent Text Reader

Abstract

This invention provides a mesh ray intersection method accelerated by multi-dimensional hashing, comprising: acquiring original model data and performing standardized preprocessing on the original model data to obtain standardized scene data; performing adaptive spatial meshing based on the preprocessed standardized scene data, mapping the spatial coordinates of the three-dimensional mesh cells to a hash table to construct a one-dimensional index of the spatial mesh, and associating the triangular faces of the scene data with the spatial mesh; performing direction parameter decomposition on the rays to be intersected, discretizing the direction vectors of the rays, and constructing a composite hash key for the ray directions; and performing hybrid intersection calculation by combining multi-level cache lookup, direction pruning to filter invalid intersections, and spatial hash traversal intersection to determine the intersection point information between the rays and the geometry. This invention, by converting the spatial mesh and ray direction data into hash values ​​for storage, has a small memory footprint and improves the efficiency of ray intersection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer graphics technology, and in particular to a grid ray intersection method based on multi-dimensional hash acceleration. Background Technology

[0002] Computer-aided design (CAD) utilizes computers and their graphics devices to assist designers in their work. In this field, designers often need to perform high-precision spatial analysis on complex 3D models to support engineering verification and design optimization. For example, in mechanical assembly scenarios, it's necessary to detect interference and collisions between moving parts in real time to avoid discovering design flaws during physical prototype testing; in architectural design, ray tracing is used to simulate the diffuse reflection paths of natural and artificial light sources to assess whether indoor lighting meets green building standards; and in reverse engineering, efficient registration of point cloud data is required to reconstruct accurate 3D geometric topology. These core functions heavily rely on the efficiency and accuracy of ray intersection calculations. As the underlying operator for 3D spatial queries, the performance of ray intersection directly determines the smoothness of interaction and the reliability of analysis within the CAD system.

[0003] However, as industrial design evolves towards higher fidelity and complexity, the number of geometric elements in CAD models has increased exponentially. Parametric models typically contain tens of millions of triangular faces, and with the demands of dynamic assembly and tolerance analysis, these models need to support real-time editing and topology updates. Traditional ray intersection algorithms, such as those based on uniform spatial meshes or static BVH acceleration structures, face significant challenges. The shortcomings of existing technologies include…

[0004] (1) There are bottlenecks in computational efficiency and wasted video memory:

[0005] 1) Existing technologies use uniform meshing, which divides the entire scene space into three-dimensional grids of the same size, such as 1m×1m×1m, regardless of whether the area contains facets. For example, if there is a 100m×100m×100m open area in the scene, but it only contains 10 facets, the uniform mesh will still divide it into 100m×100m grids of a fixed size. 3 =10 6 The system consists of 99.999% of cells that are empty and do not contain any faces. However, these empty cells still require video memory to store their spatial boundaries, index pointers, and other metadata. Even though the content is empty, the "existence" of a cell itself requires memory recording, resulting in a large amount of redundant video memory consumption.

[0006] 2) Existing technologies use fixed-level octrees for subdivision. Octrees recursively divide the space into eight child nodes to achieve hierarchical partitioning. However, fixed-level octrees can fall into "ineffective subdivision" in sparse regions. For example, a top-level node in an empty area could directly serve as a leaf node, but the fixed level forces it to be subdivided into smaller child nodes, ultimately resulting in a large number of empty leaf nodes. These empty nodes still need to store child node pointers, boundary information, etc., leading to wasted GPU memory. Furthermore, octrees, by recursively dividing the 3D space into eight child nodes, replace geometric hierarchical association with spatial partitioning, giving them a natural advantage in memory efficiency. However, simplification strategies adopted to further reduce memory usage, such as limiting the maximum depth and merging small-volume child nodes, inevitably introduce geometric approximation errors, ultimately leading to an imbalance between collision detection accuracy and memory requirements. This makes it difficult to meet the micrometer-level tolerance analysis requirements of application scenarios, resulting in an imbalance between memory and accuracy.

[0007] The aforementioned uniform grid partitioning or octree generates a large number of empty cells in sparse regions, resulting in wasted GPU memory; while in high-density regions, the excessively dense grid causes hash collisions, requiring hundreds of faces to be tested in a single ray traversal, degrading the computational complexity from the theoretical O(log N) to O(N).

[0008] (2) Direction-independent redundancy: Existing methods ignore the distribution characteristics of ray directions and do not consider the distribution characteristics of ray directions, such as the concentration and high frequency of directions. They adopt an indiscriminate traversal and intersection strategy for all directions of rays, which leads to a large amount of repeated calculations.

[0009] For example, rays traveling in the same or similar directions often pass through highly overlapping grid cells in the scene; for instance, two parallel rays may pass through completely identical grid sequences. However, existing methods independently calculate "which grid cells each ray intersects with," repeatedly performing grid boundary testing, coordinate transformation, and other operations, resulting in wasted computational resources.

[0010] For rays traveling in high-frequency directions, the intersection results (such as "whether they intersect" and "the location of the nearest intersection point") with faces within a specific grid in the scene may remain unchanged for a short period of time (especially in static scenes). For example, if a ray in a certain direction passes through the same grid 100 times consecutively, and the faces within that grid do not move, existing methods will repeatedly test all faces within that grid for these 100 rays, without reusing historical intersection results. This repeated testing of intersection results leads to a large amount of redundant geometric intersection calculations.

[0011] (3) Limitations of dynamic scenarios: The traditional BVH (Bounding Volume Hierarchy) structure is a structure that accelerates spatial queries through hierarchical bounding volumes, such as axis-aligned bounding boxes (AABB). Its core advantage lies in transforming the geometric retrieval of complex scenarios into hierarchical testing of "bounding volume-ray" or "bounding volume-bounding volume", thereby reducing invalid computation. However, in dynamic scenarios, especially in model editing interaction scenarios, its structural characteristics lead to the need for global reconstruction after model editing. The reconstruction time can account for more than 70% of the total interaction time, which is a significant real-time bottleneck. Summary of the Invention

[0012] Based on the above background, the purpose of this invention is to provide a ray intersection acceleration method suitable for dynamic scenes, which can realize the real-time updating of the ray intersection acceleration structure in dynamic scenes and solve the problems of irrelevance redundancy, memory efficiency and accuracy in current technologies.

[0013] To achieve the above objectives, the present invention adopts the following technical solution:

[0014] This invention provides a grid ray intersection method based on multi-dimensional hash acceleration, comprising:

[0015] Obtain raw model data, including mesh model data and / or parametric model data, and perform standardized preprocessing on the raw model data to obtain standardized scene data;

[0016] Adaptive spatial meshing is performed based on preprocessed standardized scene data. The spatial coordinates of the three-dimensional mesh units are mapped to a hash table to construct a one-dimensional index of the spatial mesh, and the triangular patches of the scene data are associated with the spatial mesh.

[0017] The ray to be intersected is decomposed into directional parameters, the ray's direction vector is discretized, and a composite hash key for the ray direction is constructed.

[0018] By combining multi-level cache query, directional pruning to filter invalid intersections, and spatial hash traversal intersections, hybrid intersection calculations are performed to determine the intersection information between the ray and the geometry.

[0019] The beneficial effects of this invention are as follows:

[0020] This invention processes the mesh model and parametric model to construct a 3D spatial mesh hash and ray direction hash. It then performs hybrid intersection calculations by combining multi-level cache lookup, direction pruning to filter invalid intersections, and spatial hash traversal intersection calculations. This determines the intersection information between rays and geometry, reducing invalid tests and redundant calculations, and improving ray intersection efficiency. Specifically:

[0021] (1) By converting spatial grid and ray direction data into hash values ​​for storage, memory usage is significantly reduced; among them, hash compression storage realizes the mapping from three-dimensional coordinates to one-dimensional compact hash table through prime number multiplication hash, combined with adaptive grid partitioning to optimize memory in sparse regions, avoiding the large amount of redundant grid memory allocated by uniform grid to cover a large range of scenes, making memory allocation more flexible and efficient; at the same time, the hash table structure is compact, which puts less pressure on memory bandwidth and helps to run stably on memory-constrained devices.

[0022] (2) The time consumption of batch ray intersection is reduced. The hybrid intersection strategy of directional pruning, cache reuse and spatial hash traversal reduces invalid tests and repeated calculations, and has a significant speed-up effect on the intersection of high-frequency directional rays.

[0023] (3) Supports efficient reconstruction in dynamic scenes. The incremental update mechanism ensures that when dynamic objects move, the update cost of the hash table is only proportional to the range of the object's movement and the number of affected faces, which greatly improves the real-time response capability of dynamic scenes. In frequently updated dynamic scenes, the incremental update mechanism avoids the cost of global reconstruction, significantly reduces the construction time of dynamic scenes, and improves the construction efficiency more significantly. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0025] Figure 1 A flowchart of a grid ray intersection method based on multi-dimensional hash acceleration provided in an embodiment of the present invention;

[0026] Figure 2 This is a schematic diagram of the acquisition and preprocessing process in step S1 provided in an embodiment of the present invention;

[0027] Figure 3 This is a schematic diagram of adaptive spatial grid partitioning in step S2 of an embodiment of the present invention;

[0028] Figure 4 This is a schematic diagram of the three-dimensional hash mapping principle in step S2 of this embodiment of the invention;

[0029] Figure 5 This is a schematic diagram of hash value compression storage and data prefetching in step S2 of an embodiment of the present invention;

[0030] Figure 6This is a schematic diagram of the decomposition of the polar angle and azimuth angle of the ray direction parameters in step S3 of the present invention.

[0031] Figure 7 This is a schematic diagram illustrating the composition of the unique ray identifier and the composite hash key in step S3 of this embodiment of the invention.

[0032] Figure 8 This is a schematic diagram of the multi-level caching mechanism query in step S4 of an embodiment of the present invention;

[0033] Figure 9 This is a schematic diagram of the incremental hash dynamic update in step S5 provided in an embodiment of the present invention;

[0034] Figure 10 This is a schematic diagram of memory sandbox fault tolerance processing in step S5 of the present invention. Detailed Implementation

[0035] To further understand the present invention, preferred embodiments of the present invention are described below in conjunction with examples. However, it should be understood that these descriptions are only for further illustrating the features and advantages of the present invention, and not for limiting the scope of the claims of the present invention.

[0036] like Figure 1 As shown, this application provides a grid ray intersection method accelerated by multi-dimensional hashing. The steps include:

[0037] S1. Obtain raw model data, including mesh model data and / or parametric model data, and perform standardized preprocessing on the raw model data to obtain standardized scene data;

[0038] S2. Based on the preprocessed standardized scene data, perform adaptive spatial grid division, and map the spatial coordinates of the three-dimensional grid cells to a hash table to construct a one-dimensional index of the spatial grid; associate the triangular patches of the scene data with the spatial grid;

[0039] S3. Perform direction parameter decomposition on the rays to be intersected, discretize the direction vectors of the rays, and construct a composite hash key for the ray directions;

[0040] S4. Perform hybrid intersection calculation by combining multi-level cache query, directional pruning to filter invalid intersections, and spatial hash traversal intersection to determine the intersection information of the ray and the geometry.

[0041] S5. Obtain information on dynamic changes in the grid, and perform incremental refresh of the local hash structure by detecting dynamic regions and hash key markers.

[0042] For details, see Figure 2Step S1 aims to collect digital representations of all geometric objects in the scene, providing a complete geometric data foundation for subsequent spatial hashing and ray intersection calculations. The specific implementation includes the following:

[0043] S101, Obtain the mesh model or parametric model. If the obtained model is a parametric model, convert it into a mesh model according to the conversion relationship between the parametric model and the corresponding mesh model stored in the parametric model.

[0044] A mesh model is 3D model data using triangular facets as basic units. 3D model data includes...

[0045] Vertex information: the three-dimensional coordinates of each vertex, such as (x, y, z), and the normal vector used for subsequent directional pruning;

[0046] Topological relationships of facets: combinations of vertex indices of triangular facets, such as (v1, v2, v3);

[0047] Parametric models are parametric geometric models described by mathematical formulas, such as spheres, cylinders, and NURBS surfaces. They store the analytical expressions of their basic parameters, constraint boundary conditions, and transformation relationships.

[0048] The analytical expressions for basic parameters include the coordinates of the center of a sphere and its radius, the equation of the axis of a cylinder and its base radius, etc.

[0049] The boundary conditions are the effective spatial range of the parametric model in the scene, such as the extension interval of the cylinder along the Z-axis [z_min, z_max].

[0050] The transformation relationship is the association mapping between the parametric model and the mesh model. For example, the accuracy parameters when discretizing a NURBS surface into temporary triangular patches are used for re-discretization during dynamic updates.

[0051] S102, performs unified processing on the acquired mesh model and the parametric model that has been converted into a mesh model, including,

[0052] Coordinate normalization: Transform all model coordinates to the scene's global coordinate system, such as taking the scene's center point as the origin, to eliminate differences in local coordinate systems;

[0053] Redundancy removal: Removes degenerate faces in the mesh model with an area smaller than a preset threshold, such as narrow triangles. The preset threshold can be 0.001㎡ to avoid errors in subsequent intersection calculations.

[0054] Global bounding box calculation: Generate the smallest axis-aligned bounding box (AABB) containing all models, which serves as the spatial range benchmark for subsequent adaptive mesh generation.

[0055] Through the above S1 step, complete data acquisition and standardized processing of mixed geometric scenes containing mesh models and / or parametric models are achieved, providing an accurate and consistent input basis for the subsequent dynamic construction of spatial hashing.

[0056] In step S2, adaptive spatial meshing is performed based on the preprocessed standardized scene data, and the spatial coordinates of the 3D mesh cells are mapped to a hash table to construct a one-dimensional index of the spatial mesh; the triangular patches of the scene data are associated with the spatial mesh; including,

[0057] S201, see S201. Figure 3 Adaptive spatial meshing is performed based on the scene model data density. The core objective of adaptive spatial meshing is to dynamically adjust the mesh density in 3D space to ensure efficient resource utilization and balance efficiency and memory usage. Its implementation involves the following steps:

[0058] S2011, Scene Data Pre-analysis: This involves preliminary segmentation of the overall bounding box of the scene data using an octree, counting the number of faces per unit volume within each sub-region, and obtaining the triangular face density. Upper and lower limits for the density threshold are set. Specifically, the density threshold should be set based on the typical triangular face distribution characteristics of the CAD scene. For CAD scenes such as mechanical assembly and architectural design, the recommended values ​​are as follows:

[0059] The upper limit of the density threshold is 50 cells / cubic meter, suitable for high-density areas such as the precision tooth surfaces of mechanical parts and complex nodes of building components. When the density of local patches exceeds this value, the mesh size is reduced to avoid excessive patches within a single mesh, which would decrease the efficiency of intersection calculation. The lower limit of the density threshold is 5 cells / cubic meter, suitable for sparse areas such as open spaces inside buildings and gaps in mechanical assemblies. When the density of local patches is lower than this value, the mesh size is increased to reduce the number of empty cells and reduce memory redundancy. This threshold can be dynamically adjusted according to the complexity of the scene. For example, in high-fidelity reverse engineering scenarios, the upper limit can be increased to 80 cells / cubic meter, while in simplified architectural lighting simulation scenarios, the lower limit can be reduced to 2 cells / cubic meter to avoid excessive density leading to memory waste or excessive sparseness leading to low query efficiency.

[0060] S2012, perform dynamic density calculation and dynamically adjust the mesh size based on local density. For example, when the density of a patch in a certain area is significantly higher than the average, the mesh size is reduced using an exponential decay formula; conversely, it is increased. At the same time, upper and lower limits for the mesh size are set, such as 0.5 meters to 5 meters, to prevent extreme cases. Specifically, the scaling of the mesh size needs to balance efficiency and accuracy. In this embodiment, the following formula is recommended:

[0061] Grid shrinking formula: An exponential decay formula is used to achieve smooth shrinking, avoiding frequent hash structure reconstruction caused by abrupt size changes.

[0062]

[0063] in: To adjust the mesh size, ρ is the current mesh size; k is an adjustment factor, recommended to be 0.8, to balance the shrinking rate and stability; ρ is the current patch density of the region. The global average patch density of the scene;

[0064] Constraints: ≥ ( To preset the minimum grid size, 0.5 meters is recommended to avoid excessively dense grids that could cause a surge in memory usage.

[0065] Mesh scaling formula: Linear scaling combined with upper bound constraints is used to prevent excessively large meshes from causing missed intersecting surfaces.

[0066]

[0067] in: The maximum preset grid size is recommended to be 5 meters, which is suitable for the spatial range of most CAD scenarios;

[0068] The meanings of the other parameters are the same as those in the scaling-up formula, ensuring that the grid can still cover potential intersecting areas after scaling up.

[0069] In S2013, for objects spanning multiple meshes, their bounding box (AABB) is expanded to the nearest integer multiple of the mesh boundary for boundary expansion compensation, ensuring that all potentially intersecting meshes are associated. The expansion amount is recorded for subsequent rapid updates, avoiding redundant calculations.

[0070] S202, the step of mapping the spatial coordinates of three-dimensional mesh cells to a hash table to construct a one-dimensional index for the spatial mesh includes...

[0071] S2021 maps the three-dimensional spatial coordinates of grid cells to a one-dimensional index of a hash table, enabling efficient spatial queries. See also... Figure 4 In its implementation, a weighted combination of discretized grid coordinates is performed using prime-number multiplication hashing to generate a unique hash value. This hash design reduces hash collisions while ensuring uniform memory distribution. For example:

[0072] Convert any point P(x,y,z) within the scene to normalized coordinates relative to the global bounding box; and calculate the integer mesh index based on the dynamically partitioned voxel size Vsize to obtain the voxel mesh index. A specific calculation example is as follows:

[0073] Prime number multiplication hash function processing:

[0074] Use 32-bit prime numbers p1=2654435761, p2=2246822519, p3=3266489917;

[0075] Perform hash calculation: H(vx,vy,vz)=(vx·p1+vy·p2+vz·p3)mod m,

[0076] Where m is the capacity of the hash table, ensuring uniform distribution.

[0077] S2022 uses an XOR operation to merge and compress hash values, then takes the modulo to obtain compact hash keys. This method maximizes the distribution of data and reduces the probability of collisions, thus optimizing memory layout. An example is shown below:

[0078] Assume the three-dimensional coordinates of a certain grid are (vx=12, vy=8, vz=5), and select prime numbers p1=2654435761, p2=2246822519, p3=3266489917. The hash table capacity is m=2^20=1048576 (approximately 1 million entries, balancing memory and collision rate).

[0079] Calculate the weighted values ​​of each component:

[0080] vx×p1=12×2654435761=31853229132;

[0081] vy×p2=8×2246822519=17974580152;

[0082] vz×p3=5×3266489917=16332449585;

[0083] XORing to combine three-dimensional components: 31853229132 XOR 17974580152 = 19628424268 (bit flipping and scattering);

[0084] 19628424268 XOR 16332449585 = 3545985845;

[0085] Modulo operation generates hash keys:

[0086] 3545985845 mod 1048576=3545985845-3381×1048576=3545985845-3544331456=1654389;

[0087] The final hash key is 1654389, which is within the capacity of the hash table and is significantly different from the hash keys of neighboring coordinates (such as (13,8,5)) due to the prime number weighting and XOR operation.

[0088] S2023, see also Figure 5 When traversing the hash table, hardware prefetch instructions are inserted at fixed intervals to preload data that may be needed later into the CPU cache for data prefetching.

[0089] Hardware prefetch instructions are inserted at fixed intervals: such as the CPU's PREFETCH instruction, which preloads hash entries that may be accessed later into a custom L3 cache, reducing memory access latency. An example is shown below:

[0090] When the ray passes through a continuous grid, the hash table access order is k=5→k=12→k=19→k=26→... (with an interval of 7 entries). The traversal logic is:

[0091] When processing k=5, prefetch entries for k=5+4=9 and k=5+8=13 (based on hardware prefetching of optimal distance).

[0092] When processing k=12, prefetch entries for k=12+4=16 and k=12+8=20.

[0093] Due to the continuity of the ray path, entries such as k=9 and 13 will inevitably be accessed in the subsequent 2-3 traversals. At this point, they have been prefetched into the third-level cache, and the access latency has been reduced from 100ns to 10ns.

[0094] S203, correctly associating the triangular faces of the processed mesh model with the spatial mesh, is fundamental to ensuring query integrity. This includes the following steps:

[0095] S2031 calculates the axis-aligned bounding box (AABB) for each triangular facet and performs a slight expansion using the rounding rules of floating-point operations, such as expanding by 1e-5 units, to avoid missed detections due to precision errors.

[0096] S2032 maps the bounding box of the triangular facet to the mesh coordinate system, traversing all covered mesh cells. For example, if a triangle spans meshes 3 to 5 on the X-axis, it is associated with all overlapping Y and Z cells under these three X-mesh grids.

[0097] S2033 constructs a two-level linked list index. The main hash table stores index pointers, serving as the entry point for the secondary linked list, and does not directly store triangle facet data. The secondary linked list stores triangle facet association information, enabling chained management of multiple facets. The secondary linked list is the facet data carrier directly associated with the 3D mesh unit. Each linked list node stores only two types of core information: the triangle facet ID and a pointer to the next node, forming a chain structure through pointers. When inserting a new triangle, atomic operations are used to update the head of the linked list to ensure safety under multi-threading.

[0098] The two-level linked list index achieves fast indexing through a hash table, and flexibly stores multiple faces associated with a single grid cell through a linked list, avoiding information loss caused by hash collisions, while reducing the memory usage of the main table.

[0099] In step S3, the ray to be intersected is decomposed into direction parameters, and the direction vector of the ray is discretized to construct a ray direction hash, including...

[0100] S301 addresses the storage challenge of handling an infinite number of directions in 3D space by converting ray directions into manageable discrete data. This involves transforming an infinite number of ray directions in 3D space into a finite set of discrete codes, ensuring accuracy in critical areas while reducing storage and computational costs. Specifically:

[0101] First, perform direction parameter decomposition, see [link to relevant documentation] Figure 6 The three-dimensional direction is decomposed into two angular parameters: polar angle θ and azimuth angle φ. Polar angle θ represents the angle with the vertical axis, and azimuth angle φ represents the horizontal rotation angle. The direction of the ray in the spherical coordinate system can be uniquely determined by the parameters polar angle θ and azimuth angle φ.

[0102] The polar angle θ and azimuth angle φ are divided into grid regions of different densities. The center region of the viewpoint is divided with a high precision of 0.1 degrees, the edge region is divided with a coarse precision of 5 degrees, and the intermediate transition region adopts a gradient division strategy. The center region of the viewpoint is the area within about 30 degrees, and the edge region is the area beyond 60 degrees.

[0103] Each direction is ultimately encoded as a 16-bit numerical identifier, where the first 8 bits represent the base region number, and the last 8 bits record the offset of the subdivided position. The base region is one of the eight spatial divisions, and the subdivided position is the corresponding specific azimuth, angle, distance, etc. Each discrete direction is encoded as a 16-bit number, achieving standardized storage and fast comparison, converting abstract angles into directly calculable numbers, facilitating subsequent indexing and matching in the hash table.

[0104] Furthermore, when the orientation changes are discontinuous, octahedral mapping technology is used to compress spherical coordinates into a two-dimensional plane, and a non-uniform sampling algorithm is used to dynamically adjust the mesh density. When the viewpoint is focused on a certain area, the mesh in that area is subdivided into 8 levels in real time, generating more refined orientation units. To ensure a natural transition between different areas, a geometric smoothing algorithm is used to interpolate the boundaries of adjacent meshes, so that no obvious discontinuities occur when the orientation changes.

[0105] Data updates employ an incremental write strategy, modifying only the affected regions. When a new direction is added, the closest existing direction is first matched at the base layer. If the deviation exceeds a threshold, a new entry is created at the difference layer, and finally, outliers are recorded at the special layer. The read process proceeds in reverse, corresponding to the incremental strategy of base layer, difference layer, and special layer during writing, specifically as follows:

[0106] Prioritize querying special layers. First, search the special layers that store abnormal direction data. If an abnormal entry that matches the current ray hash key exists, directly extract the complete 16-bit direction code.

[0107] Secondary query difference layer: If there is no match in the special layer, query the difference layer and compare the existing direction entries with the direction deviation of the current ray, that is, calculate the difference between the polar angle and the azimuth angle. If the deviation is ≤ the preset threshold (0.5 degrees), reuse the entry and correct the direction parameters.

[0108] Finally, query the base layer: If there is no match in the difference layer, match the closest base region number in the base layer that stores the direction data of the eight base regions, and combine it with the last 8 bits of the subdivision position offset to calculate the complete polar angle θ (base region polar angle range starting value + offset × subdivision accuracy) and azimuth angle φ (base region azimuth angle range starting value + offset × subdivision accuracy) to restore the ray direction parameters.

[0109] S302, Design a composite hash key for each discretized ray to generate a unique hash identifier;

[0110] See Figure 7 Each ray is uniquely identified by a combination of a 24-bit spatial location hash and an 8-bit directional feature code. The spatial location hash is generated using Morton codes for three-dimensional coordinates, converting the coordinates of the contact points on the object's surface into a linear sequence. The directional feature code combines the first 5 bits of the polar angle θ and the last 3 bits of the azimuth angle φ to ensure continuous encoding for similar directions. This 32-bit composite key retains both spatial location information and directional features.

[0111] Furthermore, a dual verification mechanism is used to prevent hash collisions. When two different rays generate the same key value, the complete 16-bit data of the direction encoding is compared first. If the direction encoding is still the same, a secondary hash calculation of the spatial location is initiated. The backup hash function for the secondary hash calculation uses the prime shift method, which multiplies the original coordinates by a large prime number and then takes the modulus again.

[0112] In step S4, a hybrid intersection calculation is performed using a combination of multi-level cache lookup, directional pruning, and spatial hash traversal to determine the intersection point information between the ray and the geometry. This includes...

[0113] S401, see S401. Figure 8By constructing a multi-level cache and performing cache queries, redundant calculations are reduced, improving the efficiency of ray intersection calculations. This includes...

[0114] S4011, construct a multi-level cache, and perform fast lookups in the multi-level cache based on the generated ray direction hash key;

[0115] The system consists of two caches: a first-level cache storing frequently used intersection results for the current frame and a second-level cache storing high-frequency intersection results from historical records. Based on the ray hash key, a fast match is first performed in the first-level cache. If a match is found, the corresponding intersection information is directly extracted. If no match is found, the second-level cache is further queried. If a match is found, the corresponding intersection information is directly extracted, ensuring that existing calculation results are reused as much as possible.

[0116] When a cache miss occurs, a fuzzy matching strategy is employed to search for cache entries in adjacent directions (e.g., ±5 degrees). The closest valid result is selected, and coordinate deviations are corrected through interpolation. Simultaneously, a background thread asynchronously pre-calculates intersection results in adjacent directions and fills the cache pool, potentially accelerating subsequent ray casting. This method is particularly suitable for scenes with smooth viewpoint changes in consecutive frames, such as camera movement or object rotation, and can significantly improve cache hit rates.

[0117] S4012, verify the timeliness and geometric consistency of the results after a cache hit;

[0118] First, check if the ray's starting point is located in front of the intersection point recorded in the cache to avoid misjudgments due to object movement or changes in viewpoint. Second, compare the version number of the current dynamic mesh cell with the version number of the cached record. If the versions are inconsistent, for example, if the mesh cell has been dynamically updated, the cache is deemed invalid. For partially invalid entries, only local data needs to be updated instead of the global cache, reducing computational overhead. If the verification passes, the intersection point data is returned directly, significantly reducing the time required to calculate the intersection.

[0119] S402 utilizes voxel normal vector statistics and preprocessing to quickly determine ray direction and acceleration orientation, skipping invalid intersections in advance. Specifically, this includes...

[0120] S4021, Voxel Normal Vector Statistics and Preprocessing. The Voxel-Based Method is a core spatial discretization technique in computer graphics and 3D spatial analysis. The principle is to divide the continuous 3D scene space into a large number of discrete, regular cubic units, i.e., voxels, which are analogous to pixels in 2D space. Each voxel, as an independent spatial unit, stores three types of key information: (1) Geometric information: the ID of the triangle facet contained in the voxel, the statistical value of the facet vertex normal vector, such as the average normal vector; (2) Attribute information: the static / dynamic status identifier of the voxel, valid / invalid (e.g., voxels inside a closed wall are marked as invalid); (3) Association information: the hash index pointing to the spatial grid unit to which it belongs, and the topological relationship with adjacent voxels. The core value of the voxel method is to transform the complex "ray-3D geometry intersection" into "ray-discrete voxel traversal", reducing the complexity of spatial retrieval, and providing basic support for directional pruning and parallel computing.

[0121] During the construction phase, each dynamically updated voxel calculates the average normal vector of all its internal faces. By accumulating and normalizing the face normal vectors, the "average normal vector" representing the overall orientation of the voxel is obtained. This process is completed asynchronously when the voxel data is updated, ensuring the efficiency of real-time queries. For completely closed voxels, such as those inside walls, they are automatically marked as "invalid voxels" and skipped in subsequent traversals.

[0122] 4022, Rapid determination of ray direction and voxel orientation

[0123] When a ray enters a voxel, the dot product of its direction vector and the voxel's average normal vector is calculated. If the dot product is greater than a preset threshold (e.g., close to -0.01), it indicates that the ray's direction is nearly perpendicular to the voxel's overall orientation or directly facing the front, and the voxel is retained for detailed intersection calculation. If the dot product is less than the threshold, it is determined that the ray entered the voxel from the back, and it is highly unlikely to hit a valid facet, so it is skipped directly. This process is completed in the initial stage of the traversal loop to avoid loading and calculating faces of invalid voxels.

[0124] S4023, Dynamic Scene Adaptive Optimization

[0125] For dynamic objects, such as a rotating robotic arm, the average voxel normal vector is updated in real time as the object moves. A version number mechanism is then used to ensure the timeliness of pruning decisions.

[0126] If a voxel's inner facet rotates or shifts, its version number increments and triggers a recalculation of the normal vector. Simultaneously, for voxels with drastic deformation, such as cloth simulations, directional pruning is temporarily disabled to prevent misjudgments caused by drastic changes in the normal vector.

[0127] S403 utilizes a dynamic hash grid and the 3DDA algorithm to efficiently traverse the scene space and perform intersection calculations between rays and patches. This includes...

[0128] S4031, Scene Bounding Box Intersection Test and Mesh Localization

[0129] Before a ray enters the scene, it undergoes a rapid intersection test with the global bounding box (AABB) to eliminate invalid rays. If the ray does not intersect the bounding box, the calculation terminates prematurely; if it intersects, the coordinates of the initial traversed grid cells are determined based on the ray's origin and direction, combined with the resolution of the dynamic hash grid. This process quickly locates the first grid cell to be visited by calculating the distance from the ray's origin to the grid boundary, laying the foundation for subsequent traversals.

[0130] S4032, 3DDA Algorithm Implementation and Mesh Traversal

[0131] A trilinear difference analysis (3DDA) algorithm is employed to progressively visit mesh cells along the ray path. Compared to traditional 3DDA algorithms, this approach optimizes stepping accuracy and reduces the number of empty mesh traversals. The 3DDA algorithm dynamically selects the stepping order based on the ray direction components along each axis, prioritizing movement along the nearest axis to ensure optimal traversal path optimization. After each step, a hash table is consulted to retrieve the list of faces for the current mesh cell, and face-level intersection tests are performed. During traversal, the global bounding box (AABB) is used to determine whether to stop stepping.

[0132] S4033, Patch Intersection Optimization and Dynamic Response

[0133] The intersection of faces within a mesh cell employs a hierarchical filtering strategy. First, bounding boxes are used to quickly eliminate most non-intersecting candidate faces. Then, the Möller-Trumbore algorithm is used to accurately find the intersections of the remaining faces, outputting the coordinates and / or attributes of the intersection points. Attributes include face association information, geometric properties, material and physical properties, and status indicators. To improve throughput, face testing uses SIMD instructions to process multiple faces in parallel. If a mesh cell is detected to have changed faces due to dynamic updates, the cell is marked as "dirty data," triggering asynchronous reconstruction and associated cache invalidation to ensure the accuracy of subsequent ray traversal.

[0134] Step S5 proposes a composite dynamic solution based on incremental updates, version consistency, and resource scheduling optimization to achieve efficient updates and real-time responses when the mesh changes dynamically, such as object movement, deformation, and addition / deletion. This method maintains the stability of the hash-accelerated structure while ensuring low latency and high throughput in dynamic scenarios through multi-level cache lookups, asynchronous computation, and priority strategies. This includes...

[0135] S501 identifies dynamic mesh regions and marks hash slots through kinematic feature analysis; including,

[0136] Triangles whose vertex displacement exceeds a threshold (e.g., 0.1% of the bounding box size) are marked as "dynamic units," and their corresponding hash slots are labeled as "dirty data." For rigid body motion, bounding box trajectory prediction is used to pre-mark hash slots that may be covered in future frames. For flexible deformations such as cloth or fluids, a spatiotemporal influence domain is established based on the vertex velocity field, dynamically expanding the area to be updated. All marking operations are executed asynchronously in independent threads to avoid blocking the main ray traversal process.

[0137] S502, for hash slots marked as dirty data, perform incremental refresh and reconstruction of the local hash structure, including,

[0138] Remove all faces from the original slot and re-insert the dynamic element according to the latest spatial coordinates. See [link / reference]. Figure 9 Only the mesh cells affected by dynamic objects are updated (shown as black boxes in the diagram). Old data is removed and new data is added to avoid global reconstruction where the mesh cells containing static objects remain unchanged, thus reducing computational overhead. Simultaneously, to reduce lock contention, a sharding mechanism is used, dividing the hash table into 1024 logical shards. Each shard is bound to an independent read-write lock, ensuring that only conflicting shards are serialized during multi-threaded updates.

[0139] Furthermore, a delayed merging strategy is introduced. For slots with high-frequency updates, such as those of rotating robotic arms, two sets of data copies, old and new, are retained and distinguished by version number. The data is then merged asynchronously after the update is stable, reducing instantaneous computational pressure.

[0140] S503, see S503. Figure 10 During partial update and reconstruction, an independent memory sandbox is allocated to each hash update thread. Its virtual address space is isolated from the main process. Update threads run within this independent sandbox, where exceptions only affect partial updates, do not pollute the global hash table, and do not cause the main process to crash. Exceptions within the sandbox include buffer overflows. Memory out-of-bounds errors are monitored in real-time before and after critical data structures, triggering thread-level restarts instead of process crashes in the event of an exception, thus improving stability.

[0141] The above description of the embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

[0142] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0143] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.

Claims

1. A grid ray intersection method based on multi-dimensional hash acceleration, used in architectural design, characterized in that, include, Obtain raw model data, including mesh model data and / or parametric model data, and perform standardized preprocessing on the raw model data to obtain standardized scene data; Adaptive spatial meshing is performed based on preprocessed standardized scene data. The spatial coordinates of the three-dimensional mesh units are mapped to a hash table to construct a one-dimensional index of the spatial mesh, and the triangular patches of the scene data are associated with the spatial mesh. The ray to be intersected is decomposed into directional parameters, the ray's direction vector is discretized, and a composite hash key for the ray direction is constructed. Hybrid intersection calculations are performed by combining multi-level cache lookup, directional pruning to filter invalid intersections, and spatial hash traversal intersection calculations to determine the intersection information between rays and geometry. The spatial hash traversal intersection calculation utilizes a dynamic hash grid and the 3DDA algorithm to efficiently traverse the scene space and perform intersection calculations between rays and faces. Determine whether the ray to be intersected intersects with the global bounding box. If the ray does not intersect with the bounding box, terminate the calculation early. If they intersect, determine the coordinates of the grid cells to be traversed initially based on the ray's origin and direction, combined with the resolution of the dynamic hash grid. The 3DDA algorithm of trilinear difference analysis is used to access the mesh cells along the ray path. The stepping order is dynamically selected according to the components of the ray direction on each coordinate axis, and priority is given to moving along the axis with the shortest distance. After each step, the hash table is queried to obtain the list of faces of the current mesh cell, and face-level intersection test is performed. During the traversal, the global bounding box AABB is used to determine whether to stop stepping. To perform intersection calculations on the faces within the grid cells, firstly, the bounding boxes of the faces are used to quickly eliminate most of the non-intersecting candidate faces. Then, the Möller-Trumbore algorithm is used to accurately find the intersections of the remaining faces to obtain the intersection point information.

2. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The standardization preprocessing of the original model data includes, The parametric model is converted into a mesh model based on the transformation relationship between the parametric model and the corresponding mesh model stored in the parametric model. The acquired mesh model and the parameter model that have been converted into a mesh model are processed in a unified manner, including converting all model coordinates to the scene global coordinate system and performing coordinate normalization. Remove degenerate faces with an area smaller than a preset threshold from the mesh model for redundancy elimination; Perform global bounding box calculation to generate the smallest axis-aligned bounding box (AABB) containing all models.

3. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The adaptive spatial grid partitioning based on preprocessed standardized scene data includes... The overall bounding box of the scene data is initially segmented using an octree, and the number of facets per unit volume in each sub-region is counted to obtain the triangle facet density. Set upper and lower limits for density thresholds, and dynamically adjust the grid size based on local density. When the density of a patch in a certain area is higher than the average, reduce the grid size, and vice versa.

4. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The step of mapping the spatial coordinates of three-dimensional grid cells to a hash table to construct a one-dimensional index of the spatial grid includes weighting the discretized grid coordinates using prime number multiplication hashing to generate a unique hash value.

5. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The step of associating the triangular patches of scene data with the spatial grid includes, For each triangular facet, calculate its axis-aligned bounding box (AABB) and perform minor expansions using the rounding rules of floating-point operations to avoid missed detections due to precision errors. Map the bounding box of the triangular facet to the grid coordinate system and traverse all covered grid cells; A two-level linked list index is constructed. The main hash table stores the index pointers, which serve as the entry points for the secondary linked list. The secondary linked list stores the triangular facet association information, thus realizing the chained management of multiple facets.

6. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The process of decomposing the ray to be intersected, discretizing the ray's direction vector, and constructing a composite hash key for the ray direction includes: The direction parameter is decomposed into three-dimensional direction into polar angle θ and azimuth angle φ: polar angle θ represents the angle with the vertical axis, and azimuth angle φ represents the horizontal rotation angle; Based on the polar angle θ and azimuth angle φ, each direction is ultimately encoded as a 16-bit digital identifier, where the first 8 bits represent the base area number and the last 8 bits record the offset of the subdivided position. For each discretized ray direction, a composite bond is designed to generate a unique hash identifier; the unique hash identifier includes a 24-bit spatial position hash and an 8-bit direction feature code. The spatial position hash is obtained based on the Morton code of three-dimensional coordinates, which converts the coordinates of the contact point on the object surface into a linear sequence; the direction feature code is generated by combining the first 5 bits of the polar angle θ and the last 3 bits of the azimuth angle φ.

7. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The multi-level cache query involves constructing a multi-level cache and performing fast queries within the multi-level cache based on the generated ray direction hash key. The first-level cache stores frequently used intersection results for the current frame, while the second-level cache stores high-frequency intersection results from historical records. Based on the ray hash key, a fast match is first performed in the first-level cache. If a match is found, the corresponding intersection point information is directly extracted. If no match is found, the second-level cache is further queried. If a match is found in the second-level cache, the corresponding intersection point information is directly extracted. If no match is found, cache entries in adjacent directions are searched, the closest valid result is selected, and coordinate deviations are corrected through interpolation.

8. The grid ray intersection method based on multi-dimensional hash acceleration according to claim 1, characterized in that, The directional pruning filtering of invalid intersections utilizes voxel-based vector statistics and preprocessing. This includes accumulating and normalizing the normal vectors of facets to obtain the average normal vector representing the overall orientation of the voxel; calculating the dot product between the direction vector of the ray to be intersected and the average normal vector of the voxel; if the dot product is greater than a preset threshold, it indicates that the ray direction is nearly parallel to or directly facing the voxel's overall orientation, and the voxel is retained for detailed intersection calculation; if the dot product is less than the threshold, it is determined that the ray enters the voxel from the back, and the ray to be intersected will not hit a valid facet, and is skipped.

9. The grid ray intersection method based on multi-dimensional hash acceleration according to any one of claims 1-8, characterized in that, It also includes acquiring information on dynamic changes in the grid, and incrementally refreshing the local hash structure by detecting dynamic regions and hash key markers. The process of acquiring dynamic mesh change information involves identifying dynamic mesh regions and marking hash slots through kinematic feature analysis; for rigid body motion, bounding box trajectory prediction is used to pre-mark hash slots that may be covered in future frames; for flexible deformation, a spatiotemporal influence domain is established based on the vertex velocity field, and the region to be updated is dynamically expanded. The incremental refresh of the local hash structure involves removing all faces from the original hash slot marked as dirty data and re-inserting the dynamic unit according to the latest spatial coordinates.

Citation Information

Patent Citations

  • Hybrid collision detection method in virtual operation simulation system

    CN119600227A